Changeset 5686
- Timestamp:
- 02/09/2012 10:36:36 PM (14 years ago)
- Location:
- trunk/bp-blogs
- Files:
-
- 10 edited
-
bp-blogs-actions.php (modified) (1 diff)
-
bp-blogs-activity.php (modified) (5 diffs)
-
bp-blogs-buddybar.php (modified) (2 diffs)
-
bp-blogs-cache.php (modified) (2 diffs)
-
bp-blogs-classes.php (modified) (3 diffs)
-
bp-blogs-functions.php (modified) (10 diffs)
-
bp-blogs-loader.php (modified) (1 diff)
-
bp-blogs-screens.php (modified) (1 diff)
-
bp-blogs-template.php (modified) (17 diffs)
-
bp-blogs-widgets.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-actions.php
r4961 r5686 1 1 <?php 2 3 /** 4 * BuddyPress Blogs Actions 5 * 6 * @package BuddyPress 7 * @subpackage BlogsActions 8 */ 9 2 10 // Exit if accessed directly 3 11 if ( !defined( 'ABSPATH' ) ) exit; 4 12 13 /** 14 * Redirect to a random blog in the multisite network 15 * 16 * @since BuddyPress (1.0) 17 * @package BuddyPress 18 * @subpackage BlogsActions 19 */ 5 20 function bp_blogs_redirect_to_random_blog() { 6 global $bp, $wpdb;7 21 8 if ( bp_is_blogs_component() && isset( $_GET['random-blog'] ) ) { 22 // Bail if not looking for a random blog 23 if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) ) 24 return; 25 26 // Multisite is active so find a random blog 27 if ( is_multisite() ) { 9 28 $blog = bp_blogs_get_random_blogs( 1, 1 ); 29 bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) ); 10 30 11 bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) ); 31 // No multisite and still called, always redirect to root 32 } else { 33 bp_core_redirect( bp_core_get_root_domain() ); 12 34 } 13 35 } -
trunk/bp-blogs/bp-blogs-activity.php
r5302 r5686 1 1 <?php 2 /****************************************************************************** 3 * These functions handle the recording, deleting and formatting of activity and 4 * notifications for the user and for this specific component. 2 3 /** 4 * BuddyPress Blogs Activity 5 * 6 * @package BuddyPress 7 * @subpackage BlogsActivity 5 8 */ 6 9 … … 8 11 if ( !defined( 'ABSPATH' ) ) exit; 9 12 10 13 /** 14 * Register activity actions for the blogs component 15 * 16 * @since BuddyPress (1.0) 17 * @package BuddyPress 18 * @subpackage BlogsActivity 19 * @global type $bp 20 * @return boolean 21 */ 11 22 function bp_blogs_register_activity_actions() { 12 23 global $bp; 13 24 14 if ( !bp_is_active( 'activity' ) ) 25 // Bail if activity is not active 26 if ( ! bp_is_active( 'activity' ) ) 15 27 return false; 16 28 … … 23 35 add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' ); 24 36 37 /** 38 * Record the activity to the actvity stream 39 * 40 * @since BuddyPress (1.0) 41 * @package BuddyPress 42 * @subpackage BlogsActivity 43 * @global BuddyPress $bp 44 * @param array $args 45 * @return boolean 46 */ 25 47 function bp_blogs_record_activity( $args = '' ) { 26 48 global $bp; 27 49 28 if ( !bp_is_active( 'activity' ) ) 50 // Bail if activity is not active 51 if ( ! bp_is_active( 'activity' ) ) 29 52 return false; 30 53 … … 46 69 47 70 // Remove large images and replace them with just one image thumbnail 48 if ( bp_is_active( 'activity' ) &&!empty( $content ) )71 if ( !empty( $content ) ) 49 72 $content = bp_activity_thumbnail_content_images( $content, $primary_link ); 50 73 … … 67 90 } 68 91 92 /** 93 * Delete a blogs activity stream item 94 * 95 * @since BuddyPress (1.0) 96 * @package BuddyPress 97 * @subpackage BlogsActivity 98 * @global BuddyPress $bp 99 * @param array $args 100 * @return If activity is not active 101 */ 69 102 function bp_blogs_delete_activity( $args = true ) { 70 103 global $bp; 71 104 72 if ( bp_is_active( 'activity' ) ) { 73 $defaults = array( 74 'item_id' => false, 75 'component' => $bp->blogs->id, 76 'type' => false, 77 'user_id' => false, 78 'secondary_item_id' => false 79 ); 105 // Bail if activity is not active 106 if ( ! bp_is_active( 'activity' ) ) 107 return false; 80 108 81 $params = wp_parse_args( $args, $defaults ); 82 extract( $params, EXTR_SKIP ); 109 $defaults = array( 110 'item_id' => false, 111 'component' => $bp->blogs->id, 112 'type' => false, 113 'user_id' => false, 114 'secondary_item_id' => false 115 ); 83 116 84 bp_activity_delete_by_item_id( array( 85 'item_id' => $item_id, 86 'component' => $component, 87 'type' => $type, 88 'user_id' => $user_id, 89 'secondary_item_id' => $secondary_item_id 90 ) ); 91 } 117 $params = wp_parse_args( $args, $defaults ); 118 extract( $params, EXTR_SKIP ); 119 120 bp_activity_delete_by_item_id( array( 121 'item_id' => $item_id, 122 'component' => $component, 123 'type' => $type, 124 'user_id' => $user_id, 125 'secondary_item_id' => $secondary_item_id 126 ) ); 92 127 } 93 128 -
trunk/bp-blogs/bp-blogs-buddybar.php
r5302 r5686 1 1 <?php 2 3 /** 4 * BuddyPress Blogs Activity 5 * 6 * @package BuddyPress 7 * @subpackage BlogsBuddyBar 8 */ 9 2 10 // Exit if accessed directly 3 11 if ( !defined( 'ABSPATH' ) ) exit; 4 12 5 // *** "My Blogs" Menu ******** 13 /** 14 * Add a Sites menu to the BuddyBar 15 * 16 * @since BuddyPress (1.0) 17 * @package BuddyPress 18 * @subpackage BlogsBuddyBar 19 * @global BuddyPress $bp 20 * @return boolean 21 */ 22 6 23 function bp_adminbar_blogs_menu() { 7 24 global $bp; … … 13 30 return false; 14 31 15 if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' ) ) { 32 $blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' ); 33 if ( empty( $blogs ) ) { 16 34 $blogs = bp_blogs_get_blogs_for_user( bp_loggedin_user_id(), true ); 17 35 wp_cache_set( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, 'bp' ); -
trunk/bp-blogs/bp-blogs-cache.php
r4961 r5686 1 1 <?php 2 /******************************************************************************* 3 * Caching 2 3 /** 4 * BuddyPress Blogs Caching 4 5 * 5 6 * Caching functions handle the clearing of cached objects and pages on specific 6 7 * actions throughout BuddyPress. 8 * 9 * @package BuddyPress 10 * @subpackage BlogsBuddyBar 7 11 */ 8 12 … … 10 14 if ( !defined( 'ABSPATH' ) ) exit; 11 15 16 /** 17 * Clear the blog object cache 18 * 19 * @since BuddyPress (1.0) 20 * @package BuddyPress 21 * @subpackage BlogsBuddyBar 22 * @param int $blog_id 23 * @param int $user_id 24 */ 12 25 function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) { 13 wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );26 wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' ); 14 27 wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' ); 15 28 } 16 29 30 /** 31 * Clear cache when a new blog is created 32 * 33 * @since BuddyPress (1.0) 34 * @package BuddyPress 35 * @subpackage BlogsBuddyBar 36 * @param Blog $recorded_blog_obj 37 */ 17 38 function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) { 18 39 bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id ); -
trunk/bp-blogs/bp-blogs-classes.php
r5329 r5686 1 1 <?php 2 3 /** 4 * BuddyPress Blogs Classes 5 * 6 * @package BuddyPress 7 * @subpackage BlogsClasses 8 */ 9 2 10 // Exit if accessed directly 3 11 if ( !defined( 'ABSPATH' ) ) exit; 4 12 5 Class BP_Blogs_Blog { 13 /** 14 * The main BuddyPress blog class 15 * 16 * @since BuddyPress (1.0) 17 * @package BuddyPress 18 * @subpackage BlogsClasses 19 */ 20 class BP_Blogs_Blog { 6 21 var $id; 7 22 var $user_id; … … 13 28 14 29 function __construct( $id = null ) { 15 global $bp, $wpdb; 16 17 $user_id = bp_displayed_user_id(); 18 19 if ( $id ) { 30 if ( !empty( $id ) ) { 20 31 $this->id = $id; 21 32 $this->populate(); … … 280 291 } 281 292 } 293 282 294 ?> -
trunk/bp-blogs/bp-blogs-functions.php
r5606 r5686 18 18 19 19 function bp_blogs_get_blogs( $args = '' ) { 20 global $bp;21 20 22 21 $defaults = array( … … 74 73 * Makes BuddyPress aware of a new site so that it can track its activity. 75 74 * 76 * @ global object $bp BuddyPress global settings75 * @since BuddyPress (1.0) 77 76 * @param int $blog_id 78 77 * @param int $user_id 79 78 * @param $bool $no_activity ; optional. 80 * @since 1.081 79 * @uses BP_Blogs_Blog 82 80 */ 83 81 function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) { 84 global $bp; 85 86 if ( !$user_id ) 82 83 if ( empty( $user_id ) ) 87 84 $user_id = bp_loggedin_user_id(); 88 85 … … 96 93 $recorded_blog->user_id = $user_id; 97 94 $recorded_blog->blog_id = $blog_id; 98 99 $recorded_blog_id = $recorded_blog->save(); 100 101 $is_recorded = !empty( $recorded_blog_id ) ? true : false; 95 $recorded_blog_id = $recorded_blog->save(); 96 $is_recorded = !empty( $recorded_blog_id ) ? true : false; 102 97 103 98 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name ); … … 234 229 * password protected. 235 230 * 236 * @global $bp $bp237 231 * @param int $comment_id 238 232 * @param bool $is_approved … … 240 234 */ 241 235 function bp_blogs_record_comment( $comment_id, $is_approved = true ) { 242 global $bp;243 236 244 237 // Get the users comment … … 365 358 366 359 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 367 global $bp , $current_user;368 369 $blog_id = (int) $blog_id;370 $user_id = (int) $user_id;360 global $bp; 361 362 $blog_id = (int) $blog_id; 363 $user_id = (int) $user_id; 371 364 372 365 do_action( 'bp_blogs_before_remove_blog_for_user', $blog_id, $user_id ); … … 375 368 376 369 // Delete activity stream item 377 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => 'new_blog' ) ); 370 bp_blogs_delete_activity( array( 371 'item_id' => $blog_id, 372 'component' => $bp->blogs->id, 373 'type' => 'new_blog' 374 ) ); 378 375 379 376 do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id ); … … 405 402 406 403 function bp_blogs_remove_comment( $comment_id ) { 407 global $wpdb , $bp;404 global $wpdb; 408 405 409 406 // Delete activity stream item … … 497 494 498 495 function bp_blogs_total_blogs_for_user( $user_id = 0 ) { 499 global $bp; 500 501 if ( !$user_id ) 496 497 if ( empty( $user_id ) ) 502 498 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 503 499 … … 653 649 add_action( 'delete_user', 'bp_blogs_remove_data' ); 654 650 add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' ); 651 655 652 ?> -
trunk/bp-blogs/bp-blogs-loader.php
r5478 r5686 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Blogs Streams Loader -
trunk/bp-blogs/bp-blogs-screens.php
r4961 r5686 1 1 <?php 2 3 /** 4 * BuddyPress Blogs Screens 5 * 6 * @package BuddyPress 7 * @subpackage BlogsScreens 8 */ 9 2 10 // Exit if accessed directly 3 11 if ( !defined( 'ABSPATH' ) ) exit; -
trunk/bp-blogs/bp-blogs-template.php
r5478 r5686 1 1 <?php 2 3 /** 4 * BuddyPress Blogs Template Tags 5 * 6 * @package BuddyPress 7 * @subpackage BlogsTemplate 8 */ 9 2 10 // Exit if accessed directly 3 11 if ( !defined( 'ABSPATH' ) ) exit; … … 7 15 * 8 16 * @package BuddyPress 9 * @subpackage Blogs Template17 * @subpackage BlogsTemplate 10 18 * @since BuddyPress (r4100) 11 19 * … … 19 27 * 20 28 * @package BuddyPress 21 * @subpackage Blogs Template29 * @subpackage BlogsTemplate 22 30 * @since BuddyPress (r4100) 23 31 */ … … 31 39 * 32 40 * @package BuddyPress 33 * @subpackage Blogs Template41 * @subpackage BlogsTemplate 34 42 * @since BuddyPress (r4100) 35 43 * … … 43 51 * 44 52 * @package BuddyPress 45 * @subpackage Blogs Template53 * @subpackage BlogsTemplate 46 54 * @since BuddyPress (r4100) 47 55 */ … … 55 63 * 56 64 * @package BuddyPress 57 * @subpackage Blogs Template65 * @subpackage BlogsTemplate 58 66 * @since 1.5 59 67 * @uses bp_get_blogs_directory_permalink() … … 66 74 * 67 75 * @package BuddyPress 68 * @subpackage Blogs Template76 * @subpackage BlogsTemplate 69 77 * @since 1.5 70 78 * @uses apply_filters() … … 100 108 101 109 function __construct( $type, $page, $per_page, $max, $user_id, $search_terms ) { 102 global $bp;103 110 104 111 $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : $page; … … 175 182 176 183 function the_blog() { 177 global $blog;178 184 179 185 $this->in_the_loop = true; … … 192 198 193 199 function bp_has_blogs( $args = '' ) { 194 global $b p, $blogs_template;200 global $blogs_template; 195 201 196 202 /*** … … 228 234 229 235 if ( $max ) { 230 if ( $per_page > $max ) 236 if ( $per_page > $max ) { 231 237 $per_page = $max; 238 } 232 239 } 233 240 … … 249 256 250 257 function bp_blogs_pagination_count() { 251 global $b p, $blogs_template;258 global $blogs_template; 252 259 253 260 $start_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1; … … 272 279 } 273 280 function bp_get_blog_avatar( $args = '' ) { 274 global $blogs_template , $bp;281 global $blogs_template; 275 282 276 283 $defaults = array( … … 402 409 403 410 function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') { 404 global $current_user, $current_site; 405 global $bp; 411 global $current_user; 406 412 407 413 if ( isset($_POST['submit']) ) { … … 582 588 583 589 function bp_create_blog_link() { 584 global $bp;585 586 590 if ( bp_is_my_profile() ) 587 591 echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' ); … … 589 593 590 594 function bp_blogs_blog_tabs() { 591 global $bp, $groups_template;592 595 593 596 // Don't show these tabs on a user's own profile … … 608 611 609 612 function bp_directory_blogs_search_form() { 610 global $bp;611 613 612 614 $default_search_value = bp_get_search_default_text(); 613 $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>615 $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?> 614 616 615 617 <form action="" method="get" id="search-blogs-form"> -
trunk/bp-blogs/bp-blogs-widgets.php
r4819 r5686 1 1 <?php 2 3 /** 4 * BuddyPress Blogs Widgets 5 * 6 * @package BuddyPress 7 * @subpackage BlogsWidgets 8 */ 9 2 10 // Exit if accessed directly 3 11 if ( !defined( 'ABSPATH' ) ) exit; 4 12 5 /*** 6 * The recent blogs widget is actually just the activity feed filtered on "new_blog_post". 7 * Why not make some of your own widgets using a filtered activity stream? 8 */ 13 // @todo not use create_function() 14 function bp_blogs_register_widgets() { 15 global $wpdb; 9 16 10 function bp_blogs_register_widgets() { 11 global $wpdb, $bp; 12 13 if ( bp_is_active( 'activity' ) && (int)$wpdb->blogid == bp_get_root_blog_id() ) 17 if ( bp_is_active( 'activity' ) && (int) $wpdb->blogid == bp_get_root_blog_id() ) 14 18 add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");') ); 15 19 } … … 27 31 28 32 function widget($args, $instance) { 29 global $bp;30 33 31 34 extract( $args );
Note: See TracChangeset
for help on using the changeset viewer.