Example #1
0
 /**
  * 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;
 }
 /**
  * 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];
 }
Example #3
0
<br class="clear" />

<?php 
}
?>

<?php 
$wp_list_table->display();
?>

</form>
<br class="clear" />

<?php 
// List broken themes, if any.
$broken_themes = get_broken_themes();
if (current_user_can('edit_themes') && count($broken_themes)) {
    ?>

<h3><?php 
    _e('Broken Themes');
    ?>
</h3>
<p><?php 
    _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.');
    ?>
</p>

<table id="broken-themes">
	<tr>
		<th><?php 
 /**
  * @expectedDeprecated get_themes
  * @expectedDeprecated get_broken_themes
  */
 function test_broken_themes()
 {
     $themes = get_themes();
     $expected = array('broken-theme' => array('Name' => 'broken-theme', 'Title' => 'broken-theme', 'Description' => __('Stylesheet is missing.')));
     $this->assertEquals($expected, get_broken_themes());
 }