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-themes.php

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

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