[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> theme-install.php (source)

   1  <?php
   2  /**
   3   * WordPress Theme Install Administration API
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
  10      'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
  11      'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
  12      'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
  13      'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
  14      'img' => array('src' => array(), 'class' => array(), 'alt' => array())
  15  );
  16  
  17  $theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
  18      'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
  19      'tags' => true, 'num_ratings' => true
  20  );
  21  
  22  /**
  23   * Retrieve list of WordPress theme features (aka theme tags)
  24   *
  25   * @since 2.8.0
  26   *
  27   * @deprecated since 3.1.0 Use get_theme_feature_list() instead.
  28   *
  29   * @return array
  30   */
  31  function install_themes_feature_list( ) {
  32      if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
  33          set_transient( 'wporg_theme_feature_list', array( ), 10800);
  34  
  35      if ( $cache )
  36          return $cache;
  37  
  38      $feature_list = themes_api( 'feature_list', array( ) );
  39      if ( is_wp_error( $feature_list ) )
  40          return $features;
  41  
  42      set_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
  43  
  44      return $feature_list;
  45  }
  46  
  47  /**
  48   * Display search form for searching themes.
  49   *
  50   * @since 2.8.0
  51   */
  52  function install_theme_search_form( $type_selector = true ) {
  53      $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : 'term';
  54      $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
  55      if ( ! $type_selector )
  56          echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
  57      ?>
  58  <form id="search-themes" method="get" action="">
  59      <input type="hidden" name="tab" value="search" />
  60      <?php if ( $type_selector ) : ?>
  61      <select    name="type" id="typeselector">
  62      <option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
  63      <option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
  64      <option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
  65      </select>
  66      <?php endif; ?>
  67      <input type="search" name="s" size="30" value="<?php echo esc_attr($term) ?>" />
  68      <?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
  69  </form>
  70  <?php
  71  }
  72  
  73  /**
  74   * Display tags filter for themes.
  75   *
  76   * @since 2.8.0
  77   */
  78  function install_themes_dashboard() {
  79      install_theme_search_form( false );
  80  ?>
  81  <h4><?php _e('Feature Filter') ?></h4>
  82  <p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
  83  
  84  <form method="get" action="">
  85      <input type="hidden" name="tab" value="search" />
  86      <?php
  87      $feature_list = get_theme_feature_list( );
  88      echo '<div class="feature-filter">';
  89  
  90      foreach ( (array) $feature_list as $feature_name => $features ) {
  91          $feature_name = esc_html( $feature_name );
  92          echo '<div class="feature-name">' . $feature_name . '</div>';
  93  
  94          echo '<ol class="feature-group">';
  95          foreach ( $features as $feature => $feature_name ) {
  96              $feature_name = esc_html( $feature_name );
  97              $feature = esc_attr($feature);
  98  ?>
  99  
 100  <li>
 101      <input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" />
 102      <label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label>
 103  </li>
 104  
 105  <?php    } ?>
 106  </ol>
 107  <br class="clear" />
 108  <?php
 109      } ?>
 110  
 111  </div>
 112  <br class="clear" />
 113  <?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?>
 114  </form>
 115  <?php
 116  }
 117  add_action('install_themes_dashboard', 'install_themes_dashboard');
 118  
 119  function install_themes_upload($page = 1) {
 120  ?>
 121  <h4><?php _e('Install a theme in .zip format') ?></h4>
 122  <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.') ?></p>
 123  <form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-theme') ?>">
 124      <?php wp_nonce_field( 'theme-upload') ?>
 125      <input type="file" name="themezip" />
 126      <?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
 127  </form>
 128      <?php
 129  }
 130  add_action('install_themes_upload', 'install_themes_upload', 10, 1);
 131  
 132  /**
 133   * Prints a theme on the Install Themes pages.
 134   *
 135   * @deprecated 3.4.0
 136   */
 137  function display_theme( $theme ) {
 138      _deprecated_function( __FUNCTION__, '3.4' );
 139      global $wp_list_table;
 140      return $wp_list_table->single_row( $theme );
 141  }
 142  
 143  /**
 144   * Display theme content based on theme list.
 145   *
 146   * @since 2.8.0
 147   */
 148  function display_themes() {
 149      global $wp_list_table;
 150  
 151      $wp_list_table->display();
 152  }
 153  add_action('install_themes_search', 'display_themes');
 154  add_action('install_themes_featured', 'display_themes');
 155  add_action('install_themes_new', 'display_themes');
 156  add_action('install_themes_updated', 'display_themes');
 157  
 158  /**
 159   * Display theme information in dialog box form.
 160   *
 161   * @since 2.8.0
 162   */
 163  function install_theme_information() {
 164      global $tab, $themes_allowedtags, $wp_list_table;
 165  
 166      $theme = themes_api( 'theme_information', array( 'slug' => stripslashes( $_REQUEST['theme'] ) ) );
 167  
 168      if ( is_wp_error( $theme ) )
 169          wp_die( $theme );
 170  
 171      iframe_header( __('Theme Install') );
 172      $wp_list_table->theme_installer_single( $theme );
 173      iframe_footer();
 174      exit;
 175  }
 176  add_action('install_themes_pre_theme-information', 'install_theme_information');


Generated: Fri May 25 03:56:23 2012 Hosted by follow the white rabbit.