[ Root ] [ Search ] [ Index ]

PHP Cross Reference of WordPress MU 2.9.2

Provided by Yoast

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 ('admin.php');
  11  
  12  $menu_perms = get_site_option( "menu_items" );
  13  if( is_array( $menu_perms ) == false )
  14      $menu_perms = array();
  15  
  16  if ( $menu_perms[ 'plugins' ] != 1 && !is_site_admin() )
  17      wp_die( __( 'Page disabled by the administrator' ) );
  18  
  19  if ( ! current_user_can('activate_plugins') )
  20      wp_die(__('You do not have sufficient permissions to manage plugins for this blog.'));
  21  
  22  if ( isset($_POST['clear-recent-list']) )
  23      $action = 'clear-recent-list';
  24  elseif ( !empty($_REQUEST['action']) )
  25      $action = $_REQUEST['action'];
  26  elseif ( !empty($_REQUEST['action2']) )
  27      $action = $_REQUEST['action2'];
  28  else
  29      $action = false;
  30  
  31  $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
  32  
  33  $default_status = get_user_option('plugins_last_view');
  34  if ( empty($default_status) )
  35      $default_status = 'all';
  36  $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status;
  37  if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search')) )
  38      $status = 'all';
  39  if ( $status != $default_status && 'search' != $status )
  40      update_usermeta($current_user->ID, 'plugins_last_view', $status);
  41  
  42  $page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
  43  
  44  //Clean up request URI from temporary args for screen options/paging uri's to work as expected.
  45  $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
  46  
  47  if ( !empty($action) ) {
  48      switch ( $action ) {
  49          case 'activate':
  50              if ( ! current_user_can('activate_plugins') )
  51                  wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
  52  
  53              check_admin_referer('activate-plugin_' . $plugin);
  54  
  55              $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
  56              if ( is_wp_error( $result ) )
  57                  wp_die($result);
  58  
  59              $recent = (array)get_option('recently_activated');
  60              if ( isset($recent[ $plugin ]) ) {
  61                  unset($recent[ $plugin ]);
  62                  update_option('recently_activated', $recent);
  63              }
  64  
  65              wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above
  66              exit;
  67              break;
  68          case 'activate-selected':
  69              if ( ! current_user_can('activate_plugins') )
  70                  wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
  71  
  72              check_admin_referer('bulk-manage-plugins');
  73  
  74              $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
  75              $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active.
  76              if ( empty($plugins) ) {
  77                  wp_redirect("plugins.php?plugin_status=$status&paged=$page");
  78                  exit;
  79              }
  80  
  81              activate_plugins($plugins, 'plugins.php?error=true');
  82              
  83              /* Check to see if any of the plugins should only be active site-wide */
  84              check_wpmu_plugins_on_bulk_activate( $_POST['checked']);
  85  
  86              $recent = (array)get_option('recently_activated');
  87              foreach ( $plugins as $plugin => $time)
  88                  if ( isset($recent[ $plugin ]) )
  89                      unset($recent[ $plugin ]);
  90  
  91              update_option('recently_activated', $recent);
  92  
  93              wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page");
  94              exit;
  95              break;
  96          case 'error_scrape':
  97              if ( ! current_user_can('activate_plugins') )
  98                  wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
  99  
 100              check_admin_referer('plugin-activation-error_' . $plugin);
 101  
 102              $valid = validate_plugin($plugin);
 103              if ( is_wp_error($valid) )
 104                  wp_die($valid);
 105  
 106              if ( defined('E_RECOVERABLE_ERROR') )
 107                  error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
 108              else
 109                  error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
 110  
 111              @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
 112              include(WP_PLUGIN_DIR . '/' . $plugin);
 113              do_action('activate_' . $plugin);
 114              exit;
 115              break;
 116          case 'deactivate':
 117              if ( ! current_user_can('activate_plugins') )
 118                  wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
 119  
 120              check_admin_referer('deactivate-plugin_' . $plugin);
 121              deactivate_plugins($plugin);
 122              update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
 123              wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page");
 124              exit;
 125              break;
 126          case 'deactivate-selected':
 127              if ( ! current_user_can('activate_plugins') )
 128                  wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
 129  
 130              check_admin_referer('bulk-manage-plugins');
 131  
 132              $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
 133              $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
 134              if ( empty($plugins) ) {
 135                  wp_redirect("plugins.php?plugin_status=$status&paged=$page");
 136                  exit;
 137              }
 138  
 139              deactivate_plugins($plugins);
 140  
 141              $deactivated = array();
 142              foreach ( $plugins as $plugin )
 143                  $deactivated[ $plugin ] = time();
 144  
 145              update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
 146              wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page");
 147              exit;
 148              break;
 149          case 'delete-selected':
 150              if ( ! current_user_can('delete_plugins') )
 151                  wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
 152  
 153              check_admin_referer('bulk-manage-plugins');
 154  
 155              //$_POST = from the plugin form; $_GET = from the FTP details screen.
 156              $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
 157              $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
 158              if ( empty($plugins) ) {
 159                  wp_redirect("plugins.php?plugin_status=$status&paged=$page");
 160                  exit;
 161              }
 162  
 163              include (ABSPATH . 'wp-admin/update.php');
 164  
 165              $parent_file = 'plugins.php';
 166  
 167              if ( ! isset($_REQUEST['verify-delete']) ) {
 168                  wp_enqueue_script('jquery');
 169                  require_once ('admin-header.php');
 170                  ?>
 171              <div class="wrap">
 172                  <h2><?php _e('Delete Plugin(s)'); ?></h2>
 173                  <?php
 174                      $files_to_delete = $plugin_info = array();
 175                      foreach ( (array) $plugins as $plugin ) {
 176                          if ( '.' == dirname($plugin) ) {
 177                              $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
 178                              if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
 179                                  $plugin_info[ $plugin ] = $data;
 180                          } else {
 181                              //Locate all the files in that folder:
 182                              $files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
 183                              if( $files ) {
 184                                  $files_to_delete = array_merge($files_to_delete, $files);
 185                              }
 186                              //Get plugins list from that folder
 187                              if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) )
 188                                  $plugin_info = array_merge($plugin_info, $folder_plugins);
 189                          }
 190                      }
 191                  ?>
 192                  <p><?php _e('Deleting the selected plugins will remove the following plugin(s) and their files:'); ?></p>
 193                      <ul class="ul-disc">
 194                          <?php
 195                          foreach ( $plugin_info as $plugin )
 196                              echo '<li>', sprintf(__('<strong>%s</strong> by <em>%s</em>'), $plugin['Name'], $plugin['Author']), '</li>';
 197                          ?>
 198                      </ul>
 199                  <p><?php _e('Are you sure you wish to delete these files?') ?></p>
 200                  <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
 201                      <input type="hidden" name="verify-delete" value="1" />
 202                      <input type="hidden" name="action" value="delete-selected" />
 203                      <?php
 204                          foreach ( (array)$plugins as $plugin )
 205                              echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
 206                      ?>
 207                      <?php wp_nonce_field('bulk-manage-plugins') ?>
 208                      <input type="submit" name="submit" value="<?php esc_attr_e('Yes, Delete these files') ?>" class="button" />
 209                  </form>
 210                  <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
 211                      <input type="submit" name="submit" value="<?php esc_attr_e('No, Return me to the plugin list') ?>" class="button" />
 212                  </form>
 213  
 214                  <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
 215                  <div id="files-list" style="display:none;">
 216                      <ul class="code">
 217                      <?php
 218                          foreach ( (array)$files_to_delete as $file )
 219                              echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
 220                      ?>
 221                      </ul>
 222                  </div>
 223              </div>
 224                  <?php
 225                  require_once ('admin-footer.php');
 226                  exit;
 227              } //Endif verify-delete
 228              $delete_result = delete_plugins($plugins);
 229  
 230              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
 231              wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page");
 232              exit;
 233              break;
 234          case 'clear-recent-list':
 235              update_option('recently_activated', array());
 236              break;
 237      }
 238  }
 239  
 240  wp_enqueue_script('plugin-install');
 241  add_thickbox();
 242  
 243  $help = '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>';
 244  if ( is_site_admin() ) {
 245  $help .= '<p>' . sprintf(__('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>';
 246  $help .= '<p>' . sprintf(__('You can find additional plugins for your site by using the new <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually.  To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%2$s</code> directory.  Once a plugin has been installed, you may activate it here.'), 'plugin-install.php', WP_PLUGIN_DIR) . '</p>';
 247  }
 248  
 249  add_contextual_help('plugins', $help);
 250  
 251  $title = __('Manage Plugins');
 252  require_once ('admin-header.php');
 253  
 254  $invalid = validate_active_plugins();
 255  if ( !empty($invalid) )
 256      foreach ( $invalid as $plugin_file => $error )
 257          echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>';
 258  ?>
 259  
 260  <?php if ( isset($_GET['error']) ) : ?>
 261      <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
 262      <?php
 263          if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
 264      <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
 265      <?php
 266          }
 267      ?>
 268      </div>
 269  <?php elseif ( isset($_GET['deleted']) ) :
 270          $delete_result = get_transient('plugins_delete_result_'.$user_ID);
 271          delete_transient('plugins_delete_result'); //Delete it once we're done.
 272  
 273          if ( is_wp_error($delete_result) ) : ?>
 274          <div id="message" class="updated fade"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
 275          <?php else : ?>
 276          <div id="message" class="updated fade"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
 277          <?php endif; ?>
 278  <?php elseif ( isset($_GET['activate']) ) : ?>
 279      <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
 280  <?php elseif (isset($_GET['activate-multi'])) : ?>
 281      <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
 282  <?php elseif ( isset($_GET['deactivate']) ) : ?>
 283      <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
 284  <?php elseif (isset($_GET['deactivate-multi'])) : ?>
 285      <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
 286  <?php endif; ?>
 287  
 288  <div class="wrap">
 289  <?php screen_icon(); ?>
 290  <h2><?php echo esc_html( $title ); if ( is_site_admin() ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2>
 291  
 292  <?php
 293  
 294  $all_plugins = apply_filters( 'all_plugins', get_plugins() );
 295  $search_plugins = array();
 296  $active_plugins = array();
 297  $inactive_plugins = array();
 298  $recent_plugins = array();
 299  $recently_activated = get_option('recently_activated', array());
 300  $upgrade_plugins = array();
 301  
 302  set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
 303  
 304  // Clean out any plugins which were deactivated over a week ago.
 305  foreach ( $recently_activated as $key => $time )
 306      if ( $time + (7*24*60*60) < time() ) //1 week
 307          unset($recently_activated[ $key ]);
 308  if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
 309      update_option('recently_activated', $recently_activated);
 310  $current = get_transient( 'update_plugins' );
 311  
 312  foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
 313  
 314      //Translate, Apply Markup, Sanitize HTML
 315      $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
 316      $all_plugins[ $plugin_file ] = $plugin_data;
 317  
 318      //Filter into individual sections
 319      if ( is_plugin_active($plugin_file) ) {
 320          $active_plugins[ $plugin_file ] = $plugin_data;
 321      } else {
 322          if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
 323              $recent_plugins[ $plugin_file ] = $plugin_data;
 324          $inactive_plugins[ $plugin_file ] = $plugin_data;
 325      }
 326  
 327      if ( isset( $current->response[ $plugin_file ] ) )
 328          $upgrade_plugins[ $plugin_file ] = $plugin_data;
 329  }
 330  
 331  if ( !is_site_admin() ) {
 332      $upgrade_plugins = false;
 333  }
 334  
 335  $total_all_plugins = count($all_plugins);
 336  $total_inactive_plugins = count($inactive_plugins);
 337  $total_active_plugins = count($active_plugins);
 338  $total_recent_plugins = count($recent_plugins);
 339  $total_upgrade_plugins = count($upgrade_plugins);
 340  
 341  //Searching.
 342  if ( isset($_GET['s']) ) {
 343  	function _search_plugins_filter_callback($plugin) {
 344          static $term;
 345          if ( is_null($term) )
 346              $term = stripslashes($_GET['s']);
 347          if (     stripos($plugin['Name'], $term) !== false ||
 348                  stripos($plugin['Description'], $term) !== false ||
 349                  stripos($plugin['Author'], $term) !== false ||
 350                  stripos($plugin['PluginURI'], $term) !== false ||
 351                  stripos($plugin['AuthorURI'], $term) !== false ||
 352                  stripos($plugin['Version'], $term) !== false )
 353              return true;
 354          else
 355              return false;
 356      }
 357      $status = 'search';
 358      $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback');
 359      $total_search_plugins = count($search_plugins);
 360  }
 361  
 362  $plugin_array_name = "$status}_plugins";
 363  if ( empty($$plugin_array_name) && $status != 'all' ) {
 364      $status = 'all';
 365      $plugin_array_name = "$status}_plugins";
 366  }
 367  
 368  $plugins = &$$plugin_array_name;
 369  
 370  //Paging.
 371  $total_this_page = "total_{$status}_plugins";
 372  $total_this_page = $$total_this_page;
 373  $plugins_per_page = (int) get_user_option( 'plugins_per_page', 0, false );
 374  if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
 375      $plugins_per_page = 999;
 376  $plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
 377  
 378  $start = ($page - 1) * $plugins_per_page;
 379  
 380  $page_links = paginate_links( array(
 381      'base' => add_query_arg( 'paged', '%#%' ),
 382      'format' => '',
 383      'prev_text' => __('&laquo;'),
 384      'next_text' => __('&raquo;'),
 385      'total' => ceil($total_this_page / $plugins_per_page),
 386      'current' => $page
 387  ));
 388  $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
 389      number_format_i18n( $start + 1 ),
 390      number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ),
 391      '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>',
 392      $page_links
 393  );
 394  
 395  /**
 396   * @ignore
 397   *
 398   * @param array $plugins
 399   * @param string $context
 400   */
 401  function print_plugins_table($plugins, $context = '') {
 402      global $page;
 403  ?>
 404  <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
 405      <thead>
 406      <tr>
 407          <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
 408          <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
 409          <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
 410      </tr>
 411      </thead>
 412  
 413      <tfoot>
 414      <tr>
 415          <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
 416          <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
 417          <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
 418      </tr>
 419      </tfoot>
 420  
 421      <tbody class="plugins">
 422  <?php
 423  
 424      if ( empty($plugins) ) {
 425          echo '<tr>
 426              <td colspan="3">' . __('No plugins to show') . '</td>
 427          </tr>';
 428      }
 429      foreach ( (array)$plugins as $plugin_file => $plugin_data) {
 430          $actions = array();
 431          $is_active = is_plugin_active($plugin_file);
 432  
 433          if ( $is_active )
 434              $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
 435          else
 436              $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
 437  
 438          if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
 439              $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
 440  
 441          if ( ! $is_active && current_user_can('delete_plugins') )
 442              $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
 443  
 444          $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
 445          $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
 446          $action_count = count($actions);
 447          $class = $is_active ? 'active' : 'inactive';
 448          echo "
 449      <tr class='$class'>
 450          <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
 451          <td class='plugin-title'><strong>{$plugin_data['Name']}</strong></td>
 452          <td class='desc'><p>{$plugin_data['Description']}</p></td>
 453      </tr>
 454      <tr class='$class second'>
 455          <td></td>
 456          <td class='plugin-title'>";
 457          echo '<div class="row-actions-visible">';
 458          foreach ( $actions as $action => $link ) {
 459              $sep = end($actions) == $link ? '' : ' | ';
 460              echo "<span class='$action'>$link$sep</span>";
 461          }
 462          echo "</div></td>
 463          <td class='desc'>";
 464          $plugin_meta = array();
 465          if ( !empty($plugin_data['Version']) )
 466              $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']);
 467          if ( !empty($plugin_data['Author']) ) {
 468              $author = $plugin_data['Author'];
 469              if ( !empty($plugin_data['AuthorURI']) )
 470                  $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
 471              $plugin_meta[] = sprintf( __('By %s'), $author );
 472          }
 473          if ( ! empty($plugin_data['PluginURI']) )
 474              $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
 475  
 476          $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
 477          echo implode(' | ', $plugin_meta);
 478          echo "</td>
 479      </tr>\n";
 480  
 481          do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
 482          do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
 483      }
 484  ?>
 485      </tbody>
 486  </table>
 487  <?php
 488  } //End print_plugins_table()
 489  
 490  /**
 491   * @ignore
 492   *
 493   * @param string $context
 494   */
 495  function print_plugin_actions($context, $field_name = 'action' ) {
 496  ?>
 497      <div class="alignleft actions">
 498          <select name="<?php echo $field_name; ?>">
 499              <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
 500      <?php if ( 'active' != $context ) : ?>
 501              <option value="activate-selected"><?php _e('Activate'); ?></option>
 502      <?php endif; ?>
 503      <?php if ( 'inactive' != $context && 'recent' != $context ) : ?>
 504              <option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
 505      <?php endif; ?>
 506      <?php if ( current_user_can('delete_plugins') && ( 'active' != $context ) ) : ?>
 507              <option value="delete-selected"><?php _e('Delete'); ?></option>
 508      <?php endif; ?>
 509          </select>
 510          <input type="submit" name="doaction_active" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary action" />
 511      <?php if( 'recent' == $context ) : ?>
 512          <input type="submit" name="clear-recent-list" value="<?php esc_attr_e('Clear List') ?>" class="button-secondary" />
 513      <?php endif; ?>
 514      </div>
 515  <?php
 516  }
 517  ?>
 518  
 519  <form method="get" action="">
 520  <p class="search-box">
 521      <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label>
 522      <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" />
 523      <input type="submit" value="<?php esc_attr_e( 'Search Plugins' ); ?>" class="button" />
 524  </p>
 525  </form>
 526  
 527  <?php do_action( 'pre_current_active_plugins', $all_plugins ) ?>
 528  
 529  <form method="post" action="<?php echo admin_url('plugins.php') ?>">
 530  <?php wp_nonce_field('bulk-manage-plugins') ?>
 531  <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
 532  <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
 533  
 534  <ul class="subsubsub">
 535  <?php
 536  $status_links = array();
 537  $class = ( 'all' == $status ) ? ' class="current"' : '';
 538  $status_links[] = "<li><a href='plugins.php?plugin_status=all' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_all_plugins, 'plugins' ), number_format_i18n( $total_all_plugins ) ) . '</a>';
 539  if ( ! empty($active_plugins) ) {
 540      $class = ( 'active' == $status ) ? ' class="current"' : '';
 541      $status_links[] = "<li><a href='plugins.php?plugin_status=active' $class>" . sprintf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $total_active_plugins ), number_format_i18n( $total_active_plugins ) ) . '</a>';
 542  }
 543  if ( ! empty($recent_plugins) ) {
 544      $class = ( 'recent' == $status ) ? ' class="current"' : '';
 545      $status_links[] = "<li><a href='plugins.php?plugin_status=recent' $class>" . sprintf( _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $total_recent_plugins ), number_format_i18n( $total_recent_plugins ) ) . '</a>';
 546  }
 547  if ( ! empty($inactive_plugins) ) {
 548      $class = ( 'inactive' == $status ) ? ' class="current"' : '';
 549      $status_links[] = "<li><a href='plugins.php?plugin_status=inactive' $class>" . sprintf( _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $total_inactive_plugins ), number_format_i18n( $total_inactive_plugins ) ) . '</a>';
 550  }
 551  if ( ! empty($upgrade_plugins) ) {
 552      $class = ( 'upgrade' == $status ) ? ' class="current"' : '';
 553      $status_links[] = "<li><a href='plugins.php?plugin_status=upgrade' $class>" . sprintf( _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $total_upgrade_plugins ), number_format_i18n( $total_upgrade_plugins ) ) . '</a>';
 554  }
 555  if ( ! empty($search_plugins) ) {
 556      $class = ( 'search' == $status ) ? ' class="current"' : '';
 557      $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : '';
 558      $status_links[] = "<li><a href='plugins.php?s=$term' $class>" . sprintf( _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $total_search_plugins ), number_format_i18n( $total_search_plugins ) ) . '</a>';
 559  }
 560  echo implode( " |</li>\n", $status_links ) . '</li>';
 561  unset( $status_links );
 562  ?>
 563  </ul>
 564  
 565  <div class="tablenav">
 566  <?php
 567  if ( $page_links )
 568      echo '<div class="tablenav-pages">', $page_links_text, '</div>';
 569  
 570  print_plugin_actions($status);
 571  ?>
 572  </div>
 573  <div class="clear"></div>
 574  <?php
 575      if ( $total_this_page > $plugins_per_page )
 576          $plugins = array_slice($plugins, $start, $plugins_per_page);
 577  
 578      print_plugins_table($plugins, $status);
 579  ?>
 580  <div class="tablenav">
 581  <?php
 582  if ( $page_links )
 583      echo "<div class='tablenav-pages'>$page_links_text</div>";
 584  
 585  print_plugin_actions($status, "action2");
 586  ?>
 587  </div>
 588  </form>
 589  
 590  <?php if ( empty($all_plugins) ) : ?>
 591  <p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
 592  <?php endif; ?>
 593  
 594  </div>
 595  
 596  <?php
 597  include ('admin-footer.php');
 598  ?>


Generated: Mon May 3 12:25:32 2010 Cross-referenced by PHPXref 0.7