Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_ajax_add_link_category [ WordPress Function ]

wp_ajax_add_link_category ( $action )
Defined at:



No description yet.

Source


<?php
function wp_ajax_add_link_category$action ) {
    
check_ajax_referer$action );
    if ( !
current_user_can'manage_categories' ) )
        
wp_die( -);
    
$names explode(','$_POST['newcat']);
    
$x = new WP_Ajax_Response();
    foreach ( 
$names as $cat_name ) {
        
$cat_name trim($cat_name);
        
$slug sanitize_title($cat_name);
        if ( 
'' === $slug )
            continue;
        if ( !
$cat_id term_exists$cat_name'link_category' ) )
            
$cat_id wp_insert_term$cat_name'link_category' );
        if ( 
is_wp_error$cat_id ) )
            continue;
        else if ( 
is_array$cat_id ) )
            
$cat_id $cat_id['term_id'];
        
$cat_name esc_html(stripslashes($cat_name));
        
$x->add( array(
            
'what' => 'link-category',
            
'id' => $cat_id,
            
'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='" esc_attr($cat_id) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>",
            
'position' => -1
        
) );
    }
    
$x->send();
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics