Changeset 1250 for trunk/bp-blogs/bp-blogs-templatetags.php
- Timestamp:
- 03/25/2009 04:01:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-templatetags.php
r1238 r1250 1 1 <?php 2 2 3 /** Blog listing template class **/ 4 class BP_Blogs_Blog_Template { 3 /* Blog registration template tags */ 4 5 function bp_blog_signup_enabled() { 6 $active_signup = get_site_option( 'registration' ); 7 8 if ( !$active_signup ) 9 $active_signup = 'all'; 10 11 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" 12 13 if ( 'none' == $active_signup || 'user' == $active_signup ) 14 return false; 15 16 return true; 17 } 18 19 function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') { 20 global $current_user, $current_site; 21 global $bp; 22 23 require_once( ABSPATH . WPINC . '/registration.php' ); 24 25 if ( isset($_POST['submit']) ) { 26 bp_blogs_validate_blog_signup(); 27 } else { 28 if ( ! is_wp_error($errors) ) { 29 $errors = new WP_Error(); 30 } 31 32 // allow definition of default variables 33 $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors )); 34 $blogname = $filtered_results['blogname']; 35 $blog_title = $filtered_results['blog_title']; 36 $errors = $filtered_results['errors']; 37 38 if ( $errors->get_error_code() ) { 39 echo "<p>" . __('There was a problem, please correct the form below and try again.', 'buddypress') . "</p>"; 40 } 41 ?> 42 <p><?php printf(__("By filling out the form below, you can <strong>add a blog to your account</strong>. There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly.", 'buddypress'), $current_user->display_name) ?></p> 43 44 <p><?php _e("If you’re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress') ?></p> 45 46 <form id="setupform" method="post" action="<?php echo $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog' ?>"> 47 48 <input type="hidden" name="stage" value="gimmeanotherblog" /> 49 <?php do_action( "signup_hidden_fields" ); ?> 50 <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?> 51 <p> 52 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog »', 'buddypress') ?>" /> 53 </p> 54 55 <?php wp_nonce_field( 'bp_blog_signup_form' ) ?> 56 </form> 57 <?php 58 } 59 } 60 61 function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) { 62 global $current_site; 63 64 // Blog name 65 if( 'no' == constant( "VHOST" ) ) 66 echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>'; 67 else 68 echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>'; 69 70 if ( $errmsg = $errors->get_error_message('blogname') ) { ?> 71 <p class="error"><?php echo $errmsg ?></p> 72 <?php } 73 74 if( 'no' == constant( "VHOST" ) ) { 75 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />'; 76 } else { 77 echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />'; 78 } 79 if ( !is_user_logged_in() ) { 80 print '(<strong>' . __( 'Your address will be ' , 'buddypress'); 81 if( 'no' == constant( "VHOST" ) ) { 82 print $current_site->domain . $current_site->path . __( 'blogname' , 'buddypress'); 83 } else { 84 print __( 'domain.' , 'buddypress') . $current_site->domain . $current_site->path; 85 } 86 echo '.</strong> ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)' , 'buddypress') . '</p>'; 87 } 88 89 // Blog Title 90 ?> 91 <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label> 92 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 93 <p class="error"><?php echo $errmsg ?></p> 94 <?php } 95 echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>'; 96 ?> 97 98 <p> 99 <label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label> 100 <?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 <div style="clear:both;"></div> 102 <label class="checkbox" for="blog_public_on"> 103 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 104 <strong><?php _e( 'Yes' , 'buddypress'); ?></strong> 105 </label> 106 <label class="checkbox" for="blog_public_off"> 107 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 108 <strong><?php _e( 'No' , 'buddypress'); ?></strong> 109 </label> 110 </p> 111 112 <?php 113 do_action('signup_blogform', $errors); 114 } 115 116 function bp_blogs_validate_blog_signup() { 117 global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path; 118 119 if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 120 return false; 121 122 $current_user = wp_get_current_user(); 123 124 if( !is_user_logged_in() ) 125 die(); 126 127 $result = bp_blogs_validate_blog_form(); 128 extract($result); 129 130 if ( $errors->get_error_code() ) { 131 unset($_POST['submit']); 132 bp_show_blog_signup_form( $blogname, $blog_title, $errors ); 133 return false; 134 } 135 136 $public = (int) $_POST['blog_public']; 137 138 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated 139 $meta = apply_filters( 'add_signup_meta', $meta ); 140 141 /* If this is a VHOST install, remove the username from the domain as we are setting this blog 142 up inside a user domain, not the root domain. */ 143 144 wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid ); 145 bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); 146 return true; 147 } 148 149 function bp_blogs_validate_blog_form() { 150 $user = ''; 151 if ( is_user_logged_in() ) 152 $user = wp_get_current_user(); 153 154 return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); 155 } 156 157 function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) { 158 ?> 159 <p><?php _e('Congratulations! You have successfully registered a new blog.', 'buddypress') ?></p> 160 <p> 161 <?php printf(__('<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.', 'buddypress'), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name) ?> 162 </p> 163 <?php 164 do_action('signup_finished'); 165 } 166 167 function bp_create_blog_link() { 168 global $bp; 169 170 if ( bp_is_home() ) { 171 echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' ); 172 } 173 } 174 175 function bp_blogs_blog_tabs() { 176 global $bp, $groups_template; 177 178 // Don't show these tabs on a user's own profile 179 if ( bp_is_home() ) 180 return false; 181 182 $current_tab = $bp->current_action 183 ?> 184 <ul class="content-header-nav"> 185 <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> 186 <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> 187 <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> 188 </ul> 189 <?php 190 do_action( 'bp_blogs_blog_tabs', $current_tab ); 191 } 192 193 /********************************************************************** 194 * User Blog listing template class 195 */ 196 197 class BP_Blogs_User_Blogs_Template { 5 198 var $current_blog = -1; 6 199 var $blog_count; … … 15 208 var $total_blog_count; 16 209 17 function bp_blogs_ blog_template( $user_id = null ) {210 function bp_blogs_user_blogs_template( $user_id = null ) { 18 211 global $bp; 19 212 … … 22 215 23 216 $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1; 24 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5; 25 26 $this->blogs = bp_blogs_get_blogs_for_user( $user_id ); 27 28 if ( !$this->blogs = wp_cache_get( 'bp_user_blogs_' . $user_id, 'bp' ) ) { 217 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 10; 218 219 if ( !$this->blogs = wp_cache_get( 'bp_blogs_for_user_' . $user_id, 'bp' ) ) { 29 220 $this->blogs = bp_blogs_get_blogs_for_user( $user_id ); 30 wp_cache_set( 'bp_ user_blogs_' . $user_id, $this->blogs, 'bp' );221 wp_cache_set( 'bp_blogs_for_user_' . $user_id, $this->blogs, 'bp' ); 31 222 } 32 223 … … 94 285 global $blogs_template; 95 286 96 $blogs_template = new BP_Blogs_ Blog_Template;287 $blogs_template = new BP_Blogs_User_Blogs_Template; 97 288 return $blogs_template->has_blogs(); 98 289 } … … 124 315 125 316 126 /** User Blog posts listing template class **/ 317 /********************************************************************** 318 * User Blog Posts listing template class 319 */ 127 320 128 321 class BP_Blogs_Blog_Post_Template { … … 146 339 147 340 $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1; 148 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;341 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 10; 149 342 150 343 if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) { … … 476 669 477 670 478 /** User Blog comments listing template class **/ 671 /********************************************************************** 672 * User Blog Comments listing template class 673 */ 479 674 480 675 class BP_Blogs_Post_Comment_Template { … … 498 693 499 694 $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1; 500 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;695 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 10; 501 696 502 697 if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) { … … 654 849 } 655 850 656 657 /* Blog registration template tags */ 658 659 function bp_blog_signup_enabled() { 660 $active_signup = get_site_option( 'registration' ); 661 662 if ( !$active_signup ) 663 $active_signup = 'all'; 664 665 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" 666 667 if ( 'none' == $active_signup || 'user' == $active_signup ) 668 return false; 669 670 return true; 671 } 672 673 function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') { 674 global $current_user, $current_site; 675 global $bp; 676 677 require_once( ABSPATH . WPINC . '/registration.php' ); 678 679 if ( isset($_POST['submit']) ) { 680 bp_blogs_validate_blog_signup(); 681 } else { 682 if ( ! is_wp_error($errors) ) { 683 $errors = new WP_Error(); 684 } 685 686 // allow definition of default variables 687 $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors )); 688 $blogname = $filtered_results['blogname']; 689 $blog_title = $filtered_results['blog_title']; 690 $errors = $filtered_results['errors']; 691 692 if ( $errors->get_error_code() ) { 693 echo "<p>" . __('There was a problem, please correct the form below and try again.', 'buddypress') . "</p>"; 694 } 695 ?> 696 <p><?php printf(__("By filling out the form below, you can <strong>add a blog to your account</strong>. There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly.", 'buddypress'), $current_user->display_name) ?></p> 697 698 <p><?php _e("If you’re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress') ?></p> 699 700 <form id="setupform" method="post" action="<?php echo $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog' ?>"> 701 702 <input type="hidden" name="stage" value="gimmeanotherblog" /> 703 <?php do_action( "signup_hidden_fields" ); ?> 704 <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?> 705 <p> 706 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog »', 'buddypress') ?>" /> 707 </p> 708 709 <?php wp_nonce_field( 'bp_blog_signup_form' ) ?> 710 </form> 711 <?php 712 } 713 } 714 715 function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) { 716 global $current_site; 717 718 // Blog name 719 if( 'no' == constant( "VHOST" ) ) 720 echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>'; 721 else 722 echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>'; 723 724 if ( $errmsg = $errors->get_error_message('blogname') ) { ?> 725 <p class="error"><?php echo $errmsg ?></p> 726 <?php } 727 728 if( 'no' == constant( "VHOST" ) ) { 729 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />'; 730 } else { 731 echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />'; 732 } 733 if ( !is_user_logged_in() ) { 734 print '(<strong>' . __( 'Your address will be ' , 'buddypress'); 735 if( 'no' == constant( "VHOST" ) ) { 736 print $current_site->domain . $current_site->path . __( 'blogname' , 'buddypress'); 851 /********************************************************************** 852 * Site Wide Blog listing template class 853 */ 854 855 class BP_Blogs_Site_Blogs_Template { 856 var $current_blog = -1; 857 var $blog_count; 858 var $blogs; 859 var $blog; 860 861 var $in_the_loop; 862 863 var $pag_page; 864 var $pag_num; 865 var $pag_links; 866 var $total_blog_count; 867 868 function bp_blogs_site_blogs_template( $type, $per_page, $max ) { 869 global $bp; 870 871 $this->pag_page = isset( $_REQUEST['page'] ) ? intval( $_REQUEST['page'] ) : 1; 872 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 873 874 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 875 $this->blogs = BP_Blogs_Blog::search_blogs( $_REQUEST['s'], $this->pag_num, $this->pag_page ); 876 } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { 877 $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 737 878 } else { 738 print __( 'domain.' , 'buddypress') . $current_site->domain . $current_site->path; 739 } 740 echo '.</strong> ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)' , 'buddypress') . '</p>'; 741 } 742 743 // Blog Title 744 ?> 745 <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label> 746 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 747 <p class="error"><?php echo $errmsg ?></p> 748 <?php } 749 echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>'; 750 ?> 751 752 <p> 753 <label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label> 754 <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?> 755 <div style="clear:both;"></div> 756 <label class="checkbox" for="blog_public_on"> 757 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 758 <strong><?php _e( 'Yes' , 'buddypress'); ?></strong> 759 </label> 760 <label class="checkbox" for="blog_public_off"> 761 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 762 <strong><?php _e( 'No' , 'buddypress'); ?></strong> 763 </label> 764 </p> 765 766 <?php 767 do_action('signup_blogform', $errors); 768 } 769 770 function bp_blogs_validate_blog_signup() { 771 global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path; 772 773 if ( !check_admin_referer( 'bp_blog_signup_form' ) ) 774 return false; 775 776 $current_user = wp_get_current_user(); 777 778 if( !is_user_logged_in() ) 779 die(); 780 781 $result = bp_blogs_validate_blog_form(); 782 extract($result); 783 784 if ( $errors->get_error_code() ) { 785 unset($_POST['submit']); 786 bp_show_blog_signup_form( $blogname, $blog_title, $errors ); 787 return false; 788 } 789 790 $public = (int) $_POST['blog_public']; 791 792 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated 793 $meta = apply_filters( 'add_signup_meta', $meta ); 794 795 /* If this is a VHOST install, remove the username from the domain as we are setting this blog 796 up inside a user domain, not the root domain. */ 797 798 wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid ); 799 bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); 800 return true; 801 } 802 803 function bp_blogs_validate_blog_form() { 804 $user = ''; 805 if ( is_user_logged_in() ) 806 $user = wp_get_current_user(); 807 808 return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); 809 } 810 811 function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) { 812 ?> 813 <p><?php _e('Congratulations! You have successfully registered a new blog.', 'buddypress') ?></p> 814 <p> 815 <?php printf(__('<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.', 'buddypress'), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name) ?> 816 </p> 817 <?php 818 do_action('signup_finished'); 819 } 820 821 function bp_create_blog_link() { 822 global $bp; 823 824 if ( bp_is_home() ) { 825 echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' ); 826 } 827 } 828 829 function bp_blogs_blog_tabs() { 830 global $bp, $groups_template; 831 832 // Don't show these tabs on a user's own profile 833 if ( bp_is_home() ) 834 return false; 835 836 $current_tab = $bp->current_action 879 switch ( $type ) { 880 case 'random': 881 $this->blogs = BP_Blogs_Blog::get_random( $this->pag_num, $this->pag_page ); 882 break; 883 884 case 'newest': 885 $this->blogs = BP_Blogs_Blog::get_newest( $this->pag_num, $this->pag_page ); 886 break; 887 888 case 'active': default: 889 $this->blogs = BP_Blogs_Blog::get_active( $this->pag_num, $this->pag_page ); 890 break; 891 } 892 } 893 894 if ( !$max ) 895 $this->total_blog_count = (int)$this->blogs['total']; 896 else 897 $this->total_blog_count = (int)$max; 898 899 $this->blogs = $this->blogs['blogs']; 900 $this->blog_count = count($this->blogs); 901 902 $this->pag_links = paginate_links( array( 903 'base' => add_query_arg( 'page', '%#%' ), 904 'format' => '', 905 'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ), 906 'current' => (int) $this->pag_page, 907 'prev_text' => '«', 908 'next_text' => '»', 909 'mid_size' => 1 910 )); 911 } 912 913 function has_blogs() { 914 if ( $this->blog_count ) 915 return true; 916 917 return false; 918 } 919 920 function next_blog() { 921 $this->current_blog++; 922 $this->blog = $this->blogs[$this->current_blog]; 923 924 return $this->blog; 925 } 926 927 function rewind_blogs() { 928 $this->current_blog = -1; 929 if ( $this->blog_count > 0 ) { 930 $this->blog = $this->blogs[0]; 931 } 932 } 933 934 function blogs() { 935 if ( $this->current_blog + 1 < $this->blog_count ) { 936 return true; 937 } elseif ( $this->current_blog + 1 == $this->blog_count ) { 938 do_action('loop_end'); 939 // Do some cleaning up after the loop 940 $this->rewind_blogs(); 941 } 942 943 $this->in_the_loop = false; 944 return false; 945 } 946 947 function the_blog() { 948 global $blog; 949 950 $this->in_the_loop = true; 951 $this->blog = $this->next_blog(); 952 953 if ( 0 == $this->current_blog ) // loop has just started 954 do_action('loop_start'); 955 } 956 } 957 958 function bp_rewind_site_blogs() { 959 global $site_blogs_template; 960 961 $site_blogs_template->rewind_blogs(); 962 } 963 964 function bp_has_site_blogs( $args = '' ) { 965 global $site_blogs_template; 966 967 $defaults = array( 968 'type' => 'active', 969 'per_page' => 10, 970 'max' => false 971 ); 972 973 $r = wp_parse_args( $args, $defaults ); 974 extract( $r, EXTR_SKIP ); 975 976 // type: active ( default ) | random | newest | popular 977 978 if ( $max ) { 979 if ( $per_page > $max ) 980 $per_page = $max; 981 } 982 983 $site_blogs_template = new BP_Blogs_Site_Blogs_Template( $type, $per_page, $max ); 984 985 return $site_blogs_template->has_blogs(); 986 } 987 988 function bp_site_blogs() { 989 global $site_blogs_template; 990 991 return $site_blogs_template->blogs(); 992 } 993 994 function bp_the_site_blog() { 995 global $site_blogs_template; 996 997 return $site_blogs_template->the_blog(); 998 } 999 1000 function bp_site_blogs_pagination_count() { 1001 global $bp, $site_blogs_template; 1002 1003 $from_num = intval( ( $site_blogs_template->pag_page - 1 ) * $site_blogs_template->pag_num ) + 1; 1004 $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 ) ; 1005 1006 echo sprintf( __( 'Viewing blog %d to %d (of %d blogs)', 'buddypress' ), $from_num, $to_num, $site_blogs_template->total_blog_count ); ?> 1007 <img id="ajax-loader-blogs" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php 1008 } 1009 1010 function bp_site_blogs_pagination_links() { 1011 global $site_blogs_template; 1012 echo $site_blogs_template->pag_links; 1013 } 1014 1015 function bp_the_site_blog_avatar() { 1016 global $site_blogs_template, $bp; 1017 1018 /*** 1019 * In future BuddyPress versions you will be able to set the avatar for a blog. 1020 * Right now you can use a filter with the ID of the blog to change it if you wish. 1021 */ 1022 1023 echo apply_filters( 'bp_blogs_blog_avatar_' . $site_blogs_template->blog->blog_id, '<img src="http://www.gravatar.com/avatar/' . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&s=150" class="avatar blog-avatar" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />' ); 1024 } 1025 1026 function bp_the_site_blog_avatar_thumb() { 1027 global $site_blogs_template, $bp; 1028 1029 echo apply_filters( 'bp_blogs_blog_avatar_thumb_' . $site_blogs_template->blog->blog_id, '<img src="http://www.gravatar.com/avatar/' . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&s=50" class="avatar blog-avatar thumb" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />' ); 1030 } 1031 1032 function bp_the_site_blog_avatar_mini() { 1033 global $site_blogs_template, $bp; 1034 1035 echo apply_filters( 'bp_blogs_blog_avatar_mini_' . $site_blogs_template->blog->blog_id, '<img src="http://www.gravatar.com/avatar/' . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&s=25" class="avatar blog-avatar mini" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />' ); 1036 } 1037 1038 function bp_the_site_blog_link() { 1039 global $site_blogs_template; 1040 1041 echo get_blog_option( $site_blogs_template->blog->blog_id, 'siteurl' ); 1042 } 1043 1044 function bp_the_site_blog_name() { 1045 global $site_blogs_template; 1046 1047 echo get_blog_option( $site_blogs_template->blog->blog_id, 'blogname' ); 1048 } 1049 1050 function bp_the_site_blog_description() { 1051 global $site_blogs_template; 1052 1053 echo get_blog_option( $site_blogs_template->blog->blog_id, 'blogdescription' ); 1054 } 1055 1056 function bp_the_site_blog_last_active() { 1057 global $site_blogs_template; 1058 1059 echo bp_core_get_last_activity( bp_blogs_get_blogmeta( $site_blogs_template->blog->blog_id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ); 1060 } 1061 1062 function bp_the_site_blog_latest_post() { 1063 global $site_blogs_template; 1064 1065 if ( $post = bp_blogs_get_latest_posts( $site_blogs_template->blog->blog_id, 1 ) ) { 1066 printf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . bp_post_get_permalink( $post[0], $site_blogs_template->blog->blog_id ) . '">' . apply_filters( 'the_title', $post[0]->post_title ) . '</a>' ); 1067 } 1068 } 1069 1070 1071 function bp_the_site_blog_hidden_fields() { 1072 if ( isset( $_REQUEST['s'] ) ) { 1073 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />'; 1074 } 1075 1076 if ( isset( $_REQUEST['letter'] ) ) { 1077 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 1078 } 1079 1080 if ( isset( $_REQUEST['blogs_search'] ) ) { 1081 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />'; 1082 } 1083 } 1084 1085 function bp_directory_blogs_search_form() { 1086 global $bp; ?> 1087 <form action="<?php echo $bp->root_domain . '/' . blogs_SLUG . '/search/' ?>" method="post" id="search-blogs-form"> 1088 <label><input type="text" name="blogs_search" id="blogs_search" value="<?php if ( isset( $_GET['s'] ) ) { echo $_GET['s']; } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 1089 <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 1090 </form> 1091 <?php 1092 } 1093 1094 837 1095 ?> 838 <ul class="content-header-nav">839 <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>840 <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>841 <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>842 </ul>843 <?php844 do_action( 'bp_blogs_blog_tabs', $current_tab );845 }846 847 ?>
Note: See TracChangeset
for help on using the changeset viewer.