| @@ -9,15 +9,16 @@ | ||
| 9 | 9 | * |
| 10 | 10 | * @since 1.0 |
| 11 | 11 | * @since 2.8 Renamed from PLL_Plugins_Compat to PLL_Integrations. |
| 12 | 12 | */ |
| 13 | +#[AllowDynamicProperties] | |
| 13 | 14 | class PLL_Integrations { |
| 14 | 15 | /** |
| 15 | 16 | * Singleton instance. |
| 16 | 17 | * |
| 17 | - * @var PLL_Integrations | |
| 18 | + * @var PLL_Integrations|null | |
| 18 | 19 | */ |
| 19 | - protected static $instance; | |
| 20 | + protected static $instance = null; | |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Constructor. |
| 23 | 24 | * |
| @@ -22,28 +23,38 @@ | ||
| 22 | 23 | * Constructor. |
| 23 | 24 | * |
| 24 | 25 | * @since 1.0 |
| 25 | 26 | */ |
| 26 | - protected function __construct() { | |
| 27 | - // Loads external integrations. | |
| 28 | - foreach ( glob( __DIR__ . '/*/load.php', GLOB_NOSORT ) as $load_script ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable | |
| 29 | - require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable | |
| 30 | - } | |
| 31 | - } | |
| 27 | + protected function __construct() {} | |
| 32 | 28 | |
| 33 | 29 | /** |
| 34 | - * Access to the single instance of the class. | |
| 30 | + * Returns the single instance of the class. | |
| 35 | 31 | * |
| 36 | 32 | * @since 1.7 |
| 37 | 33 | * |
| 38 | - * @return object | |
| 34 | + * @return self | |
| 39 | 35 | */ |
| 40 | - public static function instance() { | |
| 41 | - if ( empty( self::$instance ) ) { | |
| 36 | + public static function instance(): self { | |
| 37 | + if ( null === self::$instance ) { | |
| 42 | 38 | self::$instance = new self(); |
| 39 | + self::$instance->init(); | |
| 43 | 40 | } |
| 44 | 41 | |
| 45 | 42 | return self::$instance; |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Requires integrations. | |
| 47 | + * | |
| 48 | + * @since 3.7 | |
| 49 | + * | |
| 50 | + * @return void | |
| 51 | + */ | |
| 52 | + protected function init(): void { | |
| 53 | + // Loads external integrations. | |
| 54 | + foreach ( glob( __DIR__ . '/*/load.php', GLOB_NOSORT ) as $load_script ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable | |
| 55 | + require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable | |
| 56 | + } | |
| 46 | 57 | } |
| 47 | 58 | } |
| 48 | 59 | |
| 49 | 60 | class_alias( 'PLL_Integrations', 'PLL_Plugins_Compat' ); // For Backward compatibility. |