[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> plugin-install.php (source)

   1  <?php
   2  /**
   3   * Install plugin administration panel.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  // TODO: Route this page 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  
  13  /**
  14   * WordPress Administration Bootstrap.
  15   */
  16  require_once  __DIR__ . '/admin.php';
  17  
  18  if ( ! current_user_can( 'install_plugins' ) ) {
  19      wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
  20  }
  21  
  22  if ( is_multisite() && ! is_network_admin() ) {
  23      wp_redirect( network_admin_url( 'plugin-install.php' ) );
  24      exit;
  25  }
  26  
  27  $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table' );
  28  $pagenum       = $wp_list_table->get_pagenum();
  29  
  30  if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
  31      $location = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
  32  
  33      if ( ! empty( $_REQUEST['paged'] ) ) {
  34          $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
  35      }
  36  
  37      wp_redirect( $location );
  38      exit;
  39  }
  40  
  41  $wp_list_table->prepare_items();
  42  
  43  /**
  44   * WP_Plugin_Install_List_Table::prepare_items() populates these globals, which
  45   * are used throughout the rest of this file.
  46   *
  47   * @global string $tab   The current tab of the Install Plugins screen.
  48   * @global int    $paged The current page number of the plugins list.
  49   */
  50  global $tab, $paged;
  51  
  52  $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
  53  
  54  if ( $pagenum > $total_pages && $total_pages > 0 ) {
  55      wp_redirect( add_query_arg( 'paged', $total_pages ) );
  56      exit;
  57  }
  58  
  59  // Used in the HTML title tag.
  60  $title       = __( 'Add Plugins' );
  61  $parent_file = 'plugins.php';
  62  
  63  wp_enqueue_script( 'plugin-install' );
  64  if ( 'plugin-information' !== $tab ) {
  65      add_thickbox();
  66  }
  67  
  68  $body_id = $tab;
  69  
  70  wp_enqueue_script( 'updates' );
  71  
  72  /**
  73   * Fires before each tab on the Install Plugins screen is loaded.
  74   *
  75   * The dynamic portion of the hook name, `$tab`, allows for targeting
  76   * individual tabs.
  77   *
  78   * Possible hook names include:
  79   *
  80   *  - `install_plugins_pre_beta`
  81   *  - `install_plugins_pre_favorites`
  82   *  - `install_plugins_pre_featured`
  83   *  - `install_plugins_pre_plugin-information`
  84   *  - `install_plugins_pre_popular`
  85   *  - `install_plugins_pre_recommended`
  86   *  - `install_plugins_pre_search`
  87   *  - `install_plugins_pre_upload`
  88   *
  89   * @since 2.7.0
  90   */
  91  do_action( "install_plugins_pre_{$tab}" );
  92  
  93  /*
  94   * Call the pre upload action on every non-upload plugin installation screen
  95   * because the form is always displayed on these screens.
  96   */
  97  if ( 'upload' !== $tab ) {
  98      /** This action is documented in wp-admin/plugin-install.php */
  99      do_action( 'install_plugins_pre_upload' );
 100  }
 101  
 102  get_current_screen()->add_help_tab(
 103      array(
 104          'id'      => 'overview',
 105          'title'   => __( 'Overview' ),
 106          'content' =>
 107                  '<p>' . sprintf(
 108                      /* translators: %s: https://wordpress.org/plugins/ */
 109                      __( '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.' ),
 110                      __( 'https://wordpress.org/plugins/' )
 111                  ) . '</p>' .
 112                  '<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>',
 113  
 114      )
 115  );
 116  get_current_screen()->add_help_tab(
 117      array(
 118          'id'      => 'adding-plugins',
 119          'title'   => __( 'Adding Plugins' ),
 120          'content' =>
 121                  '<p>' . __( 'If you know what you are 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>' .
 122                  '<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>' .
 123                  '<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>' .
 124                  '<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>',
 125      )
 126  );
 127  
 128  get_current_screen()->set_help_sidebar(
 129      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 130      '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-add-new-screen/">Documentation on Installing Plugins</a>' ) . '</p>' .
 131      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 132  );
 133  
 134  get_current_screen()->set_screen_reader_content(
 135      array(
 136          'heading_views'      => __( 'Filter plugins list' ),
 137          'heading_pagination' => __( 'Plugins list navigation' ),
 138          'heading_list'       => __( 'Plugins list' ),
 139      )
 140  );
 141  
 142  /**
 143   * WordPress Administration Template Header.
 144   */
 145  require_once  ABSPATH . 'wp-admin/admin-header.php';
 146  
 147  WP_Plugin_Dependencies::initialize();
 148  WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies();
 149  WP_Plugin_Dependencies::display_admin_notice_for_circular_dependencies();
 150  ?>
 151  <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
 152  <h1 class="wp-heading-inline">
 153  <?php
 154  echo esc_html( $title );
 155  ?>
 156  </h1>
 157  
 158  <?php
 159  if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
 160      printf(
 161          ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>',
 162          ( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
 163          __( 'Upload Plugin' ),
 164          __( 'Browse Plugins' )
 165      );
 166  }
 167  ?>
 168  
 169  <hr class="wp-header-end">
 170  
 171  <?php
 172  /*
 173   * Output the upload plugin form on every non-upload plugin installation screen, so it can be
 174   * displayed via JavaScript rather then opening up the devoted upload plugin page.
 175   */
 176  if ( 'upload' !== $tab ) {
 177      ?>
 178      <div class="upload-plugin-wrap">
 179          <?php
 180          /** This action is documented in wp-admin/plugin-install.php */
 181          do_action( 'install_plugins_upload', $paged );
 182          ?>
 183      </div>
 184      <?php
 185      $wp_list_table->views();
 186  }
 187  
 188  /**
 189   * Fires after the plugins list table in each tab of the Install Plugins screen.
 190   *
 191   * The dynamic portion of the hook name, `$tab`, allows for targeting
 192   * individual tabs.
 193   *
 194   * Possible hook names include:
 195   *
 196   *  - `install_plugins_beta`
 197   *  - `install_plugins_favorites`
 198   *  - `install_plugins_featured`
 199   *  - `install_plugins_plugin-information`
 200   *  - `install_plugins_popular`
 201   *  - `install_plugins_recommended`
 202   *  - `install_plugins_search`
 203   *  - `install_plugins_upload`
 204   *
 205   * @since 2.7.0
 206   *
 207   * @param int $paged The current page number of the plugins list table.
 208   */
 209  do_action( "install_plugins_{$tab}", $paged );
 210  ?>
 211  
 212      <span class="spinner"></span>
 213  </div>
 214  
 215  <?php
 216  wp_print_request_filesystem_credentials_modal();
 217  wp_print_admin_notice_templates();
 218  
 219  /**
 220   * WordPress Administration Template Footer.
 221   */
 222  require_once  ABSPATH . 'wp-admin/admin-footer.php';


Generated : Sat Aug 8 08:20:21 2026 Cross-referenced by PHPXref