Skip to content

Commit

Permalink
Load Odyssey Stats for simple sites (#36628)
Browse files Browse the repository at this point in the history
* Load Odyssey Stats for simple sites

* Changelog

* Fix file name to wpcom-simple-odyssey-stats.php

* Make Phan happy

* Run tools/fixup-project-versions.sh to make linter happy

* Add wpcom_is_nav_redesign_enabled check

---------

Co-authored-by: DustyReagan <[email protected]>
  • Loading branch information
candy02058912 and DustyReagan authored Apr 1, 2024
1 parent 0dec4ca commit f8c3448
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
12 changes: 11 additions & 1 deletion projects/packages/jetpack-mu-wpcom/.phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@
// Require base config.
require __DIR__ . '/../../../../.phan/config.base.php';

return make_phan_config( dirname( __DIR__ ) );
$root = dirname( __DIR__, 4 );

return make_phan_config(
dirname( __DIR__ ),
array(
'parse_file_list' => array(
"$root/projects/packages/stats-admin/src/class-dashboard.php",
"$root/projects/plugins/jetpack/class-jetpack-stats-dashboard-widget.php",
),
)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add Odyssey Stats to wpcom Simple Site
10 changes: 10 additions & 0 deletions projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static function init() {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
add_action( 'plugins_loaded', array( __CLASS__, 'load_verbum_comments' ) );
add_action( 'wp_loaded', array( __CLASS__, 'load_verbum_comments_admin' ) );
add_action( 'plugins_loaded', array( __CLASS__, 'load_wpcom_simple_odyssey_stats' ) );
}

// Unified navigation fix for changes in WordPress 6.2.
Expand Down Expand Up @@ -278,4 +279,13 @@ public static function load_verbum_comments_admin() {
public static function load_wpcom_command_palette() {
require_once __DIR__ . '/features/wpcom-command-palette/wpcom-command-palette.php';
}

/**
* Load Odyssey Stats in Simple sites.
*/
public static function load_wpcom_simple_odyssey_stats() {
if ( function_exists( 'wpcom_is_nav_redesign_enabled' ) && wpcom_is_nav_redesign_enabled() ) {
require_once __DIR__ . '/features/wpcom-simple-odyssey-stats/wpcom-simple-odyssey-stats.php';
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Load the Odyssey stats feature on WordPress.com Simple Site.
* See https://github.com/Automattic/jetpack/tree/trunk/projects/packages/stats-admin
*
* @package automattic/jetpack-mu-wpcom
*/

use Automattic\Jetpack\Stats_Admin\Dashboard as OdysseyStats;
OdysseyStats::init();

/**
* Load the Odyssey stats widget in the Dashboard.
*/
if ( defined( 'JETPACK_PLUGIN_LOADER_PATH' ) ) {
require_once JETPACK_PLUGIN_LOADER_PATH . '/class-jetpack-stats-dashboard-widget.php';
add_action( 'wp_dashboard_setup', array( new Jetpack_Stats_Dashboard_Widget(), 'init' ) );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


0 comments on commit f8c3448

Please sign in to comment.