' . esc_html__( 'Themes', 'mainwp' ) . '', 'read', 'ThemesManage', array( static::get_class_name(), 'render', ) ); add_submenu_page( 'mainwp_tab', __( 'Themes', 'mainwp' ), '
' . esc_html__( 'Install Themes', 'mainwp' ) . '
', 'read', 'ThemesInstall', array( static::get_class_name(), 'render_install', ) ); add_submenu_page( 'mainwp_tab', __( 'Themes', 'mainwp' ), '
' . esc_html__( 'Advanced Auto Updates', 'mainwp' ) . '
', 'read', 'ThemesAutoUpdate', array( static::get_class_name(), 'render_auto_update', ) ); add_submenu_page( 'mainwp_tab', __( 'Themes', 'mainwp' ), '
' . esc_html__( 'Ignored Updates', 'mainwp' ) . '
', 'read', 'ThemesIgnore', array( static::get_class_name(), 'render_ignore', ) ); add_submenu_page( 'mainwp_tab', __( 'Themes', 'mainwp' ), '
' . esc_html__( 'Abandoned Themes', 'mainwp' ) . '
', 'read', 'ThemesAbandoned', array( static::get_class_name(), 'render_abandoned_themes', ) ); add_submenu_page( 'mainwp_tab', __( 'Themes', 'mainwp' ), '
' . esc_html__( 'Ignored Abandoned', 'mainwp' ) . '
', 'read', 'ThemesIgnoredAbandoned', array( static::get_class_name(), 'render_ignored_abandoned', ) ); /** * Themes Subpages * * Filters subpages for the Themes page. * * @since Unknown */ $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. static::$subPages = apply_filters( 'mainwp_getsubpages_themes', $sub_pages ); if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { foreach ( static::$subPages as $subPage ) { if ( MainWP_Menu::is_disable_menu_item( 3, 'Themes' . $subPage['slug'] ) ) { continue; } add_submenu_page( 'mainwp_tab', $subPage['title'], '
' . $subPage['title'] . '
', 'read', 'Themes' . $subPage['slug'], $subPage['callback'] ); } } static::init_left_menu( static::$subPages ); } /** * Method init_subpages_menu() * * Themes Subpage Menu HTML Content. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() */ public static function init_subpages_menu() { ?> esc_html__( 'Themes', 'mainwp' ), 'parent_key' => 'managesites', 'slug' => 'ThemesManage', 'href' => 'admin.php?page=ThemesManage', 'icon' => '', 'leftsub_order' => 6, ), 1 ); $init_sub_subleftmenu = array( array( 'title' => esc_html__( 'Manage Themes', 'mainwp' ), 'parent_key' => 'ThemesManage', 'href' => 'admin.php?page=ThemesManage', 'slug' => 'ThemesManage', 'right' => '', 'leftsub_order_level2' => 1, ), array( 'title' => esc_html__( 'Install Themes', 'mainwp' ), 'parent_key' => 'ThemesManage', 'href' => 'admin.php?page=ThemesInstall', 'slug' => 'ThemesInstall', 'right' => 'install_themes', 'leftsub_order_level2' => 2, ), array( 'title' => esc_html__( 'Advanced Auto Updates', 'mainwp' ), 'parent_key' => 'ThemesManage', 'href' => 'admin.php?page=ThemesAutoUpdate', 'slug' => 'ThemesAutoUpdate', 'right' => '', 'leftsub_order_level2' => 3, ), array( 'title' => esc_html__( 'Ignored Updates', 'mainwp' ), 'parent_key' => 'ThemesManage', 'href' => 'admin.php?page=ThemesIgnore', 'slug' => 'ThemesIgnore', 'right' => '', 'leftsub_order_level2' => 4, ), array( 'title' => esc_html__( 'Abandoned Themes', 'mainwp' ), 'parent_key' => 'ThemesManage', 'href' => 'admin.php?page=ThemesAbandoned', 'slug' => 'ThemesAbandoned', 'right' => '', 'leftsub_order_level2' => 4.1, ), array( 'title' => esc_html__( 'Ignored Abandoned', 'mainwp' ), 'parent_key' => 'ThemesManage', 'href' => 'admin.php?page=ThemesIgnoredAbandoned', 'slug' => 'ThemesIgnoredAbandoned', 'right' => '', 'leftsub_order_level2' => 5, ), ); MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'ThemesManage', 'Themes' ); foreach ( $init_sub_subleftmenu as $item ) { if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { continue; } MainWP_Menu::add_left_menu( $item, 2 ); } } /** * Method render_header() * * Render Themes SubPage Header. * * @param string $shownPage The page slug shown at this moment. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation() */ public static function render_header( $shownPage = '' ) { // phpcs:ignore -- NOSONAR - complex. $params = array( 'title' => esc_html__( 'Themes', 'mainwp' ) ); MainWP_UI::render_top_header( $params ); $renderItems = array(); $renderItems[] = array( 'title' => esc_html__( 'Manage Themes', 'mainwp' ), 'href' => 'admin.php?page=ThemesManage', 'active' => ( 'Manage' === $shownPage ) ? true : false, ); if ( \mainwp_current_user_can( 'dashboard', 'install_themes' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Install', 'mainwp' ), 'href' => 'admin.php?page=ThemesInstall', 'active' => ( 'Install' === $shownPage ) ? true : false, ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ThemesAutoUpdate' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Advanced Auto Updates', 'mainwp' ), 'href' => 'admin.php?page=ThemesAutoUpdate', 'active' => ( 'AutoUpdate' === $shownPage ) ? true : false, ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ThemesIgnore' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Ignored Updates', 'mainwp' ), 'href' => 'admin.php?page=ThemesIgnore', 'active' => ( 'Ignore' === $shownPage ) ? true : false, ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ThemesAbandoned' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Abandoned Themes', 'mainwp' ), 'href' => 'admin.php?page=ThemesAbandoned', 'active' => ( 'Abandoned' === $shownPage ) ? true : false, ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ThemesIgnoredAbandoned' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Ignored Abandoned', 'mainwp' ), 'href' => 'admin.php?page=ThemesIgnoredAbandoned', 'active' => ( 'IgnoreAbandoned' === $shownPage ) ? true : false, ); } if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { foreach ( static::$subPages as $subPage ) { if ( MainWP_Menu::is_disable_menu_item( 3, 'Themes' . $subPage['slug'] ) ) { continue; } $item = array(); $item['title'] = $subPage['title']; $item['href'] = 'admin.php?page=Themes' . $subPage['slug']; $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false; $renderItems[] = $item; } } MainWP_UI::render_page_navigation( $renderItems ); } /** * Method render_footer() * * Close the page container. */ public static function render_footer() { echo ''; } /** * Method render() * * Render the Theme SubPage content. * * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_result() * @uses \MainWP\Dashboard\MainWP_UI::render_empty_bulk_actions() */ public static function render() { // phpcs:ignore -- NOSONAR - complex. $cachedSearch = MainWP_Cache::get_cached_context( 'Themes' ); $selected_sites = array(); $selected_groups = array(); $selected_clients = array(); if ( null !== $cachedSearch ) { if ( is_array( $cachedSearch['sites'] ) ) { $selected_sites = $cachedSearch['sites']; } elseif ( is_array( $cachedSearch['groups'] ) ) { $selected_groups = $cachedSearch['groups']; } elseif ( is_array( $cachedSearch['clients'] ) ) { $selected_clients = $cachedSearch['clients']; } } $cachedResult = MainWP_Cache::get_cached_result( 'Themes' ); if ( isset( $_POST['select_mainwp_options_plugintheme_view'] ) && check_admin_referer( 'mainwp-admin-nonce' ) && is_array( $cachedResult ) && isset( $cachedResult['result'] ) ) { unset( $cachedResult['result'] ); // clear cached results. } static::render_header( 'Manage' ); ?>

', ' ' ); ?>

>
'mainwp_select_sites_box_left', 'selected_sites' => $selected_sites, 'selected_groups' => $selected_groups, 'selected_clients' => $selected_clients, 'show_client' => true, ); MainWP_UI_Select_Sites::select_sites_box( $sel_params ); ?>
value="1" id="display_sites_not_meeting_criteria" />
errors = array(); $output->themes = array(); $output->themes_installed = array(); $output->status = $status; $output->roll_items = array(); $error_results = ''; $data_fields = MainWP_System_Utility::get_default_map_site_fields(); $data_fields[] = 'themes'; $data_fields[] = 'rollback_updates_data'; if ( 1 === (int) get_option( 'mainwp_optimize', 1 ) || MainWP_Demo_Handle::is_demo_mode() ) { $keyword = trim( $keyword ); $multi_kws = explode( ',', $keyword ); $multi_kws = array_filter( array_map( 'trim', $multi_kws ) ); if ( '' !== $sites ) { foreach ( $sites as $v ) { if ( MainWP_Utility::ctype_digit( $v ) ) { $website = MainWP_DB::instance()->get_website_by_id( $v, false, array( 'rollback_updates_data' ) ); $allThemes = json_decode( $website->themes, true ); $_count = count( $allThemes ); $_count_installed = 0; for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; $active_inactive = 'active' === $status || 'inactive' === $status; if ( $active_inactive && ( ( 1 === (int) $theme['active'] && 'active' !== $status ) || ( 1 !== $theme['active'] && 'inactive' !== $status ) ) ) { continue; } if ( ! empty( $keyword ) ) { if ( $not_criteria ) { if ( MainWP_Utility::multi_find_keywords( $theme['title'], $multi_kws ) ) { continue; } } elseif ( ! MainWP_Utility::multi_find_keywords( $theme['title'], $multi_kws ) ) { continue; } } $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $theme['websitename'] = $website->name; $output->themes[] = $theme; ++$_count_installed; } if ( 0 === $_count_installed && 'not_installed' === $status ) { for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $theme['websitename'] = $website->name; $output->themes_installed[] = $theme; } } $output->roll_items[ $website->id ] = MainWP_Updates_Helper::get_roll_update_plugintheme_items( 'theme', $website->rollback_updates_data ); } } } if ( '' !== $groups ) { foreach ( $groups as $v ) { if ( MainWP_Utility::ctype_digit( $v ) ) { $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' ) ) ) ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $allThemes = json_decode( $website->themes, true ); $_count = count( $allThemes ); $_count_installed = 0; for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; $act_inact = 'active' === $status || 'inactive' === $status; if ( $act_inact && ( ( 1 === (int) $theme['active'] && 'active' !== $status ) || ( 1 !== $theme['active'] && 'inactive' !== $status ) ) ) { continue; } if ( ! empty( $keyword ) ) { if ( $not_criteria ) { if ( MainWP_Utility::multi_find_keywords( $theme['title'], $multi_kws ) ) { continue; } } elseif ( ! MainWP_Utility::multi_find_keywords( $theme['title'], $multi_kws ) ) { continue; } } $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $theme['websitename'] = $website->name; $output->themes[] = $theme; ++$_count_installed; } if ( 0 === $_count_installed && 'not_installed' === $status ) { for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $theme['websitename'] = $website->name; $output->themes_installed[] = $theme; } } $output->roll_items[ $website->id ] = MainWP_Updates_Helper::get_roll_update_plugintheme_items( 'theme', $website->rollback_updates_data ); } MainWP_DB::free_result( $websites ); } } } if ( '' !== $clients && is_array( $clients ) ) { $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( $clients, array( 'select_data' => $data_fields, 'extra_view' => array( 'rollback_updates_data' ), ) ); if ( $websites ) { foreach ( $websites as $website ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $allThemes = json_decode( $website->themes, true ); $_count = count( $allThemes ); $_count_installed = 0; for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; $act_inacy = 'active' === $status || 'inactive' === $status; if ( $act_inacy && ( ( 1 === (int) $theme['active'] && 'active' !== $status ) || ( 1 !== $theme['active'] && 'inactive' !== $status ) ) ) { continue; } if ( ! empty( $keyword ) ) { if ( $not_criteria ) { if ( MainWP_Utility::multi_find_keywords( $theme['title'], $multi_kws ) ) { continue; } } elseif ( ! MainWP_Utility::multi_find_keywords( $theme['title'], $multi_kws ) ) { continue; } } $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $theme['websitename'] = $website->name; $output->themes[] = $theme; ++$_count_installed; } if ( 0 === $_count_installed && 'not_installed' === $status ) { for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $theme['websitename'] = $website->name; $output->themes_installed[] = $theme; } } $output->roll_items[ $website->id ] = MainWP_Updates_Helper::get_roll_update_plugintheme_items( 'theme', $website->rollback_updates_data ); } } } } else { $dbwebsites = array(); if ( '' !== $sites ) { foreach ( $sites as $v ) { if ( MainWP_Utility::ctype_digit( $v ) ) { $website = MainWP_DB::instance()->get_website_by_id( $v, false, array( 'rollback_updates_data' ) ); if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } } } if ( '' !== $groups ) { foreach ( $groups as $v ) { if ( MainWP_Utility::ctype_digit( $v ) ) { $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' ) ) ) ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } MainWP_DB::free_result( $websites ); } } } if ( '' !== $clients && is_array( $clients ) ) { $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( $clients, array( 'select_data' => $data_fields, 'extra_view' => array( 'rollback_updates_data' ), ) ); if ( $websites ) { foreach ( $websites as $website ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } } } $post_data = array( 'keyword' => $keyword, ); if ( 'active' === $status || 'inactive' === $status ) { $post_data['status'] = $status; $post_data['filter'] = true; } else { $post_data['status'] = ''; $post_data['filter'] = false; } if ( 'not_installed' === $status ) { $post_data['not_installed'] = true; } $post_data['not_criteria'] = $not_criteria ? true : false; MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_themes', $post_data, array( MainWP_Themes_Handler::get_class_name(), 'themes_search_handler' ), $output ); if ( ! empty( $output->errors ) ) { foreach ( $output->errors as $siteid => $error ) { $error_results .= MainWP_Utility::get_nice_url( $dbwebsites[ $siteid ]->url ) . ' - ' . $error . '
'; // phpcs:ignore WordPress.Security.EscapeOutput } } } MainWP_Cache::add_context( 'Themes', array( 'keyword' => $keyword, 'status' => $status, 'sites' => ( '' !== $sites ) ? $sites : '', 'groups' => ( '' !== $groups ) ? $groups : '', 'clients' => ( '' !== $clients ) ? $clients : '', 'not_criteria' => $not_criteria ? true : false, ) ); $view_mode = MainWP_Plugins::get_manage_view( 'theme' ); $bulkActions = static::render_bulk_actions( $status ); ob_start(); if ( ! empty( $error_results ) ) { // phpcs:disable WordPress.Security.EscapeOutput ?>
themes_installed ) ) { ?>
themes_installed; $roll_items_list = ! empty( $output->roll_items ) ? $output->roll_items : array(); $view_mode = MAINWP_VIEW_PER_SITE; } } elseif ( empty( $output->themes ) ) { ?>
themes; $roll_items_list = ! empty( $output->roll_items ) ? $output->roll_items : array(); } $sites = array(); $siteThemes = array(); $themesName = array(); $themesNameSites = array(); $themesRealVersion = array(); $themesSlug = array(); if ( ! is_array( $roll_items_list ) ) { $roll_items_list = array(); } if ( ! empty( $themes_list ) ) { foreach ( $themes_list as $theme ) { $slug_ver = esc_html( $theme['name'] . '_' . $theme['version'] ); $theme['name'] = esc_html( $theme['name'] ); $theme['version'] = esc_html( $theme['version'] ); $theme['title'] = esc_html( $theme['title'] ); $theme['slug'] = esc_html( $theme['slug'] ); $theme['active'] = ( 1 === (int) $theme['active'] ) ? 1 : 0; $theme['websiteurl'] = esc_url_raw( $theme['websiteurl'] ); $sites[ $theme['websiteid'] ] = array( 'websiteurl' => $theme['websiteurl'], 'websitename' => $theme['websitename'], ); $themesName[ $slug_ver ] = $theme['name']; $themesSlug[ $slug_ver ] = $theme['slug']; $themesNameSites[ $theme['name'] ][ $theme['websiteid'] ][] = $slug_ver; $themesRealVersion[ $slug_ver ] = $theme['version']; if ( ! isset( $siteThemes[ $theme['websiteid'] ] ) || ! is_array( $siteThemes[ $theme['websiteid'] ] ) ) { $siteThemes[ $theme['websiteid'] ] = array(); } $siteThemes[ $theme['websiteid'] ][ $slug_ver ] = $theme; } ksort( $themesNameSites, SORT_STRING ); if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $view_mode ) { static::render_manage_table( $sites, $themesName, $siteThemes, $themesSlug, $themesNameSites, $themesRealVersion, $roll_items_list ); } else { static::render_manage_per_site_table( $sites, $themesName, $siteThemes, $themesSlug, $themesNameSites, $themesRealVersion, $roll_items_list ); } MainWP_UI::render_modal_upload_icon(); } $newOutput = ob_get_clean(); $result = array( 'result' => $newOutput, 'bulk_actions' => $bulkActions, ); MainWP_Cache::add_result( 'Themes', $result ); return $result; } /** * Method render_manage_per_site_table() * * Render the Manage Themes table * * @param array $sites List of sites. * @param array $themesName List of themes. * @param array $siteThemes List of themes for the site. * @param array $themesSlug List of theme slugs. * @param array $themesNameSites Installed theme version. * @param string $themesRealVersion Current theme version. * @param array $roll_list roll items list. */ 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. $userExtension = MainWP_DB_Common::instance()->get_user_extension(); $decodedIgnoredThemes = json_decode( $userExtension->ignored_themes, true ); $trustedThemes = json_decode( $userExtension->trusted_themes, true ); $is_demo = MainWP_Demo_Handle::is_demo_mode(); if ( ! is_array( $trustedThemes ) ) { $trustedThemes = array(); } $updateWebsites = array(); foreach ( $sites as $site_id => $info ) { $theme_upgrades = array(); $website = MainWP_DB::instance()->get_website_by_id( $site_id ); if ( $website && ! $website->is_ignoreThemeUpdates ) { $theme_upgrades = json_decode( $website->theme_upgrades, true ); $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); if ( is_array( $decodedPremiumUpgrades ) ) { foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { $premiumUpgrade['premium'] = true; if ( 'theme' === $premiumUpgrade['type'] ) { if ( ! is_array( $theme_upgrades ) ) { $theme_upgrades = array(); } $premiumUpgrade = array_filter( $premiumUpgrade ); if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { $theme_upgrades[ $crrSlug ] = array(); } $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); } } } $ignored_themes = json_decode( $website->ignored_themes, true ); if ( is_array( $ignored_themes ) ) { $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); } if ( is_array( $decodedIgnoredThemes ) ) { $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $decodedIgnoredThemes ); } } $updateWebsites[ $site_id ] = $theme_upgrades; } /** * Action: mainwp_before_themes_table * * Fires before the Themes table. * * @since 4.1 */ do_action( 'mainwp_before_themes_table' ); ?>
$website ) : ?>
$theme ) : $theme_slug = $themesSlug[ $slug_ver ]; $theme_title = $theme['title']; $trusted = in_array( $theme_slug, $trustedThemes ) ? true : false; $theme_version = $siteThemes[ $site_id ][ $slug_ver ]['version']; $theme_upgrades = isset( $updateWebsites[ $site_id ] ) ? $updateWebsites[ $site_id ] : array(); if ( ! is_array( $theme_upgrades ) ) { $theme_upgrades = array(); } $upgradeInfo = isset( $theme_upgrades[ $theme_slug ] ) ? $theme_upgrades[ $theme_slug ] : false; $active_status_class = ''; if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) { $active_status_class = 'positive'; } elseif ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && empty( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) ) { $active_status_class = 'negative'; } else { $active_status_class = ''; } if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['child_active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['child_active'] ) { $active_status_class .= ' child-active'; } $not_delete = false; $parent_str = ''; if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['parent_active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['parent_active'] ) { $parent_str = ''; $not_delete = true; } $new_version = ''; if ( ! empty( $upgradeInfo ) && isset( $upgradeInfo['update']['new_version'] ) ) { $new_version = $upgradeInfo['update']['new_version']; } if ( isset( $siteThemes[ $site_id ][ $slug_ver ] ) && ( empty( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) || 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) ) { $actived = true; if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) { $theme_status = 'Active'; } elseif ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && empty( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) ) { $theme_status = 'Inactive'; $actived = false; } else { $theme_status = ''; } $item_id = $slug_ver . '_' . $site_id; $item_id = strtolower( $item_id ); $item_id = preg_replace( '/[[:space:]]+/', '_', $item_id ); $el_id_ite_id_1 = $item_id; ?>
' . esc_html__( 'Trusted', 'mainwp' ) . '' : '' . esc_html__( 'Not Trusted', 'mainwp' ) . ''; ?>
get_user_extension(); $decodedIgnoredThemes = json_decode( $userExtension->ignored_themes, true ); $trustedThemes = json_decode( $userExtension->trusted_themes, true ); $is_demo = MainWP_Demo_Handle::is_demo_mode(); if ( ! is_array( $trustedThemes ) ) { $trustedThemes = array(); } $updateWebsites = array(); foreach ( $sites as $site_id => $info ) { $theme_upgrades = array(); $website = MainWP_DB::instance()->get_website_by_id( $site_id ); if ( $website && ! $website->is_ignoreThemeUpdates ) { $theme_upgrades = json_decode( $website->theme_upgrades, true ); $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ); $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array(); if ( is_array( $decodedPremiumUpgrades ) ) { foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { $premiumUpgrade['premium'] = true; if ( 'theme' === $premiumUpgrade['type'] ) { if ( ! is_array( $theme_upgrades ) ) { $theme_upgrades = array(); } $premiumUpgrade = array_filter( $premiumUpgrade ); if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { $theme_upgrades[ $crrSlug ] = array(); } $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); } } } $ignored_themes = json_decode( $website->ignored_themes, true ); if ( is_array( $ignored_themes ) ) { $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); } if ( is_array( $decodedIgnoredThemes ) ) { $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $decodedIgnoredThemes ); } } $updateWebsites[ $site_id ] = $theme_upgrades; } /** * Action: mainwp_before_themes_table * * Fires before the Themes table. * * @since 4.1 */ do_action( 'mainwp_before_themes_table' ); ?>
$themeSites ) : ?>
$slugVersions ) : $site_name = $sites[ $site_id ]['websitename']; foreach ( $slugVersions as $slug_ver ) : $theme_slug = $themesSlug[ $slug_ver ]; $trusted = in_array( $theme_slug, $trustedThemes ) ? true : false; $theme_version = $siteThemes[ $site_id ][ $slug_ver ]['version']; $theme_upgrades = isset( $updateWebsites[ $site_id ] ) ? $updateWebsites[ $site_id ] : array(); if ( ! is_array( $theme_upgrades ) ) { $theme_upgrades = array(); } $upgradeInfo = isset( $theme_upgrades[ $theme_slug ] ) ? $theme_upgrades[ $theme_slug ] : false; $active_status_class = ''; if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) { $active_status_class = 'positive'; } elseif ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && 0 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) { $active_status_class = 'negative'; } else { $active_status_class = ''; } if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['child_active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['child_active'] ) { $active_status_class .= ' child-active'; } $not_delete = false; $parent_str = ''; if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['parent_active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['parent_active'] ) { $parent_str = ''; $not_delete = true; } $new_version = ''; if ( ! empty( $upgradeInfo ) && isset( $upgradeInfo['update']['new_version'] ) ) { $new_version = $upgradeInfo['update']['new_version']; } if ( '' === $lastest_version || version_compare( $theme_version, $lastest_version, '>' ) ) { $lastest_version = $theme_version; } if ( '' !== $new_version && version_compare( $new_version, $lastest_version, '>' ) ) { $lastest_version = $new_version; } if ( isset( $siteThemes[ $site_id ][ $slug_ver ] ) && ( 0 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] || 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) ) { $actived = true; if ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && 1 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) { $theme_status = 'Active'; } elseif ( isset( $siteThemes[ $site_id ][ $slug_ver ]['active'] ) && 0 === (int) $siteThemes[ $site_id ][ $slug_ver ]['active'] ) { $theme_status = 'Inactive'; $actived = false; } else { $theme_status = ''; } $item_id = $slug_ver . '_' . $site_id; $item_id = strtolower( $item_id ); $item_id = preg_replace( '/[[:space:]]+/', '_', $item_id ); $el_id_ite_id_2 = $item_id; ?>
' . esc_html__( 'Trusted', 'mainwp' ) . '' : '' . esc_html__( 'Not Trusted', 'mainwp' ) . ''; ?>
false, 'settings' => array( 'isInstall' => true, 'canInstall' => false, 'installURI' => null, 'adminUrl' => wp_parse_url( self_admin_url(), PHP_URL_PATH ), ), 'l10n' => array( 'addNew' => esc_html__( 'Add new theme', 'mainwp' ), 'search' => esc_html__( 'Search themes', 'mainwp' ), 'searchPlaceholder' => esc_html__( 'Search themes...', 'mainwp' ), 'upload' => esc_html__( 'Upload theme', 'mainwp' ), 'back' => esc_html__( 'Back', 'mainwp' ), 'error' => __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.', 'mainwp' ), 'themesFound' => esc_html__( 'Number of themes found: %d', 'mainwp' ), 'noThemesFound' => esc_html__( 'No themes found. Try a different search.', 'mainwp' ), 'collapseSidebar' => esc_html__( 'Collapse sidebar', 'mainwp' ), 'expandSidebar' => esc_html__( 'Expand sidebar', 'mainwp' ), ), 'installedThemes' => array(), ) ); static::render_header( 'Install' ); static::render_themes_table(); static::render_footer( 'Install' ); } /** * Render the Themes table for the Install Themes Tab. * * @uses \MainWP\Dashboard\MainWP_UI::render_modal_install_plugin_theme() * * @uses \MainWP\Dashboard\MainWP_Install_Bulk::render_upload() */ public static function render_themes_table() { if ( ! \mainwp_current_user_can( 'dashboard', 'install_themes' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'install themes', 'mainwp' ) ); return; } ?>
', ' ' ); ?>
'mainwp_select_sites_box_left', 'selected_sites' => $selected_sites, 'show_client' => true, ); MainWP_UI_Select_Sites::select_sites_box( $sel_params ); ?>
render_demo_disable_button( '' ); } else { ?>
', '' ); // NOSONAR - noopener - open safe. ?>
errors = array(); $output->themes = array(); $output->themes_installed = array(); $output->status = $search_theme_status; if ( 1 === (int) get_option( 'mainwp_optimize', 1 ) || MainWP_Demo_Handle::is_demo_mode() ) { $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { $allThemes = json_decode( $website->themes, true ); $_count = count( $allThemes ); for ( $i = 0; $i < $_count; $i++ ) { $theme = $allThemes[ $i ]; if ( 'all' !== $search_theme_status ) { if ( 1 === (int) $theme['active'] && 'active' !== $search_theme_status ) { continue; } if ( 1 !== $theme['active'] && 'inactive' !== $search_theme_status ) { continue; } } if ( ! empty( $keyword ) ) { $keyword = trim( $keyword ); $multi_kws = explode( ',', $keyword ); $multi_kws = array_filter( array_map( 'trim', $multi_kws ) ); if ( ! MainWP_Utility::multi_find_keywords( $theme['name'], $multi_kws ) ) { continue; } } $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $output->themes[] = $theme; } } MainWP_DB::free_result( $websites ); } else { $dbwebsites = array(); $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } MainWP_DB::free_result( $websites ); $post_data = array( 'keyword' => $keyword ); if ( 'active' === $search_theme_status || 'inactive' === $search_theme_status ) { $post_data['status'] = $search_theme_status; $post_data['filter'] = true; } else { $post_data['status'] = ''; $post_data['filter'] = false; } MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_themes', $post_data, array( MainWP_Themes_Handler::get_class_name(), 'themes_search_handler' ), $output ); if ( ! empty( $output->errors ) ) { foreach ( $output->errors as $siteid => $error ) { echo MainWP_Utility::get_nice_url( $dbwebsites[ $siteid ]->url ) . ' - ' . $error . '
'; // phpcs:ignore WordPress.Security.EscapeOutput } echo ''; } if ( count( $output->errors ) === count( $dbwebsites ) ) { $_SESSION['SNThemesAll'] = $output; return; } } $_SESSION['SNThemesAll'] = $output; $_SESSION['SNThemesAllStatus'] = array( 'keyword' => $keyword, 'status' => $search_status, 'theme_status' => $search_theme_status, ); } elseif ( isset( $_SESSION['SNThemesAllStatus'] ) ) { //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $search_status = isset( $_SESSION['SNThemesAllStatus']['status'] ) ? $_SESSION['SNThemesAllStatus']['status'] : ''; //phpcs:enable } if ( empty( $output->themes ) ) { ?>
themes as $theme ) { $themes[ $theme['slug'] ] = $theme; } asort( $themes ); $userExtension = MainWP_DB_Common::instance()->get_user_extension(); $decodedIgnoredThemes = json_decode( $userExtension->ignored_themes, true ); $trustedThemes = json_decode( $userExtension->trusted_themes, true ); if ( ! is_array( $trustedThemes ) ) { $trustedThemes = array(); } $trustedThemesNotes = json_decode( $userExtension->trusted_themes_notes, true ); if ( ! is_array( $trustedThemesNotes ) ) { $trustedThemesNotes = array(); } static::render_all_themes_html( $themes, $search_status, $trustedThemes, $trustedThemesNotes, $decodedIgnoredThemes ); } /** * Render all themes html. * * @param mixed $themes Themes list. * @param mixed $search_status Search status. * @param mixed $trustedThemes Trusted themes. * @param mixed $trustedThemesNotes Trusted themes notes. * @param mixed $decodedIgnoredThemes Decoded ignored themes. * * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() */ public static function render_all_themes_html( $themes, $search_status, $trustedThemes, $trustedThemesNotes, $decodedIgnoredThemes ) { // phpcs:ignore -- NOSONAR - complex. /** * Action: mainwp_themes_before_auto_updates_table * * Fires before the Auto Update Themes table. * * @since 4.1 */ do_action( 'mainwp_themes_before_auto_updates_table' ); ?> $theme ) : ?>
' . esc_html__( 'Trusted', 'mainwp' ) . '' : '' . esc_html__( 'Not Trusted', 'mainwp' ) . ''; ?> ' . esc_html__( 'Ignored', 'mainwp' ) . '' : ''; ?> ' : ''; ?>
'true', 'stateSave' => 'true', 'colReorder' => 'true', 'info' => 'true', 'paging' => 'false', 'ordering' => 'true', 'order' => '[ [ 2, "asc" ] ]', 'responsive' => 'true', ); /** * Filter: mainwp_theme_auto_updates_table_fatures * * Filters the Theme Auto Updates table features. * * @since 4.1 */ $table_features = apply_filters( 'mainwp_theme_auto_updates_table_fatures', $table_features ); ?> query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); $userExtension = MainWP_DB_Common::instance()->get_user_extension(); $decodedIgnoredThemes = json_decode( $userExtension->ignored_themes, true ); $ignoredThemes = is_array( $decodedIgnoredThemes ) && ! empty( $decodedIgnoredThemes ); $cnt = 0; while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( $website->is_ignoreThemeUpdates ) { continue; } $tmpDecodedIgnoredThemes = json_decode( $website->ignored_themes, true ); if ( ! is_array( $tmpDecodedIgnoredThemes ) || empty( $tmpDecodedIgnoredThemes ) ) { continue; } ++$cnt; } static::render_header( 'Ignore' ); ?>
', ' ' ); ?>

