WordPress.org

Make WordPress Core

Ticket #18710: 18710.diff

File 18710.diff, 5.3 KB (added by johnbillion, 5 years ago)

Refreshed patch

  • wp-admin/edit.php

    diff --git wp-admin/edit.php wp-admin/edit.php
    index 65fd034..9acfac9 100644
    if ( 'post' == $post_type ) { 
    224224
    225225add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
    226226
     227$counts = array(
     228        0 => null,
     229        1 => isset( $_REQUEST['updated'] )   ? absint( $_REQUEST['updated'] )   : 0,
     230        2 => isset( $_REQUEST['locked'] )    ? absint( $_REQUEST['locked'] )    : 0,
     231        3 => isset( $_REQUEST['deleted'] )   ? absint( $_REQUEST['deleted'] )   : 0,
     232        4 => isset( $_REQUEST['trashed'] )   ? absint( $_REQUEST['trashed'] )   : 0,
     233        5 => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0,
     234);
     235
     236$bulk_messages = array();
     237$bulk_messages['post'] = array(
     238        0 => '',
     239        1 => _n( '%s post updated.', '%s posts updated.', $counts[1] ),
     240        2 => _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $counts[2] ),
     241        3 => _n( '%s post permanently deleted.', '%s posts permanently deleted.', $counts[3] ),
     242        4 => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $counts[4] ),
     243        5 => _n( '%s post restored from the Trash.', '%s posts restored from the Trash.', $counts[5] ),
     244);
     245$bulk_messages['page'] = array(
     246        0 => '',
     247        1 => _n( '%s page updated.', '%s pages updated.', $counts[1] ),
     248        2 => _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $counts[2] ),
     249        3 => _n( '%s page permanently deleted.', '%s pages permanently deleted.', $counts[3] ),
     250        4 => _n( '%s page moved to the Trash.', '%s pages moved to the Trash.', $counts[4] ),
     251        5 => _n( '%s page restored from the Trash.', '%s pages restored from the Trash.', $counts[5] ),
     252);
     253
     254$bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $counts );
     255unset( $counts );
     256
    227257require_once('./admin-header.php');
    228258?>
    229259<div class="wrap">
    if ( ! empty( $_REQUEST['s'] ) ) 
    239269<?php if ( isset( $_REQUEST['locked'] ) || isset( $_REQUEST['updated'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) ) {
    240270        $messages = array();
    241271?>
    242 <div id="message" class="updated"><p>
    243272<?php if ( isset( $_REQUEST['updated'] ) && $updated = absint( $_REQUEST['updated'] ) ) {
    244         $messages[] = sprintf( _n( '%s post updated.', '%s posts updated.', $updated ), number_format_i18n( $updated ) );
     273
     274        if ( isset( $bulk_messages[$post_type][1] ) )
     275                $messages[] = sprintf( $bulk_messages[$post_type][1], number_format_i18n( $updated ) );
     276        else if ( isset( $bulk_messages['post'][1] ) )
     277                $messages[] = sprintf( $bulk_messages['post'][1], number_format_i18n( $updated ) );
     278
    245279}
    246280
    247281if ( isset( $_REQUEST['locked'] ) && $locked = absint( $_REQUEST['locked'] ) ) {
    248         $messages[] = sprintf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $locked ), number_format_i18n( $locked ) );
     282
     283        if ( isset( $bulk_messages[$post_type][2] ) )
     284                $messages[] = sprintf( $bulk_messages[$post_type][2], number_format_i18n( $locked ) );
     285        else if ( isset( $bulk_messages['post'][2] ) )
     286                $messages[] = sprintf( $bulk_messages['post'][2], number_format_i18n( $locked ) );
     287
    249288}
    250289
    251290if ( isset( $_REQUEST['deleted'] ) && $deleted = absint( $_REQUEST['deleted'] ) ) {
    252         $messages[] = sprintf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $deleted ), number_format_i18n( $deleted ) );
     291
     292        if ( isset( $bulk_messages[$post_type][3] ) )
     293                $messages[] = sprintf( $bulk_messages[$post_type][3], number_format_i18n( $deleted ) );
     294        else if ( isset( $bulk_messages['post'][3] ) )
     295                $messages[] = sprintf( $bulk_messages['post'][3], number_format_i18n( $deleted ) );
     296
    253297}
    254298
    255299if ( isset( $_REQUEST['trashed'] ) && $trashed = absint( $_REQUEST['trashed'] ) ) {
    256         $messages[] = sprintf( _n( 'Item moved to the Trash.', '%s items moved to the Trash.', $trashed ), number_format_i18n( $trashed ) );
     300
     301        if ( isset( $bulk_messages[$post_type][4] ) )
     302                $messages[] = sprintf( $bulk_messages[$post_type][4], number_format_i18n( $trashed ) );
     303        else if ( isset( $bulk_messages['post'][4] ) )
     304                $messages[] = sprintf( $bulk_messages['post'][4], number_format_i18n( $trashed ) );
     305
    257306        $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    258307        $messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a>';
     308
    259309}
    260310
    261311if ( isset( $_REQUEST['untrashed'] ) && $untrashed = absint( $_REQUEST['untrashed'] ) ) {
    262         $messages[] = sprintf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $untrashed ), number_format_i18n( $untrashed ) );
     312
     313        if ( isset( $bulk_messages[$post_type][5] ) )
     314                $messages[] = sprintf( $bulk_messages[$post_type][5], number_format_i18n( $untrashed ) );
     315        else if ( isset( $bulk_messages['post'][5] ) )
     316                $messages[] = sprintf( $bulk_messages['post'][5], number_format_i18n( $untrashed ) );
     317
    263318}
    264319
    265320if ( $messages )
    266         echo join( ' ', $messages );
     321        echo '<div id="message" class="updated"><p>' . join( ' ', $messages ) . '</p></div>';
    267322unset( $messages );
    268323
    269324$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );
    270325?>
    271 </p></div>
    272326<?php } ?>
    273327
    274328<?php $wp_list_table->views(); ?>