wppaste
WordPress

wp_ajax_delete_tag()

Since
3.1.0
Source
wp-admin/includes/ajax-actions.php:792
Handles deleting a tag via AJAX.

Uses · 6

  • check_ajax_referer()Verifies the Ajax request to prevent processing requests external of the blog.
  • current_user_can()Returns whether the current user has the specified capability.
  • wp_die()Kills WordPress execution and displays HTML page with an error message.
  • get_term()Gets all term data from database by term ID.
  • is_wp_error()Checks whether the given variable is a WordPress Error.
  • wp_delete_term()Removes a term from the database.

Source

function wp_ajax_delete_tag() {	$tag_id = (int) $_POST['tag_ID'];	check_ajax_referer( "delete-tag_$tag_id" ); 	if ( ! current_user_can( 'delete_term', $tag_id ) ) {		wp_die( -1 );	} 	$taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag';	$tag      = get_term( $tag_id, $taxonomy ); 	if ( ! $tag || is_wp_error( $tag ) ) {		wp_die( 1 );	} 	if ( wp_delete_term( $tag_id, $taxonomy ) ) {		wp_die( 1 );	} else {		wp_die( 0 );	}}

History

Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/ajax-actions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.