WordPress.org

Make WordPress Core

Ticket #11184: 11184-cats-tags-links-3.2.patch

File 11184-cats-tags-links-3.2.patch, 4.4 KB (added by nacin, 4 years ago)

New patch for bulk action feedback: cats, tags/tax, links & link cats

  • categories.php

     
    3434break; 
    3535 
    3636case 'delete': 
     37        if ( !isset( $_GET['tag_ID'] ) ) 
     38                wp_redirect('categories.php?message=7'); 
     39 
    3740        $cat_ID = (int) $_GET['cat_ID']; 
    3841        check_admin_referer('delete-category_' .  $cat_ID); 
    3942 
     
    5962        if ( !current_user_can('manage_categories') ) 
    6063                wp_die( __('You are not allowed to delete categories.') ); 
    6164 
    62         foreach ( (array) $_GET['delete'] as $cat_ID ) { 
     65        $cats = $_GET['delete']; 
     66        foreach ( (array) $cats as $cat_ID ) { 
    6367                $cat_name = get_cat_name($cat_ID); 
    6468 
    6569                // Don't delete the default cats. 
     
    6973                wp_delete_category($cat_ID); 
    7074        } 
    7175 
    72         wp_safe_redirect( wp_get_referer() ); 
     76        if ( count( (array) $cats ) == 1 ) 
     77                wp_safe_redirect( add_query_arg( 'message', 2, wp_get_referer() ) ); 
     78        else 
     79                wp_safe_redirect( add_query_arg( 'message', 6, wp_get_referer() ) ); 
    7380        exit(); 
    7481 
    7582break; 
     
    125132$messages[3] = __('Category updated.'); 
    126133$messages[4] = __('Category not added.'); 
    127134$messages[5] = __('Category not updated.'); 
     135$messages[6] = __('Categories deleted.'); 
     136$messages[7] = __('No categories selected.'); 
    128137?> 
    129138 
    130139<div class="wrap nosubsub"> 
  • edit-tags.php

     
    4444break; 
    4545 
    4646case 'delete': 
     47        if ( !isset( $_GET['tag_ID'] ) ) 
     48                wp_redirect('edit-tags.php?message=7'); 
     49 
    4750        $tag_ID = (int) $_GET['tag_ID']; 
    4851        check_admin_referer('delete-tag_' .  $tag_ID); 
    4952 
     
    8184                        $location = $referer; 
    8285        } 
    8386 
    84         $location = add_query_arg('message', 6, $location); 
     87        if ( count( (array) $tags ) == 1 ) 
     88                $location = add_query_arg('message', 2, $location); 
     89        else 
     90                $location = add_query_arg('message', 6, $location); 
    8591        wp_redirect($location); 
    8692        exit; 
    8793 
     
    142148$messages[3] = __('Tag updated.'); 
    143149$messages[4] = __('Tag not added.'); 
    144150$messages[5] = __('Tag not updated.'); 
    145 $messages[6] = __('Tags deleted.'); ?> 
     151$messages[6] = __('Tags deleted.'); 
     152$messages[7] = __('No tags selected.'); ?> 
    146153 
    147154<div class="wrap nosubsub"> 
    148155<?php screen_icon(); ?> 
  • link-manager.php

     
    1818                wp_die( __('You do not have sufficient permissions to edit the links for this blog.') ); 
    1919 
    2020        if ( 'delete' == $doaction ) { 
    21                 foreach ( (array) $_GET['linkcheck'] as $link_id ) { 
     21                $bulklinks = $_GET['linkcheck']; 
     22                foreach ( (array) $bulklinks as $link_id ) { 
    2223                        $link_id = (int) $link_id; 
    2324 
    2425                        wp_delete_link($link_id); 
    2526                } 
    2627 
    27                 wp_redirect( wp_get_referer() ); 
     28                wp_redirect( add_query_arg( 'deleted', count( (array) $bulklinks ), wp_get_referer() ) ); 
    2829                exit; 
    2930        } 
    3031} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 
  • edit-link-categories.php

     
    1818                wp_die(__('Cheatin&#8217; uh?')); 
    1919 
    2020        if ( 'delete' == $doaction ) { 
    21                 foreach( (array) $_GET['delete'] as $cat_ID ) { 
     21                $cats = $_GET['delete']; 
     22                foreach( (array) $cats as $cat_ID ) { 
    2223                        $cat_name = get_term_field('name', $cat_ID, 'link_category'); 
    2324                        $default_cat_id = get_option('default_link_category'); 
    2425 
     
    3536                                $location = $referer; 
    3637                } 
    3738 
    38                 $location = add_query_arg('message', 6, $location); 
     39                if ( count( (array) $cats ) == 1 ) 
     40                        $location = add_query_arg( 'message', 2, $location ); 
     41                else 
     42                        $location = add_query_arg( 'message', 6, $location ); 
    3943                wp_redirect($location); 
    4044                exit(); 
    4145        } 
    4246} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 
    43          wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 
     47         wp_redirect( add_query_arg( 'message', 7, remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ) ); 
    4448         exit; 
    4549} 
    4650 
     
    5761$messages[3] = __('Category updated.'); 
    5862$messages[4] = __('Category not added.'); 
    5963$messages[5] = __('Category not updated.'); 
    60 $messages[6] = __('Categories deleted.'); ?> 
     64$messages[6] = __('Categories deleted.'); 
     65$messages[7] = __('No categories selected.'); ?> 
    6166 
    6267<div class="wrap nosubsub"> 
    6368<?php screen_icon(); ?>