PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.3.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.3.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 5.2.2 5.3 All 153 releases
mainwp / pages / page-mainwp-plugins.php

page-mainwp-plugins.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.0.3.1, at pages/page-mainwp-plugins.php

2,951 lines 123.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Plugins Page.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 /**
11 * Class MainWP_Plugins
12 *
13 * @package MainWP\Dashboard\
14 *
15 * @uses \MainWP\Dashboard\MainWP_Install_Bulk
16 */
17 class MainWP_Plugins {
18 // phpcs:disable Generic.Metrics.CyclomaticComplexity -- This is the only way to achieve desired results, pull request solutions appreciated.
19
20 /**
21 * Get Class Name.
22 *
23 * @return string __CLASS__
24 */
25 public static function get_class_name() {
26 return __CLASS__;
27 }
28
29 /**
30 * MainWP Plugins sub-pages.
31 *
32 * @var array $subPages MainWP Plugins Sub Pages.
33 */
34 public static $subPages;
35
36 /**
37 * Plugins table.
38 *
39 * @var mixed $pluginsTable Plugins table.
40 */
41 public static $pluginsTable;
42
43 /** Instantiate Hooks. */
44 public static function init() {
45 /**
46 * This hook allows you to render the Plugins page header via the 'mainwp-pageheader-plugins' action.
47 *
48 * @link http://codex.mainwp.com/#mainwp-pageheader-plugins
49 *
50 * This hook is normally used in the same context of 'mainwp-getsubpages-plugins'
51 * @link http://codex.mainwp.com/#mainwp-getsubpages-plugins
52 *
53 * @see \MainWP_Plugins::render_header
54 */
55 add_action( 'mainwp-pageheader-plugins', array( self::get_class_name(), 'render_header' ) );
56
57 /**
58 * This hook allows you to render the Plugins page footer via the 'mainwp-pagefooter-plugins' action.
59 *
60 * @link http://codex.mainwp.com/#mainwp-pagefooter-plugins
61 *
62 * This hook is normally used in the same context of 'mainwp-getsubpages-plugins'
63 * @link http://codex.mainwp.com/#mainwp-getsubpages-plugins
64 *
65 * @see \MainWP_Plugins::render_footer
66 */
67 add_action( 'mainwp-pagefooter-plugins', array( self::get_class_name(), 'render_footer' ) );
68
69 add_action( 'mainwp_help_sidebar_content', array( self::get_class_name(), 'mainwp_help_content' ) );
70 }
71
72 /**
73 * Instantiate Main Plugins Menu.
74 *
75 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
76 */
77 public static function init_menu() {
78 $_page = add_submenu_page(
79 'mainwp_tab',
80 __( 'Plugins', 'mainwp' ),
81 '<span id="mainwp-Plugins">' . esc_html__( 'Plugins', 'mainwp' ) . '</span>',
82 'read',
83 'PluginsManage',
84 array(
85 self::get_class_name(),
86 'render',
87 )
88 );
89 if ( mainwp_current_user_have_right( 'dashboard', 'install_plugins' ) ) {
90 $page = add_submenu_page(
91 'mainwp_tab',
92 __( 'Plugins', 'mainwp' ),
93 '<div class="mainwp-hidden">' . esc_html__( 'Install ', 'mainwp' ) . '</div>',
94 'read',
95 'PluginsInstall',
96 array(
97 self::get_class_name(),
98 'render_install',
99 )
100 );
101
102 add_action( 'load-' . $page, array( self::get_class_name(), 'load_page' ) );
103 }
104 add_submenu_page(
105 'mainwp_tab',
106 __( 'Plugins', 'mainwp' ),
107 '<div class="mainwp-hidden">' . esc_html__( 'Advanced Auto Updates', 'mainwp' ) . '</div>',
108 'read',
109 'PluginsAutoUpdate',
110 array(
111 self::get_class_name(),
112 'render_auto_update',
113 )
114 );
115 add_submenu_page(
116 'mainwp_tab',
117 __( 'Plugins', 'mainwp' ),
118 '<div class="mainwp-hidden">' . esc_html__( 'Ignored Updates', 'mainwp' ) . '</div>',
119 'read',
120 'PluginsIgnore',
121 array(
122 self::get_class_name(),
123 'render_ignore',
124 )
125 );
126 add_submenu_page(
127 'mainwp_tab',
128 __( 'Plugins', 'mainwp' ),
129 '<div class="mainwp-hidden">' . esc_html__( 'Ignored Abandoned', 'mainwp' ) . '</div>',
130 'read',
131 'PluginsIgnoredAbandoned',
132 array(
133 self::get_class_name(),
134 'render_ignored_abandoned',
135 )
136 );
137
138 /**
139 * Plugins Subpages
140 *
141 * Filters subpages for the Plugins page.
142 *
143 * @since Unknown
144 */
145 $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-plugins', array( array() ), '4.0.7.2', 'mainwp_getsubpages_plugins' ); // @deprecated Use 'mainwp_getsubpages_plugins' instead.
146 self::$subPages = apply_filters( 'mainwp_getsubpages_plugins', $sub_pages );
147
148 if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
149 foreach ( self::$subPages as $subPage ) {
150 if ( MainWP_Menu::is_disable_menu_item( 3, 'Plugins' . $subPage['slug'] ) ) {
151 continue;
152 }
153 add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Plugins' . $subPage['slug'], $subPage['callback'] );
154 }
155 }
156 self::init_left_menu( self::$subPages );
157 }
158
159 /**
160 * Load the Plugins Page.
161 *
162 * @uses \MainWP\Dashboard\MainWP_Plugins_Install_List_Table
163 */
164 public static function load_page() {
165 self::$pluginsTable = new MainWP_Plugins_Install_List_Table();
166 $pagenum = self::$pluginsTable->get_pagenum();
167
168 self::$pluginsTable->prepare_items();
169
170 $total_pages = self::$pluginsTable->get_pagination_arg( 'total_pages' );
171
172 if ( $pagenum > $total_pages && 0 < $total_pages ) {
173 wp_safe_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
174 exit;
175 }
176 }
177
178 /**
179 * Instantiate Subpage "tabs".
180 *
181 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
182 */
183 public static function init_subpages_menu() {
184 ?>
185 <div id="menu-mainwp-Plugins" class="mainwp-submenu-wrapper" xmlns="http://www.w3.org/1999/html">
186 <div class="wp-submenu sub-open" >
187 <div class="mainwp_boxout">
188 <div class="mainwp_boxoutin"></div>
189 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsManage' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Manage Plugins', 'mainwp' ); ?></a>
190 <?php if ( mainwp_current_user_have_right( 'dashboard', 'install_plugins' ) ) : ?>
191 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsInstall' ) ) : ?>
192 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsInstall' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Install Plugins', 'mainwp' ); ?></a>
193 <?php endif; ?>
194 <?php endif; ?>
195 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsAutoUpdate' ) ) : ?>
196 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsAutoUpdate' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Advanced Auto Updates', 'mainwp' ); ?></a>
197 <?php endif; ?>
198 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsIgnore' ) ) : ?>
199 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsIgnore' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Ignored Updates', 'mainwp' ); ?></a>
200 <?php endif; ?>
201 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsIgnoredAbandoned' ) ) : ?>
202 <a href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsIgnoredAbandoned' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Ignored Abandoned', 'mainwp' ); ?></a>
203 <?php endif; ?>
204 <?php
205 if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
206 foreach ( self::$subPages as $subPage ) {
207 if ( MainWP_Menu::is_disable_menu_item( 3, 'Plugins' . $subPage['slug'] ) ) {
208 continue;
209 }
210 ?>
211 <a href="<?php echo esc_url( admin_url( 'admin.php?page=Plugins' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $subPage['title'] ); ?></a>
212 <?php
213 }
214 }
215 ?>
216 </div>
217 </div>
218 </div>
219 <?php
220 }
221
222 /**
223 * Instantiate MainWP main menu Subpages menu.
224 *
225 * @param array $subPages Subpages array.
226 *
227 * @uses MainWP_Menu::add_left_menu()
228 * @uses MainWP_Menu::init_subpages_left_menu()
229 * @uses MainWP_Menu::is_disable_menu_item()
230 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
231 */
232 public static function init_left_menu( $subPages = array() ) {
233 MainWP_Menu::add_left_menu(
234 array(
235 'title' => esc_html__( 'Plugins', 'mainwp' ),
236 'parent_key' => 'managesites',
237 'slug' => 'PluginsManage',
238 'href' => 'admin.php?page=PluginsManage',
239 'icon' => '<i class="plug icon"></i>',
240 'leftsub_order' => 5,
241 ),
242 1
243 );
244
245 $init_sub_subleftmenu = array(
246 array(
247 'title' => esc_html__( 'Manage Plugins', 'mainwp' ),
248 'parent_key' => 'PluginsManage',
249 'href' => 'admin.php?page=PluginsManage',
250 'slug' => 'PluginsManage',
251 'right' => '',
252 'leftsub_order_level2' => 1,
253 ),
254 array(
255 'title' => esc_html__( 'Install Plugins', 'mainwp' ),
256 'parent_key' => 'PluginsManage',
257 'href' => 'admin.php?page=PluginsInstall',
258 'slug' => 'PluginsInstall',
259 'right' => 'install_plugins',
260 'leftsub_order_level2' => 2,
261 ),
262 array(
263 'title' => esc_html__( 'Advanced Auto Updates', 'mainwp' ),
264 'parent_key' => 'PluginsManage',
265 'href' => 'admin.php?page=PluginsAutoUpdate',
266 'slug' => 'PluginsAutoUpdate',
267 'right' => '',
268 'leftsub_order_level2' => 3,
269 ),
270 array(
271 'title' => esc_html__( 'Ignored Updates', 'mainwp' ),
272 'parent_key' => 'PluginsManage',
273 'href' => 'admin.php?page=PluginsIgnore',
274 'slug' => 'PluginsIgnore',
275 'right' => '',
276 'leftsub_order_level2' => 4,
277 ),
278 array(
279 'title' => esc_html__( 'Abandoned Plugins', 'mainwp' ),
280 'parent_key' => 'PluginsManage',
281 'href' => 'admin.php?page=UpdatesManage&tab=abandoned-plugins',
282 'slug' => 'PluginsManage&tab=abandoned-plugins',
283 'right' => '',
284 'leftsub_order_level2' => 4.1,
285 ),
286 array(
287 'title' => esc_html__( 'Ignored Abandoned', 'mainwp' ),
288 'parent_key' => 'PluginsManage',
289 'href' => 'admin.php?page=PluginsIgnoredAbandoned',
290 'slug' => 'PluginsIgnoredAbandoned',
291 'right' => '',
292 'leftsub_order_level2' => 5,
293 ),
294
295 );
296
297 MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'PluginsManage', 'Plugins' );
298
299 foreach ( $init_sub_subleftmenu as $item ) {
300 if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
301 continue;
302 }
303 MainWP_Menu::add_left_menu( $item, 2 );
304 }
305 }
306
307 /**
308 * Render MainWP Plugins Page Header.
309 *
310 * @param string $shownPage The page slug shown at this moment.
311 *
312 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
313 * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
314 * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation()
315 */
316 public static function render_header( $shownPage = '' ) {
317
318 $params = array(
319 'title' => esc_html__( 'Plugins', 'mainwp' ),
320 );
321
322 MainWP_UI::render_top_header( $params );
323
324 $renderItems = array();
325 $renderItems[] = array(
326 'title' => esc_html__( 'Manage Plugins', 'mainwp' ),
327 'href' => 'admin.php?page=PluginsManage',
328 'active' => ( 'Manage' === $shownPage ) ? true : false,
329 );
330
331 if ( mainwp_current_user_have_right( 'dashboard', 'install_plugins' ) ) {
332 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsInstall' ) ) {
333 $renderItems[] = array(
334 'title' => esc_html__( 'Install', 'mainwp' ),
335 'href' => 'admin.php?page=PluginsInstall',
336 'active' => ( 'Install' === $shownPage ) ? true : false,
337 );
338 }
339 }
340
341 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsAutoUpdate' ) ) {
342 $renderItems[] = array(
343 'title' => esc_html__( 'Advanced Auto Updates', 'mainwp' ),
344 'href' => 'admin.php?page=PluginsAutoUpdate',
345 'active' => ( 'AutoUpdate' === $shownPage ) ? true : false,
346 );
347 }
348
349 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsIgnore' ) ) {
350 $renderItems[] = array(
351 'title' => esc_html__( 'Ignored Updates', 'mainwp' ),
352 'href' => 'admin.php?page=PluginsIgnore',
353 'active' => ( 'Ignore' === $shownPage ) ? true : false,
354 );
355 }
356
357 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginsIgnoredAbandoned' ) ) {
358 $renderItems[] = array(
359 'title' => esc_html__( 'Ignored Abandoned', 'mainwp' ),
360 'href' => 'admin.php?page=PluginsIgnoredAbandoned',
361 'active' => ( 'IgnoreAbandoned' === $shownPage ) ? true : false,
362 );
363 }
364
365 if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
366 foreach ( self::$subPages as $subPage ) {
367 if ( MainWP_Menu::is_disable_menu_item( 3, 'Plugins' . $subPage['slug'] ) ) {
368 continue;
369 }
370
371 $item = array();
372 $item['title'] = $subPage['title'];
373 $item['href'] = 'admin.php?page=Plugins' . $subPage['slug'];
374 $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false;
375 $renderItems[] = $item;
376 }
377 }
378
379 MainWP_UI::render_page_navigation( $renderItems );
380 }
381
382 /**
383 * Method render_footer()
384 *
385 * Render MainWP Plugins Page Footer.
386 */
387 public static function render_footer() {
388 echo '</div>';
389 }
390
391 /**
392 * Render MainWP Plugins Page.
393 *
394 * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context()
395 * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_result()
396 * @uses \MainWP\Dashboard\MainWP_UI::render_empty_bulk_actions()
397 */
398 public static function render() {
399 $cachedSearch = MainWP_Cache::get_cached_context( 'Plugins' );
400 $selected_sites = array();
401 $selected_groups = array();
402 $selected_clients = array();
403
404 if ( null !== $cachedSearch ) {
405 if ( is_array( $cachedSearch['sites'] ) ) {
406 $selected_sites = $cachedSearch['sites'];
407 } elseif ( is_array( $cachedSearch['groups'] ) ) {
408 $selected_groups = $cachedSearch['groups'];
409 } elseif ( is_array( $cachedSearch['clients'] ) ) {
410 $selected_clients = $cachedSearch['clients'];
411 }
412 }
413 $cachedResult = MainWP_Cache::get_cached_result( 'Plugins' );
414
415 if ( isset( $_POST['select_mainwp_options_plugintheme_view'] ) && check_admin_referer( 'mainwp-admin-nonce' ) ) {
416 if ( is_array( $cachedResult ) && isset( $cachedResult['result'] ) ) {
417 unset( $cachedResult['result'] ); // clear cached results.
418 }
419 }
420
421 self::render_header( 'Manage' );
422 ?>
423
424 <div id="mainwp-manage-plugins" class="ui alt segment">
425 <div class="mainwp-main-content">
426 <div class="ui mini form mainwp-actions-bar">
427 <div class="ui stackable grid">
428 <div class="ui three column row">
429 <div class="column" >
430 <div id="mainwp-plugins-bulk-actions-wapper">
431 <?php
432 if ( is_array( $cachedResult ) && isset( $cachedResult['bulk_actions'] ) ) {
433 echo $cachedResult['bulk_actions']; // phpcs:ignore WordPress.Security.EscapeOutput
434 } else {
435 MainWP_UI::render_empty_bulk_actions();
436 }
437 ?>
438 </div>
439 <?php
440 /**
441 * Action: mainwp_plugins_actions_bar_left
442 *
443 * Fires at the left side of the actions bar on the Plugins screen, after the Bulk Actions menu.
444 *
445 * @since 4.0
446 */
447 do_action( 'mainwp_plugins_actions_bar_left' );
448 ?>
449 </div>
450 <div class="right aligned column" >
451 <?php
452 self::render_select_manage_view();
453 ?>
454 </div>
455 <div class="right aligned column">
456 <button id="mainwp-install-to-selected-sites" class="ui mini green basic button" style="display: none"><?php esc_html_e( 'Install to Selected Site(s)', 'mainwp' ); ?></button>
457 <?php
458 /**
459 * Action: mainwp_plugins_actions_bar_right
460 *
461 * Fires at the right side of the actions bar on the Plugins screen.
462 *
463 * @since 4.0
464 */
465 do_action( 'mainwp_plugins_actions_bar_right' );
466 ?>
467 </div>
468 </div>
469 </div>
470 </div>
471 <div class="ui segment" id="mainwp-plugins-table-wrapper">
472 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-plugins-info-message' ) ) : ?>
473 <div class="ui info message">
474 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-plugins-info-message"></i>
475 <div><?php echo esc_html__( 'Manage installed plugins on your child sites. Here you can activate, deactivate, and delete installed plugins.', 'mainwp' ); ?></div>
476 <p><?php echo esc_html__( 'To Activate or Delete a specific plugin, you must search only for Inactive plugin on your child sites. If you search for Active or both Active and Inactive, the Activate and Delete actions will be disabled.', 'mainwp' ); ?></p>
477 <p><?php echo esc_html__( 'To Deactivate a specific plugin, you must search only for Active plugins on your child sites. If you search for Inactive or both Active and Inactive, the Deactivate action will be disabled.', 'mainwp' ); ?></p>
478 <p><?php printf( esc_html__( 'For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/managing-plugins-with-mainwp/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></p>
479 </div>
480 <?php endif; ?>
481 <div id="mainwp-message-zone" class="ui message" style="display:none"></div>
482 <div id="mainwp-loading-plugins-row" class="ui active inverted dimmer" style="display:none">
483 <div class="ui large text loader"><?php esc_html_e( 'Loading Plugins...', 'mainwp' ); ?></div>
484 </div>
485 <div id="mainwp-plugins-main-content" <?php echo ( null !== $cachedSearch ) ? 'style="display: block;"' : ''; ?> >
486 <div id="mainwp-plugins-content">
487 <?php if ( is_array( $cachedResult ) && isset( $cachedResult['result'] ) ) : ?>
488 <?php echo $cachedResult['result']; // phpcs:ignore WordPress.Security.EscapeOutput ?>
489 <?php else : ?>
490 <div class="ui hidden divider"></div>
491 <div class="ui hidden divider"></div>
492 <div class="ui hidden divider"></div>
493 <?php MainWP_UI::render_empty_element_placeholder( __( 'Use the search options to find the plugin you want to manage', 'mainwp' ) ); ?>
494 <?php endif; ?>
495 </div>
496 </div>
497 </div>
498 </div>
499
500 <div class="mainwp-side-content mainwp-no-padding">
501 <?php
502 /**
503 * Action: mainwp_manage_plugins_sidebar_top
504 *
505 * Fires at the top of the sidebar on Manage themes.
506 *
507 * @since 4.1
508 */
509 do_action( 'mainwp_manage_plugins_sidebar_top' );
510 ?>
511
512 <div class="mainwp-select-sites ui accordion mainwp-sidebar-accordion">
513 <?php
514 /**
515 * Action: mainwp_manage_plugins_before_select_sites
516 *
517 * Fires before the Select Sites elemnt on Manage plugins.
518 *
519 * @since 4.1
520 */
521 do_action( 'mainwp_manage_plugins_before_select_sites' );
522 ?>
523 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Sites', 'mainwp' ); ?></div>
524 <div class="content active">
525 <?php
526 $sel_params = array(
527 'class' => 'mainwp_select_sites_box_left',
528 'selected_sites' => $selected_sites,
529 'selected_groups' => $selected_groups,
530 'selected_clients' => $selected_clients,
531 'show_client' => true,
532 );
533 MainWP_UI_Select_Sites::select_sites_box( $sel_params );
534 ?>
535 </div>
536 <?php
537 /**
538 * Action: mainwp_manage_plugins_after_select_sites
539 *
540 * Fires after the Select Sites elemnt on Manage plugins.
541 *
542 * @since 4.1
543 */
544 do_action( 'mainwp_manage_plugins_after_select_sites' );
545 ?>
546 </div>
547 <div class="ui fitted divider"></div>
548 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
549 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Status', 'mainwp' ); ?></div>
550 <div class="content active">
551 <?php
552 /**
553 * Action: mainwp_manage_plugins_before_search_options
554 *
555 * Fires before the Search Options elemnt on Manage plugins.
556 *
557 * @since 4.1
558 */
559 do_action( 'mainwp_manage_plugins_before_search_options' );
560 ?>
561 <div class="ui info message">
562 <i class="close icon mainwp-notice-dismiss" notice-id="plugins-manage-info"></i>
563 <?php esc_html_e( 'A plugin needs to be Inactive for it to be Activated or Deleted.', 'mainwp' ); ?>
564 </div>
565 <div class="ui mini form">
566 <div class="field">
567 <select class="ui fluid dropdown" id="mainwp_plugins_search_by_status">
568 <option value=""><?php esc_html_e( 'Select status', 'mainwp' ); ?></option>
569 <option value="active" selected><?php esc_html_e( 'Active', 'mainwp' ); ?></option>
570 <option value="inactive"><?php esc_html_e( 'Inactive', 'mainwp' ); ?></option>
571 <option value="installed"><?php esc_html_e( 'Active & Inactive', 'mainwp' ); ?></option>
572 <option value="not_installed"><?php esc_html_e( 'Not installed', 'mainwp' ); ?></option>
573 </select>
574 </div>
575 </div>
576 <?php
577 /**
578 * Action: mainwp_manage_plugins_after_search_options
579 *
580 * Fires after the Search Options elemnt on Manage plugins.
581 *
582 * @since 4.1
583 */
584 do_action( 'mainwp_manage_plugins_after_search_options' );
585 ?>
586 </div>
587 </div>
588 <div class="ui fitted divider"></div>
589 <?php self::render_search_options(); ?>
590 <div class="ui fitted divider"></div>
591 <div class="mainwp-search-submit">
592 <?php
593 /**
594 * Action: mainwp_manage_plugins_before_submit_button
595 *
596 * Fires before the Submit Button elemnt on Manage plugins.
597 *
598 * @since 4.1
599 */
600 do_action( 'mainwp_manage_plugins_before_submit_button' );
601 ?>
602 <input type="button" name="mainwp-show-plugins" id="mainwp-show-plugins" class="ui green big fluid button" value="<?php esc_attr_e( 'Show Plugins', 'mainwp' ); ?>"/>
603 <?php
604 /**
605 * Action: mainwp_manage_plugins_after_submit_button
606 *
607 * Fires after the Submit Button elemnt on Manage plugins.
608 *
609 * @since 4.1
610 */
611 do_action( 'mainwp_manage_plugins_after_submit_button' );
612 ?>
613 </div>
614 <?php
615 /**
616 * Action: mainwp_manage_plugins_sidebar_bottom
617 *
618 * Fires at the bottom of the sidebar on Manage themes.
619 *
620 * @since 4.1
621 */
622 do_action( 'mainwp_manage_plugins_sidebar_bottom' );
623 ?>
624 </div>
625 <div style="clear:both"></div>
626 </div>
627 <?php
628 self::render_footer( 'Manage' );
629 }
630
631 /**
632 * Render MainWP plugins page search options.
633 *
634 * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context()
635 */
636 public static function render_search_options() {
637 $cachedSearch = MainWP_Cache::get_cached_context( 'Plugins' );
638 $statuses = isset( $cachedSearch['status'] ) ? $cachedSearch['status'] : array();
639 if ( $cachedSearch && isset( $cachedSearch['keyword'] ) ) {
640 $cachedSearch['keyword'] = trim( $cachedSearch['keyword'] );
641 }
642 $disabledNegative = ( null !== $cachedSearch ) && ! empty( $cachedSearch['keyword'] ) ? false : true;
643 $checkedNegative = ! $disabledNegative && ( null !== $cachedSearch ) && ! empty( $cachedSearch['not_criteria'] ) ? true : false;
644 ?>
645 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
646 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Search Options', 'mainwp' ); ?></div>
647 <div class="content active">
648 <div class="ui mini form">
649 <div class="field">
650 <div class="ui input fluid">
651 <input type="text" placeholder="<?php esc_attr_e( 'Plugin name', 'mainwp' ); ?>" id="mainwp_plugin_search_by_keyword" class="text" value="<?php echo ( null !== $cachedSearch ) ? esc_attr( $cachedSearch['keyword'] ) : ''; //phpcs:ignore -- escaped. ?>" />
652 </div>
653 </div>
654 <div class="ui hidden fitted divider"></div>
655 <div class="field">
656 <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Display sites not meeting the above search criteria.', 'mainwp' ); ?>" data-position="left center" data-inverted="">
657 <input type="checkbox" <?php echo $disabledNegative ? 'disabled' : ''; ?> <?php echo ( $checkedNegative ? 'checked="true"' : '' ); ?> value="1" id="display_sites_not_meeting_criteria" />
658 <label for="display_sites_not_meeting_criteria"><?php esc_html_e( 'Exclude plugin', 'mainwp' ); ?></label>
659 </div>
660 </div>
661 </div>
662 </div>
663 </div>
664 <?php
665 if ( is_array( $statuses ) && 0 < count( $statuses ) ) {
666 $status = '';
667 foreach ( $statuses as $st ) {
668 $status .= "'" . esc_html( $st ) . "',";
669 }
670 $status = rtrim( $status, ',' );
671 ?>
672 <script type="text/javascript">
673 jQuery( document ).ready( function () {
674 jQuery( '#mainwp_plugins_search_by_status' ).dropdown( 'set selected', [<?php echo $status; // phpcs:ignore -- safe output, to fix incorrect characters. ?>] );
675 } );
676 </script>
677 <?php
678 }
679 ?>
680 <script type="text/javascript">
681 jQuery( document ).on( 'keyup', '#mainwp_plugin_search_by_keyword', function () {
682 if( jQuery(this).val() != '' ){
683 jQuery( '#display_sites_not_meeting_criteria' ).prop("disabled", false);
684 } else {
685 jQuery( '#display_sites_not_meeting_criteria' ).closest('.checkbox').checkbox('set unchecked');
686 jQuery( '#display_sites_not_meeting_criteria' ).attr('disabled', 'true');
687 }
688 });
689 </script>
690 <?php
691 }
692
693 /**
694 * Render Plugins Table.
695 *
696 * @param mixed $keyword Search Terms.
697 * @param mixed $status active|inactive Whether the plugin is active or inactive.
698 * @param mixed $groups Selected Child Site Groups.
699 * @param mixed $sites Selected individual Child Sites.
700 * @param mixed $not_criteria Show not criteria result.
701 * @param mixed $clients Selected Clients.
702 *
703 * @return string Plugin Table.
704 *
705 * @uses MainWP_Cache::init_cache()
706 * @uses MainWP_Utility::ctype_digit()
707 * @uses MainWP_DB::instance()
708 * @uses MainWP_DB::free_result()
709 * @uses MainWP_DB::fetch_object()
710 * @uses MainWP_Utility::map_site()
711 * @uses MainWP_Utility::fetch_urls_authed()
712 * @uses MainWP_Utility::get_nice_url()
713 * @uses MainWP_Cache::add_result()
714 * @uses \MainWP\Dashboard\MainWP_Cache::init_cache()
715 * @uses \MainWP\Dashboard\MainWP_Cache::add_context()
716 * @uses \MainWP\Dashboard\MainWP_Cache::add_result()
717 * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed()
718 * @uses \MainWP\Dashboard\MainWP_DB::query()
719 * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
720 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_by_group_id()
721 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
722 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
723 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::get_class_name()
724 * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
725 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
726 */
727 public static function render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients ) { // phpcs:ignore -- Current complexity required to achieve desired results. Pull request solutions appreciated.
728 $keyword = trim( $keyword );
729 MainWP_Cache::init_cache( 'Plugins' );
730
731 $output = new \stdClass();
732 $output->errors = array();
733 $output->plugins = array();
734 $output->plugins_installed = array();
735 $output->status = $status;
736 $error_results = '';
737
738 $data_fields = MainWP_System_Utility::get_default_map_site_fields();
739 $data_fields[] = 'plugins';
740
741 if ( 1 === (int) get_option( 'mainwp_optimize', 1 ) || MainWP_Demo_Handle::is_demo_mode() ) {
742
743 $multi_kws = explode( ',', $keyword );
744 $multi_kws = array_filter( array_map( 'trim', $multi_kws ) );
745
746 if ( ! empty( $sites ) ) {
747 foreach ( $sites as $k => $v ) {
748 if ( MainWP_Utility::ctype_digit( $v ) ) {
749 $website = MainWP_DB::instance()->get_website_by_id( $v );
750 $allPlugins = json_decode( $website->plugins, true );
751 $_count = count( $allPlugins );
752 $_count_installed = 0;
753 for ( $i = 0; $i < $_count; $i++ ) {
754 $plugin = $allPlugins[ $i ];
755
756 if ( ( 'active' === $status ) || ( 'inactive' === $status ) ) {
757 if ( ( ( 'active' === $status ) ? 1 : 0 ) !== (int) $plugin['active'] ) {
758 continue;
759 }
760 }
761
762 if ( ! empty( $keyword ) ) {
763 if ( $not_criteria ) {
764 if ( MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
765 continue;
766 }
767 } elseif ( ! MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
768 continue;
769 }
770 }
771
772 $plugin['websiteid'] = $website->id;
773 $plugin['websiteurl'] = $website->url;
774 $plugin['websitename'] = $website->name;
775 $output->plugins[] = $plugin;
776 ++$_count_installed;
777 }
778
779 if ( 0 === $_count_installed ) {
780 if ( 'not_installed' === $status ) {
781 for ( $i = 0; $i < $_count; $i++ ) {
782 $plugin = $allPlugins[ $i ];
783 $plugin['websiteid'] = $website->id;
784 $plugin['websiteurl'] = $website->url;
785 $plugin['websitename'] = $website->name;
786 $output->plugins_installed[] = $plugin;
787 }
788 }
789 }
790 }
791 }
792 }
793
794 if ( '' !== $groups ) {
795 foreach ( $groups as $k => $v ) {
796 if ( MainWP_Utility::ctype_digit( $v ) ) {
797 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) );
798 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
799 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
800 continue;
801 }
802 $allPlugins = json_decode( $website->plugins, true );
803 $_count = count( $allPlugins );
804 $_count_installed = 0;
805 for ( $i = 0; $i < $_count; $i++ ) {
806 $plugin = $allPlugins[ $i ];
807
808 if ( ( 'active' === $status ) || ( 'inactive' === $status ) ) {
809 if ( ( ( 'active' === $status ) ? 1 : 0 ) !== (int) $plugin['active'] ) {
810 continue;
811 }
812 }
813
814 if ( ! empty( $keyword ) ) {
815 if ( $not_criteria ) {
816 if ( MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
817 continue;
818 }
819 } elseif ( ! MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
820 continue;
821 }
822 }
823
824 $plugin['websiteid'] = $website->id;
825 $plugin['websiteurl'] = $website->url;
826 $plugin['websitename'] = $website->name;
827 $output->plugins[] = $plugin;
828 ++$_count_installed;
829 }
830
831 if ( 0 === $_count_installed ) {
832 if ( 'not_installed' === $status ) {
833 for ( $i = 0; $i < $_count; $i++ ) {
834 $plugin = $allPlugins[ $i ];
835 $plugin['websiteid'] = $website->id;
836 $plugin['websiteurl'] = $website->url;
837 $plugin['websitename'] = $website->name;
838 $output->plugins_installed[] = $plugin;
839 }
840 }
841 }
842 }
843 MainWP_DB::free_result( $websites );
844 }
845 }
846 }
847
848 if ( '' !== $clients && is_array( $clients ) ) {
849 $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids(
850 $clients,
851 array(
852 'select_data' => $data_fields,
853 )
854 );
855 if ( $websites ) {
856 foreach ( $websites as $website ) {
857 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
858 continue;
859 }
860 $allPlugins = json_decode( $website->plugins, true );
861 $_count = count( $allPlugins );
862 $_count_installed = 0;
863 for ( $i = 0; $i < $_count; $i++ ) {
864 $plugin = $allPlugins[ $i ];
865
866 if ( ( 'active' === $status ) || ( 'inactive' === $status ) ) {
867 if ( ( ( 'active' === $status ) ? 1 : 0 ) !== (int) $plugin['active'] ) {
868 continue;
869 }
870 }
871
872 if ( ! empty( $keyword ) ) {
873 if ( $not_criteria ) {
874 if ( MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
875 continue;
876 }
877 } elseif ( ! MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
878 continue;
879 }
880 }
881
882 $plugin['websiteid'] = $website->id;
883 $plugin['websiteurl'] = $website->url;
884 $plugin['websitename'] = $website->name;
885 $output->plugins[] = $plugin;
886 ++$_count_installed;
887 }
888 if ( 0 === $_count_installed ) {
889 if ( 'not_installed' === $status ) {
890 for ( $i = 0; $i < $_count; $i++ ) {
891 $plugin = $allPlugins[ $i ];
892 $plugin['websiteid'] = $website->id;
893 $plugin['websiteurl'] = $website->url;
894 $plugin['websitename'] = $website->name;
895 $output->plugins_installed[] = $plugin;
896 }
897 }
898 }
899 }
900 }
901 }
902 } else {
903 $dbwebsites = array();
904
905 if ( '' !== $sites ) {
906 foreach ( $sites as $k => $v ) {
907 if ( MainWP_Utility::ctype_digit( $v ) ) {
908 $website = MainWP_DB::instance()->get_website_by_id( $v );
909
910 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
911 continue;
912 }
913
914 $dbwebsites[ $website->id ] = MainWP_Utility::map_site(
915 $website,
916 $data_fields
917 );
918 }
919 }
920 }
921
922 if ( '' !== $groups ) {
923 foreach ( $groups as $k => $v ) {
924 if ( MainWP_Utility::ctype_digit( $v ) ) {
925 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) );
926 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
927 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
928 continue;
929 }
930 $dbwebsites[ $website->id ] = MainWP_Utility::map_site(
931 $website,
932 $data_fields
933 );
934 }
935 MainWP_DB::free_result( $websites );
936 }
937 }
938 }
939
940 if ( '' !== $clients && is_array( $clients ) ) {
941 $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids(
942 $clients,
943 array(
944 'select_data' => $data_fields,
945 )
946 );
947 if ( $websites ) {
948 foreach ( $websites as $website ) {
949 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
950 continue;
951 }
952 $dbwebsites[ $website->id ] = MainWP_Utility::map_site(
953 $website,
954 $data_fields
955 );
956 }
957 }
958 }
959
960 $post_data = array(
961 'keyword' => $keyword,
962 );
963
964 if ( 'active' === $status || 'inactive' === $status ) {
965 $post_data['status'] = $status;
966 $post_data['filter'] = true;
967 } else {
968 $post_data['status'] = '';
969 $post_data['filter'] = false;
970 }
971
972 if ( 'not_installed' === $status ) {
973 $post_data['not_installed'] = true;
974 }
975
976 $post_data['not_criteria'] = $not_criteria ? true : false;
977 MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_plugins', $post_data, array( MainWP_Plugins_Handler::get_class_name(), 'plugins_search_handler' ), $output );
978 // phpcs:disable WordPress.Security.EscapeOutput
979 if ( 0 < count( $output->errors ) ) {
980 foreach ( $output->errors as $siteid => $error ) {
981 $error_results .= MainWP_Utility::get_nice_url( $dbwebsites[ $siteid ]->url ) . ': ' . $error . ' <br/>';
982 }
983 }
984 // phpcs:enable
985 }
986
987 MainWP_Cache::add_context(
988 'Plugins',
989 array(
990 'keyword' => $keyword,
991 'status' => $status,
992 'sites' => ( '' !== $sites ) ? $sites : '',
993 'groups' => ( '' !== $groups ) ? $groups : '',
994 'clients' => ( '' !== $clients ) ? $clients : '',
995 'not_criteria' => $not_criteria ? true : false,
996 )
997 );
998
999 $view_mode = self::get_manage_view();
1000
1001 $bulkActions = self::render_bulk_actions( $status );
1002
1003 $plugins_list = array();
1004
1005 ob_start();
1006
1007 if ( ! empty( $error_results ) ) {
1008 // phpcs:disable WordPress.Security.EscapeOutput
1009 ?>
1010 <div class="ui message yellow"><?php echo $error_results; ?></div>
1011 <?php
1012 // phpcs:enable
1013 }
1014
1015 if ( 'not_installed' === $status ) {
1016 if ( empty( $output->plugins_installed ) ) {
1017 ?>
1018 <div class="ui message yellow"><?php esc_html_e( 'No websites found.', 'mainwp' ); ?></div>
1019 <?php
1020 } else {
1021 $plugins_list = $output->plugins_installed;
1022 $view_mode = MAINWP_VIEW_PER_SITE;
1023 }
1024 } elseif ( 0 === count( $output->plugins ) ) {
1025 ?>
1026 <div class="ui message yellow"><?php esc_html_e( 'No plugins found.', 'mainwp' ); ?></div>
1027 <?php
1028 } else {
1029 $plugins_list = $output->plugins;
1030 }
1031
1032 $sites = array();
1033 $sitePlugins = array();
1034 $plugins = array();
1035 $pluginsNameSites = array();
1036 $muPlugins = array();
1037 $pluginsName = array();
1038 $pluginsMainWP = array();
1039 $pluginsRealVersion = array();
1040
1041 if ( ! empty( $plugins_list ) ) {
1042
1043 foreach ( $plugins_list as $plugin ) {
1044 $slug_ver = esc_html( $plugin['slug'] . '_' . $plugin['version'] );
1045 $sites[ $plugin['websiteid'] ] = array(
1046 'websiteurl' => esc_html( $plugin['websiteurl'] ),
1047 'websitename' => $plugin['websitename'],
1048 );
1049
1050 $pluginsSlug[ $slug_ver ] = isset( $plugin['slug'] ) ? $plugin['slug'] : '';
1051 $muPlugins[ $slug_ver ] = isset( $plugin['mu'] ) ? esc_html( $plugin['mu'] ) : 0;
1052 $pluginsName[ $slug_ver ] = esc_html( $plugin['name'] );
1053
1054 $pluginsNameSites[ $plugin['name'] ][ $plugin['websiteid'] ][] = $slug_ver;
1055
1056 $pluginsMainWP[ $slug_ver ] = isset( $plugin['mainwp'] ) ? esc_html( $plugin['mainwp'] ) : 'F';
1057 $pluginsRealVersion[ $slug_ver ] = rawurlencode( $plugin['version'] );
1058
1059 if ( ! isset( $sitePlugins[ $plugin['websiteid'] ] ) || ! is_array( $sitePlugins[ $plugin['websiteid'] ] ) ) {
1060 $sitePlugins[ $plugin['websiteid'] ] = array();
1061 }
1062
1063 $sitePlugins[ $plugin['websiteid'] ][ $slug_ver ] = $plugin;
1064 }
1065
1066 ksort( $pluginsNameSites, SORT_STRING );
1067
1068 if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $view_mode ) {
1069 self::render_manage_table( $sites, $pluginsSlug, $sitePlugins, $pluginsMainWP, $muPlugins, $pluginsName, $pluginsNameSites, $pluginsRealVersion );
1070 } else {
1071 self::render_manage_per_site_table( $sites, $pluginsSlug, $sitePlugins, $pluginsMainWP, $muPlugins, $pluginsName, $pluginsNameSites, $pluginsRealVersion );
1072 }
1073 MainWP_Updates::render_plugin_details_modal();
1074 MainWP_UI::render_modal_upload_icon();
1075 }
1076
1077 $newOutput = ob_get_clean();
1078 $result = array(
1079 'result' => $newOutput,
1080 'bulk_actions' => $bulkActions,
1081 );
1082
1083 MainWP_Cache::add_result( 'Plugins', $result );
1084 return $result;
1085 }
1086
1087
1088 /**
1089 * Render Bulk Actions.
1090 *
1091 * @param mixed $status active|inactive|all.
1092 *
1093 * @return string Plugin Bulk Actions Menu.
1094 */
1095 public static function render_bulk_actions( $status ) {
1096 ob_start();
1097 ?>
1098 <select class="ui dropdown" id="mainwp-bulk-actions">
1099 <option value="none"><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
1100 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
1101 <option value="ignore_updates" data-value="ignore_updates"><?php esc_html_e( 'Ignore updates', 'mainwp' ); ?></option>
1102 <?php endif; ?>
1103 <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) : ?>
1104 <?php if ( 'active' === $status ) : ?>
1105 <option value="deactivate" data-value="deactivate"><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></option>
1106 <?php else : ?>
1107 <option value="deactivate" disabled data-value="deactivate"><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></option>
1108 <?php endif; ?>
1109 <?php endif; ?>
1110 <?php if ( 'inactive' === $status ) : ?>
1111 <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) : ?>
1112 <option value="activate" data-value="activate"><?php esc_html_e( 'Activate', 'mainwp' ); ?></option>
1113 <?php endif; ?>
1114 <?php if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) : ?>
1115 <option value="delete" data-value="delete"><?php esc_html_e( 'Delete', 'mainwp' ); ?></option>
1116 <?php endif; ?>
1117 <?php else : ?>
1118 <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) : ?>
1119 <option value="activate" disabled data-value="activate"><?php esc_html_e( 'Activate', 'mainwp' ); ?></option>
1120 <?php endif; ?>
1121 <?php if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) : ?>
1122 <option value="delete" disabled data-value="delete"><?php esc_html_e( 'Delete', 'mainwp' ); ?></option>
1123 <?php endif; ?>
1124 <?php endif; ?>
1125 <?php
1126 /**
1127 * Action: mainwp_plugins_bulk_action
1128 *
1129 * Adds a new action to the Manage Plugins bulk actions menu.
1130 *
1131 * @param string $status Status search parameter.
1132 *
1133 * @since 4.1
1134 */
1135 do_action( 'mainwp_plugins_bulk_action' );
1136 ?>
1137 </select>
1138 <button class="ui mini basic button" href="javascript:void(0)" id="mainwp-do-plugins-bulk-actions"><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
1139 <span id="mainwp_bulk_action_loading"><i class="ui active inline loader tiny"></i></span>
1140 <?php
1141 $bulkActions = ob_get_clean();
1142 return $bulkActions;
1143 }
1144
1145 /**
1146 * Method get_manage_view().
1147 *
1148 * Get view mode.
1149 *
1150 * @param string $which plugin|theme.
1151 *
1152 * @return int view mode value.
1153 */
1154 public static function get_manage_view( $which = 'plugin' ) {
1155 if ( 'plugin' === $which ) {
1156 return get_user_option( 'mainwp_manage_plugin_view', MAINWP_VIEW_PER_PLUGIN_THEME );
1157 } else {
1158 return get_user_option( 'mainwp_manage_theme_view', MAINWP_VIEW_PER_PLUGIN_THEME );
1159 }
1160 }
1161
1162 /**
1163 * Method render_select_manage_view().
1164 *
1165 * Handle render view mode selection.
1166 *
1167 * @param string $which plugin|theme.
1168 *
1169 * @return void.
1170 */
1171 public static function render_select_manage_view( $which = 'plugin' ) {
1172
1173 $view_mode = self::get_manage_view( $which );
1174
1175 $hide_show_updates_per = apply_filters( 'mainwp_manage_plugin_theme_hide_show_updates_per', false, $which );
1176
1177 if ( ! $hide_show_updates_per ) {
1178 ?>
1179 <form method="post" action="" class="ui mini form right aligned">
1180 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1181 <input type="hidden" name="whichview" value="<?php echo esc_attr( $which ); ?>" />
1182 <div class="inline field">
1183 <select class="ui dropdown" onchange="mainwp_siteview_onchange(this)" name="select_mainwp_options_plugintheme_view">
1184 <option value="0" class="item" <?php echo MAINWP_VIEW_PER_PLUGIN_THEME === (int) $view_mode ? 'selected' : ''; ?>><?php echo esc_html( 'plugin' === $which ? esc_html__( 'Show Plugins per Item', 'mainwp' ) : esc_html__( 'Show Themes per Item', 'mainwp' ) ); ?></option>
1185 <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === (int) $view_mode ? 'selected' : ''; ?>><?php echo esc_html( 'plugin' === $which ? esc_html__( 'Show Plugins per Site', 'mainwp' ) : esc_html__( 'Show Themes per Site', 'mainwp' ) ); ?></option>
1186 </select>
1187 </div>
1188 </form>
1189 <?php
1190 }
1191 }
1192
1193
1194 /**
1195 * Method render_manage_per_site_table()
1196 *
1197 * Render Manage Plugins Table.
1198 *
1199 * @param array $sites Child Sites array.
1200 * @param array $pluginsSlug Plugins slug array.
1201 * @param array $sitePlugins Site plugins array.
1202 * @param array $pluginsMainWP MainWP plugins array.
1203 * @param array $muPlugins Must use plugins array.
1204 * @param array $pluginsName Plugin names array.
1205 * @param array $pluginsNameSites Plugin names with Sites array.
1206 * @param array $pluginsRealVersion Latest plugin release version.
1207 */
1208 public static function render_manage_per_site_table( $sites, $pluginsSlug = array(), $sitePlugins = array(), $pluginsMainWP = array(), $muPlugins = array(), $pluginsName = array(), $pluginsNameSites = array(), $pluginsRealVersion = array() ) { //phpcs:ignore -- complex method.
1209
1210 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
1211 $decodedIgnoredPlugins = json_decode( $userExtension->ignored_plugins, true );
1212 $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
1213 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1214
1215 if ( ! is_array( $trustedPlugins ) ) {
1216 $trustedPlugins = array();
1217 }
1218
1219 $updateWebsites = array();
1220
1221 foreach ( $sites as $site_id => $info ) {
1222
1223 $plugin_upgrades = array();
1224 $website = MainWP_DB::instance()->get_website_by_id( $site_id );
1225 if ( $website ) {
1226 if ( ! $website->is_ignorePluginUpdates ) {
1227 $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
1228 $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
1229 $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
1230
1231 if ( is_array( $decodedPremiumUpgrades ) ) {
1232 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
1233 $premiumUpgrade['premium'] = true;
1234
1235 if ( 'plugin' === $premiumUpgrade['type'] ) {
1236 if ( ! is_array( $plugin_upgrades ) ) {
1237 $plugin_upgrades = array();
1238 }
1239
1240 $premiumUpgrade = array_filter( $premiumUpgrade );
1241
1242 if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
1243 $plugin_upgrades[ $crrSlug ] = array();
1244 }
1245 $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
1246 }
1247 }
1248 }
1249 $ignored_plugins = json_decode( $website->ignored_plugins, true );
1250 if ( is_array( $ignored_plugins ) ) {
1251 $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
1252 }
1253
1254 if ( is_array( $decodedIgnoredPlugins ) ) {
1255 $plugin_upgrades = array_diff_key( $plugin_upgrades, $decodedIgnoredPlugins );
1256 }
1257 }
1258 }
1259 $updateWebsites[ $site_id ] = $plugin_upgrades;
1260 }
1261
1262 /**
1263 * Action: mainwp_before_plugins_table
1264 *
1265 * Fires before the Plugins table.
1266 *
1267 * @since 4.1
1268 */
1269 do_action( 'mainwp_before_plugins_table' );
1270 ?>
1271 <div class="ui secondary segment main-master-checkbox">
1272 <div class="ui stackable grid">
1273 <div class="one wide center aligned middle aligned column">
1274 <span class="trigger-all-accordion"><span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span></span>
1275 </div>
1276 <div class="one wide center aligned middle aligned column"><div class="ui checkbox main-master not-auto-init"><input type="checkbox"/><label></label></div></div>
1277 <div class="five wide middle aligned column"><?php esc_html_e( 'Website', 'mainwp' ); ?></div>
1278 <div class="two wide center aligned middle aligned column"></div>
1279 <div class="two wide center aligned middle aligned column"></div>
1280 <div class="two wide center aligned middle aligned column"></div>
1281 <div class="two wide center aligned middle aligned column"><?php esc_html_e( 'Plugins', 'mainwp' ); ?></div>
1282 </div>
1283 </div>
1284
1285 <div class="mainwp-manage-plugins-wrapper main-child-checkbox">
1286 <?php foreach ( $sites as $site_id => $website ) : ?>
1287 <?php
1288 $site_name = $website['websitename'];
1289 $slugVersions = isset( $sitePlugins[ $site_id ] ) ? $sitePlugins[ $site_id ] : array();
1290
1291 if ( ! is_array( $slugVersions ) ) {
1292 $slugVersions = array();
1293 }
1294
1295 $item_id = $site_id;
1296 $count_plugins = count( $slugVersions );
1297
1298 // phpcs:disable WordPress.Security.EscapeOutput
1299 ?>
1300 <div class="ui accordion mainwp-manage-plugin-accordion mainwp-manage-plugin-item main-child-checkbox" id="<?php echo esc_html( $item_id ); ?>">
1301 <div class="title master-checkbox">
1302 <div class="ui stackable grid">
1303 <div class="one wide center aligned middle aligned column"><i class="dropdown icon dropdown-trigger"></i></div>
1304 <div class="one wide center aligned middle aligned column">
1305 <div class="ui checkbox master">
1306 <input type="checkbox"/>
1307 <label></label>
1308 </div>
1309 </div>
1310 <div class="three wide middle aligned column"><a target="_blank" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo intval( $site_id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>"><i class="sign in icon"></i></a> <a href="admin.php?page=managesites&dashboard=<?php echo intval( $site_id ); ?>"><?php echo esc_html( $site_name ); ?></a></div>
1311 <div class="two wide center aligned middle aligned column"></div>
1312 <div class="two wide center aligned middle aligned column"></div>
1313 <div class="two wide center aligned middle aligned column"></div>
1314 <div class="two wide center aligned middle aligned column"></div>
1315 <div class="two wide center aligned middle aligned column"><div class="ui label"><i class="icon plug"></i> <?php echo intval( $count_plugins ); ?></div></div>
1316 </div>
1317 </div>
1318 <div class="content child-checkbox">
1319 <?php
1320 // phpcs:enable
1321 foreach ( $slugVersions as $slug_ver => $plugin ) :
1322
1323 $plugin_title = wp_strip_all_tags( $pluginsName[ $slug_ver ] );
1324
1325 $plugin_slug = $pluginsSlug[ $slug_ver ];
1326 $trusted = in_array( $plugin_slug, $trustedPlugins ) ? true : false;
1327 $child_plugin = ( isset( $pluginsMainWP[ $slug_ver ] ) && 'T' === $pluginsMainWP[ $slug_ver ] ) ? true : false;
1328
1329 $plugin_mu = false;
1330
1331 $plugin_version = $sitePlugins[ $site_id ][ $slug_ver ]['version'];
1332
1333 $plugin_upgrades = isset( $updateWebsites[ $site_id ] ) ? $updateWebsites[ $site_id ] : array();
1334 if ( ! is_array( $plugin_upgrades ) ) {
1335 $plugin_upgrades = array();
1336 }
1337
1338 $upgradeInfo = isset( $plugin_upgrades[ $plugin_slug ] ) ? $plugin_upgrades[ $plugin_slug ] : false;
1339
1340 $new_version = '';
1341 if ( ! empty( $upgradeInfo ) && isset( $upgradeInfo['update']['new_version'] ) ) {
1342 $new_version = $upgradeInfo['update']['new_version'];
1343 }
1344
1345 if ( isset( $sitePlugins[ $site_id ][ $slug_ver ] ) && ( empty( $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) || 1 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) ) {
1346 $actived = true;
1347 if ( isset( $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) && 1 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) {
1348 $plugin_status = '<span class="ui small green basic label">' . esc_html__( 'Active', 'mainwp' ) . '</span>';
1349 } elseif ( isset( $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) && 0 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) {
1350 $plugin_status = '<span class="ui small red basic label">' . esc_html__( 'Inactive', 'mainwp' ) . '</span>';
1351 $actived = false;
1352 } else {
1353 $plugin_status = '';
1354 }
1355
1356 if ( isset( $sitePlugins[ $site_id ][ $slug_ver ] ) && ( 1 === (int) $muPlugins[ $slug_ver ] ) ) {
1357 $plugin_mu = true;
1358 }
1359
1360 if ( $plugin_mu ) {
1361 $actived = true; // always.
1362 }
1363
1364 $item_id = $slug_ver . '_' . $site_id;
1365 $item_id = strtolower( $item_id );
1366 $item_id = preg_replace( '/[[:space:]]+/', '_', $item_id );
1367
1368 $plugin_directory = MainWP_Utility::get_dir_slug( $plugin_slug );
1369 $details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $site_id ) . '&plugin=' . rawurlencode( $plugin_directory ) . '&section=changelog' );
1370 ?>
1371 <div class="ui very compact stackable grid mainwp-manage-plugin-item-website" plugin-slug="<?php echo esc_attr( rawurlencode( $plugin_slug ) ); ?>" plugin-name="<?php echo esc_html( $plugin_title ); ?>" site-id="<?php echo intval( $site_id ); ?>" site-name="<?php echo esc_html( $site_name ); ?>" id="<?php echo esc_html( $item_id ); ?>">
1372 <div class="one wide center aligned middle aligned column"></div>
1373 <div class="one wide center aligned middle aligned column">
1374 <div class="ui checkbox child <?php echo 'mainwp-child' === $plugin_directory ? 'disabled' : ''; ?>">
1375 <input type="checkbox"
1376 <?php
1377 echo 'mainwp-child' === $plugin_directory ? 'disabled="disabled"' : 'class="mainwp-selected-plugin-site"';
1378 ?>
1379 ><label></label>
1380 </div>
1381 </div>
1382 <?php // phpcs:disable WordPress.Security.EscapeOutput ?>
1383 <div class="one wide center aligned middle aligned column"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); ?></div>
1384 <?php // phpcs:enable ?>
1385 <div class="three wide middle aligned column"><a class="open-plugin-details-modal" href="<?php echo esc_url( $details_link ); ?>" target="_blank" ><strong><?php echo esc_html( $plugin_title ); ?></strong></a></div>
1386 <div class="one wide center aligned middle aligned column"><?php echo $plugin_status; //phpcs:ignore -- escaped. ?></div>
1387 <div class="two wide center aligned middle aligned column"><?php echo $trusted ? '<span class="ui tiny basic green label">' . esc_html__( 'Trusted', 'mainwp' ) . '</span>' : '<span class="ui tiny basic grey label">' . esc_html__( 'Not Trusted', 'mainwp' ) . '</span>'; ?></div>
1388 <div class="one wide center aligned middle aligned column"><?php echo $plugin_mu ? '<span class="ui small label"><i class="exclamation yellow triangle icon"></i> Must Use</span>' : ''; ?></div>
1389 <div class="two wide center aligned middle aligned column current-version">
1390 <?php echo esc_html( $plugin_version ); ?>
1391 <?php if ( ! empty( $new_version ) ) : ?>
1392 &rarr; <?php echo esc_html( $new_version ); ?>
1393 <?php endif; ?>
1394 </div>
1395 <div class="two wide right aligned middle aligned column update-column" updated="0">
1396 <?php if ( ! empty( $upgradeInfo ) && MainWP_Updates::user_can_update_plugins() ) : ?>
1397 <a href="javascript:void(0)" class="ui mini green basic button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Update ', 'mainwp' ) . esc_html( $plugin_title ) . esc_attr_e( ' plugin on this child site.', 'mainwp' ); ?>" data-inverted="" onClick="return manage_plugins_upgrade( '<?php echo esc_js( rawurlencode( $plugin_slug ) ); ?>', <?php echo esc_attr( $site_id ); ?> )"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a>
1398 <?php endif; ?>
1399 </div>
1400 <div class="two wide center aligned middle aligned column column-actions">
1401 <?php if ( ! $child_plugin ) : ?>
1402 <?php if ( $actived ) { ?>
1403 <?php if ( ! $plugin_mu && mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
1404 <a href="#" class="mainwp-manage-plugin-deactivate ui mini fluid button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Deactivate ', 'mainwp' ) . esc_html( $plugin_title ) . esc_attr_e( ' plugin on this child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></a>
1405 <?php } ?>
1406 <?php } else { ?>
1407 <div class="ui mini fluid buttons">
1408 <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
1409 <a href="#" class="mainwp-manage-plugin-activate ui green button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Activate ', 'mainwp' ) . esc_html( wp_strip_all_tags( $plugin_title ) ) . esc_attr_e( ' plugin on this child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Activate', 'mainwp' ); ?></a>
1410 <?php } ?>
1411 <?php if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) { ?>
1412 <a href="#" class="mainwp-manage-plugin-delete ui button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Delete ', 'mainwp' ) . ' ' . esc_html( wp_strip_all_tags( $plugin_title ) ) . ' ' . esc_attr_e( 'plugin from this child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Delete', 'mainwp' ); ?></a>
1413 <?php } ?>
1414 </div>
1415 <?php } ?>
1416 <?php endif; ?>
1417 </div>
1418 </div>
1419 <?php
1420
1421 }
1422 endforeach;
1423 ?>
1424 </div>
1425 </div>
1426 <?php endforeach; ?>
1427 </div>
1428
1429 <script type="text/javascript">
1430 jQuery( '.mainwp-manage-plugin-accordion' ).accordion( {
1431 "selector": {
1432 "trigger" : '.dropdown-trigger',
1433 }
1434 } );
1435
1436 jQuery( '.trigger-all-accordion' ).on( 'click', function() { // not use document here.
1437 if ( jQuery( this ).hasClass( 'active' ) ) {
1438 jQuery( this ).removeClass( 'active' );
1439 jQuery( '.mainwp-manage-plugins-wrapper .ui.accordion div.title' ).each( function( i ) {
1440 if ( jQuery( this ).hasClass( 'active' ) ) {
1441 jQuery( this ).find('.dropdown-trigger').trigger( 'click' );
1442 }
1443 } );
1444 } else {
1445 jQuery( this ).addClass( 'active' );
1446 jQuery( '.mainwp-manage-plugins-wrapper .ui.accordion div.title' ).each( function( i ) {
1447 if ( !jQuery( this ).hasClass( 'active' ) ) {
1448 jQuery( this ).find('.dropdown-trigger').trigger( 'click' );
1449 }
1450 } );
1451 }
1452 return false;
1453 } );
1454
1455 jQuery(document).ready(function ($) {
1456 mainwp_master_checkbox_init($);
1457 mainwp_get_icon_start();
1458 mainwp_show_hide_install_to_selected_sites( 'plugin' );
1459 } );
1460
1461 </script>
1462
1463 <?php
1464 /**
1465 * Action: mainwp_after_plugins_table
1466 *
1467 * Fires after the Plugins table.
1468 *
1469 * @since 4.1
1470 */
1471 do_action( 'mainwp_after_plugins_table' );
1472 }
1473
1474
1475
1476 /**
1477 * Method render_manage_table()
1478 *
1479 * Render Manage Plugins Table.
1480 *
1481 * @param array $sites Child Sites array.
1482 * @param array $pluginsSlug Plugins slug array.
1483 * @param array $sitePlugins Site plugins array.
1484 * @param array $pluginsMainWP MainWP plugins array.
1485 * @param array $muPlugins Must use plugins array.
1486 * @param array $pluginsName Plugin names array.
1487 * @param array $pluginsNameSites Plugin names with Sites array.
1488 * @param array $pluginsRealVersion Latest plugin release version.
1489 */
1490 public static function render_manage_table( $sites, $pluginsSlug, $sitePlugins, $pluginsMainWP, $muPlugins, $pluginsName, $pluginsNameSites, $pluginsRealVersion ) { //phpcs:ignore -- complex method.
1491
1492 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
1493 $decodedIgnoredPlugins = json_decode( $userExtension->ignored_plugins, true );
1494 $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
1495 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1496
1497 if ( ! is_array( $trustedPlugins ) ) {
1498 $trustedPlugins = array();
1499 }
1500
1501 $updateWebsites = array();
1502
1503 foreach ( $sites as $site_id => $info ) {
1504
1505 $plugin_upgrades = array();
1506 $website = MainWP_DB::instance()->get_website_by_id( $site_id );
1507 if ( $website ) {
1508 if ( ! $website->is_ignorePluginUpdates ) {
1509 $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
1510 if ( ! is_array( $plugin_upgrades ) ) {
1511 $plugin_upgrades = array();
1512 }
1513 $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
1514 $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
1515 if ( is_array( $decodedPremiumUpgrades ) ) {
1516 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
1517 $premiumUpgrade['premium'] = true;
1518 if ( 'plugin' === $premiumUpgrade['type'] ) {
1519 $premiumUpgrade = array_filter( $premiumUpgrade );
1520
1521 if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
1522 $plugin_upgrades[ $crrSlug ] = array();
1523 }
1524 $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
1525 }
1526 }
1527 }
1528 $ignored_plugins = json_decode( $website->ignored_plugins, true );
1529 if ( is_array( $ignored_plugins ) ) {
1530 $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
1531 }
1532
1533 if ( is_array( $decodedIgnoredPlugins ) ) {
1534 $plugin_upgrades = array_diff_key( $plugin_upgrades, $decodedIgnoredPlugins );
1535 }
1536 }
1537 }
1538 $updateWebsites[ $site_id ] = $plugin_upgrades;
1539 }
1540
1541 /**
1542 * Action: mainwp_before_plugins_table
1543 *
1544 * Fires before the Plugins table.
1545 *
1546 * @since 4.1
1547 */
1548 do_action( 'mainwp_before_plugins_table' );
1549 ?>
1550 <div class="ui secondary segment main-master-checkbox">
1551 <div class="ui stackable grid">
1552 <div class="one wide center aligned middle aligned column">
1553 <span class="trigger-all-accordion"><span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span></span>
1554 </div>
1555 <div class="one wide center aligned middle aligned column"><div class="ui checkbox main-master not-auto-init"><input type="checkbox"/><label></label></div></div>
1556 <div class="one wide center aligned middle aligned column"></div>
1557 <div class="five wide middle aligned column"><?php esc_html_e( 'Plugin', 'mainwp' ); ?></div>
1558 <div class="two wide center aligned middle aligned column"></div>
1559 <div class="two wide center aligned middle aligned column"><?php esc_html_e( 'Latest Version', 'mainwp' ); ?></div>
1560 <div class="two wide center aligned middle aligned column"></div>
1561 <div class="two wide center aligned middle aligned column"><?php esc_html_e( 'Websites', 'mainwp' ); ?></div>
1562 </div>
1563 </div>
1564
1565 <div class="mainwp-manage-plugins-wrapper main-child-checkbox">
1566 <?php foreach ( $pluginsNameSites as $plugin_title => $pluginSites ) : ?>
1567 <?php
1568 $slugVersions = current( $pluginSites );
1569 $slug_ver_first = $slugVersions[0]; // get the first one [slug]_[version] to get plugin [slug].
1570 $plugin_slug_first = $pluginsSlug[ $slug_ver_first ];
1571 $plugin_directory = MainWP_Utility::get_dir_slug( $plugin_slug_first );
1572
1573 $plugin_status = '';
1574
1575 $item_id = strtolower( $plugin_title );
1576 $item_id = preg_replace( '/[[:space:]]+/', '_', $item_id );
1577
1578 $count_sites = count( $pluginSites );
1579
1580 reset( $pluginSites );
1581 $first_siteid = key( $pluginSites );
1582
1583 $details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $first_siteid ) . '&plugin=' . rawurlencode( $plugin_directory ) . '&section=changelog' );
1584 $lastest_version = '';
1585 // phpcs:disable WordPress.Security.EscapeOutput
1586 ?>
1587 <div class="ui accordion mainwp-manage-plugin-accordion mainwp-manage-plugin-item main-child-checkbox" id="<?php echo esc_html( $item_id ); ?>">
1588 <div class="title master-checkbox">
1589 <div class="ui grid">
1590 <div class="one wide center aligned middle aligned column"><i class="dropdown icon dropdown-trigger"></i></div>
1591 <div class="one wide center aligned middle aligned column">
1592 <div class="ui checkbox <?php echo 'mainwp-child' === $plugin_directory ? 'disabled' : ''; ?> master"><input type="checkbox" <?php echo 'mainwp-child' === $plugin_directory ? 'disabled="disabled"' : ''; ?>><label></label></div>
1593 </div>
1594 <div class="one wide center aligned middle aligned column"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?></div>
1595 <div class="five wide middle aligned column"><a class="open-plugin-details-modal" href="<?php echo esc_url( $details_link ); ?>" target="_blank" ><strong><?php echo esc_html( $plugin_title ); ?></strong></a></div>
1596 <div class="two wide center aligned middle aligned column"></div>
1597 <div class="two wide center aligned middle aligned column lastest-version-info"></div>
1598 <div class="two wide center aligned middle aligned column"></div>
1599 <div class="two wide center aligned middle aligned column"><div class="ui label"><i class="icon wordpress"></i> <?php echo intval( $count_sites ); // phpcs:ignore -- Prevent modify WP icon. ?></div></div>
1600 </div>
1601 </div>
1602 <div class="content child-checkbox">
1603 <?php
1604 // phpcs:enable
1605 foreach ( $pluginSites as $site_id => $slugVersions ) :
1606 $site_name = $sites[ $site_id ]['websitename'];
1607
1608 foreach ( $slugVersions as $slug_ver ) :
1609
1610 $plugin_slug = $pluginsSlug[ $slug_ver ];
1611 $trusted = in_array( $plugin_slug, $trustedPlugins ) ? true : false;
1612 $child_plugin = ( isset( $pluginsMainWP[ $slug_ver ] ) && 'T' === $pluginsMainWP[ $slug_ver ] ) ? true : false;
1613
1614 $plugin_mu = false;
1615
1616 $plugin_version = $sitePlugins[ $site_id ][ $slug_ver ]['version'];
1617
1618 $plugin_upgrades = isset( $updateWebsites[ $site_id ] ) ? $updateWebsites[ $site_id ] : array();
1619 if ( ! is_array( $plugin_upgrades ) ) {
1620 $plugin_upgrades = array();
1621 }
1622
1623 $upgradeInfo = isset( $plugin_upgrades[ $plugin_slug ] ) ? $plugin_upgrades[ $plugin_slug ] : false;
1624
1625 $new_version = '';
1626 if ( ! empty( $upgradeInfo ) && isset( $upgradeInfo['update']['new_version'] ) ) {
1627 $new_version = $upgradeInfo['update']['new_version'];
1628 }
1629
1630 if ( '' === $lastest_version ) {
1631 $lastest_version = $plugin_version;
1632 } elseif ( version_compare( $plugin_version, $lastest_version, '>' ) ) {
1633 $lastest_version = $plugin_version;
1634 }
1635
1636 if ( '' !== $new_version ) {
1637 if ( version_compare( $new_version, $lastest_version, '>' ) ) {
1638 $lastest_version = $new_version;
1639 }
1640 }
1641
1642 if ( isset( $sitePlugins[ $site_id ][ $slug_ver ] ) && ( 0 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] || 1 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) ) {
1643 $actived = true;
1644 if ( isset( $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) && 1 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) {
1645 $plugin_status = '<span class="ui small green basic label">' . esc_html__( 'Active', 'mainwp' ) . '</span>';
1646 } elseif ( isset( $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) && 0 === (int) $sitePlugins[ $site_id ][ $slug_ver ]['active'] ) {
1647 $plugin_status = '<span class="ui small red basic label">' . esc_html__( 'Inactive', 'mainwp' ) . '</span>';
1648 $actived = false;
1649 } else {
1650 $plugin_status = '';
1651 }
1652
1653 if ( isset( $sitePlugins[ $site_id ][ $slug_ver ] ) && ( 1 === (int) $muPlugins[ $slug_ver ] ) ) {
1654 $plugin_mu = true;
1655 }
1656 if ( $plugin_mu ) {
1657 $actived = true; // always.
1658 }
1659 $item_id = $slug_ver . '_' . $site_id;
1660 $item_id = strtolower( $item_id );
1661 $item_id = preg_replace( '/[[:space:]]+/', '_', $item_id );
1662
1663 ?>
1664 <div class="ui stackable grid very compact mainwp-manage-plugin-item-website" plugin-slug="<?php echo esc_attr( rawurlencode( $plugin_slug ) ); ?>" plugin-name="<?php echo esc_html( wp_strip_all_tags( $pluginsName[ $slug_ver ] ) ); ?>" site-id="<?php echo intval( $site_id ); ?>" site-name="<?php echo esc_html( $site_name ); ?>" id="<?php echo esc_html( $item_id ); ?>">
1665 <div class="one wide center aligned middle aligned column"></div>
1666 <div class="one wide center aligned middle aligned column">
1667 <?php if ( $child_plugin ) { ?>
1668 <div class="ui disabled checkbox"><input type="checkbox" disabled="disabled"><label></label></div>
1669 <?php } else { ?>
1670 <div class="ui checkbox child">
1671 <input type="checkbox" class="mainwp-selected-plugin-site" />
1672 <label></label>
1673 </div>
1674 <?php
1675 }
1676 ?>
1677 </div>
1678 <div class="three wide middle aligned column"><a target="_blank" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo intval( $site_id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>"><i class="sign in icon"></i></a> <a href="admin.php?page=managesites&dashboard=<?php echo intval( $site_id ); ?>"><?php echo esc_html( $site_name ); ?></a></div>
1679 <div class="one wide middle aligned column"></div>
1680 <div class="one wide center aligned middle aligned column"><?php echo $plugin_status; //phpcs:ignore -- escaped. ?></div>
1681 <div class="two wide center aligned middle aligned column"><?php echo $trusted ? '<span class="ui tiny basic green label">' . esc_html__( 'Trusted', 'mainwp' ) . '</span>' : '<span class="ui tiny basic grey label">' . esc_html__( 'Not Trusted', 'mainwp' ) . '</span>'; ?></div>
1682
1683
1684 <div class="one wide center aligned middle aligned column"><?php echo $plugin_mu ? '<span class="ui small label"><i class="exclamation yellow triangle icon"></i> Must Use</span>' : ''; ?></div>
1685
1686 <div class="two wide center aligned middle aligned column current-version">
1687 <?php echo esc_html( $plugin_version ); ?>
1688 <?php if ( ! empty( $new_version ) ) : ?>
1689 &rarr; <?php echo esc_html( $new_version ); ?>
1690 <?php endif; ?>
1691 </div>
1692 <div class="two wide right aligned middle aligned column update-column" updated="0">
1693 <?php if ( ! empty( $upgradeInfo ) && MainWP_Updates::user_can_update_plugins() ) : ?>
1694 <a href="javascript:void(0)" class="ui mini green basic button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Update ', 'mainwp' ) . esc_html( $plugin_title ) . esc_attr_e( ' plugin on this child site.', 'mainwp' ); ?>" data-inverted="" onClick="return manage_plugins_upgrade( '<?php echo esc_js( rawurlencode( $plugin_slug ) ); ?>', <?php echo esc_attr( $site_id ); ?> )"><?php esc_html_e( 'Update Now', 'mainwp' ); ?></a>
1695 <?php endif; ?>
1696 </div>
1697 <div class="two wide center aligned middle aligned column column-actions">
1698 <?php if ( ! $child_plugin ) : ?>
1699 <?php if ( $actived ) { ?>
1700 <?php if ( ! $plugin_mu && mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
1701 <a href="#" class="mainwp-manage-plugin-deactivate ui mini fluid button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Deactivate ', 'mainwp' ) . esc_html( $plugin_title ) . esc_attr_e( ' plugin on this child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></a>
1702 <?php } ?>
1703 <?php } else { ?>
1704 <div class="ui mini fluid buttons">
1705 <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
1706 <a href="#" class="mainwp-manage-plugin-activate ui green button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Activate ', 'mainwp' ) . esc_html( wp_strip_all_tags( $plugin_title ) ) . esc_attr_e( ' plugin on this child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Activate', 'mainwp' ); ?></a>
1707 <?php } ?>
1708 <?php if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) { ?>
1709 <a href="#" class="mainwp-manage-plugin-delete ui button <?php echo $is_demo ? 'disabled' : ''; ?>" data-position="top right" data-tooltip="<?php esc_attr_e( 'Delete ', 'mainwp' ) . ' ' . esc_html( wp_strip_all_tags( $plugin_title ) ) . ' ' . esc_attr_e( 'plugin from this child site.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'Delete', 'mainwp' ); ?></a>
1710 <?php } ?>
1711 </div>
1712 <?php } ?>
1713 <?php endif; ?>
1714 </div>
1715 </div>
1716 <?php
1717
1718 }
1719 endforeach;
1720 ?>
1721 <span style="display:none" class="lastest-version-hidden" lastest-version="<?php echo esc_html( $lastest_version ); ?>"></span>
1722 <?php
1723 endforeach;
1724 ?>
1725 </div>
1726 </div>
1727 <?php endforeach; ?>
1728 </div>
1729
1730 <script type="text/javascript">
1731 jQuery( '.mainwp-manage-plugin-accordion' ).accordion( {
1732 "selector": {
1733 "trigger" : '.dropdown-trigger',
1734 }
1735 } );
1736
1737 jQuery( '.trigger-all-accordion' ).on( 'click', function() { // not use document here.
1738 if ( jQuery( this ).hasClass( 'active' ) ) {
1739 jQuery( this ).removeClass( 'active' );
1740 jQuery( '.mainwp-manage-plugins-wrapper .ui.accordion div.title' ).each( function( i ) {
1741 if ( jQuery( this ).hasClass( 'active' ) ) {
1742 jQuery( this ).find('.dropdown-trigger').trigger( 'click' );
1743 }
1744 } );
1745 } else {
1746 jQuery( this ).addClass( 'active' );
1747 jQuery( '.mainwp-manage-plugins-wrapper .ui.accordion div.title' ).each( function( i ) {
1748 if ( !jQuery( this ).hasClass( 'active' ) ) {
1749 jQuery( this ).find('.dropdown-trigger').trigger( 'click' );
1750 }
1751 } );
1752 }
1753 return false;
1754 } );
1755
1756
1757
1758 jQuery(document).ready(function ($) {
1759 $( '.lastest-version-hidden' ).each(function(){
1760 $(this).closest('.mainwp-manage-plugin-item').find('.lastest-version-info').html( $(this).attr('lastest-version') );
1761 });
1762 mainwp_master_checkbox_init($);
1763 mainwp_get_icon_start();
1764 mainwp_show_hide_install_to_selected_sites( 'plugin' );
1765 } );
1766
1767 </script>
1768
1769 <?php
1770 /**
1771 * Action: mainwp_after_plugins_table
1772 *
1773 * Fires after the Plugins table.
1774 *
1775 * @since 4.1
1776 */
1777 do_action( 'mainwp_after_plugins_table' );
1778 }
1779
1780
1781 /** Render Install Subpage. */
1782 public static function render_install() {
1783 self::render_header( 'Install' );
1784 self::render_plugins_table();
1785 self::render_footer( 'Install' );
1786 }
1787
1788
1789 /**
1790 * Render Install plugins Table.
1791 *
1792 * @uses \MainWP\Dashboard\MainWP_UI::render_modal_install_plugin_theme()
1793 *
1794 * @uses \MainWP\Dashboard\MainWP_Install_Bulk::render_upload()
1795 */
1796 public static function render_plugins_table() {
1797
1798 /**
1799 * Tab array.
1800 *
1801 * @global object
1802 */
1803 global $tab;
1804
1805 if ( ! mainwp_current_user_have_right( 'dashboard', 'install_plugins' ) ) {
1806 mainwp_do_not_have_permissions( esc_html__( 'install plugins', 'mainwp' ) );
1807 return;
1808 }
1809 ?>
1810
1811 <div class="ui alt segment" id="mainwp-install-plugins">
1812 <div class="mainwp-main-content">
1813 <div class="mainwp-actions-bar">
1814 <div class="ui stackable grid">
1815 <div class="ui two column row">
1816 <div class="column">
1817 <div id="mainwp-search-plugins-form" class="ui fluid search focus">
1818 <div class="ui icon fluid input">
1819 <input id="mainwp-search-plugins-form-field" class="fluid prompt" type="text" placeholder="<?php esc_attr_e( 'Search plugins...', 'mainwp' ); ?>" value="<?php echo isset( $_GET['s'] ) ? esc_html( sanitize_text_field( wp_unslash( $_GET['s'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>">
1820 <i class="search icon"></i>
1821 </div>
1822 <div class="results"></div>
1823 </div>
1824 <script type="text/javascript">
1825 jQuery( document ).ready(function () {
1826 jQuery( '#mainwp-search-plugins-form-field' ).on( 'keypress', function(e) {
1827 var search = jQuery( '#mainwp-search-plugins-form-field' ).val();
1828 var sel_ids = jQuery( '#plugin_install_selected_sites' ).val();
1829 if ( '' != sel_ids )
1830 sel_ids = '&selected_sites=' + sel_ids;
1831 var origin = '<?php echo esc_url( get_admin_url() ); ?>';
1832 if ( 13 === e.which ) {
1833 location.href = origin + 'admin.php?page=PluginsInstall&tab=search&s=' + encodeURIComponent(search) + sel_ids;
1834 }
1835 } );
1836 } );
1837 </script>
1838 <?php
1839 /**
1840 * Install Plugins actions bar (left)
1841 *
1842 * Fires at the left side of the actions bar on the Install Plugins screen, after the Search bar.
1843 *
1844 * @since 4.0
1845 */
1846 do_action( 'mainwp_install_plugins_actions_bar_left' );
1847 ?>
1848 </div>
1849 <div class="right aligned column">
1850 <div class="ui buttons">
1851 <a href="#" id="MainWPInstallBulkNavSearch" class="ui button" ><?php esc_html_e( 'Install from WordPress.org', 'mainwp' ); ?></a>
1852 <div class="or"></div>
1853 <a href="#" id="MainWPInstallBulkNavUpload" class="ui button" ><?php esc_html_e( 'Upload .zip file', 'mainwp' ); ?></a>
1854 </div>
1855 <?php
1856 /**
1857 * Install Plugins actions bar (right)
1858 *
1859 * Fires at the left side of the actions bar on the Install Plugins screen, after the Nav buttons.
1860 *
1861 * @since 4.0
1862 */
1863 do_action( 'mainwp_install_plugins_actions_bar_right' );
1864 ?>
1865 </div>
1866 </div>
1867 </div>
1868 </div>
1869 <div class="ui segment">
1870 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-install-plugins-info-message' ) ) : ?>
1871 <div class="ui info message">
1872 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-install-plugins-info-message"></i>
1873 <?php printf( esc_html__( 'Install plugins on your child sites. You can install plugins from the WordPress.org repository or by uploading a ZIP file. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/install-plugins/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
1874 </div>
1875 <?php endif; ?>
1876 <div id="mainwp-message-zone" class="ui message" style="display:none;"></div>
1877 <div class="mainwp-upload-plugin" style="display:none;">
1878 <?php MainWP_Install_Bulk::render_upload( 'plugin' ); ?>
1879 </div>
1880 <div class="mainwp-browse-plugins">
1881 <form id="plugin-filter" method="post">
1882 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1883 <?php self::$pluginsTable->display(); ?>
1884 </form>
1885 </div>
1886 <?php
1887 MainWP_UI::render_modal_install_plugin_theme();
1888 MainWP_Updates::render_plugin_details_modal();
1889 ?>
1890 </div>
1891 </div>
1892 <?php
1893 $selected_sites = array();
1894
1895 if ( isset( $_GET['selected_sites'] ) && ! empty( $_GET['selected_sites'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1896 $selected_sites = explode( '-', sanitize_text_field( wp_unslash( $_GET['selected_sites'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitize ok.
1897 $selected_sites = array_map( 'intval', $selected_sites );
1898 $selected_sites = array_filter( $selected_sites );
1899 }
1900 ?>
1901 <div class="mainwp-side-content mainwp-no-padding">
1902 <?php do_action( 'mainwp_manage_plugins_sidebar_top' ); ?>
1903 <div class="mainwp-select-sites ui accordion mainwp-sidebar-accordion">
1904 <?php do_action( 'mainwp_manage_plugins_before_select_sites' ); ?>
1905 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Sites', 'mainwp' ); ?></div>
1906 <div class="content active">
1907 <?php
1908 $sel_params = array(
1909 'class' => 'mainwp_select_sites_box_left',
1910 'selected_sites' => $selected_sites,
1911 'show_client' => true,
1912 );
1913 MainWP_UI_Select_Sites::select_sites_box( $sel_params );
1914 ?>
1915 </div>
1916 <?php do_action( 'mainwp_manage_plugins_after_select_sites' ); ?>
1917 </div>
1918 <input type="hidden" id="plugin_install_selected_sites" name="plugin_install_selected_sites" value="<?php echo esc_html( implode( '-', $selected_sites ) ); ?>" />
1919 <div class="ui fitted divider"></div>
1920 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
1921 <?php do_action( 'mainwp_manage_plugins_before_search_options' ); ?>
1922 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Installation Options', 'mainwp' ); ?></div>
1923 <div class="content active">
1924 <div class="ui form">
1925 <div class="field">
1926 <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the plugin will be automatically activated after the installation.', 'mainwp' ); ?>" data-position="left center" data-inverted="">
1927 <input type="checkbox" value="1" checked="checked" id="chk_activate_plugin" />
1928 <label for="chk_activate_plugin"><?php esc_html_e( 'Activate after installation', 'mainwp' ); ?></label>
1929 </div>
1930 </div>
1931 <div class="field">
1932 <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled and the plugin already installed on the sites, the already installed version will be overwritten.', 'mainwp' ); ?>" data-position="left center" data-inverted="">
1933 <input type="checkbox" value="2" checked="checked" id="chk_overwrite" />
1934 <label for="chk_overwrite"><?php esc_html_e( 'Overwrite existing version', 'mainwp' ); ?></label>
1935 </div>
1936 </div>
1937 </div>
1938 </div>
1939 <?php do_action( 'mainwp_manage_plugins_after_search_options' ); ?>
1940 </div>
1941 <div class="ui fitted divider"></div>
1942 <div class="mainwp-search-submit">
1943 <?php do_action( 'mainwp_manage_plugins_before_submit_button' ); ?>
1944 <?php
1945 /**
1946 * Disables plugin installation
1947 *
1948 * Filters whether file modifications are allowed on the Dashboard site. If not, installation process will be disabled too.
1949 *
1950 * @since 4.1
1951 */
1952 $allow_install = apply_filters( 'file_mod_allowed', true, 'mainwp_install_plugin' );
1953 if ( $allow_install ) {
1954 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1955 if ( $is_demo ) {
1956 MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<input type="button" disabled="disabled" class="ui green big fluid button disabled" value="' . esc_html__( 'Complete Installation', 'mainwp' ) . '">' );
1957 } else {
1958 ?>
1959 <input type="button" value="<?php esc_attr_e( 'Complete Installation', 'mainwp' ); ?>" class="ui green big fluid button" id="mainwp_plugin_bulk_install_btn" bulk-action="install" name="bulk-install">
1960 <?php
1961 }
1962 }
1963 ?>
1964 <?php do_action( 'mainwp_manage_plugins_before_submit_button' ); ?>
1965 </div>
1966 <?php do_action( 'mainwp_manage_plugins_sidebar_bottom', 'install' ); ?>
1967 </div>
1968 <div class="ui clearing hidden divider"></div>
1969 </div>
1970 <?php
1971 }
1972
1973 /**
1974 * Render Autoupdate SubPage.
1975 *
1976 * @uses \MainWP\Dashboard\MainWP_UI::render_modal_edit_notes()
1977 */
1978 public static function render_auto_update() { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1979
1980 $cachedAUSearch = isset( $_SESSION['MainWP_PluginsActiveStatus'] ) ? $_SESSION['MainWP_PluginsActiveStatus'] : null; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized --- ok.
1981
1982 self::render_header( 'AutoUpdate' );
1983
1984 if ( ! mainwp_current_user_have_right( 'dashboard', 'trust_untrust_updates' ) ) {
1985 mainwp_do_not_have_permissions( esc_html__( 'trust/untrust updates', 'mainwp' ) );
1986 } else {
1987 $snPluginAutomaticDailyUpdate = get_option( 'mainwp_pluginAutomaticDailyUpdate' );
1988
1989 if ( false === $snPluginAutomaticDailyUpdate ) {
1990 $snPluginAutomaticDailyUpdate = get_option( 'mainwp_automaticDailyUpdate' );
1991 update_option( 'mainwp_pluginAutomaticDailyUpdate', $snPluginAutomaticDailyUpdate );
1992 }
1993
1994 ?>
1995 <div class="ui alt segment" id="mainwp-plugin-auto-updates">
1996 <div class="mainwp-main-content">
1997 <div class="mainwp-actions-bar">
1998 <div class="ui mini form stackable grid">
1999 <div class="ui two column row">
2000 <div class="left aligned column">
2001 <select id="mainwp-bulk-actions" name="bulk_action" class="ui mini selection dropdown">
2002 <option class="item" value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
2003 <option class="item" value="trust"><?php esc_html_e( 'Trust', 'mainwp' ); ?></option>
2004 <option class="item" value="untrust"><?php esc_html_e( 'Untrust', 'mainwp' ); ?></option>
2005 <?php
2006 /**
2007 * Action: mainwp_plugins_auto_updates_bulk_action
2008 *
2009 * Adds new action to the bulk actions menu on Plugins Auto Updates.
2010 *
2011 * @since 4.1
2012 */
2013 do_action( 'mainwp_plugins_auto_updates_bulk_action' );
2014 ?>
2015 </select>
2016 <input type="button" name="" id="mainwp-bulk-trust-plugins-action-apply" class="ui mini basic button" value="<?php esc_attr_e( 'Apply', 'mainwp' ); ?>"/>
2017 </div>
2018 <div class="right aligned column"></div>
2019 </div>
2020 </div>
2021 </div>
2022
2023 <?php if ( isset( $_GET['message'] ) && 'saved' === $_GET['message'] ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
2024 <div class="ui message green"><?php esc_html_e( 'Settings have been saved.', 'mainwp' ); ?></div>
2025 <?php endif; ?>
2026 <div id="mainwp-message-zone" class="ui message" style="display:none"></div>
2027 <div id="mainwp-auto-updates-plugins-content" class="ui segment">
2028 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-disable-auto-updates-info-message' ) ) : ?>
2029 <div class="ui info message">
2030 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-disable-auto-updates-info-message"></i>
2031 <div><?php printf( esc_html__( 'Check out %1$show to disable the WordPress built in auto-updates feature%2$s.', 'mainwp' ), '<a href="https://mainwp.com/how-to-disable-automatic-plugin-and-theme-updates-on-your-child-sites/" target="_blank">', '</a>' ); ?></div>
2032 </div>
2033 <?php endif; ?>
2034 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-plugins-auto-updates-info-message' ) ) : ?>
2035 <div class="ui info message">
2036 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-plugins-auto-updates-info-message"></i>
2037 <div><?php esc_html_e( 'The MainWP Advanced Auto Updates feature is a tool for your Dashboard to automatically update plugins that you trust to be updated without breaking your Child sites.', 'mainwp' ); ?></div>
2038 <div><?php esc_html_e( 'Only mark plugins as trusted if you are absolutely sure they can be automatically updated by your MainWP Dashboard without causing issues on the Child sites!', 'mainwp' ); ?></div>
2039 <div><strong><?php esc_html_e( 'Advanced Auto Updates a delayed approximately 24 hours from the update release. Ignored plugins can not be automatically updated.', 'mainwp' ); ?></strong></div>
2040 </div>
2041 <?php endif; ?>
2042 <div class="ui inverted dimmer">
2043 <div class="ui text loader"><?php esc_html_e( 'Loading plugins', 'mainwp' ); ?></div>
2044 </div>
2045 <div id="mainwp-auto-updates-plugins-table-wrapper">
2046 <?php
2047 if ( isset( $_SESSION['MainWP_PluginsActive'] ) ) {
2048 self::render_all_active_table( $_SESSION['MainWP_PluginsActive'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2049 }
2050 ?>
2051 </div>
2052 </div>
2053 </div>
2054 <div class="mainwp-side-content mainwp-no-padding">
2055 <?php do_action( 'mainwp_manage_plugins_sidebar_top' ); ?>
2056 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
2057 <?php do_action( 'mainwp_manage_plugins_before_search_options' ); ?>
2058 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Plugin Status to Search', 'mainwp' ); ?></div>
2059 <div class="content active">
2060 <div class="ui mini form">
2061 <div class="field">
2062 <select class="ui fluid dropdown" id="mainwp_au_plugin_status">
2063 <option value="all" <?php echo ( null !== $cachedAUSearch && 'all' === $cachedAUSearch['plugin_status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Active and Inactive', 'mainwp' ); ?></option>
2064 <option value="active" <?php echo ( null !== $cachedAUSearch && 'active' === $cachedAUSearch['plugin_status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Active', 'mainwp' ); ?></option>
2065 <option value="inactive" <?php echo ( null !== $cachedAUSearch && 'inactive' === $cachedAUSearch['plugin_status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Inactive', 'mainwp' ); ?></option>
2066 </select>
2067 </div>
2068 </div>
2069 </div>
2070 <?php do_action( 'mainwp_manage_plugins_after_search_options' ); ?>
2071 </div>
2072 <div class="ui fitted divider"></div>
2073 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
2074 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Search Options', 'mainwp' ); ?></div>
2075 <div class="content active">
2076 <div class="ui mini form">
2077 <div class="field">
2078 <select class="ui fluid dropdown" id="mainwp_au_plugin_trust_status">
2079 <option value="all" <?php echo ( null !== $cachedAUSearch && 'all' === $cachedAUSearch['status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Trusted, Not trusted and Ignored', 'mainwp' ); ?></option>
2080 <option value="trust" <?php echo ( null !== $cachedAUSearch && 'trust' === $cachedAUSearch['status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Trusted', 'mainwp' ); ?></option>
2081 <option value="untrust" <?php echo ( null !== $cachedAUSearch && 'untrust' === $cachedAUSearch['status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Not trusted', 'mainwp' ); ?></option>
2082 <option value="ignored" <?php echo ( null !== $cachedAUSearch && 'ignored' === $cachedAUSearch['status'] ) ? 'selected' : ''; ?>><?php esc_html_e( 'Ignored', 'mainwp' ); ?></option>
2083 </select>
2084 </div>
2085 <div class="field">
2086 <div class="ui input fluid">
2087 <input type="text" placeholder="<?php esc_attr_e( 'Plugin name', 'mainwp' ); ?>" id="mainwp_au_plugin_keyword" class="text" value="<?php echo ( null !== $cachedAUSearch ) ? esc_attr( $cachedAUSearch['keyword'] ) : ''; ?>">
2088 </div>
2089 </div>
2090 </div>
2091 </div>
2092 </div>
2093 <div class="ui fitted divider"></div>
2094 <div class="mainwp-search-submit">
2095 <?php do_action( 'mainwp_manage_plugins_before_submit_button' ); ?>
2096 <a href="#" class="ui green big fluid button" id="mainwp_show_all_active_plugins"><?php esc_html_e( 'Show Plugins', 'mainwp' ); ?></a>
2097 <?php do_action( 'mainwp_manage_plugins_after_submit_button' ); ?>
2098 </div>
2099 <?php do_action( 'mainwp_manage_plugins_sidebar_bottom' ); ?>
2100 </div>
2101 </div>
2102 <?php
2103 MainWP_UI::render_modal_edit_notes( 'plugin' );
2104 }
2105 self::render_footer( 'AutoUpdate' );
2106 }
2107
2108 /**
2109 * Method render_all_active_table()
2110 *
2111 * Render all active Plugins table.
2112 *
2113 * @param null $output function output.
2114 *
2115 * @return void
2116 *
2117 * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed()
2118 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
2119 * @uses \MainWP\Dashboard\MainWP_DB::query()
2120 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
2121 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2122 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
2123 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::get_class_name()
2124 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
2125 * @uses \MainWP\Dashboard\MainWP_Utility::get_nice_url()
2126 */
2127 public static function render_all_active_table( $output = null ) { // phpcs:ignore -- not quite complex function.
2128 $keyword = null;
2129 $search_status = 'all';
2130
2131 $data_fields = MainWP_System_Utility::get_default_map_site_fields();
2132
2133 if ( null === $output ) {
2134 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2135 $keyword = isset( $_POST['keyword'] ) && ! empty( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : null;
2136 $search_status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : 'all';
2137 $search_plugin_status = isset( $_POST['plugin_status'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_status'] ) ) : 'all';
2138 // phpcs:enable
2139
2140 $output = new \stdClass();
2141 $output->errors = array();
2142 $output->plugins = array();
2143 $output->plugins_installed = array(); // to fix.
2144
2145 if ( 1 === (int) get_option( 'mainwp_optimize', 1 ) || MainWP_Demo_Handle::is_demo_mode() ) {
2146 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
2147 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2148 $allPlugins = json_decode( $website->plugins, true );
2149 $_count = count( $allPlugins );
2150 for ( $i = 0; $i < $_count; $i++ ) {
2151 $plugin = $allPlugins[ $i ];
2152 if ( 'all' !== $search_plugin_status ) {
2153 if ( 1 === (int) $plugin['active'] && 'active' !== $search_plugin_status ) {
2154 continue;
2155 } elseif ( 1 !== (int) $plugin['active'] && 'inactive' !== $search_plugin_status ) {
2156 continue;
2157 }
2158 }
2159 if ( ! empty( $keyword ) ) {
2160 $keyword = trim( $keyword );
2161 $multi_kws = explode( ',', $keyword );
2162 $multi_kws = array_filter( array_map( 'trim', $multi_kws ) );
2163 if ( ! MainWP_Utility::multi_find_keywords( $plugin['name'], $multi_kws ) ) {
2164 continue;
2165 }
2166 }
2167 $plugin['websiteid'] = $website->id;
2168 $plugin['websiteurl'] = $website->url;
2169 $output->plugins[] = $plugin;
2170 }
2171 }
2172 MainWP_DB::free_result( $websites );
2173 } else {
2174 $dbwebsites = array();
2175 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
2176 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2177 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
2178 continue;
2179 }
2180
2181 $dbwebsites[ $website->id ] = MainWP_Utility::map_site(
2182 $website,
2183 $data_fields
2184 );
2185 }
2186 MainWP_DB::free_result( $websites );
2187
2188 $post_data = array( 'keyword' => $keyword );
2189
2190 if ( 'active' === $search_plugin_status || 'inactive' === $search_plugin_status ) {
2191 $post_data['status'] = $search_plugin_status;
2192 $post_data['filter'] = true;
2193 } else {
2194 $post_data['status'] = '';
2195 $post_data['filter'] = false;
2196 }
2197 $output->status = $search_plugin_status;
2198 MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_plugins', $post_data, array( MainWP_Plugins_Handler::get_class_name(), 'plugins_search_handler' ), $output );
2199 // phpcs:disable WordPress.Security.EscapeOutput
2200 if ( 0 < count( $output->errors ) ) {
2201 foreach ( $output->errors as $siteid => $error ) {
2202 echo MainWP_Utility::get_nice_url( $dbwebsites[ $siteid ]->url ) . ' - ' . $error . ' <br/>';
2203
2204 }
2205 echo '<div class="ui hidden divider"></div>';
2206
2207 if ( count( $output->errors ) === count( $dbwebsites ) ) {
2208 $_SESSION['MainWP_PluginsActive'] = $output;
2209 $_SESSION['MainWP_PluginsActiveStatus'] = array(
2210 'keyword' => $keyword,
2211 'status' => $search_status,
2212 'plugin_status' => $search_plugin_status,
2213 );
2214 return;
2215 }
2216 }
2217 // phpcs:enable
2218 }
2219
2220 $_SESSION['MainWP_PluginsActive'] = $output;
2221 $_SESSION['MainWP_PluginsActiveStatus'] = array(
2222 'keyword' => $keyword,
2223 'status' => $search_status,
2224 'plugin_status' => $search_plugin_status,
2225 );
2226 } elseif ( isset( $_SESSION['MainWP_PluginsActiveStatus'] ) ) {
2227 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2228 $keyword = isset( $_SESSION['MainWP_PluginsActiveStatus']['keyword'] ) ? $_SESSION['MainWP_PluginsActiveStatus']['keyword'] : null;
2229 $search_status = isset( $_SESSION['MainWP_PluginsActiveStatus']['status'] ) ? $_SESSION['MainWP_PluginsActiveStatus']['status'] : null;
2230 $search_plugin_status = isset( $_SESSION['MainWP_PluginsActiveStatus']['plugin_status'] ) ? $_SESSION['MainWP_PluginsActiveStatus']['plugin_status'] : null;
2231 //phpcs:enable
2232 }
2233
2234 if ( 'inactive' !== $search_plugin_status ) {
2235 if ( empty( $keyword ) || ( ! empty( $keyword ) && false !== stristr( 'MainWP Child', $keyword ) ) ) {
2236 $output->plugins[] = array(
2237 'slug' => 'mainwp-child/mainwp-child.php',
2238 'name' => 'MainWP Child',
2239 'active' => 1,
2240 );
2241 }
2242 }
2243
2244 if ( 0 === count( $output->plugins ) ) {
2245 ?>
2246 <div class="ui message yellow"><?php esc_html_e( 'No plugins found.', 'mainwp' ); ?></div>
2247 <?php
2248 return;
2249 }
2250
2251 $plugins = array();
2252 foreach ( $output->plugins as $plugin ) {
2253 $plugins[ $plugin['slug'] ] = $plugin;
2254 }
2255 asort( $plugins );
2256
2257 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
2258 $decodedIgnoredPlugins = json_decode( $userExtension->ignored_plugins, true );
2259 $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
2260
2261 if ( ! is_array( $trustedPlugins ) ) {
2262 $trustedPlugins = array();
2263 }
2264 $trustedPluginsNotes = json_decode( $userExtension->trusted_plugins_notes, true );
2265 if ( ! is_array( $trustedPluginsNotes ) ) {
2266 $trustedPluginsNotes = array();
2267 }
2268 self::render_all_active_html( $plugins, $trustedPlugins, $search_status, $decodedIgnoredPlugins, $trustedPluginsNotes );
2269 MainWP_UI::render_modal_upload_icon();
2270 }
2271
2272
2273 /**
2274 * Method render_all_active_html()
2275 *
2276 * Render all active plugins html.
2277 *
2278 * @param array $plugins Plugins array.
2279 * @param array $trustedPlugins Trusted plugins array.
2280 * @param mixed $search_status trust|untrust|ignored.
2281 * @param array $decodedIgnoredPlugins Decoded ignored plugins array.
2282 * @param array $trustedPluginsNotes Trusted plugins notes.
2283 *
2284 * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
2285 */
2286 public static function render_all_active_html( $plugins, $trustedPlugins, $search_status, $decodedIgnoredPlugins, $trustedPluginsNotes ) {
2287
2288 /**
2289 * Action: mainwp_plugins_before_auto_updates_table
2290 *
2291 * Fires before the Auto Update Plugins table.
2292 *
2293 * @since 4.1
2294 */
2295 do_action( 'mainwp_plugins_before_auto_updates_table' );
2296 ?>
2297 <table class="ui unstackable table" id="mainwp-all-active-plugins-table">
2298 <thead>
2299 <tr>
2300 <th class="no-sort check-column collapsing"><span class="ui checkbox"><input id="cb-select-all-top" type="checkbox" /></span></th>
2301 <th class="no-sort"><?php esc_html_e( '', 'mainwp' ); ?></th>
2302 <th data-priority="1"><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
2303 <th><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
2304 <th class="collapsing" data-priority="2"><?php esc_html_e( 'Trust Status', 'mainwp' ); ?></th>
2305 <th><?php esc_html_e( 'Ignored Status', 'mainwp' ); ?></th>
2306 <th class="collapsing"></th>
2307 <th class="collapsing"><?php esc_html_e( 'Notes', 'mainwp' ); ?></th>
2308 </tr>
2309 </thead>
2310 <tbody>
2311 <?php foreach ( $plugins as $slug => $plugin ) : ?>
2312 <?php
2313 $name = $plugin['name'];
2314 $wpid = isset( $plugin['websiteid'] ) ? intval( $plugin['websiteid'] ) : 0;
2315
2316 if ( ! empty( $search_status ) && 'all' !== $search_status ) {
2317 if ( 'trust' === $search_status && ! in_array( $slug, $trustedPlugins ) ) {
2318 continue;
2319 } elseif ( 'untrust' === $search_status && in_array( $slug, $trustedPlugins ) ) {
2320 continue;
2321 } elseif ( 'ignored' === $search_status && ! isset( $decodedIgnoredPlugins[ $slug ] ) ) {
2322 continue;
2323 }
2324 }
2325 $esc_note = '';
2326 $strip_note = '';
2327 if ( isset( $trustedPluginsNotes[ $slug ] ) ) {
2328 $esc_note = MainWP_Utility::esc_content( $trustedPluginsNotes[ $slug ] );
2329 $strip_note = wp_strip_all_tags( $esc_note );
2330 }
2331
2332 $plugin_directory = dirname( $slug );
2333 ?>
2334 <?php // phpcs:disable WordPress.Security.EscapeOutput ?>
2335 <tr plugin-slug="<?php echo esc_attr( rawurlencode( $slug ) ); ?>" plugin-name="<?php echo esc_html( wp_strip_all_tags( $name ) ); ?>">
2336 <td class="check-column"><span class="ui checkbox"><input type="checkbox" name="plugin[]" value="<?php echo esc_attr( rawurlencode( $slug ) ); ?>"></span></td>
2337 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); ?></td>
2338 <td><a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $wpid ) . '&plugin=' . rawurlencode( dirname( $slug ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $name ); ?></a></td>
2339 <td><?php echo ( 1 === (int) $plugin['active'] ) ? esc_html__( 'Active', 'mainwp' ) : esc_html__( 'Inactive', 'mainwp' ); //phpcs:ignore -- escaped. ?></td>
2340 <td><?php echo ( in_array( $slug, $trustedPlugins ) ) ? '<span class="ui mini green fluid center aligned label">' . esc_html__( 'Trusted', 'mainwp' ) . '</span>' : '<span class="ui mini red fluid center aligned label">' . esc_html__( 'Not Trusted', 'mainwp' ) . '</span>'; ?></td>
2341 <td><?php echo ( isset( $decodedIgnoredPlugins[ $slug ] ) ) ? '<span class="ui mini label">' . esc_html__( 'Ignored', 'mainwp' ) . '</span>' : ''; ?></td>
2342 <td><?php echo ( isset( $decodedIgnoredPlugins[ $slug ] ) ) ? '<span data-tooltip="Ignored plugins will not be automatically updated." data-inverted=""><i class="info red circle icon" ></i></span>' : ''; ?></td>
2343 <td class="collapsing center aligned">
2344 <?php if ( '' === $esc_note ) : ?>
2345 <a href="javascript:void(0)" class="mainwp-edit-plugin-note" ><i class="sticky note outline icon"></i></a>
2346 <?php else : ?>
2347 <a href="javascript:void(0)" class="mainwp-edit-plugin-note" data-tooltip="<?php echo substr( $strip_note, 0, 100 ); //phpcs:ignore -- escaped. ?>" data-position="left center" data-inverted=""><i class="sticky green note icon"></i></a>
2348 <?php endif; ?>
2349 <span style="display: none" class="esc-content-note"><?php echo $esc_note; //phpcs:ignore -- escaped. ?></span>
2350 </td>
2351 </tr>
2352 <?php // phpcs:enable ?>
2353 <?php endforeach; ?>
2354 </tbody>
2355 <tfoot>
2356 <tr>
2357 <th class="no-sort check-column"><span class="ui checkbox"><input id="cb-select-all-bottom" type="checkbox" /></span></th>
2358 <th></th>
2359 <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
2360 <th><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
2361 <th><?php esc_html_e( 'Trust Status', 'mainwp' ); ?></th>
2362 <th><?php esc_html_e( 'Ignored Status', 'mainwp' ); ?></th>
2363 <th class="collapsing"></th>
2364 <th><?php esc_html_e( 'Notes', 'mainwp' ); ?></th>
2365 </tr>
2366 </tfoot>
2367 </table>
2368 <?php
2369 /**
2370 * Action: mainwp_plugins_after_auto_updates_table
2371 *
2372 * Fires after the Auto Update Plugins table.
2373 *
2374 * @since 4.1
2375 */
2376 do_action( 'mainwp_plugins_after_auto_updates_table' );
2377
2378 $table_features = array(
2379 'searching' => 'true',
2380 'stateSave' => 'true',
2381 'colReorder' => 'true',
2382 'info' => 'true',
2383 'paging' => 'false',
2384 'ordering' => 'true',
2385 'order' => '[ [ 2, "asc" ] ]',
2386 'responsive' => 'true',
2387 );
2388
2389 /**
2390 * Filter: mainwp_plugin_auto_updates_table_fatures
2391 *
2392 * Filters the Plugin Auto Updates table features.
2393 *
2394 * @since 4.1
2395 */
2396 $table_features = apply_filters( 'mainwp_plugin_auto_updates_table_fatures', $table_features );
2397 ?>
2398 <script type="text/javascript">
2399 var responsive = <?php echo esc_html( $table_features['responsive'] ); ?>;
2400 if( jQuery( window ).width() > 1140 ) {
2401 responsive = false;
2402 }
2403 jQuery( document ).ready( function() {
2404 jQuery( '#mainwp-all-active-plugins-table' ).DataTable( {
2405 "searching" : <?php echo esc_html( $table_features['searching'] ); ?>,
2406 "stateSave" : <?php echo esc_html( $table_features['stateSave'] ); ?>,
2407 "colReorder" : <?php echo esc_html( $table_features['colReorder'] ); ?>,
2408 "info" : <?php echo esc_html( $table_features['info'] ); ?>,
2409 "paging" : <?php echo esc_html( $table_features['paging'] ); ?>,
2410 "ordering" : <?php echo esc_html( $table_features['ordering'] ); ?>,
2411 "order" : <?php echo $table_features['order']; // phpcs:ignore -- specical chars. ?>,
2412 "columnDefs": [ { "orderable": false, "targets": [ 0, 1, 6 ] } ],
2413 "responsive": responsive,
2414 } );
2415 } );
2416 </script>
2417
2418 <script type="text/javascript">
2419 jQuery( document ).ready( function () {
2420 jQuery( '.mainwp-ui-page .ui.checkbox:not(.not-auto-init)' ).checkbox();
2421 } );
2422 </script>
2423 <?php
2424 }
2425
2426 /**
2427 * Render Ignore Subpage.
2428 *
2429 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
2430 * @uses \MainWP\Dashboard\MainWP_DB::query()
2431 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
2432 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2433 */
2434 public static function render_ignore() {
2435 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
2436 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
2437 $decodedIgnoredPlugins = json_decode( $userExtension->ignored_plugins, true );
2438 $ignoredPlugins = ( is_array( $decodedIgnoredPlugins ) && ( 0 < count( $decodedIgnoredPlugins ) ) );
2439
2440 $cnt = 0;
2441
2442 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2443 if ( $website->is_ignorePluginUpdates ) {
2444 continue;
2445 }
2446
2447 $tmpDecodedIgnoredPlugins = json_decode( $website->ignored_plugins, true );
2448
2449 if ( ! is_array( $tmpDecodedIgnoredPlugins ) || 0 === count( $tmpDecodedIgnoredPlugins ) ) {
2450 continue;
2451 }
2452 ++$cnt;
2453 }
2454
2455 self::render_header( 'Ignore' );
2456 ?>
2457 <div id="mainwp-ignored-plugins" class="ui segment">
2458 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-ignored-plugins-info-message' ) ) : ?>
2459 <div class="ui info message">
2460 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-ignored-plugins-info-message"></i>
2461 <?php printf( esc_html__( 'Manage plugins you have told your MainWP Dashboard to ignore updates on global or per site level. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
2462 </div>
2463 <?php endif; ?>
2464 <?php
2465 /**
2466 * Action: mainwp_plugins_before_ignored_updates
2467 *
2468 * Fires on the top of the Ignored Plugins Updates page.
2469 *
2470 * @since 4.1
2471 */
2472 do_action( 'mainwp_plugins_before_ignored_updates', $ignoredPlugins, $websites );
2473 ?>
2474 <h3 class="ui header">
2475 <?php esc_html_e( 'Globally Ignored Plugins', 'mainwp' ); ?>
2476 <div class="sub header"><?php esc_html_e( 'These are plugins you have told your MainWP Dashboard to ignore updates on global level and not notify you about pending updates.', 'mainwp' ); ?></div>
2477 </h3>
2478 <?php self::render_global_ignored( $ignoredPlugins, $decodedIgnoredPlugins ); ?>
2479 <div class="ui hidden divider"></div>
2480 <h3 class="ui header">
2481 <?php esc_html_e( 'Per Site Ignored Plugins' ); ?>
2482 <div class="sub header"><?php esc_html_e( 'These are plugins you have told your MainWP Dashboard to ignore updates per site level and not notify you about pending updates.', 'mainwp' ); ?></div>
2483 </h3>
2484 <?php self::render_sites_ignored( $cnt, $websites ); ?>
2485 <?php
2486 /**
2487 * Action: mainwp_plugins_after_ignored_updates
2488 *
2489 * Fires on the bottom of the Ignored Plugins Updates page.
2490 *
2491 * @since 4.1
2492 */
2493 do_action( 'mainwp_plugins_after_ignored_updates', $ignoredPlugins, $websites );
2494 ?>
2495 </div>
2496 <?php
2497 MainWP_Updates::render_plugin_details_modal();
2498 self::render_footer( 'Ignore' );
2499 }
2500
2501 /**
2502 * Method render_global_ignored()
2503 *
2504 * Render Global Ignored plugins list.
2505 *
2506 * @param array $ignoredPlugins Ignored plugins array.
2507 * @param array $decodedIgnoredPlugins Decoded ignored plugins array.
2508 */
2509 public static function render_global_ignored( $ignoredPlugins, $decodedIgnoredPlugins ) {
2510 ?>
2511 <table id="mainwp-globally-ignored-plugins" class="ui compact selectable table unstackable">
2512 <thead>
2513 <tr>
2514 <th class="no-sort"></th>
2515 <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
2516 <th><?php esc_html_e( 'Plugin slug', 'mainwp' ); ?></th>
2517 <th></th>
2518 </tr>
2519 </thead>
2520 <tbody id="globally-ignored-plugins-list">
2521 <?php if ( $ignoredPlugins ) : ?>
2522 <?php // phpcs:disable WordPress.Security.EscapeOutput ?>
2523 <?php foreach ( $decodedIgnoredPlugins as $ignoredPlugin => $ignoredPluginName ) : ?>
2524 <?php $plugin_directory = dirname( $ignoredPlugin ); ?>
2525 <tr plugin-slug="<?php echo esc_attr( rawurlencode( $ignoredPlugin ) ); ?>">
2526 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); ?></td>
2527 <td><a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&plugin=' . esc_html( rawurlencode( dirname( $ignoredPlugin ) ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $ignoredPluginName ); ?></a></td>
2528 <td><?php echo esc_html( $ignoredPlugin ); ?></td>
2529 <td class="right aligned">
2530 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2531 <a href="#" class="ui mini button" onClick="return updatesoverview_plugins_unignore_globally( '<?php echo esc_html( rawurlencode( $ignoredPlugin ) ); ?>' )"><?php esc_html_e( 'Unignore', 'mainwp' ); ?></a>
2532 <?php endif; ?>
2533 </td>
2534 </tr>
2535 <?php endforeach; ?>
2536 <?php // phpcs:enable ?>
2537 <?php endif; ?>
2538 </tbody>
2539 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2540 <?php if ( $ignoredPlugins ) : ?>
2541 <tfoot class="full-width">
2542 <tr>
2543 <th colspan="4">
2544 <a class="ui right floated small green labeled icon button" onClick="return updatesoverview_plugins_unignore_globally_all();" id="mainwp-unignore-globally-all">
2545 <i class="check icon"></i> <?php esc_html_e( 'Unignore All', 'mainwp' ); ?>
2546 </a>
2547 </th>
2548 </tr>
2549 </tfoot>
2550 <?php endif; ?>
2551 <?php endif; ?>
2552 </table>
2553 <script type="text/javascript">
2554 jQuery( document ).ready( function() {
2555 jQuery( '#mainwp-globally-ignored-plugins' ).DataTable( {
2556 "searching": false,
2557 "paging": false,
2558 "info": false,
2559 "responsive": true,
2560 "columnDefs": [ {
2561 "targets": 'no-sort',
2562 "orderable": false
2563 } ],
2564 "language": {
2565 "emptyTable": "<?php esc_html_e( 'No ignored plugins.', 'mainwp' ); ?>"
2566 }
2567 } );
2568 } );
2569 </script>
2570 <?php
2571 }
2572
2573 /**
2574 * Render Per Site Ignored table.
2575 *
2576 * @param mixed $cnt Plugin count.
2577 * @param mixed $websites Child Sites.
2578 *
2579 * @return void
2580 *
2581 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
2582 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2583 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
2584 */
2585 public static function render_sites_ignored( $cnt, $websites ) {
2586 ?>
2587 <table id="mainwp-per-site-ignored-plugins" class="ui unstackable compact selectable table ">
2588 <thead>
2589 <tr>
2590 <th><?php esc_html_e( 'Site', 'mainwp' ); ?></th>
2591 <th class="no-sort"><?php esc_html_e( '', 'mainwp' ); ?></th>
2592 <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
2593 <th><?php esc_html_e( 'Plugin slug', 'mainwp' ); ?></th>
2594 <th></th>
2595 </tr>
2596 </thead>
2597 <tbody id="ignored-plugins-list">
2598 <?php if ( 0 < $cnt ) : ?>
2599 <?php
2600 MainWP_DB::data_seek( $websites, 0 );
2601
2602 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2603 if ( $website->is_ignorePluginUpdates ) {
2604 continue;
2605 }
2606
2607 $decodedIgnoredPlugins = json_decode( $website->ignored_plugins, true );
2608 if ( ! is_array( $decodedIgnoredPlugins ) || 0 === count( $decodedIgnoredPlugins ) ) {
2609 continue;
2610 }
2611 $first = true;
2612 // phpcs:disable WordPress.Security.EscapeOutput
2613 foreach ( $decodedIgnoredPlugins as $ignoredPlugin => $ignoredPluginName ) {
2614 $plugin_directory = MainWP_Utility::get_dir_slug( rawurldecode( $ignoredPlugin ) );
2615 ?>
2616 <tr site-id="<?php echo intval( $website->id ); ?>" plugin-slug="<?php echo esc_attr( rawurlencode( $ignoredPlugin ) ); ?>">
2617 <?php if ( $first ) : ?>
2618 <td><div><a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a></div></td>
2619 <?php $first = false; ?>
2620 <?php else : ?>
2621 <td><div style="display:none;"><a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a></div></td>
2622 <?php endif; ?>
2623 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); ?></td>
2624 <td><a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( rawurlencode( $plugin_directory ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $ignoredPluginName ); ?></a></td>
2625 <td><?php echo esc_html( rawurldecode( $ignoredPlugin ) ); ?></td>
2626 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2627 <td class="right aligned"><a href="#" class="ui mini button" onClick="return updatesoverview_plugins_unignore_detail( '<?php echo esc_js( rawurlencode( $ignoredPlugin ) ); ?>', <?php echo intval( $website->id ); ?> )"> <?php esc_html_e( 'Unignore', 'mainwp' ); ?></a></td>
2628 <?php endif; ?>
2629 </tr>
2630 <?php
2631 }
2632 // phpcs:enable
2633 }
2634
2635 MainWP_DB::free_result( $websites );
2636 ?>
2637 <?php endif; ?>
2638 </tbody>
2639 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2640 <?php if ( 0 < $cnt ) : ?>
2641 <tfoot class="full-width">
2642 <tr>
2643 <th colspan="5">
2644 <a class="ui right floated small green labeled icon button" onClick="return updatesoverview_plugins_unignore_detail_all();" id="mainwp-unignore-detail-all">
2645 <i class="check icon"></i> <?php esc_html_e( 'Unignore All', 'mainwp' ); ?>
2646 </a>
2647 </th>
2648 </tr>
2649 </tfoot>
2650 <?php endif; ?>
2651 <?php endif; ?>
2652 </table>
2653 <script type="text/javascript">
2654 jQuery( document ).ready( function() {
2655 jQuery( '#mainwp-per-site-ignored-plugins' ).DataTable( {
2656 "responsive": true,
2657 "searching": false,
2658 "paging": false,
2659 "info": false,
2660 "columnDefs": [ {
2661 "targets": 'no-sort',
2662 "orderable": false
2663 } ],
2664 "language": {
2665 "emptyTable": "<?php esc_html_e( 'No ignored plugins', 'mainwp' ); ?>"
2666 }
2667 } );
2668 } );
2669 </script>
2670 <?php
2671 }
2672
2673 /**
2674 * Render Ignored Abandoned Page.
2675 *
2676 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
2677 * @uses \MainWP\Dashboard\MainWP_DB::query()
2678 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
2679 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
2680 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2681 */
2682 public static function render_ignored_abandoned() {
2683 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
2684 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
2685 $decodedIgnoredPlugins = json_decode( $userExtension->dismissed_plugins, true );
2686 $ignoredPlugins = ( is_array( $decodedIgnoredPlugins ) && ( 0 < count( $decodedIgnoredPlugins ) ) );
2687 $cnt = 0;
2688 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2689 $tmpDecodedDismissedPlugins = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
2690 $tmpDecodedDismissedPlugins = ! empty( $tmpDecodedDismissedPlugins ) ? json_decode( $tmpDecodedDismissedPlugins, true ) : array();
2691
2692 if ( ! is_array( $tmpDecodedDismissedPlugins ) || 0 === count( $tmpDecodedDismissedPlugins ) ) {
2693 continue;
2694 }
2695 ++$cnt;
2696 }
2697
2698 self::render_header( 'IgnoreAbandoned' );
2699 ?>
2700 <div id="mainwp-ignored-abandoned-plugins" class="ui segment">
2701 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-ignored-abandoned-plugins-info-message' ) ) : ?>
2702 <div class="ui info message">
2703 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-ignored-abandoned-plugins-info-message"></i>
2704 <?php printf( esc_html__( 'Manage abandoned plugins you have told your MainWP Dashboard to ignore on global or per site level. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/abandoned-plugins/" target="_blank">', '</a> <i class="external alternate icon"></i> ' ); ?>
2705 </div>
2706 <?php endif; ?>
2707 <?php
2708 /**
2709 * Action: mainwp_plugins_before_ignored_abandoned
2710 *
2711 * Fires on the top of the Ignored Plugins Abandoned page.
2712 *
2713 * @since 4.1
2714 */
2715 do_action( 'mainwp_plugins_before_ignored_abandoned', $ignoredPlugins, $websites );
2716 ?>
2717 <h3 class="ui header">
2718 <?php esc_html_e( 'Globally Ignored Abandoned Plugins' ); ?>
2719 <div class="sub header"><?php esc_html_e( 'These are plugins you have told your MainWP Dashboard to ignore on global level even though they have passed your Abandoned Plugin Tolerance date', 'mainwp' ); ?></div>
2720 </h3>
2721 <?php self::render_global_ignored_abandoned( $ignoredPlugins, $decodedIgnoredPlugins ); ?>
2722 <div class="ui hidden divider"></div>
2723 <h3 class="ui header">
2724 <?php esc_html_e( 'Per Site Ignored Abandoned Plugins' ); ?>
2725 <div class="sub header"><?php esc_html_e( 'These are plugins you have told your MainWP Dashboard to ignore per site level even though they have passed your Abandoned Plugin Tolerance date', 'mainwp' ); ?></div>
2726 </h3>
2727 <?php self::render_sites_ignored_abandoned( $cnt, $websites ); ?>
2728 <?php
2729 /**
2730 * Action: mainwp_plugins_after_ignored_abandoned
2731 *
2732 * Fires on the bottom of the Ignored Plugins Abandoned page.
2733 *
2734 * @since 4.1
2735 */
2736 do_action( 'mainwp_plugins_after_ignored_abandoned', $ignoredPlugins, $websites );
2737 ?>
2738 </div>
2739 <?php
2740 self::render_footer( 'IgnoreAbandoned' );
2741 }
2742
2743 /**
2744 * Method render_global_ignored_abandoned()
2745 *
2746 * Render Global Ignored Abandoned table.
2747 *
2748 * @param array $ignoredPlugins Ignored plugins array.
2749 * @param array $decodedIgnoredPlugins Decoded dgnored plugins array.
2750 */
2751 public static function render_global_ignored_abandoned( $ignoredPlugins, $decodedIgnoredPlugins ) {
2752 ?>
2753 <table id="mainwp-globally-ignored-abandoned-plugins" class="ui compact selectable table unstackable">
2754 <thead>
2755 <tr>
2756 <th class="no-sort"><?php esc_html_e( ' ', 'mainwp' ); ?></th>
2757 <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
2758 <th><?php esc_html_e( 'Plugin slug', 'mainwp' ); ?></th>
2759 <th></th>
2760 </tr>
2761 </thead>
2762 <tbody id="ignored-globally-abandoned-plugins-list">
2763 <?php if ( $ignoredPlugins ) : ?>
2764 <?php
2765 // phpcs:disable WordPress.Security.EscapeOutput
2766 foreach ( $decodedIgnoredPlugins as $ignoredPlugin => $ignoredPluginName ) :
2767 $plugin_directory = MainWP_Utility::get_dir_slug( rawurldecode( $ignoredPlugin ) );
2768 ?>
2769 <tr plugin-slug="<?php echo esc_attr( rawurlencode( $ignoredPlugin ) ); ?>">
2770 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); ?></td>
2771 <td><a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&plugin=' . esc_html( rawurlencode( $plugin_directory ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $ignoredPluginName ); ?></a></td>
2772 <td><?php echo esc_html( $ignoredPlugin ); ?></td>
2773 <td class="right aligned">
2774 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2775 <a href="#" class="ui mini button" onClick="return updatesoverview_plugins_abandoned_unignore_globally( '<?php echo esc_html( rawurlencode( $ignoredPlugin ) ); ?>' )"><?php esc_html_e( 'Unignore', 'mainwp' ); ?></a>
2776 <?php endif; ?>
2777 </td>
2778 </tr>
2779 <?php endforeach; ?>
2780 <?php // phpcs:enable ?>
2781 <?php endif; ?>
2782 </tbody>
2783 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2784 <?php if ( $ignoredPlugins ) : ?>
2785 <tfoot class="full-width">
2786 <tr>
2787 <th colspan="4">
2788 <a class="ui right floated small green labeled icon button" onClick="return updatesoverview_plugins_abandoned_unignore_globally_all();" id="mainwp-unignore-globally-all">
2789 <i class="check icon"></i> <?php esc_html_e( 'Unignore All', 'mainwp' ); ?>
2790 </a>
2791 </th>
2792 </tr>
2793 </tfoot>
2794 <?php endif; ?>
2795 <?php endif; ?>
2796 </table>
2797 <script type="text/javascript">
2798 jQuery( document ).ready( function() {
2799 jQuery( '#mainwp-globally-ignored-abandoned-plugins' ).DataTable( {
2800 "responsive": true,
2801 "searching": false,
2802 "paging": false,
2803 "info": false,
2804 "columnDefs": [ {
2805 "targets": 'no-sort',
2806 "orderable": false
2807 } ],
2808 "language": {
2809 "emptyTable": "<?php esc_html_e( 'No ignored abandoned plugins.', 'mainwp' ); ?>"
2810 }
2811 } );
2812 } );
2813 </script>
2814 <?php
2815 }
2816
2817 /**
2818 * Method render_sites_ignored_abandoned()
2819 *
2820 * Render Per Site Ignored Abandoned Table.
2821 *
2822 * @param int $cnt Plugins count.
2823 * @param object $websites The websites object.
2824 *
2825 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
2826 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2827 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
2828 */
2829 public static function render_sites_ignored_abandoned( $cnt, $websites ) {
2830 ?>
2831 <table id="mainwp-per-site-ignored-abandoned-plugins" class="ui compact selectable table unstackable">
2832 <thead>
2833 <tr>
2834 <th><?php esc_html_e( 'Site', 'mainwp' ); ?></th>
2835 <th class="no-sort"><?php esc_html_e( ' ', 'mainwp' ); ?></th>
2836 <th><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
2837 <th><?php esc_html_e( 'Plugin slug', 'mainwp' ); ?></th>
2838 <th></th>
2839 </tr>
2840 </thead>
2841 <tbody id="ignored-abandoned-plugins-list">
2842 <?php if ( 0 < $cnt ) : ?>
2843 <?php
2844 MainWP_DB::data_seek( $websites, 0 );
2845
2846 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2847 $decodedIgnoredPlugins = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
2848 $decodedIgnoredPlugins = ! empty( $decodedIgnoredPlugins ) ? json_decode( $decodedIgnoredPlugins, true ) : array();
2849
2850 if ( ! is_array( $decodedIgnoredPlugins ) || 0 === count( $decodedIgnoredPlugins ) ) {
2851 continue;
2852 }
2853 $first = true;
2854 // phpcs:disable WordPress.Security.EscapeOutput
2855 foreach ( $decodedIgnoredPlugins as $ignoredPlugin => $ignoredPluginName ) {
2856 $plugin_directory = MainWP_Utility::get_dir_slug( rawurldecode( $ignoredPlugin ) );
2857 ?>
2858 <tr site-id="<?php echo esc_attr( $website->id ); ?>" plugin-slug="<?php echo esc_attr( rawurlencode( $ignoredPlugin ) ); ?>">
2859 <?php if ( $first ) : ?>
2860 <td>
2861 <a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a>
2862 </td>
2863 <?php $first = false; ?>
2864 <?php else : ?>
2865 <td><div style="display:none;"><a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a></div></td>
2866 <?php endif; ?>
2867 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); ?></td>
2868 <td><a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( rawurlencode( $plugin_directory ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $ignoredPluginName ); ?></a></td>
2869 <td><?php echo esc_html( $ignoredPlugin ); ?></td>
2870 <td class="right aligned"><a href="#" class="ui mini button" onClick="return updatesoverview_plugins_unignore_abandoned_detail( '<?php echo esc_html( rawurlencode( $ignoredPlugin ) ); ?>', <?php echo intval( $website->id ); ?> )"> <?php esc_html_e( 'Unignore', 'mainwp' ); ?></a></td>
2871 </tr>
2872 <?php
2873 }
2874 // phpcs:enable
2875 }
2876 MainWP_DB::free_result( $websites );
2877 ?>
2878 <?php endif; ?>
2879 </tbody>
2880 <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) : ?>
2881 <?php if ( 0 < $cnt ) : ?>
2882 <tfoot class="full-width">
2883 <tr>
2884 <th colspan="5">
2885 <a class="ui right floated small green labeled icon button" onClick="return updatesoverview_plugins_unignore_abandoned_detail_all();" id="mainwp-unignore-detail-all">
2886 <i class="check icon"></i> <?php esc_html_e( 'Unignore All', 'mainwp' ); ?>
2887 </a>
2888 </th>
2889 </tr>
2890 </tfoot>
2891 <?php endif; ?>
2892 <?php endif; ?>
2893 </table>
2894 <script type="text/javascript">
2895 jQuery( document ).ready( function() {
2896 jQuery( '#mainwp-per-site-ignored-abandoned-plugins' ).DataTable( {
2897 "responsive": true,
2898 "searching": false,
2899 "paging": false,
2900 "info": false,
2901 "columnDefs": [ {
2902 "targets": 'no-sort',
2903 "orderable": false
2904 } ],
2905 "language": {
2906 "emptyTable": "<?php esc_html_e( 'No ignored abandoned plugins.', 'mainwp' ); ?>"
2907 }
2908 } );
2909 } );
2910 </script>
2911 <?php
2912 }
2913
2914 /**
2915 * Hooks the section help content to the Help Sidebar element.
2916 */
2917 public static function mainwp_help_content() {
2918 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2919 if ( isset( $_GET['page'] ) && ( 'PluginsManage' === $_GET['page'] || 'PluginsInstall' === $_GET['page'] || 'PluginsAutoUpdate' === $_GET['page'] || 'PluginsIgnore' === $_GET['page'] || 'PluginsIgnoredAbandoned' === $_GET['page'] ) ) {
2920 ?>
2921 <p><?php esc_html_e( 'If you need help with managing plugins, please review following help documents', 'mainwp' ); ?></p>
2922 <div class="ui relaxed bulleted list">
2923 <div class="item"><a href="https://kb.mainwp.com/docs/managing-plugins-with-mainwp/" target="_blank">Managing Plugins with MainWP</a> <i class="external alternate icon"></i></div>
2924 <div class="item"><a href="https://kb.mainwp.com/docs/install-plugins/" target="_blank">Install Plugins</a> <i class="external alternate icon"></i></div>
2925 <div class="item"><a href="https://kb.mainwp.com/docs/activate-plugins/" target="_blank">Activate Plugins</a> <i class="external alternate icon"></i></div>
2926 <div class="item"><a href="https://kb.mainwp.com/docs/delete-plugins/" target="_blank">Delete Plugins</a> <i class="external alternate icon"></i></div>
2927 <div class="item"><a href="https://kb.mainwp.com/docs/abandoned-plugins/" target="_blank">Abandoned Plugins</a> <i class="external alternate icon"></i></div>
2928 <div class="item"><a href="https://kb.mainwp.com/docs/update-plugins/" target="_blank">Update Plugins</a> <i class="external alternate icon"></i></div>
2929 <div class="item"><a href="https://kb.mainwp.com/docs/plugins-auto-updates/" target="_blank">Plugins Auto Updates</a> <i class="external alternate icon"></i></div>
2930 <div class="item"><a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">Ignore Plugin Updates</a> <i class="external alternate icon"></i></div>
2931 <?php
2932 /**
2933 * Action: mainwp_plugins_help_item
2934 *
2935 * Fires at the bottom of the help articles list in the Help sidebar on the Plugins page.
2936 *
2937 * Suggested HTML markup:
2938 *
2939 * <div class="item"><a href="Your custom URL">Your custom text</a></div>
2940 *
2941 * @since 4.1
2942 */
2943 do_action( 'mainwp_plugins_help_item' );
2944 ?>
2945 </div>
2946 <?php
2947 }
2948 // phpcs:enable
2949 }
2950 }
2951