wp/wp-admin/includes/plugin-install.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   134 	$args = apply_filters( 'plugins_api_args', $args, $action );
   134 	$args = apply_filters( 'plugins_api_args', $args, $action );
   135 
   135 
   136 	/**
   136 	/**
   137 	 * Filters the response for the current WordPress.org Plugin Installation API request.
   137 	 * Filters the response for the current WordPress.org Plugin Installation API request.
   138 	 *
   138 	 *
   139 	 * Passing a non-false value will effectively short-circuit the WordPress.org API request.
   139 	 * Returning a non-false value will effectively short-circuit the WordPress.org API request.
   140 	 *
   140 	 *
   141 	 * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed.
   141 	 * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed.
   142 	 * If `$action` is 'hot_tags' or 'hot_categories', an array should be passed.
   142 	 * If `$action` is 'hot_tags' or 'hot_categories', an array should be passed.
   143 	 *
   143 	 *
   144 	 * @since 2.7.0
   144 	 * @since 2.7.0
   233 	 */
   233 	 */
   234 	return apply_filters( 'plugins_api_result', $res, $action, $args );
   234 	return apply_filters( 'plugins_api_result', $res, $action, $args );
   235 }
   235 }
   236 
   236 
   237 /**
   237 /**
   238  * Retrieve popular WordPress plugin tags.
   238  * Retrieves popular WordPress plugin tags.
   239  *
   239  *
   240  * @since 2.7.0
   240  * @since 2.7.0
   241  *
   241  *
   242  * @param array $args
   242  * @param array $args
   243  * @return array|WP_Error
   243  * @return array|WP_Error
   259 
   259 
   260 	return $tags;
   260 	return $tags;
   261 }
   261 }
   262 
   262 
   263 /**
   263 /**
       
   264  * Displays the Featured tab of Add Plugins screen.
       
   265  *
   264  * @since 2.7.0
   266  * @since 2.7.0
   265  */
   267  */
   266 function install_dashboard() {
   268 function install_dashboard() {
       
   269 	display_plugins_table();
   267 	?>
   270 	?>
   268 	<p>
       
   269 		<?php
       
   270 		printf(
       
   271 			/* translators: %s: https://wordpress.org/plugins/ */
       
   272 			__( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ),
       
   273 			__( 'https://wordpress.org/plugins/' )
       
   274 		);
       
   275 		?>
       
   276 	</p>
       
   277 
       
   278 	<?php display_plugins_table(); ?>
       
   279 
   271 
   280 	<div class="plugins-popular-tags-wrapper">
   272 	<div class="plugins-popular-tags-wrapper">
   281 	<h2><?php _e( 'Popular tags' ); ?></h2>
   273 	<h2><?php _e( 'Popular tags' ); ?></h2>
   282 	<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p>
   274 	<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p>
   283 	<?php
   275 	<?php
   340 	</form>
   332 	</form>
   341 	<?php
   333 	<?php
   342 }
   334 }
   343 
   335 
   344 /**
   336 /**
   345  * Upload from zip
   337  * Displays a form to upload plugins from zip files.
   346  *
   338  *
   347  * @since 2.8.0
   339  * @since 2.8.0
   348  */
   340  */
   349 function install_plugins_upload() {
   341 function install_plugins_upload() {
   350 	?>
   342 	?>
   359 </div>
   351 </div>
   360 	<?php
   352 	<?php
   361 }
   353 }
   362 
   354 
   363 /**
   355 /**
   364  * Show a username form for the favorites page
   356  * Shows a username form for the favorites page.
   365  *
   357  *
   366  * @since 3.5.0
   358  * @since 3.5.0
   367  */
   359  */
   368 function install_plugins_favorites_form() {
   360 function install_plugins_favorites_form() {
   369 	$user   = get_user_option( 'wporg_favorites' );
   361 	$user   = get_user_option( 'wporg_favorites' );
   381 	</form>
   373 	</form>
   382 	<?php
   374 	<?php
   383 }
   375 }
   384 
   376 
   385 /**
   377 /**
   386  * Display plugin content based on plugin list.
   378  * Displays plugin content based on plugin list.
   387  *
   379  *
   388  * @since 2.7.0
   380  * @since 2.7.0
   389  *
   381  *
   390  * @global WP_List_Table $wp_list_table
   382  * @global WP_List_Table $wp_list_table
   391  */
   383  */
   392 function display_plugins_table() {
   384 function display_plugins_table() {
   393 	global $wp_list_table;
   385 	global $wp_list_table;
   394 
   386 
   395 	switch ( current_filter() ) {
   387 	switch ( current_filter() ) {
   396 		case 'install_plugins_favorites':
       
   397 			if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
       
   398 				return;
       
   399 			}
       
   400 			break;
       
   401 		case 'install_plugins_recommended':
       
   402 			echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>';
       
   403 			break;
       
   404 		case 'install_plugins_beta':
   388 		case 'install_plugins_beta':
   405 			printf(
   389 			printf(
   406 				/* translators: %s: URL to "Features as Plugins" page. */
   390 				/* translators: %s: URL to "Features as Plugins" page. */
   407 				'<p>' . __( 'You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.' ) . '</p>',
   391 				'<p>' . __( 'You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.' ) . '</p>',
   408 				'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/'
   392 				'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/'
   409 			);
   393 			);
   410 			break;
   394 			break;
   411 	}
   395 		case 'install_plugins_featured':
   412 
   396 			printf(
       
   397 				/* translators: %s: https://wordpress.org/plugins/ */
       
   398 				'<p>' . __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ) . '</p>',
       
   399 				__( 'https://wordpress.org/plugins/' )
       
   400 			);
       
   401 			break;
       
   402 		case 'install_plugins_recommended':
       
   403 			echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>';
       
   404 			break;
       
   405 		case 'install_plugins_favorites':
       
   406 			if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
       
   407 				return;
       
   408 			}
       
   409 			break;
       
   410 	}
   413 	?>
   411 	?>
   414 	<form id="plugin-filter" method="post">
   412 	<form id="plugin-filter" method="post">
   415 		<?php $wp_list_table->display(); ?>
   413 		<?php $wp_list_table->display(); ?>
   416 	</form>
   414 	</form>
   417 	<?php
   415 	<?php
   418 }
   416 }
   419 
   417 
   420 /**
   418 /**
   421  * Determine the status we can perform on a plugin.
   419  * Determines the status we can perform on a plugin.
   422  *
   420  *
   423  * @since 3.0.0
   421  * @since 3.0.0
   424  *
   422  *
   425  * @param array|object $api  Data about the plugin retrieved from the API.
   423  * @param array|object $api  Data about the plugin retrieved from the API.
   426  * @param bool         $loop Optional. Disable further loops. Default false.
   424  * @param bool         $loop Optional. Disable further loops. Default false.
   506 	$file = $update_file;
   504 	$file = $update_file;
   507 	return compact( 'status', 'url', 'version', 'file' );
   505 	return compact( 'status', 'url', 'version', 'file' );
   508 }
   506 }
   509 
   507 
   510 /**
   508 /**
   511  * Display plugin information in dialog box form.
   509  * Displays plugin information in dialog box form.
   512  *
   510  *
   513  * @since 2.7.0
   511  * @since 2.7.0
   514  *
   512  *
   515  * @global string $tab
   513  * @global string $tab
   516  */
   514  */
   695 					echo number_format_i18n( $api->active_installs ) . '+';
   693 					echo number_format_i18n( $api->active_installs ) . '+';
   696 				}
   694 				}
   697 				?>
   695 				?>
   698 				</li>
   696 				</li>
   699 			<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
   697 			<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
   700 				<li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
   698 				<li><a target="_blank" href="<?php echo esc_url( __( 'https://wordpress.org/plugins/' ) . $api->slug ); ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
   701 			<?php } if ( ! empty( $api->homepage ) ) { ?>
   699 			<?php } if ( ! empty( $api->homepage ) ) { ?>
   702 				<li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
   700 				<li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
   703 			<?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
   701 			<?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
   704 				<li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a></li>
   702 				<li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a></li>
   705 			<?php } ?>
   703 			<?php } ?>