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

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

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