wp/wp-admin/plugin-install.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    13  * WordPress Administration Bootstrap.
    13  * WordPress Administration Bootstrap.
    14  */
    14  */
    15 require_once( dirname( __FILE__ ) . '/admin.php' );
    15 require_once( dirname( __FILE__ ) . '/admin.php' );
    16 
    16 
    17 if ( ! current_user_can('install_plugins') )
    17 if ( ! current_user_can('install_plugins') )
    18 	wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
    18 	wp_die(__('Sorry, you are not allowed to install plugins on this site.'));
    19 
    19 
    20 if ( is_multisite() && ! is_network_admin() ) {
    20 if ( is_multisite() && ! is_network_admin() ) {
    21 	wp_redirect( network_admin_url( 'plugin-install.php' ) );
    21 	wp_redirect( network_admin_url( 'plugin-install.php' ) );
    22 	exit();
    22 	exit();
    23 }
    23 }
    62  * The dynamic portion of the action hook, `$tab`, allows for targeting
    62  * The dynamic portion of the action hook, `$tab`, allows for targeting
    63  * individual tabs, for instance 'install_plugins_pre_plugin-information'.
    63  * individual tabs, for instance 'install_plugins_pre_plugin-information'.
    64  *
    64  *
    65  * @since 2.7.0
    65  * @since 2.7.0
    66  */
    66  */
    67 do_action( "install_plugins_pre_$tab" );
    67 do_action( "install_plugins_pre_{$tab}" );
       
    68 
       
    69 /*
       
    70  * Call the pre upload action on every non-upload plugin installation screen
       
    71  * because the form is always displayed on these screens.
       
    72  */
       
    73 if ( 'upload' !== $tab ) {
       
    74 	/** This action is documented in wp-admin/plugin-install.php */
       
    75 	do_action( 'install_plugins_pre_upload' );
       
    76 }
    68 
    77 
    69 get_current_screen()->add_help_tab( array(
    78 get_current_screen()->add_help_tab( array(
    70 'id'		=> 'overview',
    79 'id'		=> 'overview',
    71 'title'		=> __('Overview'),
    80 'title'		=> __('Overview'),
    72 'content'	=>
    81 'content'	=>
    73 	'<p>' . sprintf(__('Plugins hook into WordPress to extend its functionality with custom features. Plugins are developed independently from the core WordPress application by thousands of developers all over the world. All plugins in the official <a href="%s" target="_blank">WordPress.org Plugin Directory</a> are compatible with the license WordPress uses. You can find new plugins to install by searching or browsing the Directory right here in your own Plugins section.'), 'https://wordpress.org/plugins/') . '</p>'
    82 	'<p>' . sprintf( __('Plugins hook into WordPress to extend its functionality with custom features. Plugins are developed independently from the core WordPress application by thousands of developers all over the world. All plugins in the official <a href="%s">WordPress Plugin Directory</a> are compatible with the license WordPress uses.' ), __( 'https://wordpress.org/plugins/' ) ) . '</p>' .
       
    83 	'<p>' . __( 'You can find new plugins to install by searching or browsing the directory right here in your own Plugins section.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>'
       
    84 
    74 ) );
    85 ) );
    75 get_current_screen()->add_help_tab( array(
    86 get_current_screen()->add_help_tab( array(
    76 'id'		=> 'adding-plugins',
    87 'id'		=> 'adding-plugins',
    77 'title'		=> __('Adding Plugins'),
    88 'title'		=> __('Adding Plugins'),
    78 'content'	=>
    89 'content'	=>
    79 	'<p>' . __('If you know what you&#8217;re looking for, Search is your best bet. The Search screen has options to search the WordPress.org Plugin Directory for a particular Term, Author, or Tag. You can also search the directory by selecting popular tags. Tags in larger type mean more plugins have been labeled with that tag.') . '</p>' .
    90 	'<p>' . __('If you know what you&#8217;re looking for, Search is your best bet. The Search screen has options to search the WordPress Plugin Directory for a particular Term, Author, or Tag. You can also search the directory by selecting popular tags. Tags in larger type mean more plugins have been labeled with that tag.') . '</p>' .
    80 	'<p>' . __('If you just want to get an idea of what&#8217;s available, you can browse Featured and Popular plugins by using the links in the upper left of the screen. These sections rotate regularly.') . '</p>' .
    91 	'<p>' . __( 'If you just want to get an idea of what&#8217;s available, you can browse Featured and Popular plugins by using the links above the plugins list. These sections rotate regularly.' ) . '</p>' .
    81 	'<p>' . __('You can also browse a user&#8217;s favorite plugins, by using the Favorites link in the upper left of the screen and entering their WordPress.org username.') . '</p>' .
    92 	'<p>' . __( 'You can also browse a user&#8217;s favorite plugins, by using the Favorites link above the plugins list and entering their WordPress.org username.' ) . '</p>' .
    82 	'<p>' . __('If you want to install a plugin that you&#8217;ve downloaded elsewhere, click the Upload link in the upper left. You will be prompted to upload the .zip package, and once uploaded, you can activate the new plugin.') . '</p>'
    93 	'<p>' . __( 'If you want to install a plugin that you&#8217;ve downloaded elsewhere, click the Upload Plugin button above the plugins list. You will be prompted to upload the .zip package, and once uploaded, you can activate the new plugin.' ) . '</p>'
    83 ) );
    94 ) );
    84 
    95 
    85 get_current_screen()->set_help_sidebar(
    96 get_current_screen()->set_help_sidebar(
    86 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    97 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    87 	'<p>' . __('<a href="https://codex.wordpress.org/Plugins_Add_New_Screen" target="_blank">Documentation on Installing Plugins</a>') . '</p>' .
    98 	'<p>' . __('<a href="https://codex.wordpress.org/Plugins_Add_New_Screen">Documentation on Installing Plugins</a>') . '</p>' .
    88 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    99 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    89 );
   100 );
       
   101 
       
   102 get_current_screen()->set_screen_reader_content( array(
       
   103 	'heading_views'      => __( 'Filter plugins list' ),
       
   104 	'heading_pagination' => __( 'Plugins list navigation' ),
       
   105 	'heading_list'       => __( 'Plugins list' ),
       
   106 ) );
    90 
   107 
    91 /**
   108 /**
    92  * WordPress Administration Template Header.
   109  * WordPress Administration Template Header.
    93  */
   110  */
    94 include(ABSPATH . 'wp-admin/admin-header.php');
   111 include(ABSPATH . 'wp-admin/admin-header.php');
    95 ?>
   112 ?>
    96 <div class="wrap">
   113 <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
    97 <h2>
   114 <h1 class="wp-heading-inline"><?php
    98 	<?php
   115 echo esc_html( $title );
    99 	echo esc_html( $title );
   116 ?></h1>
   100 	if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
       
   101 		if ( $tab === 'upload' ) {
       
   102 			$href = self_admin_url( 'plugin-install.php' );
       
   103 			$text = _x( 'Browse', 'plugins' );
       
   104 		} else {
       
   105 			$href = self_admin_url( 'plugin-install.php?tab=upload' );
       
   106 			$text = __( 'Upload Plugin' );
       
   107 		}
       
   108 		echo ' <a href="' . $href . '" class="upload add-new-h2">' . $text . '</a>';
       
   109 	}
       
   110 	?>
       
   111 </h2>
       
   112 
   117 
   113 <?php
   118 <?php
   114 if ( $tab !== 'upload' ) {
   119 if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
       
   120 	printf( ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>',
       
   121 		( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
       
   122 		__( 'Upload Plugin' ),
       
   123 		__( 'Browse Plugins' )
       
   124 	);
       
   125 }
       
   126 ?>
       
   127 
       
   128 <hr class="wp-header-end">
       
   129 
       
   130 <?php
       
   131 /*
       
   132  * Output the upload plugin form on every non-upload plugin installation screen, so it can be
       
   133  * displayed via JavaScript rather then opening up the devoted upload plugin page.
       
   134  */
       
   135 if ( 'upload' !== $tab ) {
       
   136 	?>
       
   137 	<div class="upload-plugin-wrap">
       
   138 		<?php
       
   139 		/** This action is documented in wp-admin/plugin-install.php */
       
   140 		do_action( 'install_plugins_upload' );
       
   141 		?>
       
   142 	</div>
       
   143 	<?php
   115 	$wp_list_table->views();
   144 	$wp_list_table->views();
   116 	echo '<br class="clear" />';
   145 	echo '<br class="clear" />';
   117 }
   146 }
   118 
   147 
   119 /**
   148 /**
   124  *
   153  *
   125  * @since 2.7.0
   154  * @since 2.7.0
   126  *
   155  *
   127  * @param int $paged The current page number of the plugins list table.
   156  * @param int $paged The current page number of the plugins list table.
   128  */
   157  */
   129 do_action( "install_plugins_$tab", $paged ); ?>
   158 do_action( "install_plugins_{$tab}", $paged ); ?>
       
   159 
       
   160 	<span class="spinner"></span>
   130 </div>
   161 </div>
   131 
   162 
   132 <?php
   163 <?php
   133 wp_print_request_filesystem_credentials_modal();
   164 wp_print_request_filesystem_credentials_modal();
       
   165 wp_print_admin_notice_templates();
   134 
   166 
   135 /**
   167 /**
   136  * WordPress Administration Template Footer.
   168  * WordPress Administration Template Footer.
   137  */
   169  */
   138 include(ABSPATH . 'wp-admin/admin-footer.php');
   170 include(ABSPATH . 'wp-admin/admin-footer.php');