Changeset 10374 for trunk/src/bp-blogs/bp-blogs-template.php
- Timestamp:
- 11/23/2015 03:55:00 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-template.php
r10248 r10374 195 195 $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); 196 196 197 // Backwards compatibility support for blogs by first letter 197 // Backwards compatibility support for blogs by first letter. 198 198 if ( ! empty( $_REQUEST['letter'] ) ) { 199 199 $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 200 200 201 // Typical blogs query 201 // Typical blogs query. 202 202 } else { 203 203 $this->blogs = bp_blogs_get_blogs( array( … … 212 212 } 213 213 214 // Set the total blog count 214 // Set the total blog count. 215 215 if ( empty( $max ) || ( $max >= (int) $this->blogs['total'] ) ) { 216 216 $this->total_blog_count = (int) $this->blogs['total']; … … 219 219 } 220 220 221 // Set the blogs array (to loop through later 221 // Set the blogs array (to loop through later. 222 222 $this->blogs = $this->blogs['blogs']; 223 223 224 // Get the current blog count to compare maximum against 224 // Get the current blog count to compare maximum against. 225 225 $blog_count = count( $this->blogs ); 226 226 227 // Set the current blog count 227 // Set the current blog count. 228 228 if ( empty( $max ) || ( $max >= (int) $blog_count ) ) { 229 229 $this->blog_count = (int) $blog_count; … … 232 232 } 233 233 234 // Build pagination links based on total blogs and current page number 234 // Build pagination links based on total blogs and current page number. 235 235 if ( ! empty( $this->total_blog_count ) && ! empty( $this->pag_num ) ) { 236 236 $this->pag_links = paginate_links( array( … … 302 302 */ 303 303 do_action( 'blog_loop_end' ); 304 // Do some cleaning up after the loop 304 // Do some cleaning up after the loop. 305 305 $this->rewind_blogs(); 306 306 } … … 324 324 $this->blog = $this->next_blog(); 325 325 326 // loop has just started326 // Loop has just started. 327 327 if ( 0 === $this->current_blog ) { 328 328 … … 396 396 } 397 397 398 // Parse arguments 398 // Parse arguments. 399 399 $r = bp_parse_args( $args, array( 400 400 'type' => 'active', 401 'page_arg' => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679401 'page_arg' => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679. 402 402 'page' => 1, 403 403 'per_page' => 20, 404 404 'max' => false, 405 'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of 405 'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of. 406 406 'include_blog_ids' => false, 407 407 'search_terms' => $search_terms_default, … … 409 409 ), 'has_blogs' ); 410 410 411 // Set per_page to maximum if max is enforced 411 // Set per_page to maximum if max is enforced. 412 412 if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) { 413 413 $r['per_page'] = (int) $r['max']; 414 414 } 415 415 416 // Get the blogs 416 // Get the blogs. 417 417 $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] ); 418 418 … … 550 550 $author_displayname = bp_core_get_user_displayname( $blogs_template->blog->admin_user_id ); 551 551 552 // Parse the arguments 552 // Parse the arguments. 553 553 $r = bp_parse_args( $args, array( 554 554 'type' => 'full', … … 562 562 ) ); 563 563 564 // Fetch the avatar 564 // Fetch the avatar. 565 565 $avatar = bp_core_fetch_avatar( array( 566 566 'item_id' => $blogs_template->blog->admin_user_id, 567 567 'title' => $r['title'], 568 // 'avatar_dir' => 'blog-avatars',569 // 'object' => 'blog',568 // 'avatar_dir' => 'blog-avatars', 569 // 'object' => 'blog', 570 570 'type' => $r['type'], 571 571 'alt' => $r['alt'], … … 576 576 ) ); 577 577 578 /** *578 /** 579 579 * In future BuddyPress versions you will be able to set the avatar for a blog. 580 580 * Right now you can use a filter with the ID of the blog to change it if you wish. … … 714 714 * @since 1.7.0 715 715 * 716 * @param array $classes Array of custom classes 716 * @param array $classes Array of custom classes. 717 717 */ 718 718 function bp_blog_class( $classes = array() ) { … … 725 725 * 726 726 * @global BP_Blogs_Template $blogs_template 727 * @param array $classes Array of custom classes728 * 727 * 728 * @param array $classes Array of custom classes. 729 729 * @return string Row class of the site. 730 730 */ … … 732 732 global $blogs_template; 733 733 734 // Add even/odd classes, but only if there's more than 1 group 734 // Add even/odd classes, but only if there's more than 1 group. 735 735 if ( $blogs_template->blog_count > 1 ) { 736 736 $pos_in_loop = (int) $blogs_template->current_blog; 737 737 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 738 738 739 // If we've only one site in the loop, don't bother with odd and even 739 // If we've only one site in the loop, don't bother with odd and even. 740 740 } else { 741 741 $classes[] = 'bp-single-blog'; … … 778 778 global $blogs_template; 779 779 780 // Parse the activity format 780 // Parse the activity format. 781 781 $r = bp_parse_args( $args, array( 782 782 'active_format' => true 783 783 ) ); 784 784 785 // Backwards compatibility for anyone forcing a 'true' active_format 785 // Backwards compatibility for anyone forcing a 'true' active_format. 786 786 if ( true === $r['active_format'] ) { 787 787 $r['active_format'] = __( 'active %s', 'buddypress' ); 788 788 } 789 789 790 // Blog has been posted to at least once 790 // Blog has been posted to at least once. 791 791 if ( isset( $blogs_template->blog->last_activity ) ) { 792 792 793 // Backwards compatibility for pre 1.5 'ago' strings 793 // Backwards compatibility for pre 1.5 'ago' strings. 794 794 $last_activity = ! empty( $r['active_format'] ) 795 795 ? bp_core_get_last_activity( $blogs_template->blog->last_activity, $r['active_format'] ) 796 796 : bp_core_time_since( $blogs_template->blog->last_activity ); 797 797 798 // Blog has never been posted to 798 // Blog has never been posted to. 799 799 } else { 800 800 $last_activity = __( 'Never active', 'buddypress' ); … … 1000 1000 * @param string $size Image version to return. 'thumbnail', 'medium', 1001 1001 * 'large', or 'post-thumbnail'. Default: 'thumbnail'. 1002 *1003 1002 * @return string URL of the image. 1004 1003 */ … … 1028 1027 * @param string $thumbnail Image version to return. 'thumbnail', 'medium', 'large', 1029 1028 * or 'post-thumbnail'. Default: 'thumbnail'. 1030 *1031 1029 * @return bool True if the latest blog post from the current blog has a 1032 1030 * featured image of the given size. … … 1101 1099 * 1102 1100 * @param int $user_id ID of the user. 1103 *1104 1101 * @return int Total number of blogs for the user. 1105 1102 */ … … 1138 1135 * Filters whether or not blog creation is enabled. 1139 1136 * 1137 * Return "all", "none", "blog" or "user". 1138 * 1140 1139 * @since 1.0.0 1141 1140 * 1142 1141 * @param string $active_signup Value of the registration site option creation status. 1143 1142 */ 1144 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"1143 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); 1145 1144 1146 1145 if ( 'none' == $active_signup || 'user' == $active_signup ) … … 1226 1225 global $current_site; 1227 1226 1228 // Blog name 1227 // Blog name. 1229 1228 if( !is_subdomain_install() ) 1230 1229 echo '<label for="blogname">' . __('Site Name:', 'buddypress') . '</label>'; … … 1255 1254 } 1256 1255 1257 // Blog Title 1256 // Blog Title. 1258 1257 ?> 1259 1258 … … 1323 1322 $public = (int) $_POST['blog_public']; 1324 1323 1325 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated 1324 // Depreciated. 1325 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); 1326 1326 1327 1327 /** … … 1398 1398 function bp_create_blog_link() { 1399 1399 1400 // Don't show this link when not on your own profile 1400 // Don't show this link when not on your own profile. 1401 1401 if ( ! bp_is_my_profile() ) { 1402 1402 return; … … 1420 1420 function bp_blogs_blog_tabs() { 1421 1421 1422 // Don't show these tabs on a user's own profile 1422 // Don't show these tabs on a user's own profile. 1423 1423 if ( bp_is_my_profile() ) { 1424 1424 return false; … … 1531 1531 */ 1532 1532 function bp_get_blog_create_nav_item() { 1533 // Get the create a site button 1533 // Get the create a site button. 1534 1534 $create_blog_button = bp_get_blog_create_button(); 1535 1535 1536 // Make sure the button is available 1536 // Make sure the button is available. 1537 1537 if ( empty( $create_blog_button ) ) { 1538 1538 return; … … 1555 1555 */ 1556 1556 function bp_blog_backcompat_create_nav_item() { 1557 // Bail if Blogs nav item is already used by bp-legacy 1557 // Bail if Blogs nav item is already used by bp-legacy. 1558 1558 if ( has_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ) ) { 1559 1559 return; 1560 1560 } 1561 1561 1562 // Bail if the theme is not filtering the Blogs directory title 1562 // Bail if the theme is not filtering the Blogs directory title. 1563 1563 if ( ! has_filter( 'bp_blogs_directory_header' ) ) { 1564 1564 return; … … 1634 1634 * @uses bp_blogs_admin_get_profile_stats() to get the stats. 1635 1635 * 1636 * @param array|string $args before|after|user_id1636 * @param array|string $args Before|after|user_id. 1637 1637 */ 1638 1638 function bp_blogs_profile_stats( $args = '' ) { … … 1646 1646 * @since 2.0.0 1647 1647 * 1648 * @param array|string $args before|after|user_id 1649 * 1648 * @param array|string $args Before|after|user_id. 1650 1649 * @return string HTML for stats output. 1651 1650 */ 1652 1651 function bp_blogs_get_profile_stats( $args = '' ) { 1653 1652 1654 // Parse the args 1653 // Parse the args. 1655 1654 $r = bp_parse_args( $args, array( 1656 1655 'before' => '<li class="bp-blogs-profile-stats">', … … 1661 1660 ), 'blogs_get_profile_stats' ); 1662 1661 1663 // Allow completely overloaded output 1662 // Allow completely overloaded output. 1664 1663 if ( is_multisite() && empty( $r['output'] ) ) { 1665 1664 1666 // Only proceed if a user ID was passed 1665 // Only proceed if a user ID was passed. 1667 1666 if ( ! empty( $r['user_id'] ) ) { 1668 1667 1669 // Get the user's blogs 1668 // Get the user's blogs. 1670 1669 if ( empty( $r['blogs'] ) ) { 1671 1670 $r['blogs'] = absint( bp_blogs_total_blogs_for_user( $r['user_id'] ) ); 1672 1671 } 1673 1672 1674 // If blogs exist, show some formatted output 1673 // If blogs exist, show some formatted output. 1675 1674 $r['output'] = $r['before'] . sprintf( _n( '%s site', '%s sites', $r['blogs'], 'buddypress' ), '<strong>' . $r['blogs'] . '</strong>' ) . $r['after']; 1676 1675 }
Note: See TracChangeset
for help on using the changeset viewer.