Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/10/2014 01:37:05 AM (13 years ago)
Author:
boonebgorges
Message:

Introduce 'latest_format' param for bp_get_blog_latest_post()

This param allows themers to omit BP's 'Latest post: %s' wrapper around the
link to the latest post.

Fixes #5392

Props lenasterg

File:
1 edited

Legend:

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

    r8407 r8408  
    672672/**
    673673 * Output the latest post from the current blog in the loop.
    674  */
    675 function bp_blog_latest_post() {
    676         echo bp_get_blog_latest_post();
     674 *
     675 * @param array $args See {@link bp_get_blog_latest_post()}.
     676 */
     677function bp_blog_latest_post( $args = array() ) {
     678        echo bp_get_blog_latest_post( $args );
    677679}
    678680        /**
    679681         * Return the latest post from the current blog in the loop.
    680682         *
     683         * @param array $args {
     684         *     Array of optional arguments.
     685         *     @type bool $latest_format If true, formatted "Latest post:
     686         *           [link to post]". If false, formatted "[link to post]".
     687         *           Default: true.
     688         * }
    681689         * @return string $retval String of the form 'Latest Post: [link to post]'.
    682690         */
    683         function bp_get_blog_latest_post() {
     691        function bp_get_blog_latest_post( $args = array() ) {
    684692                global $blogs_template;
    685693
     694                $r = wp_parse_args( $args, array(
     695                        'latest_format' => true,
     696                ) );
     697
    686698                $retval = bp_get_blog_latest_post_title();
    687699
    688                 if ( ! empty( $retval ) )
    689                         $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
     700                if ( ! empty( $retval ) ) {
     701                        if ( ! empty( $r['latest_format'] ) ) {
     702                                $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
     703                        } else {
     704                                $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
     705                        }
     706                }
    690707
    691708                return apply_filters( 'bp_get_blog_latest_post', $retval );
Note: See TracChangeset for help on using the changeset viewer.