diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 139780500b..7218be8e49 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -125,6 +125,28 @@ case 'add-category' : // On the Fly
}
$x->send();
break;
+case 'add-link-category' : // On the Fly
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+ $names = explode(',', $_POST['newcat']);
+ $x = new WP_Ajax_Response();
+ foreach ( $names as $cat_name ) {
+ $cat_name = trim($cat_name);
+ if ( !$slug = sanitize_title($cat_name) )
+ die('0');
+ if ( !$cat_id = category_exists( $cat_name ) ) {
+ $cat_id = wp_insert_term( $cat_name, 'link_category' );
+ $cat_id = $cat_id['term_id'];
+ }
+ $cat_name = wp_specialchars(stripslashes($cat_name));
+ $x->add( array(
+ 'what' => 'link-category',
+ 'id' => $cat_id,
+ 'data' => "
"
+ ) );
+ }
+ $x->send();
+ break;
case 'add-cat' : // From Manage->Categories
if ( !current_user_can( 'manage_categories' ) )
die('-1');
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
index 91c1a31763..1527688b19 100644
--- a/wp-admin/edit-link-form.php
+++ b/wp-admin/edit-link-form.php
@@ -43,7 +43,7 @@ function xfn_check($class, $value = '', $type = 'check') {
diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php
index 490a9e41f5..36cb2edb1c 100644
--- a/wp-admin/includes/bookmark.php
+++ b/wp-admin/includes/bookmark.php
@@ -13,7 +13,6 @@ function edit_link( $link_id = '' ) {
$_POST['link_name'] = wp_specialchars( $_POST['link_name'] );
$_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
$_POST['link_rss'] = clean_url($_POST['link_rss']);
- $_POST['link_category'] = $_POST['post_category'];
if ( !empty( $link_id ) ) {
$_POST['link_id'] = $link_id;
diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php
index 2f04328b89..39fb0abc91 100644
--- a/wp-admin/includes/taxonomy.php
+++ b/wp-admin/includes/taxonomy.php
@@ -5,7 +5,10 @@
//
function category_exists($cat_name) {
- return is_term($cat_name, 'category');
+ $id = is_term($cat_name, 'category');
+ if ( is_array($id) )
+ $id = $id['term_id'];
+ return $id;
}
function get_category_to_edit( $id ) {
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 0721fc26f8..857bdaa600 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -157,7 +157,7 @@ function dropdown_link_categories( $default = 0 ) {
$cat_id = $category->term_id;
$name = wp_specialchars( apply_filters('the_category', $category->name));
$checked = in_array( $cat_id, $checked_categories );
- echo '";
+ echo '";
}
}
diff --git a/wp-admin/js/link-cat.js b/wp-admin/js/link-cat.js
new file mode 100644
index 0000000000..a0775ce158
--- /dev/null
+++ b/wp-admin/js/link-cat.js
@@ -0,0 +1,10 @@
+addLoadEvent(function(){linkcatList=new listMan('linkcategorychecklist');linkcatList.ajaxRespEl='jaxcat';linkcatList.topAdder=1;linkcatList.alt=0;linkcatList.showLink=0;});
+addLoadEvent(newLinkCatAddIn);
+function newLinkCatAddIn() {
+ var jaxcat = $('jaxcat');
+ if ( !jaxcat )
+ return false;
+ Element.update(jaxcat,'' + linkcatL10n.how + '');
+ $('newcat').onkeypress = function(e) { return killSubmit("linkcatList.ajaxAdder('link-category','jaxcat');", e); };
+ $('catadd').onclick = function() { linkcatList.ajaxAdder('link-category', 'jaxcat'); };
+}
diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php
index 1e48fe8547..2b06d8ec0b 100644
--- a/wp-admin/link-add.php
+++ b/wp-admin/link-add.php
@@ -13,7 +13,7 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) )
- wp_enqueue_script( 'ajaxcat' );
+ wp_enqueue_script( 'ajaxlinkcat' );
require('admin-header.php');
?>
diff --git a/wp-admin/link.php b/wp-admin/link.php
index 425e912cfc..464943a8f0 100644
--- a/wp-admin/link.php
+++ b/wp-admin/link.php
@@ -93,7 +93,7 @@ switch ($action) {
case 'edit' :
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) )
- wp_enqueue_script( 'ajaxcat' );
+ wp_enqueue_script( 'ajaxlinkcat' );
$parent_file = 'link-manager.php';
$submenu_file = 'link-manager.php';
$title = __('Edit Link');
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index 6ab9c54440..00ddc47dd4 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -109,6 +109,11 @@ class WP_Scripts {
'add' => attribute_escape(__('Add')),
'how' => __('Separate multiple categories with commas.')
) );
+ $this->add( 'ajaxlinkcat', '/wp-admin/js/link-cat.js', array('listman'), '200700601' );
+ $this->localize( 'ajaxlinkcat', 'linkcatL10n', array(
+ 'add' => attribute_escape(__('Add')),
+ 'how' => __('Separate multiple categories with commas.')
+ ) );
$this->add( 'admin-categories', '/wp-admin/js/categories.js', array('listman'), '3684' );
$this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('listman'), '3733' );
$this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('listman'), '20070327' );