Changeset 14165
- Timestamp:
- 12/23/2025 02:20:11 AM (7 days ago)
- File:
-
- 1 edited
-
trunk/src/bp-blogs/bp-blogs-template.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-template.php
r14077 r14165 492 492 } 493 493 494 /** 495 * Output the permalink of the current blog in the loop. 496 * 497 * @since 1.0.0 498 */ 494 499 function bp_blog_permalink() { 495 500 echo esc_url( bp_get_blog_permalink() ); 496 501 } 502 /** 503 * Return the permalink of the current blog in the loop. 504 * 505 * @since 1.0.0 506 * 507 * @global BP_Blogs_Template $blogs_template The main blog template loop class. 508 * 509 * @return string 510 */ 497 511 function bp_get_blog_permalink() { 498 512 global $blogs_template; … … 529 543 * Return the name of the current blog in the loop. 530 544 * 545 * @global BP_Blogs_Template $blogs_template The main blog template loop class. 546 * 531 547 * @return string The name of the current blog in the loop. 532 548 */ … … 563 579 * @since 1.7.0 564 580 * 581 * @global BP_Blogs_Template $blogs_template The main blog template loop class. 582 * 565 583 * @return int ID of the current blog in the loop. 566 584 */ … … 594 612 /** 595 613 * Return the description of the current blog in the loop. 614 * 615 * @global BP_Blogs_Template $blogs_template The main blog template loop class. 596 616 * 597 617 * @return string Description of the current blog in the loop. … … 653 673 $classes = array_map( 'sanitize_html_class', apply_filters( 'bp_get_blog_class', $classes ) ); 654 674 $classes = array_merge( $classes, array() ); 655 $retval = 'class="' . join( ' ', $classes ) . '"'; 656 657 return $retval; 675 676 return 'class="' . join( ' ', $classes ) . '"'; 658 677 } 659 678 … … 754 773 ); 755 774 756 $retval = bp_get_blog_latest_post_title(); 775 $retval = bp_get_blog_latest_post_title(); 776 $post_id = bp_get_blog_latest_post_id(); 757 777 758 778 if ( ! empty( $retval ) ) { … … 769 789 /* translators: %s: the title of the latest post */ 770 790 __( 'Latest Post: %s', 'buddypress' ), 771 '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>'791 '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval, $post_id ) . '</a>' 772 792 ); 773 793 } else { 774 794 775 795 /** This filter is documented in bp-blogs/bp-blogs-template.php */ 776 $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';796 $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval, $post_id ) . '</a>'; 777 797 } 778 798 } … … 791 811 792 812 /** 813 * Output the ID of the latest post on the current blog in the loop. 814 * 815 * @since 14.5.0 816 * 817 * @see bp_get_blog_latest_post_id() 818 */ 819 function bp_blog_latest_post_id() { 820 echo bp_get_blog_latest_post_id(); 821 } 822 /** 823 * Return the ID of the latest post on the current blog in the loop. 824 * 825 * @since 14.5.0 826 * 827 * @global BP_Blogs_Template $blogs_template The main blog template loop class. 828 * 829 * @return int 830 */ 831 function bp_get_blog_latest_post_id() { 832 global $blogs_template; 833 834 $latest_post_id = 0; 835 836 if ( 837 ! empty( $blogs_template->blog->latest_post ) 838 && ! empty( $blogs_template->blog->latest_post->ID ) 839 && is_int( $blogs_template->blog->latest_post->ID ) 840 ) { 841 $latest_post_id = $blogs_template->blog->latest_post->ID; 842 } 843 844 /** 845 * Filters the ID of the latest post on the current blog in the loop. 846 * 847 * @since 14.5.0 848 * 849 * @param int $latest_post_id ID of the latest post. 850 */ 851 return (int) apply_filters( 'bp_get_blog_latest_post_id', (int) $latest_post_id ); 852 } 853 854 /** 793 855 * Output the title of the latest post on the current blog in the loop. 794 856 * … … 814 876 $retval = ''; 815 877 816 if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_title ) ) 878 if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_title ) ) { 817 879 $retval = $blogs_template->blog->latest_post->post_title; 880 } 818 881 819 882 /** … … 842 905 * @since 1.7.0 843 906 * 844 * @global BP_Blogs_Template $blogs_template The main blog template loop class.845 *846 907 * @return string URL of the blog's latest post. 847 908 */ 848 909 function bp_get_blog_latest_post_permalink() { 849 global $blogs_template;850 851 $retval = ''; 852 853 if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->ID ) )854 $retval = add_query_arg( 'p', $blogs_template->blog->latest_post->ID, bp_get_blog_permalink() );910 $retval = ''; 911 $post_id = bp_get_blog_latest_post_id(); 912 913 if ( ! empty( $post_id ) ) { 914 $retval = add_query_arg( 'p', $post_id, bp_get_blog_permalink() );