function show_vars() { global $name; if (is_file("modules/{$name}/configure.php")) { $file = file("modules/{$name}/configure.php"); $strfile = join("", $file); #eval("\n>\n$file\n<?php\n "); echo "<table>" . "<tr>" . "<td><textarea name=config_file cols=80 rows=25>{$strfile}</textarea></td>" . "</tr>" . "</table>"; foreach ($file as $line) { if (strstr($line, "\$hlpdsk_theme")) { $theme_selected = substr(strstr($line, '"'), 1, -3); echo "theme selected<br>{$theme_selected}<br>"; } } $themes = get_themes(); foreach ($themes as $value) { if ($value == $theme_selected) { $options .= "<option value=\"{$value}\" selected>{$value}</option>\n"; } else { $options .= "<option value=\"{$value}\">{$value}</option>\n"; } } echo "<select>{$options}</select>"; } else { write_config(); } }
/** * Scans the template files of the active theme, and returns an * array of [Template Name => {file}.php] * * @since 0.2.0 * * @return array */ function get_post_templates() { $themes = get_themes(); $theme = get_current_theme(); $templates = $themes[$theme]['Template Files']; $post_templates = array(); $base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory())); foreach ((array) $templates as $template) { $template = WP_CONTENT_DIR . str_replace(WP_CONTENT_DIR, '', $template); $basename = str_replace($base, '', $template); /** Don't allow template files in subdirectories */ if (false !== strpos($basename, '/')) { continue; } $template_data = implode('', file($template)); $name = ''; if (preg_match('|Single Post Template:(.*)$|mi', $template_data, $name)) { $name = _cleanup_header_comment($name[1]); } if (!empty($name)) { if (basename($template) != basename(__FILE__)) { $post_templates[trim($name)] = $basename; } } } return $post_templates; }
function DisplayThemeBar($theme1) { global $lang,$flag_new_themes,$contact_sheet,$theme_images,$allow_share,$n,$baseurl; # Work out theme name $themename=$theme1; $theme_display=getval("theme_$n","off"); $themes=get_themes(array($theme1)); if (count($themes)>0) { ?> <div onclick=" var theme_display=get_cookie('theme_<?php echo $n?>'); if (theme_display=='off'){var toggle_theme_display='on';} else { var toggle_theme_display='off';} SetCookie('theme_<?php echo $n?>',toggle_theme_display,1000); jQuery('#themebar_<?php echo htmlspecialchars(str_replace(array("\""," "),"",$themename)) ?>').slideToggle(0.2); return false;"> <a href='#'><b><?php echo htmlspecialchars(stripslashes(i18n_get_translated(str_replace("*","",$themename)))) ?></b></a></div> <div id="themebar_<?php echo htmlspecialchars(str_replace(array("\""," "),"",$themename)) ?>" style="display:<?php if ($theme_display == 'off'){echo 'none';} else {echo '';}?>" > <?php for ($m=0;$m<count($themes);$m++) { ?><br> <a href="<?php echo $baseurl?>/pages/search.php?search=!collection<?php echo $themes[$m]["ref"]?>&bc_from=themes" title="<?php echo $lang["collectionviewhover"]?>"><?php echo htmlspecialchars(i18n_get_collection_name($themes[$m])) ?></a> <?php } ?><br><br></div><?php } }
function select_themes() { global $name; if (is_file("modules/{$name}/configure.php")) { $file = file("modules/{$name}/configure.php"); foreach ($file as $line) { if (strstr($line, "\$hlpdsk_theme")) { $theme_selected = substr(strstr($line, '"'), 1, -3); $show = "theme selected<br>{$theme_selected}<br>"; } } $themes = get_themes(); foreach ($themes as $value) { if ($value == $theme_selected) { $options .= "<option value=\"{$value}\" selected>{$value}</option>\n"; } else { $options .= "<option value=\"{$value}\">{$value}</option>\n"; } } $theme_select = "<select name='theme_selected'>{$options}</select>"; echo "<form action='modules.php?name={$name}&file=admin&func=change_theme' method='POST'>"; echo "<table>" . "<tr>" . "<td>{$theme_select}</td>" . "</tr>" . "</table>"; echo "<input name=submit type=submit></form>"; } }
function default_theme_site_admin_options() { $themes = get_themes(); $default_theme = get_site_option('default_theme'); if (empty($default_theme)) { $default_theme = 'default'; } ?> <h3><?php _e('Theme Settings', 'defaulttheme'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Default Theme', 'defaulttheme'); ?> </th> <td><select name="default_theme"> <?php foreach ($themes as $key => $theme) { $theme_key = wp_specialchars($theme['Stylesheet']); echo '<option value="' . $theme_key . '"' . ($theme_key == $default_theme ? ' selected' : '') . '>' . $key . '</option>' . "\n"; } ?> </select> <br /><?php _e('Default theme applied to new blogs.', 'defaulttheme'); ?> </td> </tr> </table> <?php }
/** * Return an array of installed themes * * @return array */ function _wprp_get_themes() { require_once ABSPATH . '/wp-admin/includes/theme.php'; // Get all themes $themes = get_themes(); // Get the list of active themes $active = get_option('current_theme'); // Force a theme update check wp_update_themes(); // Different versions of wp store the updates in different places // TODO can we depreciate if (function_exists('get_site_transient') && ($transient = get_site_transient('update_themes'))) { $current = $transient; } elseif ($transient = get_transient('update_themes')) { $current = $transient; } else { $current = get_option('update_themes'); } foreach ((array) $themes as $theme) { $new_version = isset($current->response[$theme['Template']]) ? $current->response[$theme['Template']]['new_version'] : null; if ($active == $theme['Name']) { $themes[$theme['Name']]['active'] = true; } else { $themes[$theme['Name']]['active'] = false; } if ($new_version) { $themes[$theme['Name']]['latest_version'] = $new_version; $themes[$theme['Name']]['latest_package'] = $current->response[$theme['Template']]['package']; } else { $themes[$theme['Name']]['latest_version'] = $theme['Version']; } } return $themes; }
/** * Function for getting an array of available custom templates with a specific header. Ideally, * this function would be used to grab custom singular post (any post type) templates. * * @since 0.7 * @param array $args Arguments to check the templates against. * @return array $post_templates The array of templates. */ function hybrid_get_post_templates( $args = array() ) { $args = wp_parse_args( $args, array( 'label' => array( 'Post Template' ) ) ); $themes = get_themes(); $theme = get_current_theme(); $templates = $themes[$theme]['Template Files']; $post_templates = array(); if ( is_array( $templates ) ) { $base = array( trailingslashit( get_template_directory() ), trailingslashit( get_stylesheet_directory() ) ); foreach ( $templates as $template ) { $basename = str_replace( $base, '', $template ); $template_data = implode( '', file( $template ) ); $name = ''; foreach ( $args['label'] as $label ) { if ( preg_match( "|{$label}:(.*)$|mi", $template_data, $name ) ) { $name = _cleanup_header_comment( $name[1] ); break; } } if ( !empty( $name ) ) $post_templates[trim( $name )] = $basename; } } return $post_templates; }
function multitheme_admin_save_page_beforepost() { global $lang, $p_theme; echo '<tr>'; echo '<td><label for="theme">' . $lang['multitheme']['page_edit'] . ' </label></td>'; echo '<td><select name="theme" id="theme">'; $themes = get_themes(); if ($themes) { foreach ($themes as $theme) { if (isset($p_theme)) { if ($theme['dir'] == $p_theme) { echo '<option value="' . $theme['dir'] . '" selected="selected">' . $theme['title'] . '</option>'; } else { echo '<option value="' . $theme['dir'] . '">' . $theme['title'] . '</option>'; } } else { if ($theme['dir'] == THEME) { echo '<option value="' . $theme['dir'] . '" selected="selected">' . $theme['title'] . '</option>'; } else { echo '<option value="' . $theme['dir'] . '">' . $theme['title'] . '</option>'; } } } } echo '</select></td>'; echo '</tr>'; }
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)); }
/** * Reducing in-memory size further. * * @ticket 11214 */ function test_smaller_storage() { $themes = get_themes(); $this->_filter_out_themes_not_in_root($themes); $theme_names = array_keys($themes); $this->assertEquals(87, count($theme_names)); $this->assertLessThanOrEqual(136342, strlen(serialize($themes))); }
public function get_avaiable_themes() { if (function_exists('wp_get_themes')) { $this->avaiable_themes = wp_get_themes(); } else { $this->avaiable_themes = get_themes(); } }
function getAndroidTemplate() { $androidTheme = get_option('android_theme'); $themeList = get_themes(); foreach ($themeList as $theme) { if ($theme['Name'] == $androidTheme) { return $theme['Stylesheet']; } } }
/** * Get directory name of current theme * * @since WordPress 3.4 * * @return string */ function _deprecated_get_theme_stylesheet() { if (function_exists('wp_get_theme')) { $theme = wp_get_theme(); return $theme->stylesheet; } else { $themes = get_themes(); return $themes[get_current_theme()]['Stylesheet']; } }
function admin_toxid_preview_theme_field() { $themes = array_keys(get_themes()); $currentTheme = get_option('toxid_preview_theme'); echo '<select name="toxid_preview_theme">'; echo '<option>' . __('None') . '</option>'; foreach ($themes as $theme) { printf('<option value="%s" %s>%s</option>', esc_attr($theme), $theme == $currentTheme ? 'selected' : '', esc_html($theme)); } echo '</select>'; }
function pl_get_themes() { if (!class_exists('WP_Theme')) { return get_themes(); } $themes = wp_get_themes(); foreach ($themes as $key => $theme) { $theme_data[$key] = array('Name' => $theme->get('Name'), 'URI' => $theme->display('ThemeURI', true, false), 'Description' => $theme->display('Description', true, false), 'Author' => $theme->display('Author', true, false), 'Author Name' => $theme->display('Author', false), 'Author URI' => $theme->display('AuthorURI', true, false), 'Version' => $theme->get('Version'), 'Template' => $theme->get('Template'), 'Status' => $theme->get('Status'), 'Tags' => $theme->get('Tags'), 'Title' => $theme->get('Name'), 'Template' => '' != $theme->display('Template', false, false) ? $theme->display('Template', false, false) : $key, 'Stylesheet' => $key, 'Stylesheet Files' => array(0 => sprintf('%s/style.css', $theme->get_stylesheet_directory()))); } return $theme_data; }
public static function get_installed_themes() { $raw_themes = function_exists('wp_get_themes') ? wp_get_themes() : get_themes(); $installed_themes = array(); foreach ($raw_themes as $key => $theme) { $is_active = get_option('stylesheet') == $theme['Stylesheet']; /* WP 3.4 and newer requires a different nonce */ $nonce = function_exists('wp_get_themes') ? 'switch-theme_' . $theme['Stylesheet'] : 'switch-theme_' . $theme['Template']; $installed_themes[$theme['Stylesheet']] = array('theme' => $theme['Stylesheet'], 'name' => $theme['Name'], 'is_active' => $is_active, 'activation_url' => $is_active ? '' : wp_nonce_url('themes.php?action=activate&template=' . urlencode($theme['Template']) . '&stylesheet=' . urlencode($theme['Stylesheet']), $nonce)); } return $installed_themes; }
/** * Return an array of installed themes * * @return array */ function _wprp_get_themes() { require_once ABSPATH . '/wp-admin/includes/theme.php'; // Get all themes if (function_exists('wp_get_themes')) { $themes = wp_get_themes(); } else { $themes = get_themes(); } // Get the active theme $active = get_option('current_theme'); // Delete the transient so wp_update_themes can get fresh data if (function_exists('get_site_transient')) { delete_site_transient('update_themes'); } else { delete_transient('update_themes'); } // Force a theme update check wp_update_themes(); // Different versions of wp store the updates in different places // TODO can we depreciate if (function_exists('get_site_transient') && ($transient = get_site_transient('update_themes'))) { $current = $transient; } elseif ($transient = get_transient('update_themes')) { $current = $transient; } else { $current = get_option('update_themes'); } foreach ((array) $themes as $key => $theme) { // WordPress 3.4+ if (is_object($theme) && is_a($theme, 'WP_Theme')) { /* @var $theme WP_Theme */ $new_version = isset($current->response[$theme->get_stylesheet()]) ? $current->response[$theme->get_stylesheet()]['new_version'] : null; $theme_array = array('Name' => $theme->get('Name'), 'active' => $active == $theme->get('Name'), 'Template' => $theme->get_template(), 'Stylesheet' => $theme->get_stylesheet(), 'Screenshot' => $theme->get_screenshot(), 'AuthorURI' => $theme->get('AuthorURI'), 'Author' => $theme->get('Author'), 'latest_version' => $new_version ? $new_version : $theme->get('Version'), 'Version' => $theme->get('Version'), 'ThemeURI' => $theme->get('ThemeURI')); $themes[$key] = $theme_array; } else { $new_version = isset($current->response[$theme['Stylesheet']]) ? $current->response[$theme['Stylesheet']]['new_version'] : null; if ($active == $theme['Name']) { $themes[$key]['active'] = true; } else { $themes[$key]['active'] = false; } if ($new_version) { $themes[$key]['latest_version'] = $new_version; $themes[$key]['latest_package'] = $current->response[$theme['Template']]['package']; } else { $themes[$key]['latest_version'] = $theme['Version']; } } } return $themes; }
public function getInstalledVersion() { if (function_exists('wp_get_theme')) { $theme = wp_get_theme($this->theme); return $theme->get('Version'); } foreach (get_themes() as $theme) { if ($theme['Stylesheet'] === $this->theme) { return $theme['Version']; } } return ''; }
public function __construct() { parent::__construct(); if (!$this->session->userdata('logged_in')) { $this->session->set_userdata('url', uri_string()); redirect(base_url() . 'login'); } $themes = get_themes(); if ($this->input->get('theme') && in_array($this->input->get('theme'), $themes)) { set_theme($this->input->get('theme')); } $this->form_validation->set_error_delimiters('<p class="bg-danger">', '</p>'); }
function mts_show_admin() { if ($_POST['form_hidden'] == 'Y') { //Form data sent $mobiletheme = $_POST['mobiletheme']; update_option('mobiletheme', $mobiletheme); ?> <div class="updated"><p><strong>Options saved.</strong></p></div> <?php } else { $mobiletheme = get_option('mobiletheme'); } ?> <div class="wrap"> <h2>Choose mobile theme</h2> <br /> <form name="mobiletheme_form" method="post" action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?> "> <?php $themes = get_themes(); $default_theme = get_current_theme(); if (count($themes) > 1) { $theme_names = array_keys($themes); natcasesort($theme_names); $html = 'Select mobile theme: <select name="mobiletheme">' . "\n"; foreach ($theme_names as $theme_name) { if ($mobiletheme == $theme_name || $mobiletheme == '' && $theme_name == $default_theme) { $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>' . "\n"; } else { $html .= '<option value="' . $theme_name . '">' . htmlspecialchars($theme_name) . '</option>' . "\n"; } } $html .= '</select>' . "\n\n"; } echo $html; ?> <input type="hidden" name="form_hidden" value="Y"> <p class="submit"> <input type="submit" name="Submit" value="Update Options" /> </p> </form> </div> <?php }
/** * Get theme list */ public function getThemes() { global $wp_version; $themes = null; if (!function_exists('wp_get_themes')) { $themes = get_themes(); } else { $themes = wp_get_themes(); } if (version_compare($wp_version, '3.4', '>=')) { foreach ($themes as $key => $theme) { $themes[$key] = $this->WP_ThemeToArray($theme); } } return $themes; }
/** * Gets the currently available themes. * * @return array The currently available themes */ public function get_themes() { $this->_pre_search($this->get_theme_dirs()); $options = array('errors' => null, 'allowed' => null); $theme_map = null; if (function_exists('wp_get_themes')) { $theme_map = wp_get_themes($options); } else { $theme_map = get_themes() + get_broken_themes(); } add_filter('theme_root_uri', array($this, 'get_root_uri_for_our_themes'), 10, 3); foreach ($theme_map as $theme) { $theme->get_theme_root_uri(); } $this->_post_search(); return $theme_map; }
/** * Function for getting an array of available custom templates with a specific header. Ideally, this function * would be used to grab custom singular post (any post type) templates. It is a recreation of the WordPress * page templates function because it doesn't allow for other types of templates. * * @since 0.7.0 * @param array $args Arguments to check the templates against. * @return array $post_templates The array of templates. */ function hybrid_get_post_templates( $args = array() ) { /* Parse the arguments with the defaults. */ $args = wp_parse_args( $args, array( 'label' => array( 'Post Template' ) ) ); /* Get theme and templates variables. */ $themes = get_themes(); $theme = get_current_theme(); $templates = $themes[$theme]['Template Files']; $post_templates = array(); /* If there's an array of templates, loop through each template. */ if ( is_array( $templates ) ) { /* Set up a $base path that we'll use to remove from the file name. */ $base = array( trailingslashit( get_template_directory() ), trailingslashit( get_stylesheet_directory() ) ); /* Loop through the post templates. */ foreach ( $templates as $template ) { /* Remove the base (parent/child theme path) from the template file name. */ $basename = str_replace( $base, '', $template ); /* Get the template data. */ $template_data = implode( '', file( $template ) ); /* Make sure the name is set to an empty string. */ $name = ''; /* Loop through each of the potential labels and see if a match is found. */ foreach ( $args['label'] as $label ) { if ( preg_match( "|{$label}:(.*)$|mi", $template_data, $name ) ) { $name = _cleanup_header_comment( $name[1] ); break; } } /* If a post template was found, add its name and file name to the $post_templates array. */ if ( !empty( $name ) ) $post_templates[trim( $name )] = $basename; } } /* Return array of post templates. */ return $post_templates; }
private function list_themes() { // Print the header WP_CLI::line('Installed themes:'); foreach (get_themes() as $theme) { if (WP_CLI::get_update_status($theme['Stylesheet'], 'update_themes')) { $line = ' %yU%n'; } else { $line = ' '; } $line .= $this->get_status($theme['Name']) . ' ' . $theme['Stylesheet'] . '%n'; WP_CLI::line($line); } // Print the footer WP_CLI::line(); $legend = array('I' => 'Inactive', '%gA' => 'Active'); WP_CLI::legend($legend); }
public function check($updates) { $this->username = apply_filters("vibe_theme_update_username", $this->username); $this->apiKey = apply_filters("vibe_theme_update_apiKey", $this->apiKey); $this->authors = apply_filters("vibe_theme_update_authors", $this->authors); if ($this->authors && !is_array($this->authors)) { $this->authors = array($this->authors); } if (!$this->username || !$this->apiKey || !isset($updates->checked)) { return $updates; } if (!class_exists("Envato_Protected_API")) { require_once "class-envato-protected-api.php"; } $api = new Envato_Protected_API($this->username, $this->apiKey); add_filter("http_request_args", array(&$this, "http_timeout"), 10, 1); $purchased = $api->wp_list_themes(true); $installed = function_exists("wp_get_themes") ? wp_get_themes() : get_themes(); $filtered = array(); foreach ($installed as $theme) { if ($this->authors && !in_array($theme->{'Author Name'}, $this->authors)) { continue; } $filtered[$theme->Name] = $theme; //echo $theme->{'Author Name'}.' <=##=>'.$this->authors .' || '; } foreach ($purchased as $theme) { //echo '###'.$theme->theme_name; if (isset($theme->theme_name) && isset($filtered[$theme->theme_name])) { // gotcha, compare version now $current = $filtered[$theme->theme_name]; if (version_compare($current->Version, $theme->version, '<')) { // bingo, inject the update if ($url = $api->wp_download($theme->item_id)) { $update = array("url" => "http://themeforest.net/item/theme/{$theme->item_id}", "new_version" => $theme->version, "package" => $url); $updates->response[$current->Stylesheet] = $update; } } } } remove_filter("http_request_args", array(&$this, "http_timeout")); return $updates; }
function edit($width, $area) { $themes = get_themes(); ?> <tr> <th width="<?php echo $width; ?> " align="right"><?php _e('Theme', 'headspace'); ?> :</th> <td> <select name="headspace_theme"> <option value="0"><?php _e('Current theme', 'headspace'); ?> </option> <?php foreach ($themes as $name => $values) { ?> <option value="<?php echo $values['Template']; ?> "<?php if ($values['Template'] == $this->theme) { echo ' selected="selected"'; } ?> ><?php echo $name; ?> </option> <?php } ?> </select> </td> </tr> <?php }
function do_init() { $themes = get_themes(); $shouldbe = basename($this->infos['path']); foreach ($themes as $theme) { $current = basename($theme['Template Dir']); if ($current == $shouldbe) { if (get_settings('template') == $current) { $this->infos['active'] = TRUE; } else { $this->infos['active'] = FALSE; } $this->infos['theme_name'] = $theme['Name']; $this->infos['theme_shortname'] = $current; $this->infos['theme_site'] = $theme['Title']; $this->infos['theme_version'] = $theme['Version']; $this->infos['theme_author'] = preg_replace("#>\\s*([^<]*)</a>#", ">\\1</a>", $theme['Author']); } } }
function get_page_templates() { $themes = get_themes(); $theme = get_current_theme(); $templates = $themes[$theme]['Template Files']; $page_templates = array(); if (is_array($templates)) { foreach ($templates as $template) { $template_data = implode('', file(ABSPATH . $template)); preg_match('|Template Name:(.*)$|mi', $template_data, $name); preg_match('|Description:(.*)$|mi', $template_data, $description); $name = $name[1]; $description = $description[1]; if (!empty($name)) { $page_templates[trim($name)] = basename($template); } } } return $page_templates; }
private function core_count_themes() { if (!class_exists('WP_Theme')) { return get_themes(); } global $wp_themes; if (isset($wp_themes)) { return $wp_themes; } $themes = wp_get_themes(); $wp_themes = array(); foreach ($themes as $theme) { $name = $theme->get('Name'); if (isset($wp_themes[$name])) { $wp_themes[$name . '/' . $theme->get_stylesheet()] = $theme; } else { $wp_themes[$name] = $theme; } } return $wp_themes; }
/** * get_themes method * * Wrapper to WP `wp_get_themes` or `get_themes` (whichever is available). * Method resets global variables and hooks, required for indexing, whilst * performing theme search. After themes are found - it caches these using * local static variable and restores global functions. * * @param bool $force Set to true to re-list themes * * @return array Map of theme names and their paths */ public function get_themes($force = false, $options = array()) { static $theme_map = array(); $key = json_encode($options); if ($force || !isset($theme_map[$key])) { global $wp_theme_directories, $wp_broken_themes; $restore_vals = array('wp_theme_directories' => array(AI1EC_THEMES_ROOT), 'wp_broken_themes' => array()); // mark restore point foreach ($restore_vals as $key => $cval) { $restore_vals[$key] = ${$key}; ${$key} = $cval; } // disable and clean cache add_filter('wp_cache_themes_persistently', '__return_false', 1); search_theme_directories(true); $theme_list = NULL; if (function_exists('wp_get_themes')) { $theme_list = wp_get_themes($options); } else { if (isset($options['errors']) && $options['errors']) { $theme_list = get_broken_themes(); } else { $theme_list = get_themes(); } } foreach ($theme_list as $theme) { $theme_map[$key][$theme->get('Name')] = $theme; $theme->get_theme_root_uri(); // pre-cache } unset($theme_list); // remove cache disablers and restore values remove_filter('wp_cache_themes_persistently', '__return_false', 1); foreach ($restore_vals as $key => $cval) { ${$key} = $cval; } search_theme_directories(true); } return $theme_map[$key]; }