Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/01/2012 08:20:19 PM (14 years ago)
Author:
djpaul
Message:

Extend the functionality of the latest post tracking in the Blogs component by creating template functions for a post's title and content, as well as fetching any post thumbnail. Fixes #4570

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-template.php

    r6342 r6372  
    361361
    362362        return apply_filters( 'bp_get_blog_latest_post', sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $blogs_template->blog->latest_post->post_title ) . '</a>' ) );
     363    }
     364
     365/**
     366 * Prints this site's latest article's title
     367 *
     368 * @see bp_get_blog_latest_post_title()
     369 * @since BuddyPress (1.7)
     370 */
     371function bp_blog_latest_post_title() {
     372    echo bp_get_blog_latest_post_title();
     373}
     374    /**
     375     * Returns this site's latest article's title
     376     *
     377     * @global BP_Blogs_Template
     378     * @return string
     379     * @since BuddyPress (1.7)
     380     */
     381    function bp_get_blog_latest_post_title() {
     382        global $blogs_template;
     383
     384        if ( empty( $blogs_template->blog->latest_post ) )
     385            return '';
     386
     387        return apply_filters( 'bp_get_blog_latest_post_title', $blogs_template->blog->latest_post->post_title );
     388    }
     389
     390/**
     391 * Prints this site's latest article's content
     392 *
     393 * @see bp_get_blog_latest_post_content()
     394 * @since BuddyPress (1.7)
     395 */
     396function bp_blog_latest_post_content() {
     397    $content = bp_get_blog_latest_post_content();
     398    $content = apply_filters( 'bp_blog_latest_post_content', $content );
     399    $content = str_replace( ']]>', ']]&gt;', $content );
     400    echo $content;
     401}
     402    /**
     403     * Returns this site's latest article's content
     404     *
     405     * @global BP_Blogs_Template
     406     * @return string
     407     * @since BuddyPress (1.7)
     408     */
     409    function bp_get_blog_latest_post_content() {
     410        global $blogs_template;
     411
     412        if ( empty( $blogs_template->blog->latest_post ) )
     413            return '';
     414
     415        return apply_filters( 'bp_get_blog_latest_post_content', $blogs_template->blog->latest_post->post_content );
     416    }
     417
     418/**
     419 * Prints this site's latest article's featured image
     420 *
     421 * @param string $size Image version to return. Either "thumbnail", "medium", "large", "post-thumbnail".
     422 * @see bp_get_blog_latest_post_content()
     423 * @since BuddyPress (1.7)
     424 */
     425function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
     426    echo bp_get_blog_latest_post_featured_image( $size );
     427}
     428    /**
     429     * Returns this site's latest article's featured image
     430     *
     431     * @global BP_Blogs_Template
     432     * @param string $size Image version to return. Either "thumbnail", "medium", "large", "post-thumbnail".
     433     * @return string
     434     * @since BuddyPress (1.7)
     435     */
     436    function bp_get_blog_latest_post_featured_image( $size = 'thumbnail' ) {
     437        global $blogs_template;
     438
     439        if ( empty( $blogs_template->blog->latest_post->images[$size] ) )
     440            return '';
     441
     442        return apply_filters( 'bp_get_blog_latest_post_featured_image', $blogs_template->blog->latest_post->images[$size] );
    363443    }
    364444
Note: See TracChangeset for help on using the changeset viewer.