Skip to:
Content

BuddyPress.org

Changeset 6374


Ignore:
Timestamp:
10/01/2012 09:04:40 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Blogs:

  • Tweak the way new latest_blog template tags work, to always be filterable even if no result exists.
  • Have latest_content use _get_ function, and remove extra filter to prevent confusion.
  • Remove CDATA str_replace, as it won't be used in feeds.
  • Fix @since phpdoc order.
  • Switch some $bp globals to using buddypress().
  • See: r6372.
File:
1 edited

Legend:

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

    r6372 r6374  
    3131         */
    3232        function bp_get_blogs_slug() {
    33                 global $bp;
    34                 return apply_filters( 'bp_get_blogs_slug', $bp->blogs->slug );
     33                return apply_filters( 'bp_get_blogs_slug', buddypress()->blogs->slug );
    3534        }
    3635
     
    5554         */
    5655        function bp_get_blogs_root_slug() {
    57                 global $bp;
    58                 return apply_filters( 'bp_get_blogs_root_slug', $bp->blogs->root_slug );
     56                return apply_filters( 'bp_get_blogs_root_slug', buddypress()->blogs->root_slug );
    5957        }
    6058
     
    357355                global $blogs_template;
    358356
    359                 if ( null == $blogs_template->blog->latest_post )
    360                         return false;
    361 
    362                 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>' ) );
     357                $retval = bp_get_blog_latest_post_title();
     358
     359                if ( ! empty( $retval ) )
     360                        $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
     361
     362                return apply_filters( 'bp_get_blog_latest_post', $retval );
    363363        }
    364364
     
    366366 * Prints this site's latest article's title
    367367 *
     368 * @since BuddyPress (1.7)
     369 *
    368370 * @see bp_get_blog_latest_post_title()
    369  * @since BuddyPress (1.7)
    370371 */
    371372function bp_blog_latest_post_title() {
     
    375376         * Returns this site's latest article's title
    376377         *
     378         * @since BuddyPress (1.7)
     379         *
    377380         * @global BP_Blogs_Template
    378381         * @return string
    379          * @since BuddyPress (1.7)
    380382         */
    381383        function bp_get_blog_latest_post_title() {
    382384                global $blogs_template;
    383385
    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 );
     386                $retval = '';
     387
     388                if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_title ) )
     389                        $retval = $blogs_template->blog->latest_post->post_title;
     390
     391                return apply_filters( 'bp_get_blog_latest_post_title', $retval );
    388392        }
    389393
     
    391395 * Prints this site's latest article's content
    392396 *
    393  * @see bp_get_blog_latest_post_content()
    394397 * @since BuddyPress (1.7)
     398 *
     399 * @uses bp_get_blog_latest_post_content()
    395400 */
    396401function 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;
     402        echo bp_get_blog_latest_post_content();
    401403}
    402404        /**
    403405         * Returns this site's latest article's content
    404406         *
     407         * @since BuddyPress (1.7)
     408         *
    405409         * @global BP_Blogs_Template
    406410         * @return string
    407          * @since BuddyPress (1.7)
    408411         */
    409412        function bp_get_blog_latest_post_content() {
    410413                global $blogs_template;
    411414
    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 );
     415                $retval = '';
     416
     417                if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_content ) )
     418                        $retval = $blogs_template->blog->latest_post->post_content;
     419
     420                return apply_filters( 'bp_get_blog_latest_post_content', $retval );
    416421        }
    417422
    418423/**
    419424 * Prints this site's latest article's featured image
     425 *
     426 * @since BuddyPress (1.7)
    420427 *
    421428 * @param string $size Image version to return. Either "thumbnail", "medium", "large", "post-thumbnail".
    422429 * @see bp_get_blog_latest_post_content()
    423  * @since BuddyPress (1.7)
    424430 */
    425431function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
     
    428434        /**
    429435         * Returns this site's latest article's featured image
     436         *
     437         * @since BuddyPress (1.7)
    430438         *
    431439         * @global BP_Blogs_Template
    432440         * @param string $size Image version to return. Either "thumbnail", "medium", "large", "post-thumbnail".
    433441         * @return string
    434          * @since BuddyPress (1.7)
    435442         */
    436443        function bp_get_blog_latest_post_featured_image( $size = 'thumbnail' ) {
    437444                global $blogs_template;
    438445
    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] );
     446                $retval = '';
     447
     448                if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->images[$size] ) )
     449                        $retval = $blogs_template->blog->latest_post->images[$size];
     450
     451                return apply_filters( 'bp_get_blog_latest_post_featured_image', $retval );
    443452        }
    444453
     
    685694
    686695<?php
     696
     697        // @todo where does $current_tab come from?
    687698        do_action( 'bp_blogs_blog_tabs', $current_tab );
    688699}
Note: See TracChangeset for help on using the changeset viewer.