Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetpack: Display correct Jetpack version in plugins list UI #6043

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading