Changeset 2088 for trunk/bp-blogs/bp-blogs-templatetags.php
- Timestamp:
- 11/13/2009 01:01:37 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-blogs/bp-blogs-templatetags.php (modified) (77 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-templatetags.php
r1949 r2088 5 5 function bp_blog_signup_enabled() { 6 6 $active_signup = get_site_option( 'registration' ); 7 7 8 8 if ( !$active_signup ) 9 9 $active_signup = 'all'; 10 10 11 11 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" 12 12 13 13 if ( 'none' == $active_signup || 'user' == $active_signup ) 14 14 return false; 15 15 16 16 return true; 17 17 } … … 20 20 global $current_user, $current_site; 21 21 global $bp; 22 22 23 23 require_once( ABSPATH . WPINC . '/registration.php' ); 24 24 … … 48 48 <input type="hidden" name="stage" value="gimmeanotherblog" /> 49 49 <?php do_action( "signup_hidden_fields" ); ?> 50 50 51 51 <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?> 52 52 <p> 53 53 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog »', 'buddypress') ?>" /> 54 54 </p> 55 55 56 56 <?php wp_nonce_field( 'bp_blog_signup_form' ) ?> 57 57 </form> … … 62 62 function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) { 63 63 global $current_site; 64 64 65 65 // Blog name 66 66 if( 'no' == constant( "VHOST" ) ) … … 90 90 // Blog Title 91 91 ?> 92 <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label> 92 <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label> 93 93 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 94 94 <p class="error"><?php echo $errmsg ?></p> … … 99 99 <p> 100 100 <label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label> 101 <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?> 101 <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?> 102 102 103 103 … … 119 119 global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path; 120 120 121 if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 121 if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 122 122 return false; 123 123 124 124 $current_user = wp_get_current_user(); 125 125 126 126 if( !is_user_logged_in() ) 127 127 die(); … … 137 137 138 138 $public = (int) $_POST['blog_public']; 139 139 140 140 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated 141 141 $meta = apply_filters( 'add_signup_meta', $meta ); 142 142 143 143 /* If this is a VHOST install, remove the username from the domain as we are setting this blog 144 144 up inside a user domain, not the root domain. */ 145 145 146 146 wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid ); 147 147 bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); … … 169 169 function bp_create_blog_link() { 170 170 global $bp; 171 171 172 172 if ( bp_is_home() ) { 173 173 echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' ); … … 177 177 function bp_blogs_blog_tabs() { 178 178 global $bp, $groups_template; 179 179 180 180 // Don't show these tabs on a user's own profile 181 181 if ( bp_is_home() ) 182 182 return false; 183 183 184 184 $current_tab = $bp->current_action 185 185 ?> … … 187 187 <li<?php if ( 'my-blogs' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/my-blogs"><?php printf( __( "%s's Blogs", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 188 188 <li<?php if ( 'recent-posts' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-posts"><?php printf( __( "%s's Recent Posts", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 189 <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 189 <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li> 190 190 </ul> 191 191 <?php … … 202 202 var $blogs; 203 203 var $blog; 204 204 205 205 var $in_the_loop; 206 206 207 207 var $pag_page; 208 208 var $pag_num; 209 209 var $pag_links; 210 210 var $total_blog_count; 211 211 212 212 function bp_blogs_user_blogs_template( $user_id, $per_page, $max ) { 213 213 global $bp; 214 214 215 215 if ( !$user_id ) 216 216 $user_id = $bp->displayed_user->id; … … 223 223 wp_cache_set( 'bp_blogs_for_user_' . $user_id, $this->blogs, 'bp' ); 224 224 } 225 225 226 226 if ( !$max || $max >= (int)$this->blogs['count'] ) 227 227 $this->total_blog_count = (int)$this->blogs['count']; 228 228 else 229 229 $this->total_blog_count = (int)$max; 230 230 231 231 $this->blogs = array_slice( (array)$this->blogs['blogs'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) ); 232 232 233 233 if ( $max ) { 234 234 if ( $max >= count($this->blogs) ) … … 239 239 $this->blog_count = count($this->blogs); 240 240 } 241 241 242 242 $this->pag_links = paginate_links( array( 243 243 'base' => add_query_arg( 'fpage', '%#%' ), … … 250 250 )); 251 251 } 252 252 253 253 function has_blogs() { 254 254 if ( $this->blog_count ) 255 255 return true; 256 256 257 257 return false; 258 258 } 259 259 260 260 function next_blog() { 261 261 $this->current_blog++; 262 262 $this->blog = $this->blogs[$this->current_blog]; 263 263 264 264 return $this->blog; 265 265 } 266 266 267 267 function rewind_blogs() { 268 268 $this->current_blog = -1; … … 271 271 } 272 272 } 273 274 function user_blogs() { 273 274 function user_blogs() { 275 275 if ( $this->current_blog + 1 < $this->blog_count ) { 276 276 return true; … … 284 284 return false; 285 285 } 286 286 287 287 function the_blog() { 288 288 global $blog; … … 290 290 $this->in_the_loop = true; 291 291 $blog = $this->next_blog(); 292 292 293 293 if ( 0 == $this->current_blog ) // loop has just started 294 294 do_action('loop_start'); … … 324 324 function bp_blogs_pagination_count() { 325 325 global $bp, $blogs_template; 326 326 327 327 $from_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1; 328 328 $to_num = ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) ; … … 346 346 function bp_get_blog_title() { 347 347 global $blogs_template; 348 349 return apply_filters( 'bp_get_blog_title', $blogs_template->blog ['title']);348 349 return apply_filters( 'bp_get_blog_title', $blogs_template->blog->name ); 350 350 } 351 351 … … 355 355 function bp_get_blog_description() { 356 356 global $blogs_template; 357 358 return apply_filters( 'bp_get_blog_description', $blogs_template->blog ['description']);357 358 return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description ); 359 359 } 360 360 … … 363 363 } 364 364 function bp_get_blog_permalink() { 365 global $blogs_template; 366 367 return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog ['siteurl']);365 global $blogs_template; 366 367 return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog->siteurl ); 368 368 } 369 369 … … 378 378 var $posts; 379 379 var $post; 380 380 381 381 var $in_the_loop; 382 382 383 383 var $pag_page; 384 384 var $pag_num; 385 385 var $pag_links; 386 386 var $total_post_count; 387 387 388 388 function bp_blogs_blog_post_template( $user_id, $per_page, $max ) { 389 389 global $bp; 390 390 391 391 if ( !$user_id ) 392 392 $user_id = $bp->displayed_user->id; … … 394 394 $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1; 395 395 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page; 396 396 397 397 if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) { 398 398 $this->posts = bp_blogs_get_posts_for_user( $user_id ); 399 399 wp_cache_set( 'bp_user_posts_' . $user_id, $this->posts, 'bp' ); 400 400 } 401 401 402 402 if ( !$max || $max >= (int)$this->posts['count'] ) 403 403 $this->total_post_count = (int)$this->posts['count']; 404 404 else 405 405 $this->total_post_count = (int)$max; 406 406 407 407 $this->posts = array_slice( (array)$this->posts['posts'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) ); 408 408 … … 415 415 $this->post_count = count($this->posts); 416 416 } 417 417 418 418 $this->pag_links = paginate_links( array( 419 419 'base' => add_query_arg( 'fpage', '%#%' ), … … 424 424 'next_text' => '»', 425 425 'mid_size' => 1 426 )); 427 } 428 426 )); 427 } 428 429 429 function has_posts() { 430 430 if ( $this->post_count ) 431 431 return true; 432 432 433 433 return false; 434 434 } 435 435 436 436 function next_post() { 437 437 $this->current_post++; 438 438 $this->post = $this->posts[$this->current_post]; 439 439 440 440 return $this->post; 441 441 } 442 442 443 443 function rewind_posts() { 444 444 $this->current_post = -1; … … 447 447 } 448 448 } 449 450 function user_posts() { 449 450 function user_posts() { 451 451 if ( $this->current_post + 1 < $this->post_count ) { 452 452 return true; … … 460 460 return false; 461 461 } 462 462 463 463 function the_post() { 464 464 global $post; … … 466 466 $this->in_the_loop = true; 467 467 $post = $this->next_post(); 468 468 469 469 if ( 0 == $this->current_post ) // loop has just started 470 470 do_action('loop_start'); … … 484 484 extract( $r, EXTR_SKIP ); 485 485 486 $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max ); 486 $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max ); 487 487 return apply_filters( 'bp_has_posts', $posts_template->has_posts(), &$posts_template ); 488 488 } … … 500 500 function bp_post_pagination_count() { 501 501 global $bp, $posts_template; 502 502 503 503 $from_num = intval( ( $posts_template->pag_page - 1 ) * $posts_template->pag_num ) + 1; 504 504 $to_num = ( $from_num + ( $posts_template->pag_num - 1 ) > $posts_template->total_post_count ) ? $posts_template->total_post_count : $from_num + ( $posts_template->pag_num - 1 ) ; … … 522 522 function bp_get_post_id() { 523 523 global $posts_template; 524 return apply_filters( 'bp_get_post_id', $posts_template->post->ID ); 525 } 526 524 return apply_filters( 'bp_get_post_id', $posts_template->post->ID ); 525 } 526 527 527 function bp_post_title( $deprecated = true ) { 528 528 if ( !$deprecated ) … … 533 533 function bp_get_post_title() { 534 534 global $posts_template; 535 535 536 536 return apply_filters( 'bp_get_post_title', $posts_template->post->post_title ); 537 537 } … … 539 539 function bp_post_permalink() { 540 540 global $posts_template; 541 542 echo bp_post_get_permalink(); 541 542 echo bp_post_get_permalink(); 543 543 } 544 544 545 545 function bp_post_excerpt() { 546 echo bp_get_post_excerpt(); 546 echo bp_get_post_excerpt(); 547 547 } 548 548 function bp_get_post_excerpt() { 549 549 global $posts_template; 550 echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt ); 550 echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt ); 551 551 } 552 552 … … 567 567 function bp_get_post_status() { 568 568 global $posts_template; 569 return apply_filters( 'bp_get_post_status', $posts_template->post->post_status ); 570 } 571 569 return apply_filters( 'bp_get_post_status', $posts_template->post->post_status ); 570 } 571 572 572 function bp_post_date( $date_format = null, $deprecated = true ) { 573 573 if ( !$date_format ) 574 574 $date_format = get_option('date_format'); 575 575 576 576 if ( !$deprecated ) 577 577 return bp_get_post_date( $date_format ); … … 593 593 function bp_get_post_comment_count() { 594 594 global $posts_template; 595 return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count ); 595 return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count ); 596 596 } 597 597 598 598 function bp_post_comments( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) { 599 599 global $posts_template, $wpdb; 600 600 601 601 $number = (int)$posts_template->post->comment_count; 602 602 603 603 if ( 0 == $number && 'closed' == $posts_template->postcomment_status && 'closed' == $posts_template->postping_status ) { 604 604 echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>'; … … 614 614 615 615 echo '<a href="'; 616 616 617 617 if ( 0 == $number ) 618 618 echo bp_post_get_permalink() . '#respond'; … … 620 620 echo bp_post_get_permalink() . '#comments'; 621 621 echo '"'; 622 622 623 623 if ( !empty( $css_class ) ) { 624 624 echo ' class="'.$css_class.'" '; … … 629 629 630 630 echo ' title="' . sprintf( __('Comment on %s', 'buddypress'), $title ) . '">'; 631 631 632 632 if ( 1 == $number ) 633 633 printf( __( '%d Comment', 'buddypress' ), $number ); 634 634 else 635 635 printf( __( '%d Comments', 'buddypress' ), $number ); 636 636 637 637 echo '</a>'; 638 638 } … … 646 646 function bp_get_post_author() { 647 647 global $posts_template; 648 648 649 649 return apply_filters( 'bp_get_post_author', bp_core_get_userlink( $posts_template->post->post_author ) ); 650 650 } … … 664 664 $post_id = $posts_template->post->ID; 665 665 666 return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) ); 666 return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) ); 667 667 } 668 668 669 669 function bp_post_tags( $before = '', $sep = ', ', $after = '' ) { 670 670 global $posts_template, $wpdb; 671 671 672 672 /* Disabling this for now as it's too expensive and there is no global tags directory */ 673 673 return false; 674 674 675 675 switch_to_blog( $posts_template->post->blog_id ); 676 676 $terms = bp_post_get_term_list( $before, $sep, $after ); … … 692 692 function bp_get_post_blog_name() { 693 693 global $posts_template; 694 return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) ); 694 return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) ); 695 695 } 696 696 697 697 function bp_post_blog_permalink() { 698 echo bp_get_post_blog_permalink(); 698 echo bp_get_post_blog_permalink(); 699 699 } 700 700 function bp_get_post_blog_permalink() { 701 701 global $posts_template; 702 return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) ); 703 } 704 702 return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) ); 703 } 704 705 705 function bp_post_get_permalink( $post = null, $blog_id = null ) { 706 706 global $current_blog, $posts_template; 707 707 708 708 if ( !$post ) 709 $post = $posts_template->post; 710 709 $post = $posts_template->post; 710 711 711 if ( !$blog_id ) 712 712 $blog_id = $posts_template->post->blog_id; 713 713 714 714 if ( !$post || !$blog_id ) 715 715 return false; 716 716 717 717 $rewritecode = array( 718 718 '%year%', … … 735 735 736 736 $permalink = get_blog_option( $blog_id, 'permalink_structure' ); 737 $site_url = get_blog_option( $blog_id, 'siteurl' ); 737 $site_url = get_blog_option( $blog_id, 'siteurl' ); 738 738 739 739 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) { … … 753 753 if ( empty($category) ) { 754 754 $default_category = get_category( get_option( 'default_category' ) ); 755 $category = is_wp_error( $default_category ) ? '' : $default_category->slug; 755 $category = is_wp_error( $default_category ) ? '' : $default_category->slug; 756 756 } 757 757 } … … 789 789 function bp_post_get_term_list( $before = '', $sep = '', $after = '' ) { 790 790 global $posts_template; 791 791 792 792 $terms = get_the_terms( $posts_template->post->ID, 'post_tag' ); 793 793 … … 801 801 $link = get_blog_option( BP_ROOT_BLOG, 'siteurl') . '/tag/' . $term->slug; 802 802 $link = apply_filters('term_link', $link); 803 803 804 804 $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>'; 805 805 } … … 820 820 var $comments; 821 821 var $comment; 822 822 823 823 var $in_the_loop; 824 824 825 825 var $pag_page; 826 826 var $pag_num; 827 827 var $pag_links; 828 828 var $total_comment_count; 829 829 830 830 function bp_blogs_post_comment_template( $user_id, $per_page, $max ) { 831 831 global $bp; 832 832 833 833 if ( !$user_id ) 834 834 $user_id = $bp->displayed_user->id; … … 836 836 $this->pag_page = isset( $_GET['compage'] ) ? intval( $_GET['compage'] ) : 1; 837 837 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page; 838 838 839 839 if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) { 840 840 $this->comments = bp_blogs_get_comments_for_user( $user_id ); 841 841 wp_cache_set( 'bp_user_comments_' . $user_id, $this->comments, 'bp' ); 842 842 } 843 843 844 844 if ( !$max || $max >= (int)$this->comments['count'] ) 845 845 $this->total_comment_count = (int)$this->comments['count']; 846 846 else 847 847 $this->total_comment_count = (int)$max; 848 848 849 849 $this->comments = array_slice( (array)$this->comments['comments'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) ); 850 850 … … 857 857 $this->comment_count = count($this->comments); 858 858 } 859 859 860 860 $this->pag_links = paginate_links( array( 861 861 'base' => add_query_arg( 'compage', '%#%' ), … … 867 867 'mid_size' => 1 868 868 )); 869 870 } 871 869 870 } 871 872 872 function has_comments() { 873 873 if ( $this->comment_count ) 874 874 return true; 875 875 876 876 return false; 877 877 } 878 878 879 879 function next_comment() { 880 880 $this->current_comment++; 881 881 $this->comment = $this->comments[$this->current_comment]; 882 882 883 883 return $this->comment; 884 884 } 885 885 886 886 function rewind_comments() { 887 887 $this->current_comment = -1; … … 890 890 } 891 891 } 892 893 function user_comments() { 892 893 function user_comments() { 894 894 if ( $this->current_comment + 1 < $this->comment_count ) { 895 895 return true; … … 903 903 return false; 904 904 } 905 905 906 906 function the_comment() { 907 907 global $comment; … … 909 909 $this->in_the_loop = true; 910 910 $comment = $this->next_comment(); 911 911 912 912 if ( 0 == $this->current_comment ) // loop has just started 913 913 do_action('loop_start'); … … 926 926 $r = wp_parse_args( $args, $defaults ); 927 927 extract( $r, EXTR_SKIP ); 928 928 929 929 $comments_template = new BP_Blogs_Post_Comment_Template( $user_id, $per_page, $max ); 930 930 return apply_filters( 'bp_has_comments', $comments_template->has_comments(), &$comments_template ); … … 946 946 function bp_get_comments_pagination() { 947 947 global $comments_template; 948 948 949 949 return apply_filters( 'bp_get_comments_pagination', $comments_template->pag_links ); 950 950 } … … 966 966 function bp_get_comment_post_permalink() { 967 967 global $comments_template; 968 968 969 969 return apply_filters( 'bp_get_comment_post_permalink', bp_post_get_permalink( $comments_template->comment->post, $comments_template->comment->blog_id ) . '#comment-' . $comments_template->comment->comment_ID ); 970 970 } … … 978 978 function bp_get_comment_post_title( $deprecated = true ) { 979 979 global $comments_template; 980 980 981 981 return apply_filters( 'bp_get_comment_post_title', $comments_template->comment->post->post_title ); 982 982 } … … 984 984 function bp_comment_author( $deprecated = true ) { 985 985 global $comments_template; 986 986 987 987 if ( !$deprecated ) 988 988 return bp_get_comment_author(); … … 1010 1010 if ( !$date_format ) 1011 1011 $date_format = get_option('date_format'); 1012 1012 1013 1013 if ( !$deprecated ) 1014 1014 return bp_get_comment_date( $date_format ); 1015 else 1015 else 1016 1016 echo bp_get_comment_date( $date_format ); 1017 1017 } … … 1027 1027 function bp_comment_blog_permalink( $deprecated = true ) { 1028 1028 if ( !$deprecated ) 1029 return bp_get_comment_blog_permalink(); 1029 return bp_get_comment_blog_permalink(); 1030 1030 else 1031 1031 echo bp_get_comment_blog_permalink(); … … 1039 1039 function bp_comment_blog_name( $deprecated = true ) { 1040 1040 global $comments_template; 1041 1041 1042 1042 if ( !$deprecated ) 1043 return bp_get_comment_blog_permalink(); 1043 return bp_get_comment_blog_permalink(); 1044 1044 else 1045 echo bp_get_comment_blog_permalink(); 1045 echo bp_get_comment_blog_permalink(); 1046 1046 } 1047 1047 function bp_get_comment_blog_name( $deprecated = true ) { … … 1060 1060 var $blogs; 1061 1061 var $blog; 1062 1062 1063 1063 var $in_the_loop; 1064 1064 1065 1065 var $pag_page; 1066 1066 var $pag_num; 1067 1067 var $pag_links; 1068 1068 var $total_blog_count; 1069 1069 1070 1070 function bp_blogs_site_blogs_template( $type, $per_page, $max ) { 1071 1071 global $bp; … … 1073 1073 $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : 1; 1074 1074 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1075 1075 1076 1076 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 1077 1077 $this->blogs = BP_Blogs_Blog::search_blogs( $_REQUEST['s'], $this->pag_num, $this->pag_page ); … … 1083 1083 $this->blogs = BP_Blogs_Blog::get_random( $this->pag_num, $this->pag_page ); 1084 1084 break; 1085 1085 1086 1086 case 'newest': 1087 1087 $this->blogs = BP_Blogs_Blog::get_newest( $this->pag_num, $this->pag_page ); 1088 break; 1089 1088 break; 1089 1090 1090 case 'active': default: 1091 1091 $this->blogs = BP_Blogs_Blog::get_active( $this->pag_num, $this->pag_page ); 1092 break; 1092 break; 1093 1093 } 1094 1094 } 1095 1095 1096 1096 if ( !$max || $max >= (int)$this->blogs['total'] ) 1097 1097 $this->total_blog_count = (int)$this->blogs['total']; … … 1109 1109 $this->blog_count = count($this->blogs); 1110 1110 } 1111 1111 1112 1112 $this->pag_links = paginate_links( array( 1113 1113 'base' => add_query_arg( 'bpage', '%#%' ), … … 1118 1118 'next_text' => '»', 1119 1119 'mid_size' => 1 1120 )); 1121 } 1122 1120 )); 1121 } 1122 1123 1123 function has_blogs() { 1124 1124 if ( $this->blog_count ) 1125 1125 return true; 1126 1126 1127 1127 return false; 1128 1128 } 1129 1129 1130 1130 function next_blog() { 1131 1131 $this->current_blog++; 1132 1132 $this->blog = $this->blogs[$this->current_blog]; 1133 1133 1134 1134 return $this->blog; 1135 1135 } 1136 1136 1137 1137 function rewind_blogs() { 1138 1138 $this->current_blog = -1; … … 1141 1141 } 1142 1142 } 1143 1144 function blogs() { 1143 1144 function blogs() { 1145 1145 if ( $this->current_blog + 1 < $this->blog_count ) { 1146 1146 return true; … … 1154 1154 return false; 1155 1155 } 1156 1156 1157 1157 function the_blog() { 1158 1158 global $blog; … … 1160 1160 $this->in_the_loop = true; 1161 1161 $this->blog = $this->next_blog(); 1162 1162 1163 1163 if ( 0 == $this->current_blog ) // loop has just started 1164 1164 do_action('loop_start'); … … 1168 1168 function bp_rewind_site_blogs() { 1169 1169 global $site_blogs_template; 1170 1171 $site_blogs_template->rewind_blogs(); 1170 1171 $site_blogs_template->rewind_blogs(); 1172 1172 } 1173 1173 … … 1183 1183 $r = wp_parse_args( $args, $defaults ); 1184 1184 extract( $r, EXTR_SKIP ); 1185 1185 1186 1186 // type: active ( default ) | random | newest | popular 1187 1187 1188 1188 if ( $max ) { 1189 1189 if ( $per_page > $max ) 1190 1190 $per_page = $max; 1191 1191 } 1192 1192 1193 1193 $site_blogs_template = new BP_Blogs_Site_Blogs_Template( $type, $per_page, $max ); 1194 1194 … … 1198 1198 function bp_site_blogs() { 1199 1199 global $site_blogs_template; 1200 1200 1201 1201 return $site_blogs_template->blogs(); 1202 1202 } … … 1204 1204 function bp_the_site_blog() { 1205 1205 global $site_blogs_template; 1206 1206 1207 1207 return $site_blogs_template->the_blog(); 1208 1208 } … … 1210 1210 function bp_site_blogs_pagination_count() { 1211 1211 global $bp, $site_blogs_template; 1212 1212 1213 1213 $from_num = intval( ( $site_blogs_template->pag_page - 1 ) * $site_blogs_template->pag_num ) + 1; 1214 1214 $to_num = ( $from_num + ( $site_blogs_template->pag_num - 1 ) > $site_blogs_template->total_blog_count ) ? $site_blogs_template->total_blog_count : $from_num + ( $site_blogs_template->pag_num - 1 ) ; … … 1226 1226 return apply_filters( 'bp_get_site_blogs_pagination_links', $site_blogs_template->pag_links ); 1227 1227 } 1228 1228 1229 1229 function bp_the_site_blog_avatar() { 1230 1230 echo bp_get_the_site_blog_avatar(); … … 1232 1232 function bp_get_the_site_blog_avatar() { 1233 1233 global $site_blogs_template, $bp; 1234 1234 1235 1235 /*** 1236 1236 * In future BuddyPress versions you will be able to set the avatar for a blog. … … 1309 1309 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />'; 1310 1310 } 1311 1311 1312 1312 if ( isset( $_REQUEST['letter'] ) ) { 1313 1313 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 1314 1314 } 1315 1315 1316 1316 if ( isset( $_REQUEST['blogs_search'] ) ) { 1317 1317 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
Note: See TracChangeset
for help on using the changeset viewer.