Changeset 7409
- Timestamp:
- 10/10/2013 06:34:00 PM (11 years ago)
- Location:
- trunk/bp-blogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-filters.php
r6477 r7409 9 9 */ 10 10 11 / / Display filters11 /** Display Filters **********************************************************/ 12 12 13 13 add_filter( 'bp_get_blog_latest_post_title', 'wptexturize' ); … … 23 23 24 24 /** 25 * Ensure sthat the 'Create a new site' link at wp-admin/my-sites.php points to the BP blog signup25 * Ensure that the 'Create a new site' link at wp-admin/my-sites.php points to the BP blog signup 26 26 * 27 27 * @since BuddyPress (1.6) 28 * @uses apply_filters() Filter bp_blogs_creation_location to alter the returned value29 28 * 30 * @param string $url The original URL (points to wp-signup.php by default) 31 * @return string The new URL 29 * @uses apply_filters() Filter 'bp_blogs_creation_location' to alter the 30 * returned value. 31 * 32 * @param string $url The original URL (points to wp-signup.php by default). 33 * @return string The new URL. 32 34 */ 33 35 function bp_blogs_creation_location( $url ) { -
trunk/bp-blogs/bp-blogs-functions.php
r7349 r7409 1 1 <?php 2 2 /** 3 * Blogs component functions 3 * Blogs component functions. 4 4 * 5 5 * @package BuddyPress … … 11 11 12 12 /** 13 * Check s $bp pages global and looks for directory page13 * Check whether the $bp global lists an activity directory page. 14 14 * 15 15 * @since BuddyPress (1.5) 16 16 * 17 * @global BuddyPress $bp The one true BuddyPress instance 18 * @return bool True if set, False if empty 17 * @global BuddyPress $bp The one true BuddyPress instance. 18 * 19 * @return bool True if set, false if empty. 19 20 */ 20 21 function bp_blogs_has_directory() { … … 24 25 } 25 26 27 /** 28 * Retrieve a set of blogs 29 * 30 * @see BP_Blogs_Blog::get() for a description of arguments and return value. 31 * 32 * @param array $args { 33 * Arguments are listed here with their default values. For more 34 * information about the arguments, see {@link BP_Blogs_Blog::get()}. 35 * @type string $type Default: 'active'. 36 * @type int|bool $user_id Default: false. 37 * @type string|bool $search_terms Default: false. 38 * @type int $per_page Default: 20. 39 * @type int $page Default: 1. 40 * } 41 * @return array See {@link BP_Blogs_Blog::get()}. 42 */ 26 43 function bp_blogs_get_blogs( $args = '' ) { 27 44 … … 41 58 42 59 /** 43 * Populates the BP blogs table with existing blogs. 44 * 45 * @package BuddyPress Blogs 60 * Populate the BP blogs table with existing blogs. 46 61 * 47 62 * @global object $bp BuddyPress global settings … … 80 95 81 96 /** 82 * Makes BuddyPress aware of sites that shouldn't be recorded toactivity streams.97 * Check whether a given blog should be recorded in activity streams. 83 98 * 84 99 * If $user_id is provided, you can restrict site from being recordable … … 86 101 * 87 102 * @since BuddyPress (1.7) 88 * @param int $blog_id 89 * @param int|null $user_id 103 * 90 104 * @uses apply_filters() 91 * @return bool True if blog is recordable, false elsewhere 105 * 106 * @param int $blog_id ID of the blog being checked. 107 * @param int $user_id Optional. ID of the user for whom access is being checked. 108 * @return bool True if blog is recordable, otherwise false. 92 109 */ 93 110 function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) { … … 109 126 110 127 /** 111 * Makes BuddyPress aware of sites that activities shouldn't be trackable. 128 * Check whether a given blog should be tracked by the Blogs component. 129 * 112 130 * If $user_id is provided, the developer can restrict site from 113 131 * being trackable only to particular users. 114 132 * 115 133 * @since BuddyPress (1.7) 116 * @param int $blog_id 117 * @param int|null $user_id 134 * 118 135 * @uses bp_blogs_is_blog_recordable 119 136 * @uses apply_filters() 120 * @return bool True if blog is trackable, false elsewhere 137 * 138 * @param int $blog_id ID of the blog being checked. 139 * @param int $user_id Optional. ID of the user for whom access is being checked. 140 * @return bool True if blog is trackable, otherwise false. 121 141 */ 122 142 function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) { … … 138 158 139 159 /** 140 * Make sBuddyPress aware of a new site so that it can track its activity.160 * Make BuddyPress aware of a new site so that it can track its activity. 141 161 * 142 162 * @since BuddyPress (1.0) 143 * @param int $blog_id 144 * @param int $user_id 145 * @param bool $no_activity Optional; defaults to false 163 * 146 164 * @uses BP_Blogs_Blog 165 * 166 * @param int $blog_id ID of the blog being recorded. 167 * @param int $user_id ID of the user for whom the blog is being recorded. 168 * @param bool $no_activity Optional. Whether to skip recording an activity 169 * item about this blog creation. Default: false. 170 * @return bool|null Returns false on failure. 147 171 */ 148 172 function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) { … … 192 216 193 217 /** 194 * Updates blogname in BuddyPress blogmeta table 195 * 196 * @global object $wpdb DB Layer 197 * @param string $oldvalue Value before save (not used) 198 * @param string $newvalue Value to change meta to 218 * Update blog name in BuddyPress blogmeta table. 219 * 220 * @global object $wpdb DB Layer. 221 * 222 * @param string $oldvalue Value before save. Passed by do_action() but unused here. 223 * @param string $newvalue Value to change meta to. 199 224 */ 200 225 function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) { … … 206 231 207 232 /** 208 * Updates blogdescription in BuddyPress blogmeta table 209 * 210 * @global object $wpdb DB Layer 211 * @param string $oldvalue Value before save (not used) 212 * @param string $newvalue Value to change meta to 233 * Update blog description in BuddyPress blogmeta table 234 * 235 * @global object $wpdb DB Layer. 236 * 237 * @param string $oldvalue Value before save. Passed by do_action() but unused here. 238 * @param string $newvalue Value to change meta to. 213 239 */ 214 240 function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) { … … 219 245 add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 ); 220 246 247 /** 248 * Record a new blog post in the BuddyPress activity stream. 249 * 250 * @param int $post_id ID of the post being recorded. 251 * @param object $post The WP post object passed to the 'save_post' action. 252 * @param int $user_id Optional. The user to whom the activity item will be 253 * associated. Defaults to the post_author. 254 * @return bool|null Returns false on failure. 255 */ 221 256 function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) { 222 257 global $bp, $wpdb; … … 301 336 302 337 /** 303 * Record blog comment activity. Checks if blog is public and post is not 304 * password protected. 305 * 306 * @param int $comment_id 307 * @param mixed $is_approved 308 * @return mixed 338 * Record a new blog comment in the BuddyPress activity stream. 339 * 340 * Only posts the item if blog is public and post is not password-protected. 341 * 342 * @param int $comment_id ID of the comment being recorded. 343 * @param bool|string $is_approved Optional. The $is_approved value passed to 344 * the 'comment_post' action. Default: true. 345 * @return bool|object Returns false on failure, the comment object on success. 309 346 */ 310 347 function bp_blogs_record_comment( $comment_id, $is_approved = true ) { … … 392 429 add_action( 'edit_comment', 'bp_blogs_record_comment', 10 ); 393 430 431 /** 432 * Record a user's association with a blog. 433 * 434 * This function is hooked to several WordPress actions where blog roles are 435 * set/changed ('add_user_to_blog', 'profile_update', 'user_register'). It 436 * parses the changes, and records them as necessary in the BP blog tracker. 437 * 438 * BuddyPress does not track blogs for Subscribers. 439 * 440 * @param int $user_id The ID of the user. 441 * @param string|bool $role The WP role being assigned to the user 442 * ('subscriber', 'contributor', 'author', 'editor', 'administrator', or 443 * a custom role). Defaults to false. 444 * @param int $blog_id Default: the current blog ID. 445 * @return bool|null False on failure. 446 */ 394 447 function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = 0 ) { 395 448 global $wpdb; … … 417 470 add_action( 'user_register', 'bp_blogs_add_user_to_blog' ); 418 471 472 /** 473 * Remove a blog-user pair from BP's blog tracker. 474 * 475 * @param int $user_id ID of the user whose blog is being removed. 476 * @param int $blog_id Optional. ID of the blog being removed. Default: current blog ID. 477 */ 419 478 function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) { 420 479 global $wpdb; … … 428 487 429 488 /** 430 * Rehooks WP's maybe_add_existing_user_to_blog with a later priority 431 * 432 * WordPress catches add-user-to-blog requests at init:10. In some cases, this can precede BP's 433 * Blogs component. This function bumps the priority of the core function, so that we can be sure 434 * that the Blogs component is loaded first. See http://buddypress.trac.wordpress.org/ticket/3916 489 * Rehook WP's maybe_add_existing_user_to_blog with a later priority 490 * 491 * WordPress catches add-user-to-blog requests at init:10. In some cases, this 492 * can precede BP's Blogs component. This function bumps the priority of the 493 * core function, so that we can be sure that the Blogs component is loaded 494 * first. See http://buddypress.trac.wordpress.org/ticket/3916. 435 495 * 436 496 * @since BuddyPress (1.6) 497 * @access private 437 498 */ 438 499 function bp_blogs_maybe_add_user_to_blog() { … … 445 506 add_action( 'init', 'bp_blogs_maybe_add_user_to_blog', 1 ); 446 507 508 /** 509 * Remove the "blog created" item from the BP blogs tracker and activity stream. 510 * 511 * @param int $blog_id ID of the blog being removed. 512 */ 447 513 function bp_blogs_remove_blog( $blog_id ) { 448 514 global $bp; … … 460 526 add_action( 'delete_blog', 'bp_blogs_remove_blog' ); 461 527 528 /** 529 * Remove a blog from the tracker for a specific user. 530 * 531 * @param int $user_id ID of the user for whom the blog is being removed. 532 * @param int $blog_id ID of the blog being removed. 533 */ 462 534 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 463 535 global $bp; … … 481 553 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 ); 482 554 555 /** 556 * Remove a blog post activity item from the activity stream. 557 * 558 * @param int $post_id ID of the post to be removed. 559 * @param int $blog_id Optional. Defaults to current blog ID. 560 * @param int $user_id Optional. Defaults to the logged-in user ID. This param 561 * is currently unused in the function (but is passed to hooks). 562 */ 483 563 function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) { 484 564 global $wpdb, $bp; … … 504 584 add_action( 'delete_post', 'bp_blogs_remove_post' ); 505 585 586 /** 587 * Remove a blog comment activity item from the activity stream. 588 * 589 * @param int $comment_id ID of the comment to be removed. 590 */ 506 591 function bp_blogs_remove_comment( $comment_id ) { 507 592 global $wpdb; … … 517 602 * When a blog comment status transition occurs, update the relevant activity's status. 518 603 * 519 * @global object $bp BuddyPress global settings 604 * @since BuddyPress (1.6) 605 * 606 * @global object $bp BuddyPress global settings. 607 * 520 608 * @param string $new_status New comment status. 521 609 * @param string $old_status Previous comment status. 522 610 * @param object $comment Comment data. 523 * @since BuddyPress (1.6)524 611 */ 525 612 function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) { … … 586 673 add_action( 'transition_comment_status', 'bp_blogs_transition_activity_status', 10, 3 ); 587 674 675 /** 676 * Get the total number of blogs being tracked by BuddyPress. 677 * 678 * @return int $count Total blog count. 679 */ 588 680 function bp_blogs_total_blogs() { 589 681 if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) { … … 595 687 } 596 688 689 /** 690 * Get the total number of blogs being tracked by BP for a specific user. 691 * 692 * @param int $user_id ID of the user being queried. Default: on a user page, 693 * the displayed user. Otherwise, the logged-in user. 694 * @return int $count Total blog count for the user. 695 */ 597 696 function bp_blogs_total_blogs_for_user( $user_id = 0 ) { 598 697 … … 608 707 } 609 708 709 /** 710 * Remove the all data related to a given blog from the BP blogs tracker and activity stream. 711 * 712 * @param int $blog_id The ID of the blog to expunge. 713 */ 610 714 function bp_blogs_remove_data_for_blog( $blog_id ) { 611 715 global $bp; … … 623 727 add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 ); 624 728 729 /** 730 * Get all of a user's blogs, as tracked by BuddyPress. 731 * 732 * @see BP_Blogs_Blog::get_blogs_for_user() for a description of parameters 733 * and return values. 734 * 735 * @param int $user_id See {@BP_Blogs_Blog::get_blogs_for_user()}. 736 * @param bool $show_hidden See {@BP_Blogs_Blog::get_blogs_for_user()}. 737 * @return array See {@BP_Blogs_Blog::get_blogs_for_user()}. 738 */ 625 739 function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) { 626 740 return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden ); 627 741 } 628 742 743 /** 744 * Retrieve a list of all blogs. 745 * 746 * @see BP_Blogs_Blog::get_all() for a description of parameters and return values. 747 * 748 * @param int $limit See {@BP_Blogs_Blog::get_all()}. 749 * @param int $page See {@BP_Blogs_Blog::get_all()}. 750 * @return array See {@BP_Blogs_Blog::get_all()}. 751 */ 629 752 function bp_blogs_get_all_blogs( $limit = null, $page = null ) { 630 753 return BP_Blogs_Blog::get_all( $limit, $page ); 631 754 } 632 755 756 /** 757 * Retrieve a random list of blogs. 758 * 759 * @see BP_Blogs_Blog::get() for a description of parameters and return values. 760 * 761 * @param int $limit See {@BP_Blogs_Blog::get()}. 762 * @param int $page See {@BP_Blogs_Blog::get()}. 763 * @return array See {@BP_Blogs_Blog::get()}. 764 */ 633 765 function bp_blogs_get_random_blogs( $limit = null, $page = null ) { 634 766 return BP_Blogs_Blog::get( 'random', $limit, $page ); 635 767 } 636 768 769 /** 770 * Check whether a given blog is hidden. 771 * 772 * @see BP_Blogs_Blog::is_hidden() for a description of parameters and return values. 773 * 774 * @param int $blog_id See {@BP_Blogs_Blog::is_hidden()}. 775 * @return bool See {@BP_Blogs_Blog::is_hidden()}. 776 */ 637 777 function bp_blogs_is_blog_hidden( $blog_id ) { 638 778 return BP_Blogs_Blog::is_hidden( $blog_id ); … … 648 788 */ 649 789 790 /** 791 * Delete a metadta from the DB for a blog. 792 * 793 * @global object $wpdb WordPress database access object. 794 * @global object $bp BuddyPress global settings. 795 * 796 * @param int $blog_id ID of the blog whose metadata is being deleted. 797 * @param string $meta_key Optional. The key of the metadata being deleted. If 798 * omitted, all BP metadata associated with the blog will be deleted. 799 * @param string $meta_value Optional. If present, the metadata will only be 800 * deleted if the meta_value matches this parameter. 801 * @return bool True on success, false on failure. 802 */ 650 803 function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) { 651 804 global $wpdb, $bp; … … 673 826 } 674 827 828 /** 829 * Get metadata for a given blog. 830 * 831 * @since BuddyPress (1.2) 832 * 833 * @global object $wpdb WordPress database access object. 834 * @global object $bp BuddyPress global settings. 835 * 836 * @param int $blog_id ID of the blog whose metadata is being requested. 837 * @param string $meta_key Optional. If present, only the metadata matching 838 * that meta key will be returned. Otherwise, all metadata for the 839 * blog will be fetched. 840 * @return mixed The meta value(s) being requested. 841 */ 675 842 function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') { 676 843 global $wpdb, $bp; … … 707 874 } 708 875 876 /** 877 * Update a piece of blog meta. 878 * 879 * @global object $wpdb WordPress database access object. 880 * @global object $bp BuddyPress global settings. 881 * 882 * @param int $blog_id ID of the blog whose metadata is being updated. 883 * @param string $meta_key Key of the metadata being updated. 884 * @param mixed $meta_value Value to be set. 885 * @return bool True on success, false on failure. 886 */ 709 887 function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) { 710 888 global $wpdb, $bp; … … 737 915 } 738 916 917 /** 918 * Remove all blog associations for a given user. 919 * 920 * @param int $user_id ID whose blog data should be removed. 921 * @return bool|null Returns false on failure. 922 */ 739 923 function bp_blogs_remove_data( $user_id ) { 740 924 if ( !is_multisite() )
Note: See TracChangeset
for help on using the changeset viewer.