PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.6.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.6.0.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
mainwp / pages / page-mainwp-plugins.php

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

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