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 | pages/page-mainwp-client-overview.php +489 -466 5.0 → 6.2.2 View file →
@@ -1,532 +1,555 @@
1 1 <?php
2 2 /**
3 3 * MainWP Client Overview Page.
4 4 *
5 - * @package MainWP/Dashboard
5 + * @package MainWP/Dashboard
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_Overview
12 17 *
13 18 * @package MainWP\Dashboard
14 19 */
15 -class MainWP_Client_Overview {
20 +class MainWP_Client_Overview { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16 21
17 - /**
18 - * Get Class Name
19 - *
20 - * @return string __CLASS__
21 - */
22 - public static function get_class_name() {
23 - return __CLASS__;
24 - }
22 + /**
23 + * Get Class Name
24 + *
25 + * @return string __CLASS__
26 + */
27 + public static function get_class_name() {
28 + return __CLASS__;
29 + }
25 30
26 - /**
27 - * The single instance of the class
28 - *
29 - * @var mixed Default null
30 - */
31 - protected static $instance = null;
31 + /**
32 + * The single instance of the class
33 + *
34 + * @var mixed Default null
35 + */
36 + protected static $instance = null;
32 37
33 - /**
34 - * Enabled widgets
35 - *
36 - * @var array $enable_widgets
37 - */
38 - private static $enable_widgets = array(
39 - 'overview' => true,
40 - 'note' => true,
41 - 'fields_info' => true,
42 - 'websites' => true,
43 - 'recent_posts' => true,
44 - 'recent_pages' => true,
45 - 'non_mainwp_changes' => true,
46 - );
38 + /**
39 + * Enabled widgets
40 + *
41 + * @var array $enable_widgets
42 + */
43 + private static $enable_widgets = array(
44 + 'overview' => true,
45 + 'note' => true,
46 + 'fields_info' => true,
47 + 'websites' => true,
48 + 'recent_posts' => true,
49 + 'recent_pages' => true,
50 + 'non_mainwp_changes' => true,
51 + );
47 52
48 - /**
49 - * Current page.
50 - *
51 - * @static
52 - * @var string $page Current page.
53 - */
54 - public static $page;
53 + /**
54 + * Current page.
55 + *
56 + * @static
57 + * @var string $page Current page.
58 + */
59 + public static $page;
55 60
56 - /**
57 - * Check if there is a session,
58 - * if there isn't one create it.
59 - *
60 - * @return self::singlton Overview Page Session.
61 - *
62 - * @uses \MainWP\Dashboard\MainWP_Overview
63 - */
64 - public static function instance() {
65 - if ( null === self::$instance ) {
66 - self::$instance = new self();
67 - }
61 + /**
62 + * Check if there is a session,
63 + * if there isn't one create it.
64 + *
65 + * @return static::singlton Overview Page Session.
66 + *
67 + * @uses \MainWP\Dashboard\MainWP_Overview
68 + */
69 + public static function instance() {
70 + if ( null === static::$instance ) {
71 + static::$instance = new self();
72 + }
68 73
69 - return self::$instance;
70 - }
74 + return static::$instance;
75 + }
71 76
72 - /**
73 - * MainWP_Overview constructor.
74 - *
75 - * Run each time the class is called.
76 - */
77 - public function __construct() {
78 - add_filter( 'screen_layout_columns', array( &$this, 'on_screen_layout_columns' ), 10, 2 );
79 - add_action( 'mainwp_help_sidebar_content', array( &$this, 'mainwp_help_content' ) );
80 - }
77 + /**
78 + * MainWP_Overview constructor.
79 + *
80 + * Run each time the class is called.
81 + */
82 + public function __construct() {
83 + add_filter( 'screen_layout_columns', array( &$this, 'on_screen_layout_columns' ), 10, 2 );
84 + add_action( 'mainwp_help_sidebar_content', array( &$this, 'mainwp_help_content' ) );
85 + }
81 86
82 - /**
83 - * Set the number of page coumns.
84 - *
85 - * @param mixed $columns Number of Columns.
86 - * @param mixed $screen Screen size.
87 - *
88 - * @return int $columns Number of desired page columns.
89 - */
90 - public function on_screen_layout_columns( $columns, $screen ) {
91 - if ( $screen === self::$page ) {
92 - $columns[ self::$page ] = 3;
93 - }
87 + /**
88 + * Set the number of page coumns.
89 + *
90 + * @param mixed $columns Number of Columns.
91 + * @param mixed $screen Screen size.
92 + *
93 + * @return int $columns Number of desired page columns.
94 + */
95 + public function on_screen_layout_columns( $columns, $screen ) {
96 + if ( $screen === static::$page ) {
97 + $columns[ static::$page ] = 3;
98 + }
94 99
95 - return $columns;
96 - }
100 + return $columns;
101 + }
97 102
98 103
99 - /**
100 - * Method on_load_page()
101 - *
102 - * Run on page load.
103 - *
104 - * @param mixed $page Page name.
105 - */
106 - public static function on_load_page( $page ) {
104 + /**
105 + * Method on_load_page()
106 + *
107 + * Run on page load.
108 + *
109 + * @param mixed $page Page name.
110 + */
111 + public static function on_load_page( $page ) {
107 112
108 - self::$page = $page;
113 + static::$page = $page;
109 114
110 - $val = get_user_option( 'screen_layout_' . $page );
111 - if ( ! $val ) {
112 - global $current_user;
113 - update_user_option( $current_user->ID, 'screen_layout_' . $page, 2, true );
114 - }
115 + $val = get_user_option( 'screen_layout_' . $page );
116 + if ( ! $val ) {
117 + global $current_user;
118 + update_user_option( $current_user->ID, 'screen_layout_' . $page, 2, true );
119 + }
115 120
116 - wp_enqueue_script( 'common' );
117 - wp_enqueue_script( 'wp-lists' );
118 - wp_enqueue_script( 'postbox' );
119 - wp_enqueue_script( 'dashboard' );
120 - wp_enqueue_script( 'widgets' );
121 + wp_enqueue_script( 'common' );
122 + wp_enqueue_script( 'wp-lists' );
123 + wp_enqueue_script( 'postbox' );
124 + wp_enqueue_script( 'dashboard' );
125 + wp_enqueue_script( 'widgets' );
121 126
122 - self::add_meta_boxes( $page );
127 + static::add_meta_boxes( $page );
123 128
124 - add_filter( 'mainwp_header_actions_right', array( self::get_class_name(), 'screen_options' ), 10, 2 );
125 - }
129 + add_filter( 'mainwp_header_actions_right', array( static::get_class_name(), 'screen_options' ), 10, 2 );
130 + }
126 131
127 - /**
128 - * Method screen_options()
129 - *
130 - * Create Page Settings button.
131 - *
132 - * @param mixed $input Page Settings button HTML.
133 - *
134 - * @return mixed Page Settings button.
135 - */
136 - public static function screen_options( $input ) {
137 - return $input .
138 - '<a class="ui button basic icon" onclick="mainwp_clients_overview_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '">
139 - <i class="cog icon"></i>
140 - </a>';
141 - }
132 + /**
133 + * Method screen_options()
134 + *
135 + * Create Page Settings button.
136 + *
137 + * @param mixed $input Page Settings button HTML.
138 + *
139 + * @return mixed Page Settings button.
140 + */
141 + public static function screen_options( $input ) {
142 + return $input .
143 + '<a class="ui button basic icon" onclick="mainwp_clients_overview_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '">
144 + <i class="cog icon"></i>
145 + </a>';
146 + }
142 147
143 - /**
144 - * Method add_meta_boxes()
145 - *
146 - * Add MainWP Overview Page Widgets.
147 - *
148 - * @param array $page Current page.
149 - *
150 - * @uses \MainWP\Dashboard\MainWP_System_Handler::apply_filters()
151 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
152 - * @uses \MainWP\Dashboard\MainWP_UI::add_widget_box()
153 - * @uses \MainWP\Dashboard\MainWP_Connection_Status::get_class_name()
154 - * @uses \MainWP\Dashboard\MainWP_Recent_Pages::get_class_name()
155 - * @uses \MainWP\Dashboard\MainWP_Recent_Posts::get_class_name()
156 - * @uses \MainWP\Dashboard\MainWP_Security_Issues_Widget::get_class_name()
157 - * @uses \MainWP\Dashboard\MainWP_Updates_Overview::get_class_name()
158 - */
159 - public static function add_meta_boxes( $page ) { // phpcs:ignore -- complex method. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
148 + /**
149 + * Method add_meta_boxes()
150 + *
151 + * Add MainWP Overview Page Widgets.
152 + *
153 + * @param array $page Current page.
154 + *
155 + * @uses \MainWP\Dashboard\MainWP_System_Handler::apply_filters()
156 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
157 + * @uses \MainWP\Dashboard\MainWP_UI::add_widget_box()
158 + * @uses \MainWP\Dashboard\MainWP_Connection_Status::get_class_name()
159 + * @uses \MainWP\Dashboard\MainWP_Recent_Pages::get_class_name()
160 + * @uses \MainWP\Dashboard\MainWP_Recent_Posts::get_class_name()
161 + * @uses \MainWP\Dashboard\MainWP_Security_Issues_Widget::get_class_name()
162 + * @uses \MainWP\Dashboard\MainWP_Updates_Overview::get_class_name()
163 + */
164 + public static function add_meta_boxes( $page ) { // phpcs:ignore -- NOSONAR - complex method. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
160 165
161 - /**
162 - * Get getmetaboxes
163 - *
164 - * Adds metaboxes (widgets) to the Overview page.
165 - *
166 - * @since 4.3
167 - */
168 - $extMetaBoxs = array();
169 - $extMetaBoxs = apply_filters( 'mainwp_clients_getmetaboxes', $extMetaBoxs );
170 - foreach ( $extMetaBoxs as $box ) {
171 - if ( isset( $box['plugin'] ) ) {
172 - $name = basename( $box['plugin'], '.php' );
173 - self::$enable_widgets[ $name ] = true;
174 - } elseif ( ! empty( $box['widget_id'] ) ) {
175 - self::$enable_widgets[ $box['widget_id'] ] = true;
176 - }
177 - }
166 + /**
167 + * Get getmetaboxes
168 + *
169 + * Adds metaboxes (widgets) to the Operations page.
170 + *
171 + * @since 4.3
172 + */
173 + $extMetaBoxs = array();
174 + $extMetaBoxs = apply_filters( 'mainwp_clients_getmetaboxes', $extMetaBoxs );
175 + foreach ( $extMetaBoxs as $box ) {
176 + if ( isset( $box['plugin'] ) ) {
177 + $name = basename( $box['plugin'], '.php' );
178 + static::$enable_widgets[ $name ] = true;
179 + } elseif ( ! empty( $box['widget_id'] ) ) {
180 + static::$enable_widgets[ $box['widget_id'] ] = true;
181 + }
182 + }
178 183
179 - $client_contacts = array();
180 - if ( isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
181 - $client_contacts = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'client_id', intval( $_GET['client_id'] ), ARRAY_A ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
182 - }
184 + $client_contacts = array();
185 + if ( isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
186 + $client_contacts = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'client_id', intval( $_GET['client_id'] ), ARRAY_A ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
187 + }
183 188
184 - if ( is_array( $client_contacts ) ) {
185 - foreach ( $client_contacts as $contact ) {
186 - self::$enable_widgets[ 'contact_' . $contact['contact_id'] ] = true;
187 - }
188 - }
189 - $values = self::$enable_widgets;
189 + if ( is_array( $client_contacts ) ) {
190 + foreach ( $client_contacts as $contact ) {
191 + static::$enable_widgets[ 'contact_' . $contact['contact_id'] ] = true;
192 + }
193 + }
194 + $values = static::$enable_widgets;
190 195
191 - /**
192 - * Unset unwanted Widgets
193 - *
194 - * Contains the list of enabled widgets and allows user to unset unwanted widgets.
195 - *
196 - * @param array $values Array containing enabled widgets.
197 - * @param int $dashboard_siteid Child site (Overview) ID.
198 - *
199 - * @since 4.3
200 - */
201 - $values = apply_filters( 'mainwp_clients_overview_enabled_widgets', $values, null );
202 - self::$enable_widgets = array_merge( self::$enable_widgets, $values );
196 + /**
197 + * Unset unwanted Widgets
198 + *
199 + * Contains the list of enabled widgets and allows user to unset unwanted widgets.
200 + *
201 + * @param array $values Array containing enabled widgets.
202 + * @param int $dashboard_siteid Child site (Operations) ID.
203 + *
204 + * @since 4.3
205 + */
206 + $values = apply_filters( 'mainwp_clients_overview_enabled_widgets', $values, null );
207 + static::$enable_widgets = array_merge( static::$enable_widgets, $values );
203 208
204 - $i = 1;
205 - foreach ( $extMetaBoxs as $metaBox ) {
206 - $enabled = true;
207 - if ( isset( $metaBox['plugin'] ) ) {
208 - $name = basename( $metaBox['plugin'], '.php' );
209 - if ( isset( self::$enable_widgets[ $name ] ) && ! self::$enable_widgets[ $name ] ) {
210 - $enabled = false;
211 - }
212 - }
209 + // Load the Overview widget.
210 + if ( static::$enable_widgets['overview'] ) {
211 + MainWP_UI::add_widget_box( 'overview', array( MainWP_Client_Overview_Info::get_class_name(), 'render' ), $page, array( -1, -1, 3, 40 ) );
212 + }
213 213
214 - $id = isset( $metaBox['id'] ) ? $metaBox['id'] : $i++;
215 - $id = 'advanced-' . $id;
214 + // Load the Notes widget.
215 + if ( static::$enable_widgets['note'] ) {
216 + MainWP_UI::add_widget_box( 'note', array( MainWP_Client_Overview_Note::get_class_name(), 'render' ), $page, array( -1, -1, 3, 40 ) );
217 + }
216 218
217 - $layout = ! empty( $metaBox['layout'] ) && is_array( $metaBox['layout'] ) ? $metaBox['layout'] : array( 1, 1, 4, 11 );
219 + // Load the Websites widget.
220 + if ( static::$enable_widgets['websites'] ) {
221 + MainWP_UI::add_widget_box( 'websites', array( MainWP_Client_Overview_Sites::get_class_name(), 'render' ), $page, array( -1, -1, 6, 40 ) );
222 + }
218 223
219 - if ( $enabled ) {
220 - MainWP_UI::add_widget_box( $id, $metaBox['callback'], $page, $layout );
221 - }
222 - }
224 + // Load the Info widget.
225 + if ( static::$enable_widgets['fields_info'] ) {
226 + MainWP_UI::add_widget_box( 'fields_info', array( MainWP_Client_Overview_Custom_Info::get_class_name(), 'render' ), $page, array( -1, -1, 6, 30 ) );
227 + }
223 228
224 - // Load the Non-MainWP Changes widget.
225 - if ( self::$enable_widgets['non_mainwp_changes'] ) {
226 - MainWP_UI::add_widget_box( 'non_mainwp_changes', array( MainWP_Site_Actions::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
227 - }
229 + // Load the Non-MainWP Changes widget.
230 + if ( static::$enable_widgets['non_mainwp_changes'] ) {
231 + MainWP_UI::add_widget_box( 'non_mainwp_changes', array( MainWP_Site_Actions::get_class_name(), 'render' ), $page, array( -1, -1, 6, 30 ) );
232 + }
228 233
229 - // Load the Recent Pages widget.
230 - if ( self::$enable_widgets['recent_pages'] ) {
231 - MainWP_UI::add_widget_box( 'recent_pages', array( MainWP_Recent_Pages::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
232 - }
234 + // Load the Recent Posts widget.
235 + if ( static::$enable_widgets['recent_posts'] ) {
236 + MainWP_UI::add_widget_box( 'recent_posts', array( MainWP_Recent_Posts::get_class_name(), 'render' ), $page, array( -1, -1, 6, 30 ) );
237 + }
233 238
234 - // Load the Recent Posts widget.
235 - if ( self::$enable_widgets['recent_posts'] ) {
236 - MainWP_UI::add_widget_box( 'recent_posts', array( MainWP_Recent_Posts::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
237 - }
239 + // Load the Recent Pages widget.
240 + if ( static::$enable_widgets['recent_pages'] ) {
241 + MainWP_UI::add_widget_box( 'recent_pages', array( MainWP_Recent_Pages::get_class_name(), 'render' ), $page, array( -1, -1, 6, 30 ) );
242 + }
238 243
239 - // Load the Notes widget.
240 - if ( self::$enable_widgets['note'] ) {
241 - MainWP_UI::add_widget_box( 'note', array( MainWP_Client_Overview_Note::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
242 - }
244 + if ( is_array( $client_contacts ) ) {
245 + foreach ( $client_contacts as $contact ) {
246 + if ( isset( static::$enable_widgets[ 'contact_' . $contact['contact_id'] ] ) && static::$enable_widgets[ 'contact_' . $contact['contact_id'] ] ) {
247 + $contact_widget = new MainWP_Client_Overview_Contacts();
248 + $contact_widget->contact = $contact;
249 + MainWP_UI::add_widget_box( 'contact_' . $contact['contact_id'], array( $contact_widget, 'render' ), $page, array( -1, -1, 3, 30 ) );
250 + }
251 + }
252 + }
243 253
244 - if ( is_array( $client_contacts ) ) {
245 - foreach ( $client_contacts as $contact ) {
246 - if ( isset( self::$enable_widgets[ 'contact_' . $contact['contact_id'] ] ) && self::$enable_widgets[ 'contact_' . $contact['contact_id'] ] ) {
247 - $contact_widget = new MainWP_Client_Overview_Contacts();
248 - $contact_widget->contact = $contact;
249 - MainWP_UI::add_widget_box( 'contact_' . $contact['contact_id'], array( $contact_widget, 'render' ), $page, array( 1, 1, 4, 9 ) );
250 - }
251 - }
252 - }
254 + $i = 1;
255 + foreach ( $extMetaBoxs as $metaBox ) {
256 + $enabled = true;
257 + if ( isset( $metaBox['plugin'] ) ) {
258 + $name = basename( $metaBox['plugin'], '.php' );
259 + if ( isset( static::$enable_widgets[ $name ] ) && ! static::$enable_widgets[ $name ] ) {
260 + $enabled = false;
261 + }
262 + }
253 263
254 - // Load the Websites widget.
255 - if ( self::$enable_widgets['websites'] ) {
256 - MainWP_UI::add_widget_box( 'websites', array( MainWP_Client_Overview_Sites::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
257 - }
264 + $id = isset( $metaBox['id'] ) ? $metaBox['id'] : $i++;
265 + $id = 'advanced-' . $id;
258 266
259 - // Load the Info widget.
260 - if ( self::$enable_widgets['fields_info'] ) {
261 - MainWP_UI::add_widget_box( 'fields_info', array( MainWP_Client_Overview_Custom_Info::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
262 - }
267 + $layout = ! empty( $metaBox['layout'] ) && is_array( $metaBox['layout'] ) ? $metaBox['layout'] : array( -1, -1, 6, 30 );
263 268
264 - // Load the Overview widget.
265 - if ( self::$enable_widgets['overview'] ) {
266 - MainWP_UI::add_widget_box( 'overview', array( MainWP_Client_Overview_Info::get_class_name(), 'render' ), $page, array( 1, 1, 4, 9 ) );
267 - }
268 - }
269 + if ( $enabled ) {
270 + MainWP_UI::add_widget_box( $id, $metaBox['callback'], $page, $layout );
271 + }
272 + }
273 + }
269 274
270 - /**
271 - * Method on_show_page()
272 - *
273 - * When the page loads render the body content.
274 - */
275 - public function on_show_page() {
276 - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_clients' ) && ! mainwp_current_user_have_right( 'dashboard', 'access_client_dashboard' ) ) {
277 - mainwp_do_not_have_permissions( esc_html__( 'client dashboard', 'mainwp' ) );
278 - return;
279 - }
275 + /**
276 + * Method on_show_page()
277 + *
278 + * When the page loads render the body content.
279 + */
280 + public function on_show_page() {
281 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_clients' ) && ! \mainw\mainwp_current_user_can( 'dashboard', 'access_client_dashboard' ) ) {
282 + \mainwp_do_not_have_permissions( esc_html__( 'client dashboard', 'mainwp' ) );
283 + return;
284 + }
280 285
281 - /**
282 - * Screen layout columns array.
283 - *
284 - * @global object
285 - */
286 - global $screen_layout_columns;
286 + /**
287 + * Screen layout columns array.
288 + *
289 + * @global object
290 + */
291 + global $screen_layout_columns;
287 292
288 - MainWP_Client::render_header( 'overview' );
293 + MainWP_Client::render_header( 'overview' );
289 294
290 - self::render_dashboard_body();
291 - ?>
292 - </div>
293 - <?php
294 - }
295 + static::render_dashboard_body();
296 + ?>
297 + </div>
298 + <?php
299 + }
295 300
296 - /**
297 - * Method render_dashboard_body()
298 - *
299 - * Render the Dashboard Body content.
300 - */
301 - public static function render_dashboard_body() {
302 - $screen = get_current_screen();
303 - $clientid = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
304 - ?>
305 - <div class="mainwp-primary-content-wrap">
306 - <div id="mainwp-message-zone" class="ui message" style="display:none;"></div>
307 - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'client-widgets' ) ) : ?>
308 - <div class="ui info message">
309 - <i class="close icon mainwp-notice-dismiss" notice-id="client-widgets"></i>
310 - <?php printf( esc_html__( 'To hide or show a widget, click the Cog (%1$s) icon.', 'mainwp' ), '<i class="cog icon"></i>' ); ?>
311 - </div>
312 - <?php endif; ?>
313 - <?php
314 - /**
315 - * Action: mainwp_before_overview_widgets
316 - *
317 - * Fires at the top of the Overview page (before first widget).
318 - *
319 - * @since 4.3
320 - */
321 - do_action( 'mainwp_before_overview_widgets', 'clients' );
322 - ?>
323 - <div id="mainwp-grid-wrapper" class="gridster">
324 - <?php MainWP_UI::do_widget_boxes( $screen->id ); ?>
325 - </div>
326 - <?php
327 - /**
328 - * Action: 'mainwp_after_overview_widgets'
329 - *
330 - * Fires at the bottom of the Overview page (after the last widget).
331 - *
332 - * @since 4.3
333 - */
334 - do_action( 'mainwp_after_overview_widgets', 'clients' );
335 - ?>
336 - <script type="text/javascript">
337 - jQuery( document ).ready( function( $ ) {
301 + /**
302 + * Method render_dashboard_body()
303 + *
304 + * Render the Dashboard Body content.
305 + */
306 + public static function render_dashboard_body() {
338 307
339 - jQuery( '.mainwp-widget .mainwp-dropdown-tab .item' ).tab();
308 + MainWP_Ui_Manage_Widgets_Layout::render_modal_save_layout();
340 309
341 - mainwp_clients_overview_screen_options = function () {
342 - jQuery( '#mainwp-clients-overview-screen-options-modal' ).modal( {
343 - allowMultiple: true,
344 - onHide: function () {
345 - }
346 - } ).modal( 'show' );
347 - return false;
348 - };
349 - jQuery('#reset-clients-overview-settings').on('click', function () {
350 - mainwp_confirm(__('Are you sure.'), function(){
351 - jQuery('.mainwp_hide_wpmenu_checkboxes input[name="mainwp_show_widgets[]"]').prop('checked', true);
352 - jQuery('input[name=reset_client_overview_settings]').attr('value', 1);
353 - jQuery('#submit-client-overview-settings').click();
354 - }, false, false, true);
355 - return false;
356 - });
357 - } );
358 - </script>
359 - <div class="ui modal" id="mainwp-clients-overview-screen-options-modal">
360 - <i class="close icon"></i>
361 - <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
362 - <div class="content ui form">
363 - <?php
364 - /**
365 - * Action: mainwp_clients_overview_screen_options_top
366 - *
367 - * Fires at the top of the Sceen Options modal on the Overview page.
368 - *
369 - * @since 4.1
370 - */
371 - do_action( 'mainwp_clients_overview_screen_options_top' );
372 - ?>
373 - <form method="POST" action="" name="mainwp_clients_overview_screen_options_form" id="mainwp-clients-overview-screen-options-form">
374 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
375 - <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPClientsScrOptions' ) ); ?>" />
376 - <?php self::render_screen_options( false ); ?>
377 - <?php
378 - /**
379 - * Action: mainwp_clients_overview_screen_options_bottom
380 - *
381 - * Fires at the bottom of the Sceen Options modal on the Overview page.
382 - *
383 - * @since 4.1
384 - */
385 - do_action( 'mainwp_clients_overview_screen_options_bottom' );
386 - ?>
387 - </div>
388 - <div class="actions">
389 - <div class="ui two columns grid">
390 - <div class="left aligned column">
391 - <span data-tooltip="<?php esc_attr_e( 'Resets the page to its original layout and reinstates relocated widgets.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><input type="button" class="ui button" name="reset" id="reset-clients-overview-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span>
392 - </div>
393 - <div class="ui right aligned column">
394 - <input type="submit" class="ui green button" id="submit-client-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
395 - </div>
396 - </div>
397 - </div>
310 + $screen = get_current_screen();
311 + ?>
312 + <div class="mainwp-primary-content-wrap">
313 + <div class="ui segment">
314 + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'client-widgets' ) ) : ?>
315 + <div class="ui message" style="margin:1em;">
316 + <i class="close icon mainwp-notice-dismiss" notice-id="client-widgets"></i>
317 + <?php /* translators: 1: bulb emoji, 2: cog icon, 3: layout icon */ printf( esc_html__( '%1$s Tip: You can drag and drop widgets to reorder your dashboard, use Page Settings (%2$s) to show or hide widgets, and use Layout (%3$s) in the header to save and load your widget layouts.', 'mainwp' ), '<em data-emoji=":bulb:" class="small"></em>', '<i class="cog fitted icon"></i>', '<i class="all border fitted icon"></i>' ); ?>
318 + </div>
319 + <?php endif; ?>
320 + <div id="mainwp-message-zone" class="ui message" style="display:none;"></div>
321 + <?php do_action( 'mainwp_module_log_render_db_update_notice' ); ?>
322 + <?php do_action( 'mainwp_module_log_render_db_size_notice', 300, 'client_overview' ); ?>
323 + <?php
324 + /**
325 + * Action: mainwp_before_overview_widgets
326 + *
327 + * Fires at the top of the Operations page (before first widget).
328 + *
329 + * @since 4.3
330 + */
331 + do_action( 'mainwp_before_overview_widgets', 'clients' );
332 + ?>
333 + <div id="mainwp-grid-wrapper" class="gridster">
334 + <div id="mainwp-widgets-placeholder" class="ui page dimmer">
335 + <div class="ui double text loader"><?php esc_html_e( 'Loading...', 'mainwp' ); ?></div>
336 + </div>
337 + <script>
338 + jQuery( document ).ready( function () {
339 + jQuery('#mainwp-widgets-placeholder').dimmer('show');
340 + });
341 + </script>
342 + <?php MainWP_UI::do_widget_boxes( $screen->id ); ?>
343 + </div>
344 + <?php
345 + /**
346 + * Action: 'mainwp_after_overview_widgets'
347 + *
348 + * Fires at the bottom of the Operations page (after the last widget).
349 + *
350 + * @since 4.3
351 + */
352 + do_action( 'mainwp_after_overview_widgets', 'clients' );
353 + ?>
354 + </div>
355 + <script type="text/javascript">
356 + jQuery( document ).ready( function( $ ) {
398 357
399 - <input type="hidden" name="reset_client_overview_settings" value="" />
400 - </form>
401 - </div>
402 - </div>
403 - <?php
404 - }
358 + jQuery( '.mainwp-widget .mainwp-dropdown-tab .item' ).tab();
405 359
406 - /**
407 - * Method render_screen_options()
408 - *
409 - * Render Page Settings.
410 - *
411 - * @return void Render Page Settings html.
412 - */
413 - public static function render_screen_options() { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated.
360 + mainwp_clients_overview_screen_options = function () {
361 + jQuery( '#mainwp-clients-overview-screen-options-modal' ).modal( {
362 + allowMultiple: true,
363 + onHide: function () {
364 + }
365 + } ).modal( 'show' );
366 + return false;
367 + };
368 + jQuery('#reset-clients-overview-settings').on('click', function () {
369 + mainwp_confirm(__('Are you sure?'), function(){
370 + jQuery('.mainwp_hide_wpmenu_checkboxes input[name="mainwp_show_widgets[]"]').prop('checked', true);
371 + jQuery('input[name=reset_client_overview_settings]').attr('value', 1);
372 + jQuery('#submit-client-overview-settings').click();
373 + }, false, false, true);
374 + return false;
375 + });
376 + } );
377 + </script>
378 + <div class="ui modal" id="mainwp-clients-overview-screen-options-modal">
379 + <i class="close icon"></i>
380 + <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
381 + <div class="content ui form">
382 + <?php
383 + /**
384 + * Action: mainwp_clients_overview_screen_options_top
385 + *
386 + * Fires at the top of the Sceen Options modal on the Operations page.
387 + *
388 + * @since 4.1
389 + */
390 + do_action( 'mainwp_clients_overview_screen_options_top' );
391 + ?>
392 + <form method="POST" action="" name="mainwp_clients_overview_screen_options_form" id="mainwp-clients-overview-screen-options-form">
393 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
394 + <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPClientsScrOptions' ) ); ?>" />
395 + <?php static::render_screen_options( false ); ?>
396 + <?php
397 + /**
398 + * Action: mainwp_clients_overview_screen_options_bottom
399 + *
400 + * Fires at the bottom of the Sceen Options modal on the Operations page.
401 + *
402 + * @since 4.1
403 + */
404 + do_action( 'mainwp_clients_overview_screen_options_bottom' );
405 + ?>
406 + </div>
407 + <div class="actions">
408 + <div class="ui two columns grid">
409 + <div class="left aligned column">
410 + <span data-tooltip="<?php esc_attr_e( 'Resets the page to its original layout and reinstates relocated widgets.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><input type="button" class="ui button" name="reset" id="reset-clients-overview-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span>
411 + </div>
412 + <div class="ui right aligned column">
413 + <input type="submit" class="ui green button" id="submit-client-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
414 + </div>
415 + </div>
416 + </div>
414 417
415 - $default_widgets = array(
416 - 'overview' => esc_html__( 'Overview', 'mainwp' ),
417 - 'note' => esc_html__( 'Notes', 'mainwp' ),
418 - 'fields_info' => esc_html__( 'Addition Info', 'mainwp' ),
419 - 'websites' => esc_html__( 'Websites', 'mainwp' ),
420 - 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
421 - 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
422 - 'non_mainwp_changes' => esc_html__( 'Non-MainWP Changes', 'mainwp' ),
423 - );
418 + <input type="hidden" name="reset_client_overview_settings" value="" />
419 + </form>
420 + </div>
421 + </div>
422 + <?php
423 + }
424 424
425 - if ( isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
426 - $client_contacts = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'client_id', intval( $_GET['client_id'] ), ARRAY_A ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
427 - if ( $client_contacts ) {
428 - foreach ( $client_contacts as $contact ) {
429 - $default_widgets[ 'contact_' . $contact['contact_id'] ] = esc_html( $contact['contact_name'] );
425 + /**
426 + * Method render_screen_options()
427 + *
428 + * Render Page Settings.
429 + *
430 + * @return void Render Page Settings html.
431 + */
432 + public static function render_screen_options() { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
430 433
431 - }
432 - }
433 - }
434 + $default_widgets = array(
435 + 'overview' => esc_html__( 'Overview', 'mainwp' ),
436 + 'note' => esc_html__( 'Notes', 'mainwp' ),
437 + 'fields_info' => esc_html__( 'Addition Info', 'mainwp' ),
438 + 'websites' => esc_html__( 'Websites', 'mainwp' ),
439 + 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
440 + 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
441 + 'non_mainwp_changes' => esc_html__( 'Network Activity', 'mainwp' ),
442 + );
434 443
435 - $custom_opts = array();
436 - /**
437 - * Filter: mainwp_clients_widgets_screen_options
438 - *
439 - * Filters available widgets on the Overview page allowing users to unsent unwanted widgets.
440 - *
441 - * @since 4.0
442 - */
443 - $custom_opts = apply_filters( 'mainwp_clients_widgets_screen_options', $custom_opts );
444 + if ( isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
445 + $client_contacts = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'client_id', intval( $_GET['client_id'] ), ARRAY_A ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
446 + if ( $client_contacts ) {
447 + foreach ( $client_contacts as $contact ) {
448 + $default_widgets[ 'contact_' . $contact['contact_id'] ] = esc_html( $contact['contact_name'] );
444 449
445 - if ( is_array( $custom_opts ) && 0 < count( $custom_opts ) ) {
446 - $default_widgets = array_merge( $default_widgets, $custom_opts );
447 - }
450 + }
451 + }
452 + }
448 453
449 - $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
450 - if ( ! is_array( $show_widgets ) ) {
451 - $show_widgets = array();
452 - }
454 + $custom_opts = array();
455 + /**
456 + * Filter: mainwp_clients_widgets_screen_options
457 + *
458 + * Filters available widgets on the Operations page allowing users to unset unwanted widgets.
459 + *
460 + * @since 4.0
461 + */
462 + $custom_opts = apply_filters( 'mainwp_clients_widgets_screen_options', $custom_opts );
453 463
454 - /**
455 - * Action: mainwp_screen_options_modal_top
456 - *
457 - * Fires at the top of the Page Settings modal element.
458 - *
459 - * @since 4.1
460 - */
461 - do_action( 'mainwp_screen_options_modal_top' );
462 - ?>
463 - <?php if ( isset( $_GET['page'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
464 - <div class="ui grid field">
465 - <label class="six wide column"><?php esc_html_e( 'Show widgets', 'mainwp' ); ?></label>
466 - <div class="ten wide column" <?php echo 'data-tooltip="' . esc_attr_e( 'Select widgets that you want to hide in the MainWP Overview page.', 'mainwp' ); ?> data-inverted="" data-position="top left">
467 - <ul class="mainwp_hide_wpmenu_checkboxes">
468 - <?php
469 - foreach ( $default_widgets as $name => $title ) {
470 - $_selected = '';
471 - if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
472 - $_selected = 'checked';
473 - }
474 - ?>
475 - <li>
476 - <div class="ui checkbox">
477 - <input type="checkbox" id="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" name="mainwp_show_widgets[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
478 - <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
479 - </div>
480 - <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
481 - </li>
482 - <?php
483 - }
484 - ?>
485 - </ul>
486 - </div>
487 - </div>
488 - <?php endif; ?>
489 - <?php
490 - /**
491 - * Action: mainwp_screen_options_modal_bottom
492 - *
493 - * Fires at the bottom of the Page Settings modal element.
494 - *
495 - * @since 4.1
496 - */
497 - do_action( 'mainwp_screen_options_modal_bottom' );
498 - }
464 + if ( is_array( $custom_opts ) && ! empty( $custom_opts ) ) {
465 + $default_widgets = array_merge( $default_widgets, $custom_opts );
466 + }
499 467
468 + $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
469 + if ( ! is_array( $show_widgets ) ) {
470 + $show_widgets = array();
471 + }
500 472
501 - /**
502 - * Method mainwp_help_content()
503 - *
504 - * Hook the section help content to the Help Sidebar element
505 - *
506 - * @return void
507 - */
508 - public static function mainwp_help_content() {
509 - if ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
510 - ?>
511 - <p><?php esc_html_e( 'If you need help with your MainWP Dashboard, please review following help documents', 'mainwp' ); ?></p>
512 - <div class="ui relaxed bulleted list">
513 - <div class="item"><a href="https://kb.mainwp.com/docs/manage-clients/" target="_blank">Manage Clients</a> <i class="external alternate icon"></i></div>
514 - <?php
515 - /**
516 - * Action: mainwp_clients_overview_help_item
517 - *
518 - * Fires at the bottom of the help articles list in the Help sidebar on the Overview page.
519 - *
520 - * Suggested HTML markup:
521 - *
522 - * <div class="item"><a href="Your custom URL">Your custom text</a></div>
523 - *
524 - * @since 4.3
525 - */
526 - do_action( 'mainwp_clients_overview_help_item' );
527 - ?>
528 - </div>
529 - <?php
530 - }
531 - }
473 + /**
474 + * Action: mainwp_screen_options_modal_top
475 + *
476 + * Fires at the top of the Page Settings modal element.
477 + *
478 + * @since 4.1
479 + */
480 + do_action( 'mainwp_screen_options_modal_top' );
481 + ?>
482 + <?php if ( isset( $_GET['page'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
483 + <div class="ui grid field">
484 + <label class="six wide column"><?php esc_html_e( 'Show widgets', 'mainwp' ); ?></label>
485 + <div class="ten wide column" <?php echo 'data-tooltip="' . esc_attr__( 'Select widgets that you want to hide in the MainWP Operations page.', 'mainwp' ) . '"'; ?> data-inverted="" data-position="top left">
486 + <ul class="mainwp_hide_wpmenu_checkboxes">
487 + <?php
488 + foreach ( $default_widgets as $name => $title ) {
489 + $_selected = '';
490 + if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
491 + $_selected = 'checked';
492 + }
493 + ?>
494 + <li>
495 + <div class="ui checkbox">
496 + <input type="checkbox" id="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" name="mainwp_show_widgets[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
497 + <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
498 + </div>
499 + <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
500 + </li>
501 + <?php
502 + }
503 + ?>
504 + </ul>
505 + </div>
506 + </div>
507 + <?php endif; ?>
508 + <?php
509 + /**
510 + * Action: mainwp_screen_options_modal_bottom
511 + *
512 + * Fires at the bottom of the Page Settings modal element.
513 + *
514 + * @since 4.1
515 + */
516 + do_action( 'mainwp_screen_options_modal_bottom' );
517 + }
518 +
519 +
520 + /**
521 + * Method mainwp_help_content()
522 + *
523 + * Creates the MainWP Help Documentation List for the help component in the sidebar.
524 + */
525 + public static function mainwp_help_content() {
526 + if ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
527 + ?>
528 + <p><?php esc_html_e( 'If you need help with your MainWP Dashboard, please review following help documents', 'mainwp' ); ?></p>
529 + <div class="ui list">
530 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients" target="_blank">Manage Clients</a></div> <?php // NOSONAR - noopener - open safe. ?>
531 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients#create-a-new-client" target="_blank">Create a new Client</a></div> <?php // NOSONAR - noopener - open safe. ?>
532 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients#update-a-client" target="_blank">Update a Client</a></div> <?php // NOSONAR - noopener - open safe. ?>
533 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients#update-a-client" target="_blank">Delete a Client</a></div> <?php // NOSONAR - noopener - open safe. ?>
534 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients#customize-the-manage-clients-table" target="_blank">Customize the Manage Clients table</a></div> <?php // NOSONAR - noopener - open safe. ?>
535 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients#client-card" target="_blank">Client Card (View Client)</a></div> <?php // NOSONAR - noopener - open safe. ?>
536 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/clients/manage-clients#client-fields" target="_blank">Client Fields</a></div> <?php // NOSONAR - noopener - open safe. ?>
537 + <?php
538 + /**
539 + * Action: mainwp_clients_overview_help_item
540 + *
541 + * Fires at the bottom of the help articles list in the Help sidebar on the Clients page.
542 + *
543 + * Suggested HTML markup:
544 + *
545 + * <div class="item"><a href="Your custom URL">Your custom text</a></div>
546 + *
547 + * @since 4.3
548 + */
549 + do_action( 'mainwp_clients_overview_help_item' );
550 + ?>
551 + </div>
552 + <?php
553 + }
554 + }
532 555 }