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
mainwp / widgets / widget-mainwp-site-actions.php

widget-mainwp-site-actions.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.2.2, at widgets/widget-mainwp-site-actions.php

231 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Site Actions Widget
4 *
5 * Displays the Site Actions Info.
6 *
7 * @package MainWP/Dashboard
8 */
9
10 namespace MainWP\Dashboard;
11
12 use MainWP\Dashboard\MainWP_UI;
13 use MainWP\Dashboard\Module\Log\Log_Manager;
14 use MainWP\Dashboard\Module\Log\Log_Events_List_Table;
15 use MainWP\Dashboard\Module\Log\Log_DB_Helper;
16
17 // Exit if accessed directly.
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /**
23 * Class MainWP_Site_Actions
24 *
25 * Displays the Site Actions.
26 */
27 class MainWP_Site_Actions { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
28
29 /**
30 * Private static variable to hold the single instance of the class.
31 *
32 * @static
33 *
34 * @var mixed Default null
35 */
36 private static $instance = null;
37
38 /**
39 * Private static variable to hold the single instance of the events table.
40 *
41 * @static
42 *
43 * @var mixed Default null
44 */
45 private $list_events_table = null;
46
47
48 /**
49 * Private static variable to hold the table type value.
50 *
51 * @var mixed Default null
52 */
53 private $table_id_prefix = 'widget-overview';
54
55 /**
56 * Method instance()
57 *
58 * Create public static instance.
59 *
60 * @static
61 * @return MainWP_Site_Actions
62 */
63 public static function instance() {
64 if ( null === static::$instance ) {
65 static::$instance = new self();
66 }
67 return static::$instance;
68 }
69
70
71 /**
72 * Method get_class_name()
73 *
74 * @return string __CLASS__ Class name.
75 */
76 public static function get_class_name() {
77 return __CLASS__;
78 }
79
80 /**
81 * Method render()
82 *
83 * @return mixed render_site_info()
84 */
85 public static function render() {
86 $current_wpid = MainWP_System_Utility::get_current_wpid();
87 $website = null;
88 $params = array();
89 $params['limit'] = apply_filters( 'mainwp_widget_site_actions_limit_number', 50 );
90 if ( $current_wpid ) {
91 $params = array(
92 'wpid' => $current_wpid,
93 );
94 $website = MainWP_DB::instance()->get_website_by_id( $current_wpid );
95 } elseif ( isset( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
96 $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
97 $params = array(
98 'client_id' => $client_id,
99 );
100 }
101 static::instance()->render_info( $params, $website );
102 }
103
104 /**
105 * Render Sites actions Info.
106 *
107 * @param array $params Events params.
108 * @param object $website Sites info.
109 */
110 private function render_info( $params, $website ) { // phpcs:ignore -- NOSONAR - complex.
111
112 if ( ! is_array( $params ) ) {
113 $params = array();
114 }
115 $this->load_events_list_table();
116 ?>
117
118 <div class="mainwp-widget-header">
119 <div class="ui grid">
120 <div class="fourteen wide column">
121 <h2 class="ui header handle-drag">
122 <?php
123 /**
124 * Filter: mainwp_non_mainwp_changes_widget_title
125 *
126 * Filters the Site info widget title text.
127 *
128 * @param object $website Object containing the child site info.
129 *
130 * @since 4.1
131 */
132 echo esc_html( apply_filters( 'mainwp_non_mainwp_changes_widget_title', esc_html__( 'Network Activity', 'mainwp' ), $website ) );
133 ?>
134 <div class="sub header"><?php esc_html_e( 'The most recent changes made to your Child Sites.', 'mainwp' ); ?></div>
135 </h2>
136 </div>
137 <div class="two wide column right aligned">
138 <div id="widget-sites-changes-dropdown-selector" class="ui dropdown top right tiny pointing not-auto-init mainwp-dropdown-tab">
139 <i class="vertical ellipsis icon"></i>
140 <div class="menu">
141 <a href="javascript:void(0)" class="item" data-value="wp-admin"><?php esc_html_e( 'Non-MainWP Changes', 'mainwp' ); ?></a>
142 <a href="javascript:void(0)" class="item" data-value="dashboard"><?php esc_html_e( 'Dashboard Changes', 'mainwp' ); ?></a>
143 <a href="javascript:void(0)" class="item" data-value=""><?php esc_html_e( 'Show All', 'mainwp' ); ?></a>
144 </div>
145 </div>
146 </div>
147 </div>
148 </div>
149 <input type="hidden" id="mainwp-widget-filter-current-site-id" value="<?php echo isset( $params['wpid'] ) ? intval( $params['wpid'] ) : 0; ?>" />
150 <input type="hidden" id="mainwp-widget-filter-current-client-id" value="<?php echo isset( $params['client_id'] ) ? intval( $params['client_id'] ) : 0; ?>" />
151 <input type="hidden" id="mainwp-widget-filter-events-limit" value="<?php echo isset( $params['limit'] ) ? intval( $params['limit'] ) : 50; ?>" />
152
153 <div id="mainwp-widget-site-actions" class="mainwp-scrolly-overflow">
154 <?php
155 /**
156 * Actoin: mainwp_non_mainwp_changes_widget_top
157 *
158 * Fires at the top of the Site Info widget on the Individual site overview page.
159 *
160 * @param object $website Object containing the child site info.
161 *
162 * @since 4.0
163 */
164 do_action( 'mainwp_non_mainwp_changes_widget_top', $website );
165 ?>
166 <?php
167 /**
168 * Action: mainwp_non_mainwp_changes_table_top
169 *
170 * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
171 *
172 * @param object $website Object containing the child site info.
173 *
174 * @since 4.0
175 */
176 do_action( 'mainwp_non_mainwp_changes_table_top', $website );
177 ?>
178 <div id="mainwp-non-mainwp-changes-feed">
179 <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
180 <?php
181 MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
182 $this->list_events_table->display();
183 ?>
184 </div>
185 <?php
186 /**
187 * Action: mainwp_non_mainwp_changes_table_bottom
188 *
189 * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
190 *
191 * @param object $website Object containing the child site info.
192 *
193 * @since 4.0
194 */
195 do_action( 'mainwp_non_mainwp_changes_table_bottom', $website );
196 ?>
197 </div>
198
199 <div class="mainwp-widget-footer">
200 <div class="ui two columns stackable grid">
201 <div class="left aligned middle aligned column">
202 </div>
203 <div class="right aligned middle aligned column">
204 <a href="admin.php?page=InsightsManage" class="ui mini basic button"><?php esc_html_e( 'View All Changes', 'mainwp' ); ?></a>
205 </div>
206 </div>
207 </div>
208 <?php
209 /**
210 * Action: mainwp_non_mainwp_changes_widget_bottom
211 *
212 * Fires at the bottom of the Site Info widget on the Individual site overview page.
213 *
214 * @param object $website Object containing the child site info.
215 *
216 * @since 4.0
217 */
218 do_action( 'mainwp_non_mainwp_changes_widget_bottom', $website );
219 }
220
221 /**
222 * Method load_sites_table()
223 *
224 * Load sites table.
225 */
226 public function load_events_list_table() {
227 $manager = Log_Manager::instance();
228 $this->list_events_table = new Log_Events_List_Table( $manager, $this->table_id_prefix );
229 }
230 }
231