PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | modules/widgets/blog-stats.php +9 -4 13.1.5 → 16.3-a.7 View file →
@@ -9,12 +9,13 @@
9 9
10 10 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
11 11
12 12 use Automattic\Jetpack\Stats\WPCOM_Stats;
13 +use Automattic\Jetpack\Status\Host;
13 14
14 15 // Disable direct access/execution to/of the widget code.
15 16 if ( ! defined( 'ABSPATH' ) ) {
16 - exit;
17 + exit( 0 );
17 18 }
18 19
19 20 /**
20 21 * Blog Stats Widget.
@@ -51,9 +52,12 @@
51 52 * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
52 53 * @return array $widget_types New list of widgets that will be removed.
53 54 */
54 55 public function hide_widget_in_block_editor( $widget_types ) {
55 - $widget_types[] = 'blog-stats';
56 + // @TODO: Hide for Simple sites when the block API starts working.
57 + if ( ! ( new Host() )->is_wpcom_simple() ) {
58 + $widget_types[] = 'blog-stats';
59 + }
56 60 return $widget_types;
57 61 }
58 62
59 63 /**
@@ -80,10 +84,11 @@
80 84 *
81 85 * @return string|false $views All Time Stats for that blog.
82 86 */
83 87 public function get_stats() {
88 + $wpcom_stats = new WPCOM_Stats();
84 89 // Get data from the WordPress.com Stats REST API endpoint.
85 - $stats = convert_stats_array_to_object( ( new WPCOM_Stats() )->get_stats( array( 'fields' => 'stats' ) ) );
90 + $stats = $wpcom_stats->convert_stats_array_to_object( $wpcom_stats->get_stats( array( 'fields' => 'stats' ) ) );
86 91
87 92 if ( isset( $stats->stats->views ) ) {
88 93 return $stats->stats->views;
89 94 } else {
@@ -97,9 +102,9 @@
97 102 * @see WP_Widget::form()
98 103 *
99 104 * @param array $instance Previously saved values from database.
100 105 *
101 - * @return void
106 + * @return string|void
102 107 */
103 108 public function form( $instance ) {
104 109 $instance = wp_parse_args( $instance, $this->defaults() );
105 110 ?>