Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
902ac2f
drop unregistered widget types from defaults
retrofox Sep 28, 2026
d53f902
declare the layout before the try in the init test
retrofox Sep 28, 2026
ccc7410
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 28, 2026
cbc3bf5
carry former names on widget types
retrofox Sep 28, 2026
ae0bccb
treat a non-string default instance type as unknown
retrofox Sep 28, 2026
7a4c2c0
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 28, 2026
fca2e66
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 28, 2026
a61759c
keep the malformed-type test within the helper's types
retrofox Sep 28, 2026
03114b5
expose the leaderboard primitives through the SDK
retrofox Sep 28, 2026
b185baf
move the Top videos widget to packages/videopress
retrofox Sep 29, 2026
24ff4ea
register Top videos on wpcom by plan feature
retrofox Sep 29, 2026
7dd1ca8
normalize former names in the registry
retrofox Sep 29, 2026
d95ee7d
Merge branch 'update/pa-extensibility-videopress-former-names' into u…
retrofox Sep 29, 2026
ed158c7
Merge branch 'update/pa-extensibility-videopress-sdk-exports' into up…
retrofox Sep 29, 2026
2cc3148
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 29, 2026
2f3777c
Merge branch 'update/pa-extensibility-videopress-former-names' into u…
retrofox Sep 29, 2026
e0e0a46
Merge branch 'update/pa-extensibility-videopress-sdk-exports' into up…
retrofox Sep 29, 2026
43a1d7e
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 29, 2026
0063b48
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 29, 2026
8c74142
Merge branch 'update/pa-extensibility-videopress-former-names' into u…
retrofox Sep 29, 2026
b8825b6
Merge branch 'update/pa-extensibility-videopress-sdk-exports' into up…
retrofox Sep 29, 2026
700bbec
expose the leaderboard primitives through the SDK
retrofox Sep 28, 2026
76b5f1d
Merge remote-tracking branch 'origin/update/pa-extensibility-videopre…
retrofox Sep 30, 2026
c76b93e
expose the leaderboard primitives through the SDK
retrofox Sep 28, 2026
41513e7
fix phan on the VideoPress registrant
retrofox Sep 30, 2026
629974b
stub the generated manifest accessor for phan
retrofox Sep 30, 2026
0718d6f
give the phan stub a body phpcs accepts
retrofox Sep 30, 2026
f0a8a61
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Sep 30, 2026
0774978
expose Leaderboard through the SDK, not its pieces
retrofox Sep 30, 2026
5dc8704
Merge branch 'update/pa-extensibility-videopress-sdk-exports' into up…
retrofox Sep 30, 2026
d112699
remove the orphaned video helpers from the toolkit
retrofox Sep 30, 2026
938146e
test the Top videos render against a stand-in SDK
retrofox Sep 30, 2026
970e2e1
test the video plays hook directly
retrofox Sep 30, 2026
459dd3a
keep the widget row limit out of the SDK
retrofox Sep 30, 2026
f5d6490
Merge branch 'update/pa-extensibility-videopress-sdk-exports' into up…
retrofox Sep 30, 2026
f62bfb8
size the Top videos request in the widget
retrofox Sep 30, 2026
9cc245e
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Oct 1, 2026
d6fe131
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Oct 1, 2026
7af01a5
feed the test manifest through the host filter
retrofox Oct 1, 2026
d7fabb7
Merge remote-tracking branch 'origin/trunk' into update/pa-extensibil…
retrofox Oct 2, 2026
e3b6bdf
expose the CSV download action through the SDK
retrofox Oct 2, 2026
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
24 changes: 24 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Declare the CSV download action of the linked report.
1 change: 1 addition & 0 deletions projects/js-packages/premium-analytics-sdk/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export declare function useWidgetRootContext(): any;
export declare const WidgetState: AnyComponent;
export declare const WidgetFooter: AnyComponent;
export declare const ReportLink: AnyComponent;
export declare const ExporterCsvDownloadButton: AnyComponent;
export declare function describeError( ...args: any[] ): any;

