From 47194e9cd7e7a831ede45c64df403602a10a101a Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 13 Aug 2008 19:09:08 +0000 Subject: [PATCH] Add post_class() template function for emitting standard classes for post div. see #7457 git-svn-id: https://develop.svn.wordpress.org/trunk@8638 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/themes/classic/index.php | 2 +- wp-content/themes/default/index.php | 2 +- wp-includes/post-template.php | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/wp-content/themes/classic/index.php b/wp-content/themes/classic/index.php index f0b6d693b5..652ec0597f 100644 --- a/wp-content/themes/classic/index.php +++ b/wp-content/themes/classic/index.php @@ -6,7 +6,7 @@ get_header(); ',''); ?> -
+
id="post-">

@
diff --git a/wp-content/themes/default/index.php b/wp-content/themes/default/index.php index 978a215246..47c13fc516 100644 --- a/wp-content/themes/default/index.php +++ b/wp-content/themes/default/index.php @@ -6,7 +6,7 @@ -
+
id="post-">

diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index a0cc3088ca..b50ee2c2f2 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -160,6 +160,33 @@ function has_excerpt( $id = 0 ) { return ( !empty( $post->post_excerpt ) ); } +/** + * Echo the classes for the post div + * + * {@internal Missing Long Description}} + * + * @package WordPress + * @subpackage Post + * @since 2.7 + * + @ param string $class One or more classes to add to the class list + * @param int $post_id An optional post ID + */ +function post_class( $class = '', $post_id = null ) { + + $classes = 'post'; + + if ( is_sticky($post_id) ) + $classes .= ' sticky'; + + if ( !empty($class) ) + $classes .= ' ' . $class; + + $classes = apply_filters('post_class', $classes, $class, $post_id); + + echo 'class="' . $classes . '"'; +} + /** * Echo "sticky" CSS class if a post is sticky *