PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0
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.0, at modules/api-backups/classes/class-api-backups-overview.php

128 lines 3.0 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 === self::$instance ) {
40 self::$instance = new self();
41 }
42 return self::$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'] ) ) { //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 }
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();
102 endif;
103 }
104 }
105 ?>
106 </div>
107 <?php
108 do_action( 'mainwp_pagefooter_sites', 'ApiBackups' );
109 }
110
111 /**
112 * Render backups list.
113 */
114 public function render_backups_list() {
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 }
127 }
128