Changeset 6372
- Timestamp:
- 10/01/2012 08:20:19 PM (13 years ago)
- Location:
- trunk/bp-blogs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-classes.php
r6342 r6372 262 262 for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) { 263 263 $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id ); 264 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" ); 264 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" ); 265 $images = array(); 266 267 // Add URLs to any Featured Image this post might have 268 if ( has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) { 269 270 // Grab 4 sizes of the image. Thumbnail. 271 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false ); 272 if ( ! empty( $image ) ) 273 $images['thumbnail'] = $image[0]; 274 275 // Medium 276 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false ); 277 if ( ! empty( $image ) ) 278 $images['medium'] = $image[0]; 279 280 // Large 281 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false ); 282 if ( ! empty( $image ) ) 283 $images['large'] = $image[0]; 284 285 // Post thumbnail 286 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false ); 287 if ( ! empty( $image ) ) 288 $images['post-thumbnail'] = $image[0]; 289 } 290 291 // Add the images to the latest_post object 292 $paged_blogs[$i]->latest_post->images = $images; 265 293 } 266 294 -
trunk/bp-blogs/bp-blogs-filters.php
r6342 r6372 8 8 * @since BuddyPress (1.6) 9 9 */ 10 11 // Display filters 12 13 add_filter( 'bp_get_blog_latest_post_title', 'wptexturize' ); 14 add_filter( 'bp_get_blog_latest_post_title', 'convert_chars' ); 15 add_filter( 'bp_get_blog_latest_post_title', 'trim' ); 16 17 add_filter( 'bp_blog_latest_post_content', 'wptexturize' ); 18 add_filter( 'bp_blog_latest_post_content', 'convert_smilies' ); 19 add_filter( 'bp_blog_latest_post_content', 'convert_chars' ); 20 add_filter( 'bp_blog_latest_post_content', 'wpautop' ); 21 add_filter( 'bp_blog_latest_post_content', 'shortcode_unautop' ); 22 add_filter( 'bp_blog_latest_post_content', 'prepend_attachment' ); 10 23 11 24 /** -
trunk/bp-blogs/bp-blogs-template.php
r6342 r6372 361 361 362 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>' ) ); 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 */ 371 function 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 */ 396 function 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( ']]>', ']]>', $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 */ 425 function 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] ); 363 443 } 364 444
Note: See TracChangeset
for help on using the changeset viewer.