web/wp-admin/includes/plugin-install.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    72 	$tags = plugins_api('hot_tags', $args);
    72 	$tags = plugins_api('hot_tags', $args);
    73 
    73 
    74 	if ( is_wp_error($tags) )
    74 	if ( is_wp_error($tags) )
    75 		return $tags;
    75 		return $tags;
    76 
    76 
    77 	set_site_transient('poptags_' . $key, $tags, 10800); // 3 * 60 * 60 = 10800
    77 	set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS );
    78 
    78 
    79 	return $tags;
    79 	return $tags;
    80 }
    80 }
    81 
    81 
    82 function install_dashboard() {
    82 function install_dashboard() {
   126 			<option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
   126 			<option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
   127 			<option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
   127 			<option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
   128 			<option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
   128 			<option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
   129 		</select>
   129 		</select>
   130 		<?php endif; ?>
   130 		<?php endif; ?>
   131 		<input type="search" name="s" value="<?php echo esc_attr($term) ?>" />
   131 		<input type="search" name="s" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
   132 		<label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label>
   132 		<label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label>
   133 		<?php submit_button( __( 'Search Plugins' ), 'button', 'plugin-search-input', false ); ?>
   133 		<?php submit_button( __( 'Search Plugins' ), 'button', 'plugin-search-input', false ); ?>
   134 	</form><?php
   134 	</form><?php
   135 }
   135 }
   136 
   136 
   140  *
   140  *
   141  * @param string $page
   141  * @param string $page
   142  */
   142  */
   143 function install_plugins_upload( $page = 1 ) {
   143 function install_plugins_upload( $page = 1 ) {
   144 ?>
   144 ?>
   145 	<h4><?php _e('Install a plugin in .zip format') ?></h4>
   145 	<h4><?php _e('Install a plugin in .zip format'); ?></h4>
   146 	<p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.') ?></p>
   146 	<p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>
   147 	<form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-plugin') ?>">
   147 	<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>">
   148 		<?php wp_nonce_field( 'plugin-upload') ?>
   148 		<?php wp_nonce_field( 'plugin-upload'); ?>
   149 		<label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label>
   149 		<label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label>
   150 		<input type="file" id="pluginzip" name="pluginzip" />
   150 		<input type="file" id="pluginzip" name="pluginzip" />
   151 		<input type="submit" class="button" value="<?php esc_attr_e('Install Now') ?>" />
   151 		<?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?>
   152 	</form>
   152 	</form>
   153 <?php
   153 <?php
   154 }
   154 }
   155 add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
   155 add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
   156 
   156 
   157 /**
   157 /**
       
   158  * Show a username form for the favorites page
       
   159  * @since 3.5.0
       
   160  *
       
   161  */
       
   162 function install_plugins_favorites_form() {
       
   163 	$user = ! empty( $_GET['user'] ) ? stripslashes( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
       
   164 	?>
       
   165 	<p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p>
       
   166 	<form method="get" action="">
       
   167 		<input type="hidden" name="tab" value="favorites" />
       
   168 		<p>
       
   169 			<label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label>
       
   170 			<input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" />
       
   171 			<input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" />
       
   172 		</p>
       
   173 	</form>
       
   174 	<?php
       
   175 }
       
   176 
       
   177 /**
   158  * Display plugin content based on plugin list.
   178  * Display plugin content based on plugin list.
   159  *
   179  *
   160  * @since 2.7.0
   180  * @since 2.7.0
   161  */
   181  */
   162 function display_plugins_table() {
   182 function display_plugins_table() {
   163 	global $wp_list_table;
   183 	global $wp_list_table;
   164 
   184 
       
   185 	if ( current_filter() == 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) )
       
   186 			return;
       
   187 
   165 	$wp_list_table->display();
   188 	$wp_list_table->display();
   166 }
   189 }
   167 add_action('install_plugins_search', 'display_plugins_table');
   190 add_action( 'install_plugins_search',    'display_plugins_table' );
   168 add_action('install_plugins_featured', 'display_plugins_table');
   191 add_action( 'install_plugins_featured',  'display_plugins_table' );
   169 add_action('install_plugins_popular', 'display_plugins_table');
   192 add_action( 'install_plugins_popular',   'display_plugins_table' );
   170 add_action('install_plugins_new', 'display_plugins_table');
   193 add_action( 'install_plugins_new',       'display_plugins_table' );
       
   194 add_action( 'install_plugins_favorites', 'display_plugins_table' );
   171 
   195 
   172 /**
   196 /**
   173  * Determine the status we can perform on a plugin.
   197  * Determine the status we can perform on a plugin.
   174  *
   198  *
   175  * @since 3.0.0
   199  * @since 3.0.0