[ Index ]

PHP Cross Reference of WordPress

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  $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
  44  
  45  if ( $pagenum > $total_pages && $total_pages > 0 ) {
  46      wp_redirect( add_query_arg( 'paged', $total_pages ) );
  47      exit;
  48  }
  49  
  50  // Used in the HTML title tag.
  51  $title       = __( 'Add Plugins' );
  52  $parent_file = 'plugins.php';
  53  
  54  wp_enqueue_script( 'plugin-install' );
  55  if ( 'plugin-information' !== $tab ) {
  56      add_thickbox();
  57  }
  58  
  59  $body_id = $tab;
  60  
  61  wp_enqueue_script( 'updates' );
  62  
  63  /**
  64   * Fires before each tab on the Install Plugins screen is loaded.
  65   *
  66   * The dynamic portion of the hook name, `$tab`, allows for targeting
  67   * individual tabs.
  68   *
  69   * Possible hook names include:
  70   *
  71   *  - `install_plugins_pre_beta`
  72   *  - `install_plugins_pre_favorites`
  73   *  - `install_plugins_pre_featured`
  74   *  - `install_plugins_pre_plugin-information`
  75   *  - `install_plugins_pre_popular`
  76   *  - `install_plugins_pre_recommended`
  77   *  - `install_plugins_pre_search`
  78   *  - `install_plugins_pre_upload`
  79   *
  80   * @since 2.7.0
  81   */
  82  do_action( "install_plugins_pre_{$tab}" );
  83  
  84  /*
  85   * Call the pre upload action on every non-upload plugin installation screen
  86   * because the form is always displayed on these screens.
  87   */
  88  if ( 'upload' !== $tab ) {
  89      /** This action is documented in wp-admin/plugin-install.php */
  90      do_action( 'install_plugins_pre_upload' );
  91  }
  92  
  93  get_current_screen()->add_help_tab(
  94      array(
  95          'id'      => 'overview',
  96          'title'   => __( 'Overview' ),
  97          'content' =>
  98                  '<p>' . sprintf(
  99                      /* translators: %s: https://wordpress.org/plugins/ */
 100                      __( '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.' ),
 101                      __( 'https://wordpress.org/plugins/' )
 102                  ) . '</p>' .
 103                  '<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>',
 104  
 105      )
 106  );
 107  get_current_screen()->add_help_tab(
 108      array(
 109          'id'      => 'adding-plugins',
 110          'title'   => __( 'Adding Plugins' ),
 111          'content' =>
 112                  '<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>' .
 113                  '<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>' .
 114                  '<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>' .
 115                  '<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>',
 116      )
 117  );
 118  
 119  get_current_screen()->set_help_sidebar(
 120      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 121      '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-add-new-screen/">Documentation on Installing Plugins</a>' ) . '</p>' .
 122      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 123  );
 124  
 125  get_current_screen()->set_screen_reader_content(
 126      array(
 127          'heading_views'      => __( 'Filter plugins list' ),
 128          'heading_pagination' => __( 'Plugins list navigation' ),
 129          'heading_list'       => __( 'Plugins list' ),
 130      )
 131  );
 132  
 133  /**
 134   * WordPress Administration Template Header.
 135   */
 136  require_once ABSPATH . 'wp-admin/admin-header.php';
 137  ?>
 138  <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
 139  <h1 class="wp-heading-inline">
 140  <?php
 141  echo esc_html( $title );
 142  ?>
 143  </h1>
 144  
 145  <?php
 146  if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
 147      printf(
 148          ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>',
 149          ( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
 150          __( 'Upload Plugin' ),
 151          __( 'Browse Plugins' )
 152      );
 153  }
 154  ?>
 155  
 156  <hr class="wp-header-end">
 157  
 158  <?php
 159  /*
 160   * Output the upload plugin form on every non-upload plugin installation screen, so it can be
 161   * displayed via JavaScript rather then opening up the devoted upload plugin page.
 162   */
 163  if ( 'upload' !== $tab ) {
 164      ?>
 165      <div class="upload-plugin-wrap">
 166          <?php
 167          /** This action is documented in wp-admin/plugin-install.php */
 168          do_action( 'install_plugins_upload' );
 169          ?>
 170      </div>
 171      <?php
 172      $wp_list_table->views();
 173  }
 174  
 175  /**
 176   * Fires after the plugins list table in each tab of the Install Plugins screen.
 177   *
 178   * The dynamic portion of the hook name, `$tab`, allows for targeting
 179   * individual tabs.
 180   *
 181   * Possible hook names include:
 182   *
 183   *  - `install_plugins_beta`
 184   *  - `install_plugins_favorites`
 185   *  - `install_plugins_featured`
 186   *  - `install_plugins_plugin-information`
 187   *  - `install_plugins_popular`
 188   *  - `install_plugins_recommended`
 189   *  - `install_plugins_search`
 190   *  - `install_plugins_upload`
 191   *
 192   * @since 2.7.0
 193   *
 194   * @param int $paged The current page number of the plugins list table.
 195   */
 196  do_action( "install_plugins_{$tab}", $paged );
 197  ?>
 198  
 199      <span class="spinner"></span>
 200  </div>
 201  
 202  <?php
 203  wp_print_request_filesystem_credentials_modal();
 204  wp_print_admin_notice_templates();
 205  
 206  /**
 207   * WordPress Administration Template Footer.
 208   */
 209  require_once ABSPATH . 'wp-admin/admin-footer.php';


Generated: Sat Apr 27 01:00:02 2024 Cross-referenced by PHPXref 0.7.1