function prepare_items() { global $status, $themes, $totals, $page, $orderby, $order, $s; nxt_reset_vars(array('orderby', 'order', 's')); $themes = array('all' => apply_filters('all_themes', get_themes()), 'search' => array(), 'enabled' => array(), 'disabled' => array(), 'upgrade' => array()); $site_allowed_themes = get_site_allowed_themes(); if (!$this->is_site_themes) { $allowed_themes = $site_allowed_themes; $themes_per_page = $this->get_items_per_page('themes_network_per_page'); } else { $allowed_themes = nxtmu_get_blog_allowedthemes($this->site_id); $themes_per_page = $this->get_items_per_page('site_themes_network_per_page'); } $current = get_site_transient('update_themes'); foreach ((array) $themes['all'] as $key => $theme) { $theme_key = $theme['Stylesheet']; if (isset($allowed_themes[$theme_key])) { $themes['all'][$key]['enabled'] = true; $themes['enabled'][$key] = $themes['all'][$key]; } else { $themes['all'][$key]['enabled'] = false; $themes['disabled'][$key] = $themes['all'][$key]; } if (isset($current->response[$theme['Template']])) { $themes['upgrade'][$key] = $themes['all'][$key]; } if ($this->is_site_themes && isset($site_allowed_themes[$theme_key])) { unset($themes['all'][$key]); unset($themes['enabled'][$key]); unset($themes['disabled'][$key]); } } if (!current_user_can('update_themes') || $this->is_site_themes) { $themes['upgrade'] = array(); } if ($s) { $status = 'search'; $themes['search'] = array_filter($themes['all'], array(&$this, '_search_callback')); } $totals = array(); foreach ($themes as $type => $list) { $totals[$type] = count($list); } if (empty($themes[$status]) && !in_array($status, array('all', 'search'))) { $status = 'all'; } $this->items = $themes[$status]; $total_this_page = $totals[$status]; if ($orderby) { $orderby = ucfirst($orderby); $order = strtoupper($order); uasort($this->items, array(&$this, '_order_callback')); } $start = ($page - 1) * $themes_per_page; if ($total_this_page > $themes_per_page) { $this->items = array_slice($this->items, $start, $themes_per_page); } $this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $themes_per_page)); }
/** * Get the allowed themes for the current blog. * * @since 3.0.0 * * @uses get_themes() * @uses current_theme_info() * @uses get_site_allowed_themes() * @uses nxtmu_get_blog_allowedthemes * * @return array $themes Array of allowed themes. */ function get_allowed_themes() { if (!is_multisite()) { return get_themes(); } $themes = get_themes(); $ct = current_theme_info(); $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes()); if ($allowed_themes == false) { $allowed_themes = array(); } $blog_allowed_themes = nxtmu_get_blog_allowedthemes(); if (is_array($blog_allowed_themes)) { $allowed_themes = array_merge($allowed_themes, $blog_allowed_themes); } if (isset($allowed_themes[esc_html($ct->stylesheet)]) == false) { $allowed_themes[esc_html($ct->stylesheet)] = true; } reset($themes); foreach ($themes as $key => $theme) { if (isset($allowed_themes[esc_html($theme['Stylesheet'])]) == false) { unset($themes[$key]); } } reset($themes); return $themes; }