PluginProbe ʕ •ᴥ•ʔ
MonsterInsights – Google Analytics Dashboard for WordPress (Website Stats Made Easy) / 10.1.3
MonsterInsights – Google Analytics Dashboard for WordPress (Website Stats Made Easy) v10.1.3
10.2.2 10.2.1 10.2.0 10.1.3 trunk 10.0.0 10.0.1 10.0.2 10.0.3 10.1.1 10.1.2 8.1.0 8.10.0 8.10.1 8.11.0 8.12.0 8.12.1 8.13.0 8.13.1 8.14.0 8.14.1 8.15 8.16 8.17 8.18 8.19.0 8.2.0 8.20.0 8.20.1 8.21.0 8.22.0 8.23.0 8.23.1 8.24.0 8.25.0 8.26.0 8.27.0 8.28.0 8.3.0 8.3.1 8.3.2 8.3.3 8.3.4 8.4.0 8.5.0 8.5.1 8.5.2 8.5.3 8.6.0 8.7.0 8.8.0 8.8.1 8.8.2 8.9.0 8.9.1 9.0.0 9.0.1 9.1.0 9.1.1 9.10.0 9.10.1 9.11.0 9.11.1 9.2.0 9.2.1 9.2.2 9.2.3 9.2.4 9.3.0 9.3.1 9.4.0 9.4.1 9.5.1 9.5.2 9.5.3 9.6.0 9.6.1 9.7.0 9.8.0 9.9.0
google-analytics-for-wordpress / includes / admin / exclude-page-metabox.php
google-analytics-for-wordpress / includes / admin Last commit date
feature-feedback 1 year ago licensing 1 year ago notifications 6 months ago pages 1 month ago reports 1 month ago site-notes 1 month ago admin-assets.php 1 month ago admin.php 1 month ago ajax.php 1 month ago api-auth.php 1 month ago class-monsterinsights-am-deactivation-survey.php 8 months ago class-monsterinsights-charitable-notice.php 7 months ago class-monsterinsights-onboarding.php 1 month ago class-monsterinsights-usage-tracking.php 1 month ago common.php 1 month ago eea-compliance.php 1 month ago exclude-page-metabox.php 1 month ago index.php 3 years ago notice.php 1 year ago notification-event-runner.php 1 year ago notification-event.php 1 year ago notifications.php 1 month ago product-feed-cronjob.php 6 months ago reporting.php 3 years ago review.php 1 year ago routes.php 1 month ago setup-checklist.php 1 month ago sharedcount.php 1 year ago tracking.php 7 months ago translations.php 1 year ago uninstall.php 4 years ago wp-site-health.php 3 years ago
exclude-page-metabox.php
168 lines
1 <?php
2
3 /**
4 * Metabox class.
5 */
6
7 // Exit if accessed directly
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11 if ( ! class_exists( 'MonsterInsights_MetaBox_ExcludePage' ) ) {
12 class MonsterInsights_MetaBox_ExcludePage {
13
14 public function __construct() {
15 add_action( 'init', [ $this, 'register_meta' ] );
16
17 if ( ! is_admin() ) {
18 return;
19 }
20
21 add_action( 'load-post.php', [ $this, 'meta_box_init' ] );
22 add_action( 'load-post-new.php', [ $this, 'meta_box_init' ] );
23 }
24
25 private function is_gutenberg_editor() {
26 if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
27 return true;
28 }
29
30 $current_screen = get_current_screen();
31 if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
32 return true;
33 }
34
35 return false;
36 }
37
38 private function get_current_post_type() {
39 global $post;
40
41 if ( $post && $post->post_type ) {
42 return $post->post_type;
43 }
44
45 global $typenow;
46
47 if ( $typenow ) {
48 return $typenow;
49 }
50
51 global $current_screen;
52
53 if ( $current_screen && $current_screen->post_type ) {
54 return $current_screen->post_type;
55 }
56
57 if ( isset( $_REQUEST['post_type'] ) ) {
58 return sanitize_key( $_REQUEST['post_type'] );
59 }
60
61 return null;
62 }
63
64 public function meta_box_init() {
65 $post_type = $this->get_current_post_type();
66 if ( ! is_post_type_viewable( $post_type ) ) {
67 return;
68 }
69
70 add_action( 'admin_enqueue_scripts', array( $this, 'load_metabox_styles' ) );
71 if ( $this->is_gutenberg_editor() ) {
72 return;
73 }
74 if ( 'attachment' !== $post_type ) {
75 add_action( 'add_meta_boxes', [ $this, 'create_meta_box' ] );
76 }
77 }
78
79 public function register_meta() {
80 if ( ! function_exists( 'register_post_meta' ) ) {
81 return;
82 }
83
84 register_post_meta(
85 '',
86 '_monsterinsights_skip_tracking',
87 [
88 'auth_callback' => '__return_true',
89 'default' => false,
90 'show_in_rest' => true,
91 'single' => true,
92 'type' => 'boolean',
93 ]
94 );
95 }
96
97 public function create_meta_box() {
98 add_meta_box(
99 'monsterinsights-metabox',
100 'MonsterInsights',
101 [ $this, 'print_metabox_html' ],
102 null,
103 'side',
104 'high'
105 );
106 }
107
108 public function print_metabox_html( $post ) {
109 $skipped = (bool) get_post_meta( $post->ID, '_monsterinsights_skip_tracking', true );
110 wp_nonce_field( 'monsterinsights_metabox', 'monsterinsights_metabox_nonce' );
111 ?>
112 <div class="monsterinsights-metabox" id="monsterinsights-metabox-skip-tracking">
113 <div class="monsterinsights-metabox-input-checkbox">
114 <label class="">
115 <input type="checkbox" name="_monsterinsights_skip_tracking"
116 value="1" <?php checked( $skipped ); ?> <?php disabled( ! monsterinsights_is_pro_version() ); ?>>
117 <span
118 class="monsterinsights-metabox-input-checkbox-label"><?php _e( 'Exclude page from Google Analytics Tracking', 'google-analytics-for-wordpress' ); ?></span>
119 </label>
120 </div>
121 <div class="monsterinsights-metabox-helper">
122 <?php _e( 'Toggle to prevent Google Analytics from tracking this page.', 'google-analytics-for-wordpress' ); ?>
123 </div>
124 </div>
125
126 <?php do_action( 'monsterinsights_after_exclude_metabox', $skipped, $post ); ?>
127
128 <?php if ( ! monsterinsights_is_pro_version() ) { ?>
129 <div class="monsterinsights-metabox-pro-badge">
130 <span>
131 <svg width="15" height="14" viewBox="0 0 15 14" fill="none"
132 xmlns="http://www.w3.org/2000/svg">
133 <path
134 d="M6.57617 1.08203L4.92578 4.45898L1.19336 4.99219C0.533203 5.09375 0.279297 5.90625 0.761719 6.38867L3.42773 9.00391L2.79297 12.6855C2.69141 13.3457 3.40234 13.8535 3.98633 13.5488L7.3125 11.7969L10.6133 13.5488C11.1973 13.8535 11.9082 13.3457 11.8066 12.6855L11.1719 9.00391L13.8379 6.38867C14.3203 5.90625 14.0664 5.09375 13.4062 4.99219L9.69922 4.45898L8.02344 1.08203C7.74414 0.498047 6.88086 0.472656 6.57617 1.08203Z"
135 fill="#31862D"/>
136 </svg>
137 <?php _e( 'This is a PRO feature.', 'google-analytics-for-wordpress' ); ?>
138 </span>
139 <div class="monsterinsights-metabox-pro-badge-upgrade">
140 <a href="<?php echo monsterinsights_get_upgrade_link( 'exclude-page-tracking', 'lite-metabox', "https://www.monsterinsights.com/lite/" ); // phpcs:ignore ?>"
141 target="_blank" rel="noopener">
142 <?php _e( 'Upgrade', 'google-analytics-for-wordpress' ); ?>
143 </a>
144 </div>
145 </div>
146 <?php } ?>
147
148 <?php
149 }
150
151 public function load_metabox_styles() {
152 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
153
154 wp_register_style( 'monsterinsights-admin-metabox-style', plugins_url( 'assets/css/admin-metabox' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
155 wp_enqueue_style( 'monsterinsights-admin-metabox-style' );
156
157 if ( monsterinsights_is_pro_version() ) {
158 return;
159 }
160
161 wp_register_script( 'monsterinsights-admin-metabox-script', plugins_url( 'assets/js/admin-metabox' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() );
162 wp_enqueue_script( 'monsterinsights-admin-metabox-script' );
163 }
164 }
165
166 new MonsterInsights_MetaBox_ExcludePage();
167 }
168