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-overview.php +99 -99 5.0.3 → 6.2.2 View file →
@@ -9,10 +9,12 @@
9 9 */
10 10
11 11 namespace MainWP\Dashboard\Module\ApiBackups;
12 12
13 -use function MainWP\Dashboard\mainwp_current_user_have_right;
14 -use function MainWP\Dashboard\mainwp_do_not_have_permissions;
13 +// Exit if accessed directly.
14 +if ( ! defined( 'ABSPATH' ) ) {
15 + exit;
16 +}
15 17
16 18 /**
17 19 * MainWP API Backups Overview
18 20 */
@@ -18,110 +20,108 @@
18 20 */
19 21 class Api_Backups_Overview {
20 22
21 23
22 - /**
23 - * Public static variable to hold the single instance of the class.
24 - *
25 - * @var mixed Default null
26 - */
27 - public static $instance = null;
24 + /**
25 + * Public static variable to hold the single instance of the class.
26 + *
27 + * @var mixed Default null
28 + */
29 + public static $instance = null;
28 30
29 - /**
30 - * Get Instance
31 - *
32 - * Creates public static instance.
33 - *
34 - * @static
35 - *
36 - * @return Api_Backups_Overview
37 - */
38 - public static function get_instance() {
39 - if ( null === self::$instance ) {
40 - self::$instance = new self();
41 - }
42 - return self::$instance;
43 - }
31 + /**
32 + * Get Instance
33 + *
34 + * Creates public static instance.
35 + *
36 + * @static
37 + *
38 + * @return Api_Backups_Overview
39 + */
40 + public static function get_instance() {
41 + if ( null === static::$instance ) {
42 + static::$instance = new self();
43 + }
44 + return static::$instance;
45 + }
44 46
45 47
46 - /**
47 - * Constructor.
48 - *
49 - * Run each time the class is called.
50 - */
51 - public function __construct() {
52 - }
48 + /**
49 + * Constructor.
50 + *
51 + * Run each time the class is called.
52 + */
53 + public function __construct() {
54 + }
53 55
54 - /**
55 - * Sites Page Check
56 - *
57 - * Checks if the current page is individual site Cache Control page.
58 - *
59 - * @return bool True if correct, false if not.
60 - */
61 - public static function is_managesites_page() {
62 - if ( isset( $_GET['page'] ) && ( 'ManageSitesApiBackups' === $_GET['page'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
63 - return true;
64 - }
65 - return false;
66 - }
56 + /**
57 + * Sites Page Check
58 + *
59 + * Checks if the current page is individual site Cache Control page.
60 + *
61 + * @return bool True if correct, false if not.
62 + */
63 + public static function is_managesites_page() {
64 + if ( isset( $_GET['page'] ) && ( 'ManageSitesApiBackups' === $_GET['page'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
65 + return true;
66 + }
67 + return false;
68 + }
67 69
68 - /**
69 - * Get current tab.
70 - */
71 - public function get_current_tab() {
72 - $curent_tab = 'backups';
73 - if ( isset( $_GET['tab'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
74 - if ( 'settings' === $_GET['tab'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
75 - $curent_tab = 'settings';
76 - }
77 - }
78 - return $curent_tab;
79 - }
70 + /**
71 + * Get current tab.
72 + */
73 + public function get_current_tab() {
74 + $curent_tab = 'backups';
75 + if ( isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
76 + $curent_tab = 'settings';
77 + }
78 + return $curent_tab;
79 + }
80 80
81 - /**
82 - * Render Tabs.
83 - *
84 - * Renders the page tabs.
85 - */
86 - public function render_individual_tabs() {
87 - do_action( 'mainwp_pageheader_sites', 'ApiBackups' );
88 - ?>
89 - <div>
90 - <?php
91 - if ( self::is_managesites_page() ) {
92 - $site_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
93 - $website = Api_Backups_Helper::get_website_by_id( $site_id );
94 - if ( empty( $site_id ) || empty( $website ) ) {
95 - echo '<div class="ui yellow message">' . esc_html__( 'Error: empty site ID', 'mainwp' ) . '</div>';
96 - } else {
97 - $curent_tab = $this->get_current_tab();
98 - if ( 'backups' === $curent_tab ) :
99 - Api_Backups_3rd_Party::instance()->render_api_backups_site( $website );
100 - elseif ( 'settings' === $curent_tab ) :
101 - Api_Backups_Settings::get_instance()->render_settings_content( true );
102 - endif;
103 - }
104 - }
105 - ?>
106 - </div>
107 - <?php
108 - do_action( 'mainwp_pagefooter_sites', 'ApiBackups' );
109 - }
81 + /**
82 + * Render Tabs.
83 + *
84 + * Renders the page tabs.
85 + */
86 + public function render_individual_tabs() {
87 + do_action( 'mainwp_pageheader_sites', 'ApiBackups' );
88 + ?>
89 + <div>
90 + <?php
91 + if ( static::is_managesites_page() ) {
92 + $site_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
93 + $website = Api_Backups_Helper::get_website_by_id( $site_id );
94 + if ( empty( $site_id ) || empty( $website ) ) {
95 + echo '<div class="ui yellow message">' . esc_html__( 'Error: empty site ID', 'mainwp' ) . '</div>';
96 + } else {
97 + $curent_tab = $this->get_current_tab();
98 + if ( 'backups' === $curent_tab ) :
99 + Api_Backups_3rd_Party::instance()->render_api_backups_site( $website );
100 + elseif ( 'settings' === $curent_tab ) :
101 + Api_Backups_Settings::get_instance()->render_settings_content( true );
102 + endif;
103 + }
104 + }
105 + ?>
106 + </div>
107 + <?php
108 + do_action( 'mainwp_pagefooter_sites', 'ApiBackups' );
109 + }
110 110
111 - /**
112 - * Render backups list.
113 - */
114 - public function render_backups_list() {
111 + /**
112 + * Render backups list.
113 + */
114 + public function render_backups_list() {
115 115
116 - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_api_backups' ) ) {
117 - mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
118 - return;
119 - }
120 - Api_Backups_Admin::render_header();
121 - ?>
122 - <div id="mainwp-module-api-backups-dashboard">
123 - <?php Api_Backups_3rd_Party::render_mainwp_backups_page(); ?>
124 - </div>
125 - <?php
126 - }
116 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_api_backups' ) ) {
117 + \mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
118 + return;
119 + }
120 + Api_Backups_Admin::render_header();
121 + ?>
122 + <div id="mainwp-module-api-backups-dashboard">
123 + <?php Api_Backups_3rd_Party::render_mainwp_backups_page(); ?>
124 + </div>
125 + <?php
126 + }
127 127 }