PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.2.2
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 5.2.2 5.3 All 153 releases
mainwp / modules / api-backups / classes / class-api-backups-overview.php

class-api-backups-overview.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.2.2, at modules/api-backups/classes/class-api-backups-overview.php

126 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * =======================================
4 * MainWP API Backups Overview
5 * =======================================
6 *
7 * @package MainWP\Dashboard
8 * @version 5.0
9 */
10
11 namespace MainWP\Dashboard\Module\ApiBackups;
12
13 use function MainWP\Dashboard\mainwp_current_user_have_right;
14 use function MainWP\Dashboard\mainwp_do_not_have_permissions;
15
16 /**
17 * MainWP API Backups Overview
18 */
19 class Api_Backups_Overview {
20
21
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;
28
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 === static::$instance ) {
40 static::$instance = new self();
41 }
42 return static::$instance;
43 }
44
45
46 /**
47 * Constructor.
48 *
49 * Run each time the class is called.
50 */
51 public function __construct() {
52 }
53
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 }
67
68 /**
69 * Get current tab.
70 */
71 public function get_current_tab() {
72 $curent_tab = 'backups';
73 if ( isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
74 $curent_tab = 'settings';
75 }
76 return $curent_tab;
77 }
78
79 /**
80 * Render Tabs.
81 *
82 * Renders the page tabs.
83 */
84 public function render_individual_tabs() {
85 do_action( 'mainwp_pageheader_sites', 'ApiBackups' );
86 ?>
87 <div>
88 <?php
89 if ( static::is_managesites_page() ) {
90 $site_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
91 $website = Api_Backups_Helper::get_website_by_id( $site_id );
92 if ( empty( $site_id ) || empty( $website ) ) {
93 echo '<div class="ui yellow message">' . esc_html__( 'Error: empty site ID', 'mainwp' ) . '</div>';
94 } else {
95 $curent_tab = $this->get_current_tab();
96 if ( 'backups' === $curent_tab ) :
97 Api_Backups_3rd_Party::instance()->render_api_backups_site( $website );
98 elseif ( 'settings' === $curent_tab ) :
99 Api_Backups_Settings::get_instance()->render_settings_content( true );
100 endif;
101 }
102 }
103 ?>
104 </div>
105 <?php
106 do_action( 'mainwp_pagefooter_sites', 'ApiBackups' );
107 }
108
109 /**
110 * Render backups list.
111 */
112 public function render_backups_list() {
113
114 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_api_backups' ) ) {
115 mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
116 return;
117 }
118 Api_Backups_Admin::render_header();
119 ?>
120 <div id="mainwp-module-api-backups-dashboard">
121 <?php Api_Backups_3rd_Party::render_mainwp_backups_page(); ?>
122 </div>
123 <?php
124 }
125 }
126