Skip to content

Commit

Permalink
Legacy Widgets: Return Stats Widgets for Simple Sites (#38610)
Browse files Browse the repository at this point in the history
* Legacy Widgets: Return Stats Widgets for Simple Sites

* Apply changes to Top Posts

* Add changelog

---------

Co-authored-by: Jasper Kang <[email protected]>
  • Loading branch information
Aurorum and kangzj authored Aug 22, 2024
1 parent 6f5af72 commit ae79cc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Legacy Widgets: ensure Blog Stats and Top Posts and Pages widgets are still available for Simple sites until the block API is fixed.
6 changes: 5 additions & 1 deletion projects/plugins/jetpack/modules/widgets/blog-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.

use Automattic\Jetpack\Stats\WPCOM_Stats;
use Automattic\Jetpack\Status\Host;

// Disable direct access/execution to/of the widget code.
if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -52,7 +53,10 @@ public function __construct() {
* @return array $widget_types New list of widgets that will be removed.
*/
public function hide_widget_in_block_editor( $widget_types ) {
$widget_types[] = 'blog-stats';
// @TODO: Hide for Simple sites when the block API starts working.
if ( ! ( new Host() )->is_wpcom_simple() ) {
$widget_types[] = 'blog-stats';
}
return $widget_types;
}

Expand Down
6 changes: 5 additions & 1 deletion projects/plugins/jetpack/modules/widgets/top-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Stats\WPCOM_Stats;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;

// Register the widget for use in Appearance -> Widgets
add_action( 'widgets_init', 'jetpack_top_posts_widget_init' );
Expand Down Expand Up @@ -94,7 +95,10 @@ public function __construct() {
* @return array $widget_types New list of widgets that will be removed.
*/
public function hide_widget_in_block_editor( $widget_types ) {
$widget_types[] = 'top-posts';
// @TODO: Hide for Simple sites when the block API starts working.
if ( ! ( new Host() )->is_wpcom_simple() ) {
$widget_types[] = 'top-posts';
}
return $widget_types;
}

Expand Down

0 comments on commit ae79cc6

Please sign in to comment.