PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | modules/api-backups/classes/class-api-backups-manager.php +81 -76 5.0 → 6.2.2 View file →
@@ -7,8 +7,13 @@
7 7 */
8 8
9 9 namespace MainWP\Dashboard\Module\ApiBackups;
10 10
11 +// Exit if accessed directly.
12 +if ( ! defined( 'ABSPATH' ) ) {
13 + exit;
14 +}
15 +
11 16 /**
12 17 * Class Api_Backups_Manager
13 18 */
14 19 class Api_Backups_Manager {
@@ -13,91 +18,91 @@
13 18 */
14 19 class Api_Backups_Manager {
15 20
16 21
17 - /**
18 - * Static variable to hold the single instance of the class.
19 - *
20 - * @static
21 - *
22 - * @var mixed Default null
23 - */
24 - public static $instance = null;
22 + /**
23 + * Static variable to hold the single instance of the class.
24 + *
25 + * @static
26 + *
27 + * @var mixed Default null
28 + */
29 + public static $instance = null;
25 30
26 - /**
27 - * Get Instance
28 - *
29 - * Creates public static instance.
30 - *
31 - * @static
32 - *
33 - * @return Api_Backups_Manager
34 - */
35 - public static function get_instance() {
36 - if ( null === self::$instance ) {
37 - self::$instance = new self();
38 - }
39 - return self::$instance;
40 - }
31 + /**
32 + * Get Instance
33 + *
34 + * Creates public static instance.
35 + *
36 + * @static
37 + *
38 + * @return Api_Backups_Manager
39 + */
40 + public static function get_instance() {
41 + if ( null === static::$instance ) {
42 + static::$instance = new self();
43 + }
44 + return static::$instance;
45 + }
41 46
42 - /**
43 - * Constructor
44 - *
45 - * Runs each time the class is called.
46 - */
47 - public function __construct() {
48 - spl_autoload_register( array( $this, 'autoload' ) );
49 - Api_Backups_Admin::get_instance();
50 - }
47 + /**
48 + * Constructor
49 + *
50 + * Runs each time the class is called.
51 + */
52 + public function __construct() {
53 + spl_autoload_register( array( $this, 'autoload' ) );
54 + Api_Backups_Admin::get_instance();
55 + }
51 56
52 - /**
53 - * Autoloader for classes.
54 - *
55 - * @param string $class_name class name.
56 - */
57 - public function autoload( $class_name ) {
57 + /**
58 + * Autoloader for classes.
59 + *
60 + * @param string $class_name class name.
61 + */
62 + public function autoload( $class_name ) {
58 63
59 - if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class_name, $matches ) ) {
60 - return;
61 - }
64 + if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class_name, $matches ) ) {
65 + return;
66 + }
62 67
63 - static $reflection;
68 + static $reflection;
64 69
65 - if ( empty( $reflection ) ) {
66 - $reflection = new \ReflectionObject( $this );
67 - }
70 + if ( empty( $reflection ) ) {
71 + $reflection = new \ReflectionObject( $this );
72 + }
68 73
69 - if ( $reflection->getNamespaceName() !== $matches['namespace'] ) {
70 - return;
71 - }
74 + if ( $reflection->getNamespaceName() !== $matches['namespace'] ) {
75 + return;
76 + }
72 77
73 - $autoload_name = $matches['autoload'];
74 - $autoload_dir = self::get_location_path();
78 + $autoload_name = $matches['autoload'];
79 + $autoload_dir = static::get_location_path();
75 80
76 - $load_dirs = array(
77 - 'classes' => 'class',
78 - );
79 - foreach ( $load_dirs as $dir => $prefix ) {
80 - $dir = $dir . DIRECTORY_SEPARATOR;
81 - $autoload_path = sprintf( '%s%s%s-%s.php', $autoload_dir, $dir, $prefix, strtolower( str_replace( '_', '-', $autoload_name ) ) );
82 - if ( is_readable( $autoload_path ) ) {
83 - require_once $autoload_path;
84 - return;
85 - }
86 - }
87 - }
81 + $load_dirs = array(
82 + 'classes' => 'class',
83 + );
84 + foreach ( $load_dirs as $dir => $prefix ) {
85 + $dir = $dir . DIRECTORY_SEPARATOR;
86 + $autoload_path = sprintf( '%s%s%s-%s.php', $autoload_dir, $dir, $prefix, strtolower( str_replace( '_', '-', $autoload_name ) ) );
87 + if ( is_readable( $autoload_path ) ) {
88 + require_once $autoload_path; // NOSONAR - WP compatible.
89 + return;
90 + }
91 + }
92 + }
88 93
89 - /**
90 - * Method get_location().
91 - *
92 - * @param string $path what to get path/url.
93 - *
94 - * @return string value.
95 - */
96 - public static function get_location_path( $path = 'dir' ) {
97 - $location = array(
98 - 'dir' => MAINWP_MODULES_DIR . 'api-backups' . DIRECTORY_SEPARATOR,
99 - 'url' => MAINWP_MODULES_URL . 'api-backups/',
100 - );
101 - return isset( $location[ $path ] ) ? $location[ $path ] : '';
102 - }
94 + /**
95 + * Method get_location().
96 + *
97 + * @param string $path what to get path/url.
98 + *
99 + * @return string value.
100 + */
101 + public static function get_location_path( $path = 'dir' ) {
102 + $location = array(
103 + 'dir' => MAINWP_MODULES_DIR . 'api-backups' . DIRECTORY_SEPARATOR,
104 + 'url' => MAINWP_MODULES_URL . 'api-backups/',
105 + );
106 + return isset( $location[ $path ] ) ? $location[ $path ] : '';
107 + }
103 108 }