wp/wp-admin/plugin-install.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 // TODO route this pages via a specific iframe handler instead of the do_action below
     8 // TODO route this pages via a specific iframe handler instead of the do_action below
     9 if ( !defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) )
     9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) ) {
    10 	define( 'IFRAME_REQUEST', true );
    10 	define( 'IFRAME_REQUEST', true );
       
    11 }
    11 
    12 
    12 /**
    13 /**
    13  * WordPress Administration Bootstrap.
    14  * WordPress Administration Bootstrap.
    14  */
    15  */
    15 require_once( dirname( __FILE__ ) . '/admin.php' );
    16 require_once( dirname( __FILE__ ) . '/admin.php' );
    16 
    17 
    17 if ( ! current_user_can('install_plugins') )
    18 if ( ! current_user_can( 'install_plugins' ) ) {
    18 	wp_die(__('Sorry, you are not allowed to install plugins on this site.'));
    19 	wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
       
    20 }
    19 
    21 
    20 if ( is_multisite() && ! is_network_admin() ) {
    22 if ( is_multisite() && ! is_network_admin() ) {
    21 	wp_redirect( network_admin_url( 'plugin-install.php' ) );
    23 	wp_redirect( network_admin_url( 'plugin-install.php' ) );
    22 	exit();
    24 	exit();
    23 }
    25 }
    24 
    26 
    25 $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
    27 $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table' );
    26 $pagenum = $wp_list_table->get_pagenum();
    28 $pagenum       = $wp_list_table->get_pagenum();
    27 
    29 
    28 if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
    30 if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
    29 	$location = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
    31 	$location = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
    30 
    32 
    31 	if ( ! empty( $_REQUEST['paged'] ) ) {
    33 	if ( ! empty( $_REQUEST['paged'] ) ) {
    43 if ( $pagenum > $total_pages && $total_pages > 0 ) {
    45 if ( $pagenum > $total_pages && $total_pages > 0 ) {
    44 	wp_redirect( add_query_arg( 'paged', $total_pages ) );
    46 	wp_redirect( add_query_arg( 'paged', $total_pages ) );
    45 	exit;
    47 	exit;
    46 }
    48 }
    47 
    49 
    48 $title = __( 'Add Plugins' );
    50 $title       = __( 'Add Plugins' );
    49 $parent_file = 'plugins.php';
    51 $parent_file = 'plugins.php';
    50 
    52 
    51 wp_enqueue_script( 'plugin-install' );
    53 wp_enqueue_script( 'plugin-install' );
    52 if ( 'plugin-information' != $tab )
    54 if ( 'plugin-information' != $tab ) {
    53 	add_thickbox();
    55 	add_thickbox();
       
    56 }
    54 
    57 
    55 $body_id = $tab;
    58 $body_id = $tab;
    56 
    59 
    57 wp_enqueue_script( 'updates' );
    60 wp_enqueue_script( 'updates' );
    58 
    61 
    73 if ( 'upload' !== $tab ) {
    76 if ( 'upload' !== $tab ) {
    74 	/** This action is documented in wp-admin/plugin-install.php */
    77 	/** This action is documented in wp-admin/plugin-install.php */
    75 	do_action( 'install_plugins_pre_upload' );
    78 	do_action( 'install_plugins_pre_upload' );
    76 }
    79 }
    77 
    80 
    78 get_current_screen()->add_help_tab( array(
    81 get_current_screen()->add_help_tab(
    79 'id'		=> 'overview',
    82 	array(
    80 'title'		=> __('Overview'),
    83 		'id'      => 'overview',
    81 'content'	=>
    84 		'title'   => __( 'Overview' ),
    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>' .
    85 		'content' =>
    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>'
    86 				 '<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>' .
       
    87 				 '<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 
    88 
    85 ) );
    89 	)
    86 get_current_screen()->add_help_tab( array(
    90 );
    87 'id'		=> 'adding-plugins',
    91 get_current_screen()->add_help_tab(
    88 'title'		=> __('Adding Plugins'),
    92 	array(
    89 'content'	=>
    93 		'id'      => 'adding-plugins',
    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>' .
    94 		'title'   => __( 'Adding Plugins' ),
    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>' .
    95 		'content' =>
    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>' .
    96 				 '<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>' .
    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>'
    97 				 '<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>' .
    94 ) );
    98 				 '<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>' .
       
    99 				 '<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>',
       
   100 	)
       
   101 );
    95 
   102 
    96 get_current_screen()->set_help_sidebar(
   103 get_current_screen()->set_help_sidebar(
    97 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   104 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    98 	'<p>' . __('<a href="https://codex.wordpress.org/Plugins_Add_New_Screen">Documentation on Installing Plugins</a>') . '</p>' .
   105 	'<p>' . __( '<a href="https://codex.wordpress.org/Plugins_Add_New_Screen">Documentation on Installing Plugins</a>' ) . '</p>' .
    99 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
   106 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   100 );
   107 );
   101 
   108 
   102 get_current_screen()->set_screen_reader_content( array(
   109 get_current_screen()->set_screen_reader_content(
   103 	'heading_views'      => __( 'Filter plugins list' ),
   110 	array(
   104 	'heading_pagination' => __( 'Plugins list navigation' ),
   111 		'heading_views'      => __( 'Filter plugins list' ),
   105 	'heading_list'       => __( 'Plugins list' ),
   112 		'heading_pagination' => __( 'Plugins list navigation' ),
   106 ) );
   113 		'heading_list'       => __( 'Plugins list' ),
       
   114 	)
       
   115 );
   107 
   116 
   108 /**
   117 /**
   109  * WordPress Administration Template Header.
   118  * WordPress Administration Template Header.
   110  */
   119  */
   111 include(ABSPATH . 'wp-admin/admin-header.php');
   120 include( ABSPATH . 'wp-admin/admin-header.php' );
   112 ?>
   121 ?>
   113 <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
   122 <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
   114 <h1 class="wp-heading-inline"><?php
   123 <h1 class="wp-heading-inline">
       
   124 <?php
   115 echo esc_html( $title );
   125 echo esc_html( $title );
   116 ?></h1>
   126 ?>
       
   127 </h1>
   117 
   128 
   118 <?php
   129 <?php
   119 if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
   130 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>',
   131 	printf(
       
   132 		' <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' ),
   133 		( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
   122 		__( 'Upload Plugin' ),
   134 		__( 'Upload Plugin' ),
   123 		__( 'Browse Plugins' )
   135 		__( 'Browse Plugins' )
   124 	);
   136 	);
   125 }
   137 }
   153  *
   165  *
   154  * @since 2.7.0
   166  * @since 2.7.0
   155  *
   167  *
   156  * @param int $paged The current page number of the plugins list table.
   168  * @param int $paged The current page number of the plugins list table.
   157  */
   169  */
   158 do_action( "install_plugins_{$tab}", $paged ); ?>
   170 do_action( "install_plugins_{$tab}", $paged );
       
   171 ?>
   159 
   172 
   160 	<span class="spinner"></span>
   173 	<span class="spinner"></span>
   161 </div>
   174 </div>
   162 
   175 
   163 <?php
   176 <?php
   165 wp_print_admin_notice_templates();
   178 wp_print_admin_notice_templates();
   166 
   179 
   167 /**
   180 /**
   168  * WordPress Administration Template Footer.
   181  * WordPress Administration Template Footer.
   169  */
   182  */
   170 include(ABSPATH . 'wp-admin/admin-footer.php');
   183 include( ABSPATH . 'wp-admin/admin-footer.php' );