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
wpsso / lib / abstract / add-on.php

add-on.php in WPSSO Core – Complete Schema Markup and Meta Tags 22.7.0, at lib/abstract/add-on.php

109 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * License: GPLv3
4 * License URI: https://www.gnu.org/licenses/gpl.txt
5 * Copyright 2014-2026 Jean-Sebastien Morisset (https://surniaulula.com/)
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9
10 die( 'These aren\'t the droids you\'re looking for.' );
11 }
12
13 if ( ! class_exists( 'SucomAbstractAddOn' ) ) {
14
15 require_once dirname( __FILE__ ) . '/com/add-on.php'; // SucomAbstractAddOn class.
16 }
17
18 if ( ! class_exists( 'WpssoAbstractAddOn' ) ) {
19
20 abstract class WpssoAbstractAddOn extends SucomAbstractAddOn {
21
22 protected $p; // Wpsso class object.
23 protected $ext = ''; // Add-on lowercase classname.
24 protected $p_ext = ''; // Add-on lowercase acronym.
25 protected $cf = array(); // Add-on config array.
26
27 public $reg; // Add-on register class object.
28
29 /*
30 * Called from the child class as parent::__construct( __FILE__, __CLASS__ ).
31 */
32 public function __construct( $plugin_file, $classname ) {
33
34 $plugin_dir = trailingslashit( dirname( $plugin_file ) );
35 $config_class = $classname . 'Config';
36 $register_class = $classname . 'Register';
37 $this->ext = strtolower( $classname );
38 $this->p_ext = str_replace( 'wpsso', '', $this->ext );
39
40 require_once $plugin_dir . '/lib/config.php';
41
42 $config_class::set_constants( $plugin_file );
43 $config_class::require_libs( $plugin_file ); // Includes the register.php class library.
44
45 $this->cf =& $config_class::$cf;
46
47 $this->reg = new $register_class(); // Activate, deactivate, uninstall hooks.
48
49 $this->add_hooks( $plugin_file );
50 }
51
52 protected function add_hooks( $plugin_file ) {
53
54 /*
55 * WPSSO filter hooks.
56 */
57 add_filter( 'wpsso_get_config', array( $this, 'get_config' ), 10, 1 );
58
59 add_filter( 'wpsso_get_avail', array( $this, 'get_avail' ), 10, 1 );
60
61 /*
62 * WPSSO action hooks.
63 */
64 foreach ( array(
65 'init_textdomain' => 0,
66 'init_objects_preloader' => 0,
67 'init_objects' => 0,
68 'init_check_options' => 0,
69 ) as $method => $args_num ) {
70
71 if ( method_exists( $this, $method ) ) {
72
73 add_action( 'wpsso_' . $method, array( $this, $method ), 10, $args_num );
74 }
75 }
76
77 /*
78 * The SucomAbstractAddOn->init_plugin_notices() method adds toolbar notices for any missing requirements.
79 */
80 add_action( 'wpsso_init_plugin', array( $this, 'init_plugin_notices' ), 100, 0 );
81
82 /*
83 * If SucomAbstractAddOn->init_plugin_notices() is not executed, then show any missing requirements using
84 * the standard WordPress admin notices action.
85 */
86 add_action( 'all_admin_notices', array( $this, 'show_admin_notices' ), 100, 0 );
87
88 /*
89 * Declare compatibility with WooCommerce features.
90 */
91 if ( ! empty( $this->cf[ 'plugin' ][ $this->ext ][ 'wc_compat' ] ) ) {
92
93 $wc_compat = $this->cf[ 'plugin' ][ $this->ext ][ 'wc_compat' ];
94
95 add_action( 'before_woocommerce_init', function () use ( $plugin_file, $wc_compat ) {
96
97 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
98
99 foreach ( $wc_compat as $feature ) {
100
101 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( $feature, $plugin_file, true );
102 }
103 }
104 }, 10, 0 );
105 }
106 }
107 }
108 }
109