Skip to content

Commit

Permalink
Jetpack: Display correct Jetpack version in plugins list UI (#6043)
Browse files Browse the repository at this point in the history
* Jetpack: Display correct Jetpack version in plugins list UI

* Display whether loaded locally or mu

* The Vlad way constant

* lint
  • Loading branch information
rebeccahum authored Dec 10, 2024
1 parent 97c10f8 commit c82dc65
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions vip-jetpack/vip-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,29 @@ function vip_jetpack_is_mobile( $matches, $kind, $return_matched_agent ) {
add_filter( 'pre_jetpack_is_mobile', 'vip_jetpack_is_mobile', PHP_INT_MAX, 3 );

/**
* Display correct Jetpack version in wp-admin plugins UI for pinned or local versions.
* Display correct Jetpack version in wp-admin plugins UI for pinned, local or default versions.
*
* @param string[] $plugin_meta An array of the plugin's metadata, including
* the version, author, author URI, and plugin URI.
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
* @param string[] plugin_meta An array of the plugin's metadata, including
* the version, author, author URI, and plugin URI.
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
* @return string[] $plugin_meta Updated plugin's metadata.
*/
function vip_filter_plugin_version_jetpack( $plugin_meta, $plugin_file ) {
if ( ! defined( 'VIP_JETPACK_PINNED_VERSION' ) && ! defined( 'WPCOM_VIP_JETPACK_LOCAL' ) ) {
if ( defined( 'VIP_JETPACK_SKIP_LOAD' ) && constant( 'VIP_JETPACK_SKIP_LOAD' ) ) {
return $plugin_meta;
}

if ( 'jetpack.php' === $plugin_file ) {
$version = defined( 'VIP_JETPACK_LOADED_VERSION' ) ? VIP_JETPACK_LOADED_VERSION : JETPACK__VERSION;
$type = defined( 'WPCOM_VIP_JETPACK_LOCAL' ) && constant( 'WPCOM_VIP_JETPACK_LOCAL' ) ? 'Local' :
'MU-Plugins';
if ( defined( 'VIP_JETPACK_LOADED_VERSION' ) ) {
$version = constant( 'VIP_JETPACK_LOADED_VERSION' );
} else {
$version = constant( 'JETPACK__VERSION' );
}

/* translators: Loaded Jetpack version number */
$plugin_meta[0] = sprintf( esc_html__( 'Version %s' ), $version );
$plugin_meta[0] = sprintf( esc_html__( '%1$s - Version %2$s' ), $type, $version );
}

return $plugin_meta;
Expand Down

0 comments on commit c82dc65

Please sign in to comment.