at path:
ROOT
/
wp-content
/
plugins
/
jetpack
/
modules
/
widgets
/
blog-stats.php
run:
R
W
Run
authors
DIR
2026-04-17 06:07:59
R
W
Run
contact-info
DIR
2026-04-17 06:07:59
R
W
Run
eu-cookie-law
DIR
2026-04-17 06:07:59
R
W
Run
facebook-likebox
DIR
2026-04-17 06:07:59
R
W
Run
flickr
DIR
2026-04-17 06:07:59
R
W
Run
gallery
DIR
2026-04-17 06:07:54
R
W
Run
goodreads
DIR
2026-04-17 06:07:54
R
W
Run
google-translate
DIR
2026-04-17 06:07:59
R
W
Run
image-widget
DIR
2026-04-17 06:07:59
R
W
Run
instagram
DIR
2026-04-17 06:07:59
R
W
Run
internet-defense-league
DIR
2026-04-17 06:07:59
R
W
Run
milestone
DIR
2026-04-17 06:07:59
R
W
Run
my-community
DIR
2026-04-17 06:07:59
R
W
Run
social-icons
DIR
2026-04-17 06:07:59
R
W
Run
social-media-icons
DIR
2026-04-17 06:07:59
R
W
Run
top-posts
DIR
2026-04-17 06:07:59
R
W
Run
wordpress-post-widget
DIR
2026-04-17 06:07:59
R
W
Run
authors.php
9.02 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
blog-stats.php
6.12 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
class-jetpack-eu-cookie-law-widget.php
10.73 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
class-jetpack-instagram-widget.php
24.38 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
contact-info.php
18.18 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
customizer-controls.css
168 By
2026-04-17 06:07:59
R
W
Run
Delete
Rename
customizer-utils.js
4.06 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
facebook-likebox.php
15.35 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
flickr.php
8.39 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
gallery.php
16.08 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
goodreads.php
8.79 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
google-translate.php
6.47 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
gravatar-profile.css
632 By
2026-04-17 06:07:59
R
W
Run
Delete
Rename
gravatar-profile.php
16.37 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
image-widget.php
12.16 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
internet-defense-league.php
5.72 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
mailchimp.php
4.34 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
milestone.php
393 By
2026-04-17 06:07:59
R
W
Run
Delete
Rename
my-community.php
10.93 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
rsslinks-widget.php
10.77 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
simple-payments.php
451 By
2026-04-17 06:07:59
R
W
Run
Delete
Rename
social-icons.php
22.22 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
social-media-icons.php
10.77 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
top-posts.php
27.68 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
twitter-timeline-admin.js
2.18 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
twitter-timeline.php
20.11 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
upcoming-events.php
6.81 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
wordpress-post-widget.php
3.71 KB
2026-04-17 06:07:59
R
W
Run
Delete
Rename
error_log
up
📄
blog-stats.php
Save
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileNam /** * Blog Stats Widget. * * @since 4.5.0 * * @package automattic/jetpack */ // 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' ) ) { exit( 0 ); } /** * Blog Stats Widget. * * Displays all time stats for that site. * * @since 4.5.0 */ class Jetpack_Blog_Stats_Widget extends WP_Widget { /** * Constructor */ public function __construct() { $widget_ops = array( 'classname' => 'blog-stats', 'description' => esc_html__( 'Show a hit counter for your blog.', 'jetpack' ), 'customize_selective_refresh' => true, 'show_instance_in_rest' => true, ); parent::__construct( 'blog-stats', /** This filter is documented in modules/widgets/facebook-likebox.php */ apply_filters( 'jetpack_widget_name', esc_html__( 'Blog Stats', 'jetpack' ) ), $widget_ops ); $this->alt_option_name = 'widget_statscounter'; add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) ); } /** * Remove the "Blog Stats" widget from the Legacy Widget block * * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block. * @return array $widget_types New list of widgets that will be removed. */ public function hide_widget_in_block_editor( $widget_types ) { // @TODO: Hide for Simple sites when the block API starts working. if ( ! ( new Host() )->is_wpcom_simple() ) { $widget_types[] = 'blog-stats'; } return $widget_types; } /** * Return an associative array of default values * * These values are used in new widgets. * * @return array Array of default values for the Widget's options */ public function defaults() { return array( 'title' => esc_html__( 'Blog Stats', 'jetpack' ), /* Translators: Number of views, plural */ 'hits' => esc_html__( 'hits', 'jetpack' ), ); } /** * Return All Time Stats for that blog. * * We query the WordPress.com Stats REST API endpoint. * * @uses Automattic\Jetpack\Stats\WPCOM_Stats->get_stats. That function caches data locally for 5 minutes. * * @return string|false $views All Time Stats for that blog. */ public function get_stats() { $wpcom_stats = new WPCOM_Stats(); // Get data from the WordPress.com Stats REST API endpoint. $stats = $wpcom_stats->convert_stats_array_to_object( $wpcom_stats->get_stats( array( 'fields' => 'stats' ) ) ); if ( isset( $stats->stats->views ) ) { return $stats->stats->views; } else { return false; } } /** * Back end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * * @return string|void */ public function form( $instance ) { $instance = wp_parse_args( $instance, $this->defaults() ); ?> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'hits' ) ); ?>"><?php esc_html_e( 'Pageview Description:', 'jetpack' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'hits' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hits' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['hits'] ); ?>" /> </p> <p><?php esc_html_e( 'Hit counter is delayed by up to 5 minutes.', 'jetpack' ); ?></p> <?php } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @return array Updated safe values to be saved. */ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $instance = array(); $instance['title'] = wp_kses( $new_instance['title'], array() ); $instance['hits'] = wp_kses( $new_instance['hits'], array() ); return $instance; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $instance = wp_parse_args( $instance, $this->defaults() ); /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $instance['title'] ); echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } // Get the Site Stats. $views = $this->get_stats(); if ( 0 === $views ) { esc_html_e( 'There is nothing to display yet', 'jetpack' ); } elseif ( $views ) { printf( '<ul><li>%1$s %2$s</li></ul>', esc_html( number_format_i18n( $views ) ), isset( $instance['hits'] ) ? esc_html( $instance['hits'] ) : '' ); } else { esc_html_e( 'There was an issue retrieving stats. Please try again later.', 'jetpack' ); } echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped /** This action is already documented in modules/widgets/gravatar-profile.php */ do_action( 'jetpack_stats_extra', 'widget_view', 'blog_stats' ); } } /** * If the Stats module is active in a recent version of Jetpack, register the widget. * * @since 4.5.0 */ function jetpack_blog_stats_widget_init() { if ( Jetpack::is_module_active( 'stats' ) ) { register_widget( 'Jetpack_Blog_Stats_Widget' ); } } add_action( 'widgets_init', 'jetpack_blog_stats_widget_init' );