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.


Built from https://develop.svn.wordpress.org/trunk@40655


git-svn-id: http://core.svn.wordpress.org/trunk@40518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2017-05-12 19:26:41 +00:00
parent 6f4a1049a8
commit d1ec180619
14 changed files with 94 additions and 14 deletions

View File

@ -874,7 +874,8 @@ hr {
.submitbox .submitdelete,
#media-items a.delete,
#media-items a.delete-permanently,
#nav-menu-footer .menu-delete {
#nav-menu-footer .menu-delete,
#delete-link a.delete {
color: #a00;
}
@ -890,7 +891,8 @@ span.required,
.submitbox .submitdelete:hover,
#media-items a.delete:hover,
#media-items a.delete-permanently:hover,
#nav-menu-footer .menu-delete:hover {
#nav-menu-footer .menu-delete:hover,
#delete-link a.delete:hover {
color: #dc3232;
border: none;
}
@ -911,6 +913,17 @@ span.required,
line-height: 28px;
}
#delete-link {
line-height: 28px;
vertical-align: middle;
text-align: right;
margin-right: 8px;
}
#delete-link a {
text-decoration: none;
}
#publishing-action {
text-align: left;
float: left;

File diff suppressed because one or more lines are too long

View File

@ -874,7 +874,8 @@ hr {
.submitbox .submitdelete,
#media-items a.delete,
#media-items a.delete-permanently,
#nav-menu-footer .menu-delete {
#nav-menu-footer .menu-delete,
#delete-link a.delete {
color: #a00;
}
@ -890,7 +891,8 @@ span.required,
.submitbox .submitdelete:hover,
#media-items a.delete:hover,
#media-items a.delete-permanently:hover,
#nav-menu-footer .menu-delete:hover {
#nav-menu-footer .menu-delete:hover,
#delete-link a.delete:hover {
color: #dc3232;
border: none;
}
@ -911,6 +913,17 @@ span.required,
line-height: 28px;
}
#delete-link {
line-height: 28px;
vertical-align: middle;
text-align: left;
margin-left: 8px;
}
#delete-link a {
text-decoration: none;
}
#publishing-action {
text-align: right;
float: right;

File diff suppressed because one or more lines are too long

View File

