From 9d35395cb575e6644c704c83b06b0670b4de337d Mon Sep 17 00:00:00 2001 From: azaozz Date: Thu, 9 Apr 2009 16:00:40 +0000 Subject: [PATCH] Tag descriptions, props aaroncampbell, fixes #9381 git-svn-id: http://svn.automattic.com/wordpress/trunk@10903 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 3 +++ wp-admin/edit-tag-form.php | 5 +++++ wp-admin/edit-tags.php | 6 ++++++ wp-admin/includes/template.php | 4 ++++ wp-includes/category-template.php | 36 ++++++++++++++++++++++++++----- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 387cbd353..4fdfc00d6 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1169,6 +1169,9 @@ case 'inline-save-tax': else $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 ); diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php index 8cd22f8ef..74861f342 100644 --- a/wp-admin/edit-tag-form.php +++ b/wp-admin/edit-tag-form.php @@ -34,6 +34,11 @@ do_action('edit_tag_form_pre', $tag); ?>

+ + +
+ +

diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index a6d13e253..89e1a161d 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -287,6 +287,12 @@ else

+
+ + +

+
+

diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index c2d60441c..28bfe9bb7 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -668,6 +668,9 @@ function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) { $out .= '
' . $qe_data->name . '
'; $out .= '
' . $qe_data->slug . '
'; break; + case 'description': + $out .= "$tag->description"; + break; case 'slug': $out .= "$tag->slug"; break; @@ -872,6 +875,7 @@ function get_column_headers($page) { $_wp_column_headers[$page] = array( 'cb' => '', 'name' => __('Name'), + 'description' => __('Description'), 'slug' => __('Slug'), 'posts' => __('Posts') ); diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index f83f213c3..b178dee09 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -293,11 +293,7 @@ function the_category( $separator = '', $parents='', $post_id = false ) { * @return string Category description, available. */ function category_description( $category = 0 ) { - global $cat; - if ( !$category ) - $category = $cat; - - return get_term_field( 'description', $category, 'category' ); + return term_description( $category, 'category' ); } /** @@ -798,6 +794,36 @@ function the_tags( $before = null, $sep = ', ', $after = '' ) { echo get_the_tag_list($before, $sep, $after); } +/** + * Retrieve tag description. + * + * @since 2.8 + * + * @param int $tag Optional. Tag ID. Will use global tag ID by default. + * @return string Tag description, available. + */ +function tag_description( $tag = 0 ) { + return term_description( $tag ); +} + +/** + * Retrieve term description. + * + * @since 2.8 + * + * @param int $term Optional. Term ID. Will use global term ID by default. + * @return string Term description, available. + */ +function term_description( $term = 0, $taxonomy = 'post_tag' ) { + if ( !$term && ( is_tax() || is_tag() || is_category() ) ) { + global $wp_query; + $term = $wp_query->get_queried_object(); + $taxonomy = $term->taxonomy; + $term = $term->term_id; + } + return get_term_field( 'description', $term, $taxonomy ); +} + /** * Retrieve the terms of the taxonomy that are attached to the post. *