[ 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                  $plugins  = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
 418                  $sendback = wp_get_referer();
 419  
 420                  /** This action is documented in wp-admin/edit-comments.php */
 421                  $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $action, $plugins );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 422                  wp_safe_redirect( $sendback );
 423                  exit;
 424              }
 425              break;
 426      }
 427  }
 428  
 429  $wp_list_table->prepare_items();
 430  
 431  wp_enqueue_script( 'plugin-install' );
 432  add_thickbox();
 433  
 434  add_screen_option( 'per_page', array( 'default' => 999 ) );
 435  
 436  get_current_screen()->add_help_tab(
 437      array(
 438          'id'      => 'overview',
 439          'title'   => __( 'Overview' ),
 440          'content' =>
 441                  '<p>' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '</p>' .
 442                  '<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>' .
 443                  '<p>' . sprintf(
 444                      /* translators: %s: WordPress Plugin Directory URL. */
 445                      __( '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!' ),
 446                      __( 'https://wordpress.org/plugins/' )
 447                  ) . '</p>',
 448      )
 449  );
 450  get_current_screen()->add_help_tab(
 451      array(
 452          'id'      => 'compatibility-problems',
 453          'title'   => __( 'Troubleshooting' ),
 454          'content' =>
 455                  '<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>' .
 456                  '<p>' . sprintf(
 457                      /* translators: WP_PLUGIN_DIR constant value. */
 458                      __( '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.' ),
 459                      '<code>' . WP_PLUGIN_DIR . '</code>'
 460                  ) . '</p>',
 461      )
 462  );
 463  
 464  get_current_screen()->set_help_sidebar(
 465      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 466      '<p>' . __( '<a href="https://wordpress.org/support/article/managing-plugins/">Documentation on Managing Plugins</a>' ) . '</p>' .
 467      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 468  );
 469  
 470  get_current_screen()->set_screen_reader_content(
 471      array(
 472          'heading_views'      => __( 'Filter plugins list' ),
 473          'heading_pagination' => __( 'Plugins list navigation' ),
 474          'heading_list'       => __( 'Plugins list' ),
 475      )
 476  );
 477  
 478  $title       = __( 'Plugins' );
 479  $parent_file = 'plugins.php';
 480  
 481  require_once( ABSPATH . 'wp-admin/admin-header.php' );
 482  
 483  $invalid = validate_active_plugins();
 484  if ( ! empty( $invalid ) ) {
 485      foreach ( $invalid as $plugin_file => $error ) {
 486          echo '<div id="message" class="error"><p>';
 487          printf(
 488              /* translators: 1: Plugin file, 2: Error message. */
 489              __( 'The plugin %1$s has been deactivated due to an error: %2$s' ),
 490              '<code>' . esc_html( $plugin_file ) . '</code>',
 491              $error->get_error_message()
 492          );
 493          echo '</p></div>';
 494      }
 495  }
 496  ?>
 497  
 498  <?php
 499  if ( isset( $_GET['error'] ) ) :
 500  
 501      if ( isset( $_GET['main'] ) ) {
 502          $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
 503      } elseif ( isset( $_GET['charsout'] ) ) {
 504          $errmsg = sprintf(
 505              /* translators: %d: Number of characters. */
 506              _n(
 507                  'The plugin generated %d character of <strong>unexpected output</strong> during activation.',
 508                  'The plugin generated %d characters of <strong>unexpected output</strong> during activation.',
 509                  $_GET['charsout']
 510              ),
 511              $_GET['charsout']
 512          );
 513          $errmsg .= ' ' . __( 'If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' );
 514      } elseif ( 'resuming' === $_GET['error'] ) {
 515          $errmsg = __( 'Plugin could not be resumed because it triggered a <strong>fatal error</strong>.' );
 516      } else {
 517          $errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' );
 518      }
 519      ?>
 520      <div id="message" class="error"><p><?php echo $errmsg; ?></p>
 521      <?php
 522      if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) {
 523          $iframe_url = add_query_arg(
 524              array(
 525                  'action'   => 'error_scrape',
 526                  'plugin'   => urlencode( $plugin ),
 527                  '_wpnonce' => urlencode( $_GET['_error_nonce'] ),
 528              ),
 529              admin_url( 'plugins.php' )
 530          );
 531          ?>
 532      <iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe>
 533          <?php
 534      }
 535      ?>
 536      </div>
 537      <?php
 538  elseif ( isset( $_GET['deleted'] ) ) :
 539          $delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
 540          // Delete it once we're done.
 541          delete_transient( 'plugins_delete_result_' . $user_ID );
 542  
 543      if ( is_wp_error( $delete_result ) ) :
 544          ?>
 545          <div id="message" class="error notice is-dismissible">
 546              <p>
 547                  <?php
 548                  printf(
 549                      /* translators: %s: Error message. */
 550                      __( 'Plugin could not be deleted due to an error: %s' ),
 551                      $delete_result->get_error_message()
 552                  );
 553                  ?>
 554              </p>
 555          </div>
 556          <?php else : ?>
 557          <div id="message" class="updated notice is-dismissible">
 558              <p>
 559                  <?php
 560                  if ( 1 == (int) $_GET['deleted'] ) {
 561                      _e( 'The selected plugin has been deleted.' );
 562                  } else {
 563                      _e( 'The selected plugins have been deleted.' );
 564                  }
 565                  ?>
 566              </p>
 567          </div>
 568          <?php endif; ?>
 569  <?php elseif ( isset( $_GET['activate'] ) ) : ?>
 570      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin activated.' ); ?></p></div>
 571  <?php elseif ( isset( $_GET['activate-multi'] ) ) : ?>
 572      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins activated.' ); ?></p></div>
 573  <?php elseif ( isset( $_GET['deactivate'] ) ) : ?>
 574      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin deactivated.' ); ?></p></div>
 575  <?php elseif ( isset( $_GET['deactivate-multi'] ) ) : ?>
 576      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins deactivated.' ); ?></p></div>
 577  <?php elseif ( 'update-selected' == $action ) : ?>
 578      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div>
 579  <?php elseif ( isset( $_GET['resume'] ) ) : ?>
 580      <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin resumed.' ); ?></p></div>
 581  <?php endif; ?>
 582  
 583  <div class="wrap">
 584  <h1 class="wp-heading-inline">
 585  <?php
 586  echo esc_html( $title );
 587  ?>
 588  </h1>
 589  
 590  <?php
 591  if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_plugins' ) ) {
 592      ?>
 593      <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'plugin' ); ?></a>
 594      <?php
 595  }
 596  
 597  if ( strlen( $s ) ) {
 598      /* translators: %s: Search query. */
 599      printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( urldecode( $s ) ) );
 600  }
 601  ?>
 602  
 603  <hr class="wp-header-end">
 604  
 605  <?php
 606  /**
 607   * Fires before the plugins list table is rendered.
 608   *
 609   * This hook also fires before the plugins list table is rendered in the Network Admin.
 610   *
 611   * Please note: The 'active' portion of the hook name does not refer to whether the current
 612   * view is for active plugins, but rather all plugins actively-installed.
 613   *
 614   * @since 3.0.0
 615   *
 616   * @param array[] $plugins_all An array of arrays containing information on all installed plugins.
 617   */
 618  do_action( 'pre_current_active_plugins', $plugins['all'] );
 619  ?>
 620  
 621  <?php $wp_list_table->views(); ?>
 622  
 623  <form class="search-form search-plugins" method="get">
 624  <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
 625  </form>
 626  
 627  <form method="post" id="bulk-action-form">
 628  
 629  <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $status ); ?>" />
 630  <input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" />
 631  
 632  <?php $wp_list_table->display(); ?>
 633  </form>
 634  
 635      <span class="spinner"></span>
 636  </div>
 637  
 638  <?php
 639  wp_print_request_filesystem_credentials_modal();
 640  wp_print_admin_notice_templates();
 641  wp_print_update_row_templates();
 642  
 643  include( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Tue Sep 17 01:00:03 2019 Cross-referenced by PHPXref 0.7.1