@ -1092,6 +1092,17 @@ p.popular-tags a {
text-decoration: underline;
}
#edittag {
max-width: 800px;
}
.edit-tag-actions {
margin-top: 20px;
overflow: hidden;
padding: 10px;
margin-left: 10px;
}
/* Comments */
.comment-php .wp-editor-area {
@ -1348,6 +1359,10 @@ table.links-table {
}
@media screen and ( max-width: 782px ) {
.wp-core-ui .edit-tag-actions .button-primary {
margin-bottom: 0;
}
#post-body-content {
min-width: 0;
}

File diff suppressed because one or more lines are too long

View File

@ -1092,6 +1092,17 @@ p.popular-tags a {
text-decoration: underline;
}
#edittag {
max-width: 800px;
}
.edit-tag-actions {
margin-top: 20px;
overflow: hidden;
padding: 10px;
margin-right: 10px;
}
/* Comments */
.comment-php .wp-editor-area {
@ -1348,6 +1359,10 @@ table.links-table {
}
@media screen and ( max-width: 782px ) {
.wp-core-ui .edit-tag-actions .button-primary {
margin-bottom: 0;
}
#post-body-content {
min-width: 0;
}

File diff suppressed because one or more lines are too long

View File

@ -254,9 +254,20 @@ if ( 'category' == $taxonomy ) {
* @param string $taxonomy Current taxonomy slug.
*/
do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
submit_button( __('Update') );
?>
<div class="edit-tag-actions">
<?php submit_button( __( 'Update' ), 'primary', null, false ); ?>
<?php if ( current_user_can( 'delete_term', $tag->term_id ) ) : ?>
<span id="delete-link">
<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>
</span>
<?php endif; ?>
</div>
</form>
</div>

View File

@ -65,7 +65,6 @@ if ( ! $referer ) { // For POST requests.
$referer = wp_unslash( $_SERVER['REQUEST_URI'] );
}
$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer );
switch ( $wp_list_table->current_action() ) {
case 'add-tag':
@ -107,6 +106,9 @@ case 'delete':
$location = add_query_arg( 'message', 2, $referer );
// When deleting a term, prevent the action from redirecting back to a term that no longer exists.
$location = remove_query_arg( array( 'tag_ID', 'action' ), $location );
break;
case 'bulk-delete':

View File

@ -28,6 +28,17 @@ jQuery(document).ready(function($) {
return false;
});
$( '#edittag' ).on( 'click', '.delete', function( e ) {
if ( 'undefined' === typeof showNotice ) {
return true;
}
var response = showNotice.warn();
if ( ! response ) {
e.preventDefault();
}
});
$('#submit').click(function(){
var form = $(this).parents('form');

View File

@ -1 +1 @@
jQuery(document).ready(function(a){a("#the-list").on("click",".delete-tag",function(){var b,c=a(this),d=c.parents("tr"),e=!0;return"undefined"!=showNotice&&(e=showNotice.warn()),e&&(b=c.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),a.post(ajaxurl,b,function(c){"1"==c?(a("#ajax-response").empty(),d.fadeOut("normal",function(){d.remove()}),a('select#parent option[value="'+b.match(/tag_ID=(\d+)/)[1]+'"]').remove(),a("a.tag-link-"+b.match(/tag_ID=(\d+)/)[1]).remove()):"-1"==c?(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#submit").click(function(){var b=a(this).parents("form");return!!validateForm(b)&&(a.post(ajaxurl,a("#addtag").serialize(),function(c){var d,e,f,g,h;if(a("#ajax-response").empty(),d=wpAjax.parseAjaxResponse(c,"ajax-response"),d&&!d.errors){if(e=b.find("select#parent").val(),e>0&&a("#tag-"+e).length>0?a(".tags #tag-"+e).after(d.responses[0].supplemental.noparents):a(".tags").prepend(d.responses[0].supplemental.parents),a(".tags .no-items").remove(),b.find("select#parent")){for(f=d.responses[1].supplemental,g="",h=0;h<d.responses[1].position;h++)g+="&nbsp;&nbsp;&nbsp;";b.find("select#parent option:selected").after('<option value="'+f.term_id+'">'+g+f.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")}}),!1)})});
jQuery(document).ready(function(a){a("#the-list").on("click",".delete-tag",function(){var b,c=a(this),d=c.parents("tr"),e=!0;return"undefined"!=showNotice&&(e=showNotice.warn()),e&&(b=c.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),a.post(ajaxurl,b,function(c){"1"==c?(a("#ajax-response").empty(),d.fadeOut("normal",function(){d.remove()}),a('select#parent option[value="'+b.match(/tag_ID=(\d+)/)[1]+'"]').remove(),a("a.tag-link-"+b.match(/tag_ID=(\d+)/)[1]).remove()):"-1"==c?(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#edittag").on("click",".delete",function(a){if("undefined"==typeof showNotice)return!0;var b=showNotice.warn();b||a.preventDefault()}),a("#submit").click(function(){var b=a(this).parents("form");return!!validateForm(b)&&(a.post(ajaxurl,a("#addtag").serialize(),function(c){var d,e,f,g,h;if(a("#ajax-response").empty(),d=wpAjax.parseAjaxResponse(c,"ajax-response"),d&&!d.errors){if(e=b.find("select#parent").val(),e>0&&a("#tag-"+e).length>0?a(".tags #tag-"+e).after(d.responses[0].supplemental.noparents):a(".tags").prepend(d.responses[0].supplemental.parents),a(".tags .no-items").remove(),b.find("select#parent")){for(f=d.responses[1].supplemental,g="",h=0;h<d.responses[1].position;h++)g+="&nbsp;&nbsp;&nbsp;";b.find("select#parent option:selected").after('<option value="'+f.term_id+'">'+g+f.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")}}),!1)})});

View File

@ -62,7 +62,7 @@ get_current_screen()->set_screen_reader_content( array(
'heading_pagination' => $tax->labels->items_list_navigation,
'heading_list' => $tax->labels->items_list,
) );
wp_enqueue_script( 'admin-tags' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
include( ABSPATH . 'wp-admin/edit-tag-form.php' );
include( ABSPATH . 'wp-admin/admin-footer.php' );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40654';
$wp_version = '4.8-alpha-40655';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.