// Charts and metrics.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Premium Analytics: Register the Top videos widget on Simple and Atomic from the VideoPress package.
6 changes: 4 additions & 2 deletions projects/packages/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"brain/monkey": "^2.6.2",
"automattic/phpunit-select-config": "@dev",
"automattic/jetpack-premium-analytics": "@dev",
"automattic/jetpack-ads": "@dev"
"automattic/jetpack-ads": "@dev",
"automattic/jetpack-videopress": "@dev"
},
"suggest": {
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
Expand Down Expand Up @@ -98,7 +99,8 @@
"dependencies": {
"test-only": [
"packages/premium-analytics",
"packages/ads"
"packages/ads",
"packages/videopress"
]
}
},
Expand Down
14 changes: 14 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 @@ -140,6 +140,9 @@ public static function init() {
// Premium Analytics offers the Ads tab on Simple and Atomic sites whose plan includes WordAds and that have it on.
add_action( 'plugins_loaded', array( __CLASS__, 'load_premium_analytics_wordads_section' ) );

// Premium Analytics seeds the Top videos widget wherever the plan includes VideoPress, on Simple and Atomic.
add_action( 'plugins_loaded', array( __CLASS__, 'load_premium_analytics_videopress_widgets' ) );

// Unified navigation fix for changes in WordPress 6.2.
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'unbind_focusout_on_wp_admin_bar_menu_toggle' ) );

Expand Down Expand Up @@ -925,6 +928,17 @@ public static function load_premium_analytics_wordads_section() {
require_once __DIR__ . '/features/premium-analytics/wordads-section.php';
}

/**
* Register the Top videos widget of the Premium Analytics dashboard by plan feature.
*
* Same seam as the Ads tab: inert on a site without the dashboard.
*
* @since $$next-version$$
*/
public static function load_premium_analytics_videopress_widgets() {
require_once __DIR__ . '/features/premium-analytics/videopress-widgets.php';
}

/**
* Load the Jetpack Custom CSS feature.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* The Top videos widget of the Premium Analytics dashboard on the WordPress.com platform.
*
* Simple runs no Jetpack plugin, and on Atomic the VideoPress module is routinely off while the plan
* includes VideoPress, so the plan feature decides here and the package registrant skips the platform.
* The widget comes from the jetpack-videopress package, which the Jetpack plugin bundles: WordPress.com
* loads that copy, so this package does not.
*
* @package automattic/jetpack-mu-wpcom
*/

use Automattic\Jetpack\VideoPress\Analytics_Dashboard;

/**
* Whether the site's plan includes VideoPress, and the package that owns the widget is here.
*
* @since $$next-version$$
*
* @return bool
*/
function wpcom_premium_analytics_site_has_videopress() {
return function_exists( 'wpcom_site_has_feature' )
&& wpcom_site_has_feature( 'videopress' )
&& class_exists( Analytics_Dashboard::class );
}

/**
* Register the Top videos widget type on a site whose plan includes VideoPress.
*
* @since $$next-version$$
*
* @param \Automattic\Jetpack\PremiumAnalytics\Widget_Type_Registry $registry The registry being hydrated.
* @return void
*/
function wpcom_premium_analytics_register_videopress_widget_types( $registry ) {
if ( ! wpcom_premium_analytics_site_has_videopress() ) {
return;
}

Analytics_Dashboard::register_widget_types( $registry );
}

/**
* Seed the Top videos instance into the Traffic default layout on a site whose plan includes VideoPress.
*
* @since $$next-version$$
*
* @param array $layout The section's default widget instances.
* @param string $section_id Namespaced section identifier.
* @return array
*/
function wpcom_premium_analytics_seed_videopress_default_layout( $layout, $section_id ) {
if ( ! wpcom_premium_analytics_site_has_videopress() ) {
return $layout;
}

return Analytics_Dashboard::add_default_layout_instance( $layout, $section_id );
}

