bsf_get_current_version( string $template, string $type )
Get current version of plugin / theme.
Description
Always reads from disk — deliberately not cached, because callers on upgrader_process_complete run after the files have changed mid-request.
Parameters
- $template
-
(Required) plugin template/slug.
- $type
-
(Required) type of product.
Return
(float)
Source
File: admin/bsf-core/auto-update/admin-functions.php
function bsf_get_current_version( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$version = $theme->get( 'Version' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$version = $plugin['Version'];
}
return $version;
}
Expand full source code Collapse full source code View on Trac