home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress2 / wp-admin / includes / theme-install.php < prev    next >
Encoding:
PHP Script  |  2017-08-22  |  6.1 KB  |  213 lines

  1. <?php
  2. /**
  3.  * WordPress Theme Installation 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.     _deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );
  33.  
  34.     if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
  35.         set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
  36.  
  37.     if ( $cache )
  38.         return $cache;
  39.  
  40.     $feature_list = themes_api( 'feature_list', array() );
  41.     if ( is_wp_error( $feature_list ) )
  42.         return array();
  43.  
  44.     set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
  45.  
  46.     return $feature_list;
  47. }
  48.  
  49. /**
  50.  * Display search form for searching themes.
  51.  *
  52.  * @since 2.8.0
  53.  *
  54.  * @param bool $type_selector
  55.  */
  56. function install_theme_search_form( $type_selector = true ) {
  57.     $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
  58.     $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
  59.     if ( ! $type_selector )
  60.         echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
  61.     ?>
  62. <form id="search-themes" method="get">
  63.     <input type="hidden" name="tab" value="search" />
  64.     <?php if ( $type_selector ) : ?>
  65.     <label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label>
  66.     <select    name="type" id="typeselector">
  67.     <option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
  68.     <option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
  69.     <option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
  70.     </select>
  71.     <label class="screen-reader-text" for="s"><?php
  72.     switch ( $type ) {
  73.         case 'term':
  74.             _e( 'Search by keyword' );
  75.             break;
  76.         case 'author':
  77.             _e( 'Search by author' );
  78.             break;
  79.         case 'tag':
  80.             _e( 'Search by tag' );
  81.             break;
  82.     }
  83.     ?></label>
  84.     <?php else : ?>
  85.     <label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
  86.     <?php endif; ?>
  87.     <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
  88.     <?php submit_button( __( 'Search' ), '', 'search', false ); ?>
  89. </form>
  90. <?php
  91. }
  92.  
  93. /**
  94.  * Display tags filter for themes.
  95.  *
  96.  * @since 2.8.0
  97.  */
  98. function install_themes_dashboard() {
  99.     install_theme_search_form( false );
  100. ?>
  101. <h4><?php _e('Feature Filter') ?></h4>
  102. <p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
  103.  
  104. <form method="get">
  105.     <input type="hidden" name="tab" value="search" />
  106.     <?php
  107.     $feature_list = get_theme_feature_list();
  108.     echo '<div class="feature-filter">';
  109.  
  110.     foreach ( (array) $feature_list as $feature_name => $features ) {
  111.         $feature_name = esc_html( $feature_name );
  112.         echo '<div class="feature-name">' . $feature_name . '</div>';
  113.  
  114.         echo '<ol class="feature-group">';
  115.         foreach ( $features as $feature => $feature_name ) {
  116.             $feature_name = esc_html( $feature_name );
  117.             $feature = esc_attr($feature);
  118. ?>
  119.  
  120. <li>
  121.     <input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" />
  122.     <label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label>
  123. </li>
  124.  
  125. <?php    } ?>
  126. </ol>
  127. <br class="clear" />
  128. <?php
  129.     } ?>
  130.  
  131. </div>
  132. <br class="clear" />
  133. <?php submit_button( __( 'Find Themes' ), '', 'search' ); ?>
  134. </form>
  135. <?php
  136. }
  137.  
  138. /**
  139.  * @since 2.8.0
  140.  */
  141. function install_themes_upload() {
  142. ?>
  143. <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p>
  144. <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
  145.     <?php wp_nonce_field( 'theme-upload' ); ?>
  146.     <label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label>
  147.     <input type="file" id="themezip" name="themezip" />
  148.     <?php submit_button( __( 'Install Now' ), '', 'install-theme-submit', false ); ?>
  149. </form>
  150.     <?php
  151. }
  152.  
  153. /**
  154.  * Prints a theme on the Install Themes pages.
  155.  *
  156.  * @deprecated 3.4.0
  157.  *
  158.  * @global WP_Theme_Install_List_Table $wp_list_table
  159.  *
  160.  * @param object $theme
  161.  */
  162. function display_theme( $theme ) {
  163.     _deprecated_function( __FUNCTION__, '3.4.0' );
  164.     global $wp_list_table;
  165.     if ( ! isset( $wp_list_table ) ) {
  166.         $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
  167.     }
  168.     $wp_list_table->prepare_items();
  169.     $wp_list_table->single_row( $theme );
  170. }
  171.  
  172. /**
  173.  * Display theme content based on theme list.
  174.  *
  175.  * @since 2.8.0
  176.  *
  177.  * @global WP_Theme_Install_List_Table $wp_list_table
  178.  */
  179. function display_themes() {
  180.     global $wp_list_table;
  181.  
  182.     if ( ! isset( $wp_list_table ) ) {
  183.         $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
  184.     }
  185.     $wp_list_table->prepare_items();
  186.     $wp_list_table->display();
  187.  
  188. }
  189.  
  190. /**
  191.  * Display theme information in dialog box form.
  192.  *
  193.  * @since 2.8.0
  194.  *
  195.  * @global WP_Theme_Install_List_Table $wp_list_table
  196.  */
  197. function install_theme_information() {
  198.     global $wp_list_table;
  199.  
  200.     $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
  201.  
  202.     if ( is_wp_error( $theme ) )
  203.         wp_die( $theme );
  204.  
  205.     iframe_header( __('Theme Installation') );
  206.     if ( ! isset( $wp_list_table ) ) {
  207.         $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
  208.     }
  209.     $wp_list_table->theme_installer_single( $theme );
  210.     iframe_footer();
  211.     exit;
  212. }
  213.