PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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/stats.php +23 -97 16.3-a.1 → 16.3-a.5 View file →
@@ -21,8 +21,9 @@
21 21 use Automattic\Jetpack\Stats\Options as Stats_Options;
22 22 use Automattic\Jetpack\Stats\Tracking_Pixel as Stats_Tracking_Pixel;
23 23 use Automattic\Jetpack\Stats\WPCOM_Stats;
24 24 use Automattic\Jetpack\Stats\XMLRPC_Provider as Stats_XMLRPC;
25 +use Automattic\Jetpack\Stats_Admin\Admin_Bar as Stats_Admin_Bar;
25 26 use Automattic\Jetpack\Stats_Admin\Admin_Post_List_Column;
26 27 use Automattic\Jetpack\Stats_Admin\Dashboard as Stats_Dashboard;
27 28 use Automattic\Jetpack\Stats_Admin\Main as Stats_Main;
28 29 use Automattic\Jetpack\Status\Host;
@@ -55,21 +56,13 @@
55 56 */
56 57 function stats_load() {
57 58 Jetpack::enable_module_configurable( __FILE__ );
58 59
59 - // Only run the callback for those who can see the stats.
60 - if ( is_user_logged_in() && current_user_can( 'view_stats' ) ) {
61 - add_action( 'admin_head', 'stats_admin_bar_head', 100 );
62 - add_action( 'wp_head', 'stats_admin_bar_head', 100 );
63 - }
64 -
60 + Stats_Admin_Bar::init();
65 61 Admin_Post_List_Column::register();
66 62
67 63 add_action( 'jetpack_admin_menu', 'stats_admin_menu' );
68 - add_action( 'wp_before_admin_bar_render', 'stats_add_link_to_admin_bar_site_menu' );
69 64
70 - add_filter( 'pre_option_db_version', 'stats_ignore_db_version' );
71 -
72 65 // Filter for adding the Jetpack plugin version to tracking stats.
73 66 add_filter( 'stats_array', 'filter_stats_array_add_jp_version' );
74 67
75 68 require_once __DIR__ . '/stats/class-jetpack-stats-upgrade-nudges.php';
@@ -88,24 +81,18 @@
88 81 }
89 82
90 83 /**
91 84 * Prevent sparkline img requests being redirected to upgrade.php.
92 - * See wp-admin/admin.php where it checks $wp_db_version.
93 85 *
86 + * @deprecated 16.3
87 + *
94 88 * @access public
95 89 * @param mixed $version Version.
96 90 * @return string $version.
97 91 */
98 92 function stats_ignore_db_version( $version ) {
99 - if (
100 - is_admin() &&
101 - isset( $_GET['page'] ) && 'stats' === $_GET['page'] && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
102 - isset( $_GET['chart'] ) && strpos( $_GET['chart'], 'admin-bar-hours' ) === 0 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
103 - ) {
104 - global $wp_db_version;
105 - return $wp_db_version;
106 - }
107 - return $version;
93 + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Stats_Admin\Admin_Bar::ignore_db_version' );
94 + return Stats_Admin_Bar::ignore_db_version( $version );
108 95 }
109 96
110 97 /**
111 98 * Maps view_stats cap to read cap as needed.
@@ -507,9 +494,9 @@
507 494 $i18n_headers = jetpack_get_module_i18n( 'stats' );
508 495 ?>
509 496 <a
510 497 style="font-size:13px;"
511 - href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack#/settings?term=' . rawurlencode( $i18n_headers['name'] ?? '' ) ) ); ?>"
498 + href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack-settings#/settings?term=' . rawurlencode( $i18n_headers['name'] ?? '' ) ) ); ?>"
512 499 >
513 500 <?php esc_html_e( 'Configure', 'jetpack' ); ?>
514 501 </a>
515 502 <?php
@@ -738,68 +725,30 @@
738 725
739 726 /**
740 727 * Stats Admin Bar Head.
741 728 *
729 + * @deprecated 16.3
730 + *
742 731 * @access public
743 732 * @return void
744 733 */
745 734 function stats_admin_bar_head() {
746 - // Let's not show the stats admin bar to users who are not logged in.
747 - if ( ! is_user_logged_in() ) {
748 - return;
749 - }
750 -
751 - if ( ! Stats_Options::get_option( 'admin_bar' ) ) {
752 - return;
753 - }
754 -
755 - if ( ! current_user_can( 'view_stats' ) ) {
756 - return;
757 - }
758 -
759 - if ( ! is_admin_bar_showing() ) {
760 - return;
761 - }
762 -
763 - add_action( 'admin_bar_menu', 'stats_admin_bar_menu', 100 );
764 - ?>
765 -
766 -<style data-ampdevmode type='text/css'>
767 -#wpadminbar .quicklinks li#wp-admin-bar-stats {
768 - height: 32px;
735 + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Stats_Admin\Admin_Bar::maybe_add_chart' );
736 + Stats_Admin_Bar::maybe_add_chart();
769 737 }
770 -#wpadminbar .quicklinks li#wp-admin-bar-stats a {
771 - height: 32px;
772 - padding: 0;
773 -}
774 -#wpadminbar .quicklinks li#wp-admin-bar-stats a div {
775 - height: 32px;
776 - width: 95px;
777 - overflow: hidden;
778 - margin: 0 10px;
779 -}
780 -#wpadminbar .quicklinks li#wp-admin-bar-stats a:hover div {
781 - width: auto;
782 - margin: 0 8px 0 10px;
783 -}
784 -#wpadminbar .quicklinks li#wp-admin-bar-stats a img {
785 - height: 24px;
786 - margin: 4px 0;
787 - max-width: none;
788 - border: none;
789 -}
790 -</style>
791 - <?php
792 -}
793 738
794 739 /**
795 740 * Gets the image source of the given stats chart.
796 741 *
742 + * @deprecated 16.3
743 + *
797 744 * @param string $chart Name of the chart.
798 745 * @param array $args Extra list of argument to use in the image source.
799 746 * @return string An image source.
800 747 */
801 748 function stats_get_image_chart_src( $chart, $args = array() ) {
749 + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Stats_Admin\Admin_Bar::get_chart_src' );
750 +
802 751 $url = add_query_arg( 'page', 'stats', admin_url( 'admin.php' ) );
803 752
804 753 return add_query_arg(
805 754 array_merge(
@@ -816,53 +765,30 @@
816 765
817 766 /**
818 767 * Stats AdminBar.
819 768 *
769 + * @deprecated 16.3
770 + *
820 771 * @access public
821 772 * @param mixed $wp_admin_bar WPAdminBar.
822 773 * @return void
823 774 */
824 775 function stats_admin_bar_menu( &$wp_admin_bar ) {
825 - $img_src = esc_attr( stats_get_image_chart_src( 'admin-bar-hours-scale' ) );
826 - $img_src_2x = esc_attr( stats_get_image_chart_src( 'admin-bar-hours-scale-2x' ) );
827 - $alt = esc_attr( __( 'Stats', 'jetpack' ) );
828 - $title = esc_attr( __( 'Views over 48 hours. Click for more Jetpack Stats.', 'jetpack' ) );
829 -
830 - $menu = array(
831 - 'id' => 'stats',
832 - 'href' => add_query_arg( 'page', 'stats', admin_url( 'admin.php' ) ), // no menu_page_url() blog-side.
833 - 'title' => "<div><img fetchpriority='low' loading='lazy' decoding='async' src='$img_src' srcset='$img_src 1x, $img_src_2x 2x' width='112' height='24' alt='$alt' title='$title'></div>",
834 - );
835 -
836 - $wp_admin_bar->add_menu( $menu );
776 + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Stats_Admin\Admin_Bar::add_chart_node' );
777 + Stats_Admin_Bar::add_chart_node( $wp_admin_bar );
837 778 }
838 779
839 780 /**
840 781 * Adds a Stats link to the site-name admin bar submenu, alongside Dashboard.
841 782 *
783 + * @deprecated 16.3
784 + *
842 785 * @access public
843 786 * @return void
844 787 */
845 788 function stats_add_link_to_admin_bar_site_menu() {
846 - global $wp_admin_bar;
847 -
848 - if (
849 - ! is_object( $wp_admin_bar ) ||
850 - ! $wp_admin_bar->get_node( 'dashboard' ) ||
851 - ! current_user_can( 'view_stats' ) ||
852 - ( new Host() )->is_wpcom_platform()
853 - ) {
854 - return;
855 - }
856 -
857 - $wp_admin_bar->add_node(
858 - array(
859 - 'parent' => 'site-name',
860 - 'id' => 'jetpack-stats',
861 - 'title' => __( 'Stats', 'jetpack' ),
862 - 'href' => admin_url( 'admin.php?page=stats' ),
863 - )
864 - );
789 + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Stats_Admin\Admin_Bar::add_site_menu_link' );
790 + Stats_Admin_Bar::add_site_menu_link();
865 791 }
866 792
867 793 /**
868 794 * Stats Get Blog.