PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.26
Advanced Ads – Ad Manager & AdSense v2.0.26
2.0.26 2.0.25 2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / classes / checks.php
advanced-ads / classes Last commit date
ad-health-notices.php 3 weeks ago checks.php 3 weeks ago display-conditions.php 3 weeks ago filesystem.php 3 weeks ago frontend_checks.php 3 weeks ago inline-css.php 3 weeks ago utils.php 3 weeks ago visitor-conditions.php 3 weeks ago
checks.php
413 lines
1 <?php // phpcs:ignoreFile
2
3 use AdvancedAds\Constants;
4 use AdvancedAds\License\License_Site_Activation;
5 use AdvancedAds\Utilities\Conditional;
6 use AdvancedAds\Utilities\Data;
7
8 /**
9 * Checks for various things
10 *
11 * @since 1.6.9
12 */
13 class Advanced_Ads_Checks {
14
15 /**
16 * Minimum required PHP version of Advanced Ads
17 */
18 const MINIMUM_PHP_VERSION = '5.6.20';
19
20 /**
21 * A Quiz plugin is active
22 *
23 * @return bool true if any quiz plugin is active.
24 */
25 public static function active_quiz_plugins() {
26 return defined( 'AYS_QUIZ_VERSION' )
27 || defined( 'FORMINATOR_PLUGIN_BASENAME' )
28 || defined( 'QSM_PLUGIN_PATH' )
29 || class_exists( 'GFForms', false );
30 }
31
32 /**
33 * Show the list of potential issues
34 */
35 public static function show_issues() {
36 include_once ADVADS_ABSPATH . '/admin/views/checks.php';
37 }
38
39 /**
40 * PHP version minimum
41 *
42 * @return bool true if uses the minimum PHP version or higher
43 */
44 public static function php_version_minimum() {
45
46 if ( version_compare( phpversion(), self::MINIMUM_PHP_VERSION, '>=' ) ) {
47 return true;
48 }
49
50 return false;
51 }
52
53 /**
54 * Caching used
55 *
56 * @deprecated 1.48.0
57 *
58 * @return bool true if active
59 */
60 public static function cache() {
61 _deprecated_function( __METHOD__, '1.48.0', '\AdvancedAds\Utilities\Conditional::has_cache_plugins()' );
62 return Conditional::has_cache_plugins();
63 }
64
65 /**
66 * WordPress update available
67 *
68 * @return bool true if WordPress update available
69 */
70 public static function wp_update_available() {
71
72 $update_data = wp_get_update_data();
73 $count = absint( $update_data['counts']['wordpress'] );
74
75 if ( $count ) {
76 return true;
77 }
78
79 return false;
80 }
81
82 /**
83 * Check if license keys are missing or invalid or expired
84 *
85 * @since 1.6.6
86 * @update 1.8.21 also check for expired licenses
87 * @return true if there are missing licenses
88 */
89 public static function licenses_invalid() {
90 $add_ons = Data::get_addons();
91
92 if ( [] === $add_ons ) {
93 Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
94 return false;
95 }
96
97 // If at least one license key is active on this site, suppress the legacy
98 // "invalid or missing license keys" notice. This health check historically
99 // validated *all* installed paid add-ons (including those not activated yet)
100 // which can produce false positives even though the customer has at least
101 // one valid plan/license active.
102 if ( ! empty( License_Site_Activation::get_active_license_keys() ) ) {
103 Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
104 return false;
105 }
106
107 foreach ( $add_ons as $_add_on_key => $_add_on ) {
108 if ( 'slider-ads' === $_add_on['id'] ) {
109 continue;
110 }
111
112 $status = Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] );
113
114 // check expiry date.
115 $expiry_date = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $_add_on['options_slug'] );
116
117 if ( $expiry_date && 'lifetime' !== $expiry_date && strtotime( $expiry_date ) < time() ) {
118 return true;
119 }
120
121 // don’t check if license is valid.
122 if ( 'valid' === $status ) {
123 continue;
124 }
125
126 // retrieve our license key from the DB.
127 $licenses = Advanced_Ads_Admin_Licenses::get_instance()->get_licenses();
128
129 $license_key = isset( $licenses[ $_add_on_key ] ) ? $licenses[ $_add_on_key ] : false;
130
131 if ( ! $license_key || 'valid' !== $status ) {
132 return true;
133 }
134 }
135
136 // remove notice, if one is given.
137 Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
138 return false;
139 }
140
141 /**
142 * Autoptimize plugin installed
143 * can change ad tags, especially inline css and scripts
144 *
145 * @link https://wordpress.org/plugins/autoptimize/
146 * @return bool true if Autoptimize is installed
147 */
148 public static function active_autoptimize() {
149
150 if ( defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) ) {
151 return true;
152 }
153
154 return false;
155 }
156
157 /**
158 * WP rocket plugin installed
159 *
160 * @return bool true if WP rocket is installed
161 */
162 public static function active_wp_rocket() {
163 if ( defined( 'WP_ROCKET_SLUG' ) ) {
164 return true;
165 }
166
167 return false;
168 }
169
170 /**
171 * Checks the settings of wp rocket to find out if combining of javascript files is enabled
172 *
173 * @return boolean true, when "Combine JavaScript files" is enabled
174 */
175 public static function is_wp_rocket_combine_js_enabled() {
176 if ( self::active_wp_rocket() ) {
177 $settings = get_option( 'wp_rocket_settings' );
178 if ( $settings ) {
179 if ( isset( $settings['minify_concatenate_js'] ) && $settings['minify_concatenate_js'] ) {
180 return true;
181 }
182 }
183 }
184 return false;
185 }
186
187 /**
188 * Any AMP plugin enabled
189 *
190 * @return bool true if AMP plugin is installed
191 */
192 public static function active_amp_plugin() {
193 // Accelerated Mobile Pages.
194 if ( function_exists( 'ampforwp_is_amp_endpoint' ) ) {
195 return true;
196 }
197
198 // AMP plugin.
199 if ( function_exists( 'is_amp_endpoint' ) ) {
200 return true;
201 }
202
203 // other plugins.
204 if ( function_exists( 'is_wp_amp' ) ) {
205 return true;
206 }
207
208 return false;
209 }
210
211 /**
212 * Checks if the preconditions are met to wrap an ad with <!--noptimize--> comments
213 *
214 * @return boolean
215 */
216 public static function requires_noptimize_wrapping() {
217 return self::active_autoptimize() || self::is_wp_rocket_combine_js_enabled();
218 }
219
220 /**
221 * Check for additional conflicting plugins
222 *
223 * @return array<int, string> Names of conflicting plugins.
224 */
225 public static function conflicting_plugins() {
226 $conflicting_plugins = [];
227
228 if ( defined( 'Publicize_Base' ) ) { // JetPack Publicize module.
229 $conflicting_plugins[] = 'Jetpack – Publicize';
230 }
231 if ( defined( 'PF__PLUGIN_DIR' ) ) { // Facebook Instant Articles & Google AMP Pages by PageFrog.
232 $conflicting_plugins[] = 'Facebook Instant Articles & Google AMP Pages by PageFrog';
233 }
234 if ( defined( 'GT_VERSION' ) ) { // GT ShortCodes.
235 $conflicting_plugins[] = 'GT ShortCodes';
236 }
237 if ( class_exists( 'SimilarPosts', false ) ) { // Similar Posts, https://de.wordpress.org/plugins/similar-posts/.
238 $conflicting_plugins[] = 'Similar Posts';
239 }
240
241 return $conflicting_plugins;
242 }
243
244 /**
245 * Check if any of the global hide ads options is set
246 * ignore RSS feed setting, because it is standard
247 *
248 * @since 1.7.10
249 * @return bool
250 */
251 public static function ads_disabled() {
252 $options = Advanced_Ads::get_instance()->options();
253 if ( isset( $options['disabled-ads'] ) && is_array( $options['disabled-ads'] ) ) {
254 foreach ( $options['disabled-ads'] as $_key => $_value ) {
255 // don’t warn if "RSS Feed", "404", or "REST API" option are enabled, because they are normally not critical.
256 if ( ! empty( $_value ) && ! in_array( (string) $_key, [ 'feed', '404', 'rest-api' ], true ) ) {
257 return true;
258 }
259 }
260 }
261 return false;
262 }
263
264 /**
265 * Check for required php extensions
266 *
267 * @return array<int, string>
268 */
269 public static function php_extensions() {
270
271 $missing_extensions = [];
272
273 if ( ! extension_loaded( 'dom' ) ) {
274 $missing_extensions[] = 'dom';
275 }
276
277 if ( ! extension_loaded( 'mbstring' ) ) {
278 $missing_extensions[] = 'mbstring';
279 }
280
281 return $missing_extensions;
282 }
283
284 /**
285 * Get the list of Advanced Ads constant defined by the user.
286 *
287 * @return array<int, string>
288 */
289 public static function get_defined_constants() {
290 $constants = apply_filters(
291 'advanced-ads-constants',
292 [
293 'ADVADS_ADS_DISABLED',
294 'ADVADS_ALLOW_ADSENSE_ON_404',
295 'ADVADS_DISABLE_RESPONSIVE_IMAGES',
296 'ADVANCED_ADS_AD_DEBUG_FOR_ADMIN_ONLY',
297 'ADVANCED_ADS_DISABLE_ANALYTICS_ANONYMIZE_IP',
298 'ADVANCED_ADS_DISABLE_CHANGE',
299 'ADVANCED_ADS_DISABLE_CODE_HIGHLIGHTING',
300 'ADVANCED_ADS_DISABLE_SHORTCODE_BUTTON',
301 'ADVANCED_ADS_DISALLOW_PHP',
302 'ADVANCED_ADS_ENABLE_REVISIONS',
303 'ADVANCED_ADS_GEO_TEST_IP',
304 'ADVANCED_ADS_PRO_CUSTOM_POSITION_MOVE_INTO_HIDDEN',
305 'ADVANCED_ADS_PRO_PAGE_IMPR_EXDAYS',
306 'ADVANCED_ADS_PRO_REFERRER_EXDAYS',
307 'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH',
308 'ADVANCED_ADS_SHOW_LICENSE_RESPONSE',
309 'ADVANCED_ADS_SUPPRESS_PLUGIN_ERROR_NOTICES',
310 'ADVANCED_ADS_TRACKING_DEBUG',
311 'ADVANCED_ADS_TRACKING_NO_HOURLY_LIMIT',
312 ]
313 );
314
315 $result = [];
316 foreach ( $constants as $constant ) {
317 if ( defined( $constant ) ) {
318 $result[] = $constant;
319 }
320 }
321 return $result;
322 }
323
324
325 /**
326 * WP Engine hosting detected
327 *
328 * @return bool true if site is hosted by WP Engine
329 */
330 public static function wp_engine_hosting() {
331 if ( defined( 'WPE_APIKEY' ) ) {
332 return true;
333 }
334
335 return false;
336 }
337
338 /**
339 * Notice for Adblocker module if assets have expired
340 */
341 public static function assets_expired() {
342 $plugin_options = Advanced_Ads::get_instance()->get_adblocker_options();
343 $adblocker_options = Advanced_Ads_Ad_Blocker::get_instance()->options();
344
345 return ! empty( $plugin_options['use-adblocker'] ) && empty( $adblocker_options['module_can_work'] );
346 }
347
348 /**
349 * Check for other ads.txt plugins
350 *
351 * @return array<int, string>
352 */
353 public static function ads_txt_plugins() {
354
355 $ads_txt_plugins = [];
356
357 // Ads.txt Manager.
358 if ( function_exists( 'tenup_display_ads_txt' ) ) {
359 $ads_txt_plugins[] = 'Ads.txt Manager';
360 }
361
362 // todo:
363 // ads-txt-admin/unveil-media-ads-txt.php
364 // simple-ads-txt/bs_ads_txt.php
365 // ads-txt-manager/adstxtmanager.php
366 // monetizemore-ads-txt/wp-ads-txt.php
367 // authorized-sellers-manager/ads-txt-publisher.php.
368
369 return $ads_txt_plugins;
370 }
371
372 /**
373 * Check for activated plugins that manage header or footer code
374 *
375 * @return array<int, string>
376 */
377 public static function header_footer_plugins() {
378
379 $plugins = [];
380
381 // Header Footer Code Manager.
382 if ( function_exists( 'hfcm_options_install' ) ) {
383 $plugins[] = 'Header Footer Code Manager';
384 }
385 // Head, Footer and Post Injections.
386 if ( function_exists( 'hefo_template_redirect' ) ) {
387 $plugins[] = 'Head, Footer and Post Injections';
388 }
389 // Insert Headers and Footers /insert-headers-and-footers/.
390 if ( class_exists( 'InsertHeadersAndFooters', false ) ) {
391 $plugins[] = 'Insert Headers and Footers';
392 }
393 // Header and Footer Scripts /header-and-footer-scripts/.
394 if ( class_exists( 'HeaderAndFooterScripts', false ) ) {
395 $plugins[] = 'Header and Footer Scripts';
396 }
397
398 return $plugins;
399 }
400
401 /**
402 * Check if monetize wizard has been completed or notice dismissed
403 *
404 * @return bool
405 */
406 public static function can_launch_wizard(): bool {
407 $wizard_done = get_option( Constants::OPTION_WIZARD_COMPLETED, false );
408 $notice_dismissed = get_user_meta( get_current_user_id(), Constants::USER_WIZARD_DISMISS, true );
409
410 return ! $wizard_done && ! $notice_dismissed;
411 }
412 }
413