Changes from trunk/wp-admin/plugins.php at r17322 to branches/3.0/wp-admin/plugins.php at r16373
- File:
-
- 1 edited
-
branches/3.0/wp-admin/plugins.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-admin/plugins.php
r17322 r16373 9 9 /** WordPress Administration Bootstrap */ 10 10 require_once('./admin.php'); 11 12 11 if ( is_multisite() ) { 13 12 $menu_perms = get_site_option( 'menu_items', array() ); 14 13 15 if ( empty( $menu_perms['plugins']) && ! is_super_admin() )14 if ( empty($menu_perms['plugins']) && ! is_super_admin() ) 16 15 wp_die( __( 'Cheatin’ uh?' ) ); 17 } 18 19 if ( !current_user_can('activate_plugins') ) 16 else if ( $menu_perms['plugins'] != 1 && is_super_admin() ) 17 add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' ); 18 } 19 20 if ( ! current_user_can( 'activate_plugins' ) ) 20 21 wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) ); 21 22 22 $wp_list_table = _get_list_table('WP_Plugins_List_Table'); 23 $pagenum = $wp_list_table->get_pagenum(); 24 25 $action = $wp_list_table->current_action(); 23 if ( isset($_POST['clear-recent-list']) ) 24 $action = 'clear-recent-list'; 25 elseif ( !empty($_REQUEST['action']) ) 26 $action = $_REQUEST['action']; 27 elseif ( !empty($_REQUEST['action2']) ) 28 $action = $_REQUEST['action2']; 29 else 30 $action = false; 26 31 27 32 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; 28 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 29 30 // Clean up request URI from temporary args for screen options/paging uri's to work as expected. 33 34 $default_status = get_user_option('plugins_last_view'); 35 if ( empty($default_status) ) 36 $default_status = 'all'; 37 $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status; 38 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) ) 39 $status = 'all'; 40 if ( $status != $default_status && 'search' != $status ) 41 update_user_meta($current_user->ID, 'plugins_last_view', $status); 42 43 $page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1; 44 45 //Clean up request URI from temporary args for screen options/paging uri's to work as expected. 31 46 $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']); 32 47 33 if ( $action) {48 if ( !empty($action) ) { 34 49 $network_wide = false; 35 50 if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) ) … … 43 58 check_admin_referer('activate-plugin_' . $plugin); 44 59 45 $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), $network_wide);60 $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide); 46 61 if ( is_wp_error( $result ) ) { 47 62 if ( 'unexpected_output' == $result->get_error_code() ) { 48 $redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s");63 $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin; 49 64 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); 50 65 exit; … … 60 75 } 61 76 if ( isset($_GET['from']) && 'import' == $_GET['from'] ) { 62 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, striping the -importer suffix77 wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix 63 78 } else { 64 wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s")); // overrides the ?error=true one above79 wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above 65 80 } 66 81 exit; … … 71 86 wp_die(__('You do not have sufficient permissions to activate plugins for this site.')); 72 87 73 check_admin_referer('bulk- plugins');88 check_admin_referer('bulk-manage-plugins'); 74 89 75 90 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 76 77 // Only activate plugins which are not already active. 78 $check = $network_wide ? 'is_plugin_active_for_network' : 'is_plugin_active'; 79 foreach ( $plugins as $i => $plugin ) 80 if ( $check( $plugin ) ) 81 unset( $plugins[ $i ] ); 82 91 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active. 83 92 if ( empty($plugins) ) { 84 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s"));93 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 85 94 exit; 86 95 } 87 96 88 activate_plugins($plugins, self_admin_url('plugins.php?error=true'), $network_wide);97 activate_plugins($plugins, 'plugins.php?error=true', $network_wide); 89 98 90 99 $recent = (array)get_option('recently_activated'); … … 95 104 update_option('recently_activated', $recent); 96 105 97 wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s"));106 wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); 98 107 exit; 99 108 break; 100 109 case 'update-selected' : 101 110 102 check_admin_referer( 'bulk- plugins' );111 check_admin_referer( 'bulk-manage-plugins' ); 103 112 104 113 if ( isset( $_GET['plugins'] ) ) … … 109 118 $plugins = array(); 110 119 111 $title = __( 'Up date Plugins' );120 $title = __( 'Upgrade Plugins' ); 112 121 $parent_file = 'plugins.php'; 113 122 114 require_once( ABSPATH . 'wp-admin/admin-header.php');123 require_once( './admin-header.php' ); 115 124 116 125 echo '<div class="wrap">'; … … 119 128 120 129 121 $url = self_admin_url('update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) ));130 $url = 'update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) ); 122 131 $url = wp_nonce_url($url, 'bulk-update-plugins'); 123 132 124 133 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; 125 134 echo '</div>'; 126 require_once( ABSPATH . 'wp-admin/admin-footer.php');135 require_once( './admin-footer.php' ); 127 136 exit; 128 137 break; … … 160 169 deactivate_plugins($plugin); 161 170 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); 162 if ( headers_sent())163 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page &s=$s" ) . "' />";171 if (headers_sent()) 172 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page" ) . "' />"; 164 173 else 165 wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s"));174 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); 166 175 exit; 167 176 break; … … 170 179 wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.')); 171 180 172 check_admin_referer('bulk- plugins');181 check_admin_referer('bulk-manage-plugins'); 173 182 174 183 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 175 184 $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. 176 185 if ( empty($plugins) ) { 177 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s"));186 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 178 187 exit; 179 188 } … … 186 195 187 196 update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); 188 wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s"));197 wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); 189 198 exit; 190 199 break; … … 193 202 wp_die(__('You do not have sufficient permissions to delete plugins for this site.')); 194 203 195 check_admin_referer('bulk- plugins');204 check_admin_referer('bulk-manage-plugins'); 196 205 197 206 //$_POST = from the plugin form; $_GET = from the FTP details screen. 198 207 $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); 199 if ( empty( $plugins ) ) { 200 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); 201 exit; 202 } 203 204 $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins. 205 if ( empty( $plugins ) ) { 206 wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) ); 208 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins. 209 if ( empty($plugins) ) { 210 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 207 211 exit; 208 212 } … … 214 218 if ( ! isset($_REQUEST['verify-delete']) ) { 215 219 wp_enqueue_script('jquery'); 216 require_once( ABSPATH . 'wp-admin/admin-header.php');220 require_once('./admin-header.php'); 217 221 ?> 218 222 <div class="wrap"> 219 223 <?php 220 224 $files_to_delete = $plugin_info = array(); 221 $have_non_network_plugins = false;222 225 foreach ( (array) $plugins as $plugin ) { 223 226 if ( '.' == dirname($plugin) ) { … … 226 229 $plugin_info[ $plugin ] = $data; 227 230 $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); 228 if ( ! $plugin_info[ $plugin ]['Network'] )229 $have_non_network_plugins = true;230 231 } 231 232 } else { … … 238 239 if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) { 239 240 foreach( $folder_plugins as $plugin_file => $data ) { 240 $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );241 $plugin_info[ $plugin_file ] = $data; 241 242 $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); 242 if ( ! $plugin_info[ $plugin_file ]['Network'] )243 $have_non_network_plugins = true;244 243 } 245 244 } … … 250 249 echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>'; 251 250 ?> 252 <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>253 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This plugin may be active on other sites in the network.', 'These plugins may be active on other sites in the network.', $plugins_to_delete ); ?></p></div>254 <?php endif; ?>255 251 <p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p> 256 252 <ul class="ul-disc"> … … 260 256 if ( $plugin['is_uninstallable'] ) { 261 257 /* translators: 1: plugin name, 2: plugin author */ 262 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['Author Name']) ), '</li>';258 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '</li>'; 263 259 $data_to_delete = true; 264 260 } else { 265 261 /* translators: 1: plugin name, 2: plugin author */ 266 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['Author Name']) ), '</li>';262 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '</li>'; 267 263 } 268 264 } … … 279 275 <input type="hidden" name="action" value="delete-selected" /> 280 276 <?php 281 foreach ( (array) $plugins as $plugin )277 foreach ( (array)$plugins as $plugin ) 282 278 echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />'; 283 279 ?> 284 <?php wp_nonce_field('bulk- plugins') ?>285 < ?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>280 <?php wp_nonce_field('bulk-manage-plugins') ?> 281 <input type="submit" name="submit" value="<?php $data_to_delete ? esc_attr_e('Yes, Delete these files and data') : esc_attr_e('Yes, Delete these files') ?>" class="button" /> 286 282 </form> 287 283 <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;"> 288 < ?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>284 <input type="submit" name="submit" value="<?php esc_attr_e('No, Return me to the plugin list') ?>" class="button" /> 289 285 </form> 290 286 … … 300 296 </div> 301 297 <?php 302 require_once( ABSPATH . 'wp-admin/admin-footer.php');298 require_once('./admin-footer.php'); 303 299 exit; 304 300 } //Endif verify-delete 305 301 $delete_result = delete_plugins($plugins); 306 302 307 set_transient('plugins_delete_result_' .$user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length308 wp_redirect( self_admin_url("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s"));303 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 304 wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page"); 309 305 exit; 310 306 break; … … 315 311 } 316 312 317 $wp_list_table->prepare_items();318 319 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );320 if ( $pagenum > $total_pages && $total_pages > 0 ) {321 wp_redirect( add_query_arg( 'paged', $total_pages ) );322 exit;323 }324 325 313 wp_enqueue_script('plugin-install'); 326 314 add_thickbox(); 327 328 add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' )) );329 315 330 316 add_contextual_help($current_screen, … … 339 325 340 326 $title = __('Plugins'); 341 $parent_file = 'plugins.php'; 342 343 require_once(ABSPATH . 'wp-admin/admin-header.php'); 327 328 require_once('./admin-header.php'); 344 329 345 330 $invalid = validate_active_plugins(); … … 351 336 <?php if ( isset($_GET['error']) ) : 352 337 353 if ( isset( $_GET['main'] ) ) 354 $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' ); 355 elseif ( isset($_GET['charsout']) ) 338 if ( isset($_GET['charsout']) ) 356 339 $errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']); 357 340 else … … 360 343 <div id="message" class="updated"><p><?php echo $errmsg; ?></p> 361 344 <?php 362 if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>363 <iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>345 if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> 346 <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe> 364 347 <?php 365 348 } … … 389 372 <div class="wrap"> 390 373 <?php screen_icon(); ?> 391 <h2><?php echo esc_html( $title ); 392 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?> 393 <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a> 394 <?php } 395 if ( $s ) 396 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> 397 </h2> 398 399 <?php do_action( 'pre_current_active_plugins', $plugins['all'] ) ?> 400 401 <?php $wp_list_table->views(); ?> 402 403 <form method="post" action=""> 404 405 <?php $wp_list_table->search_box( __( 'Search Plugins' ), 'plugin' ); ?> 406 374 <h2><?php echo esc_html( $title ); if ( current_user_can('install_plugins') ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2> 375 376 <?php 377 378 $all_plugins = apply_filters( 'all_plugins', get_plugins() ); 379 $search_plugins = array(); 380 $active_plugins = array(); 381 $inactive_plugins = array(); 382 $recent_plugins = array(); 383 $recently_activated = get_option('recently_activated', array()); 384 $upgrade_plugins = array(); 385 $network_plugins = array(); 386 $mustuse_plugins = $dropins_plugins = array(); 387 if ( ! is_multisite() || current_user_can('manage_network_plugins') ) { 388 if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) 389 $mustuse_plugins = get_mu_plugins(); 390 if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) 391 $dropins_plugins = get_dropins(); 392 } 393 394 set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 ); 395 396 // Clean out any plugins which were deactivated over a week ago. 397 foreach ( $recently_activated as $key => $time ) 398 if ( $time + (7*24*60*60) < time() ) //1 week 399 unset($recently_activated[ $key ]); 400 if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it. 401 update_option('recently_activated', $recently_activated); 402 $current = get_site_transient( 'update_plugins' ); 403 404 foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) { 405 foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) { 406 // Translate, Apply Markup, Sanitize HTML 407 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); 408 ${$plugin_array_name}[ $plugin_file ] = $plugin_data; 409 } 410 } 411 unset( $plugin_array_name ); 412 413 foreach ( (array) $all_plugins as $plugin_file => $plugin_data) { 414 // Filter into individual sections 415 if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) { 416 unset( $all_plugins[ $plugin_file ] ); 417 continue; 418 } elseif ( is_plugin_active_for_network($plugin_file) ) { 419 $network_plugins[ $plugin_file ] = $plugin_data; 420 } elseif ( is_plugin_active($plugin_file) ) { 421 $active_plugins[ $plugin_file ] = $plugin_data; 422 } else { 423 if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated? 424 $recent_plugins[ $plugin_file ] = $plugin_data; 425 $inactive_plugins[ $plugin_file ] = $plugin_data; 426 } 427 428 if ( isset( $current->response[ $plugin_file ] ) ) 429 $upgrade_plugins[ $plugin_file ] = $plugin_data; 430 } 431 432 if ( !current_user_can('update_plugins') ) 433 $upgrade_plugins = array(); 434 435 $total_all_plugins = count($all_plugins); 436 $total_inactive_plugins = count($inactive_plugins); 437 $total_active_plugins = count($active_plugins); 438 $total_recent_plugins = count($recent_plugins); 439 $total_upgrade_plugins = count($upgrade_plugins); 440 $total_network_plugins = count($network_plugins); 441 $total_mustuse_plugins = count($mustuse_plugins); 442 $total_dropins_plugins = count($dropins_plugins); 443 444 // Searching. 445 if ( !empty($_GET['s']) ) { 446 function _search_plugins_filter_callback($plugin) { 447 static $term; 448 if ( is_null($term) ) 449 $term = stripslashes($_GET['s']); 450 if ( stripos($plugin['Name'], $term) !== false || 451 stripos($plugin['Description'], $term) !== false || 452 stripos($plugin['Author'], $term) !== false || 453 stripos($plugin['PluginURI'], $term) !== false || 454 stripos($plugin['AuthorURI'], $term) !== false || 455 stripos($plugin['Version'], $term) !== false ) 456 return true; 457 else 458 return false; 459 } 460 $status = 'search'; 461 $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback'); 462 $total_search_plugins = count($search_plugins); 463 } 464 465 $plugin_array_name = "${status}_plugins"; 466 if ( empty($$plugin_array_name) && !in_array($status, array('all', 'search')) ) { 467 $status = 'all'; 468 $plugin_array_name = "${status}_plugins"; 469 } 470 471 $plugins = &$$plugin_array_name; 472 473 // Paging. 474 $total_this_page = "total_{$status}_plugins"; 475 $total_this_page = $$total_this_page; 476 $plugins_per_page = (int) get_user_option( 'plugins_per_page' ); 477 if ( empty( $plugins_per_page ) || $plugins_per_page < 1 ) 478 $plugins_per_page = 999; 479 $plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page ); 480 481 $start = ($page - 1) * $plugins_per_page; 482 483 $page_links = paginate_links( array( 484 'base' => add_query_arg( 'paged', '%#%' ), 485 'format' => '', 486 'prev_text' => __('«'), 487 'next_text' => __('»'), 488 'total' => ceil($total_this_page / $plugins_per_page), 489 'current' => $page 490 )); 491 $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 492 number_format_i18n( $start + 1 ), 493 number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ), 494 '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>', 495 $page_links 496 ); 497 498 /** 499 * @ignore 500 * 501 * @param array $plugins 502 * @param string $context 503 */ 504 function print_plugins_table($plugins, $context = '') { 505 global $page; 506 $checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : ''; 507 ?> 508 <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table"> 509 <thead> 510 <tr> 511 <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th> 512 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th> 513 <th scope="col" class="manage-column"><?php _e('Description'); ?></th> 514 </tr> 515 </thead> 516 517 <tfoot> 518 <tr> 519 <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th> 520 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th> 521 <th scope="col" class="manage-column"><?php _e('Description'); ?></th> 522 </tr> 523 </tfoot> 524 525 <tbody class="plugins"> 526 <?php 527 528 if ( empty($plugins) ) { 529 echo '<tr> 530 <td colspan="3">' . __('No plugins to show') . '</td> 531 </tr>'; 532 } 533 foreach ( (array)$plugins as $plugin_file => $plugin_data) { 534 // preorder 535 $actions = array( 536 'network_deactivate' => '', 'deactivate' => '', 537 'network_only' => '', 'activate' => '', 538 'network_activate' => '', 539 'edit' => '', 540 'delete' => '', 541 ); 542 543 if ( 'mustuse' == $context ) { 544 $is_active = true; 545 } elseif ( 'dropins' == $context ) { 546 $dropins = _get_dropins(); 547 $plugin_name = $plugin_file; 548 if ( $plugin_file != $plugin_data['Name'] ) 549 $plugin_name .= '<br/>' . $plugin_data['Name']; 550 if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant 551 $is_active = true; 552 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; 553 } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true 554 $is_active = true; 555 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; 556 } else { 557 $is_active = false; 558 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>'; 559 } 560 if ( $plugin_data['Description'] ) 561 $description .= '<p>' . $plugin_data['Description'] . '</p>'; 562 } else { 563 $is_active_for_network = is_plugin_active_for_network($plugin_file); 564 $is_active = $is_active_for_network || is_plugin_active( $plugin_file ); 565 if ( $is_active_for_network && !is_super_admin() ) 566 continue; 567 568 if ( $is_active ) { 569 if ( $is_active_for_network ) { 570 if ( is_super_admin() ) 571 $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>'; 572 } else { 573 $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>'; 574 } 575 } else { 576 if ( is_multisite() && is_network_only_plugin( $plugin_file ) ) 577 $actions['network_only'] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>'; 578 else 579 $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 580 581 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) 582 $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>'; 583 584 if ( current_user_can('delete_plugins') ) 585 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; 586 } // end if $is_active 587 588 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 589 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 590 } // end if $context 591 592 $actions = apply_filters( 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context ); 593 $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 594 595 $class = $is_active ? 'active' : 'inactive'; 596 $checkbox = in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' />"; 597 if ( 'dropins' != $context ) { 598 $description = '<p>' . $plugin_data['Description'] . '</p>'; 599 $plugin_name = $plugin_data['Name']; 600 } 601 echo " 602 <tr class='$class'> 603 <th scope='row' class='check-column'>$checkbox</th> 604 <td class='plugin-title'><strong>$plugin_name</strong></td> 605 <td class='desc'>$description</td> 606 </tr> 607 <tr class='$class second'> 608 <td></td> 609 <td class='plugin-title'>"; 610 echo '<div class="row-actions-visible">'; 611 foreach ( $actions as $action => $link ) { 612 $sep = end($actions) == $link ? '' : ' | '; 613 echo "<span class='$action'>$link$sep</span>"; 614 } 615 echo "</div></td> 616 <td class='desc'>"; 617 $plugin_meta = array(); 618 if ( !empty($plugin_data['Version']) ) 619 $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']); 620 if ( !empty($plugin_data['Author']) ) { 621 $author = $plugin_data['Author']; 622 if ( !empty($plugin_data['AuthorURI']) ) 623 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 624 $plugin_meta[] = sprintf( __('By %s'), $author ); 625 } 626 if ( ! empty($plugin_data['PluginURI']) ) 627 $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>'; 628 629 $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context); 630 echo implode(' | ', $plugin_meta); 631 echo "</td> 632 </tr>\n"; 633 634 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context ); 635 do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context ); 636 } 637 ?> 638 </tbody> 639 </table> 640 <?php 641 } //End print_plugins_table() 642 643 /** 644 * @ignore 645 * 646 * @param string $context 647 */ 648 function print_plugin_actions($context, $field_name = 'action' ) { 649 if ( in_array( $context, array( 'mustuse', 'dropins' ) ) ) 650 return; 651 ?> 652 <div class="alignleft actions"> 653 <select name="<?php echo $field_name; ?>"> 654 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 655 <?php if ( 'active' != $context ) : ?> 656 <option value="activate-selected"><?php _e('Activate'); ?></option> 657 <?php endif; ?> 658 <?php if ( is_multisite() && 'network' != $context ) : ?> 659 <option value="network-activate-selected"><?php _e('Network Activate'); ?></option> 660 <?php endif; ?> 661 <?php if ( 'inactive' != $context && 'recent' != $context ) : ?> 662 <option value="deactivate-selected"><?php _e('Deactivate'); ?></option> 663 <?php endif; ?> 664 <?php if ( current_user_can( 'update_plugins' ) ) : ?> 665 <option value="update-selected"><?php _e( 'Upgrade' ); ?></option> 666 <?php endif; ?> 667 <?php if ( current_user_can('delete_plugins') && ( 'active' != $context ) ) : ?> 668 <option value="delete-selected"><?php _e('Delete'); ?></option> 669 <?php endif; ?> 670 </select> 671 <input type="submit" name="doaction_active" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary action" /> 672 <?php if ( 'recent' == $context ) : ?> 673 <input type="submit" name="clear-recent-list" value="<?php esc_attr_e('Clear List') ?>" class="button-secondary" /> 674 <?php endif; ?> 675 </div> 676 <?php 677 } 678 ?> 679 680 <form method="get" action=""> 681 <p class="search-box"> 682 <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label> 683 <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 684 <input type="submit" value="<?php esc_attr_e( 'Search Installed Plugins' ); ?>" class="button" /> 685 </p> 686 </form> 687 688 <?php do_action( 'pre_current_active_plugins', $all_plugins ) ?> 689 690 <form method="post" action="<?php echo admin_url('plugins.php') ?>"> 691 <?php wp_nonce_field('bulk-manage-plugins') ?> 407 692 <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" /> 408 693 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" /> 409 694 695 <ul class="subsubsub"> 696 <?php 697 $status_links = array(); 698 $class = ( 'all' == $status ) ? ' class="current"' : ''; 699 $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>'; 700 if ( ! empty($active_plugins) ) { 701 $class = ( 'active' == $status ) ? ' class="current"' : ''; 702 $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>'; 703 } 704 if ( ! empty($recent_plugins) ) { 705 $class = ( 'recent' == $status ) ? ' class="current"' : ''; 706 $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>'; 707 } 708 if ( ! empty($inactive_plugins) ) { 709 $class = ( 'inactive' == $status ) ? ' class="current"' : ''; 710 $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>'; 711 } 712 if ( ! empty($network_plugins) ) { 713 $class = ( 'network' == $status ) ? ' class="current"' : ''; 714 $status_links[] = "<li><a href='plugins.php?plugin_status=network' $class>" . sprintf( _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $total_network_plugins ), number_format_i18n( $total_network_plugins ) ) . '</a>'; 715 } 716 if ( ! empty($mustuse_plugins) ) { 717 $class = ( 'mustuse' == $status ) ? ' class="current"' : ''; 718 $status_links[] = "<li><a href='plugins.php?plugin_status=mustuse' $class>" . sprintf( _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $total_mustuse_plugins ), number_format_i18n( $total_mustuse_plugins ) ) . '</a>'; 719 } 720 if ( ! empty($dropins_plugins) ) { 721 $class = ( 'dropins' == $status ) ? ' class="current"' : ''; 722 $status_links[] = "<li><a href='plugins.php?plugin_status=dropins' $class>" . sprintf( _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $total_dropins_plugins ), number_format_i18n( $total_dropins_plugins ) ) . '</a>'; 723 } 724 if ( ! empty($upgrade_plugins) ) { 725 $class = ( 'upgrade' == $status ) ? ' class="current"' : ''; 726 $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>'; 727 } 728 if ( ! empty($search_plugins) ) { 729 $class = ( 'search' == $status ) ? ' class="current"' : ''; 730 $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : ''; 731 $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>'; 732 } 733 echo implode( " |</li>\n", $status_links ) . '</li>'; 734 unset( $status_links ); 735 ?> 736 </ul> 737 410 738 <?php 411 739 if ( 'mustuse' == $status ) 412 echo '< br class="clear" /><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';740 echo '<div class="clear"></div><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>'; 413 741 elseif ( 'dropins' == $status ) 414 echo '<br class="clear" /><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>'; 415 ?> 416 417 <?php $wp_list_table->display(); ?> 742 echo '<div class="clear"></div><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>'; 743 744 if ( !empty( $plugins ) && ( ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) ) : 745 ?> 746 <div class="tablenav"> 747 <?php 748 if ( $page_links ) 749 echo '<div class="tablenav-pages">', $page_links_text, '</div>'; 750 751 print_plugin_actions($status); 752 ?> 753 </div> 754 <div class="clear"></div> 755 <?php 756 endif; 757 758 if ( $total_this_page > $plugins_per_page ) 759 $plugins = array_slice($plugins, $start, $plugins_per_page); 760 761 print_plugins_table($plugins, $status); 762 763 if ( !empty( $plugins ) && ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) { 764 ?> 765 <div class="tablenav"> 766 <?php 767 if ( $page_links ) 768 echo "<div class='tablenav-pages'>$page_links_text</div>"; 769 770 print_plugin_actions($status, "action2"); 771 ?> 772 </div> 773 <?php } ?> 418 774 </form> 419 775 776 <?php if ( empty($all_plugins) ) : ?> 777 <br class="clear" /> 778 <p><?php _e('You do not appear to have any plugins available at this time.') ?></p> 779 <?php endif; ?> 780 420 781 </div> 421 782 422 783 <?php 423 include(ABSPATH . 'wp-admin/admin-footer.php'); 784 include('./admin-footer.php'); 785 ?>
Note: See TracChangeset
for help on using the changeset viewer.