Changeset 2077 for trunk/bp-blogs.php
- Timestamp:
- 11/02/2009 07:54:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs.php
r2055 r2077 13 13 /* Include deprecated functions if settings allow */ 14 14 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 15 require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 16 15 require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 16 17 17 function bp_blogs_install() { 18 18 global $wpdb, $bp; 19 19 20 20 if ( !empty($wpdb->charset) ) 21 21 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 22 22 23 23 $sql[] = "CREATE TABLE {$bp->blogs->table_name} ( 24 24 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 52 52 KEY comment_post_id (comment_post_id) 53 53 ) {$charset_collate};"; 54 54 55 55 $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} ( 56 56 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 61 61 KEY meta_key (meta_key) 62 62 ) {$charset_collate};"; 63 64 63 64 65 65 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 66 66 … … 69 69 // On first installation - record all existing blogs in the system. 70 70 if ( !(int)get_site_option( 'bp-blogs-first-install') ) { 71 71 72 72 bp_blogs_record_existing_blogs(); 73 73 add_site_option( 'bp-blogs-first-install', 1 ); 74 74 75 75 } else { 76 77 // Import blog titles and descriptions into the blogmeta table 76 77 // Import blog titles and descriptions into the blogmeta table 78 78 if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) { 79 79 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) ); … … 82 82 $name = get_blog_option( $blog_ids[$i], 'blogname' ); 83 83 $desc = get_blog_option( $blog_ids[$i], 'blogdescription' ); 84 84 85 85 bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name ); 86 86 bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc ); … … 88 88 } 89 89 } 90 91 } 92 90 91 } 92 93 93 update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION ); 94 94 } 95 95 96 function bp_blogs_check_installed() { 96 function bp_blogs_check_installed() { 97 97 global $wpdb, $bp, $userdata; 98 98 99 99 if ( is_site_admin() ) { 100 100 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ … … 107 107 function bp_blogs_setup_globals() { 108 108 global $bp, $wpdb; 109 109 110 110 /* For internal identification */ 111 111 $bp->blogs->id = 'blogs'; 112 112 113 113 $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs'; 114 114 $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts'; … … 117 117 $bp->blogs->format_notification_function = 'bp_blogs_format_notifications'; 118 118 $bp->blogs->slug = BP_BLOGS_SLUG; 119 119 120 120 /* Register this in the active components array */ 121 121 $bp->active_components[$bp->blogs->slug] = $bp->blogs->id; … … 123 123 do_action( 'bp_blogs_setup_globals' ); 124 124 } 125 add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 ); 125 add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 ); 126 126 add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 ); 127 127 … … 136 136 * 137 137 * Adds "Blog" to the navigation arrays for the current and logged in user. 138 * 138 * 139 139 * @package BuddyPress Blogs 140 140 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 143 143 function bp_blogs_setup_nav() { 144 144 global $bp; 145 145 146 146 /* Add 'Blogs' to the main navigation */ 147 147 bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) ); 148 148 149 149 $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/'; 150 150 151 151 /* Add the subnav items to the blogs nav item */ 152 152 bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) ); … … 159 159 if ( bp_is_home() ) { 160 160 if ( function_exists('xprofile_setup_nav') ) { 161 $bp->bp_options_title = __('My Blogs', 'buddypress'); 161 $bp->bp_options_title = __('My Blogs', 'buddypress'); 162 162 } 163 163 } else { 164 164 /* If we are not viewing the logged in user, set up the current users avatar and name */ 165 165 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 166 $bp->bp_options_title = $bp->displayed_user->fullname; 166 $bp->bp_options_title = $bp->displayed_user->fullname; 167 167 } 168 168 } 169 169 170 170 do_action( 'bp_blogs_setup_nav' ); 171 171 } … … 178 178 if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) { 179 179 $bp->is_directory = true; 180 180 181 181 do_action( 'bp_blogs_directory_blogs_setup' ); 182 182 bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) ); … … 196 196 function bp_blogs_screen_my_blogs() { 197 197 do_action( 'bp_blogs_screen_my_blogs' ); 198 bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) ); 198 bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) ); 199 199 } 200 200 … … 224 224 function bp_blogs_register_activity_actions() { 225 225 global $bp; 226 226 227 227 if ( !function_exists( 'bp_activity_set_action' ) ) 228 228 return false; … … 238 238 function bp_blogs_record_activity( $args = '' ) { 239 239 global $bp; 240 240 241 241 if ( !function_exists( 'bp_activity_add' ) ) 242 242 return false; 243 243 244 244 /* Because blog, comment, and blog post code execution happens before anything else 245 245 we may need to manually instantiate the activity component globals */ 246 246 if ( !$bp->activity && function_exists('bp_activity_setup_globals') ) 247 247 bp_activity_setup_globals(); 248 248 249 249 $defaults = array( 250 250 'user_id' => $bp->loggedin_user->id, … … 260 260 261 261 $r = wp_parse_args( $args, $defaults ); 262 extract( $r, EXTR_SKIP ); 263 262 extract( $r, EXTR_SKIP ); 263 264 264 return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); 265 265 } … … 268 268 if ( function_exists('bp_activity_delete_by_item_id') ) { 269 269 extract($args); 270 271 bp_activity_delete_by_item_id( array( 272 'item_id' => $item_id, 270 271 bp_activity_delete_by_item_id( array( 272 'item_id' => $item_id, 273 273 'component_name' => $component_name, 274 'component_action' => $component_action, 274 'component_action' => $component_action, 275 275 'user_id' => $user_id, 276 276 'secondary_item_id' => $secondary_item_id … … 292 292 293 293 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) ); 294 294 295 295 if ( $blog_ids ) { 296 296 foreach( $blog_ids as $blog_id ) { … … 311 311 function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) { 312 312 global $bp; 313 313 314 314 if ( !$user_id ) 315 315 $user_id = $bp->loggedin_user->id; 316 316 317 317 $name = get_blog_option( $blog_id, 'blogname' ); 318 318 $description = get_blog_option( $blog_id, 'blogdescription' ); 319 319 320 320 $recorded_blog = new BP_Blogs_Blog; 321 321 $recorded_blog->user_id = $user_id; … … 323 323 324 324 $recorded_blog_id = $recorded_blog->save(); 325 325 326 326 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name ); 327 327 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description ); 328 328 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() ); 329 329 330 330 /* Only record this activity if the blog is public */ 331 331 if ( (int)$_POST['blog_public'] || !$no_activity ) { … … 333 333 bp_blogs_record_activity( array( 334 334 'user_id' => $recorded_blog->user_id, 335 'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ), 335 'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ), 336 336 'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ), 337 337 'component_action' => 'new_blog', … … 339 339 ) ); 340 340 } 341 341 342 342 do_action( 'bp_blogs_new_blog', &$recorded_blog, $is_private, $is_recorded ); 343 343 } … … 346 346 function bp_blogs_record_post( $post_id, $post, $user_id = false ) { 347 347 global $bp, $wpdb; 348 348 349 349 $post_id = (int)$post_id; 350 350 $blog_id = (int)$wpdb->blogid; 351 351 352 352 if ( !$user_id ) 353 353 $user_id = (int)$post->post_author; 354 355 354 /* This is to stop infinate loops with Donncha's sitewide tags plugin */ 356 355 if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id ) 357 356 return false; 358 357 359 358 /* Don't record this if it's not a post */ 360 359 if ( $post->post_type != 'post' ) 361 360 return false; 362 361 363 362 if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) { 364 363 if ( 'publish' == $post->post_status && '' == $post->post_password ) { 365 364 366 365 $recorded_post = new BP_Blogs_Post; 367 366 $recorded_post->user_id = $user_id; … … 369 368 $recorded_post->post_id = $post_id; 370 369 $recorded_post->date_created = strtotime( $post->post_date ); 371 370 372 371 $recorded_post_id = $recorded_post->save(); 373 372 374 373 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() ); 375 374 … … 380 379 $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); 381 380 $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>"; 382 381 383 382 bp_blogs_record_activity( array( 384 383 'user_id' => (int)$post->post_author, 385 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 384 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 386 385 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 387 386 'component_action' => 'new_blog_post', … … 399 398 /* Delete the recorded post if the status is not published or it is password protected */ 400 399 if ( 'publish' != $post->post_status || '' != $post->post_password ) { 401 return bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 402 400 return bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 401 403 402 /* If the post author has changed, delete the post and re-add it. */ 404 403 } else if ( (int)$existing_post->user_id != (int)$post->post_author ) { 405 404 // Delete the existing recorded post 406 405 bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 407 406 408 407 // Re-record the post with the new author. 409 bp_blogs_record_post( $post_id ); 408 bp_blogs_record_post( $post_id ); 410 409 } 411 410 412 411 if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) { 413 /* Now re-record the post in the activity streams */ 412 /* Now re-record the post in the activity streams */ 414 413 $post_permalink = bp_post_get_permalink( $post, $blog_id ); 415 414 416 415 $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); 417 416 $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>"; 418 417 419 418 /* Record this in activity streams */ 420 419 bp_blogs_record_activity( array( 421 420 'user_id' => (int)$post->post_author, 422 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 421 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 423 422 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 424 423 'component_action' => 'new_blog_post', … … 435 434 function bp_blogs_record_comment( $comment_id, $is_approved ) { 436 435 global $wpdb, $bp; 437 436 438 437 if ( !$is_approved ) 439 438 return false; 440 439 441 440 $comment = get_comment($comment_id); 442 441 $comment->post = get_post( $comment->comment_post_ID ); 443 442 444 443 /* Get the user_id from the author email. */ 445 444 $user = get_user_by_email( $comment->comment_author_email ); 446 445 $user_id = (int)$user->ID; 447 446 448 447 if ( !$user_id ) 449 448 return false; … … 457 456 458 457 $recorded_commment_id = $recorded_comment->save(); 459 458 460 459 bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() ); 461 460 … … 463 462 /* Record in activity streams */ 464 463 $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id ); 465 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 464 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 466 465 $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>'; 467 466 … … 469 468 bp_blogs_record_activity( array( 470 469 'user_id' => $recorded_comment->user_id, 471 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 470 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 472 471 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ), 473 472 'component_action' => 'new_blog_comment', … … 484 483 function bp_blogs_approve_comment( $comment_id, $comment_status ) { 485 484 global $bp, $wpdb; 486 485 487 486 if ( 'approve' != $comment_status ) 488 487 return false; … … 491 490 $comment = get_comment($comment_id); 492 491 $comment->post = get_post( $comment->comment_post_ID ); 493 492 494 493 bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) ); 495 494 … … 497 496 /* Record in activity streams */ 498 497 $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id ); 499 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 498 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 500 499 $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>'; 501 500 … … 503 502 bp_blogs_record_activity( array( 504 503 'user_id' => $recorded_comment->user_id, 505 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 504 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 506 505 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ), 507 506 'component_action' => 'new_blog_comment', 508 507 'item_id' => $comment_id, 509 508 'secondary_item_id' => $recorded_comment->blog_id, 510 'recorded_time' => $recorded_comment->date_created 509 'recorded_time' => $recorded_comment->date_created 511 510 ) ); 512 511 } … … 516 515 function bp_blogs_unapprove_comment( $comment_id, $comment_status ) { 517 516 if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status ) 518 bp_blogs_remove_comment( $comment_id ); 517 bp_blogs_remove_comment( $comment_id ); 519 518 } 520 519 add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 ); … … 538 537 539 538 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 540 539 541 540 // Delete activity stream item 542 541 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) ); 543 542 544 543 do_action( 'bp_blogs_remove_blog', $blog_id ); 545 544 } … … 548 547 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 549 548 global $current_user; 550 549 551 550 $blog_id = (int)$blog_id; 552 551 $user_id = (int)$user_id; … … 565 564 566 565 $post_id = (int)$post_id; 567 566 568 567 if ( !$blog_id ) 569 568 $blog_id = (int)$current_blog->blog_id; 570 569 571 570 if ( !$existing_post ) 572 571 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id ); … … 574 573 // Delete post from the bp_blogs table 575 574 BP_Blogs_Post::delete( $post_id, $blog_id ); 576 575 577 576 // Delete activity stream item 578 577 bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) ); … … 586 585 587 586 $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id ); 588 BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 587 BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 589 588 590 589 // Delete activity stream item … … 597 596 function bp_blogs_remove_data_for_blog( $blog_id ) { 598 597 global $bp; 599 598 600 599 /* If this is regular blog, delete all data for that blog. */ 601 600 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 602 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 601 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 603 602 BP_Blogs_Comment::delete_comments_for_blog( $blog_id ); 604 603 … … 624 623 function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) { 625 624 global $bp; 626 625 627 626 if ( !is_numeric( $limit ) ) 628 627 $limit = 5; 629 628 630 629 return BP_Blogs_Post::get_latest_posts( $blog_id, $limit ); 631 630 } … … 645 644 function bp_blogs_total_post_count( $blog_id ) { 646 645 return BP_Blogs_Post::total_post_count( $blog_id ); 647 } 646 } 648 647 649 648 function bp_blogs_total_comment_count( $blog_id, $post_id = false ) { 650 649 return BP_Blogs_Post::total_comment_count( $blog_id, $post_id ); 651 } 650 } 652 651 653 652 function bp_blogs_is_blog_hidden( $blog_id ) { … … 657 656 function bp_blogs_redirect_to_random_blog() { 658 657 global $bp, $wpdb; 659 658 660 659 if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) { 661 660 $blog = bp_blogs_get_random_blog(); … … 676 675 function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) { 677 676 global $wpdb, $bp; 678 677 679 678 if ( !is_numeric( $blog_id ) ) 680 679 return false; 681 680 682 681 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 683 682 684 683 if ( is_array($meta_value) || is_object($meta_value) ) 685 684 $meta_value = serialize($meta_value); 686 685 687 686 $meta_value = trim( $meta_value ); 688 687 689 688 if ( !$meta_key ) { 690 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) ); 689 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) ); 691 690 } else if ( $meta_value ) { 692 691 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) ); … … 694 693 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) ); 695 694 } 696 695 697 696 // TODO need to look into using this. 698 697 // wp_cache_delete($group_id, 'groups'); … … 703 702 function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') { 704 703 global $wpdb, $bp; 705 704 706 705 $blog_id = (int) $blog_id; 707 706 … … 711 710 if ( !empty($meta_key) ) { 712 711 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 713 712 714 713 // TODO need to look into using this. 715 714 //$user = wp_cache_get($user_id, 'users'); 716 715 717 716 // Check the cached user object 718 717 //if ( false !== $user && isset($user->$meta_key) ) … … 741 740 function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) { 742 741 global $wpdb, $bp; 743 742 744 743 if ( !is_numeric( $blog_id ) ) 745 744 return false; 746 745 747 746 $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key ); 748 747 749 748 if ( is_string($meta_value) ) 750 749 $meta_value = stripslashes($wpdb->escape($meta_value)); 751 750 752 751 $meta_value = maybe_serialize($meta_value); 753 752 … … 757 756 758 757 $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) ); 759 758 760 759 if ( !$cur ) { 761 760 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) ); … … 775 774 /* If this is regular blog, delete all data for that blog. */ 776 775 BP_Blogs_Blog::delete_blogs_for_user( $user_id ); 777 BP_Blogs_Post::delete_posts_for_user( $user_id ); 776 BP_Blogs_Post::delete_posts_for_user( $user_id ); 778 777 BP_Blogs_Comment::delete_comments_for_user( $user_id ); 779 778
Note: See TracChangeset
for help on using the changeset viewer.