Tag descriptions, props aaroncampbell, fixes #9381

git-svn-id: http://svn.automattic.com/wordpress/trunk@10903 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-04-09 16:00:40 +00:00
parent 135af2d731
commit 9d35395cb5
5 changed files with 49 additions and 5 deletions

View File

@ -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 );

View File

@ -34,6 +34,11 @@ do_action('edit_tag_form_pre', $tag); ?>
<td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo attribute_escape(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="description"><?php _e('Description') ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($tag->description); ?></textarea><br />
<?php _e('The description is not prominent by default, however some themes may show it.'); ?></td>
</tr>
</table>
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update Tag'); ?>" /></p>
<?php do_action('edit_tag_form', $tag); ?>

View File

@ -287,6 +287,12 @@ else
<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
</div>
<div class="form-field">
<label for="description"><?php _e('Description') ?></label>
<textarea name="description" id="description" rows="5" cols="40"></textarea>
<p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
</div>
<p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Tag'); ?>" /></p>
<?php do_action('add_tag_form'); ?>
</form></div>

View File

@ -668,6 +668,9 @@ function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
$out .= '<div class="name">' . $qe_data->name . '</div>';
$out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
break;
case 'description':
$out .= "<td $attributes>$tag->description</td>";
break;
case 'slug':
$out .= "<td $attributes>$tag->slug</td>";
break;
@ -872,6 +875,7 @@ function get_column_headers($page) {
$_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />',
'name' => __('Name'),
'description' => __('Description'),
'slug' => __('Slug'),
'posts' => __('Posts')
);

View File

@ -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.
*