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

128 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 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * MainWP API Backups Overview
20 */
21 class Api_Backups_Overview {
22
23
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;
30
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 }
46
47
48 /**
49 * Constructor.
50 *
51 * Run each time the class is called.
52 */
53 public function __construct() {
54 }
55
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 }
69
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
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
111 /**
112 * Render backups list.
113 */
114 public function render_backups_list() {
115
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 }
128