PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0
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, at pages/page-mainwp-plugins.php

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