[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/ -> plugins.php (source)

   1  <?php
   2  /**
   3   * Plugins administration panel.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** WordPress Administration Bootstrap */
  10  require_once( dirname( __FILE__ ) . '/admin.php' );
  11  
  12  if ( ! current_user_can( 'activate_plugins' ) ) {
  13      wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
  14  }
  15  
  16  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
  17  $pagenum       = $wp_list_table->get_pagenum();
  18  
  19  $action = $wp_list_table->current_action();
  20  
  21  $plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
  22  $s      = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
  23  
  24  // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
  25  $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce' ), $_SERVER['REQUEST_URI'] );
  26  
  27  wp_enqueue_script( 'updates' );
  28  
  29  if ( $action ) {
  30  
  31      switch ( $action ) {
  32          case 'activate':
  33              if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
  34                  wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
  35              }
  36  
  37              if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
  38                  wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
  39                  exit;
  40              }
  41  
  42              check_admin_referer( 'activate-plugin_' . $plugin );
  43  
  44              $result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
  45              if ( is_wp_error( $result ) ) {
  46                  if ( 'unexpected_output' == $result->get_error_code() ) {
  47                      $redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" );
  48                      wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
  49                      exit;
  50                  } else {
  51                      wp_die( $result );
  52                  }
  53              }
  54  
  55              if ( ! is_network_admin() ) {
  56                  $recent = (array) get_option( 'recently_activated' );
  57                  unset( $recent[ $plugin ] );
  58                  update_option( 'recently_activated', $recent );
  59              } else {
  60                  $recent = (array) get_site_option( 'recently_activated' );
  61                  unset( $recent[ $plugin ] );
  62                  update_site_option( 'recently_activated', $recent );
  63              }
  64  
  65              if ( isset( $_GET['from'] ) && 'import' == $_GET['from'] ) {
  66                  wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
  67              } elseif ( isset( $_GET['from'] ) && 'press-this' == $_GET['from'] ) {
  68                  wp_redirect( self_admin_url( 'press-this.php' ) );
  69              } else {
  70                  wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); // overrides the ?error=true one above
  71              }
  72              exit;
  73  
  74          case 'activate-selected':
  75              if ( ! current_user_can( 'activate_plugins' ) ) {
  76                  wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) );
  77              }
  78  
  79              check_admin_referer( 'bulk-plugins' );
  80  
  81              $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
  82  
  83              if ( is_network_admin() ) {
  84                  foreach ( $plugins as $i => $plugin ) {
  85                      // Only activate plugins which are not already network activated.
  86                      if ( is_plugin_active_for_network( $plugin ) ) {
  87                          unset( $plugins[ $i ] );
  88                      }
  89                  }
  90              } else {
  91                  foreach ( $plugins as $i => $plugin ) {
  92                      // Only activate plugins which are not already active and are not network-only when on Multisite.
  93                      if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) {
  94                          unset( $plugins[ $i ] );
  95                      }
  96                      // Only activate plugins which the user can activate.
  97                      if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
  98                          unset( $plugins[ $i ] );
  99                      }
 100                  }
 101              }
 102  
 103              if ( empty( $plugins ) ) {
 104                  wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
 105                  exit;
 106              }
 107  
 108              activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() );
 109  
 110              if ( ! is_network_admin() ) {
 111                  $recent = (array) get_option( 'recently_activated' );
 112              } else {
 113                  $recent = (array) get_site_option( 'recently_activated' );
 114              }
 115  
 116              foreach ( $plugins as $plugin ) {
 117                  unset( $recent[ $plugin ] );
 118              }
 119  
 120              if ( ! is_network_admin() ) {
 121                  update_option( 'recently_activated', $recent );
 122              } else {
 123                  update_site_option( 'recently_activated', $recent );
 124              }
 125  
 126              wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
 127              exit;
 128  
 129          case 'update-selected':
 130              check_admin_referer( 'bulk-plugins' );
 131  
 132              if ( isset( $_GET['plugins'] ) ) {
 133                  $plugins = explode( ',', wp_unslash( $_GET['plugins'] ) );
 134              } elseif ( isset( $_POST['checked'] ) ) {
 135                  $plugins = (array) wp_unslash( $_POST['checked'] );
 136              } else {
 137                  $plugins = array();
 138              }
 139  
 140              $title       = __( 'Update Plugins' );
 141              $parent_file = 'plugins.php';
 142  
 143              wp_enqueue_script( 'updates' );
 144              require_once( ABSPATH . 'wp-admin/admin-header.php' );
 145  
 146              echo '<div class="wrap">';
 147              echo '<h1>' . esc_html( $title ) . '</h1>';
 148  
 149              $url = self_admin_url( 'update.php?action=update-selected&amp;plugins=' . urlencode( join( ',', $plugins ) ) );
 150              $url = wp_nonce_url( $url, 'bulk-update-plugins' );
 151  
 152              echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
 153              echo '</div>';
 154              require_once( ABSPATH . 'wp-admin/admin-footer.php' );
 155              exit;
 156  
 157          case 'error_scrape':
 158              if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
 159                  wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
 160              }
 161  
 162              check_admin_referer( 'plugin-activation-error_' . $plugin );
 163  
 164              $valid = validate_plugin( $plugin );
 165              if ( is_wp_error( $valid ) ) {
 166                  wp_die( $valid );
 167              }
 168  
 169              if ( ! WP_DEBUG ) {
 170                  error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
 171              }
 172  
 173              ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed.
 174              // Go back to "sandbox" scope so we get the same errors as before
 175              plugin_sandbox_scrape( $plugin );
 176              /** This action is documented in wp-admin/includes/plugin.php */
 177              do_action( "activate_{$plugin}" );
 178              exit;
 179  
 180          case 'deactivate':
 181              if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
 182                  wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) );
 183              }
 184  
 185              check_admin_referer( 'deactivate-plugin_' . $plugin );
 186  
 187              if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
 188                  wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
 189                  exit;
 190              }
 191  
 192              deactivate_plugins( $plugin, false, is_network_admin() );
 193  
 194              if ( ! is_network_admin() ) {
 195                  update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
 196              } else {
 197                  update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
 198              }
 199  
 200              if ( headers_sent() ) {
 201                  echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
 202              } else {
 203                  wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) );
 204              }
 205              exit;
 206  
 207          case 'deactivate-selected':
 208              if ( ! current_user_can( 'deactivate_plugins' ) ) {
 209                  wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) );
 210              }
 211  
 212              check_admin_referer( 'bulk-plugins' );
 213  
 214              $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
 215              // Do not deactivate plugins which are already deactivated.
 216              if ( is_network_admin() ) {
 217                  $plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
 218              } else {
 219                  $plugins = array_filter( $plugins, 'is_plugin_active' );
 220                  $plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) );
 221  
 222                  foreach ( $plugins as $i => $plugin ) {
 223                      // Only deactivate plugins which the user can deactivate.
 224                      if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
 225                          unset( $plugins[ $i ] );
 226                      }
 227                  }
 228              }
 229              if ( empty( $plugins ) ) {
 230                  wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
 231                  exit;
 232              }
 233  
 234              deactivate_plugins( $plugins, false, is_network_admin() );
 235  
 236              $deactivated = array();
 237              foreach ( $plugins as $plugin ) {
 238                  $deactivated[ $plugin ] = time();
 239              }
 240  
 241              if ( ! is_network_admin() ) {
 242                  update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
 243              } else {
 244                  update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
 245              }
 246  
 247              wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
 248              exit;
 249  
 250          case 'delete-selected':
 251              if ( ! current_user_can( 'delete_plugins' ) ) {
 252                  wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) );
 253              }
 254  
 255              check_admin_referer( 'bulk-plugins' );
 256  
 257              //$_POST = from the plugin form; $_GET = from the FTP details screen.
 258              $plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
 259              if ( empty( $plugins ) ) {
 260                  wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
 261                  exit;
 262              }
 263  
 264              $plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete Activated plugins.
 265              if ( empty( $plugins ) ) {
 266                  wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
 267                  exit;
 268              }
 269  
 270              // Bail on all if any paths are invalid.
 271              // validate_file() returns truthy for invalid files
 272              $invalid_plugin_files = array_filter( $plugins, 'validate_file' );
 273              if ( $invalid_plugin_files ) {
 274                  wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
 275                  exit;
 276              }
 277  
 278              include( ABSPATH . 'wp-admin/update.php' );
 279  
 280              $parent_file = 'plugins.php';
 281  
 282              if ( ! isset( $_REQUEST['verify-delete'] ) ) {
 283                  wp_enqueue_script( 'jquery' );
 284                  require_once( ABSPATH . 'wp-admin/admin-header.php' );
 285                  ?>
 286              <div class="wrap">
 287                  <?php
 288                      $plugin_info              = array();
 289                      $have_non_network_plugins = false;
 290                  foreach ( (array) $plugins as $plugin ) {
 291                      $plugin_slug = dirname( $plugin );
 292  
 293                      if ( '.' == $plugin_slug ) {
 294                          $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
 295                          if ( $data ) {
 296                              $plugin_info[ $plugin ]                     = $data;
 297                              $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
 298                              if ( ! $plugin_info[ $plugin ]['Network'] ) {
 299                                  $have_non_network_plugins = true;
 300                              }
 301                          }
 302                      } else {
 303                          // Get plugins list from that folder.
 304                          $folder_plugins = get_plugins( '/' . $plugin_slug );
 305                          if ( $folder_plugins ) {
 306                              foreach ( $folder_plugins as $plugin_file => $data ) {
 307                                  $plugin_info[ $plugin_file ]                     = _get_plugin_data_markup_translate( $plugin_file, $data );
 308                                  $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
 309                                  if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
 310                                      $have_non_network_plugins = true;
 311                                  }
 312                              }
 313                          }
 314                      }
 315                  }
 316                      $plugins_to_delete = count( $plugin_info );
 317                  ?>
 318                  <?php if ( 1 == $plugins_to_delete ) : ?>
 319                      <h1><?php _e( 'Delete Plugin' ); ?></h1>
 320                      <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
 321                          <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
 322                      <?php endif; ?>
 323                      <p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
 324                  <?php else : ?>
 325                      <h1><?php _e( 'Delete Plugins' ); ?></h1>
 326                      <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
 327                          <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
 328                      <?php endif; ?>
 329                      <p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
 330                  <?php endif; ?>
 331                      <ul class="ul-disc">
 332                          <?php
 333                          $data_to_delete = false;
 334                          foreach ( $plugin_info as $plugin ) {
 335                              if ( $plugin['is_uninstallable'] ) {
 336                                  /* translators: 1: Plugin name, 2: Plugin author. */
 337                                  echo '<li>', sprintf( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>';
 338                                  $data_to_delete = true;
 339                              } else {
 340                                  /* translators: 1: Plugin name, 2: Plugin author. */
 341                                  echo '<li>', sprintf( _x( '%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';
 342                              }
 343                          }
 344                          ?>
 345                      </ul>
 346                  <p>
 347                  <?php
 348                  if ( $data_to_delete ) {
 349                      _e( 'Are you sure you want to delete these files and data?' );
 350                  } else {
 351                      _e( 'Are you sure you want to delete these files?' );
 352                  }
 353                  ?>
 354                  </p>
 355                  <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;">
 356                      <input type="hidden" name="verify-delete" value="1" />
 357                      <input type="hidden" name="action" value="delete-selected" />
 358                      <?php
 359                      foreach ( (array) $plugins as $plugin ) {
 360                          echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
 361                      }
 362                      ?>
 363                      <?php wp_nonce_field( 'bulk-plugins' ); ?>
 364                      <?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?>
 365                  </form>
 366                  <?php
 367                  $referer = wp_get_referer();
 368                  ?>
 369                  <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
 370                      <?php submit_button( __( 'No, return me to the plugin list' ), '', 'submit', false ); ?>
 371                  </form>
 372              </div>
 373                  <?php
 374                  require_once( ABSPATH . 'wp-admin/admin-footer.php' );
 375                  exit;
 376              } else {
 377                  $plugins_to_delete = count( $plugins );
 378              } // endif verify-delete
 379  
 380              $delete_result = delete_plugins( $plugins );
 381  
 382              set_transient( 'plugins_delete_result_' . $user_ID, $delete_result ); //Store the result in a cache rather than a URL param due to object type & length
 383              wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) );
 384              exit;
 385  
 386          case 'clear-recent-list':
 387              if ( ! is_network_admin() ) {
 388                  update_option( 'recently_activated', array() );
 389              } else {
 390                  update_site_option( 'recently_activated', array() );
 391              }
 392              break;
 393  
 394          case 'resume':
 395              if ( is_multisite() ) {
 396                  return;
 397              }
 398  
 399              if ( ! current_user_can( 'resume_plugin', $plugin ) ) {
 400                  wp_die( __( 'Sorry, you are not allowed to resume this plugin.' ) );
 401              }
 402  
 403              check_admin_referer( 'resume-plugin_' . $plugin );
 404  
 405              $result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) );
 406  
 407              if ( is_wp_error( $result ) ) {
 408                  wp_die( $result );
 409              }
 410  
 411              wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) );
 412              exit;
 413  
 414          default:
 415              if ( isset( $_POST['checked'] ) ) {
 416                  check_admin_referer( 'bulk-plugins' );
 417  
 418                  $screen   = get_current_screen()->id;
 419                  $sendback = wp_get_referer();
 420                  $plugins  = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
 421  
 422                  /** This action is documented in wp-admin/edit.php */
 423                  $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 424                  wp_safe_redirect( $sendback );
 425                  exit;
 426              }
 427              break;
 428      }
 429  }
 430  
 431  $wp_list_table->prepare_items();
 432  
 433  wp_enqueue_script( 'plugin-install' );
 434  add_thickbox();
 435  
 436  add_screen_option( 'per_page', array( 'default' => 999 ) );
 437  
 438  get_current_screen()->add_help_tab(
 439      array(
 440          'id'      => 'overview',
 441          'title'   => __( 'Overview' ),
 442          'content' =>
 443                  '<p>' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '</p>' .
 444                  '<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
 445                  '<p>' . sprintf(
 446                      /* translators: %s: WordPress Plugin Directory URL. */
 447                      __( 'If you would like to see more plugins to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
 448                      __( 'https://wordpress.org/plugins/' )
 449                  ) . '</p>',
 450      )
 451  );
 452  get_current_screen()->add_help_tab(
 453      array(
 454          'id'      => 'compatibility-problems',
 455          'title'   => __( 'Troubleshooting' ),
 456          'content' =>
 457                  '<p>' . __( 'Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin&#8217;s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.' ) . '</p>' .
 458                  '<p>' . sprintf(
 459                      /* translators: WP_PLUGIN_DIR constant value. */
 460                      __( 'If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ),
 461                      '<code>' . WP_PLUGIN_DIR . '</code>'
 462                  ) . '</p>',
 463      )
 464  );
 465  
 466  get_current_screen()->set_help_sidebar(
 467      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 468      '<p>' . __( '<a href="https://wordpress.org/support/article/managing-plugins/">Documentation on Managing Plugins</a>' ) . '</p>' .
 469      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 470  );
 471  
 472  get_current_screen()->set_screen_reader_content(
 473      array(
 474          'heading_views'      => __( 'Filter plugins list' ),
 475          'heading_pagination' => __( 'Plugins list navigation' ),
 476          'heading_list'       => __( 'Plugins list' ),
 477      )
 478  );
 479  
 480  $title       = __( 'Plugins' );
 481  $parent_file = 'plugins.php';
 482  
 483  require_once( ABSPATH . 'wp-admin/admin-header.php' );
 484  
 485  $invalid = validate_active_plugins();
 486  if ( ! empty( $invalid ) ) {
 487      foreach ( $invalid as $plugin_file => $error ) {
 488          echo '<div id="message" class="error"><p>';
 489          printf(
 490              /* translators: 1: Plugin file, 2: Error message. */
 491              __( 'The plugin %1$s has been deactivated due to an error: %2$s' ),
 492              '<code>' . esc_html( $plugin_file ) . '</code>',
 493              $error->get_error_message()
 494          );
 495          echo '</p></div>';
 496      }
 497  }
 498  ?>
 499  
 500  <?php
 501  if ( isset( $_GET['error'] ) ) :
 502  
 503      if ( isset( $_GET['main'] ) ) {
 504          $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
 505      } elseif ( isset( $_GET['charsout'] ) ) {
 506          $errmsg = sprintf(
 507              /* translators: %d: Number of characters. */
 508              _n(
 509                  'The plugin generated %d character of <strong>unexpected output</strong> during activation.',
 510                  'The plugin generated %d characters of <strong>unexpected output</strong> during activation.',
 511                  $_GET['charsout']
 512              ),
 513              $_GET['charsout']
 514          );
 515          $errmsg .= ' ' . __( 'If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' );
 516      } elseif ( 'resuming' === $_GET['error'] ) {
 517          $errmsg = __( 'Plugin could not be resumed because it triggered a <strong>fatal error</strong>.' );
 518      } else {
 519          $errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' );
 520      }
 521      ?>
 522      <div id="message" class="error"><p><?php echo $errmsg; ?></p>
 523      <?php
 524      if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) {
 525          $iframe_url = add_query_arg(
 526              array(
 527                  'action'   => 'error_scrape',
 528                  'plugin'   => urlencode( $plugin ),
 529                  '_wpnonce' => urlencode( $_GET['_error_nonce'] ),
 530              ),
 531              admin_url( 'plugins.php' )
 532          );
 533          ?>
 534      <iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe>
 535          <?php
 536      }
 537      ?>
 538      </div>
 539      <?php
 540  elseif ( isset( $_GET['deleted'] ) ) :
 541          $delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
 542          // Delete it once we're done.
 543          delete_transient( 'plugins_delete_result_' . $user_ID );
 544  
 545      if ( is_wp_error( $delete_result ) ) :
 546          ?>
 547          <div id="message" class="error notice is-dismissible">
 548              <p>
 549                  <?php
 550                  printf(
 551                      /* translators: %s: Error message. */
 552                      __( 'Plugin could not be deleted due to an error: %s' ),
 553                      $delete_result->get_error_message()
 554                  );
 555                  ?>
 556              </p>
 557          </div>
 558          <?php else : ?>
 559          <div id="message" class="updated notice is-dismissible">
 560              <p>
 561                  <?php
 562                  if ( 1 == (int) $_GET['deleted'] ) {
 563                      _e( 'The selected plugin has been deleted.' );
 564                  } else {
 565                      _e( 'The selected plugins have been deleted.' );
 566                  }
 567                  ?>
 568              </p>
 569          </div>
 570          <?php endif; ?>
 571  <?php elseif ( isset( $_GET['activate'] ) ) : ?>
 572      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin activated.' ); ?></p></div>
 573  <?php elseif ( isset( $_GET['activate-multi'] ) ) : ?>
 574      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins activated.' ); ?></p></div>
 575  <?php elseif ( isset( $_GET['deactivate'] ) ) : ?>
 576      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin deactivated.' ); ?></p></div>
 577  <?php elseif ( isset( $_GET['deactivate-multi'] ) ) : ?>
 578      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins deactivated.' ); ?></p></div>
 579  <?php elseif ( 'update-selected' == $action ) : ?>
 580      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div>
 581  <?php elseif ( isset( $_GET['resume'] ) ) : ?>
 582      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin resumed.' ); ?></p></div>
 583  <?php endif; ?>
 584  
 585  <div class="wrap">
 586  <h1 class="wp-heading-inline">
 587  <?php
 588  echo esc_html( $title );
 589  ?>
 590  </h1>
 591  
 592  <?php
 593  if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_plugins' ) ) {
 594      ?>
 595      <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'plugin' ); ?></a>
 596      <?php
 597  }
 598  
 599  if ( strlen( $s ) ) {
 600      /* translators: %s: Search query. */
 601      printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( urldecode( $s ) ) );
 602  }
 603  ?>
 604  
 605  <hr class="wp-header-end">
 606  
 607  <?php
 608  /**
 609   * Fires before the plugins list table is rendered.
 610   *
 611   * This hook also fires before the plugins list table is rendered in the Network Admin.
 612   *
 613   * Please note: The 'active' portion of the hook name does not refer to whether the current
 614   * view is for active plugins, but rather all plugins actively-installed.
 615   *
 616   * @since 3.0.0
 617   *
 618   * @param array[] $plugins_all An array of arrays containing information on all installed plugins.
 619   */
 620  do_action( 'pre_current_active_plugins', $plugins['all'] );
 621  ?>
 622  
 623  <?php $wp_list_table->views(); ?>
 624  
 625  <form class="search-form search-plugins" method="get">
 626  <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
 627  </form>
 628  
 629  <form method="post" id="bulk-action-form">
 630  
 631  <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $status ); ?>" />
 632  <input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" />
 633  
 634  <?php $wp_list_table->display(); ?>
 635  </form>
 636  
 637      <span class="spinner"></span>
 638  </div>
 639  
 640  <?php
 641  wp_print_request_filesystem_credentials_modal();
 642  wp_print_admin_notice_templates();
 643  wp_print_update_row_templates();
 644  
 645  include( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Mon Dec 16 01:00:04 2019 Cross-referenced by PHPXref 0.7.1