Make WordPress Core

Changeset 5637


Ignore:
Timestamp:
06/02/2007 02:53:09 AM (17 years ago)
Author:
ryan
Message:

Separate AJAX cat adder into post and link flavors. see #4189

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r5545 r5637  
    122122            'id' => $cat_id,
    123123            'data' => "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>"
     124        ) );
     125    }
     126    $x->send();
     127    break;
     128case 'add-link-category' : // On the Fly
     129    if ( !current_user_can( 'manage_categories' ) )
     130        die('-1');
     131    $names = explode(',', $_POST['newcat']);
     132    $x = new WP_Ajax_Response();
     133    foreach ( $names as $cat_name ) {
     134        $cat_name = trim($cat_name);
     135        if ( !$slug = sanitize_title($cat_name) )
     136            die('0');
     137        if ( !$cat_id = category_exists( $cat_name ) ) {
     138            $cat_id = wp_insert_term( $cat_name, 'link_category' );
     139            $cat_id = $cat_id['term_id'];
     140        }
     141        $cat_name = wp_specialchars(stripslashes($cat_name));
     142        $x->add( array(
     143            'what' => 'link-category',
     144            'id' => $cat_id,
     145            'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>"
    124146        ) );
    125147    }
  • trunk/wp-admin/edit-link-form.php

    r5323 r5637  
    4444<div class="dbx-content">
    4545<p id="jaxcat"></p>
    46 <ul id="categorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
     46<ul id="linkcategorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
    4747</div>
    4848</fieldset>
  • trunk/wp-admin/includes/bookmark.php

    r5566 r5637  
    1414    $_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
    1515    $_POST['link_rss'] = clean_url($_POST['link_rss']);
    16     $_POST['link_category'] = $_POST['post_category'];
    1716
    1817    if ( !empty( $link_id ) ) {
  • trunk/wp-admin/includes/taxonomy.php

    r5566 r5637  
    66
    77function category_exists($cat_name) {
    8     return is_term($cat_name, 'category');
     8    $id = is_term($cat_name, 'category');
     9    if ( is_array($id) )
     10        $id = $id['term_id'];
     11    return $id;
    912}
    1013
  • trunk/wp-admin/includes/template.php

    r5622 r5637  
    158158        $name = wp_specialchars( apply_filters('the_category', $category->name));
    159159        $checked = in_array( $cat_id, $checked_categories );
    160         echo '<li id="category-', $cat_id, '"><label for="in-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="post_category[]" id="in-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
     160        echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
    161161    }
    162162}
  • trunk/wp-admin/link-add.php

    r4999 r5637  
    1414wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
    1515if ( current_user_can( 'manage_categories' ) )
    16     wp_enqueue_script( 'ajaxcat' );
     16    wp_enqueue_script( 'ajaxlinkcat' );
    1717require('admin-header.php');
    1818?>
  • trunk/wp-admin/link.php

    r4499 r5637  
    9494        wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
    9595        if ( current_user_can( 'manage_categories' ) )
    96             wp_enqueue_script( 'ajaxcat' );
     96            wp_enqueue_script( 'ajaxlinkcat' );
    9797        $parent_file = 'link-manager.php';
    9898        $submenu_file = 'link-manager.php';
  • trunk/wp-includes/script-loader.php

    r5631 r5637  
    110110                'how' => __('Separate multiple categories with commas.')
    111111            ) );
     112            $this->add( 'ajaxlinkcat', '/wp-admin/js/link-cat.js', array('listman'), '200700601' );
     113            $this->localize( 'ajaxlinkcat', 'linkcatL10n', array(
     114                'add' => attribute_escape(__('Add')),
     115                'how' => __('Separate multiple categories with commas.')
     116            ) );
    112117            $this->add( 'admin-categories', '/wp-admin/js/categories.js', array('listman'), '3684' );
    113118            $this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('listman'), '3733' );
Note: See TracChangeset for help on using the changeset viewer.