// After the package's own registrant (priority 10); the seed runs before the dashboard's policy at 100.
add_action( 'jetpack_premium_analytics_register_widget_types', 'wpcom_premium_analytics_register_videopress_widget_types', 20 );
add_filter( 'jetpack_premium_analytics_dashboard_default_layout', 'wpcom_premium_analytics_seed_videopress_default_layout', 10, 2 );
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ function_exists( 'wpcom_site_has_feature' ) &&
class_exists( '\WPCOM_Features' ) &&
wpcom_site_has_feature( \WPCOM_Features::VIDEOPRESS )
) {
// @phan-suppress-next-line PhanUndeclaredClassMethod -- class_exists guarded above; provided by sibling autoloader.
\Automattic\Jetpack\VideoPress\Admin_UI::add_wp_admin_submenu();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ function wpcom_videopress_init_admin_ui() {
return;
}

// @phan-suppress-next-line PhanUndeclaredClassMethod -- class_exists guarded above; provided by the sibling autoloader (bundled Jetpack on Simple).
\Automattic\Jetpack\VideoPress\Admin_UI::init();

// Emit the JPVIDEOPRESS_INITIAL_STATE boot payload the wp-build dashboard hydrates from.
if ( class_exists( '\Automattic\Jetpack\VideoPress\Initial_State' ) ) {
// @phan-suppress-next-line PhanUndeclaredClassMethod -- class_exists guarded above; provided by the sibling autoloader (bundled Jetpack on Simple).
\Automattic\Jetpack\VideoPress\Initial_State::init();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
/**
* Tests for the Top videos registrants on the WordPress.com platform.
*
* @package automattic/jetpack-mu-wpcom
*/

use Automattic\Jetpack\Jetpack_Mu_Wpcom;
use Automattic\Jetpack\PremiumAnalytics\Widget_Type_Registry;
use Automattic\Jetpack\VideoPress\Analytics_Dashboard;
use Brain\Monkey\Functions;
use PHPUnit\Framework\Attributes\CoversFunction;
use const Automattic\Jetpack\PremiumAnalytics\REGISTRABLE_WIDGET_TYPES_FILTER;

// Required by path, like the section API below: the vendored classmap predates these classes.
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'vendor/automattic/jetpack-premium-analytics/src/class-capabilities.php';
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'vendor/automattic/jetpack-premium-analytics/src/class-enablement-setting.php';
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'vendor/automattic/jetpack-premium-analytics/src/dashboard-sections.php';
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'vendor/automattic/jetpack-premium-analytics/src/widget-types.php';
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'vendor/automattic/jetpack-videopress/src/class-package-version.php';
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'vendor/automattic/jetpack-videopress/src/class-analytics-dashboard.php';
require_once Jetpack_Mu_Wpcom::PKG_DIR . 'src/features/premium-analytics/videopress-widgets.php';

/**
* The plan feature decides; the VideoPress package registers.
*
* @covers ::wpcom_premium_analytics_register_videopress_widget_types
* @covers ::wpcom_premium_analytics_seed_videopress_default_layout
*/
#[CoversFunction( 'wpcom_premium_analytics_register_videopress_widget_types' )]
#[CoversFunction( 'wpcom_premium_analytics_seed_videopress_default_layout' )]
class Videopress_Widgets_Test extends \WorDBless\BaseTestCase {

/**
* Read a fixture manifest: the vendored package has no build.
*/
public function set_up() {
parent::set_up();
add_filter( REGISTRABLE_WIDGET_TYPES_FILTER, array( $this, 'widget_manifest' ) );
}

/**
* The package's widget, as its build manifest lists it.
*
* @return array[]
*/
public function widget_manifest() {
return array(
array(
'name' => Analytics_Dashboard::TOP_VIDEOS_TYPE,
'dir_name' => 'top-videos',
'title' => 'Top videos',
'category' => 'stats',
'presentation' => 'framed',
'render_module' => 'jetpack-videopress/widgets/top-videos/render',
'widget_module' => 'jetpack-videopress/widgets/top-videos/widget',
'textdomain' => null,
),
);
}

/**
* Reset the widget registry between tests.
*/
public function tear_down() {
remove_filter( REGISTRABLE_WIDGET_TYPES_FILTER, array( $this, 'widget_manifest' ) );
$instance = new ReflectionProperty( Widget_Type_Registry::class, 'instance' );
if ( PHP_VERSION_ID < 80100 ) {
$instance->setAccessible( true );
}
$instance->setValue( null, null );

parent::tear_down();
}

public function test_registrants_hook_after_the_package_registrant_and_before_the_layout_policy() {
$this->assertSame( 20, has_action( 'jetpack_premium_analytics_register_widget_types', 'wpcom_premium_analytics_register_videopress_widget_types' ) );
$this->assertSame( 10, has_filter( 'jetpack_premium_analytics_dashboard_default_layout', 'wpcom_premium_analytics_seed_videopress_default_layout' ) );
}

public function test_registers_the_widget_type_with_the_plan_feature() {
Functions\when( 'wpcom_site_has_feature' )->justReturn( true );
$registry = new Widget_Type_Registry();

wpcom_premium_analytics_register_videopress_widget_types( $registry );

$this->assertNotNull( $registry->get_registered( Analytics_Dashboard::TOP_VIDEOS_TYPE ) );
$this->assertSame( Analytics_Dashboard::TOP_VIDEOS_TYPE, $registry->resolve_name( 'jpa/videopress' ) );
}

public function test_skips_the_widget_type_without_the_plan_feature() {
Functions\when( 'wpcom_site_has_feature' )->justReturn( false );
$registry = new Widget_Type_Registry();

wpcom_premium_analytics_register_videopress_widget_types( $registry );

$this->assertNull( $registry->get_registered( Analytics_Dashboard::TOP_VIDEOS_TYPE ) );
}

public function test_seeds_the_traffic_default_layout_with_the_plan_feature() {
Functions\when( 'wpcom_site_has_feature' )->justReturn( true );

$layout = wpcom_premium_analytics_seed_videopress_default_layout( array(), Analytics_Dashboard::TRAFFIC_SECTION_ID );

$this->assertSame( array( Analytics_Dashboard::TOP_VIDEOS_TYPE ), array_column( $layout, 'type' ) );
}

public function test_leaves_the_traffic_default_layout_alone_without_the_plan_feature() {
Functions\when( 'wpcom_site_has_feature' )->justReturn( false );

$this->assertSame( array(), wpcom_premium_analytics_seed_videopress_default_layout( array(), Analytics_Dashboard::TRAFFIC_SECTION_ID ) );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: removed

Dashboard: Move the Top videos widget to the VideoPress package, which registers it and seeds it into the Traffic section.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Dashboard: Expose the CSV download action of the linked report through the SDK; the widget contract is 1.3.0.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ add_action(
'is_available' => array( Capabilities::class, 'current_user_can_view_analytics' ),
'default_layout' => static function () {
return array(
get_dashboard_default_widget_instance( 'videopress-top-videos', 'jpa/videopress', 0, 3, 2 ),
get_dashboard_default_widget_instance( 'videopress-top-videos', 'videopress/top-videos', 0, 3, 2 ),
);
},
)
Expand Down Expand Up @@ -139,7 +139,7 @@ add_filter(
'jetpack_premium_analytics_dashboard_default_layout',
static function ( $layout, $section_id ) {
if ( 'analytics/traffic' === $section_id ) {
$layout[] = get_dashboard_default_widget_instance( 'videopress-top-videos', 'jpa/videopress', 8, 1, 2 );
$layout[] = get_dashboard_default_widget_instance( 'videopress-top-videos', 'videopress/top-videos', 8, 1, 2 );
}

return $layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ It reads the package's fixed list and, once the registry can answer, the registr

`WIDGET_API_VERSION` names the contract a widget is built against: the `@automattic/jetpack-premium-analytics-sdk` module and the exports it declares, the dashboard modules the facade re-exports from (`@jetpack-premium-analytics/widgets-toolkit`, `data`, `fields`, `datetime`, `externals`), and the `Widget_Type` fields the client reads.

The major changes when a widget built against the previous contract stops working; the minor when a consumer can rely on something new. So far, 1.1.0 added `former_names` and 1.2.0 `Leaderboard`, `describeError()` and `useStatsVideoPlays`.
The major changes when a widget built against the previous contract stops working; the minor when a consumer can rely on something new. So far, 1.1.0 added `former_names` and 1.2.0 `Leaderboard`, `describeError()` and `useStatsVideoPlays`, and 1.3.0 `ExporterCsvDownloadButton`, which takes the linked report by id.

Inside `plugins/jetpack` the package and a consumer module ship together, so the check is a formality. With the standalone `plugins/premium-analytics` next to another plugin, each brings its own copy, and the check is what keeps a widget built against 1.x from registering on a 2.x package.

Expand Down
Loading