Ticket #28085: 28085.patch
File 28085.patch, 19.6 KB (added by , 11 years ago) |
---|
-
includes/class-wp-plugins-list-table.php
18 18 ) ); 19 19 20 20 $status = 'all'; 21 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', ' upgrade', 'mustuse', 'dropins', 'search' ) ) )21 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'recently_updated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) { 22 22 $status = $_REQUEST['plugin_status']; 23 } 23 24 24 if ( isset($_REQUEST['s']) ) 25 $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) ); 25 if ( isset( $_REQUEST['s'] ) ) { 26 $_SERVER['REQUEST_URI'] = add_query_arg( 's', wp_unslash( $_REQUEST['s'] ) ); 27 } 26 28 27 29 $page = $this->get_pagenum(); 28 30 } … … 55 57 'active' => array(), 56 58 'inactive' => array(), 57 59 'recently_activated' => array(), 60 'recently_updated' => array(), 58 61 'upgrade' => array(), 59 62 'mustuse' => array(), 60 63 'dropins' => array() … … 84 87 } 85 88 86 89 /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */ 87 if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) 90 if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) { 88 91 $plugins['dropins'] = get_dropins(); 92 } 89 93 90 94 if ( current_user_can( 'update_plugins' ) ) { 91 95 $current = get_site_transient( 'update_plugins' ); … … 103 107 if ( ! $screen->in_admin( 'network' ) ) { 104 108 $recently_activated = get_option( 'recently_activated', array() ); 105 109 106 foreach ( $recently_activated as $key => $time ) 107 if ( $time + WEEK_IN_SECONDS < time() ) 110 foreach ( $recently_activated as $key => $time ) { 111 if ( $time + WEEK_IN_SECONDS < time() ) { 108 112 unset( $recently_activated[$key] ); 113 } 114 } 109 115 update_option( 'recently_activated', $recently_activated ); 116 117 $recently_updated = get_option( 'recently_updated', array() ); 118 119 foreach ( $recently_updated as $key => $time ) { 120 if ( $time + WEEK_IN_SECONDS < time() ) { 121 unset( $recently_updated[$key] ); 122 } 123 } 124 update_option( 'recently_updated', $recently_updated ); 110 125 } 111 126 112 127 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { … … 127 142 // On the non-network screen, populate the recently activated list with plugins that have been recently activated 128 143 $plugins['recently_activated'][ $plugin_file ] = $plugin_data; 129 144 } 145 if ( ! $screen->in_admin( 'network' ) && isset( $recently_updated[ $plugin_file ] ) ) { 146 // On the non-network screen, populate the recently updated list with plugins that have been recently updated 147 $plugins['recently_updated'][ $plugin_file ] = $plugin_data; 148 } 130 149 // Populate the inactive list with plugins that aren't activated 131 150 $plugins['inactive'][ $plugin_file ] = $plugin_data; 132 151 } … … 138 157 } 139 158 140 159 $totals = array(); 141 foreach ( $plugins as $type => $list ) 160 foreach ( $plugins as $type => $list ) { 142 161 $totals[ $type ] = count( $list ); 162 } 143 163 144 if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) )164 if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) { 145 165 $status = 'all'; 166 } 146 167 147 168 $this->items = array(); 148 169 foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { 149 170 // Translate, Don't Apply Markup, Sanitize HTML 150 $this->items[ $plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );171 $this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); 151 172 } 152 173 153 174 $total_this_page = $totals[ $status ]; … … 163 184 164 185 $start = ( $page - 1 ) * $plugins_per_page; 165 186 166 if ( $total_this_page > $plugins_per_page ) 187 if ( $total_this_page > $plugins_per_page ) { 167 188 $this->items = array_slice( $this->items, $start, $plugins_per_page ); 189 } 168 190 169 191 $this->set_pagination_args( array( 170 192 'total_items' => $total_this_page, … … 174 196 175 197 function _search_callback( $plugin ) { 176 198 static $term; 177 if ( is_null( $term ) ) 199 if ( is_null( $term ) ) { 178 200 $term = wp_unslash( $_REQUEST['s'] ); 201 } 179 202 180 203 foreach ( $plugin as $value ) { 181 204 if ( false !== stripos( strip_tags( $value ), $term ) ) { … … 189 212 function _order_callback( $plugin_a, $plugin_b ) { 190 213 global $orderby, $order; 191 214 192 $a = $plugin_a[ $orderby];193 $b = $plugin_b[ $orderby];215 $a = $plugin_a[ $orderby ]; 216 $b = $plugin_b[ $orderby ]; 194 217 195 if ( $a == $b ) 218 if ( $a == $b ) { 196 219 return 0; 220 } 197 221 198 if ( 'DESC' == $order ) 222 if ( 'DESC' == $order ) { 199 223 return ( $a < $b ) ? 1 : -1; 200 else224 } else { 201 225 return ( $a < $b ) ? -1 : 1; 226 } 202 227 } 203 228 204 229 function no_items() { 205 230 global $plugins; 206 231 207 if ( !empty( $plugins['all'] ) ) 232 if ( !empty( $plugins['all'] ) ) { 208 233 _e( 'No plugins found.' ); 209 else234 } else { 210 235 _e( 'You do not appear to have any plugins available at this time.' ); 236 } 211 237 } 212 238 213 239 function get_columns() { … … 214 240 global $status; 215 241 216 242 return array( 217 'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',243 'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '', 218 244 'name' => __( 'Plugin' ), 219 245 'description' => __( 'Description' ), 220 246 ); … … 229 255 230 256 $status_links = array(); 231 257 foreach ( $totals as $type => $count ) { 232 if ( ! $count )258 if ( ! $count ) { 233 259 continue; 260 } 234 261 235 262 switch ( $type ) { 236 263 case 'all': … … 242 269 case 'recently_activated': 243 270 $text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count ); 244 271 break; 272 case 'recently_updated': 273 $text = _n( 'Recently Updated <span class="count">(%s)</span>', 'Recently Updated <span class="count">(%s)</span>', $count ); 274 break; 245 275 case 'inactive': 246 276 $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count ); 247 277 break; … … 257 287 } 258 288 259 289 if ( 'search' != $type ) { 260 $status_links[ $type] = sprintf( "<a href='%s' %s>%s</a>",261 add_query_arg( 'plugin_status', $type, 'plugins.php'),290 $status_links[ $type ] = sprintf( '<a href="%s"%s>%s</a>', 291 add_query_arg( 'plugin_status', $type, 'plugins.php' ), 262 292 ( $type == $status ) ? ' class="current"' : '', 263 293 sprintf( $text, number_format_i18n( $count ) ) 264 294 ); … … 273 303 274 304 $actions = array(); 275 305 276 if ( 'active' != $status ) 306 if ( 'active' != $status ) { 277 307 $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); 308 } 278 309 279 if ( 'inactive' != $status && 'recent' != $status ) 310 if ( 'inactive' != $status && 'recent' != $status ) { 280 311 $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); 312 } 281 313 282 314 if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) { 283 if ( current_user_can( 'update_plugins' ) ) 315 if ( current_user_can( 'update_plugins' ) ) { 284 316 $actions['update-selected'] = __( 'Update' ); 285 if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) 317 } 318 if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) { 286 319 $actions['delete-selected'] = __( 'Delete' ); 320 } 287 321 } 288 322 289 323 return $actions; … … 292 326 function bulk_actions() { 293 327 global $status; 294 328 295 if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) 329 if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) { 296 330 return; 331 } 297 332 298 333 parent::bulk_actions(); 299 334 } … … 301 336 function extra_tablenav( $which ) { 302 337 global $status; 303 338 304 if ( ! in_array($status, array('recently_activated', ' mustuse', 'dropins') ) )339 if ( ! in_array($status, array('recently_activated', 'recently_updated', 'mustuse', 'dropins') ) ) { 305 340 return; 341 } 306 342 307 343 echo '<div class="alignleft actions">'; 308 344 309 if ( ! $this->screen->in_admin( 'network' ) && 'recently_activated' == $status ) 345 if ( ! $this->screen->in_admin( 'network' ) && 'recently_activated' == $status ) { 310 346 submit_button( __( 'Clear List' ), 'button', 'clear-recent-list', false ); 311 elseif ( 'top' == $which && 'mustuse' == $status ) 347 } elseif ( ! $this->screen->in_admin( 'network' ) && 'recently_updated' == $status ) { 348 submit_button( __( 'Clear List' ), 'button', 'clear-updated-list', false ); 349 } elseif ( 'top' == $which && 'mustuse' == $status ) { 312 350 echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>'; 313 elseif ( 'top' == $which && 'dropins' == $status )351 } elseif ( 'top' == $which && 'dropins' == $status ) { 314 352 echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the <code>%s</code> directory that replace WordPress functionality when present.' ), str_replace( ABSPATH, '', WP_CONTENT_DIR ) ) . '</p>'; 353 } 315 354 316 355 echo '</div>'; 317 356 } 318 357 319 358 function current_action() { 320 if ( isset( $_POST['clear-recent-list']) )359 if ( isset( $_POST['clear-recent-list'] ) ) { 321 360 return 'clear-recent-list'; 361 } 322 362 363 if ( isset( $_POST['clear-updated-list'] ) ) { 364 return 'clear-updated-list'; 365 } 366 323 367 return parent::current_action(); 324 368 } 325 369 … … 326 370 function display_rows() { 327 371 global $status; 328 372 329 if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) 373 if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) { 330 374 return; 375 } 331 376 332 foreach ( $this->items as $plugin_file => $plugin_data ) 377 foreach ( $this->items as $plugin_file => $plugin_data ) { 333 378 $this->single_row( array( $plugin_file, $plugin_data ) ); 379 } 334 380 } 335 381 336 382 function single_row( $item ) { … … 353 399 } elseif ( 'dropins' == $context ) { 354 400 $dropins = _get_dropins(); 355 401 $plugin_name = $plugin_file; 356 if ( $plugin_file != $plugin_data['Name'] ) 402 if ( $plugin_file != $plugin_data['Name'] ) { 357 403 $plugin_name .= '<br/>' . $plugin_data['Name']; 404 } 358 405 if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant 359 406 $is_active = true; 360 407 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; … … 365 412 $is_active = false; 366 413 $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>'; 367 414 } 368 if ( $plugin_data['Description'] ) 415 if ( $plugin_data['Description'] ) { 369 416 $description .= '<p>' . $plugin_data['Description'] . '</p>'; 417 } 370 418 } else { 371 if ( $screen->in_admin( 'network' ) ) 419 if ( $screen->in_admin( 'network' ) ) { 372 420 $is_active = is_plugin_active_for_network( $plugin_file ); 373 else421 } else { 374 422 $is_active = is_plugin_active( $plugin_file ); 423 } 375 424 376 425 if ( $screen->in_admin( 'network' ) ) { 377 426 if ( $is_active ) { 378 if ( current_user_can( 'manage_network_plugins' ) ) 379 $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>'; 427 if ( current_user_can( 'manage_network_plugins' ) ) { 428 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" title="' . esc_attr__( 'Deactivate this plugin' ) . '">' . __( 'Network Deactivate' ) . '</a>'; 429 } 380 430 } else { 381 if ( current_user_can( 'manage_network_plugins' ) ) 382 $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>'; 383 if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) 384 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; 431 if ( current_user_can( 'manage_network_plugins' ) ) { 432 $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ) . '" title="' . esc_attr__( 'Activate this plugin for all sites in this network' ) . '" class="edit">' . __( 'Network Activate' ) . '</a>'; 433 } 434 if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) { 435 $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ) . '" title="' . esc_attr__( 'Delete this plugin' ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 436 } 385 437 } 386 438 } else { 387 439 if ( $is_active ) { 388 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';440 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" title="' . esc_attr__( 'Deactivate this plugin' ) . '">' . __( 'Deactivate' ) . '</a>'; 389 441 } else { 390 $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';442 $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ) . '" title="' . esc_attr__( 'Activate this plugin' ) . '" class="edit">' . __( 'Activate' ) . '</a>'; 391 443 392 if ( ! is_multisite() && current_user_can('delete_plugins') ) 393 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; 444 if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) { 445 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ) . '" title="' . esc_attr__( 'Delete this plugin' ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 446 } 394 447 } // end if $is_active 395 448 } // end if $screen->in_admin( 'network' ) 396 449 397 if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 398 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 450 if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can( 'edit_plugins' ) && is_writable( WP_PLUGIN_DIR . '/' . $plugin_file ) ) { 451 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__( 'Open this file in the Plugin Editor' ) . '" class="edit">' . __( 'Edit' ) . '</a>'; 452 } 399 453 } // end if $context 400 454 401 455 $prefix = $screen->in_admin( 'network' ) ? 'network_admin_' : ''; … … 462 516 } 463 517 464 518 $id = sanitize_title( $plugin_name ); 465 if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) 519 if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) { 466 520 $class .= ' update'; 521 } 467 522 468 523 echo "<tr id='$id' class='$class'>"; 469 524 … … 471 526 472 527 foreach ( $columns as $column_name => $column_display_name ) { 473 528 $style = ''; 474 if ( in_array( $column_name, $hidden ) ) 529 if ( in_array( $column_name, $hidden ) ) { 475 530 $style = ' style="display:none;"'; 531 } 476 532 477 533 switch ( $column_name ) { 478 534 case 'cb': … … 489 545 <div class='$class second plugin-version-author-uri'>"; 490 546 491 547 $plugin_meta = array(); 492 if ( ! empty( $plugin_data['Version'] ) )548 if ( ! empty( $plugin_data['Version'] ) ) { 493 549 $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 494 if ( !empty( $plugin_data['Author'] ) ) { 550 } 551 if ( ! empty( $plugin_data['Author'] ) ) { 495 552 $author = $plugin_data['Author']; 496 if ( ! empty( $plugin_data['AuthorURI'] ) )553 if ( ! empty( $plugin_data['AuthorURI'] ) ) { 497 554 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 555 } 498 556 $plugin_meta[] = sprintf( __( 'By %s' ), $author ); 499 557 } 500 if ( ! empty( $plugin_data['PluginURI'] ) ) 558 if ( ! empty( $plugin_data['PluginURI'] ) ) { 501 559 $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin site' ) . '">' . __( 'Visit plugin site' ) . '</a>'; 560 } 502 561 503 562 /** 504 563 * Filter the array of row meta for each plugin in the Plugins list table. -
includes/class-wp-upgrader.php
416 416 417 417 if ( ! $is_multi ) { 418 418 419 if ( isset( $hook_extra['action'], $hook_extra['type'] ) && 'update' == $hook_extra['action'] && 'plugin' == $hook_extra['type'] ) { 420 if ( isset( $hook_extra['plugin'] ) ) { 421 wp_set_recently_updated( array( $hook_extra['plugin'] ) ); 422 } elseif( isset( $hook_extra['plugins'] ) ) { 423 wp_set_recently_updated( $hook_extra['plugins'] ); 424 } 425 } 419 426 /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ 420 427 do_action( 'upgrader_process_complete', $this, $hook_extra ); 421 428 $this->skin->footer(); … … 637 644 638 645 $this->maintenance_mode(false); 639 646 647 wp_set_recently_updated( $plugins ); 640 648 /** 641 649 * Fires when the bulk upgrader process is complete. 642 650 * -
plugins.php
326 326 exit; 327 327 break; 328 328 case 'clear-recent-list': 329 if ( ! is_network_admin() ) 329 if ( ! is_network_admin() ) { 330 330 update_option( 'recently_activated', array() ); 331 } 331 332 break; 333 case 'clear-updated-list': 334 if ( ! is_network_admin() ) { 335 update_option( 'recently_updated', array() ); 336 } 337 break; 332 338 } 333 339 } 334 340