?>
	</tr>
	</tfoot>

	<tbody id="the-list" class="list:link-cat">
<?php 
$start = ($pagenum - 1) * $catsperpage;
$args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
if (!empty($_GET['s'])) {
    $args['search'] = $_GET['s'];
}
$categories = get_terms('link_category', $args);
if ($categories) {
    $output = '';
    foreach ($categories as $category) {
        $output .= link_cat_row($category);
    }
    echo $output;
    unset($category);
}
?>
	</tbody>
</table>

<div class="tablenav">
<?php 
if ($page_links) {
    echo "<div class='tablenav-pages'>{$page_links}</div>";
}
?>
     // From Blogroll -> Categories
     check_ajax_referer('add-link-category');
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
     if ('' === trim($_POST['name'])) {
         $x = new WP_Ajax_Response(array('what' => 'link-cat', 'id' => new WP_Error('name', __('You did not enter a category name.'))));
         $x->send();
     }
     $r = wp_insert_term($_POST['name'], 'link_category', $_POST);
     if (is_wp_error($r)) {
         $x = new WP_AJAX_Response(array('what' => 'link-cat', 'id' => $r));
         $x->send();
     }
     extract($r, EXTR_SKIP);
     if (!($link_cat = link_cat_row($term_id))) {
         die('0');
     }
     $x = new WP_Ajax_Response(array('what' => 'link-cat', 'id' => $term_id, 'data' => $link_cat));
     $x->send();
     break;
 case 'add-tag':
     // From Manage->Tags
     check_ajax_referer('add-tag');
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
     if ('' === trim($_POST['name'])) {
         $x = new WP_Ajax_Response(array('what' => 'tag', 'id' => new WP_Error('name', __('You did not enter a tag name.'))));
         $x->send();
     }
Exemplo n.º 3
0
     if (isset($_POST['parent']) && (int) $_POST['parent'] > 0) {
         $data['category_parent'] = $_POST['parent'];
     }
     $cat = get_category($id, ARRAY_A);
     $data['category_description'] = $cat['category_description'];
     $updated = wp_update_category($data);
     if ($updated && !is_wp_error($updated)) {
         echo _cat_row($updated, 0);
     } else {
         die(__('Category not updated.'));
     }
     break;
 case 'link-cat':
     $updated = wp_update_term($id, 'link_category', $_POST);
     if ($updated && !is_wp_error($updated)) {
         echo link_cat_row($updated['term_id']);
     } else {
         die(__('Category not updated.'));
     }
     break;
 case 'tag':
     $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
     $tag = get_term($id, $taxonomy);
     $_POST['description'] = $tag->description;
     $updated = wp_update_term($id, $taxonomy, $_POST);
     if ($updated && !is_wp_error($updated)) {
         $tag = get_term($updated['term_id'], $taxonomy);
         if (!$tag || is_wp_error($tag)) {
             die(__('Tag not updated.'));
         }
         echo _tag_row($tag, '', $taxonomy);
		) );
		$x->send();
	}

	$r = wp_insert_term($_POST['name'], 'link_category', $_POST );
	if ( is_wp_error( $r ) ) {
		$x = new WP_AJAX_Response( array(
			'what' => 'link-cat',
			'id' => $r
		) );
		$x->send();
	}

	extract($r, EXTR_SKIP);

	if ( !$link_cat = link_cat_row( $term_id ) )
		die('0');

	$x = new WP_Ajax_Response( array(
		'what' => 'link-cat',
		'id' => $term_id,
		'data' => $link_cat
	) );
	$x->send();
	break;
case 'add-tag' : // From Manage->Tags
	check_ajax_referer( 'add-tag' );
	if ( !current_user_can( 'manage_categories' ) )
		die('-1');

	if ( '' === trim($_POST['name']) ) {