PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / 22.7.0
WPSSO Core – Complete Schema Markup and Meta Tags v22.7.0
22.7.0 22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
← All changes | lib/check.php +1189 -0 22.5.122.7.0 View file →
@@ -1,0 +1,1189 @@
1 +<?php
2 +/*
3 + * License: GPLv3
4 + * License URI: https://www.gnu.org/licenses/gpl.txt
5 + * Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/)
6 + */
7 +
8 +if ( ! defined( 'ABSPATH' ) ) {
9 +
10 + die( 'These aren\'t the droids you\'re looking for.' );
11 +}
12 +
13 +if ( ! defined( 'WPSSO_PLUGINDIR' ) ) {
14 +
15 + die( 'Do. Or do not. There is no try.' );
16 +}
17 +
18 +if ( ! class_exists( 'SucomPlugin' ) ) {
19 +
20 + require_once WPSSO_PLUGINDIR . 'lib/com/plugin.php';
21 +}
22 +
23 +if ( ! class_exists( 'WpssoCheck' ) ) {
24 +
25 + class WpssoCheck {
26 +
27 + private $p; // Wpsso class object.
28 +
29 + private $extend_lib_checks = array(
30 + 'amp' => array(
31 + 'amp' => 'AMP',
32 + 'accelerated-mobile-pages' => 'AMP for WP',
33 + ),
34 + 'cache' => array( // Page caching plugins and services.
35 + 'enabler' => 'Cache Enabler',
36 + 'comet' => 'Comet Cache',
37 + 'hummingbird' => 'Hummingbird Cache',
38 + 'litespeed' => 'LiteSpeed Cache',
39 + 'pagely' => 'Pagely Cache',
40 + 'siteground' => 'SiteGround Cache',
41 + 'w3tc' => 'W3 Total Cache',
42 + 'wp-engine' => 'WP Engine cache',
43 + 'wp-fastest' => 'WP Fastest Cache',
44 + 'wp-rocket' => 'WP Rocket Cache',
45 + 'wp-super' => 'WP Super Cache',
46 + ),
47 + 'media' => array(
48 + 'wp-retina-2x' => 'Perfect Images + Retina',
49 + ),
50 + 'p' => array(
51 + 'schema' => 'Schema Markup',
52 + ),
53 + 'seo' => array(
54 + 'jetpack-seo' => 'Jetpack SEO Tools',
55 + 'seoultimate' => 'SEO Ultimate',
56 + 'slim-seo' => 'Slim SEO',
57 + 'squirrlyseo' => 'Squirrly SEO',
58 + 'wpseo-wc' => 'Yoast WooCommerce SEO',
59 + ),
60 + 'util' => array(
61 + 'autoptimize' => 'Autoptimize',
62 + ),
63 + );
64 +
65 + /*
66 + * This class is instantiated before the SucomDebug class, so do not use $this->p->debug to log status messages.
67 + */
68 + public function __construct( &$plugin ) {
69 +
70 + $this->p =& $plugin;
71 + }
72 +
73 + /*
74 + * This method is run once by Wpsso->set_objects() and typically runs in 0.0002 secs.
75 + *
76 + * Do not save or retrieve the array from the transient cache as this is slower than running the method.
77 + *
78 + * Please note that get_avail() is executed before the debug class object is defined, so do not log debugging
79 + * messages using $this->p->debug.
80 + *
81 + * Non-admin PHP library files have been loaded, even if the class object variables have not been defined yet, so
82 + * you can safely call static methods, like SucomUtil::get_const(), for example.
83 + */
84 + public function get_avail() {
85 +
86 + $mtime_start = microtime( $get_float = true );
87 +
88 + $get_avail = array(); // Initialize the array to return.
89 +
90 + $is_admin = is_admin();
91 + $lib_checks = $this->extend_lib_checks;
92 + $lib_checks = SucomUtil::array_merge_recursive_distinct( $lib_checks, $this->p->cf[ '*' ][ 'lib' ][ 'integ' ] );
93 + $lib_checks = SucomUtil::array_merge_recursive_distinct( $lib_checks, $this->p->cf[ '*' ][ 'lib' ][ 'pro' ] );
94 +
95 + foreach ( $lib_checks as $sub => $lib ) {
96 +
97 + $get_avail[ $sub ] = array();
98 +
99 + $get_avail[ $sub ][ 'any' ] = false;
100 +
101 + foreach ( $lib as $id => $name ) {
102 +
103 + $chk = array();
104 +
105 + $get_avail[ $sub ][ $id ] = false; // Default value.
106 +
107 + switch ( $sub ) {
108 +
109 + case 'admin':
110 +
111 + /*
112 + * Load admin modules in back-end.
113 + */
114 + if ( $is_admin ) {
115 +
116 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
117 + }
118 +
119 + break;
120 +
121 + case 'amp':
122 +
123 + switch ( $id ) {
124 +
125 + /*
126 + * AMP.
127 + *
128 + * See https://wordpress.org/plugins/amp/.
129 + */
130 + case 'amp':
131 +
132 + $chk[ 'function' ] = 'is_amp_endpoint';
133 +
134 + break;
135 +
136 + /*
137 + * Accelerated Mobile Pages.
138 + *
139 + * See https://wordpress.org/plugins/accelerated-mobile-pages/.
140 + */
141 + case 'accelerated-mobile-pages':
142 +
143 + $chk[ 'function' ] = 'ampforwp_is_amp_endpoint';
144 +
145 + break;
146 + }
147 +
148 + break;
149 +
150 + case 'cache':
151 +
152 + switch ( $id ) {
153 +
154 + /*
155 + * Cache Enabler.
156 + *
157 + * See https://wordpress.org/plugins/cache-enabler/.
158 + */
159 + case 'enabler':
160 +
161 + $chk[ 'class' ] = 'Cache_Enabler';
162 +
163 + break;
164 +
165 + /*
166 + * Comet Cache.
167 + *
168 + * See https://wordpress.org/plugins/comet-cache/.
169 + */
170 + case 'comet':
171 +
172 + if ( isset( $GLOBALS[ 'comet_cache' ] ) ) {
173 +
174 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
175 + }
176 +
177 + break;
178 +
179 + /*
180 + * Hummingbird Cache.
181 + *
182 + * See https://wordpress.org/plugins/hummingbird-performance/.
183 + */
184 + case 'hummingbird':
185 +
186 + $chk[ 'class' ] = '\Hummingbird\WP_Hummingbird';
187 +
188 + break;
189 +
190 + /*
191 + * LiteSpeed Cache.
192 + *
193 + * See https://wordpress.org/plugins/litespeed-cache/.
194 + */
195 + case 'litespeed':
196 +
197 + $chk[ 'function' ] = 'run_litespeed_cache';
198 +
199 + break;
200 +
201 + /*
202 + * Pagely Cache.
203 + */
204 + case 'pagely':
205 +
206 + $chk[ 'class' ] = 'PagelyCachePurge';
207 +
208 + break;
209 +
210 + /*
211 + * SiteGround Cache.
212 + */
213 + case 'siteground':
214 +
215 + $chk[ 'function' ] = 'sg_cachepress_purge_cache';
216 +
217 + break;
218 +
219 + /*
220 + * W3 Total Cache.
221 + *
222 + * See https://wordpress.org/plugins/w3-total-cache/.
223 + */
224 + case 'w3tc':
225 +
226 + $chk[ 'function' ] = 'w3tc_pgcache_flush';
227 +
228 + break;
229 +
230 + /*
231 + * WP Engine Cache.
232 + */
233 + case 'wp-engine':
234 +
235 + $chk[ 'class' ] = 'WpeCommon';
236 +
237 + break;
238 +
239 + /*
240 + * WP Fastest Cache.
241 + *
242 + * See https://wordpress.org/plugins/wp-fastest-cache/.
243 + */
244 + case 'wp-fastest':
245 +
246 + $chk[ 'function' ] = 'wpfc_clear_all_cache';
247 +
248 + break;
249 +
250 + /*
251 + * WP Rocket Cache.
252 + */
253 + case 'wp-rocket':
254 +
255 + $chk[ 'function' ] = 'rocket_clean_domain';
256 +
257 + break;
258 +
259 + /*
260 + * WP Super Cache.
261 + *
262 + * See https://wordpress.org/plugins/wp-super-cache/.
263 + */
264 + case 'wp-super':
265 +
266 + $chk[ 'function' ] = 'wp_cache_clear_cache';
267 +
268 + break;
269 + }
270 +
271 + break;
272 +
273 + case 'ecom':
274 +
275 + switch ( $id ) {
276 +
277 + /*
278 + * Perfect Brands for WooCommerce.
279 + */
280 + case 'perfect-woocommerce-brands':
281 +
282 + $chk[ 'constant' ] = 'PWB_PLUGIN_VERSION';
283 +
284 + break;
285 +
286 + /*
287 + * WooCommerce.
288 + *
289 + * See https://wordpress.org/plugins/woocommerce/.
290 + */
291 + case 'woocommerce':
292 +
293 + $chk[ 'class' ] = 'WooCommerce';
294 +
295 + $chk[ 'version_const' ] = 'WC_VERSION';
296 +
297 + $chk[ 'min_version' ] = '6.0.0';
298 +
299 + break;
300 +
301 + /*
302 + * WooCommerce Brands.
303 + *
304 + * See woocommerce/includes/class-wc-brands.php.
305 + */
306 + case 'woocommerce-brands':
307 +
308 + $chk[ 'class' ] = 'WC_Brands';
309 +
310 + break;
311 +
312 + /*
313 + * WooCommerce Currency Switcher.
314 + */
315 + case 'woocommerce-currency-switcher':
316 +
317 + $chk[ 'class' ] = 'WOOCS';
318 +
319 + break;
320 +
321 + /*
322 + * WooCommerce UPC, EAN, and ISBN.
323 + */
324 + case 'woo-add-gtin':
325 +
326 + $chk[ 'class' ] = 'Woo_GTIN';
327 +
328 + break;
329 +
330 + /*
331 + * Product GTIN for WooCommerce.
332 + */
333 + case 'wpm-product-gtin-wc':
334 +
335 + $chk[ 'class' ] = 'WPM_Product_GTIN_WC';
336 +
337 + break;
338 +
339 + /*
340 + * YITH WooCommerce Brands Add-on.
341 + */
342 + case 'yith-woocommerce-brands':
343 +
344 + $chk[ 'class' ] = 'YITH_WCBR';
345 +
346 + break;
347 + }
348 +
349 + break;
350 +
351 + case 'data':
352 +
353 + switch ( $id ) {
354 +
355 + /*
356 + * Import All in One SEO Pack metadata.
357 + */
358 + case 'aioseop-meta':
359 +
360 + $chk[ 'opt_key' ] = 'plugin_import_aioseop_meta';
361 +
362 + break;
363 +
364 + /*
365 + * Import Rank Math SEO metadata.
366 + */
367 + case 'rankmath-meta':
368 +
369 + $chk[ 'opt_key' ] = 'plugin_import_rankmath_meta';
370 +
371 + break;
372 +
373 + /*
374 + * Import The SEO Framework metadata.
375 + */
376 + case 'seoframework-meta':
377 +
378 + $chk[ 'opt_key' ] = 'plugin_import_seoframework_meta';
379 +
380 + break;
381 +
382 + /*
383 + * Import WP Meta SEO metadata.
384 + */
385 + case 'wpmetaseo-meta':
386 +
387 + $chk[ 'opt_key' ] = 'plugin_import_wpmetaseo_meta';
388 +
389 + break;
390 +
391 + /*
392 + * Import Yoast SEO block attrs.
393 + */
394 + case 'wpseo-blocks':
395 +
396 + $chk[ 'opt_key' ] = 'plugin_import_wpseo_blocks';
397 +
398 + break;
399 +
400 + /*
401 + * Import Yoast SEO metadata.
402 + */
403 + case 'wpseo-meta':
404 +
405 + $chk[ 'opt_key' ] = 'plugin_import_wpseo_meta';
406 +
407 + break;
408 + }
409 +
410 + break;
411 +
412 + case 'event':
413 +
414 + switch ( $id ) {
415 +
416 + /*
417 + * The Events Calendar.
418 + *
419 + * See https://wordpress.org/plugins/the-events-calendar/.
420 + */
421 + case 'the-events-calendar':
422 +
423 + $chk[ 'class' ] = 'Tribe__Events__Main';
424 +
425 + break;
426 + }
427 +
428 + break;
429 +
430 + case 'form':
431 +
432 + switch ( $id ) {
433 +
434 + case 'gravityforms':
435 +
436 + $chk[ 'class' ] = 'GFForms';
437 +
438 + break;
439 +
440 + case 'gravityview':
441 +
442 + $chk[ 'class' ] = 'GravityView_Plugin';
443 +
444 + break;
445 + }
446 +
447 + break;
448 +
449 + case 'job':
450 +
451 + switch ( $id ) {
452 +
453 + /*
454 + * Simple Job Board.
455 + *
456 + * See https://wordpress.org/plugins/simple-job-board/.
457 + */
458 + case 'simplejobboard':
459 +
460 + $chk[ 'class' ] = 'Simple_Job_Board';
461 +
462 + break;
463 +
464 + /*
465 + * WP Job Manager.
466 + *
467 + * See https://wordpress.org/plugins/wp-job-manager/.
468 + */
469 + case 'wpjobmanager':
470 +
471 + $chk[ 'class' ] = 'WP_Job_Manager';
472 +
473 + break;
474 + }
475 +
476 + break;
477 +
478 + case 'lang':
479 +
480 + switch ( $id ) {
481 +
482 + /*
483 + * GTranslate.
484 + *
485 + * See https://wordpress.org/plugins/gtranslate/.
486 + */
487 + case 'gtranslate':
488 +
489 + $chk[ 'class' ] = 'GTranslate';
490 +
491 + break;
492 +
493 + /*
494 + * Polylang.
495 + *
496 + * See https://wordpress.org/plugins/polylang/.
497 + */
498 + case 'polylang':
499 +
500 + $chk[ 'class' ] = 'Polylang';
501 +
502 + break;
503 +
504 + /*
505 + * qTranslate-XT.
506 + *
507 + * https://github.com/qtranslate/qtranslate-xt.
508 + */
509 + case 'qtranslate-xt':
510 +
511 + $chk[ 'constant' ] = 'QTX_VERSION';
512 +
513 + break;
514 +
515 + /*
516 + * WPML.
517 + *
518 + * See https://wpml.org/.
519 + */
520 + case 'wpml':
521 +
522 + $chk[ 'class' ] = 'SitePress';
523 +
524 + break;
525 + }
526 +
527 + break;
528 +
529 + case 'media':
530 +
531 + switch ( $id ) {
532 +
533 + /*
534 + * Perfect Images (aka WP Retina 2x).
535 + *
536 + * See https://wordpress.org/plugins/wp-retina-2x/.
537 + */
538 + case 'wp-retina-2x':
539 +
540 + $chk[ 'class' ] = 'Meow_WR2X_Core';
541 +
542 + break;
543 +
544 + /*
545 + * Premium edition feature / option.
546 + */
547 + case 'facebook': // Detect Embedded Media: Facebook Video.
548 + case 'slideshare': // Detect Embedded Media: Slideshare Presentation.
549 + case 'soundcloud': // Detect Embedded Media: Soundcloud Track.
550 + case 'vimeo': // Detect Embedded Media: Vimeo Video.
551 + case 'wistia': // Detect Embedded Media: Wistia Video.
552 + case 'wpvideoblock': // Detect Embedded Media: WP Media Library Video Block.
553 + case 'wpvideoshortcode': // Detect Embedded Media: WP Media Library Video Shortcode.
554 + case 'youtube': // Detect Embedded Media: Youtube Videos and Playlist.
555 +
556 + $chk[ 'opt_key' ] = 'plugin_media_' . $id;
557 +
558 + break;
559 +
560 + /*
561 + * Premium edition feature / option.
562 + */
563 + case 'gravatar': // Gravatar is Default Author Image.
564 +
565 + $chk[ 'opt_key' ] = 'plugin_gravatar_image';
566 +
567 + break;
568 +
569 + /*
570 + * Premium edition feature / option.
571 + */
572 + case 'upscale': // Upscale Media Library Images.
573 +
574 + $chk[ 'opt_key' ] = 'plugin_upscale_images';
575 +
576 + break;
577 + }
578 +
579 + break;
580 +
581 + case 'p':
582 +
583 + switch ( $id ) {
584 +
585 + case 'schema':
586 +
587 + $schema_disable = SucomUtil::get_const( 'WPSSO_SCHEMA_MARKUP_DISABLE' );
588 +
589 + $get_avail[ $sub ][ $id ] = $schema_disable ? false : true;
590 +
591 + break;
592 + }
593 +
594 + break;
595 +
596 + case 'rating':
597 +
598 + switch ( $id ) {
599 +
600 + /*
601 + * Rate my Post.
602 + *
603 + * https://wordpress.org/plugins/rate-my-post/
604 + */
605 + case 'rate-my-post':
606 +
607 + $chk[ 'class' ] = 'Rate_My_Post';
608 +
609 + break;
610 +
611 + /*
612 + * WP-PostRatings.
613 + *
614 + * https://wordpress.org/plugins/wp-postratings/
615 + */
616 + case 'wppostratings':
617 +
618 + $chk[ 'constant' ] = 'WP_POSTRATINGS_VERSION';
619 +
620 + break;
621 + }
622 +
623 + break;
624 +
625 + case 'recipe':
626 +
627 + switch ( $id ) {
628 +
629 + /*
630 + * WP Recipe Maker.
631 + *
632 + * See https://wordpress.org/plugins/wp-recipe-maker/.
633 + */
634 + case 'wprecipemaker':
635 +
636 + $chk[ 'class' ] = 'WP_Recipe_Maker';
637 +
638 + break;
639 + }
640 +
641 + break;
642 +
643 + case 'review':
644 +
645 + switch ( $id ) {
646 +
647 + case 'judgeme': // Judge.me.
648 +
649 + $chk[ 'opt_key' ] = array(
650 + 'plugin_ratings_reviews_svc' => 'judgeme',
651 + 'plugin_judgeme_shop_domain' => null, // Any non-empty value.
652 + 'plugin_judgeme_shop_token' => null, // Any non-empty value.
653 + );
654 +
655 + break;
656 +
657 + case 'judgeme-for-wc': // Judge.me Product Reviews for WooCommerce.
658 +
659 + $chk[ 'class' ] = 'JudgeMe';
660 +
661 + break;
662 +
663 + case 'shopperapproved': // Shopper Approved.
664 +
665 + $chk[ 'opt_key' ] = array(
666 + 'plugin_ratings_reviews_svc' => 'shopperapproved',
667 + 'plugin_shopperapproved_site_id' => null, // Any non-empty value.
668 + 'plugin_shopperapproved_token' => null, // Any non-empty value.
669 + );
670 +
671 + break;
672 +
673 + case 'stamped': // Stamped.io.
674 +
675 + $chk[ 'opt_key' ] = array(
676 + 'plugin_ratings_reviews_svc' => 'stamped',
677 + 'plugin_stamped_store_hash' => null, // Any non-empty value.
678 + 'plugin_stamped_key_public' => null, // Any non-empty value.
679 + );
680 +
681 + break;
682 +
683 + /*
684 + * WP Product Review Lite.
685 + *
686 + * See https://wordpress.org/plugins/wp-product-review/.
687 + */
688 + case 'wpproductreview':
689 +
690 + $chk[ 'class' ] = 'WPPR';
691 +
692 + break;
693 +
694 + /*
695 + * Yotpo: Product & Photo Reviews for WooCommerce.
696 + *
697 + * See https://wordpress.org/plugins/yotpo-social-reviews-for-woocommerce/.
698 + */
699 + case 'yotpowc':
700 +
701 + $chk[ 'function' ] = 'wc_yotpo_init';
702 +
703 + break;
704 + }
705 +
706 + break;
707 +
708 + case 'seo':
709 +
710 + switch ( $id ) {
711 +
712 + /*
713 + * All in One SEO Pack.
714 + *
715 + * See https://wordpress.org/plugins/all-in-one-seo-pack/.
716 + */
717 + case 'aioseop':
718 +
719 + $chk[ 'function' ] = 'aioseo';
720 +
721 + break;
722 +
723 + /*
724 + * Jetpack SEO module.
725 + *
726 + * See https://wordpress.org/plugins/jetpack/.
727 + */
728 + case 'jetpack-seo':
729 +
730 + if ( method_exists( 'Jetpack', 'get_active_modules' ) ) {
731 +
732 + $jetpack_modules = Jetpack::get_active_modules();
733 +
734 + if ( in_array( 'seo-tools', $jetpack_modules ) ) {
735 +
736 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
737 + }
738 + }
739 +
740 + break;
741 +
742 + /*
743 + * Rank Math.
744 + *
745 + * See https://wordpress.org/plugins/seo-by-rank-math/.
746 + */
747 + case 'rankmath':
748 +
749 + $chk[ 'class' ] = 'RankMath';
750 +
751 + break;
752 +
753 + /*
754 + * The SEO Framework.
755 + *
756 + * See https://wordpress.org/plugins/autodescription/.
757 + */
758 + case 'seoframework':
759 +
760 + $chk[ 'function' ] = 'the_seo_framework';
761 +
762 + break;
763 +
764 + /*
765 + * SEOPress.
766 + *
767 + * See https://wordpress.org/plugins/wp-seopress/.
768 + */
769 + case 'seopress':
770 +
771 + $chk[ 'function' ] = 'seopress_init';
772 +
773 + break;
774 +
775 + /*
776 + * SEO Ultimate.
777 + *
778 + * See https://wordpress.org/plugins/seo-ultimate/.
779 + */
780 + case 'seoultimate':
781 +
782 + $chk[ 'plugin' ] = 'seo-ultimate/seo-ultimate.php';
783 +
784 + break;
785 +
786 + /*
787 + * Slim SEO.
788 + *
789 + * See https://wordpress.org/plugins/slim-seo/.
790 + */
791 + case 'slim-seo':
792 +
793 + $chk[ 'plugin' ] = 'slim-seo/slim-seo.php';
794 +
795 + break;
796 +
797 + /*
798 + * SEO 2020 by Squirrly.
799 + *
800 + * https://wordpress.org/plugins/squirrly-seo/.
801 + */
802 + case 'squirrlyseo':
803 +
804 + $chk[ 'plugin' ] = 'squirrly-seo/squirrly.php';
805 +
806 + break;
807 +
808 + /*
809 + * WP Meta SEO.
810 + *
811 + * See https://wordpress.org/plugins/wp-meta-seo/.
812 + */
813 + case 'wpmetaseo':
814 +
815 + $chk[ 'class' ] = 'WpMetaSeo';
816 +
817 + break;
818 +
819 + /*
820 + * Yoast SEO.
821 + *
822 + * See https://wordpress.org/plugins/wordpress-seo/.
823 + */
824 + case 'wpseo':
825 +
826 + $chk[ 'function' ] = 'wpseo_init';
827 +
828 + break;
829 +
830 + /*
831 + * Yoast WooCommerce SEO.
832 + *
833 + * https://yoast.com/wordpress/plugins/yoast-woocommerce-seo/.
834 + */
835 + case 'wpseo-wc':
836 +
837 + $chk[ 'class' ] = 'Yoast_WooCommerce_SEO';
838 +
839 + break;
840 + }
841 +
842 + break;
843 +
844 + case 'user':
845 +
846 + switch ( $id ) {
847 +
848 + /*
849 + * Co-Authors Plus.
850 + *
851 + * See https://wordpress.org/plugins/co-authors-plus/.
852 + */
853 + case 'co-authors-plus':
854 +
855 + $chk[ 'plugin' ] = 'co-authors-plus/co-authors-plus.php';
856 +
857 + break;
858 +
859 + /*
860 + * PublishPress Authors.
861 + *
862 + * See https://wordpress.org/plugins/publishpress-authors/.
863 + */
864 + case 'publishpress-authors':
865 +
866 + $chk[ 'constant' ] = 'PP_AUTHORS_VERSION';
867 +
868 + break;
869 +
870 + /*
871 + * Ultimate Member.
872 + *
873 + * See https://wordpress.org/plugins/ultimate-member/.
874 + */
875 + case 'ultimate-member':
876 +
877 + $chk[ 'class' ] = 'UM';
878 +
879 + break;
880 + }
881 +
882 + break;
883 +
884 + case 'util':
885 +
886 + switch ( $id ) {
887 +
888 + /*
889 + * Autoptimize.
890 + *
891 + * See https://wordpress.org/plugins/autoptimize/.
892 + */
893 + case 'autoptimize':
894 +
895 + $chk[ 'class' ] = 'autoptimizeCache';
896 +
897 + break;
898 +
899 + /*
900 + * Yoast Duplicate Post.
901 + */
902 + case 'duplicate-post':
903 +
904 + $chk[ 'constant' ] = 'DUPLICATE_POST_CURRENT_VERSION';
905 +
906 + break;
907 +
908 + /*
909 + * Elementor.
910 + */
911 + case 'elementor':
912 +
913 + $chk[ 'constant' ] = 'ELEMENTOR_VERSION';
914 +
915 + break;
916 +
917 + /*
918 + * Jetpack.
919 + *
920 + * See https://wordpress.org/plugins/jetpack/.
921 + */
922 + case 'jetpack':
923 +
924 + $chk[ 'class' ] = 'Jetpack';
925 +
926 + break;
927 +
928 + /*
929 + * Jetpack Boost.
930 + *
931 + * See https://wordpress.org/plugins/jetpack-boost/.
932 + */
933 + case 'jetpack-boost':
934 +
935 + $chk[ 'constant' ] = 'JETPACK_BOOST_VERSION';
936 +
937 + break;
938 +
939 + /*
940 + * URL Shortening Service.
941 + */
942 + case 'shorten':
943 +
944 + $chk[ 'opt_key' ] = 'plugin_shortener';
945 +
946 + break;
947 + }
948 +
949 + break;
950 + }
951 +
952 + /*
953 + * Check for plugin classes and functions first, to include both free and pro / premium
954 + * plugins that have different plugin slugs, but use the same class or function names.
955 + */
956 + if ( ! empty( $chk ) ) {
957 +
958 + if ( isset( $chk[ 'class' ] ) || isset( $chk[ 'function' ] ) || isset( $chk[ 'plugin' ] ) ) {
959 +
960 + if ( ( ! empty( $chk[ 'class' ] ) && class_exists( $chk[ 'class' ] ) ) ||
961 + ( ! empty( $chk[ 'function' ] ) && function_exists( $chk[ 'function' ] ) ) ||
962 + ( ! empty( $chk[ 'plugin' ] ) && SucomPlugin::is_plugin_active( $chk[ 'plugin' ] ) ) ) {
963 +
964 + $version = false;
965 +
966 + if ( ! empty( $chk[ 'min_version' ] ) ) {
967 +
968 + if ( ! empty( $chk[ 'version_global' ] ) ) {
969 +
970 + $version = $GLOBALS[ $chk[ 'version_global' ] ];
971 +
972 + } elseif ( ! empty( $chk[ 'version_const' ] ) ) {
973 +
974 + $version = constant( $chk[ 'version_const' ] );
975 + }
976 + }
977 +
978 + if ( ! $version || version_compare( $version, $chk[ 'min_version' ], '>=' ) ) {
979 +
980 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
981 + }
982 + }
983 +
984 + } elseif ( isset( $chk[ 'opt_key' ] ) ) {
985 +
986 + if ( is_array( $chk[ 'opt_key' ] ) ) {
987 +
988 + $all_enabled = true;
989 +
990 + foreach ( $chk[ 'opt_key' ] as $key => $val ) {
991 +
992 + if ( ! $this->is_opt_enabled( $key, $val ) ) {
993 +
994 + $all_enabled = false;
995 +
996 + break;
997 + }
998 + }
999 +
1000 + if ( $all_enabled ) {
1001 +
1002 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
1003 + }
1004 +
1005 + } elseif ( $this->is_opt_enabled( $chk[ 'opt_key' ] ) ) {
1006 +
1007 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
1008 + }
1009 +
1010 + } elseif ( isset( $chk[ 'constant' ] ) ) {
1011 +
1012 + if ( defined( $chk[ 'constant' ] ) ) {
1013 +
1014 + $get_avail[ $sub ][ 'any' ] = $get_avail[ $sub ][ $id ] = true;
1015 + }
1016 + }
1017 + }
1018 + }
1019 + }
1020 +
1021 + /*
1022 + * Define WPSSO_UNKNOWN_SEO_PLUGIN_ACTIVE as true to disable WPSSO's SEO related meta tags and features.
1023 + */
1024 + if ( defined( 'WPSSO_UNKNOWN_SEO_PLUGIN_ACTIVE' ) && WPSSO_UNKNOWN_SEO_PLUGIN_ACTIVE ) {
1025 +
1026 + $get_avail[ 'seo' ][ 'any' ] = true;
1027 + }
1028 +
1029 + /*
1030 + * This method is run once by Wpsso->set_objects() and typically runs in 0.0002 secs.
1031 + */
1032 + $get_avail[ 'p' ][ 'avail_mtime' ] = microtime( $get_float = true ) - $mtime_start;
1033 +
1034 + $get_avail = apply_filters( 'wpsso_get_avail', $get_avail );
1035 +
1036 + return $get_avail;
1037 + }
1038 +
1039 + public function is_pp( $ext = null, $read_cache = true ) {
1040 +
1041 + return $this->pp( $ext, $li = true, $rv = true, $read_cache );
1042 + }
1043 +
1044 + public function pp( $ext = null, $li = true, $rv = true, $read_cache = true, $mx = null ) {
1045 +
1046 + static $local_cache = array();
1047 +
1048 + $ext = null === $ext ? $this->p->id : $ext;
1049 + $id = $ext . '-' . $li . '-' . $rv . '-' . $mx;
1050 + $rv = null === $mx ? $rv : $rv * $mx;
1051 +
1052 + if ( $read_cache && isset( $local_cache[ $id ] ) ) {
1053 +
1054 + return $local_cache[ $id ];
1055 +
1056 + } elseif ( defined( 'WPSSO_PRO_DISABLE' ) && WPSSO_PRO_DISABLE ) {
1057 +
1058 + return $local_cache[ $id ] = false;
1059 +
1060 + } elseif ( ! $ext_dir = WpssoConfig::get_ext_dir( $ext ) ) {
1061 +
1062 + return $local_cache[ $id ] = false;
1063 + }
1064 +
1065 + $key = 'plugin_' . $ext . '_tid';
1066 + $pdir = is_dir( $ext_dir . 'lib/pro/' ) ? $rv : false;
1067 + $umv = class_exists( 'WpssoUmConfig' ) && WpssoUmConfig::get_version() ? true : false;
1068 +
1069 + return $local_cache[ $id ] = $li ? ( ( ! empty( $this->p->options[ $key ] ) && $pdir && $umv &&
1070 + ( $ume = SucomUpdate::get_umsg( $ext ) ? false : $pdir ) ) ? $ume : false ) : $pdir;
1071 + }
1072 +
1073 + public function get_ext_gen_list() {
1074 +
1075 + static $local_cache = null;
1076 +
1077 + if ( null !== $local_cache ) {
1078 +
1079 + return $local_cache;
1080 + }
1081 +
1082 + $local_cache = array();
1083 + $ext_sorted = WpssoConfig::get_ext_sorted();
1084 +
1085 + foreach ( $ext_sorted as $ext => $info ) {
1086 +
1087 + if ( empty( $info[ 'version' ] ) ) continue; // Include only active add-ons.
1088 +
1089 + $local_cache[] = $info[ 'short' ] . ' ' . $info[ 'version' ] . '/' . $this->get_ext_status( $ext );
1090 + }
1091 +
1092 + return $local_cache;
1093 + }
1094 +
1095 + public function get_ext_status( $ext ) {
1096 +
1097 + $ext_pdir = $this->pp( $ext, $li = false );
1098 + $ext_tid = $this->get_ext_auth_id( $ext );
1099 + $ext_pp = $ext_tid && WPSSO_UNDEF === $this->pp( $ext, $li = true, WPSSO_UNDEF ) ? true : false;
1100 +
1101 + return ( $ext_pp ? 'L' : ( $ext_pdir ? 'U' : 'S' ) ) . ( $ext_tid ? '*' : '' );
1102 + }
1103 +
1104 + public function get_ext_auth_type( $ext ) {
1105 +
1106 + return empty( $this->p->cf[ 'plugin' ][ $ext ][ 'update_auth' ] ) ? 'none' : $this->p->cf[ 'plugin' ][ $ext ][ 'update_auth' ];
1107 + }
1108 +
1109 + public function get_ext_auth_id( $ext ) {
1110 +
1111 + $ext_auth_type = $this->get_ext_auth_type( $ext );
1112 +
1113 + $ext_auth_key = 'plugin_' . $ext . '_' . $ext_auth_type;
1114 +
1115 + return empty( $this->p->options[ $ext_auth_key ] ) ? '' : $this->p->options[ $ext_auth_key ];
1116 + }
1117 +
1118 + public function is_umver_gt_min() {
1119 +
1120 + static $local_cache = null;
1121 +
1122 + if ( null !== $local_cache ) {
1123 +
1124 + return $local_cache;
1125 + }
1126 +
1127 + if ( isset( $this->p->cf[ 'plugin' ][ 'wpssoum' ][ 'base' ] ) ) {
1128 +
1129 + if ( SucomPlugin::is_plugin_active( $this->p->cf[ 'plugin' ][ 'wpssoum' ][ 'base' ] ) ) {
1130 +
1131 + if ( class_exists( 'WpssoUmConfig' ) ) {
1132 +
1133 + $um_version = WpssoUmConfig::get_version();
1134 + $um_min_ver = WpssoConfig::$cf[ 'um' ][ 'min_version' ];
1135 +
1136 + if ( version_compare( $um_version, $um_min_ver, '>=' ) ) {
1137 +
1138 + return $local_cache = true;
1139 +
1140 + } elseif ( $this->p->debug->enabled ) {
1141 +
1142 + $this->p->debug->log( 'update manager version less than minimum' );
1143 + }
1144 +
1145 + } elseif ( $this->p->debug->enabled ) {
1146 +
1147 + $this->p->debug->log( 'update manager config class not found' );
1148 + }
1149 +
1150 + } elseif ( $this->p->debug->enabled ) {
1151 +
1152 + $this->p->debug->log( 'update manager add-on is not active' );
1153 + }
1154 +
1155 + } elseif ( $this->p->debug->enabled ) {
1156 +
1157 + $this->p->debug->log( 'update manager config not found' );
1158 + }
1159 +
1160 + return $local_cache = false;
1161 + }
1162 +
1163 + private function is_opt_enabled( $key, $val = null ) {
1164 +
1165 + if ( ! empty( $key ) ) { // Just in case.
1166 +
1167 + if ( null === $val ) {
1168 +
1169 + if ( ! empty( $this->p->options[ $key ] ) ) { // Not 0 or empty string.
1170 +
1171 + if ( $this->p->options[ $key ] !== 'none' ) {
1172 +
1173 + return true;
1174 + }
1175 + }
1176 +
1177 + } elseif ( isset( $this->p->options[ $key ] ) ) { // Just in case.
1178 +
1179 + if ( $val === $this->p->options[ $key ] ) {
1180 +
1181 + return true;
1182 + }
1183 + }
1184 + }
1185 +
1186 + return false;
1187 + }
1188 + }
1189 +}