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