Make WordPress Core

Ticket #15489: garyc40-15489.patch

File garyc40-15489.patch, 9.3 KB (added by garyc40, 13 years ago)

there's a patch for that

  • wp-admin/admin-ajax.php

    diff --git wp-admin/admin-ajax.php wp-admin/admin-ajax.php
    index 5eb33e1..a2048dc 100644
    function _wp_ajax_add_hierarchical_term() { 
    319319
    320320$id = isset($_POST['id'])? (int) $_POST['id'] : 0;
    321321switch ( $action = $_POST['action'] ) :
     322case 'delete-post-list-item' :
     323        $post = get_post( $id );
     324        if ( ! $post ) {
     325                die( (string) time() );
     326        }
     327       
     328        if ( ! current_user_can( 'delete_post', $post->ID ) ) {
     329                die( '-1' );
     330        }
     331       
     332        $post_type = $_POST['post_type'];
     333       
     334        if ( ! empty( $_POST['trash'] ) ) {
     335                check_ajax_referer( "trash-{$post_type}_{$post->ID}" );
     336                $status = get_post_status( $post->ID );
     337                if ( $status != 'trash' && ! wp_trash_post( $post->ID ) ) {
     338                        die( '0' );
     339                }
     340        } elseif ( ! empty( $_POST['delete'] ) ) {
     341                check_ajax_referer( "delete-{$post_type}_{$post->ID}" );
     342                if ( ! wp_delete_post( $post->ID ) ) {
     343                        die( '0' );
     344                }
     345        } elseif ( ! empty( $_POST['untrash'] ) ) {
     346                if ( ! wp_untrash_post( $post->ID ) ) {
     347                        die( '0' );
     348                }
     349        } else {
     350                die( '-1' );
     351        }
     352        die( (string) time() );
     353        break;
    322354case 'delete-comment' : // On success, die with time() instead of 1
    323355        if ( !$comment = get_comment( $id ) )
    324356                die( (string) time() );
  • wp-admin/edit.php

    diff --git wp-admin/edit.php wp-admin/edit.php
    index 5e0154f..fb1620a 100644
    if ( $wp_list_table->has_items() ) 
    261261</div>
    262262
    263263<?php
     264wp_post_trashnotice();
    264265include('./admin-footer.php');
  • wp-admin/includes/class-wp-posts-list-table.php

    diff --git wp-admin/includes/class-wp-posts-list-table.php wp-admin/includes/class-wp-posts-list-table.php
    index 801fb96..2d8a1bf 100644
    class WP_Posts_List_Table extends WP_List_Table { 
    7575
    7676                parent::WP_List_Table( array(
    7777                        'plural' => 'posts',
     78                        'singular' => 'post-list-item',
    7879                ) );
    7980        }
    8081
    class WP_Posts_List_Table extends WP_List_Table { 
    162163                        if ( !in_array( $status_name, $avail_post_stati ) )
    163164                                continue;
    164165
    165                         if ( empty( $num_posts->$status_name ) )
     166                        if ( $status_name != 'trash' && empty( $num_posts->$status_name ) )
    166167                                continue;
    167168
    168169                        if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
    class WP_Posts_List_Table extends WP_List_Table { 
    544545                                }
    545546                                if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
    546547                                        if ( 'trash' == $post->post_status )
    547                                                 $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
     548                                                $actions['untrash'] = "<a class='delete:the-list:post-" . get_the_ID() . "::untrash=1' title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
    548549                                        elseif ( EMPTY_TRASH_DAYS )
    549                                                 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
     550                                                $actions['trash'] = "<a class='delete:the-list:post-" . get_the_ID() . "::trash=1 submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
    550551                                        if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
    551                                                 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
     552                                                $actions['delete'] = "<a class='delete:the-list:post-" . get_the_ID() . "::delete=1 submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
    552553                                }
    553554                                if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) ) {
    554555                                        if ( $can_edit_post )
  • wp-admin/includes/template.php

    diff --git wp-admin/includes/template.php wp-admin/includes/template.php
    index 8a1e995..a3f05c3 100644
    function get_inline_data($post) { 
    288288        <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
    289289        <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
    290290
     291        if ( $post->post_status = 'trash' ) {
     292                echo '<div class="_wp_trash_meta_status">' . get_post_meta( $post->ID, '_wp_trash_meta_status', true ) . '</div>';
     293        }
     294
    291295        if ( $post_type_object->hierarchical )
    292296                echo '<div class="post_parent">' . $post->post_parent . '</div>';
    293297
    function wp_comment_trashnotice() { 
    408412}
    409413
    410414/**
     415 * Output 'undo move to trash' text for posts
     416 *
     417 * @since 3.2.0
     418 */
     419function wp_post_trashnotice() {
     420?>
     421<div class="hidden" id="trash-undo-holder">
     422        <div class="trash-undo-inside"><?php printf(__('%s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
     423</div>
     424<?php
     425}
     426
     427/**
    411428 * {@internal Missing Short Description}}
    412429 *
    413430 * @since 1.2.0
  • wp-admin/js/inline-edit-post.dev.js

    diff --git wp-admin/js/inline-edit-post.dev.js wp-admin/js/inline-edit-post.dev.js
    index 1a257c6..fecfbfb 100644
     
    11(function($) {
     2var inlineEditPost, postList;
     3
     4postList = {
     5        theList : {},
     6        postType : userSettings.typenow,
     7        init : function() {
     8                var t = this;
     9                t.theList = $('#the-list').wpList({
     10                        alt : '',
     11                        delBefore : t.delBefore,
     12                        delAfter : t.delAfter,
     13                        addColor : 'none'
     14                }).bind('wpListDelEnd', function(e, s){
     15                        var id = s.element.replace(/[^0-9]+/g, '');
     16                        if (s.target.className.indexOf(':trash=1') != -1)
     17                                $('#undo-' + id).fadeIn(300, function(){});
     18                });
     19        },
     20        delBefore : function(settings, list) {
     21                var cl = $(settings.target).attr('class'), el, colspan, undoRow, title, id;
     22                settings.data.post_type = typenow;
     23                if (cl.indexOf(':trash=1') != -1) {
     24                        id = cl.replace(/.*?post-([0-9]+).*/, '$1');
     25                        el = $('#post-' + id);
     26                        el.find('.check-column :checkbox').attr('checked', ''); // Uncheck the row so as not to be affected by Bulk Edits.
     27                        note = $('#trash-undo-holder').html();
     28                        colspan = el.children(':visible').length;
     29                        title = el.find('.post_title').text();
     30                        undoRow = $('<tr id="undo-' + id + '" class="undo untrash" style="display:none;"><td colspan="' + colspan + '">' + note + '</td></tr>').
     31                                insertBefore(el).
     32                                find('strong').
     33                                        text(title).end().
     34                                find('.undo a').
     35                                        attr('href', 'post.php?action=untrash&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce).
     36                                        attr('class', 'delete:the-list:post-' + id + '::untrash=1').
     37                                        click(function(){
     38                                                list.wpList.del(this);
     39                                                $('#undo-' + id).css('backgroundColor', '#ceb').fadeOut(350, function(){
     40                                                        $(this).remove();
     41                                                        $('#post-' + id).css('backgroundColor', '').fadeIn(300, function(){});
     42                                                });
     43                                                return false;
     44                                        });
     45                }
     46               
     47                return settings;
     48        },
     49        updateCount : function(counts) {
     50                var index, el, count, url;
     51               
     52                for (index in counts) {
     53                        el = $('.subsubsub .' + index + ' .count');
     54                        count = el.text().replace(/[^0-9]+/g, '') * 1;
     55                        count += counts[index];
     56                        el.text('(' + count + ')');
     57                }
     58        },
     59        delAfter : function(r, settings) {
     60                var counts = {},
     61                        action = $(settings.target).parent(),
     62                        id = $(settings.target).attr('class').replace(/.*?post-([0-9]+).*/, '$1'),
     63                        tr = $('#post-' + id),                 
     64                        status = tr.find('._status').text(),
     65                        sticky = tr.find('.sticky').text();
     66       
     67                if (action.is('span.trash')) {
     68                        counts['all'] = -1;
     69                        counts['trash'] = 1;
     70                        counts[status] = -1;
     71                        if (sticky) {
     72                                counts['sticky'] = -1;
     73                        }
     74                } else if (action.is('span.untrash')) {
     75                        counts['all'] = 1;
     76                        counts['trash'] = -1;
     77                       
     78                        status = tr.find('._wp_trash_meta_status').text();
     79                       
     80                        if (status != 'trash') {
     81                                counts[status] = 1;
     82                        }
     83                       
     84                        if (sticky) {
     85                                counts['sticky'] = 1;
     86                        }
     87                } else if (action.is('span.delete')) {
     88                        counts['trash'] = -1;
     89                }
     90               
     91                postList.updateCount(counts);
     92               
     93                return true;
     94        }
     95};
     96
    297inlineEditPost = {
    398
    499        init : function(){
    inlineEditPost = { 
    282377        }
    283378};
    284379
    285 $(document).ready(function(){inlineEditPost.init();});
     380$(document).ready(function(){inlineEditPost.init(); postList.init();});
    286381})(jQuery);
  • wp-includes/script-loader.php

    diff --git wp-includes/script-loader.php wp-includes/script-loader.php
    index 1d72dd5..d048167 100644
    function wp_default_scripts( &$scripts ) { 
    387387                $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
    388388                $scripts->add_data( 'theme-preview', 'group', 1 );
    389389
    390                 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20100707' );
     390                $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'wp-lists' ), '20100707' );
    391391                $scripts->add_data( 'inline-edit-post', 'group', 1 );
    392392                $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
    393393                        'error' => __('Error while saving the changes.'),