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


Generated: Fri Feb 28 01:00:03 2020 Cross-referenced by PHPXref 0.7.1