$ignoredThemeName ) : $ignore_name = 'N/A'; $ignored_vers = array( 'all_versions' ); if ( is_string( $ignoredThemeName ) ) { $ignore_name = $ignoredThemeName; } elseif ( is_array( $ignoredThemeName ) ) { $ignore_name = ! empty( $ignoredThemeName['Name'] ) ? $ignoredThemeName['Name'] : $ignore_name; $ig_vers = ! empty( $ignoredThemeName['ignored_versions'] ) ? $ignoredThemeName['ignored_versions'] : ''; if ( ! empty( $ig_vers ) && is_array( $ig_vers ) && ! in_array( 'all_versions', $ig_vers ) ) { $ignored_vers = $ig_vers; } } ?>
is_ignoreThemeUpdates ) { continue; } $decodedIgnoredThemes = json_decode( $website->ignored_themes, true ); if ( ! is_array( $decodedIgnoredThemes ) || empty( $decodedIgnoredThemes ) ) { continue; } $first = true; foreach ( $decodedIgnoredThemes as $ignoredTheme => $ignoredThemeName ) { $ignore_name = 'N/A'; $ignored_vers = array( 'all_versions' ); if ( is_string( $ignoredThemeName ) ) { $ignore_name = $ignoredThemeName; } elseif ( is_array( $ignoredThemeName ) ) { $ignore_name = ! empty( $ignoredThemeName['Name'] ) ? $ignoredThemeName['Name'] : $ignore_name; $ig_vers = ! empty( $ignoredThemeName['ignored_versions'] ) ? $ignoredThemeName['ignored_versions'] : ''; if ( ! empty( $ig_vers ) && is_array( $ig_vers ) && ! in_array( 'all_versions', $ig_vers ) ) { $ignored_vers = $ig_vers; } } foreach ( $ignored_vers as $ignored_ver ) { ?>
name ) ); ?>
name ) ); ?>
query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); $userExtension = MainWP_DB_Common::instance()->get_user_extension(); $decodedIgnoredThemes = json_decode( $userExtension->dismissed_themes, true ); $ignoredThemes = is_array( $decodedIgnoredThemes ) && ! empty( $decodedIgnoredThemes ); $cnt = 0; while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { $tmpDecodedIgnoredThemes = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); $tmpDecodedIgnoredThemes = ! empty( $tmpDecodedIgnoredThemes ) ? json_decode( $tmpDecodedIgnoredThemes, true ) : array(); if ( ! is_array( $tmpDecodedIgnoredThemes ) || empty( $tmpDecodedIgnoredThemes ) ) { continue; } ++$cnt; } static::render_header( 'IgnoreAbandoned' ); ?>
', ' ' ); ?>

$ignoredThemeName ) : ?>
get_website_option( $website, 'themes_outdate_dismissed' ); $decodedIgnoredThemes = ! empty( $decodedIgnoredThemes ) ? json_decode( $decodedIgnoredThemes, true ) : array(); if ( ! is_array( $decodedIgnoredThemes ) || empty( $decodedIgnoredThemes ) ) { continue; } $first = true; foreach ( $decodedIgnoredThemes as $ignoredTheme => $ignoredThemeName ) { ?>
name ) ); ?>
name ) ); ?>

Managing Themes with MainWP
Install Themes
Activate Themes
Delete Themes
Update Themes
Your custom text
* * @since 4.1 */ do_action( 'mainwp_themes_help_item' ); ?>