wp_ajax_add_tag [ WordPress Function ]
wp_ajax_add_tag ( No parameters )
| Defined at: |
|
Benzer Fonksiyonlar: wp_ajax_add_meta, wp_ajax_delete_tag, wp_ajax_add_user, wp_ajax_add_menu_item, wp_ajax_autosave
No description yet.
Source
<?php
function wp_ajax_add_tag() {
global $wp_list_table;
check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
$post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
$tax = get_taxonomy($taxonomy);
if ( !current_user_can( $tax->cap->edit_terms ) )
wp_die( -1 );
$x = new WP_Ajax_Response();
$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
$message = __('An error has occurred. Please reload the page and try again.');
if ( is_wp_error($tag) && $tag->get_error_message() )
$message = $tag->get_error_message();
$x->add( array(
'what' => 'taxonomy',
'data' => new WP_Error('error', $message )
) );
$x->send();
}
set_current_screen( $_POST['screen'] );
$wp_list_table = _get_list_table('WP_Terms_List_Table');
$level = 0;
if ( is_taxonomy_hierarchical($taxonomy) ) {
$level = count( get_ancestors( $tag->term_id, $taxonomy ) );
ob_start();
$wp_list_table->single_row( $tag, $level );
$noparents = ob_get_clean();
}
ob_start();
$wp_list_table->single_row( $tag );
$parents = ob_get_clean();
$x->add( array(
'what' => 'taxonomy',
'supplemental' => compact('parents', 'noparents')
) );
$x->add( array(
'what' => 'term',
'position' => $level,
'supplemental' => (array) $tag
) );
$x->send();
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- PHPXRef 0.7 : WordPress : Detail view of ajax-actions.php
wp_ajax_add_tag() wp_ajax_get_tagcloud() wp_ajax_get_comments() wp_ajax_replyto_comment() wp_ajax_edit_comment() wp_ajax_add_menu_item() ...
phpxref.ftwr.co.uk - Docs for page ajax-actions.php
/wp-admin/includes/ajax-actions.php. Description. Description | ...
phpdoc.wordpress.org - #20086 (Javascript error when submitting an existing taxonomy ...
Bail from AJAX success callback if wp_ajax_add_tag() returns errors. Props solarissmoke. Fixes #20086. Note: See TracTickets for help on using tickets.
core.trac.wordpress.org - WordPress 3.4-beta1
Apr 5, 2012 ... error, 600, No DocBlock was found for function wp_ajax_add_tag(). error, 655, No DocBlock was found for function wp_ajax_get_tagcloud() ...
docs.garyjones.co.uk