You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

168 lines
6.0 KiB

  1. <?php
  2. /**
  3. * Install plugin administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  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'] ) )
  10. define( 'IFRAME_REQUEST', true );
  11. /**
  12. * WordPress Administration Bootstrap.
  13. */
  14. require_once( dirname( __FILE__ ) . '/admin.php' );
  15. if ( ! current_user_can('install_plugins') )
  16. wp_die(__('Sorry, you are not allowed to install plugins on this site.'));
  17. if ( is_multisite() && ! is_network_admin() ) {
  18. wp_redirect( network_admin_url( 'plugin-install.php' ) );
  19. exit();
  20. }
  21. $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
  22. $pagenum = $wp_list_table->get_pagenum();
  23. if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
  24. $location = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
  25. if ( ! empty( $_REQUEST['paged'] ) ) {
  26. $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
  27. }
  28. wp_redirect( $location );
  29. exit;
  30. }
  31. $wp_list_table->prepare_items();
  32. $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
  33. if ( $pagenum > $total_pages && $total_pages > 0 ) {
  34. wp_redirect( add_query_arg( 'paged', $total_pages ) );
  35. exit;
  36. }
  37. $title = __( 'Add Plugins' );
  38. $parent_file = 'plugins.php';
  39. wp_enqueue_script( 'plugin-install' );
  40. if ( 'plugin-information' != $tab )
  41. add_thickbox();
  42. $body_id = $tab;
  43. wp_enqueue_script( 'updates' );
  44. /**
  45. * Fires before each tab on the Install Plugins screen is loaded.
  46. *
  47. * The dynamic portion of the action hook, `$tab`, allows for targeting
  48. * individual tabs, for instance 'install_plugins_pre_plugin-information'.
  49. *
  50. * @since 2.7.0
  51. */
  52. do_action( "install_plugins_pre_{$tab}" );
  53. /*
  54. * Call the pre upload action on every non-upload plugin install screen
  55. * because the form is always displayed on these screens.
  56. */
  57. if ( 'upload' !== $tab ) {
  58. /** This action is documented in wp-admin/plugin-install.php */
  59. do_action( 'install_plugins_pre_upload' );
  60. }
  61. get_current_screen()->add_help_tab( array(
  62. 'id' => 'overview',
  63. 'title' => __('Overview'),
  64. 'content' =>
  65. '<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>' .
  66. '<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>'
  67. ) );
  68. get_current_screen()->add_help_tab( array(
  69. 'id' => 'adding-plugins',
  70. 'title' => __('Adding Plugins'),
  71. 'content' =>
  72. '<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>' .
  73. '<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>' .
  74. '<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>' .
  75. '<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>'
  76. ) );
  77. get_current_screen()->set_help_sidebar(
  78. '<p><strong>' . __('For more information:') . '</strong></p>' .
  79. '<p>' . __('<a href="https://codex.wordpress.org/Plugins_Add_New_Screen">Documentation on Installing Plugins</a>') . '</p>' .
  80. '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
  81. );
  82. get_current_screen()->set_screen_reader_content( array(
  83. 'heading_views' => __( 'Filter plugins list' ),
  84. 'heading_pagination' => __( 'Plugins list navigation' ),
  85. 'heading_list' => __( 'Plugins list' ),
  86. ) );
  87. /**
  88. * WordPress Administration Template Header.
  89. */
  90. include(ABSPATH . 'wp-admin/admin-header.php');
  91. ?>
  92. <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
  93. <h1>
  94. <?php
  95. echo esc_html( $title );
  96. if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
  97. printf( ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>',
  98. ( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
  99. __( 'Upload Plugin' ),
  100. __( 'Browse Plugins' )
  101. );
  102. }
  103. ?>
  104. </h1>
  105. <?php
  106. /*
  107. * Output the upload plugin form on every non-upload plugin install screen, so it can be
  108. * displayed via JavaScript rather then opening up the devoted upload plugin page.
  109. */
  110. if ( 'upload' !== $tab ) {
  111. ?>
  112. <div class="upload-plugin-wrap">
  113. <?php
  114. /** This action is documented in wp-admin/plugin-install.php */
  115. do_action( 'install_plugins_upload' );
  116. ?>
  117. </div>
  118. <?php
  119. $wp_list_table->views();
  120. echo '<br class="clear" />';
  121. }
  122. /**
  123. * Fires after the plugins list table in each tab of the Install Plugins screen.
  124. *
  125. * The dynamic portion of the action hook, `$tab`, allows for targeting
  126. * individual tabs, for instance 'install_plugins_plugin-information'.
  127. *
  128. * @since 2.7.0
  129. *
  130. * @param int $paged The current page number of the plugins list table.
  131. */
  132. do_action( "install_plugins_{$tab}", $paged ); ?>
  133. <span class="spinner"></span>
  134. </div>
  135. <?php
  136. wp_print_request_filesystem_credentials_modal();
  137. wp_print_admin_notice_templates();
  138. /**
  139. * WordPress Administration Template Footer.
  140. */
  141. include(ABSPATH . 'wp-admin/admin-footer.php');