wp/wp-admin/includes/theme-install.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * WordPress Theme Install Administration API
     3  * WordPress Theme Installation Administration API
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
    27  * @deprecated since 3.1.0 Use get_theme_feature_list() instead.
    27  * @deprecated since 3.1.0 Use get_theme_feature_list() instead.
    28  *
    28  *
    29  * @return array
    29  * @return array
    30  */
    30  */
    31 function install_themes_feature_list() {
    31 function install_themes_feature_list() {
    32 	_deprecated_function( __FUNCTION__, '3.1', 'get_theme_feature_list()' );
    32 	_deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );
    33 
    33 
    34 	if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
    34 	if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
    35 		set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
    35 		set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
    36 
    36 
    37 	if ( $cache )
    37 	if ( $cache )
    48 
    48 
    49 /**
    49 /**
    50  * Display search form for searching themes.
    50  * Display search form for searching themes.
    51  *
    51  *
    52  * @since 2.8.0
    52  * @since 2.8.0
       
    53  *
       
    54  * @param bool $type_selector
    53  */
    55  */
    54 function install_theme_search_form( $type_selector = true ) {
    56 function install_theme_search_form( $type_selector = true ) {
    55 	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
    57 	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
    56 	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
    58 	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
    57 	if ( ! $type_selector )
    59 	if ( ! $type_selector )
    81 	?></label>
    83 	?></label>
    82 	<?php else : ?>
    84 	<?php else : ?>
    83 	<label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
    85 	<label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
    84 	<?php endif; ?>
    86 	<?php endif; ?>
    85 	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
    87 	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
    86 	<?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
    88 	<?php submit_button( __( 'Search' ), '', 'search', false ); ?>
    87 </form>
    89 </form>
    88 <?php
    90 <?php
    89 }
    91 }
    90 
    92 
    91 /**
    93 /**
   126 <?php
   128 <?php
   127 	} ?>
   129 	} ?>
   128 
   130 
   129 </div>
   131 </div>
   130 <br class="clear" />
   132 <br class="clear" />
   131 <?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?>
   133 <?php submit_button( __( 'Find Themes' ), '', 'search' ); ?>
   132 </form>
   134 </form>
   133 <?php
   135 <?php
   134 }
   136 }
   135 // add_action('install_themes_dashboard', 'install_themes_dashboard');
   137 
   136 
   138 /**
       
   139  * @since 2.8.0
       
   140  */
   137 function install_themes_upload() {
   141 function install_themes_upload() {
   138 ?>
   142 ?>
   139 <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p>
   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>
   140 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
   144 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
   141 	<?php wp_nonce_field( 'theme-upload'); ?>
   145 	<?php wp_nonce_field( 'theme-upload' ); ?>
   142 	<input type="file" name="themezip" />
   146 	<label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label>
   143 	<?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
   147 	<input type="file" id="themezip" name="themezip" />
       
   148 	<?php submit_button( __( 'Install Now' ), '', 'install-theme-submit', false ); ?>
   144 </form>
   149 </form>
   145 	<?php
   150 	<?php
   146 }
   151 }
   147 // add_action('install_themes_upload', 'install_themes_upload', 10, 0);
       
   148 
   152 
   149 /**
   153 /**
   150  * Prints a theme on the Install Themes pages.
   154  * Prints a theme on the Install Themes pages.
   151  *
   155  *
   152  * @deprecated 3.4.0
   156  * @deprecated 3.4.0
       
   157  *
       
   158  * @global WP_Theme_Install_List_Table $wp_list_table
       
   159  *
       
   160  * @param object $theme
   153  */
   161  */
   154 function display_theme( $theme ) {
   162 function display_theme( $theme ) {
   155 	_deprecated_function( __FUNCTION__, '3.4' );
   163 	_deprecated_function( __FUNCTION__, '3.4.0' );
   156 	global $wp_list_table;
   164 	global $wp_list_table;
   157 	if ( ! isset( $wp_list_table ) ) {
   165 	if ( ! isset( $wp_list_table ) ) {
   158 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
   166 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
   159 	}
   167 	}
   160 	$wp_list_table->prepare_items();
   168 	$wp_list_table->prepare_items();
   163 
   171 
   164 /**
   172 /**
   165  * Display theme content based on theme list.
   173  * Display theme content based on theme list.
   166  *
   174  *
   167  * @since 2.8.0
   175  * @since 2.8.0
       
   176  *
       
   177  * @global WP_Theme_Install_List_Table $wp_list_table
   168  */
   178  */
   169 function display_themes() {
   179 function display_themes() {
   170 	global $wp_list_table;
   180 	global $wp_list_table;
   171 
   181 
   172 	if ( ! isset( $wp_list_table ) ) {
   182 	if ( ! isset( $wp_list_table ) ) {
   174 	}
   184 	}
   175 	$wp_list_table->prepare_items();
   185 	$wp_list_table->prepare_items();
   176 	$wp_list_table->display();
   186 	$wp_list_table->display();
   177 
   187 
   178 }
   188 }
   179 // add_action('install_themes_search', 'display_themes');
       
   180 // add_action('install_themes_featured', 'display_themes');
       
   181 // add_action('install_themes_new', 'display_themes');
       
   182 // add_action('install_themes_updated', 'display_themes');
       
   183 
   189 
   184 /**
   190 /**
   185  * Display theme information in dialog box form.
   191  * Display theme information in dialog box form.
   186  *
   192  *
   187  * @since 2.8.0
   193  * @since 2.8.0
       
   194  *
       
   195  * @global WP_Theme_Install_List_Table $wp_list_table
   188  */
   196  */
   189 function install_theme_information() {
   197 function install_theme_information() {
   190 	global $wp_list_table;
   198 	global $wp_list_table;
   191 
   199 
   192 	$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
   200 	$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
   193 
   201 
   194 	if ( is_wp_error( $theme ) )
   202 	if ( is_wp_error( $theme ) )
   195 		wp_die( $theme );
   203 		wp_die( $theme );
   196 
   204 
   197 	iframe_header( __('Theme Install') );
   205 	iframe_header( __('Theme Installation') );
   198 	if ( ! isset( $wp_list_table ) ) {
   206 	if ( ! isset( $wp_list_table ) ) {
   199 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
   207 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
   200 	}
   208 	}
   201 	$wp_list_table->theme_installer_single( $theme );
   209 	$wp_list_table->theme_installer_single( $theme );
   202 	iframe_footer();
   210 	iframe_footer();
   203 	exit;
   211 	exit;
   204 }
   212 }
   205 add_action('install_themes_pre_theme-information', 'install_theme_information');