[ 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 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  
  13  /**
  14   * WordPress Administration Bootstrap.
  15   */
  16  require_once( dirname( __FILE__ ) . '/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  $title       = __( 'Add Plugins' );
  51  $parent_file = 'plugins.php';
  52  
  53  wp_enqueue_script( 'plugin-install' );
  54  if ( 'plugin-information' != $tab ) {
  55      add_thickbox();
  56  }
  57  
  58  $body_id = $tab;
  59  
  60  wp_enqueue_script( 'updates' );
  61  
  62  /**
  63   * Fires before each tab on the Install Plugins screen is loaded.
  64   *
  65   * The dynamic portion of the action hook, `$tab`, allows for targeting
  66   * individual tabs, for instance 'install_plugins_pre_plugin-information'.
  67   *
  68   * @since 2.7.0
  69   */
  70  do_action( "install_plugins_pre_{$tab}" );
  71  
  72  /*
  73   * Call the pre upload action on every non-upload plugin installation screen
  74   * because the form is always displayed on these screens.
  75   */
  76  if ( 'upload' !== $tab ) {
  77      /** This action is documented in wp-admin/plugin-install.php */
  78      do_action( 'install_plugins_pre_upload' );
  79  }
  80  
  81  get_current_screen()->add_help_tab(
  82      array(
  83          'id'      => 'overview',
  84          'title'   => __( 'Overview' ),
  85          'content' =>
  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>',
  88  
  89      )
  90  );
  91  get_current_screen()->add_help_tab(
  92      array(
  93          'id'      => 'adding-plugins',
  94          'title'   => __( 'Adding Plugins' ),
  95          'content' =>
  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>' .
  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>' .
  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  );
 102  
 103  get_current_screen()->set_help_sidebar(
 104      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 105      '<p>' . __( '<a href="https://codex.wordpress.org/Plugins_Add_New_Screen">Documentation on Installing Plugins</a>' ) . '</p>' .
 106      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 107  );
 108  
 109  get_current_screen()->set_screen_reader_content(
 110      array(
 111          'heading_views'      => __( 'Filter plugins list' ),
 112          'heading_pagination' => __( 'Plugins list navigation' ),
 113          'heading_list'       => __( 'Plugins list' ),
 114      )
 115  );
 116  
 117  /**
 118   * WordPress Administration Template Header.
 119   */
 120  include( ABSPATH . 'wp-admin/admin-header.php' );
 121  ?>
 122  <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
 123  <h1 class="wp-heading-inline">
 124  <?php
 125  echo esc_html( $title );
 126  ?>
 127  </h1>
 128  
 129  <?php
 130  if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
 131      printf(
 132          ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>',
 133          ( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
 134          __( 'Upload Plugin' ),
 135          __( 'Browse Plugins' )
 136      );
 137  }
 138  ?>
 139  
 140  <hr class="wp-header-end">
 141  
 142  <?php
 143  /*
 144   * Output the upload plugin form on every non-upload plugin installation screen, so it can be
 145   * displayed via JavaScript rather then opening up the devoted upload plugin page.
 146   */
 147  if ( 'upload' !== $tab ) {
 148      ?>
 149      <div class="upload-plugin-wrap">
 150          <?php
 151          /** This action is documented in wp-admin/plugin-install.php */
 152          do_action( 'install_plugins_upload' );
 153          ?>
 154      </div>
 155      <?php
 156      $wp_list_table->views();
 157      echo '<br class="clear" />';
 158  }
 159  
 160  /**
 161   * Fires after the plugins list table in each tab of the Install Plugins screen.
 162   *
 163   * The dynamic portion of the action hook, `$tab`, allows for targeting
 164   * individual tabs, for instance 'install_plugins_plugin-information'.
 165   *
 166   * @since 2.7.0
 167   *
 168   * @param int $paged The current page number of the plugins list table.
 169   */
 170  do_action( "install_plugins_{$tab}", $paged );
 171  ?>
 172  
 173      <span class="spinner"></span>
 174  </div>
 175  
 176  <?php
 177  wp_print_request_filesystem_credentials_modal();
 178  wp_print_admin_notice_templates();
 179  
 180  /**
 181   * WordPress Administration Template Footer.
 182   */
 183  include( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Fri Jul 19 01:00:04 2019 Cross-referenced by PHPXref 0.7.1