Skip to content

Commit

Permalink
Fix/rdv regressions on treatment (#40690)
Browse files Browse the repository at this point in the history
* RDV: Fix regressions for Duplicate views

* RDV: Fix regressions for Duplicate views

* Add docblock.

* Select Calypso Stats menu for post stats and fix the upsell upgrade nudge styling.

* Linting
  • Loading branch information
BogdanUngureanu authored Dec 20, 2024
1 parent b414852 commit c98bbfd
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fixed several regressions for Stats, Blaze and notices for RDV experiment
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public static function load_verbum_comments_admin() {
* Load Odyssey Stats in Simple sites.
*/
public static function load_wpcom_simple_odyssey_stats() {
if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) {
if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' || wpcom_is_duplicate_views_experiment_enabled() ) {
require_once __DIR__ . '/features/wpcom-simple-odyssey-stats/wpcom-simple-odyssey-stats.php';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ function wpcom_replace_edit_profile_menu_to_me( $wp_admin_bar ) {
* @return string Name of the admin bar class.
*/
function wpcom_custom_wpcom_admin_bar_class( $wp_admin_bar_class ) {
if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) {
remove_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
$is_wp_admin = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option', 10 );

if ( $is_wp_admin ) {
return $wp_admin_bar_class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Connection\Manager as Jetpack_Connection;
use Automattic\Jetpack\Jetpack_Mu_Wpcom;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;

/**
Expand Down Expand Up @@ -118,8 +119,6 @@ function ( $location ) {

const WPCOM_DUPLICATED_VIEW = array(
'edit.php',
'admin.php?page=stats',
'tools.php?page=advertising',
'edit.php?post_type=jetpack-portfolio',
'edit.php?post_type=jetpack-testimonial',
'edit-comments.php',
Expand Down Expand Up @@ -548,3 +547,63 @@ function wpcom_dismiss_removed_calypso_screen_notice() {
wp_die();
}
add_action( 'wp_ajax_wpcom_dismiss_removed_calypso_screen_notice', 'wpcom_dismiss_removed_calypso_screen_notice' );

/**
* Enable the Blaze dashboard (WP-Admin) for users that have the RDV experiment enabled.
*
* @param bool $activation_status The activation status - use WP-Admin or Calypso.
* @return mixed|true
*/
function wpcom_enable_blaze_dashboard_for_experiment( $activation_status ) {
if ( ! wpcom_is_duplicate_views_experiment_enabled() ) {
return $activation_status;
}

return true;
}

add_filter( 'jetpack_blaze_dashboard_enable', 'wpcom_enable_blaze_dashboard_for_experiment' );

/**
* Make the Jetpack Stats page to point to the Calypso Stats Admin menu - temporary. This is needed because WP-Admin pages are rolled-out individually.
*
* This should be removed when the sites are fully untangled (or with the Jetpack Stats).
*
* This is enabled only for the stats page for users that are part of the remove duplicate views experiment.
*
* @param string $file The parent_file of the page.
*
* @return mixed
*/
function wpcom_select_calypso_admin_menu_stats_for_jetpack_post_stats( $file ) {
global $_wp_real_parent_file, $pagenow;

$is_on_stats_page = 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'stats' === $_GET['page'];

if ( ! $is_on_stats_page || ! wpcom_is_duplicate_views_experiment_enabled() ) {
return $file;
}

remove_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
$is_using_wp_admin = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
if ( function_exists( 'wpcom_admin_interface_pre_get_option' ) ) {
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
}

if ( $is_using_wp_admin ) {
return $file;
}

if ( ! wpcom_get_custom_admin_menu_class() ) {
return $file;
}

/**
* Not ideal... We shouldn't be doing this.
*/
$_wp_real_parent_file['jetpack'] = 'https://wordpress.com/stats/day/' . ( new Status() )->get_site_suffix(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

return $file;
}

add_filter( 'parent_file', 'wpcom_select_calypso_admin_menu_stats_for_jetpack_post_stats' );
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Jetpack_Mu_Wpcom;

if ( get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
remove_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
$is_wp_admin = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option', 10 );

if ( ! $is_wp_admin ) {
return;
}

Expand Down

0 comments on commit c98bbfd

Please sign in to comment.