1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Common admin class. |
4
|
|
|
* |
5
|
|
|
* @since 6.0.0 |
6
|
|
|
* |
7
|
|
|
* @package MonsterInsights |
8
|
|
|
* @subpackage Common |
9
|
|
|
* @author Chris Christoff |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// Exit if accessed directly |
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
14
|
|
|
exit; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Loads styles for all MonsterInsights-based Administration Screens. |
19
|
|
|
* |
20
|
|
|
* @since 6.0.0 |
21
|
|
|
* @access public |
22
|
|
|
* |
23
|
|
|
* @return null Return early if not on the proper screen. |
24
|
|
|
*/ |
25
|
|
|
function monsterinsights_admin_styles() { |
26
|
|
|
|
27
|
|
|
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
28
|
|
|
|
29
|
|
|
// Load Common admin styles. |
30
|
|
|
wp_register_style( 'monsterinsights-admin-common-style', plugins_url( 'assets/css/admin-common' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
31
|
|
|
wp_enqueue_style( 'monsterinsights-admin-common-style' ); |
32
|
|
|
|
33
|
|
|
// Get current screen. |
34
|
|
|
$screen = get_current_screen(); |
|
|
|
|
35
|
|
|
|
36
|
|
|
// Bail if we're not on a MonsterInsights screen. |
37
|
|
|
if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
38
|
|
|
return; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// For the settings page, load the Vue app styles. |
42
|
|
|
if ( in_array( $screen->id, array( |
43
|
|
|
'insights_page_monsterinsights_settings', |
44
|
|
|
'toplevel_page_monsterinsights_settings', |
45
|
|
|
'toplevel_page_monsterinsights_network-network', |
46
|
|
|
'insights_page_monsterinsights_network', |
47
|
|
|
), true ) ) { |
48
|
|
|
$version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite'; |
49
|
|
|
if ( ! defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) ) { |
50
|
|
|
wp_enqueue_style( 'monsterinsights-vue-style-vendors', plugins_url( $version_path . '/assets/vue/css/chunk-vendors.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
51
|
|
|
wp_enqueue_style( 'monsterinsights-vue-style-common', plugins_url( $version_path . '/assets/vue/css/chunk-common.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
52
|
|
|
wp_enqueue_style( 'monsterinsights-vue-style', plugins_url( $version_path . '/assets/vue/css/settings.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Don't load other styles on the settings page. |
56
|
|
|
return; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
// Bootstrap |
61
|
|
|
// Primary |
62
|
|
|
wp_register_style( 'monsterinsights-bootstrap', plugins_url( 'assets/css/bootstrap-prefixed' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
63
|
|
|
wp_enqueue_style( 'monsterinsights-bootstrap' ); |
64
|
|
|
|
65
|
|
|
// Secondary |
66
|
|
|
//wp_register_style( 'monsterinsights-bootstrap-base', plugins_url( 'assets/css/bootstrap' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
67
|
|
|
//wp_enqueue_style( 'monsterinsights-bootstrap-base' ); |
68
|
|
|
//wp_register_style( 'monsterinsights-bootstrap-theme', plugins_url( 'assets/css/bootstrap-theme' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'monsterinsights-bootstrap-base' ), monsterinsights_get_asset_version() ); |
69
|
|
|
//wp_enqueue_style( 'monsterinsights-bootstrap-theme' ); |
70
|
|
|
|
71
|
|
|
// Vendors |
72
|
|
|
wp_register_style( 'monsterinsights-vendors-style', plugins_url( 'assets/css/vendors' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
73
|
|
|
wp_enqueue_style( 'monsterinsights-vendors-style' ); |
74
|
|
|
|
75
|
|
|
// Tooltips |
76
|
|
|
wp_enqueue_script( 'jquery-ui-tooltip' ); |
77
|
|
|
|
78
|
|
|
// Load necessary admin styles. |
79
|
|
|
wp_register_style( 'monsterinsights-admin-style', plugins_url( 'assets/css/admin' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
80
|
|
|
wp_enqueue_style( 'monsterinsights-admin-style' ); |
81
|
|
|
|
82
|
|
|
// Load LTR stylesheet where needed. |
83
|
|
|
if ( is_rtl() ) { |
84
|
|
|
wp_enqueue_style( 'monsterinsights-admin-style-rtl', plugins_url( 'assets/css/admin-rtl' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() ); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
add_action( 'admin_enqueue_scripts', 'monsterinsights_admin_styles' ); |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Loads scripts for all MonsterInsights-based Administration Screens. |
92
|
|
|
* |
93
|
|
|
* @since 6.0.0 |
94
|
|
|
* @access public |
95
|
|
|
* |
96
|
|
|
* @return null Return early if not on the proper screen. |
97
|
|
|
*/ |
98
|
|
|
function monsterinsights_admin_scripts() { |
99
|
|
|
|
100
|
|
|
// Our Common Admin JS. |
101
|
|
|
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
102
|
|
|
|
103
|
|
|
wp_register_script( 'monsterinsights-admin-common-script', plugins_url( 'assets/js/admin-common' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); |
104
|
|
|
wp_enqueue_script( 'monsterinsights-admin-common-script' ); |
105
|
|
|
wp_localize_script( |
106
|
|
|
'monsterinsights-admin-common-script', |
107
|
|
|
'monsterinsights_admin_common', |
108
|
|
|
array( |
109
|
|
|
'ajax' => admin_url( 'admin-ajax.php' ), |
110
|
|
|
'dismiss_notice_nonce' => wp_create_nonce( 'monsterinsights-dismiss-notice' ), |
111
|
|
|
) |
112
|
|
|
); |
113
|
|
|
|
114
|
|
|
// Get current screen. |
115
|
|
|
$screen = get_current_screen(); |
|
|
|
|
116
|
|
|
|
117
|
|
|
// Bail if we're not on a MonsterInsights screen. |
118
|
|
|
if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
119
|
|
|
return; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
// For the settings page, load the Vue app. |
123
|
|
|
if ( in_array( $screen->id, array( |
124
|
|
|
'insights_page_monsterinsights_settings', |
125
|
|
|
'toplevel_page_monsterinsights_settings', |
126
|
|
|
'toplevel_page_monsterinsights_network-network', |
127
|
|
|
'insights_page_monsterinsights_network', |
128
|
|
|
), true ) ) { |
129
|
|
|
global $wp_version; |
130
|
|
|
$version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite'; |
131
|
|
|
if ( ! defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) ) { |
132
|
|
|
|
133
|
|
|
wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true ); |
134
|
|
|
wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true ); |
135
|
|
|
} |
136
|
|
|
$app_js_url = defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) && MONSTERINSIGHTS_LOCAL_JS_URL ? MONSTERINSIGHTS_LOCAL_JS_URL : plugins_url( $version_path . '/assets/vue/js/settings.js', MONSTERINSIGHTS_PLUGIN_FILE ); |
|
|
|
|
137
|
|
|
wp_register_script( 'monsterinsights-vue-script', $app_js_url, array(), monsterinsights_get_asset_version(), true ); |
138
|
|
|
wp_enqueue_script( 'monsterinsights-vue-script' ); |
139
|
|
|
$plugins = get_plugins(); |
140
|
|
|
$install_amp_url = false; |
141
|
|
|
if ( current_user_can( 'install_plugins' ) ) { |
142
|
|
|
$amp_key = 'amp/amp.php'; |
143
|
|
|
if ( array_key_exists( $amp_key, $plugins ) ) { |
144
|
|
|
$install_amp_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $amp_key ), 'activate-plugin_' . $amp_key ); |
145
|
|
|
} else { |
146
|
|
|
$install_amp_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=amp' ), 'install-plugin_amp' ); |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
$install_fbia_url = false; |
150
|
|
|
if ( current_user_can( 'install_plugins' ) ) { |
151
|
|
|
$fbia_key = 'fb-instant-articles/facebook-instant-articles.php'; |
152
|
|
|
if ( array_key_exists( $fbia_key, $plugins ) ) { |
153
|
|
|
$install_fbia_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $fbia_key ), 'activate-plugin_' . $fbia_key ); |
154
|
|
|
} else { |
155
|
|
|
$install_fbia_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=fb-instant-articles' ), 'install-plugin_fb-instant-articles' ); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
$prepared_dimensions = array(); |
160
|
|
|
if ( class_exists( 'MonsterInsights_Admin_Custom_Dimensions' ) ) { |
161
|
|
|
$dimensions = new MonsterInsights_Admin_Custom_Dimensions(); |
|
|
|
|
162
|
|
|
$dimensions = $dimensions->custom_dimensions(); |
163
|
|
|
$prepared_dimensions = array(); |
164
|
|
|
foreach ( $dimensions as $dimension_type => $dimension ) { |
165
|
|
|
$dimension['type'] = $dimension_type; |
166
|
|
|
$prepared_dimensions[] = $dimension; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
wp_localize_script( |
171
|
|
|
'monsterinsights-vue-script', |
172
|
|
|
'monsterinsights', |
173
|
|
|
array( |
174
|
|
|
'ajax' => admin_url( 'admin-ajax.php' ), |
175
|
|
|
'nonce' => wp_create_nonce( 'mi-admin-nonce' ), |
176
|
|
|
'network' => is_network_admin(), |
177
|
|
|
'translations' => wp_get_jed_locale_data( 'mi-vue-app' ), |
178
|
|
|
'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ), |
179
|
|
|
'roles' => monsterinsights_get_roles(), |
180
|
|
|
'roles_manage_options' => monsterinsights_get_manage_options_roles(), |
181
|
|
|
'shareasale_id' => monsterinsights_get_shareasale_id(), |
182
|
|
|
'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ), |
183
|
|
|
'addons_url' => is_multisite() ? add_query_arg( 'page', 'monsterinsights_addons', network_admin_url( 'admin.php' ) ) : add_query_arg( 'page', 'monsterinsights_addons', admin_url( 'admin.php' ) ), |
184
|
|
|
'install_amp_url' => $install_amp_url, |
185
|
|
|
'install_fbia_url' => $install_fbia_url, |
186
|
|
|
'dimensions' => $prepared_dimensions, |
187
|
|
|
'wizard_url' => admin_url( 'index.php?page=monsterinsights-onboarding' ), |
188
|
|
|
'install_plugins' => current_user_can( 'install_plugins' ), |
189
|
|
|
'unfiltered_html' => current_user_can( 'unfiltered_html' ), |
190
|
|
|
// Used to add notices for future deprecations. |
191
|
|
|
'versions' => array( |
192
|
|
|
'php_version' => phpversion(), |
193
|
|
|
'php_version_below_54' => version_compare( phpversion(), '5.4', '<' ), |
194
|
|
|
'php_version_below_56' => version_compare( phpversion(), '5.6', '<' ), |
195
|
|
|
'php_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' ), |
196
|
|
|
'wp_version' => $wp_version, |
197
|
|
|
'wp_version_below_46' => version_compare( $wp_version, '4.6', '<' ), |
198
|
|
|
'wp_version_below_49' => version_compare( $wp_version, '4.9', '<' ), |
199
|
|
|
'wp_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' ), |
200
|
|
|
), |
201
|
|
|
'plugin_version' => MONSTERINSIGHTS_VERSION, |
202
|
|
|
) |
203
|
|
|
); |
204
|
|
|
|
205
|
|
|
// Don't load other scripts on the settings page. |
206
|
|
|
return; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
// Tooltips |
210
|
|
|
wp_enqueue_script( 'jquery-ui-tooltip' ); |
211
|
|
|
|
212
|
|
|
// Vendors |
213
|
|
|
wp_register_script( 'monsterinsights-vendors-script', plugins_url( 'assets/js/vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); |
214
|
|
|
wp_enqueue_script( 'monsterinsights-vendors-script' ); |
215
|
|
|
|
216
|
|
|
|
217
|
|
|
// Our Admin JS |
218
|
|
|
$deps = array( |
219
|
|
|
'jquery', |
220
|
|
|
'jquery-ui-tooltip', |
221
|
|
|
'monsterinsights-vendors-script' |
222
|
|
|
); |
223
|
|
|
|
224
|
|
|
wp_register_script( 'monsterinsights-admin-script', plugins_url( 'assets/js/admin.js', MONSTERINSIGHTS_PLUGIN_FILE ), $deps, monsterinsights_get_asset_version() ); |
225
|
|
|
wp_enqueue_script( 'monsterinsights-admin-script' ); |
226
|
|
|
wp_localize_script( |
227
|
|
|
'monsterinsights-admin-script', |
228
|
|
|
'monsterinsights_admin', |
229
|
|
|
array( |
230
|
|
|
'ajax' => admin_url( 'admin-ajax.php' ), |
231
|
|
|
'dismiss_notice_nonce' => wp_create_nonce( 'monsterinsights-dismiss-notice' ), |
232
|
|
|
'loadingtext' => esc_html__( 'Loading...', 'google-analytics-for-wordpress' ), |
233
|
|
|
'settings_changed_confirm' => esc_html__( 'Warning: You have unsaved setting changes. If you leave the settings page without saving your changes will be lost. Did you still want to leave the page?', 'google-analytics-for-wordpress' ), |
234
|
|
|
'activate_nonce' => wp_create_nonce( 'monsterinsights-activate' ), |
235
|
|
|
'active' => esc_html__( 'Status: Active', 'google-analytics-for-wordpress' ), |
236
|
|
|
'activate' => esc_html__( 'Activate', 'google-analytics-for-wordpress' ), |
237
|
|
|
'networkactive' => esc_html__( 'Status: Network Activated', 'google-analytics-for-wordpress' ), |
238
|
|
|
'networkactivate' => esc_html__( 'Network activate', 'google-analytics-for-wordpress' ), |
239
|
|
|
'get_addons_nonce' => wp_create_nonce( 'monsterinsights-get-addons' ), |
240
|
|
|
'activating' => esc_html__( 'Activating...', 'google-analytics-for-wordpress' ), |
241
|
|
|
'deactivate' => esc_html__( 'Deactivate', 'google-analytics-for-wordpress' ), |
242
|
|
|
'networkdeactivate' => esc_html__( 'Network deactivate', 'google-analytics-for-wordpress' ), |
243
|
|
|
'deactivate_nonce' => wp_create_nonce( 'monsterinsights-deactivate' ), |
244
|
|
|
'deactivating' => esc_html__( 'Deactivating...', 'google-analytics-for-wordpress' ), |
245
|
|
|
'inactive' => esc_html__( 'Status: Inactive', 'google-analytics-for-wordpress' ), |
246
|
|
|
'networkinactive' => esc_html__( 'Status: Network inactive', 'google-analytics-for-wordpress' ), |
247
|
|
|
'install' => esc_html__( 'Install', 'google-analytics-for-wordpress' ), |
248
|
|
|
'install_nonce' => wp_create_nonce( 'monsterinsights-install' ), |
249
|
|
|
'installing' => esc_html__( 'Installing...', 'google-analytics-for-wordpress' ), |
250
|
|
|
'proceed' => esc_html__( 'Proceed', 'google-analytics-for-wordpress' ), |
251
|
|
|
'isnetwork' => is_network_admin(), |
252
|
|
|
'copied' => esc_html__( 'Copied!', 'google-analytics-for-wordpress' ), |
253
|
|
|
'copytoclip' => esc_html__( 'Copy to Clipboard', 'google-analytics-for-wordpress' ), |
254
|
|
|
'failed' => esc_html__( 'Failed!', 'google-analytics-for-wordpress' ), |
255
|
|
|
'admin_nonce' => wp_create_nonce( 'mi-admin-nonce' ), |
256
|
|
|
'shorten' => esc_html__( 'Shorten URL', 'google-analytics-for-wordpress' ), |
257
|
|
|
'shortened' => esc_html__( 'Shortened!', 'google-analytics-for-wordpress' ), |
258
|
|
|
'working' => esc_html__( 'Working...', 'google-analytics-for-wordpress' ), |
259
|
|
|
'importtext' => esc_html__( 'Import', 'google-analytics-for-wordpress' ), |
260
|
|
|
'imported' => esc_html__( 'Imported!', 'google-analytics-for-wordpress' ), |
261
|
|
|
'redirect_loading_title_text' => esc_html__( 'Preparing to redirect:', 'google-analytics-for-wordpress' ), |
262
|
|
|
'redirect_loading_text_text' => esc_html__( "You'll be redirected momentarily to complete authentication. This may take a couple seconds.", 'google-analytics-for-wordpress' ), |
263
|
|
|
'redirect_loading_error_title' => esc_html__( "Authentication Error:", 'google-analytics-for-wordpress' ), |
264
|
|
|
'deauth_loading_title_text' => esc_html__( 'Deauthenticating....', 'google-analytics-for-wordpress' ), |
265
|
|
|
'deauth_loading_text_text' => esc_html__( "We're deactivating your site. This may take a couple seconds.", 'google-analytics-for-wordpress' ), |
266
|
|
|
'deauth_loading_error_title' => esc_html__( "Deactivation Error:", 'google-analytics-for-wordpress' ), |
267
|
|
|
'deauth_success_title_text' => esc_html__( 'Deactivated Successfully!', 'google-analytics-for-wordpress' ), |
268
|
|
|
'deauth_success_text_text' => esc_html__( "You've disconnected your site from MonsterInsights. Your site is no longer being tracked by Google Analytics and you won't see reports anymore.", 'google-analytics-for-wordpress' ), |
269
|
|
|
'verify_loading_title_text' => esc_html__( 'Verifying....', 'google-analytics-for-wordpress' ), |
270
|
|
|
'verify_loading_text_text' => esc_html__( "We're verifying your site. This may take a couple seconds.", 'google-analytics-for-wordpress' ), |
271
|
|
|
'verify_loading_error_title' => esc_html__( "Verification Error:", 'google-analytics-for-wordpress' ), |
272
|
|
|
'verify_success_title_text' => esc_html__( 'Verified Successfully!', 'google-analytics-for-wordpress' ), |
273
|
|
|
'verify_success_text_text' => esc_html__( "Your site is connected to MonsterInsights!", 'google-analytics-for-wordpress' ), |
274
|
|
|
'ok_text' => esc_html__( "OK", 'google-analytics-for-wordpress' ), |
275
|
|
|
'force_deauth_button_text' => esc_html__( "Force Deauthenticate", 'google-analytics-for-wordpress' ), |
276
|
|
|
'refresh_report_title' => esc_html__( 'Refreshing Report', 'google-analytics-for-wordpress' ), |
277
|
|
|
'refresh_report_text' => esc_html__( 'Loading new report data...', 'google-analytics-for-wordpress' ), |
278
|
|
|
'refresh_report_success_text' => esc_html__( 'Success', 'google-analytics-for-wordpress' ), |
279
|
|
|
'refresh_report_success_text' => esc_html__( 'Retrieved the new report data successfully', 'google-analytics-for-wordpress' ), |
280
|
|
|
'refresh_report_failure_title' => esc_html__( 'Error', 'google-analytics-for-wordpress' ), |
281
|
|
|
'timezone' => date( 'e' ), |
282
|
|
|
'verify_license_title' => esc_html__( 'Verifying....', 'google-analytics-for-wordpress' ), |
283
|
|
|
'verify_license_text' => esc_html__( 'We\'re verifying your license. This may take a couple seconds.', 'google-analytics-for-wordpress' ), |
284
|
|
|
'verify_license_error_title' => esc_html__( 'Verification Error:', 'google-analytics-for-wordpress' ), |
285
|
|
|
'verify_license_success_title' => esc_html__( 'Verified Successfully!', 'google-analytics-for-wordpress' ), |
286
|
|
|
'verify_license_success_button' => esc_html__( 'Verify Key', 'google-analytics-for-wordpress' ), |
287
|
|
|
'deactivate_license_title' => esc_html__( 'Verifying....', 'google-analytics-for-wordpress' ), |
288
|
|
|
'deactivate_license_text' => esc_html__( 'We\'re deactivating your license. This may take a couple seconds.', 'google-analytics-for-wordpress' ), |
289
|
|
|
'deactivate_license_success_title' => esc_html__( 'Deactivated Successfully!', 'google-analytics-for-wordpress' ), |
290
|
|
|
) |
291
|
|
|
); |
292
|
|
|
|
293
|
|
|
// ublock notice |
294
|
|
|
add_action( 'admin_print_footer_scripts', 'monsterinsights_settings_ublock_error_js', 9999999 ); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
add_action( 'admin_enqueue_scripts', 'monsterinsights_admin_scripts' ); |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* Remove Assets that conflict with ours from our screens. |
301
|
|
|
* |
302
|
|
|
* @since 6.0.4 |
303
|
|
|
* @access public |
304
|
|
|
* |
305
|
|
|
* @return null Return early if not on the proper screen. |
306
|
|
|
*/ |
307
|
|
|
function monsterinsights_remove_conflicting_asset_files() { |
308
|
|
|
|
309
|
|
|
// Get current screen. |
310
|
|
|
$screen = get_current_screen(); |
|
|
|
|
311
|
|
|
|
312
|
|
|
// Bail if we're not on a MonsterInsights screen. |
313
|
|
|
if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
314
|
|
|
return; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
$styles = array( |
318
|
|
|
'kt_admin_css', // Pinnacle theme |
319
|
|
|
'select2-css', // Schema theme |
320
|
|
|
'tweetshare_style', // TweetShare - Click To Tweet |
321
|
|
|
'tweetshare_custom_style', // TweetShare - Click To Tweet |
322
|
|
|
'tweeetshare_custome_style', // TweetShare - Click To Tweet |
323
|
|
|
'tweeetshare_notice_style', // TweetShare - Click To Tweet |
324
|
|
|
'tweeetshare_theme_style', // TweetShare - Click To Tweet |
325
|
|
|
'tweeetshare_tweet_box_style', // TweetShare - Click To Tweet |
326
|
|
|
'soultype2-admin', // SoulType Plugin |
327
|
|
|
'thesis-options-stylesheet', // Thesis Options Stylesheet |
328
|
|
|
'imagify-sweetalert-core', // Imagify |
329
|
|
|
'imagify-sweetalert', // Imagify |
330
|
|
|
'smls-backend-style', // Smart Logo Showcase Lite |
331
|
|
|
'wp-reactjs-starter', // wp-real-media-library |
332
|
|
|
'control-panel-modal-plugin', // Ken Theme |
333
|
|
|
'theme-admin-css', // Vitrine Theme |
334
|
|
|
'qi-framework-styles', // Artisan Nayma Theme |
335
|
|
|
'artisan-pages-style', // Artisan Pages Plugin |
336
|
|
|
'control-panel-modal-plugin', // Ken Theme |
337
|
|
|
'sweetalert', // Church Suite Theme by Webnus |
338
|
|
|
'woo_stock_alerts_admin_css', // WooCommerce bolder product alerts |
339
|
|
|
'custom_wp_admin_css', // Fix for Add Social Share |
340
|
|
|
'fo_css', // Fix for Add Social Share |
341
|
|
|
'font_css', // Fix for Add Social Share |
342
|
|
|
'font2_css', // Fix for Add Social Share |
343
|
|
|
'font3_css', // Fix for Add Social Share |
344
|
|
|
'hover_css', // Fix for Add Social Share |
345
|
|
|
'fontend_styling', // Fix for Add Social Share |
346
|
|
|
'datatable', // WP Todo |
347
|
|
|
'bootstrap', // WP Todo |
348
|
|
|
'flipclock', // WP Todo |
349
|
|
|
'repuso_css_admin', // Social testimonials and reviews by Repuso |
350
|
|
|
); |
351
|
|
|
|
352
|
|
|
$scripts = array( |
353
|
|
|
'kad_admin_js', // Pinnacle theme |
354
|
|
|
'dt-chart', // DesignThemes core features plugin |
355
|
|
|
'tweeetshare_font_script', // TweetShare - Click To Tweet |
356
|
|
|
'tweeetshare_jquery_script', // TweetShare - Click To Tweet |
357
|
|
|
'tweeetshare_jqueryui_script', // TweetShare - Click To Tweet |
358
|
|
|
'tweeetshare_custom_script', // TweetShare - Click To Tweet |
359
|
|
|
'imagify-promise-polyfill', // Imagify |
360
|
|
|
'imagify-sweetalert', // Imagify |
361
|
|
|
'imagify-chart', // Imagify |
362
|
|
|
'chartjs', // Comet Cache Pro |
363
|
|
|
'wp-reactjs-starter', // wp-real-media-library |
364
|
|
|
'jquery-tooltipster', // WP Real Media Library |
365
|
|
|
'jquery-nested-sortable', // WP Real Media Library |
366
|
|
|
'jquery-aio-tree', // WP Real Media Library |
367
|
|
|
'wp-media-picker', // WP Real Media Library |
368
|
|
|
'rml-general', // WP Real Media Library |
369
|
|
|
'rml-library', // WP Real Media Library |
370
|
|
|
'rml-grid', // WP Real Media Library |
371
|
|
|
'rml-list', // WP Real Media Library |
372
|
|
|
'rml-modal', // WP Real Media Library |
373
|
|
|
'rml-order', // WP Real Media Library |
374
|
|
|
'rml-meta', // WP Real Media Library |
375
|
|
|
'rml-uploader', // WP Real Media Library |
376
|
|
|
'rml-options', // WP Real Media Library |
377
|
|
|
'rml-usersettings', // WP Real Media Library |
378
|
|
|
'rml-main', // WP Real Media Library |
379
|
|
|
'control-panel-sweet-alert', // Ken Theme |
380
|
|
|
'sweet-alert-js', // Vitrine Theme |
381
|
|
|
'theme-admin-script', // Vitrine Theme |
382
|
|
|
'sweetalert', // Church Suite Theme by Webnus |
383
|
|
|
'be_alerts_charts', // WooCommerce bolder product alerts |
384
|
|
|
'magayo-lottery-results', // Magayo Lottery Results |
385
|
|
|
'control-panel-sweet-alert', // Ken Theme |
386
|
|
|
'cpm_chart', // WP Project Manager |
387
|
|
|
'adminscripts', // Artisan Nayma Theme |
388
|
|
|
'artisan-pages-script', // Artisan Pages Plugin |
389
|
|
|
'tooltipster', // Grand News Theme |
390
|
|
|
'fancybox', // Grand News Theme |
391
|
|
|
'grandnews-admin-cript', // Grand News Theme |
392
|
|
|
'colorpicker', // Grand News Theme |
393
|
|
|
'eye', // Grand News Theme |
394
|
|
|
'icheck', // Grand News Theme |
395
|
|
|
'learn-press-chart', // LearnPress |
396
|
|
|
'theme-script-main', // My Listing Theme by 27collective |
397
|
|
|
'selz', // Selz eCommerce |
398
|
|
|
'tie-admin-scripts', // Tie Theme |
399
|
|
|
'blossomthemes-toolkit', // BlossomThemes Toolkit |
400
|
|
|
'illdy-widget-upload-image', // Illdy Companion By Colorlib |
401
|
|
|
'moment.js', // WooCommerce Table Rate Shipping |
402
|
|
|
'default', // Bridge Theme |
403
|
|
|
'qode-tax-js', // Bridge Theme |
404
|
|
|
'wc_smartship_moment_js', // WooCommerce Posti SmartShip by markup.fi |
405
|
|
|
'ecwid-admin-js', // Fixes Conflict for Ecwid Shopping Cart |
406
|
|
|
'td-wp-admin-js', // Newspaper by tagDiv |
407
|
|
|
'moment', // Screets Live Chat |
408
|
|
|
'wpmf-base', // WP Media Folder Fix |
409
|
|
|
'wpmf-media-filters', // WP Media Folder Fix |
410
|
|
|
'wpmf-folder-tree', // WP Media Folder Fix |
411
|
|
|
'wpmf-assign-tree', // WP Media Folder Fix |
412
|
|
|
'js_files_for_wp_admin', // TagDiv Composer Fix |
413
|
|
|
'tdb_js_files_for_wp_admin_last', // TagDiv Composer Fix |
414
|
|
|
'tdb_js_files_for_wp_admin', // TagDiv Composer Fix |
415
|
|
|
'wd-functions', // affiliate boxes |
416
|
|
|
'ellk-aliExpansion', // Ali Dropship Plugin |
417
|
|
|
'ftmetajs', // Houzez Theme |
418
|
|
|
'qode_admin_default', // Fix For Stockholm Theme |
419
|
|
|
'qodef-tax-js', // Fix for Prowess Theme |
420
|
|
|
'qodef-user-js', // Fix for Prowess Theme |
421
|
|
|
'qodef-ui-admin', // Fix for Prowess Theme |
422
|
|
|
'ssi_script', // Fix for Add Social Share |
423
|
|
|
'live_templates', // Fix for Add Social Share |
424
|
|
|
'default', // Fix for Add Social Share |
425
|
|
|
'handsontable', // Fix WP Tables |
426
|
|
|
'moment-js', // Magee Shortcodes |
427
|
|
|
'postbox', // Scripts from wp-admin enqueued everywhere by WP Posts Filter |
428
|
|
|
'link', // Scripts from wp-admin enqueued everywhere by WP Posts Filter |
429
|
|
|
'wpvr_scripts', // WP Video Robot |
430
|
|
|
'wpvr_scripts_loaded', // WP Video Robot |
431
|
|
|
'wpvr_scripts_assets', // WP Video Robot |
432
|
|
|
'writee_widget_admin', // Fix for the Writtee theme |
433
|
|
|
'__ytprefs_admin__', // Fix for YouTube by EmbedPlus plugin |
434
|
|
|
'momentjs', // Fix for Blog Time plugin |
435
|
|
|
'c2c_BlogTime', // Fix for Blog Time plugin |
436
|
|
|
'material-wp', // Fix for MaterialWP plugin |
437
|
|
|
'wp-color-picker-alpha', // Fix for MaterialWP plugin |
438
|
|
|
'grandtour-theme-script', // Grandtour Theme |
439
|
|
|
'swifty-img-widget-admin-script', // Fix for Swifty Image Widget |
440
|
|
|
'datatable', // WP Todo |
441
|
|
|
'flipclock', // WP Todo |
442
|
|
|
'bootstrap', // WP Todo |
443
|
|
|
'repuso_js_admin', // Social testimonials and reviews by Repuso |
444
|
|
|
); |
445
|
|
|
|
446
|
|
|
if ( ! empty( $styles ) ) { |
447
|
|
|
foreach ( $styles as $style ) { |
448
|
|
|
wp_dequeue_style( $style ); // Remove CSS file from MI screen |
449
|
|
|
wp_deregister_style( $style ); |
450
|
|
|
} |
451
|
|
|
} |
452
|
|
|
if ( ! empty( $scripts ) ) { |
453
|
|
|
foreach ( $scripts as $script ) { |
454
|
|
|
wp_dequeue_script( $script ); // Remove JS file from MI screen |
455
|
|
|
wp_deregister_script( $script ); |
456
|
|
|
} |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
$third_party = array( |
460
|
|
|
'select2', |
461
|
|
|
'sweetalert', |
462
|
|
|
'clipboard', |
463
|
|
|
'matchHeight', |
464
|
|
|
'inputmask', |
465
|
|
|
'jquery-confirm', |
466
|
|
|
'list', |
467
|
|
|
'toastr', |
468
|
|
|
'tooltipster', |
469
|
|
|
'flag-icon', |
470
|
|
|
'bootstrap', |
471
|
|
|
); |
472
|
|
|
|
473
|
|
|
global $wp_styles; |
474
|
|
|
foreach ( $wp_styles->queue as $handle ) { |
475
|
|
|
if ( strpos( $wp_styles->registered[ $handle ]->src, 'wp-content' ) === false ) { |
476
|
|
|
return; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
if ( strpos( $wp_styles->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) { |
480
|
|
|
return; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
foreach ( $third_party as $partial ) { |
484
|
|
|
if ( strpos( $wp_styles->registered[ $handle ]->handle, $partial ) !== false ) { |
485
|
|
|
wp_dequeue_style( $handle ); // Remove css file from MI screen |
486
|
|
|
wp_deregister_style( $handle ); |
487
|
|
|
break; |
488
|
|
|
} else if ( strpos( $wp_styles->registered[ $handle ]->src, $partial ) !== false ) { |
489
|
|
|
wp_dequeue_style( $handle ); // Remove css file from MI screen |
490
|
|
|
wp_deregister_style( $handle ); |
491
|
|
|
break; |
492
|
|
|
} |
493
|
|
|
} |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
global $wp_scripts; |
497
|
|
|
foreach ( $wp_scripts->queue as $handle ) { |
498
|
|
|
if ( strpos( $wp_scripts->registered[ $handle ]->src, 'wp-content' ) === false ) { |
499
|
|
|
return; |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
if ( strpos( $wp_scripts->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) { |
503
|
|
|
return; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
foreach ( $third_party as $partial ) { |
507
|
|
|
if ( strpos( $wp_scripts->registered[ $handle ]->handle, $partial ) !== false ) { |
508
|
|
|
wp_dequeue_script( $handle ); // Remove JS file from MI screen |
509
|
|
|
wp_deregister_script( $handle ); |
510
|
|
|
break; |
511
|
|
|
} else if ( strpos( $wp_scripts->registered[ $handle ]->src, $partial ) !== false ) { |
512
|
|
|
wp_dequeue_script( $handle ); // Remove JS file from MI screen |
513
|
|
|
wp_deregister_script( $handle ); |
514
|
|
|
break; |
515
|
|
|
} |
516
|
|
|
} |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
// Remove actions from themes that are not following best practices and break the admin doing so |
520
|
|
|
// Theme: Newspaper by tagDiv |
521
|
|
|
remove_action( 'admin_enqueue_scripts', 'load_wp_admin_js' ); |
522
|
|
|
remove_action( 'admin_enqueue_scripts', 'load_wp_admin_css' ); |
523
|
|
|
remove_action( 'admin_print_scripts-widgets.php', 'td_on_admin_print_scripts_farbtastic' ); |
524
|
|
|
remove_action( 'admin_print_styles-widgets.php', 'td_on_admin_print_styles_farbtastic' ); |
525
|
|
|
remove_action( 'admin_print_footer_scripts', 'check_if_media_uploads_is_loaded', 9999 ); |
526
|
|
|
remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' ); |
527
|
|
|
remove_action( 'print_media_templates', 'td_change_backbone_js_hook' ); |
528
|
|
|
remove_action( 'admin_head', 'tdc_on_admin_head' ); // TagDiv Composer Fix |
529
|
|
|
remove_action( 'print_media_templates', 'us_media_templates' ); // Impreza Theme Fix |
530
|
|
|
remove_action( 'admin_footer', 'gt3pg_add_gallery_template' ); // GT3 Photo & Video Gallery By GT3 Themes Plugin Fix |
531
|
|
|
// Plugin WP Booklist: |
532
|
|
|
remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' ); |
533
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' ); |
534
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' ); |
535
|
|
|
remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' ); |
536
|
|
|
remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' ); |
537
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' ); |
538
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' ); |
539
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' ); |
540
|
|
|
remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' ); |
541
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' ); |
542
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' ); |
543
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' ); |
544
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' ); |
545
|
|
|
remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' ); |
546
|
|
|
remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' ); |
547
|
|
|
remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' ); |
548
|
|
|
remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' ); |
549
|
|
|
remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' ); |
550
|
|
|
remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' ); |
551
|
|
|
remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' ); |
552
|
|
|
remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' ); |
553
|
|
|
remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' ); |
554
|
|
|
remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' ); |
555
|
|
|
remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' ); |
556
|
|
|
remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' ); |
557
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' ); |
558
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' ); |
559
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' ); |
560
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' ); |
561
|
|
|
remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' ); |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
add_action( 'admin_enqueue_scripts', 'monsterinsights_remove_conflicting_asset_files', 9999 ); |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Remove non-MI notices from MI page. |
568
|
|
|
* |
569
|
|
|
* @since 6.0.0 |
570
|
|
|
* @access public |
571
|
|
|
* |
572
|
|
|
* @return null Return early if not on the proper screen. |
573
|
|
|
*/ |
574
|
|
|
function hide_non_monsterinsights_warnings() { |
575
|
|
|
// Bail if we're not on a MonsterInsights screen. |
576
|
|
|
if ( empty( $_REQUEST['page'] ) || strpos( $_REQUEST['page'], 'monsterinsights' ) === false ) { |
577
|
|
|
return; |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
global $wp_filter; |
581
|
|
|
if ( ! empty( $wp_filter['user_admin_notices']->callbacks ) && is_array( $wp_filter['user_admin_notices']->callbacks ) ) { |
582
|
|
|
foreach ( $wp_filter['user_admin_notices']->callbacks as $priority => $hooks ) { |
583
|
|
|
foreach ( $hooks as $name => $arr ) { |
584
|
|
|
if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) { |
585
|
|
|
unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] ); |
586
|
|
|
continue; |
587
|
|
|
} |
588
|
|
|
if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) { |
589
|
|
|
continue; |
590
|
|
|
} |
591
|
|
|
if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) { |
592
|
|
|
unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] ); |
593
|
|
|
} |
594
|
|
|
} |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
if ( ! empty( $wp_filter['admin_notices']->callbacks ) && is_array( $wp_filter['admin_notices']->callbacks ) ) { |
599
|
|
|
foreach ( $wp_filter['admin_notices']->callbacks as $priority => $hooks ) { |
600
|
|
|
foreach ( $hooks as $name => $arr ) { |
601
|
|
|
if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) { |
602
|
|
|
unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] ); |
603
|
|
|
continue; |
604
|
|
|
} |
605
|
|
|
if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) { |
606
|
|
|
continue; |
607
|
|
|
} |
608
|
|
|
if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) { |
609
|
|
|
unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] ); |
610
|
|
|
} |
611
|
|
|
} |
612
|
|
|
} |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
if ( ! empty( $wp_filter['all_admin_notices']->callbacks ) && is_array( $wp_filter['all_admin_notices']->callbacks ) ) { |
616
|
|
|
foreach ( $wp_filter['all_admin_notices']->callbacks as $priority => $hooks ) { |
617
|
|
|
foreach ( $hooks as $name => $arr ) { |
618
|
|
|
if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) { |
619
|
|
|
unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] ); |
620
|
|
|
continue; |
621
|
|
|
} |
622
|
|
|
if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) { |
623
|
|
|
continue; |
624
|
|
|
} |
625
|
|
|
if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) { |
626
|
|
|
unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] ); |
627
|
|
|
} |
628
|
|
|
} |
629
|
|
|
} |
630
|
|
|
} |
631
|
|
|
} |
632
|
|
|
|
633
|
|
|
add_action( 'admin_print_scripts', 'hide_non_monsterinsights_warnings' ); |
634
|
|
|
add_action( 'admin_head', 'hide_non_monsterinsights_warnings', PHP_INT_MAX ); |
635
|
|
|
|
636
|
|
|
/** |
637
|
|
|
* Called whenever an upgrade button / link is displayed in Lite, this function will |
638
|
|
|
* check if there's a shareasale ID specified. |
639
|
|
|
* |
640
|
|
|
* There are three ways to specify an ID, ordered by highest to lowest priority |
641
|
|
|
* - add_filter( 'monsterinsights_shareasale_id', function() { return 1234; } ); |
642
|
|
|
* - define( 'MONSTERINSIGHTS_SHAREASALE_ID', 1234 ); |
643
|
|
|
* - get_option( 'monsterinsights_shareasale_id' ); (with the option being in the wp_options table) |
644
|
|
|
* |
645
|
|
|
* If an ID is present, returns the ShareASale link with the affiliate ID, and tells |
646
|
|
|
* ShareASale to then redirect to monsterinsights.com/lite |
647
|
|
|
* |
648
|
|
|
* If no ID is present, just returns the monsterinsights.com/lite URL with UTM tracking. |
649
|
|
|
* |
650
|
|
|
* @since 6.0.0 |
651
|
|
|
* @access public |
652
|
|
|
* |
653
|
|
|
* @return string Upgrade link. |
654
|
|
|
*/ |
655
|
|
|
function monsterinsights_get_upgrade_link( $medium = '', $campaign = '', $url = '' ) { |
656
|
|
|
$url = monsterinsights_get_url( $medium, $campaign, $url, false ); |
657
|
|
|
|
658
|
|
|
if ( monsterinsights_is_pro_version() ) { |
659
|
|
|
return esc_url( $url ); |
660
|
|
|
} |
661
|
|
|
|
662
|
|
|
// Get the ShareASale ID |
663
|
|
|
$shareasale_id = monsterinsights_get_shareasale_id(); |
664
|
|
|
|
665
|
|
|
// If we have a shareasale ID return the shareasale url |
666
|
|
|
if ( ! empty( $shareasale_id ) ) { |
667
|
|
|
$shareasale_id = absint( $shareasale_id ); |
668
|
|
|
|
669
|
|
|
return esc_url( monsterinsights_get_shareasale_url( $shareasale_id, $url ) ); |
670
|
|
|
} else { |
671
|
|
|
return esc_url( $url ); |
672
|
|
|
} |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
function monsterinsights_get_url( $medium = '', $campaign = '', $url = '', $escape = true ) { |
676
|
|
|
// Setup Campaign variables |
677
|
|
|
$source = monsterinsights_is_pro_version() ? 'proplugin' : 'liteplugin'; |
678
|
|
|
$medium = ! empty( $medium ) ? $medium : 'defaultmedium'; |
679
|
|
|
$campaign = ! empty( $campaign ) ? $campaign : 'defaultcampaign'; |
680
|
|
|
$content = MONSTERINSIGHTS_VERSION; |
681
|
|
|
$default_url = monsterinsights_is_pro_version() ? '' : 'lite/'; |
682
|
|
|
$url = ! empty( $url ) ? $url : 'https://www.monsterinsights.com/' . $default_url; |
683
|
|
|
|
684
|
|
|
// Put together redirect URL |
685
|
|
|
$url = add_query_arg( |
686
|
|
|
array( |
687
|
|
|
'utm_source' => $source, // Pro/Lite Plugin |
688
|
|
|
'utm_medium' => sanitize_key( $medium ), // Area of MonsterInsights (example Reports) |
689
|
|
|
'utm_campaign' => sanitize_key( $campaign ), // Which link (example eCommerce Report) |
690
|
|
|
'utm_content' => $content, // Version number of MI |
691
|
|
|
), |
692
|
|
|
trailingslashit( $url ) |
693
|
|
|
); |
694
|
|
|
|
695
|
|
|
if ( $escape ) { |
696
|
|
|
return esc_url( $url ); |
697
|
|
|
} else { |
698
|
|
|
return $url; |
699
|
|
|
} |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
function monsterinsights_get_shareasale_id() { |
703
|
|
|
// Check if there's a constant. |
704
|
|
|
$shareasale_id = ''; |
705
|
|
|
if ( defined( 'MONSTERINSIGHTS_SHAREASALE_ID' ) ) { |
706
|
|
|
$shareasale_id = MONSTERINSIGHTS_SHAREASALE_ID; |
|
|
|
|
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
// If there's no constant, check if there's an option. |
710
|
|
|
if ( empty( $shareasale_id ) ) { |
711
|
|
|
$shareasale_id = get_option( 'monsterinsights_shareasale_id', '' ); |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
// Whether we have an ID or not, filter the ID. |
715
|
|
|
$shareasale_id = apply_filters( 'monsterinsights_shareasale_id', $shareasale_id ); |
716
|
|
|
|
717
|
|
|
// Ensure it's a number |
718
|
|
|
$shareasale_id = absint( $shareasale_id ); |
719
|
|
|
|
720
|
|
|
return $shareasale_id; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
// Passed in with mandatory default redirect and shareasaleid from monsterinsights_get_upgrade_link |
724
|
|
|
function monsterinsights_get_shareasale_url( $shareasale_id, $shareasale_redirect ) { |
725
|
|
|
// Check if there's a constant. |
726
|
|
|
$custom = false; |
727
|
|
|
if ( defined( 'MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL' ) ) { |
728
|
|
|
$shareasale_redirect = MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL; |
|
|
|
|
729
|
|
|
$custom = true; |
730
|
|
|
} |
731
|
|
|
|
732
|
|
|
// If there's no constant, check if there's an option. |
733
|
|
|
if ( empty( $custom ) ) { |
734
|
|
|
$shareasale_redirect = get_option( 'monsterinsights_shareasale_redirect_url', '' ); |
735
|
|
|
$custom = true; |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
// Whether we have an ID or not, filter the ID. |
739
|
|
|
$shareasale_redirect = apply_filters( 'monsterinsights_shareasale_redirect_url', $shareasale_redirect, $custom ); |
740
|
|
|
$shareasale_url = sprintf( 'http://www.shareasale.com/r.cfm?B=971799&U=%s&M=69975&urllink=%s', $shareasale_id, $shareasale_redirect ); |
741
|
|
|
|
742
|
|
|
return $shareasale_url; |
743
|
|
|
} |
744
|
|
|
|
745
|
|
|
function monsterinsights_settings_ublock_error_js() { |
746
|
|
|
echo "<script type='text/javascript'>\n"; |
747
|
|
|
echo "jQuery( document ).ready( function( $ ) { |
748
|
|
|
if ( window.uorigindetected == null){ |
749
|
|
|
$('#monsterinsights-ublock-origin-error').show(); |
750
|
|
|
$('.monsterinsights-nav-tabs').hide(); |
751
|
|
|
$('.monsterinsights-nav-container').hide(); |
752
|
|
|
$('#monsterinsights-addon-heading').hide(); |
753
|
|
|
$('#monsterinsights-addons').hide(); |
754
|
|
|
$('#monsterinsights-reports').hide(); |
755
|
|
|
} |
756
|
|
|
});"; |
757
|
|
|
echo "\n</script>"; |
758
|
|
|
} |
759
|
|
|
|
760
|
|
|
function monsterinsights_ublock_notice() { |
761
|
|
|
ob_start(); ?> |
762
|
|
|
<div id="monsterinsights-ublock-origin-error" class="error inline" style="display:none;"> |
763
|
|
|
<?php echo sprintf( esc_html__( 'MonsterInsights has detected that it\'s files are being blocked. This is usually caused by a adblock browser plugin (particularly uBlock Origin), or a conflicting WordPress theme or plugin. This issue only affects the admin side of MonsterInsights. To solve this, ensure MonsterInsights is whitelisted for your website URL in any adblock browser plugin you use. For step by step directions on how to do this, %1$sclick here%2$s. If this doesn\'t solve the issue (rare), send us a ticket %3$shere%2$s and we\'ll be happy to help diagnose the issue.', 'google-analytics-for-wordpress' ), '<a href="https://monsterinsights.com/docs/monsterinsights-asset-files-blocked/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>', '<a href="https://monsterinsights.com/contact/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' ); |
764
|
|
|
?> |
765
|
|
|
</div> |
766
|
|
|
<?php |
767
|
|
|
return ob_get_clean(); |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
/** |
771
|
|
|
* Some themes/plugins don't add proper checks and load JS code in all admin pages causing conflicts. |
772
|
|
|
*/ |
773
|
|
|
function monsterinsights_remove_unnecessary_footer_hooks() { |
774
|
|
|
|
775
|
|
|
$screen = get_current_screen(); |
|
|
|
|
776
|
|
|
// Bail if we're not on a MonsterInsights screen. |
777
|
|
|
if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
778
|
|
|
return; |
779
|
|
|
} |
780
|
|
|
|
781
|
|
|
// Remove js code added by Newspaper theme - version 8.8.0. |
782
|
|
|
remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' ); |
783
|
|
|
remove_action( 'print_media_templates', 'td_change_backbone_js_hook' ); |
784
|
|
|
// Remove js code added by the Brooklyn theme - version 4.5.3.1. |
785
|
|
|
remove_action( 'print_media_templates', 'ut_create_gallery_options' ); |
786
|
|
|
|
787
|
|
|
// Remove js code added by WordPress Book List Plugin - version 5.8.1. |
788
|
|
|
remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' ); |
789
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' ); |
790
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' ); |
791
|
|
|
remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' ); |
792
|
|
|
remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' ); |
793
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' ); |
794
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' ); |
795
|
|
|
remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' ); |
796
|
|
|
remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' ); |
797
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' ); |
798
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' ); |
799
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' ); |
800
|
|
|
remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' ); |
801
|
|
|
remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' ); |
802
|
|
|
remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' ); |
803
|
|
|
remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' ); |
804
|
|
|
remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' ); |
805
|
|
|
remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' ); |
806
|
|
|
remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' ); |
807
|
|
|
remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' ); |
808
|
|
|
remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' ); |
809
|
|
|
remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' ); |
810
|
|
|
remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' ); |
811
|
|
|
remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' ); |
812
|
|
|
remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' ); |
813
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' ); |
814
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' ); |
815
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' ); |
816
|
|
|
remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' ); |
817
|
|
|
remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' ); |
818
|
|
|
} |
819
|
|
|
|
820
|
|
|
add_action( 'admin_head', 'monsterinsights_remove_unnecessary_footer_hooks', 15 ); |
821
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.