WordPress.org

Make WordPress Core

Changeset 40655


Ignore:
Timestamp:
05/12/2017 07:25:43 PM (12 months ago)
Author:
adamsilverstein
Message:

Taxonomy: Add a "delete" button on term edit page.

Add a 'delete' link next to the update button on the term edit screen so you can delete a term while you are reviewing it's details.

Props cklosows, bradt, ocean90, johnbillion, DrewAPicture, ryan, MatheusGimenez, maguiar.
Fixes #9777.

Location:
trunk/src/wp-admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/common.css

    r40633 r40655  
    875875#media-items a.delete,
    876876#media-items a.delete-permanently,
    877 #nav-menu-footer .menu-delete {
     877#nav-menu-footer .menu-delete,
     878#delete-link a.delete  {
    878879    color: #a00;
    879880}
     
    891892#media-items a.delete:hover,
    892893#media-items a.delete-permanently:hover,
    893 #nav-menu-footer .menu-delete:hover {
     894#nav-menu-footer .menu-delete:hover,
     895#delete-link a.delete:hover {
    894896    color: #dc3232;
    895897    border: none;
     
    910912    float: left;
    911913    line-height: 28px;
     914}
     915
     916#delete-link {
     917    line-height: 28px;
     918    vertical-align: middle;
     919    text-align: left;
     920    margin-left: 8px;
     921}
     922
     923#delete-link a {
     924    text-decoration: none;
    912925}
    913926
  • trunk/src/wp-admin/css/edit.css

    r40052 r40655  
    10911091.ac_match {
    10921092    text-decoration: underline;
     1093}
     1094
     1095#edittag {
     1096    max-width: 800px;
     1097}
     1098
     1099.edit-tag-actions {
     1100    margin-top: 20px;
     1101    overflow: hidden;
     1102    padding: 10px;
     1103    margin-right: 10px;
    10931104}
    10941105
     
    13491360
    13501361@media screen and ( max-width: 782px ) {
     1362    .wp-core-ui .edit-tag-actions .button-primary {
     1363        margin-bottom: 0;
     1364    }
     1365
    13511366    #post-body-content {
    13521367        min-width: 0;
  • trunk/src/wp-admin/edit-tag-form.php

    r40146 r40655  
    255255 */
    256256do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
    257 
    258 submit_button( __('Update') );
    259257?>
     258
     259<div class="edit-tag-actions">
     260
     261    <?php submit_button( __( 'Update' ), 'primary', null, false ); ?>
     262
     263    <?php if ( current_user_can( 'delete_term', $tag->term_id ) ) : ?>
     264        <span id="delete-link">
     265            <a class="delete" href="<?php echo admin_url( wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) ) ?>"'><?php _e( 'Delete' ); ?></a>
     266        </span>
     267    <?php endif; ?>
     268
     269</div>
     270
    260271</form>
    261272</div>
  • trunk/src/wp-admin/edit-tags.php

    r40146 r40655  
    6666}
    6767$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer );
    68 
    6968switch ( $wp_list_table->current_action() ) {
    7069
     
    107106
    108107    $location = add_query_arg( 'message', 2, $referer );
     108
     109    // When deleting a term, prevent the action from redirecting back to a term that no longer exists.
     110    $location = remove_query_arg( array( 'tag_ID', 'action' ), $location );
    109111
    110112    break;
  • trunk/src/wp-admin/js/tags.js

    r31750 r40655  
    2727        }
    2828        return false;
     29    });
     30
     31    $( '#edittag' ).on( 'click', '.delete', function( e ) {
     32        if ( 'undefined' === typeof showNotice ) {
     33            return true;
     34        }
     35
     36        var response = showNotice.warn();
     37        if ( ! response ) {
     38            e.preventDefault();
     39        }
    2940    });
    3041
  • trunk/src/wp-admin/term.php

    r38698 r40655  
    6363    'heading_list'       => $tax->labels->items_list,
    6464) );
    65 
     65wp_enqueue_script( 'admin-tags' );
    6666require_once( ABSPATH . 'wp-admin/admin-header.php' );
    6767include( ABSPATH . 'wp-admin/edit-tag-form.php' );
Note: See TracChangeset for help on using the changeset viewer.