PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.1
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 5.2.2 5.3 5.3.1 All 152 releases
mainwp / includes / class-mainwp-setup.php

class-mainwp-setup.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.1, at includes/class-mainwp-setup.php

126 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP setup
4 *
5 * @package MainWP\Dashboard
6 * @since 5.1.1
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * MainWP Setup Class.
13 */
14 final class MainWP_Setup {
15
16 /**
17 * The single instance of the class.
18 *
19 * @var Setup
20 */
21 protected static $_instance = null; //phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
22
23 /**
24 * API instance
25 *
26 * @var MainWP_API
27 */
28 public $api;
29
30 /**
31 * Main Instance.
32 *
33 * Ensures only one instance loaded or can be loaded.
34 *
35 * @static
36 * @return Main instance.
37 */
38 public static function instance() {
39 if ( is_null( self::$_instance ) ) {
40 self::$_instance = new self();
41 }
42 return self::$_instance;
43 }
44
45 /**
46 * Constructor.
47 */
48 public function __construct() {
49 $this->includes();
50 $this->init_hooks();
51 }
52
53
54 /**
55 * Hook into actions and filters.
56 *
57 * @since 5.1.1
58 */
59 private function init_hooks() {
60 add_action( 'init', array( $this, 'load_rest_api' ) );
61 }
62
63 /**
64 * Returns true if the request is a non-legacy REST API request.
65 *
66 * Legacy REST requests should still run some extra code for backwards compatibility.
67 *
68 * @to_do: replace this function once core WP function is available: https://core.trac.wordpress.org/ticket/42061.
69 *
70 * @return bool
71 */
72 public function is_rest_api_request() {
73
74 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
75 return false;
76 }
77
78 $rest_prefix = trailingslashit( rest_get_url_prefix() );
79 $is_rest_api_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) ); // phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
80
81 /**
82 * Whether this is a REST API request.
83 *
84 * @since 5.1.1
85 */
86 return apply_filters( 'mainwp_is_rest_api_request', $is_rest_api_request );
87 }
88
89
90 /**
91 * Load REST API.
92 */
93 public function load_rest_api() {
94 MainWP_Rest_Server::instance()->init();
95 }
96
97
98 /**
99 * Include required core files used in admin.
100 */
101 public function includes() {
102 /**
103 * REST API.
104 */
105 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version1/class-mainwp-rest-api-v1.php';
106 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version1/class-mainwp-rest-api-v1-helper.php';
107
108 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/class-mainwp-rest-authentication.php';
109 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/class-mainwp-rest-server.php';
110
111 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-controller.php';
112 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-sites-controller.php';
113 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-clients-controller.php';
114 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-tags-controller.php';
115 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-updates-controller.php';
116 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-global-batch-controller.php';
117 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-monitors-controller.php';
118 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-api-keys-controller.php';
119 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-settings-controller.php';
120 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-posts-controller.php';
121 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-pages-controller.php';
122 include_once MAINWP_PLUGIN_DIR . 'includes/rest-api/controller/version2/class-mainwp-rest-users-controller.php';
123 }
124 }
125 MainWP_Setup::instance();
126