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 | widgets/widget-mainwp-client-overview-sites.php +592 -587 5.0 → 6.2.2 View file →
@@ -8,690 +8,695 @@
8 8 */
9 9
10 10 namespace MainWP\Dashboard;
11 11
12 +// Exit if accessed directly.
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
16 +
12 17 /**
13 18 * Class MainWP_Client_Overview_Sites
14 19 *
15 20 * Displays the Client info.
16 21 */
17 -class MainWP_Client_Overview_Sites {
22 +class MainWP_Client_Overview_Sites { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
18 23
19 24
20 - /**
21 - * Public variable to hold Items information.
22 - *
23 - * @var array
24 - */
25 - public $items;
25 + /**
26 + * Public variable to hold Items information.
27 + *
28 + * @var array
29 + */
30 + public $items;
26 31
27 - /**
28 - * Public variable to hold Total Items information.
29 - *
30 - * @var array
31 - */
32 - public $total_items;
32 + /**
33 + * Public variable to hold Total Items information.
34 + *
35 + * @var array
36 + */
37 + public $total_items;
33 38
34 - /**
35 - * Protected variable to hold columns headers
36 - *
37 - * @var array
38 - */
39 - protected $column_headers;
39 + /**
40 + * Protected variable to hold columns headers
41 + *
42 + * @var array
43 + */
44 + protected $column_headers;
40 45
41 46
42 - /**
43 - * The single instance of the class
44 - *
45 - * @var mixed Default null
46 - */
47 - protected static $instance = null;
47 + /**
48 + * The single instance of the class
49 + *
50 + * @var mixed Default null
51 + */
52 + protected static $instance = null;
48 53
49 - /**
50 - * Protected variable to hold User extension.
51 - *
52 - * @var mixed Default null.
53 - */
54 - protected $userExtension = null;
54 + /**
55 + * Protected variable to hold User extension.
56 + *
57 + * @var mixed Default null.
58 + */
59 + protected $userExtension = null;
55 60
56 - /**
57 - * Method get_class_name()
58 - *
59 - * @return string __CLASS__ Class name.
60 - */
61 - public static function get_class_name() {
62 - return __CLASS__;
63 - }
61 + /**
62 + * Method get_class_name()
63 + *
64 + * @return string __CLASS__ Class name.
65 + */
66 + public static function get_class_name() {
67 + return __CLASS__;
68 + }
64 69
65 - /**
66 - * Check if there is a session,
67 - * if there isn't one create it.
68 - *
69 - * @return self::singlton Overview Page Session.
70 - *
71 - * @uses \MainWP\Dashboard\MainWP_Overview
72 - */
73 - public static function instance() {
74 - if ( null === self::$instance ) {
75 - self::$instance = new self();
76 - }
70 + /**
71 + * Check if there is a session,
72 + * if there isn't one create it.
73 + *
74 + * @return static::singlton Overview Page Session.
75 + *
76 + * @uses \MainWP\Dashboard\MainWP_Overview
77 + */
78 + public static function instance() {
79 + if ( null === static::$instance ) {
80 + static::$instance = new self();
81 + }
77 82
78 - return self::$instance;
79 - }
83 + return static::$instance;
84 + }
80 85
81 - /**
82 - * Method render()
83 - *
84 - * @return mixed render_site_info()
85 - */
86 - public static function render() {
87 - $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
88 - if ( empty( $client_id ) ) {
89 - return;
90 - }
91 - self::instance()->render_websites( $client_id );
92 - }
86 + /**
87 + * Method render()
88 + *
89 + * @return mixed render_site_info()
90 + */
91 + public static function render() {
92 + $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
93 + if ( empty( $client_id ) ) {
94 + return;
95 + }
96 + static::instance()->render_websites( $client_id );
97 + }
93 98
94 99
95 - /**
96 - * Render client overview Info.
97 - *
98 - * @param object $client_id Client ID.
99 - */
100 - public function render_websites( $client_id ) {
100 + /**
101 + * Render client overview Info.
102 + *
103 + * @param object $client_id Client ID.
104 + */
105 + public function render_websites( $client_id ) {
101 106
102 - $client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A );
107 + $client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A );
103 108
104 - ?>
105 - <div class="mainwp-widget-header">
106 - <h3 class="ui header handle-drag">
107 - <?php
108 - /**
109 - * Filter: mainwp_clients_overview_websites_widget_title
110 - *
111 - * Filters the Site info widget title text.
112 - *
113 - * @param object $client_info Object containing the child site info.
114 - *
115 - * @since 4.1
116 - */
117 - echo esc_html( apply_filters( 'mainwp_clients_overview_websites_widget_title', esc_html__( 'Sites', 'mainwp' ), $client_info ) );
118 - ?>
119 - <div class="sub header"><?php echo esc_html__( 'Websites that belong to the client.', 'mainwp' ); ?></div>
120 - </h3>
121 - </div>
122 - <div class="mainwp-widget-client-card mainwp-scrolly-overflow">
123 - <?php
124 - /**
125 - * Actoin: mainwp_clients_overview_websites_widget_top
126 - *
127 - * Fires at the top of the Site Info widget on the Individual site overview page.
128 - *
129 - * @param object $client_info Object containing the child site info.
130 - *
131 - * @since 4.0
132 - */
133 - do_action( 'mainwp_clients_overview_websites_widget_top', $client_info );
134 - ?>
135 - <?php
136 - if ( $client_info ) {
137 - $this->prepare_items( $client_id );
138 - ?>
139 - <table id="mainwp-manage-sites-monitor-table" style="width:100%" class="ui unstackable table mainwp-with-preview-table">
140 - <thead>
141 - <tr><?php $this->print_column_headers( true ); ?></tr>
142 - </thead>
143 - <tbody id="mainwp-manage-sites-body-table">
144 - <?php $this->display_rows_or_placeholder(); ?>
145 - </tbody>
146 - <tfoot>
147 - <tr><?php $this->print_column_headers( false ); ?></tr>
148 - </tfoot>
149 - </table>
150 - <?php } ?>
151 - <?php
152 - /**
153 - * Action: mainwp_clients_overview_websites_widget_bottom
154 - *
155 - * Fires at the bottom of the Site Info widget on the Individual site overview page.
156 - *
157 - * @param object $client_info Object containing the child site info.
158 - *
159 - * @since 4.0
160 - */
161 - do_action( 'mainwp_clients_overview_websites_widget_bottom', $client_info );
162 - ?>
163 - </div>
109 + ?>
110 + <div class="mainwp-widget-header">
111 + <h2 class="ui header handle-drag">
112 + <?php
113 + /**
114 + * Filter: mainwp_clients_overview_websites_widget_title
115 + *
116 + * Filters the Site info widget title text.
117 + *
118 + * @param object $client_info Object containing the child site info.
119 + *
120 + * @since 4.1
121 + */
122 + echo esc_html( apply_filters( 'mainwp_clients_overview_websites_widget_title', esc_html__( 'Sites', 'mainwp' ), $client_info ) );
123 + ?>
124 + <div class="sub header"><?php echo esc_html__( 'Websites that belong to the client.', 'mainwp' ); ?></div>
125 + </h2>
126 + </div>
127 + <div class="mainwp-widget-client-card mainwp-scrolly-overflow">
128 + <?php
129 + /**
130 + * Actoin: mainwp_clients_overview_websites_widget_top
131 + *
132 + * Fires at the top of the Site Info widget on the Individual site overview page.
133 + *
134 + * @param object $client_info Object containing the child site info.
135 + *
136 + * @since 4.0
137 + */
138 + do_action( 'mainwp_clients_overview_websites_widget_top', $client_info );
139 + ?>
140 + <?php
141 + if ( $client_info ) {
142 + $this->prepare_items( $client_id );
143 + ?>
144 + <table id="mainwp-manage-sites-monitor-table" style="width:100%" class="ui unstackable table mainwp-with-preview-table">
145 + <thead>
146 + <tr><?php $this->print_column_headers( true ); ?></tr>
147 + </thead>
148 + <tbody id="mainwp-manage-sites-body-table">
149 + <?php $this->display_rows_or_placeholder(); ?>
150 + </tbody>
151 + </table>
152 + <?php } ?>
153 + <?php
154 + /**
155 + * Action: mainwp_clients_overview_websites_widget_bottom
156 + *
157 + * Fires at the bottom of the Site Info widget on the Individual site overview page.
158 + *
159 + * @param object $client_info Object containing the child site info.
160 + *
161 + * @since 4.0
162 + */
163 + do_action( 'mainwp_clients_overview_websites_widget_bottom', $client_info );
164 + ?>
165 + </div>
166 + <div class="ui grid mainwp-widget-footer">
167 + <div class="column">
168 + <a href="admin.php?page=managesites&client=<?php echo intval( $client_id ); ?>" title="" class="ui mini basic button"><?php echo esc_html__( 'Manage Client Sites', 'mainwp' ); ?></a>
169 + </div>
170 + </div>
164 171
165 - <?php
172 + <?php
173 + // @NO_SONAR_START@ - duplicated issue.
166 174
167 - $sites_per_page = get_option( 'mainwp_default_sites_per_page', 25 );
175 + $sites_per_page = get_option( 'mainwp_default_sites_per_page', 25 );
168 176
169 - $sites_per_page = intval( $sites_per_page );
177 + $sites_per_page = intval( $sites_per_page );
170 178
171 - $pages_length = array(
172 - 25 => '25',
173 - 10 => '10',
174 - 50 => '50',
175 - 100 => '100',
176 - 300 => '300',
177 - );
179 + $pages_length = array(
180 + 25 => '25',
181 + 10 => '10',
182 + 50 => '50',
183 + 100 => '100',
184 + 300 => '300',
185 + );
178 186
179 - $pages_length = $pages_length + array( $sites_per_page => $sites_per_page );
180 - ksort( $pages_length );
187 + $pages_length = $pages_length + array( $sites_per_page => $sites_per_page );
188 + ksort( $pages_length );
181 189
182 - if ( isset( $pages_length[-1] ) ) {
183 - unset( $pages_length[-1] );
184 - }
190 + if ( isset( $pages_length[-1] ) ) {
191 + unset( $pages_length[-1] );
192 + }
185 193
186 - $pagelength_val = implode( ',', array_keys( $pages_length ) );
187 - $pagelength_title = implode( ',', array_values( $pages_length ) );
194 + $pagelength_val = implode( ',', array_keys( $pages_length ) );
195 + $pagelength_title = implode( ',', array_values( $pages_length ) );
188 196
189 - $table_features = array(
190 - 'searching' => 'true',
191 - 'paging' => 'false',
192 - 'pagingType' => 'full_numbers',
193 - 'info' => 'true',
194 - 'colReorder' => '{ fixedColumnsLeft: 1, fixedColumnsRight: 1 }',
195 - 'stateSave' => 'true',
196 - 'stateDuration' => '0',
197 - 'order' => '[]',
198 - 'scrollX' => 'true',
199 - 'responsive' => 'true',
200 - );
197 + $table_features = array(
198 + 'searching' => 'true',
199 + 'paging' => 'true',
200 + 'info' => 'false',
201 + 'colReorder' => '{ columns:":not(.manage-status-column):not(.manage-site_actions-column)"} ',
202 + 'stateSave' => 'true',
203 + 'stateDuration' => '60 * 60 * 24 * 30',
204 + 'order' => '[]',
205 + 'scrollX' => 'true',
206 + 'responsive' => 'true',
207 + 'searchDelay' => 350,
208 + );
201 209
202 - ?>
210 + ?>
203 211
204 - <script type="text/javascript">
205 - jQuery( document ).ready( function( $ ) {
206 - var responsive = true;
207 - if( jQuery( window ).width() > 1140 ) {
208 - responsive = false;
209 - }
210 - try {
211 - $manage_sites_table = jQuery( '#mainwp-manage-sites-monitor-table' ).DataTable( {
212 - "searching" : <?php echo esc_js( $table_features['searching'] ); ?>,
213 - "responsive": responsive,
214 - "paging" : <?php echo esc_js( $table_features['paging'] ); ?>,
215 - "pagingType" : "<?php echo esc_js( $table_features['pagingType'] ); ?>",
216 - "info" : <?php echo esc_js( $table_features['info'] ); ?>,
217 - "scrollX" : <?php echo esc_js( $table_features['scrollX'] ); ?>,
218 - "colReorder" : <?php echo esc_js( $table_features['colReorder'] ); ?>,
219 - "stateSave" : <?php echo esc_js( $table_features['stateSave'] ); ?>,
220 - "stateDuration" : <?php echo esc_js( $table_features['stateDuration'] ); ?>,
221 - "order" : <?php echo $table_features['order']; // phpcs:ignore -- specical chars. ?>,
222 - "lengthMenu" : [ [<?php echo intval( $pagelength_val ); ?>, -1 ], [<?php echo esc_js( $pagelength_title ); ?>, "All" ] ],
223 - "columnDefs": [
224 - {
225 - "targets": 'no-sort',
226 - "orderable": false
227 - },
228 - {
229 - "targets": 'manage-site-column',
230 - "type": 'natural-nohtml'
231 - },
232 - <?php do_action( 'mainwp_manage_sites_table_columns_defs' ); ?>
233 - ],
234 - "pageLength": <?php echo intval( $sites_per_page ); ?>,
235 - "initComplete": function( settings, json ) {
236 - },
237 - "language": {
238 - "emptyTable": "<?php esc_html_e( 'No websites found.', 'mainwp' ); ?>"
239 - },
240 - "drawCallback": function( settings ) {
241 - if ( jQuery('#mainwp-manage-sites-body-table td.dataTables_empty').length > 0 && jQuery('#sites-table-count-empty').length ){
242 - jQuery('#mainwp-manage-sites-body-table td.dataTables_empty').html(jQuery('#sites-table-count-empty').html());
243 - }
244 - }
245 - } );
246 - } catch(err) {
247 - // to fix js error.
248 - console.log(err);
249 - }
250 - mainwp_datatable_fix_menu_overflow();
251 - });
252 - </script>
253 - <?php
254 - }
212 + <script type="text/javascript">
213 + jQuery( document ).ready( function( $ ) {
214 + let responsive = true;
215 + if( jQuery( window ).width() > 1140 ) {
216 + responsive = false;
217 + }
218 + try {
219 + $manage_sites_table = jQuery( '#mainwp-manage-sites-monitor-table' ).DataTable( {
220 + "searching" : <?php echo esc_js( $table_features['searching'] ); ?>,
221 + "responsive": responsive,
222 + "paging" : <?php echo esc_js( $table_features['paging'] ); ?>,
223 + "info" : <?php echo esc_js( $table_features['info'] ); ?>,
224 + "layout": {
225 + "bottom": 'paging',
226 + "bottomStart": null,
227 + "bottomEnd": null
228 + },
229 + "scrollX" : <?php echo esc_js( $table_features['scrollX'] ); ?>,
230 + "colReorder" : <?php echo $table_features['colReorder']; // phpcs:ignore -- specical chars. ?>,
231 + "stateSave" : <?php echo esc_js( $table_features['stateSave'] ); ?>,
232 + "stateDuration" : <?php echo esc_js( $table_features['stateDuration'] ); ?>,
233 + "order" : <?php echo $table_features['order']; // phpcs:ignore -- specical chars. ?>,
234 + "lengthMenu" : [ [<?php echo esc_js( $pagelength_val ); ?>, -1 ], [<?php echo esc_js( $pagelength_title ); ?>, "All" ] ],
235 + "columnDefs": <?php echo wp_json_encode( $this->get_columns_defines() ); ?>,
236 + "pageLength": <?php echo intval( $sites_per_page ); ?>,
237 + "initComplete": function( settings, json ) {
238 + },
239 + "language": {
240 + "emptyTable": "<?php esc_html_e( 'No websites found.', 'mainwp' ); ?>"
241 + },
242 + "drawCallback": function( settings ) {
243 + if ( jQuery('#mainwp-manage-sites-body-table td.dt-empty').length > 0 && jQuery('#sites-table-count-empty').length ){
244 + jQuery('#mainwp-manage-sites-body-table td.dt-empty').html(jQuery('#sites-table-count-empty').html());
245 + }
246 + },
247 + stateSaveParams: function (settings, data) {
248 + data._mwpv = mainwpParams.mainwpVersion || 'dev';
249 + },
250 + stateLoadParams: function (settings, data) {
251 + if ((mainwpParams.mainwpVersion || 'dev') !== data._mwpv) return false;
252 + },
253 + search: { regex: false, smart: false },
254 + orderMulti: false,
255 + searchDelay: <?php echo intval( $table_features['searchDelay'] ); ?>
256 + } ).on( 'columns-reordered', function () {
257 + setTimeout(() => {
258 + $( '#mainwp-manage-sites-monitor-table .ui.dropdown' ).dropdown();
259 + $( '#mainwp-manage-sites-monitor-table .ui.checkbox' ).checkbox();
260 + mainwp_datatable_fix_menu_overflow( '#mainwp-manage-sites-monitor-table' );
261 + }, 1000 );
262 + } );
263 + } catch(err) {
264 + // to fix js error.
265 + console.log(err);
266 + }
267 + mainwp_datatable_fix_menu_overflow( '#mainwp-manage-sites-monitor-table' );
268 + });
269 + </script>
270 + <?php
271 + // @NO_SONAR_END@ .
272 + }
255 273
256 274
257 - /**
258 - * Prepare the items to be listed.
259 - *
260 - * @param int $client_id client id.
261 - */
262 - public function prepare_items( $client_id ) {
275 + /**
276 + * Prepare the items to be listed.
277 + *
278 + * @param int $client_id client id.
279 + */
280 + public function prepare_items( $client_id ) {
263 281
264 - if ( null === $this->userExtension ) {
265 - $this->userExtension = MainWP_DB_Common::instance()->get_user_extension();
266 - }
282 + if ( null === $this->userExtension ) {
283 + $this->userExtension = MainWP_DB_Common::instance()->get_user_extension();
284 + }
267 285
268 - $total_params = array(
269 - 'count_only' => true,
270 - 'selectgroups' => true,
271 - 'orderby' => 'wp.url',
272 - 'offset' => 0,
273 - 'rowcount' => 9999,
274 - 'client_id' => array( $client_id ),
275 - );
286 + $total_params = array(
287 + 'count_only' => true,
288 + 'selectgroups' => true,
289 + 'orderby' => 'wp.url',
290 + 'offset' => 0,
291 + 'rowcount' => 9999,
292 + 'client_id' => array( $client_id ),
293 + );
276 294
277 - $params = array(
278 - 'selectgroups' => true,
279 - 'orderby' => 'wp.url',
280 - 'offset' => 0,
281 - 'rowcount' => 9999,
282 - 'client_id' => array( $client_id ),
283 - );
295 + $params = array(
296 + 'selectgroups' => true,
297 + 'orderby' => 'wp.url',
298 + 'offset' => 0,
299 + 'rowcount' => 9999,
300 + 'client_id' => array( $client_id ),
301 + );
284 302
285 - $totalRecords = 0;
286 - $websites = false;
303 + $totalRecords = 0;
304 + $websites = false;
287 305
288 - if ( $client_id ) {
289 - $total_websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_search_websites_for_current_user( $total_params ) );
290 - $totalRecords = ( $total_websites ? MainWP_DB::num_rows( $total_websites ) : 0 );
291 - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_search_websites_for_current_user( $params ) );
292 - }
306 + if ( $client_id ) {
307 + $total_websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_search_websites_for_current_user( $total_params ) );
308 + $totalRecords = ( $total_websites ? MainWP_DB::num_rows( $total_websites ) : 0 );
309 + $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_search_websites_for_current_user( $params ) );
310 + }
293 311
294 - $this->items = $websites;
295 - $this->total_items = $totalRecords;
296 - }
312 + $this->items = $websites;
313 + $this->total_items = $totalRecords;
314 + }
297 315
298 - /**
299 - * Echo the column headers.
300 - */
301 - public function print_column_headers() {
316 + /**
317 + * Echo the column headers.
318 + */
319 + public function print_column_headers() {
302 320
303 - list( $columns ) = $this->get_column_info();
321 + list( $columns ) = $this->get_column_info();
304 322
305 - $sortable = array(
306 - 'site' => array( 'site', false ),
307 - 'update' => array( 'update', false ),
308 - 'client_name' => array( 'client_name', false ),
309 - );
323 + $sortable = array(
324 + 'site' => array( 'site', false ),
325 + 'update' => array( 'update', false ),
326 + 'client_name' => array( 'client_name', false ),
327 + );
310 328
311 - $def_columns = $columns;
312 - $def_columns['site_actions'] = '';
329 + $def_columns = $columns;
330 + $def_columns['site_actions'] = '';
313 331
314 - foreach ( $columns as $column_key => $column_display_name ) {
332 + foreach ( $columns as $column_overview_key => $column_display_name ) {
315 333
316 - $class = array( 'manage-' . $column_key . '-column' );
317 - $attr = '';
318 - if ( ! isset( $def_columns[ $column_key ] ) ) {
319 - $class[] = 'extra-column';
320 - }
334 + $class = array( 'manage-' . $column_overview_key . '-column' );
335 + $attr = '';
336 + if ( ! isset( $def_columns[ $column_overview_key ] ) ) {
337 + $class[] = 'extra-column';
338 + }
321 339
322 - if ( ! isset( $sortable[ $column_key ] ) ) {
323 - $class[] = 'no-sort';
324 - }
340 + if ( ! isset( $sortable[ $column_overview_key ] ) ) {
341 + $class[] = 'no-sort';
342 + }
325 343
326 - $tag = 'th';
327 - $id = "id='$column_key'";
344 + $tag = 'th';
345 + $id = "id='$column_overview_key'";
328 346
329 - if ( ! empty( $class ) ) {
330 - $class = "class='" . join( ' ', $class ) . "'";
331 - }
347 + if ( ! empty( $class ) ) {
348 + $class = "class='" . join( ' ', $class ) . "'";
349 + }
332 350
333 - echo "<$tag $id $class $attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput
334 - }
335 - }
351 + echo "<$tag $id $class $attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput
352 + }
353 + }
336 354
337 355
338 - /**
339 - * Return empty table place holders.
340 - */
341 - public function display_rows_or_placeholder() {
342 - if ( $this->has_items() ) {
343 - $this->display_rows();
344 - }
345 - }
356 + /**
357 + * Return empty table place holders.
358 + */
359 + public function display_rows_or_placeholder() {
360 + if ( $this->has_items() ) {
361 + $this->display_rows();
362 + }
363 + }
346 364
347 365
348 366
349 - /**
350 - * Fetch single row item.
351 - *
352 - * @return mixed Single Row Item.
353 - *
354 - * @uses \MainWP\Dashboard\MainWP_DB::is_result()
355 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_array()
356 - */
357 - public function display_rows() {
358 - if ( MainWP_DB::is_result( $this->items ) ) {
359 - while ( $this->items && ( $item = MainWP_DB::fetch_array( $this->items ) ) ) {
360 - $this->single_row( $item );
361 - }
362 - }
363 - }
367 + /**
368 + * Fetch single row item.
369 + *
370 + * @return mixed Single Row Item.
371 + *
372 + * @uses \MainWP\Dashboard\MainWP_DB::is_result()
373 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_array()
374 + */
375 + public function display_rows() {
376 + if ( MainWP_DB::is_result( $this->items ) ) {
377 + while ( $this->items && ( $item = MainWP_DB::fetch_array( $this->items ) ) ) {
378 + $this->single_row( $item );
379 + }
380 + }
381 + }
364 382
365 - /**
366 - * Single Row.
367 - *
368 - * @param mixed $website Child Site.
369 - *
370 - * @uses \MainWP\Dashboard\MainWP_Utility::sanitize_file_name()
371 - */
372 - public function single_row( $website ) {
373 - $classes = '';
374 - $hasSyncErrors = ( '' !== $website['sync_errors'] );
375 - $classes = ' class="child-site mainwp-child-site-' . intval( $website['id'] ) . ' ' . ( $hasSyncErrors ? 'error' : '' ) . ' ' . $classes . '"';
376 - echo '<tr id="child-site-' . intval( $website['id'] ) . '"' . $classes . ' siteid="' . intval( $website['id'] ) . '" site-url="' . esc_url( $website['url'] ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput
377 - $this->single_row_columns( $website );
378 - echo '</tr>';
379 - }
383 + /**
384 + * Single Row.
385 + *
386 + * @param mixed $website Child Site.
387 + *
388 + * @uses \MainWP\Dashboard\MainWP_Utility::sanitize_file_name()
389 + */
390 + public function single_row( $website ) {
391 + $classes = '';
392 + $hasSyncErrors = ( '' !== $website['sync_errors'] );
393 + $classes = ' class="child-site mainwp-child-site-' . intval( $website['id'] ) . ' ' . ( $hasSyncErrors ? 'error' : '' ) . ' ' . $classes . '"';
394 + echo '<tr id="child-site-' . intval( $website['id'] ) . '"' . $classes . ' siteid="' . intval( $website['id'] ) . '" site-url="' . esc_url( $website['url'] ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput
395 + $this->single_row_columns( $website );
396 + echo '</tr>';
397 + }
380 398
381 - /**
382 - * Get default columns.
383 - *
384 - * @return array Array of default column names.
385 - */
386 - public function get_default_columns() {
387 - return array(
388 - 'status' => '',
389 - 'site' => esc_html__( 'Site', 'mainwp' ),
390 - 'login' => '<i class="sign in alternate icon"></i>',
391 - 'update' => esc_html__( 'Updates', 'mainwp' ),
392 - );
393 - }
399 + /**
400 + * Get default columns.
401 + *
402 + * @return array Array of default column names.
403 + */
404 + public function get_default_columns() {
405 + return array(
406 + 'status' => '',
407 + 'site' => esc_html__( 'Site', 'mainwp' ),
408 + 'update' => esc_html__( 'Updates', 'mainwp' ),
409 + );
410 + }
394 411
395 - /**
396 - * Method get_columns()
397 - *
398 - * Combine all columns.
399 - *
400 - * @return array $columns Array of column names.
401 - */
402 - public function get_columns() {
412 + /**
413 + * Method get_columns()
414 + *
415 + * Combine all columns.
416 + *
417 + * @return array $columns Array of column names.
418 + */
419 + public function get_columns() {
403 420
404 - $columns = $this->get_default_columns();
421 + $columns = $this->get_default_columns();
405 422
406 - $columns['site_actions'] = '';
423 + $columns['site_actions'] = '';
407 424
408 - return $columns;
409 - }
425 + return $columns;
426 + }
410 427
411 - /**
412 - * Get column info.
413 - */
414 - protected function get_column_info() {
428 + /**
429 + * Get column info.
430 + */
431 + protected function get_column_info() {
415 432
416 - if ( isset( $this->column_headers ) && is_array( $this->column_headers ) ) {
417 - $column_headers = array( array(), array(), array() );
418 - foreach ( $this->column_headers as $key => $value ) {
419 - $column_headers[ $key ] = $value;
420 - }
433 + if ( isset( $this->column_headers ) && is_array( $this->column_headers ) ) {
434 + $column_headers = array( array(), array(), array() );
435 + foreach ( $this->column_headers as $key => $value ) {
436 + $column_headers[ $key ] = $value;
437 + }
421 438
422 - return $column_headers;
423 - }
439 + return $column_headers;
440 + }
424 441
425 - $columns = $this->get_columns();
442 + $columns = $this->get_columns();
426 443
427 - $this->column_headers = array( $columns );
444 + $this->column_headers = array( $columns );
428 445
429 - return $this->column_headers;
430 - }
446 + return $this->column_headers;
447 + }
431 448
432 - /**
433 - * Get column defines.
434 - *
435 - * @return array $defines
436 - */
437 - public function get_columns_defines() {
438 - $defines = array();
439 - $defines[] = array(
440 - 'targets' => 'no-sort',
441 - 'orderable' => false,
442 - );
443 - $defines[] = array(
444 - 'targets' => 'manage-site-column',
445 - 'className' => 'column-site-bulk mainwp-site-cell',
446 - );
447 - $defines[] = array(
448 - 'targets' => 'manage-url-column',
449 - 'className' => 'mainwp-url-cell',
450 - );
451 - $defines[] = array(
452 - 'targets' => array( 'manage-login-column', 'manage-status_code-column', 'manage-site_actions-column', 'manage-client_name-column' ),
453 - 'className' => 'collapsing',
454 - );
455 - $defines[] = array(
456 - 'targets' => array( 'manage-status-column' ),
457 - 'className' => 'collapsing',
458 - );
459 - return $defines;
460 - }
449 + /**
450 + * Get column defines.
451 + *
452 + * @return array $defines
453 + */
454 + public function get_columns_defines() {
455 + $defines = array();
456 + $defines[] = array(
457 + 'targets' => 'no-sort',
458 + 'orderable' => false,
459 + );
460 + $defines[] = array(
461 + 'targets' => array( 'manage-status-column' ),
462 + 'className' => 'collapsing center aligned',
463 + );
464 + $defines[] = array(
465 + 'targets' => 'manage-site-column',
466 + 'className' => 'column-site-bulk mainwp-site-cell',
467 + );
468 + $defines[] = array(
469 + 'targets' => array( 'manage-update-column' ),
470 + 'className' => 'collapsing center aligned',
471 + );
472 + $defines[] = array(
473 + 'targets' => array( 'manage-site_actions-column' ),
474 + 'className' => 'collapsing right aligned',
475 + );
476 + return $defines;
477 + }
461 478
462 - /**
463 - * Columns for a single row.
464 - *
465 - * @param mixed $website Child Site.
466 - *
467 - * @uses \MainWP\Dashboard\MainWP_Connect::get_favico_url()
468 - * @uses \MainWP\Dashboard\MainWP_DB::instance()::get_website_options_array()
469 - * @uses \MainWP\Dashboard\MainWP_Utility::get_site_health()
470 - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
471 - * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes()
472 - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
473 - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
474 - */
475 - protected function single_row_columns( $website ) { // phpcs:ignore -- complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
479 + /**
480 + * Columns for a single row.
481 + *
482 + * @param mixed $website Child Site.
483 + *
484 + * @uses \MainWP\Dashboard\MainWP_Connect::get_favico_url()
485 + * @uses \MainWP\Dashboard\MainWP_DB::instance()::get_website_options_array()
486 + * @uses \MainWP\Dashboard\MainWP_Utility::get_site_health()
487 + * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
488 + * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes()
489 + * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
490 + * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
491 + */
492 + protected function single_row_columns( $website ) { // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
476 493
477 - $total_wp_upgrades = 0;
478 - $total_plugin_upgrades = 0;
479 - $total_theme_upgrades = 0;
494 + $userExtension = MainWP_DB_Common::instance()->get_user_extension();
495 + $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
480 496
481 - $site_options = MainWP_DB::instance()->get_website_options_array( $website, array( 'wp_upgrades', 'premium_upgrades', 'primary_lasttime_backup' ) );
482 - $wp_upgrades = isset( $site_options['wp_upgrades'] ) ? json_decode( $site_options['wp_upgrades'], true ) : array();
497 + // @NO_SONAR_START@ - duplicated issue.
498 + $total_wp_upgrades = 0;
499 + $total_plugin_upgrades = 0;
500 + $total_theme_upgrades = 0;
483 501
484 - if ( $website['is_ignoreCoreUpdates'] ) {
485 - $wp_upgrades = array();
486 - }
502 + $site_options = MainWP_DB::instance()->get_website_options_array( $website, array( 'wp_upgrades', 'ignored_wp_upgrades', 'premium_upgrades', 'primary_lasttime_backup' ) );
503 + $wp_upgrades = isset( $site_options['wp_upgrades'] ) ? json_decode( $site_options['wp_upgrades'], true ) : array();
504 + $ignored_core_upgrades = isset( $site_options['ignored_wp_upgrades'] ) ? json_decode( $site_options['ignored_wp_upgrades'], true ) : array();
487 505
488 - if ( is_array( $wp_upgrades ) && 0 < count( $wp_upgrades ) ) {
489 - ++$total_wp_upgrades;
490 - }
506 + if ( $website['is_ignoreCoreUpdates'] || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) {
507 + $wp_upgrades = array();
508 + }
491 509
492 - $plugin_upgrades = json_decode( $website['plugin_upgrades'], true );
510 + if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
511 + ++$total_wp_upgrades;
512 + }
493 513
494 - if ( $website['is_ignorePluginUpdates'] ) {
495 - $plugin_upgrades = array();
496 - }
514 + $plugin_upgrades = json_decode( $website['plugin_upgrades'], true );
497 515
498 - $theme_upgrades = json_decode( $website['theme_upgrades'], true );
516 + if ( $website['is_ignorePluginUpdates'] ) {
517 + $plugin_upgrades = array();
518 + }
499 519
500 - if ( $website['is_ignoreThemeUpdates'] ) {
501 - $theme_upgrades = array();
502 - }
520 + $theme_upgrades = json_decode( $website['theme_upgrades'], true );
503 521
504 - $decodedPremiumUpgrades = isset( $site_options['premium_upgrades'] ) ? json_decode( $site_options['premium_upgrades'], true ) : array();
505 - if ( is_array( $decodedPremiumUpgrades ) ) {
506 - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
507 - $premiumUpgrade['premium'] = true;
522 + if ( $website['is_ignoreThemeUpdates'] ) {
523 + $theme_upgrades = array();
524 + }
508 525
509 - if ( 'plugin' === $premiumUpgrade['type'] ) {
510 - if ( ! is_array( $plugin_upgrades ) ) {
511 - $plugin_upgrades = array();
512 - }
513 - if ( ! $website['is_ignorePluginUpdates'] ) {
514 - $plugin_upgrades[ $crrSlug ] = $premiumUpgrade;
515 - }
516 - } elseif ( 'theme' === $premiumUpgrade['type'] ) {
517 - if ( ! is_array( $theme_upgrades ) ) {
518 - $theme_upgrades = array();
519 - }
520 - if ( ! $website['is_ignoreThemeUpdates'] ) {
521 - $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
522 - }
523 - }
524 - }
525 - }
526 + $decodedPremiumUpgrades = isset( $site_options['premium_upgrades'] ) ? json_decode( $site_options['premium_upgrades'], true ) : array();
527 + if ( is_array( $decodedPremiumUpgrades ) ) {
528 + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
529 + $premiumUpgrade['premium'] = true;
526 530
527 - if ( is_array( $plugin_upgrades ) ) {
531 + if ( 'plugin' === $premiumUpgrade['type'] ) {
532 + if ( ! is_array( $plugin_upgrades ) ) {
533 + $plugin_upgrades = array();
534 + }
535 + if ( ! $website['is_ignorePluginUpdates'] ) {
536 + $plugin_upgrades[ $crrSlug ] = $premiumUpgrade;
537 + }
538 + } elseif ( 'theme' === $premiumUpgrade['type'] ) {
539 + if ( ! is_array( $theme_upgrades ) ) {
540 + $theme_upgrades = array();
541 + }
542 + if ( ! $website['is_ignoreThemeUpdates'] ) {
543 + $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
544 + }
545 + }
546 + }
547 + }
528 548
529 - $ignored_plugins = json_decode( $website['ignored_plugins'], true );
530 - if ( is_array( $ignored_plugins ) ) {
531 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
532 - }
549 + if ( is_array( $plugin_upgrades ) ) {
533 550
534 - $ignored_plugins = json_decode( $this->userExtension->ignored_plugins, true );
535 - if ( is_array( $ignored_plugins ) ) {
536 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
537 - }
551 + $ignored_plugins = json_decode( $website['ignored_plugins'], true );
552 + if ( is_array( $ignored_plugins ) ) {
553 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
538 554
539 - $total_plugin_upgrades += count( $plugin_upgrades );
540 - }
555 + }
541 556
542 - if ( is_array( $theme_upgrades ) ) {
557 + $ignored_plugins = json_decode( $this->userExtension->ignored_plugins, true );
558 + if ( is_array( $ignored_plugins ) ) {
559 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
560 + }
543 561
544 - $ignored_themes = json_decode( $website['ignored_themes'], true );
545 - if ( is_array( $ignored_themes ) ) {
546 - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes );
547 - }
562 + $total_plugin_upgrades += count( $plugin_upgrades );
563 + }
548 564
549 - $ignored_themes = json_decode( $this->userExtension->ignored_themes, true );
550 - if ( is_array( $ignored_themes ) ) {
551 - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes );
552 - }
565 + if ( is_array( $theme_upgrades ) ) {
553 566
554 - $total_theme_upgrades += count( $theme_upgrades );
555 - }
567 + $ignored_themes = json_decode( $website['ignored_themes'], true );
568 + if ( is_array( $ignored_themes ) ) {
569 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
570 + }
556 571
557 - $total_updates = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades;
572 + $ignored_themes = json_decode( $this->userExtension->ignored_themes, true );
573 + if ( is_array( $ignored_themes ) ) {
574 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
575 + }
558 576
559 - if ( 5 < $total_updates ) {
560 - $a_color = 'red';
561 - } elseif ( 0 < $total_updates && 5 >= $total_updates ) {
562 - $a_color = 'yellow';
563 - } else {
564 - $a_color = 'green';
565 - }
577 + $total_theme_upgrades += count( $theme_upgrades );
578 + }
566 579
567 - $hasSyncErrors = ( '' !== $website['sync_errors'] );
580 + $total_updates = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades;
581 + $hasSyncErrors = ( '' !== $website['sync_errors'] );
568 582
569 - if ( $hasSyncErrors ) {
570 - $a_color = '';
571 - $w_color = '';
572 - $p_color = '';
573 - $t_color = '';
574 - }
583 + // @NO_SONAR_END@ .
575 584
576 - if ( $hasSyncErrors ) {
577 - $h_color = '';
578 - $h_color = '';
579 - }
585 + list( $columns ) = $this->get_column_info();
580 586
581 - list( $columns ) = $this->get_column_info();
587 + foreach ( $columns as $column_name => $column_display_name ) {
588 + ?>
582 589
583 - $http_error_codes = MainWP_Utility::get_http_codes();
590 + <?php if ( 'status' === $column_name ) { ?>
591 + <td class="center aligned collapsing">
592 + <?php if ( $hasSyncErrors ) : ?>
593 + <a class="mainwp_site_reconnect" href="#"><i class="red large times icon"></i></a>
594 + <?php else : ?>
595 + <a class="managesites_syncdata" href="#">
596 + <?php echo '1' === $website['suspended'] ? '<i class="yellow pause large icon"></i>' : '<i class="green large check icon"></i>'; ?>
597 + </a>
598 + <?php endif; ?>
599 + </td>
600 + <?php
601 + } elseif ( 'site' === $column_name ) {
602 + $cls_site = '';
603 + if ( ! empty( $website['sync_errors'] ) ) {
604 + $cls_site = 'site-sync-error';
605 + }
606 + ?>
607 + <td class="column-site-bulk mainwp-site-cell all <?php echo esc_html( $cls_site ); ?>">
608 + <?php if ( ! \mainwp_current_user_can( 'dashboard', 'access_wpadmin_on_child_sites' ) ) : ?>
609 + <i class="sign in icon"></i>
610 + <?php else : ?>
611 + <a href="<?php MainWP_Site_Open::get_open_site_url( $website['id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="right center" data-inverted="" class="open_newwindow_wpadmin" target="_blank"><i class="sign in icon"></i></a>
612 + <?php endif; ?>
613 + <a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website['id'] ); ?>" >
614 + <?php echo esc_html( stripslashes( $website['name'] ) ); ?>
615 + </a>
616 + <div>
617 + <span class="ui small text">
618 + <a href="<?php echo esc_url( $website['url'] ); ?>" class="mainwp-may-hide-referrer open_site_url ui grey text" target="_blank">
619 + <?php echo esc_html( MainWP_Utility::get_nice_url( $website['url'] ) ); ?>
620 + </a>
621 + </span>
622 + </div>
623 + </td>
624 + <?php } elseif ( 'update' === $column_name ) { ?>
625 + <td>
626 + <a class="ui mini basic grey button" href="admin.php?page=managesites&updateid=<?php echo intval( $website['id'] ); ?>">
627 + <i class="sync alternate icon"></i> <?php echo intval( $total_updates ); ?>
628 + </a>
629 + </td>
630 + <?php
631 + } elseif ( 'site_actions' === $column_name ) {
632 + // @NO_SONAR_START@ - duplicated issue.
633 + ?>
634 + <td class="collapsing not-selectable">
635 + <div class="ui right pointing dropdown" style="z-index: 99;">
636 + <i class="ellipsis vertical icon"></i>
637 + <div class="menu" siteid="<?php echo intval( $website['id'] ); ?>">
638 + <?php if ( '' !== $website['sync_errors'] ) : ?>
639 + <a class="mainwp_site_reconnect item" href="#"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a>
640 + <?php else : ?>
641 + <a class="managesites_syncdata item" href="#"><?php esc_html_e( 'Sync Data', 'mainwp' ); ?></a>
642 + <?php endif; ?>
643 + <?php if ( \mainwp_current_user_can( 'dashboard', 'access_individual_dashboard' ) ) : ?>
644 + <a class="item" href="admin.php?page=managesites&dashboard=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Overview', 'mainwp' ); ?></a>
645 + <?php endif; ?>
646 + <?php if ( \mainwp_current_user_can( 'dashboard', 'edit_sites' ) ) : ?>
647 + <a class="item" href="admin.php?page=managesites&id=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Settings', 'mainwp' ); ?></a>
648 + <?php endif; ?>
649 + </div>
650 + </div>
651 + </td>
652 + <?php
653 + // @NO_SONAR_END@ .
654 + }
655 + }
656 + }
584 657
585 - foreach ( $columns as $column_name => $column_display_name ) {
586 658
587 - $classes = "collapsing center aligned $column_name column-$column_name";
588 - $attributes = "class='$classes'";
659 + /**
660 + * Set the column names.
661 + *
662 + * @param mixed $item MainWP Sitetable Item.
663 + * @param string $column_name Column name to use.
664 + *
665 + * @return string Column Name.
666 + */
667 + public function column_default( $item, $column_name ) { // phpcs:ignore -- NOSONAR - comlex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
589 668
590 - ?>
591 - <?php if ( 'status' === $column_name ) { ?>
592 - <td class="center aligned collapsing">
593 - <?php if ( $hasSyncErrors ) : ?>
594 - <a class="mainwp_site_reconnect" href="#"><i class="circular inverted red unlink icon"></i></a>
595 - <?php else : ?>
596 - <a class="managesites_syncdata" href="#"><?php echo '1' === $website['suspended'] ? '<i class="pause circular yellow inverted circle icon"></i>' : '<i class="circular inverted green check icon"></i>'; ?></a>
597 - <?php endif; ?>
598 - </td>
599 - <?php
600 - } elseif ( 'site' === $column_name ) {
601 - $cls_site = '';
602 - if ( ! empty( $website['sync_errors'] ) ) {
603 - $cls_site = 'site-sync-error';
604 - }
605 - ?>
606 - <td class="column-site-bulk mainwp-site-cell all <?php echo esc_html( $cls_site ); ?>"><a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website['id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Open the site overview', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php echo esc_html( stripslashes( $website['name'] ) ); ?></a><i class="ui active inline loader tiny" style="display:none"></i><span id="site-status-<?php echo esc_attr( $website['id'] ); ?>" class="status hidden"></span></td>
607 - <?php } elseif ( 'login' === $column_name ) { ?>
608 - <td class="collapsing">
609 - <?php if ( ! mainwp_current_user_have_right( 'dashboard', 'access_wpadmin_on_child_sites' ) ) : ?>
610 - <i class="sign in icon"></i>
611 - <?php else : ?>
612 - <a href="<?php MainWP_Site_Open::get_open_site_url( $website['id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="right center" data-inverted="" class="open_newwindow_wpadmin" target="_blank"><i class="sign in icon"></i></a>
613 - <?php endif; ?>
614 - </td>
615 - <?php
616 - } elseif ( 'update' === $column_name ) {
617 - ?>
618 - <td class="collapsing center aligned"><span data-tooltip="<?php esc_attr_e( 'Number of available updates. Click to see details.', 'mainwp' ); ?>" data-position="left center" data-inverted=""><a class="ui mini compact button <?php echo esc_attr( $a_color ); ?>" href="admin.php?page=managesites&updateid=<?php echo intval( $website['id'] ); ?>"><?php echo intval( $total_updates ); ?></a></span></td>
619 - <?php
620 - } elseif ( 'site_actions' === $column_name ) {
621 - ?>
622 - <td class="collapsing">
623 - <div class="ui right pointing dropdown icon mini basic green button" style="z-index: 999;">
624 - <i class="ellipsis horizontal icon"></i>
625 - <div class="menu" siteid="<?php echo intval( $website['id'] ); ?>">
626 - <?php if ( '' !== $website['sync_errors'] ) : ?>
627 - <a class="mainwp_site_reconnect item" href="#"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a>
628 - <?php else : ?>
629 - <a class="managesites_syncdata item" href="#"><?php esc_html_e( 'Sync Data', 'mainwp' ); ?></a>
630 - <?php endif; ?>
631 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'access_individual_dashboard' ) ) : ?>
632 - <a class="item" href="admin.php?page=managesites&dashboard=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Overview', 'mainwp' ); ?></a>
633 - <?php endif; ?>
634 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'edit_sites' ) ) : ?>
635 - <a class="item" href="admin.php?page=managesites&id=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Edit Site', 'mainwp' ); ?></a>
636 - <?php endif; ?>
637 - </div>
638 - </div>
639 - </td>
640 - <?php
641 - } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
642 - echo "<td $attributes>"; // phpcs:ignore WordPress.Security.EscapeOutput
643 - echo call_user_func( array( $this, 'column_' . $column_name ), $website ); // phpcs:ignore WordPress.Security.EscapeOutput
644 - echo '</td>';
645 - } else {
646 - echo "<td $attributes>"; // phpcs:ignore WordPress.Security.EscapeOutput
647 - echo $this->column_default( $website, $column_name ); // phpcs:ignore WordPress.Security.EscapeOutput
648 - echo '</td>';
649 - }
650 - }
651 - }
669 + switch ( $column_name ) {
670 + case 'status':
671 + case 'site':
672 + case 'login':
673 + case 'update':
674 + case 'site_actions':
675 + return '';
676 + default:
677 + return isset( $item[ $column_name ] ) ? $item[ $column_name ] : '';
678 + }
679 + }
652 680
653 681
654 - /**
655 - * Set the column names.
656 - *
657 - * @param mixed $item MainWP Sitetable Item.
658 - * @param string $column_name Column name to use.
659 - *
660 - * @return string Column Name.
661 - */
662 - public function column_default( $item, $column_name ) { // phpcs:ignore -- comlex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
682 + /**
683 + * Method has_items().
684 + *
685 + * Verify if items exist.
686 + */
687 + public function has_items() {
688 + return ! empty( $this->items );
689 + }
663 690
664 - switch ( $column_name ) {
665 - case 'status':
666 - case 'site':
667 - case 'login':
668 - case 'update':
669 - case 'site_actions':
670 - return '';
671 - default:
672 - return isset( $item[ $column_name ] ) ? $item[ $column_name ] : '';
673 - }
674 - }
675 -
676 -
677 - /**
678 - * Method has_items().
679 - *
680 - * Verify if items exist.
681 - */
682 - public function has_items() {
683 - return ! empty( $this->items );
684 - }
685 -
686 - /**
687 - * Clear Items.
688 - *
689 - * @uses \MainWP\Dashboard\MainWP_DB::is_result()
690 - * @uses \MainWP\Dashboard\MainWP_DB::free_result()
691 - */
692 - public function clear_items() {
693 - if ( MainWP_DB::is_result( $this->items ) ) {
694 - MainWP_DB::free_result( $this->items );
695 - }
696 - }
691 + /**
692 + * Clear Items.
693 + *
694 + * @uses \MainWP\Dashboard\MainWP_DB::is_result()
695 + * @uses \MainWP\Dashboard\MainWP_DB::free_result()
696 + */
697 + public function clear_items() {
698 + if ( MainWP_DB::is_result( $this->items ) ) {
699 + MainWP_DB::free_result( $this->items );
700 + }
701 + }
697 702 }