| 1 |
<?php |
| 2 |
/** |
| 3 |
* Module Api Backups classes loading. |
| 4 |
* |
| 5 |
* @package MainWP\Dashboard |
| 6 |
* @version 5.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace MainWP\Dashboard\Module\ApiBackups; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* Logs class. |
| 15 |
*/ |
| 16 |
class MainWP_Module_Api_Backups { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. |
| 17 |
/** |
| 18 |
* Load required files and hooks to make the CLI work. |
| 19 |
*/ |
| 20 |
public function __construct() { |
| 21 |
$this->includes(); |
| 22 |
add_filter( 'mainwp_init_load_all_options', array( $this, 'hook_load_options' ) ); |
| 23 |
add_action( 'mainwp_system_init', array( $this, 'hook_mainwp_system_init' ) ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Method get_instance(). |
| 28 |
*/ |
| 29 |
public static function get_instance() { |
| 30 |
return new self(); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Load files. |
| 35 |
*/ |
| 36 |
private function includes() { |
| 37 |
$dir = MAINWP_MODULES_DIR; |
| 38 |
if ( mainwp_modules_is_enabled( 'api-backups' ) && file_exists( $dir . 'api-backups/classes/class-api-backups-manager.php' ) ) { |
| 39 |
require_once $dir . 'api-backups/classes/class-api-backups-manager.php'; // NOSONAR - WP compatible. |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Handle mainwp system init load options. |
| 45 |
* |
| 46 |
* @param array $all_opts All loading mainwp options. |
| 47 |
* @return array $all_opts All loading mainwp options. |
| 48 |
*/ |
| 49 |
public function hook_load_options( $all_opts ) { |
| 50 |
return $all_opts; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Handle mainwp system init. |
| 55 |
*/ |
| 56 |
public function hook_mainwp_system_init() { |
| 57 |
if ( mainwp_modules_is_enabled( 'api-backups' ) && class_exists( '\MainWP\Dashboard\Module\ApiBackups\Api_Backups_Manager' ) ) { |
| 58 |
include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR - WP compatible. |
| 59 |
// disable the api backups extension to prevent some conflicted UIs. |
| 60 |
if ( function_exists( '\is_plugin_active' ) && is_plugin_active( 'mainwp-api-backups-extension/mainwp-api-backups-extension.php' ) && function_exists( '\deactivate_plugins' ) ) { |
| 61 |
deactivate_plugins( 'mainwp-api-backups-extension/mainwp-api-backups-extension.php' ); |
| 62 |
} |
| 63 |
Api_Backups_Manager::get_instance(); |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
MainWP_Module_Api_Backups::get_instance(); |
| 69 |
|