| 1 |
<?php |
| 2 |
/** |
| 3 |
* PSM Deactivation Feedback Framework |
| 4 |
* |
| 5 |
* @package PSM_DFR |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
if ( class_exists( 'PSM_DFR', false ) ) { |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
final class PSM_DFR { |
| 17 |
|
| 18 |
/** |
| 19 |
* Registered plugins. |
| 20 |
* |
| 21 |
* @var array |
| 22 |
*/ |
| 23 |
private static $plugins = array(); |
| 24 |
|
| 25 |
/** |
| 26 |
* Framework booted. |
| 27 |
* |
| 28 |
* @var bool |
| 29 |
*/ |
| 30 |
private static $booted = false; |
| 31 |
|
| 32 |
/** |
| 33 |
* Register plugin. |
| 34 |
* |
| 35 |
* @param array $config Plugin configuration. |
| 36 |
* |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public static function init( $config ) { |
| 40 |
|
| 41 |
$defaults = array( |
| 42 |
'plugin_file' => '', |
| 43 |
'plugin_name' => '', |
| 44 |
'plugin_version' => '', |
| 45 |
'endpoint' => '', |
| 46 |
'api_key' => '', |
| 47 |
'reasons' => array(), |
| 48 |
); |
| 49 |
|
| 50 |
$config = wp_parse_args( $config, $defaults ); |
| 51 |
|
| 52 |
if ( empty( $config['plugin_file'] ) ) { |
| 53 |
return; |
| 54 |
} |
| 55 |
|
| 56 |
self::$plugins[ $config['plugin_file'] ] = $config; |
| 57 |
|
| 58 |
if ( self::$booted ) { |
| 59 |
return; |
| 60 |
} |
| 61 |
|
| 62 |
self::$booted = true; |
| 63 |
|
| 64 |
require_once __DIR__ . '/class-psm-dfr-admin.php'; |
| 65 |
require_once __DIR__ . '/class-psm-dfr-ajax.php'; |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Get plugins. |
| 70 |
* |
| 71 |
* @return array |
| 72 |
*/ |
| 73 |
public static function get_plugins() { |
| 74 |
return self::$plugins; |
| 75 |
} |
| 76 |
} |
| 77 |
|