WordPress.org

Make WordPress Core

Changeset 8643


Ignore:
Timestamp:
08/13/2008 11:26:14 PM (13 years ago)
Author:
ryan
Message:

get_post_class() from mdawaffe. see #7457

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r8642 r8643  
    170170 * @since 2.7
    171171 *
    172  * @ param string $class One or more classes to add to the class list
     172 * @param string|array $class One or more classes to add to the class list
    173173 * @param int $post_id An optional post ID
    174174 */
    175175function post_class( $class = '', $post_id = null ) {
     176    // Separates classes with a single space, collates classes for post DIV
     177    echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
     178}
     179
     180/**
     181 * Returns the classes for the post div as an array
     182 *
     183 * {@internal Missing Long Description}}
     184 *
     185 * @package WordPress
     186 * @subpackage Post
     187 * @since 2.7
     188 *
     189 * @param string|array $class One or more classes to add to the class list
     190 * @param int $post_id An optional post ID
     191 * @return array Array of classes
     192 */
     193function get_post_class( $class = '', $post_id = null ) {
    176194    $post = get_post($post_id);
    177195
     
    202220
    203221    if ( !empty($class) ) {
    204         $class = preg_split('#\s+#', $class);
     222        if ( !is_array( $class ) )
     223            $class = preg_split('#\s+#', $class);
    205224        $classes = array_merge($classes, $class);
    206225    }
    207226
    208     // Separates classes with a single space, collates classes for post DIV
    209     $classes = join(' ', apply_filters('post_class', $classes, $class, $post_id));
    210 
    211     echo 'class="' . $classes . '"';
     227    return apply_filters('post_class', $classes, $class, $post_id);
    212228}
    213229
Note: See TracChangeset for help on using the changeset viewer.