Changeset 10374
- Timestamp:
- 11/23/2015 03:55:00 AM (9 years ago)
- Location:
- trunk/src/bp-blogs
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-actions.php
r10100 r10374 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 17 17 function bp_blogs_redirect_to_random_blog() { 18 18 19 // Bail if not looking for a random blog 19 // Bail if not looking for a random blog. 20 20 if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) ) 21 21 return; 22 22 23 // Multisite is active so find a random blog 23 // Multisite is active so find a random blog. 24 24 if ( is_multisite() ) { 25 25 $blog = bp_blogs_get_random_blogs( 1, 1 ); 26 26 bp_core_redirect( get_home_url( $blog['blogs'][0]->blog_id ) ); 27 27 28 // No multisite and still called, always redirect to root 28 // No multisite and still called, always redirect to root. 29 29 } else { 30 30 bp_core_redirect( bp_core_get_root_domain() ); -
trunk/src/bp-blogs/bp-blogs-activity.php
r10253 r10374 20 20 $bp = buddypress(); 21 21 22 // Bail if activity is not active 22 // Bail if activity is not active. 23 23 if ( ! bp_is_active( 'activity' ) ) { 24 24 return false; … … 37 37 } 38 38 39 // Only add the comment type if the 'post' post type is trackable 39 // Only add the comment type if the 'post' post type is trackable. 40 40 if ( post_type_supports( 'post', 'buddypress-activity' ) ) { 41 41 bp_activity_set_action( … … 66 66 * @param string $action Static activity action. 67 67 * @param object $activity Activity data object. 68 *69 68 * @return string 70 69 */ … … 75 74 $action = sprintf( __( '%s created the site %s', 'buddypress' ), bp_core_get_userlink( $activity->user_id ), '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' ); 76 75 77 // Legacy filter - requires the BP_Blogs_Blog object 76 // Legacy filter - requires the BP_Blogs_Blog object. 78 77 if ( has_filter( 'bp_blogs_activity_created_blog_action' ) ) { 79 78 $user_blog = BP_Blogs_Blog::get_user_blog( $activity->user_id, $activity->item_id ); … … 105 104 * @param string $action Static activity action. 106 105 * @param object $activity Activity data object. 107 *108 106 * @return string Constructed activity action. 109 107 */ … … 141 139 } 142 140 143 // Should be the case when the post has just been published 141 // Should be the case when the post has just been published. 144 142 if ( isset( $activity->post_title ) ) { 145 143 $post_title = $activity->post_title; 146 144 147 // If activity already exists try to get the post title from activity meta 145 // If activity already exists try to get the post title from activity meta. 148 146 } else if ( ! empty( $activity->id ) ) { 149 147 $post_title = bp_activity_get_meta( $activity->id, 'post_title' ); … … 152 150 /** 153 151 * In case the post was published without a title 154 * or the activity meta was not found 152 * or the activity meta was not found. 155 153 */ 156 154 if ( empty( $post_title ) ) { 157 // Defaults to no title 155 // Defaults to no title. 158 156 $post_title = esc_html__( '(no title)', 'buddypress' ); 159 157 … … 167 165 } 168 166 169 // Make sure the activity exists before saving the post title in activity meta 167 // Make sure the activity exists before saving the post title in activity meta. 170 168 if ( ! empty( $activity->id ) ) { 171 169 bp_activity_update_meta( $activity->id, 'post_title', $post_title ); … … 176 174 } 177 175 178 // Build the 'post link' part of the activity action string 176 // Build the 'post link' part of the activity action string. 179 177 $post_link = '<a href="' . esc_url( $post_url ) . '">' . $post_title . '</a>'; 180 178 181 179 $user_link = bp_core_get_userlink( $activity->user_id ); 182 180 183 // Build the complete activity action string 181 // Build the complete activity action string. 184 182 if ( is_multisite() ) { 185 183 $action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), $user_link, $post_link, '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' ); … … 188 186 } 189 187 190 // Legacy filter - requires the post object 188 // Legacy filter - requires the post object. 191 189 if ( has_filter( 'bp_blogs_activity_new_post_action' ) ) { 192 190 switch_to_blog( $activity->item_id ); … … 217 215 * @param string $action Static activity action. 218 216 * @param object $activity Activity data object. 219 *220 217 * @return string Constructed activity action. 221 218 */ … … 235 232 $post_title = bp_activity_get_meta( $activity->id, 'post_title' ); 236 233 237 // Should only be empty at the time of post creation 234 // Should only be empty at the time of post creation. 238 235 if ( empty( $post_url ) || empty( $post_title ) ) { 239 236 switch_to_blog( $activity->item_id ); … … 265 262 } 266 263 267 // Legacy filter - requires the comment object 264 // Legacy filter - requires the comment object. 268 265 if ( has_filter( 'bp_blogs_activity_new_comment_action' ) ) { 269 266 switch_to_blog( $activity->item_id ); … … 295 292 * 296 293 * @param array $activities Array of activity items. 297 *298 294 * @return array 299 295 */ … … 338 334 function bp_blogs_record_activity( $args = '' ) { 339 335 340 // Bail if activity is not active 336 // Bail if activity is not active. 341 337 if ( ! bp_is_active( 'activity' ) ) { 342 338 return false; … … 415 411 function bp_blogs_delete_activity( $args = '' ) { 416 412 417 // Bail if activity is not active 413 // Bail if activity is not active. 418 414 if ( ! bp_is_active( 'activity' ) ) { 419 415 return false; … … 444 440 * @since 2.0.0 445 441 * 446 * @param object $activity The BP_Activity_Activity object 447 * 442 * @param object $activity The BP_Activity_Activity object. 448 443 * @return bool 449 444 */ … … 453 448 $blog_id = $activity->item_id; 454 449 455 // see if we've mirrored the close comments option before450 // See if we've mirrored the close comments option before. 456 451 $days_old = bp_blogs_get_blogmeta( $blog_id, 'close_comments_days_old' ); 457 452 458 // we've never cached these items before, so do it now453 // We've never cached these items before, so do it now. 459 454 if ( '' === $days_old ) { 460 455 switch_to_blog( $blog_id ); 461 456 462 // use comments_open()457 // Use comments_open(). 463 458 remove_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 464 459 $open = comments_open( $activity->secondary_item_id ); 465 460 add_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 466 461 467 // might as well mirror values to blogmeta since we're here!462 // Might as well mirror values to blogmeta since we're here! 468 463 $thread_depth = get_option( 'thread_comments' ); 469 464 if ( ! empty( $thread_depth ) ) { 470 465 $thread_depth = get_option( 'thread_comments_depth' ); 471 466 } else { 472 // perhaps filter this?467 // Perhaps filter this? 473 468 $thread_depth = 1; 474 469 } … … 480 475 restore_current_blog(); 481 476 482 // check blogmeta and manually check activity item483 // basically a copy of _close_comments_for_old_post()477 // Check blogmeta and manually check activity item. 478 // Basically a copy of _close_comments_for_old_post(). 484 479 } else { 485 480 486 // comments are closed481 // Comments are closed. 487 482 if ( 'closed' == bp_activity_get_meta( $activity->id, 'post_comment_status' ) ) { 488 483 return false; … … 498 493 } 499 494 500 /* commenting out for now - needs some more thought... 495 /* 496 Commenting out for now - needs some more thought... 501 497 should we add the post type to activity meta? 502 498 … … 535 531 */ 536 532 function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) { 537 // if parent activity isn't a blog post, stop now!533 // If parent activity isn't a blog post, stop now! 538 534 if ( $parent_activity->type != 'new_blog_post' ) { 539 535 return; 540 536 } 541 537 542 // if activity comments are disabled for blog posts, stop now!538 // If activity comments are disabled for blog posts, stop now! 543 539 if ( bp_disable_blogforum_comments() ) { 544 540 return; 545 541 } 546 542 547 // get userdata543 // Get userdata. 548 544 if ( $params['user_id'] == bp_loggedin_user_id() ) { 549 545 $user = buddypress()->loggedin_user->userdata; … … 552 548 } 553 549 554 // see if a parent WP comment ID exists550 // See if a parent WP comment ID exists. 555 551 if ( ! empty( $params['parent_id'] ) ) { 556 552 $comment_parent = bp_activity_get_meta( $params['parent_id'], 'bp_blogs_post_comment_id' ); … … 559 555 } 560 556 561 // comment args557 // Comment args. 562 558 $args = array( 563 559 'comment_post_ID' => $parent_activity->secondary_item_id, … … 566 562 'comment_author_url' => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ), 567 563 'comment_content' => $params['content'], 568 'comment_type' => '', // could be interesting to add 'buddypress' here...564 'comment_type' => '', // Could be interesting to add 'buddypress' here... 569 565 'comment_parent' => (int) $comment_parent, 570 566 'user_id' => $params['user_id'], 571 567 572 // commenting these out for now 573 //'comment_author_IP' => '127.0.0.1', 574 //'comment_agent' => '', 575 568 // Commenting these out for now 569 // 'comment_author_IP' => '127.0.0.1', 570 // 'comment_agent' => '', . 576 571 'comment_approved' => 1 577 572 ); 578 573 579 // prevent separate activity entry being made574 // Prevent separate activity entry being made. 580 575 remove_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 581 576 582 // handle multisite577 // Handle multisite. 583 578 switch_to_blog( $parent_activity->item_id ); 584 579 585 // handle timestamps for the WP comment after we've switched to the blog580 // Handle timestamps for the WP comment after we've switched to the blog. 586 581 $args['comment_date'] = current_time( 'mysql' ); 587 582 $args['comment_date_gmt'] = current_time( 'mysql', 1 ); 588 583 589 // post the comment584 // Post the comment. 590 585 $post_comment_id = wp_insert_comment( $args ); 591 586 592 // add meta to comment587 // Add meta to comment. 593 588 add_comment_meta( $post_comment_id, 'bp_activity_comment_id', $comment_id ); 594 589 595 // add meta to activity comment590 // Add meta to activity comment. 596 591 bp_activity_update_meta( $comment_id, 'bp_blogs_post_comment_id', $post_comment_id ); 597 592 598 // resave activity comment with WP comment permalink593 // Resave activity comment with WP comment permalink. 599 594 // 600 595 // in bp_blogs_activity_comment_permalink(), we change activity comment … … 602 597 // 603 598 // @todo since this is done after AJAX posting, the activity comment permalink 604 // 599 // doesn't change on the frontend until the next page refresh. 605 600 $resave_activity = new BP_Activity_Activity( $comment_id ); 606 601 $resave_activity->primary_link = get_comment_link( $post_comment_id ); … … 614 609 $resave_activity->save(); 615 610 616 // add the edit activity comment hook back611 // Add the edit activity comment hook back. 617 612 add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 ); 618 613 619 // multisite again!614 // Multisite again! 620 615 restore_current_blog(); 621 616 622 // add the comment hook back617 // Add the comment hook back. 623 618 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 624 619 … … 646 641 * @since 2.0.0 647 642 * 648 * @param bool $retval 643 * @param bool $retval Whether BuddyPress should continue or not. 649 644 * @param int $parent_activity_id The parent activity ID for the activity comment. 650 645 * @param int $activity_id The activity ID for the pending deleted activity comment. 651 *652 646 * @return bool 653 647 */ 654 648 function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_id, $activity_id ) { 655 // check if parent activity is a blog post649 // Check if parent activity is a blog post. 656 650 $parent_activity = new BP_Activity_Activity( $parent_activity_id ); 657 651 if ( 'new_blog_post' != $parent_activity->type ) { … … 659 653 } 660 654 661 // fetch the activity comments for the activity item655 // Fetch the activity comments for the activity item. 662 656 $activity = bp_activity_get( array( 663 657 'in' => $activity_id, … … 665 659 ) ); 666 660 667 // get all activity comment IDs for the pending deleted item661 // Get all activity comment IDs for the pending deleted item. 668 662 $activity_ids = bp_activity_recurse_comments_activity_ids( $activity ); 669 663 $activity_ids[] = $activity_id; 670 664 671 // handle multisite672 // switch to the blog where the comment was made 665 // Handle multisite 666 // switch to the blog where the comment was made. 673 667 switch_to_blog( $parent_activity->item_id ); 674 668 675 // remove associated blog comments669 // Remove associated blog comments. 676 670 bp_blogs_remove_associated_blog_comments( $activity_ids, current_user_can( 'moderate_comments' ) ); 677 671 678 // multisite again!672 // Multisite again! 679 673 restore_current_blog(); 680 674 681 // rebuild activity comment tree682 // emulate bp_activity_delete_comment() 675 // Rebuild activity comment tree 676 // emulate bp_activity_delete_comment(). 683 677 BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id ); 684 678 685 // we're overriding the default bp_activity_delete_comment() functionality686 // so we need to return false 679 // We're overriding the default bp_activity_delete_comment() functionality 680 // so we need to return false. 687 681 return false; 688 682 } … … 697 691 */ 698 692 function bp_blogs_sync_activity_edit_to_post_comment( BP_Activity_Activity $activity ) { 699 // not an activity comment? stop now!693 // Not an activity comment? stop now! 700 694 if ( 'activity_comment' !== $activity->type ) { 701 695 return; 702 696 } 703 697 704 // this is a new entry, so stop!705 // we only want edits!698 // This is a new entry, so stop! 699 // We only want edits! 706 700 if ( empty( $activity->id ) ) { 707 701 return; 708 702 } 709 703 710 // prevent recursion704 // Prevent recursion. 711 705 remove_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 ); 712 706 713 // Try to see if a corresponding blog comment exists 707 // Try to see if a corresponding blog comment exists. 714 708 $post_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' ); 715 709 … … 718 712 } 719 713 720 // fetch parent activity item714 // Fetch parent activity item. 721 715 $parent_activity = new BP_Activity_Activity( $activity->item_id ); 722 716 723 // sanity check717 // Sanity check. 724 718 if ( 'new_blog_post' !== $parent_activity->type ) { 725 719 return; 726 720 } 727 721 728 // handle multisite722 // Handle multisite. 729 723 switch_to_blog( $parent_activity->item_id ); 730 724 731 // update the blog post comment725 // Update the blog post comment. 732 726 wp_update_comment( array( 733 727 'comment_ID' => $post_comment_id, … … 783 777 * 784 778 * @param array $args Arguments passed from bp_parse_args() in bp_has_activities(). 785 *786 779 * @return array $args 787 780 */ … … 790 783 $bp = buddypress(); 791 784 792 // Bail if this is not a 'new_blog_comment' query 785 // Bail if this is not a 'new_blog_comment' query. 793 786 if ( 'new_blog_comment' !== $args['action'] ) { 794 787 return $args; … … 802 795 } 803 796 804 // Init the filter query 797 // Init the filter query. 805 798 $filter_query = array(); 806 799 … … 833 826 $args['filter_query'] = $filter_query; 834 827 835 // Make sure to have comment in stream mode && avoid duplicate content 828 // Make sure to have comment in stream mode && avoid duplicate content. 836 829 $args['display_comments'] = 'stream'; 837 830 838 // Finally reset the action 831 // Finally reset the action. 839 832 $args['action'] = ''; 840 833 841 // Return the original arguments 834 // Return the original arguments. 842 835 return $args; 843 836 } … … 864 857 } 865 858 866 // parent not a blog post? stop now!859 // Parent not a blog post? stop now! 867 860 if ( 'new_blog_post' !== $activity->type ) { 868 861 return; … … 873 866 } 874 867 875 // if we've already done this before, stop now!868 // If we've already done this before, stop now! 876 869 if ( isset( buddypress()->blogs->allow_comments[ $activity->id ] ) ) { 877 870 return; … … 881 874 $thread_depth = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' ); 882 875 883 // initialize a local object so we won't have to query this again in the884 // comment loop 876 // Initialize a local object so we won't have to query this again in the 877 // comment loop. 885 878 if ( empty( buddypress()->blogs->allow_comments ) ) { 886 879 buddypress()->blogs->allow_comments = array(); … … 890 883 } 891 884 892 // cache comment settings in the buddypress() singleton to reference later in885 // Cache comment settings in the buddypress() singleton to reference later in 893 886 // the activity comment loop 894 887 // @see bp_blogs_disable_activity_replies() … … 909 902 */ 910 903 function bp_blogs_setup_comment_loop_globals_on_ajax() { 911 // not AJAX? stop now!904 // Not AJAX? stop now! 912 905 if ( ! defined( 'DOING_AJAX' ) ) { 913 906 return; … … 917 910 } 918 911 919 // get the parent activity item912 // Get the parent activity item. 920 913 $comment = bp_activity_current_comment(); 921 914 $parent_activity = new BP_Activity_Activity( $comment->item_id ); 922 915 923 // setup the globals916 // Setup the globals. 924 917 bp_blogs_setup_activity_loop_globals( $parent_activity ); 925 918 } … … 938 931 * @since 2.0.0 939 932 * 940 * @param bool $retval Is activity commenting enabled for this activity entry? 941 * 933 * @param bool $retval Is activity commenting enabled for this activity entry. 942 934 * @return bool 943 935 */ 944 936 function bp_blogs_disable_activity_commenting( $retval ) { 945 // if activity commenting is disabled, return current value937 // If activity commenting is disabled, return current value. 946 938 if ( bp_disable_blogforum_comments() ) { 947 939 return $retval; 948 940 } 949 941 950 // activity commenting is enabled for blog posts942 // Activity commenting is enabled for blog posts. 951 943 switch ( bp_get_activity_action_name() ) { 952 944 953 // we still have to disable activity commenting for 'new_blog_comment' items954 // commenting should only be done on the parent 'new_blog_post' item 945 // We still have to disable activity commenting for 'new_blog_comment' items 946 // commenting should only be done on the parent 'new_blog_post' item. 955 947 case 'new_blog_comment' : 956 948 $retval = false; … … 958 950 break; 959 951 960 // check if commenting is disabled for the WP blog post961 // we should extrapolate this and automate this for plugins... or not 952 // Check if commenting is disabled for the WP blog post 953 // we should extrapolate this and automate this for plugins... or not. 962 954 case 'new_blog_post' : 963 955 global $activities_template; 964 956 965 // setup some globals we'll need to reference later957 // Setup some globals we'll need to reference later. 966 958 bp_blogs_setup_activity_loop_globals( $activities_template->activity ); 967 959 968 // if comments are closed for the WP blog post, we should disable969 // activity comments for this activity entry 960 // If comments are closed for the WP blog post, we should disable 961 // activity comments for this activity entry. 970 962 if ( empty( buddypress()->blogs->allow_comments[bp_get_activity_id()] ) ) { 971 963 $retval = false; … … 990 982 * @since 2.0.0 991 983 * 992 * @param bool $retval Are replies allowed for this activity reply ?984 * @param bool $retval Are replies allowed for this activity reply. 993 985 * @param object|array $comment The activity comment object. 994 986 * … … 1000 992 } 1001 993 1002 // check comment depth and disable if depth is too large994 // Check comment depth and disable if depth is too large. 1003 995 if ( isset( buddypress()->blogs->thread_depth[$comment->item_id] ) ){ 1004 996 if ( $comment->mptt_left > buddypress()->blogs->thread_depth[$comment->item_id] ) { … … 1007 999 } 1008 1000 1009 // check if we should disable activity replies based on the parent activity1001 // Check if we should disable activity replies based on the parent activity. 1010 1002 if ( isset( buddypress()->blogs->allow_comments[$comment->item_id] ) ){ 1011 // the blog post has closed off commenting, so we should disable all activity1012 // comments under the parent 'new_blog_post' activity entry 1003 // The blog post has closed off commenting, so we should disable all activity 1004 // comments under the parent 'new_blog_post' activity entry. 1013 1005 if ( empty( buddypress()->blogs->allow_comments[$comment->item_id] ) ) { 1014 1006 $retval = false; … … 1030 1022 * 1031 1023 * @param string $retval The activity comment permalink. 1032 *1033 1024 * @return string 1034 1025 */ … … 1036 1027 global $activities_template; 1037 1028 1038 // Get the current comment ID 1029 // Get the current comment ID. 1039 1030 $item_id = isset( $activities_template->activity->current_comment->item_id ) 1040 1031 ? $activities_template->activity->current_comment->item_id 1041 1032 : false; 1042 1033 1043 // Maybe adjust the link if item ID exists 1034 // Maybe adjust the link if item ID exists. 1044 1035 if ( ( false !== $item_id ) && isset( buddypress()->blogs->allow_comments[ $item_id ] ) ) { 1045 1036 $retval = $activities_template->activity->current_comment->primary_link; … … 1058 1049 * 1059 1050 * @param string $retval The activity permalink. 1060 * @param BP_Activity_Activity $activity 1061 * 1051 * @param BP_Activity_Activity $activity Activity object. 1062 1052 * @return string 1063 1053 */ … … 1085 1075 * 1086 1076 * @param string $retval The activity action. 1087 * @param BP_Activity_Activity $activity 1088 * 1077 * @param BP_Activity_Activity $activity Activity object. 1089 1078 * @return string 1090 1079 */ … … 1097 1086 1098 1087 if ( ! empty( $blog_comment_id ) ) { 1099 // fetch the parent blog post activity item1088 // Fetch the parent blog post activity item. 1100 1089 $parent_blog_post_activity = new BP_Activity_Activity( $activity->item_id ); 1101 1090 1102 // fake a 'new_blog_comment' activity object1091 // Fake a 'new_blog_comment' activity object. 1103 1092 $object = $activity; 1104 1093 1105 // override 'item_id' to use blog ID1094 // Override 'item_id' to use blog ID. 1106 1095 $object->item_id = $parent_blog_post_activity->item_id; 1107 1096 1108 // override 'secondary_item_id' to use comment ID1097 // Override 'secondary_item_id' to use comment ID. 1109 1098 $object->secondary_item_id = $blog_comment_id; 1110 1099 1111 // now format the activity action using the 'new_blog_comment' action callback1100 // Now format the activity action using the 'new_blog_comment' action callback. 1112 1101 $retval = bp_blogs_format_activity_action_new_blog_comment( '', $object ); 1113 1102 } -
trunk/src/bp-blogs/bp-blogs-cache.php
r10100 r10374 25 25 function bp_blogs_update_meta_cache( $blog_ids = false ) { 26 26 $cache_args = array( 27 'object_ids' 28 'object_type' 29 'object_column' 30 'cache_group' 31 'meta_table' 27 'object_ids' => $blog_ids, 28 'object_type' => buddypress()->blogs->id, 29 'object_column' => 'blog_id', 30 'cache_group' => 'blog_meta', 31 'meta_table' => buddypress()->blogs->table_name_blogmeta, 32 32 ); 33 33 -
trunk/src/bp-blogs/bp-blogs-filters.php
r10100 r10374 30 30 * 31 31 * @param string $url The original URL (points to wp-signup.php by default). 32 *33 32 * @return string The new URL. 34 33 */ … … 54 53 * 55 54 * @param array $retval Current SQL clauses in array format. 56 *57 55 * @return array 58 56 */ … … 70 68 * @since 2.2.0 71 69 * 72 * @param bool $return Whether the post should be published. 73 * @param int $blog_id ID of the blog. 74 * @param int $post_id ID of the post. 75 * @param int $user_id ID of the post author. 76 * 70 * @param bool $return Whether the post should be published. 71 * @param int $blog_id ID of the blog. 72 * @param int $post_id ID of the post. 73 * @param int $user_id ID of the post author. 77 74 * @return bool True to authorize the post to be published, otherwise false. 78 75 */ -
trunk/src/bp-blogs/bp-blogs-functions.php
r10277 r10374 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 43 43 function bp_blogs_get_blogs( $args = '' ) { 44 44 45 // Parse query arguments 45 // Parse query arguments. 46 46 $r = bp_parse_args( $args, array( 47 47 'type' => 'active', // 'active', 'alphabetical', 'newest', or 'random' … … 54 54 ), 'blogs_get_blogs' ); 55 55 56 // Get the blogs 56 // Get the blogs. 57 57 $blogs = BP_Blogs_Blog::get( 58 58 $r['type'], … … 65 65 ); 66 66 67 // Filter and return 67 // Filter and return. 68 68 return apply_filters( 'bp_blogs_get_blogs', $blogs, $r ); 69 69 } … … 83 83 global $wpdb; 84 84 85 // Query for all sites in network 85 // Query for all sites in network. 86 86 if ( is_multisite() ) { 87 87 88 // Get blog ID's if not a large network 88 // Get blog ID's if not a large network. 89 89 if ( ! wp_is_large_network() ) { 90 90 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $wpdb->siteid ) ); 91 91 92 // If error running this query, set blog ID's to false 92 // If error running this query, set blog ID's to false. 93 93 if ( is_wp_error( $blog_ids ) ) { 94 94 $blog_ids = false; 95 95 } 96 96 97 // Large networks are not currently supported 97 // Large networks are not currently supported. 98 98 } else { 99 99 $blog_ids = false; 100 100 } 101 101 102 // Record a single site 102 // Record a single site. 103 103 } else { 104 104 $blog_ids = $wpdb->blogid; 105 105 } 106 106 107 // Bail if there are no blogs in the network 107 // Bail if there are no blogs in the network. 108 108 if ( empty( $blog_ids ) ) { 109 109 return false; 110 110 } 111 111 112 // Get BuddyPress 112 // Get BuddyPress. 113 113 $bp = buddypress(); 114 114 115 // Truncate user blogs table 115 // Truncate user blogs table. 116 116 $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" ); 117 117 if ( is_wp_error( $truncate ) ) { … … 119 119 } 120 120 121 // Truncate user blogsmeta table 121 // Truncate user blogsmeta table. 122 122 $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" ); 123 123 if ( is_wp_error( $truncate ) ) { … … 125 125 } 126 126 127 // Loop through users of blogs and record the relationship 127 // Loop through users of blogs and record the relationship. 128 128 foreach ( (array) $blog_ids as $blog_id ) { 129 129 130 // Ensure that the cache is clear after the table TRUNCATE above 130 // Ensure that the cache is clear after the table TRUNCATE above. 131 131 wp_cache_delete( $blog_id, 'blog_meta' ); 132 132 133 // Get all users 133 // Get all users. 134 134 $users = get_users( array( 135 135 'blog_id' => $blog_id 136 136 ) ); 137 137 138 // Continue on if no users exist for this site (how did this happen?) 138 // Continue on if no users exist for this site (how did this happen?). 139 139 if ( empty( $users ) ) { 140 140 continue; 141 141 } 142 142 143 // Loop through users and record their relationship to this blog 143 // Loop through users and record their relationship to this blog. 144 144 foreach ( (array) $users as $user ) { 145 145 bp_blogs_add_user_to_blog( $user->ID, false, $blog_id ); … … 154 154 do_action( 'bp_blogs_recorded_existing_blogs' ); 155 155 156 // No errors 156 // No errors. 157 157 return true; 158 158 } … … 170 170 * @param int $blog_id ID of the blog being checked. 171 171 * @param int $user_id Optional. ID of the user for whom access is being checked. 172 *173 172 * @return bool True if blog is recordable, otherwise false. 174 173 */ … … 203 202 * @param int $blog_id ID of the blog being checked. 204 203 * @param int $user_id Optional. ID of the user for whom access is being checked. 205 *206 204 * @return bool True if blog is trackable, otherwise false. 207 205 */ … … 234 232 * @param bool $no_activity Optional. Whether to skip recording an activity 235 233 * item about this blog creation. Default: false. 236 *237 234 * @return bool|null Returns false on failure. 238 235 */ … … 261 258 $thread_depth = get_blog_option( $blog_id, 'thread_comments_depth' ); 262 259 } else { 263 // perhaps filter this?260 // Perhaps filter this? 264 261 $thread_depth = 1; 265 262 } … … 282 279 $is_private = !apply_filters( 'bp_is_new_blog_public', !$is_private ); 283 280 284 // Only record this activity if the blog is public 281 // Only record this activity if the blog is public. 285 282 if ( !$is_private && !$no_activity && bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) { 286 283 287 // Record this in activity streams 284 // Record this in activity streams. 288 285 bp_blogs_record_activity( array( 289 286 'user_id' => $recorded_blog->user_id, … … 565 562 * @param bool|string $is_approved Optional. The $is_approved value passed to 566 563 * the 'comment_post' action. Default: true. 567 *568 564 * @return bool|object Returns false on failure, the comment object on success. 569 565 */ 570 566 function bp_blogs_record_comment( $comment_id, $is_approved = true ) { 571 // bail if activity component is not active567 // Bail if activity component is not active. 572 568 if ( ! bp_is_active( 'activity' ) ) { 573 569 return; 574 570 } 575 571 576 // Get the users comment 572 // Get the users comment. 577 573 $recorded_comment = get_comment( $comment_id ); 578 574 579 // Don't record activity if the comment hasn't been approved 575 // Don't record activity if the comment hasn't been approved. 580 576 if ( empty( $is_approved ) ) 581 577 return false; 582 578 583 // Don't record activity if no email address has been included 579 // Don't record activity if no email address has been included. 584 580 if ( empty( $recorded_comment->comment_author_email ) ) 585 581 return false; 586 582 587 // Don't record activity if the comment has already been marked as spam 583 // Don't record activity if the comment has already been marked as spam. 588 584 if ( 'spam' === $is_approved ) 589 585 return false; … … 592 588 $user = get_user_by( 'email', $recorded_comment->comment_author_email ); 593 589 594 // If user isn't registered, don't record activity 590 // If user isn't registered, don't record activity. 595 591 if ( empty( $user ) ) 596 592 return false; 597 593 598 // Get the user_id 594 // Get the user_id. 599 595 $user_id = (int) $user->ID; 600 596 601 // Get blog and post data 597 // Get blog and post data. 602 598 $blog_id = get_current_blog_id(); 603 599 … … 611 607 return false; 612 608 613 // If this is a password protected post, don't record the comment 609 // If this is a password protected post, don't record the comment. 614 610 if ( !empty( $recorded_comment->post->post_password ) ) 615 611 return false; 616 612 617 // Don't record activity if the comment's associated post isn't a WordPress Post 613 // Don't record activity if the comment's associated post isn't a WordPress Post. 618 614 if ( !in_array( $recorded_comment->post->post_type, apply_filters( 'bp_blogs_record_comment_post_types', array( 'post' ) ) ) ) 619 615 return false; … … 621 617 $is_blog_public = apply_filters( 'bp_is_blog_public', (int)get_blog_option( $blog_id, 'blog_public' ) ); 622 618 623 // If blog is public allow activity to be posted 619 // If blog is public allow activity to be posted. 624 620 if ( $is_blog_public ) { 625 621 626 // Get activity related links 622 // Get activity related links. 627 623 $post_permalink = get_permalink( $recorded_comment->comment_post_ID ); 628 624 $comment_link = get_comment_link( $recorded_comment->comment_ID ); 629 625 630 // Setup activity args 626 // Setup activity args. 631 627 $args = array(); 632 628 … … 637 633 638 634 // Setup some different activity args depending if activity commenting is 639 // enabled or not 640 635 // enabled or not. 641 636 // if cannot comment, record separate activity entry 642 // this is the old way of doing things 637 // this is the old way of doing things. 643 638 if ( bp_disable_blogforum_comments() ) { 644 639 $args['type'] = 'new_blog_comment'; … … 646 641 $args['secondary_item_id'] = $comment_id; 647 642 648 // record the activity entry643 // Record the activity entry. 649 644 $activity_id = bp_blogs_record_activity( $args ); 650 645 651 // add some post info in activity meta646 // Add some post info in activity meta. 652 647 bp_activity_update_meta( $activity_id, 'post_title', $recorded_comment->post->post_title ); 653 648 bp_activity_update_meta( $activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) ); 654 649 655 // record comment as BP activity comment under the parent 'new_blog_post'656 // activity item 650 // Record comment as BP activity comment under the parent 'new_blog_post' 651 // activity item. 657 652 } else { 658 // this is a comment edit659 // check to see if corresponding activity entry already exists 653 // This is a comment edit 654 // check to see if corresponding activity entry already exists. 660 655 if ( ! empty( $_REQUEST['action'] ) ) { 661 656 $existing_activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true ); … … 666 661 } 667 662 668 // find the parent 'new_blog_post' activity entry663 // Find the parent 'new_blog_post' activity entry. 669 664 $parent_activity_id = bp_activity_get_activity_id( array( 670 665 'component' => 'blogs', … … 674 669 ) ); 675 670 676 // Try to create a new activity item for the parent blog post 671 // Try to create a new activity item for the parent blog post. 677 672 if ( empty( $parent_activity_id ) ) { 678 673 $parent_activity_id = bp_activity_post_type_publish( $recorded_comment->comment_post_ID, $recorded_comment->post ); 679 674 } 680 675 681 // we found the parent activity entry682 // so let's go ahead and reconfigure some activity args 676 // We found the parent activity entry 677 // so let's go ahead and reconfigure some activity args. 683 678 if ( ! empty( $parent_activity_id ) ) { 684 // set the 'item_id' with the parent activity entry ID679 // Set the 'item_id' with the parent activity entry ID. 685 680 $args['item_id'] = $parent_activity_id; 686 681 687 // now see if the WP parent comment has a BP activity ID682 // Now see if the WP parent comment has a BP activity ID. 688 683 $comment_parent = 0; 689 684 if ( ! empty( $recorded_comment->comment_parent ) ) { … … 692 687 693 688 // WP parent comment does not have a BP activity ID 694 // so set to 'new_blog_post' activity ID 689 // so set to 'new_blog_post' activity ID. 695 690 if ( empty( $comment_parent ) ) { 696 691 $comment_parent = $parent_activity_id; … … 701 696 $args['type'] = 'activity_comment'; 702 697 703 // could not find corresponding parent activity entry704 // so wipe out $args array 698 // Could not find corresponding parent activity entry 699 // so wipe out $args array. 705 700 } else { 706 701 $args = array(); 707 702 } 708 703 709 // Record in activity streams 704 // Record in activity streams. 710 705 if ( ! empty( $args ) ) { 711 706 // @todo should we use bp_activity_new_comment()? that function will also send 712 // an email to people in the activity comment thread 707 // an email to people in the activity comment thread. 713 708 // 714 // what if a site already has some comment email notification plugin setup?709 // What if a site already has some comment email notification plugin setup? 715 710 // this is why I decided to go with bp_activity_add() to avoid any conflict 716 // with existing comment email notification plugins 711 // with existing comment email notification plugins. 717 712 $comment_activity_id = bp_activity_add( $args ); 718 713 719 714 if ( empty( $args['id'] ) ) { 720 // add meta to activity comment715 // Add meta to activity comment. 721 716 bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id ); 722 717 bp_activity_update_meta( $comment_activity_id, 'post_title', $recorded_comment->post->post_title ); 723 718 bp_activity_update_meta( $comment_activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) ); 724 719 725 // add meta to comment720 // Add meta to comment. 726 721 add_comment_meta( $comment_id, 'bp_activity_comment_id', $comment_activity_id ); 727 722 } … … 729 724 } 730 725 731 // Update the blogs last active date 726 // Update the blogs last active date. 732 727 bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); 733 728 } … … 752 747 * @param string|bool $role User's WordPress role for this blog ID. 753 748 * @param int $blog_id Blog ID user is being added to. 754 *755 749 * @return bool|null False on failure. 756 750 */ … … 758 752 global $wpdb; 759 753 760 // If no blog ID was passed, use the root blog ID 754 // If no blog ID was passed, use the root blog ID. 761 755 if ( empty( $blog_id ) ) { 762 756 $blog_id = isset( $wpdb->blogid ) ? $wpdb->blogid : bp_get_root_blog_id(); 763 757 } 764 758 765 // If no role was passed, try to find the blog role 759 // If no role was passed, try to find the blog role. 766 760 if ( empty( $role ) ) { 767 761 768 // Get user capabilities 762 // Get user capabilities. 769 763 $key = $wpdb->get_blog_prefix( $blog_id ). 'capabilities'; 770 764 $user_roles = array_keys( (array) bp_get_user_meta( $user_id, $key, true ) ); 771 765 772 // User has roles so lets 766 // User has roles so lets. 773 767 if ( ! empty( $user_roles ) ) { 774 768 775 // Get blog roles 769 // Get blog roles. 776 770 $blog_roles = array_keys( bp_get_current_blog_roles() ); 777 771 778 // Look for blog only roles of the user 772 // Look for blog only roles of the user. 779 773 $intersect_roles = array_intersect( $user_roles, $blog_roles ); 780 774 … … 789 783 } 790 784 791 // Bail if no role was found or role is not in the allowed roles array 785 // Bail if no role was found or role is not in the allowed roles array. 792 786 if ( empty( $role ) || ! in_array( $role, bp_blogs_get_allowed_roles() ) ) { 793 787 return false; 794 788 } 795 789 796 // Record the blog activity for this user being added to this blog 790 // Record the blog activity for this user being added to this blog. 797 791 bp_blogs_record_blog( $blog_id, $user_id, true ); 798 792 } … … 873 867 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 874 868 875 // Delete activity stream item 869 // Delete activity stream item. 876 870 bp_blogs_delete_activity( array( 877 871 'item_id' => $blog_id, … … 915 909 BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id ); 916 910 917 // Delete activity stream item 911 // Delete activity stream item. 918 912 bp_blogs_delete_activity( array( 919 913 'item_id' => $blog_id, … … 941 935 * @param int $user_id Optional. Defaults to the logged-in user ID. This param 942 936 * is currently unused in the function (but is passed to hooks). 943 *944 937 * @return bool 945 938 */ … … 969 962 do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id ); 970 963 971 // Delete activity stream item 964 // Delete activity stream item. 972 965 bp_blogs_delete_activity( array( 973 966 'item_id' => $blog_id, … … 998 991 global $wpdb; 999 992 1000 // activity comments are disabled for blog posts1001 // which means that individual activity items exist for blog comments 993 // Activity comments are disabled for blog posts 994 // which means that individual activity items exist for blog comments. 1002 995 if ( bp_disable_blogforum_comments() ) { 1003 // Delete the individual activity stream item 996 // Delete the individual activity stream item. 1004 997 bp_blogs_delete_activity( array( 1005 998 'item_id' => $wpdb->blogid, … … 1008 1001 ) ); 1009 1002 1010 // activity comments are enabled for blog posts1011 // remove the associated activity item 1003 // Activity comments are enabled for blog posts 1004 // remove the associated activity item. 1012 1005 } else { 1013 // get associated activity ID from comment meta1006 // Get associated activity ID from comment meta. 1014 1007 $activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true ); 1015 1008 1016 // delete the associated activity comment1009 // Delete the associated activity comment. 1017 1010 // 1018 // also removes child post comments and associated activity comments1011 // Also removes child post comments and associated activity comments. 1019 1012 if ( ! empty( $activity_id ) && bp_is_active( 'activity' ) ) { 1020 // fetch the activity comments for the activity item1013 // Fetch the activity comments for the activity item. 1021 1014 $activity = bp_activity_get( array( 1022 1015 'in' => $activity_id, … … 1025 1018 ) ); 1026 1019 1027 // get all activity comment IDs for the pending deleted item1020 // Get all activity comment IDs for the pending deleted item. 1028 1021 if ( ! empty( $activity['activities'] ) ) { 1029 1022 $activity_ids = bp_activity_recurse_comments_activity_ids( $activity ); 1030 1023 $activity_ids[] = $activity_id; 1031 1024 1032 // delete activity items1025 // Delete activity items. 1033 1026 foreach ( $activity_ids as $activity_id ) { 1034 1027 bp_activity_delete( array( … … 1037 1030 } 1038 1031 1039 // remove associated blog comments1032 // Remove associated blog comments. 1040 1033 bp_blogs_remove_associated_blog_comments( $activity_ids ); 1041 1034 1042 // rebuild activity comment tree1035 // Rebuild activity comment tree. 1043 1036 BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id ); 1044 1037 } … … 1069 1062 * @param array $activity_ids The activity IDs to check association with blog 1070 1063 * comments. 1071 * @param bool $force_delete Whether to force delete the comments. If false,1064 * @param bool $force_delete Whether to force delete the comments. If false, 1072 1065 * comments are trashed instead. 1073 1066 */ 1074 1067 function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $force_delete = true ) { 1075 // query args1068 // Query args. 1076 1069 $query_args = array( 1077 1070 'meta_query' => array( … … 1084 1077 ); 1085 1078 1086 // get comment1079 // Get comment. 1087 1080 $comment_query = new WP_Comment_Query; 1088 1081 $comments = $comment_query->query( $query_args ); 1089 1082 1090 // found the corresponding comments1083 // Found the corresponding comments 1091 1084 // let's delete them! 1092 1085 foreach ( $comments as $comment ) { 1093 1086 wp_delete_comment( $comment->comment_ID, $force_delete ); 1094 1087 1095 // if we're trashing the comment, remove the meta key as well1088 // If we're trashing the comment, remove the meta key as well. 1096 1089 if ( empty( $force_delete ) ) { 1097 1090 delete_comment_meta( $comment->comment_ID, 'bp_activity_comment_id' ); … … 1111 1104 function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) { 1112 1105 1113 // Check the Activity component is active 1106 // Check the Activity component is active. 1114 1107 if ( ! bp_is_active( 'activity' ) ) 1115 1108 return; … … 1136 1129 } 1137 1130 1138 // Get the activity 1131 // Get the activity. 1139 1132 if ( bp_disable_blogforum_comments() ) { 1140 1133 $activity_id = bp_activity_get_activity_id( array( … … 1148 1141 } 1149 1142 1150 // Check activity item exists 1143 // Check activity item exists. 1151 1144 if ( empty( $activity_id ) ) { 1152 1145 // If no activity exists, but the comment has been approved, record it into the activity table. … … 1158 1151 } 1159 1152 1160 // Create an activity object 1153 // Create an activity object. 1161 1154 $activity = new BP_Activity_Activity( $activity_id ); 1162 1155 if ( empty( $activity->component ) ) 1163 1156 return; 1164 1157 1165 // Spam/ham the activity if it's not already in that state 1158 // Spam/ham the activity if it's not already in that state. 1166 1159 if ( 'spam_activity' == $action && ! $activity->is_spam ) { 1167 1160 bp_activity_mark_as_spam( $activity ); … … 1170 1163 } 1171 1164 1172 // Add "new_blog_comment" to the whitelisted activity types, so that the activity's Akismet history is generated 1165 // Add "new_blog_comment" to the whitelisted activity types, so that the activity's Akismet history is generated. 1173 1166 $comment_akismet_history = create_function( '$t', '$t[] = "new_blog_comment"; return $t;' ); 1174 1167 add_filter( 'bp_akismet_get_activity_types', $comment_akismet_history ); 1175 1168 1176 // Save the updated activity 1169 // Save the updated activity. 1177 1170 $activity->save(); 1178 1171 1179 // Remove the "new_blog_comment" activity type whitelist so we don't break anything 1172 // Remove the "new_blog_comment" activity type whitelist so we don't break anything. 1180 1173 remove_filter( 'bp_akismet_get_activity_types', $comment_akismet_history ); 1181 1174 } … … 1205 1198 * @param int $user_id ID of the user being queried. Default: on a user page, 1206 1199 * the displayed user. Otherwise, the logged-in user. 1207 *1208 1200 * @return int $count Total blog count for the user. 1209 1201 */ … … 1213 1205 } 1214 1206 1215 // no user ID? do not attempt to look at cache1207 // No user ID? do not attempt to look at cache. 1216 1208 if ( empty( $user_id ) ) { 1217 1209 return 0; … … 1247 1239 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 1248 1240 1249 // Delete activity stream item 1241 // Delete activity stream item. 1250 1242 bp_blogs_delete_activity( array( 1251 1243 'item_id' => $blog_id, … … 1274 1266 * @param int $user_id See {@BP_Blogs_Blog::get_blogs_for_user()}. 1275 1267 * @param bool $show_hidden See {@BP_Blogs_Blog::get_blogs_for_user()}. 1276 *1277 1268 * @return array See {@BP_Blogs_Blog::get_blogs_for_user()}. 1278 1269 */ … … 1288 1279 * @param int $limit See {@BP_Blogs_Blog::get_all()}. 1289 1280 * @param int $page See {@BP_Blogs_Blog::get_all()}. 1290 *1291 1281 * @return array See {@BP_Blogs_Blog::get_all()}. 1292 1282 */ … … 1302 1292 * @param int $limit See {@BP_Blogs_Blog::get()}. 1303 1293 * @param int $page See {@BP_Blogs_Blog::get()}. 1304 *1305 1294 * @return array See {@BP_Blogs_Blog::get()}. 1306 1295 */ … … 1315 1304 * 1316 1305 * @param int $blog_id See {@BP_Blogs_Blog::is_hidden()}. 1317 *1318 1306 * @return bool See {@BP_Blogs_Blog::is_hidden()}. 1319 1307 */ … … 1322 1310 } 1323 1311 1324 /* ******************************************************************************1312 /* 1325 1313 * Blog meta functions 1326 1314 * … … 1343 1331 * deleted if the meta_value matches this parameter. 1344 1332 * @param bool $delete_all Optional. If true, delete matching metadata entries for 1345 * all objects, ignoring the specified blog_id. Otherwise, only 1346 * delete matching metadata entries for the specified blog. 1347 * Default: false. 1348 * 1333 * all objects, ignoring the specified blog_id. Otherwise, only 1334 * delete matching metadata entries for the specified blog. 1335 * Default: false. 1349 1336 * @return bool True on success, false on failure. 1350 1337 */ … … 1352 1339 global $wpdb; 1353 1340 1354 // Legacy - if no meta_key is passed, delete all for the blog_id 1341 // Legacy - if no meta_key is passed, delete all for the blog_id. 1355 1342 if ( empty( $meta_key ) ) { 1356 1343 $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->blogmeta} WHERE blog_id = %d", $blog_id ) ); … … 1384 1371 * metadata for the blog will be fetched. 1385 1372 * @param bool $single Optional. If true, return only the first value of the 1386 * specified meta_key. This parameter has no effect if 1387 * meta_key is not specified. Default: true. 1388 * 1373 * specified meta_key. This parameter has no effect if 1374 * meta_key is not specified. Default: true. 1389 1375 * @return mixed The meta value(s) being requested. 1390 1376 */ … … 1408 1394 * metadata entries with the specified value. 1409 1395 * Otherwise, update all entries. 1410 *1411 1396 * @return bool|int Returns false on failure. On successful update of existing 1412 1397 * metadata, returns true. On successful creation of new metadata, … … 1432 1417 * for the given key. If true, and the object already has a value for 1433 1418 * the key, no change will be made. Default: false. 1434 *1435 1419 * @return int|bool The meta ID on successful update, false on failure. 1436 1420 */ … … 1446 1430 * 1447 1431 * @param int $user_id ID whose blog data should be removed. 1448 * 1449 * @return bool|null Returns false on failure. 1432 * @return bool Returns false on failure. 1450 1433 */ 1451 1434 function bp_blogs_remove_data( $user_id ) { … … 1490 1473 } 1491 1474 1492 // Get the user's blogs 1475 // Get the user's blogs. 1493 1476 $user_blogs = get_blogs_of_user( $user_id ); 1494 1477 if ( empty( $user_blogs ) ) { -
trunk/src/bp-blogs/bp-blogs-loader.php
r10110 r10374 11 11 */ 12 12 13 // Exit if accessed directly 13 // Exit if accessed directly. 14 14 defined( 'ABSPATH' ) || exit; 15 15 16 /** 17 * Creates our Blogs component. 18 */ 16 19 class BP_Blogs_Component extends BP_Component { 17 20 … … 52 55 } 53 56 54 // Global tables for messaging component 57 // Global tables for messaging component. 55 58 $global_tables = array( 56 59 'table_name' => $bp->table_prefix . 'bp_user_blogs', … … 66 69 'slug' => BP_BLOGS_SLUG, 67 70 'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG, 68 'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site 71 'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site. 69 72 'directory_title' => _x( 'Sites', 'component directory title', 'buddypress' ), 70 73 'notification_callback' => 'bp_blogs_format_notifications', … … 75 78 ); 76 79 77 // Setup the globals 80 // Setup the globals. 78 81 parent::setup_globals( $args ); 79 82 80 /* 83 /** 81 84 * Filters if a blog is public. 82 85 * … … 85 88 * @since 2.3.0 86 89 * 87 * @ oaram int $value Whether or not the blog is public.90 * @param int $value Whether or not the blog is public. 88 91 */ 89 92 if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) { … … 117 120 public function includes( $includes = array() ) { 118 121 119 // Files to include 122 // Files to include. 120 123 $includes = array( 121 124 'cache', … … 133 136 } 134 137 135 // Include the files 138 // Include the files. 136 139 parent::includes( $includes ); 137 140 } … … 158 161 } 159 162 160 // Determine user to use 163 // Determine user to use. 161 164 if ( bp_displayed_user_domain() ) { 162 165 $user_domain = bp_displayed_user_domain(); … … 170 173 $parent_url = trailingslashit( $user_domain . $slug ); 171 174 172 // Add 'Sites' to the main navigation 175 // Add 'Sites' to the main navigation. 173 176 $count = (int) bp_get_total_blog_count_for_user(); 174 177 $class = ( 0 === $count ) ? 'no-count' : 'count'; … … 192 195 ); 193 196 194 // Setup navigation 197 // Setup navigation. 195 198 parent::setup_nav( $main_nav, $sub_nav ); 196 199 } … … 205 208 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() 206 209 * for description. 207 *208 210 * @return bool 209 211 */ … … 219 221 } 220 222 221 // Menus for logged in user 223 // Menus for logged in user. 222 224 if ( is_user_logged_in() ) { 223 225 224 // Setup the logged in user variables 226 // Setup the logged in user variables. 225 227 $blogs_link = trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() ); 226 228 227 // Add the "Sites" sub menu 229 // Add the "Sites" sub menu. 228 230 $wp_admin_nav[] = array( 229 231 'parent' => buddypress()->my_account_menu_id, … … 233 235 ); 234 236 235 // My Sites 237 // My Sites. 236 238 $wp_admin_nav[] = array( 237 239 'parent' => 'my-account-' . $this->id, … … 241 243 ); 242 244 243 // Create a Site 245 // Create a Site. 244 246 if ( bp_blog_signup_enabled() ) { 245 247 $wp_admin_nav[] = array( … … 256 258 257 259 /** 258 * Set up the title for pages and <title> 260 * Set up the title for pages and <title>. 259 261 */ 260 262 public function setup_title() { 261 263 262 // Set up the component options navigation for Site 264 // Set up the component options navigation for Site. 263 265 if ( bp_is_blogs_component() ) { 264 266 $bp = buddypress(); … … 270 272 271 273 // If we are not viewing the logged in user, set up the current 272 // users avatar and name 274 // users avatar and name. 273 275 } else { 274 276 $bp->bp_options_avatar = bp_core_fetch_avatar( array( … … 291 293 public function setup_cache_groups() { 292 294 293 // Global groups 295 // Global groups. 294 296 wp_cache_add_global_groups( array( 295 297 'blog_meta' … … 306 308 * @see bp_activity_get_post_type_tracking_args() for information on parameters. 307 309 * 308 * @param object|null $params 309 * @param string|int $post_type 310 * 310 * @param object|null $params Tracking arguments. 311 * @param string|int $post_type Post type to track. 311 312 * @return object 312 313 */ -
trunk/src/bp-blogs/bp-blogs-screens.php
r10100 r10374 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 96 96 public function is_blogs() { 97 97 98 // Bail if not looking at a group 98 // Bail if not looking at a group. 99 99 if ( ! bp_is_blogs_component() ) 100 100 return; 101 101 102 // Bail if looking at a users sites 102 // Bail if looking at a users sites. 103 103 if ( bp_is_user() ) 104 104 return; 105 105 106 // Blog Directory 106 // Blog Directory. 107 107 if ( is_multisite() && ! bp_current_action() ) { 108 108 bp_update_is_directory( true, 'blogs' ); … … 120 120 add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 121 121 122 // Create blog 122 // Create blog. 123 123 } elseif ( is_user_logged_in() && bp_blog_signup_enabled() ) { 124 124 add_filter( 'bp_get_buddypress_template', array( $this, 'create_template_hierarchy' ) ); … … 139 139 * 140 140 * @param string $templates The templates from bp_get_theme_compat_templates(). 141 *142 141 * @return array $templates Array of custom templates to look for. 143 142 */ … … 156 155 157 156 // Merge new templates with existing stack 158 // @see bp_get_theme_compat_templates() 157 // @see bp_get_theme_compat_templates(). 159 158 $templates = array_merge( (array) $new_templates, $templates ); 160 159 … … 202 201 * 203 202 * @param string $templates The templates from bp_get_theme_compat_templates(). 204 *205 203 * @return array $templates Array of custom templates to look for. 206 204 */ … … 219 217 220 218 // Merge new templates with existing stack 221 // @see bp_get_theme_compat_templates() 219 // @see bp_get_theme_compat_templates(). 222 220 $templates = array_merge( (array) $new_templates, $templates ); 223 221 … … 232 230 public function create_dummy_post() { 233 231 234 // Title based on ability to create blogs 232 // Title based on ability to create blogs. 235 233 if ( is_user_logged_in() && bp_blog_signup_enabled() ) { 236 234 $title = __( 'Create a Site', 'buddypress' ); -
trunk/src/bp-blogs/bp-blogs-template.php
r10248 r10374 195 195 $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); 196 196 197 // Backwards compatibility support for blogs by first letter 197 // Backwards compatibility support for blogs by first letter. 198 198 if ( ! empty( $_REQUEST['letter'] ) ) { 199 199 $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 200 200 201 // Typical blogs query 201 // Typical blogs query. 202 202 } else { 203 203 $this->blogs = bp_blogs_get_blogs( array( … … 212 212 } 213 213 214 // Set the total blog count 214 // Set the total blog count. 215 215 if ( empty( $max ) || ( $max >= (int) $this->blogs['total'] ) ) { 216 216 $this->total_blog_count = (int) $this->blogs['total']; … … 219 219 } 220 220 221 // Set the blogs array (to loop through later 221 // Set the blogs array (to loop through later. 222 222 $this->blogs = $this->blogs['blogs']; 223 223 224 // Get the current blog count to compare maximum against 224 // Get the current blog count to compare maximum against. 225 225 $blog_count = count( $this->blogs ); 226 226 227 // Set the current blog count 227 // Set the current blog count. 228 228 if ( empty( $max ) || ( $max >= (int) $blog_count ) ) { 229 229 $this->blog_count = (int) $blog_count; … … 232 232 } 233 233 234 // Build pagination links based on total blogs and current page number 234 // Build pagination links based on total blogs and current page number. 235 235 if ( ! empty( $this->total_blog_count ) && ! empty( $this->pag_num ) ) { 236 236 $this->pag_links = paginate_links( array( … … 302 302 */ 303 303 do_action( 'blog_loop_end' ); 304 // Do some cleaning up after the loop 304 // Do some cleaning up after the loop. 305 305 $this->rewind_blogs(); 306 306 } … … 324 324 $this->blog = $this->next_blog(); 325 325 326 // loop has just started326 // Loop has just started. 327 327 if ( 0 === $this->current_blog ) { 328 328 … … 396 396 } 397 397 398 // Parse arguments 398 // Parse arguments. 399 399 $r = bp_parse_args( $args, array( 400 400 'type' => 'active', 401 'page_arg' => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679401 'page_arg' => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679. 402 402 'page' => 1, 403 403 'per_page' => 20, 404 404 'max' => false, 405 'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of 405 'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of. 406 406 'include_blog_ids' => false, 407 407 'search_terms' => $search_terms_default, … … 409 409 ), 'has_blogs' ); 410 410 411 // Set per_page to maximum if max is enforced 411 // Set per_page to maximum if max is enforced. 412 412 if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) { 413 413 $r['per_page'] = (int) $r['max']; 414 414 } 415 415 416 // Get the blogs 416 // Get the blogs. 417 417 $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] ); 418 418 … … 550 550 $author_displayname = bp_core_get_user_displayname( $blogs_template->blog->admin_user_id ); 551 551 552 // Parse the arguments 552 // Parse the arguments. 553 553 $r = bp_parse_args( $args, array( 554 554 'type' => 'full', … … 562 562 ) ); 563 563 564 // Fetch the avatar 564 // Fetch the avatar. 565 565 $avatar = bp_core_fetch_avatar( array( 566 566 'item_id' => $blogs_template->blog->admin_user_id, 567 567 'title' => $r['title'], 568 // 'avatar_dir' => 'blog-avatars',569 // 'object' => 'blog',568 // 'avatar_dir' => 'blog-avatars', 569 // 'object' => 'blog', 570 570 'type' => $r['type'], 571 571 'alt' => $r['alt'], … … 576 576 ) ); 577 577 578 /** *578 /** 579 579 * In future BuddyPress versions you will be able to set the avatar for a blog. 580 580 * Right now you can use a filter with the ID of the blog to change it if you wish. … … 714 714 * @since 1.7.0 715 715 * 716 * @param array $classes Array of custom classes 716 * @param array $classes Array of custom classes. 717 717 */ 718 718 function bp_blog_class( $classes = array() ) { … … 725 725 * 726 726 * @global BP_Blogs_Template $blogs_template 727 * @param array $classes Array of custom classes728 * 727 * 728 * @param array $classes Array of custom classes. 729 729 * @return string Row class of the site. 730 730 */ … … 732 732 global $blogs_template; 733 733 734 // Add even/odd classes, but only if there's more than 1 group 734 // Add even/odd classes, but only if there's more than 1 group. 735 735 if ( $blogs_template->blog_count > 1 ) { 736 736 $pos_in_loop = (int) $blogs_template->current_blog; 737 737 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 738 738 739 // If we've only one site in the loop, don't bother with odd and even 739 // If we've only one site in the loop, don't bother with odd and even. 740 740 } else { 741 741 $classes[] = 'bp-single-blog'; … … 778 778 global $blogs_template; 779 779 780 // Parse the activity format 780 // Parse the activity format. 781 781 $r = bp_parse_args( $args, array( 782 782 'active_format' => true 783 783 ) ); 784 784 785 // Backwards compatibility for anyone forcing a 'true' active_format 785 // Backwards compatibility for anyone forcing a 'true' active_format. 786 786 if ( true === $r['active_format'] ) { 787 787 $r['active_format'] = __( 'active %s', 'buddypress' ); 788 788 } 789 789 790 // Blog has been posted to at least once 790 // Blog has been posted to at least once. 791 791 if ( isset( $blogs_template->blog->last_activity ) ) { 792 792 793 // Backwards compatibility for pre 1.5 'ago' strings 793 // Backwards compatibility for pre 1.5 'ago' strings. 794 794 $last_activity = ! empty( $r['active_format'] ) 795 795 ? bp_core_get_last_activity( $blogs_template->blog->last_activity, $r['active_format'] ) 796 796 : bp_core_time_since( $blogs_template->blog->last_activity ); 797 797 798 // Blog has never been posted to 798 // Blog has never been posted to. 799 799 } else { 800 800 $last_activity = __( 'Never active', 'buddypress' ); … … 1000 1000 * @param string $size Image version to return. 'thumbnail', 'medium', 1001 1001 * 'large', or 'post-thumbnail'. Default: 'thumbnail'. 1002 *1003 1002 * @return string URL of the image. 1004 1003 */ … … 1028 1027 * @param string $thumbnail Image version to return. 'thumbnail', 'medium', 'large', 1029 1028 * or 'post-thumbnail'. Default: 'thumbnail'. 1030 *1031 1029 * @return bool True if the latest blog post from the current blog has a 1032 1030 * featured image of the given size. … … 1101 1099 * 1102 1100 * @param int $user_id ID of the user. 1103 *1104 1101 * @return int Total number of blogs for the user. 1105 1102 */ … … 1138 1135 * Filters whether or not blog creation is enabled. 1139 1136 * 1137 * Return "all", "none", "blog" or "user". 1138 * 1140 1139 * @since 1.0.0 1141 1140 * 1142 1141 * @param string $active_signup Value of the registration site option creation status. 1143 1142 */ 1144 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"1143 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); 1145 1144 1146 1145 if ( 'none' == $active_signup || 'user' == $active_signup ) … … 1226 1225 global $current_site; 1227 1226 1228 // Blog name 1227 // Blog name. 1229 1228 if( !is_subdomain_install() ) 1230 1229 echo '<label for="blogname">' . __('Site Name:', 'buddypress') . '</label>'; … … 1255 1254 } 1256 1255 1257 // Blog Title 1256 // Blog Title. 1258 1257 ?> 1259 1258 … … 1323 1322 $public = (int) $_POST['blog_public']; 1324 1323 1325 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated 1324 // Depreciated. 1325 $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); 1326 1326 1327 1327 /** … … 1398 1398 function bp_create_blog_link() { 1399 1399 1400 // Don't show this link when not on your own profile 1400 // Don't show this link when not on your own profile. 1401 1401 if ( ! bp_is_my_profile() ) { 1402 1402 return; … … 1420 1420 function bp_blogs_blog_tabs() { 1421 1421 1422 // Don't show these tabs on a user's own profile 1422 // Don't show these tabs on a user's own profile. 1423 1423 if ( bp_is_my_profile() ) { 1424 1424 return false; … … 1531 1531 */ 1532 1532 function bp_get_blog_create_nav_item() { 1533 // Get the create a site button 1533 // Get the create a site button. 1534 1534 $create_blog_button = bp_get_blog_create_button(); 1535 1535 1536 // Make sure the button is available 1536 // Make sure the button is available. 1537 1537 if ( empty( $create_blog_button ) ) { 1538 1538 return; … … 1555 1555 */ 1556 1556 function bp_blog_backcompat_create_nav_item() { 1557 // Bail if Blogs nav item is already used by bp-legacy 1557 // Bail if Blogs nav item is already used by bp-legacy. 1558 1558 if ( has_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ) ) { 1559 1559 return; 1560 1560 } 1561 1561 1562 // Bail if the theme is not filtering the Blogs directory title 1562 // Bail if the theme is not filtering the Blogs directory title. 1563 1563 if ( ! has_filter( 'bp_blogs_directory_header' ) ) { 1564 1564 return; … … 1634 1634 * @uses bp_blogs_admin_get_profile_stats() to get the stats. 1635 1635 * 1636 * @param array|string $args before|after|user_id1636 * @param array|string $args Before|after|user_id. 1637 1637 */ 1638 1638 function bp_blogs_profile_stats( $args = '' ) { … … 1646 1646 * @since 2.0.0 1647 1647 * 1648 * @param array|string $args before|after|user_id 1649 * 1648 * @param array|string $args Before|after|user_id. 1650 1649 * @return string HTML for stats output. 1651 1650 */ 1652 1651 function bp_blogs_get_profile_stats( $args = '' ) { 1653 1652 1654 // Parse the args 1653 // Parse the args. 1655 1654 $r = bp_parse_args( $args, array( 1656 1655 'before' => '<li class="bp-blogs-profile-stats">', … … 1661 1660 ), 'blogs_get_profile_stats' ); 1662 1661 1663 // Allow completely overloaded output 1662 // Allow completely overloaded output. 1664 1663 if ( is_multisite() && empty( $r['output'] ) ) { 1665 1664 1666 // Only proceed if a user ID was passed 1665 // Only proceed if a user ID was passed. 1667 1666 if ( ! empty( $r['user_id'] ) ) { 1668 1667 1669 // Get the user's blogs 1668 // Get the user's blogs. 1670 1669 if ( empty( $r['blogs'] ) ) { 1671 1670 $r['blogs'] = absint( bp_blogs_total_blogs_for_user( $r['user_id'] ) ); 1672 1671 } 1673 1672 1674 // If blogs exist, show some formatted output 1673 // If blogs exist, show some formatted output. 1675 1674 $r['output'] = $r['before'] . sprintf( _n( '%s site', '%s sites', $r['blogs'], 'buddypress' ), '<strong>' . $r['blogs'] . '</strong>' ) . $r['after']; 1676 1675 } -
trunk/src/bp-blogs/bp-blogs-widgets.php
r10215 r10374 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 77 77 $after_widget = $args['after_widget']; 78 78 79 // Override some of the contextually set parameters for bp_has_activities() 79 // Override some of the contextually set parameters for bp_has_activities(). 80 80 $args = array( 81 81 'action' => 'new_blog_post', … … 128 128 * @param array $new_instance The new instance options. 129 129 * @param array $old_instance The old instance options. 130 *131 130 * @return array $instance The parsed options to be saved. 132 131 */ … … 145 144 * @param array $instance Settings for this widget. 146 145 * 147 * @return string146 * @return void 148 147 */ 149 148 public function form( $instance ) { -
trunk/src/bp-blogs/classes/class-bp-blogs-blog.php
r10100 r10374 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 19 19 */ 20 20 class BP_Blogs_Blog { 21 22 /** 23 * Site ID. 24 * 25 * @var int|null 26 */ 21 27 public $id; 28 29 /** 30 * User ID. 31 * 32 * @var int 33 */ 22 34 public $user_id; 35 36 /** 37 * Blog ID. 38 * 39 * @var int 40 */ 23 41 public $blog_id; 24 42 … … 82 100 83 101 if ( $this->id ) { 84 // Update 102 // Update. 85 103 $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id ); 86 104 } else { 87 // Save 105 // Save. 88 106 $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id ); 89 107 } … … 141 159 * blogs. Default: true. 142 160 * @param array|bool $include_blog_ids Array of blog IDs to include. 143 *144 161 * @return array Multidimensional results array, structured as follows: 145 162 * 'blogs' - Array of located blog objects … … 255 272 * @param int $user_id Optional. The ID of the user from whom the blog is 256 273 * being removed. If absent, defaults to the logged-in user ID. 257 *258 274 * @return int|bool Number of rows deleted on success, false on failure. 259 275 */ … … 274 290 * @param int $user_id Optional. The ID of the user whose blog associations 275 291 * are being deleted. If absent, defaults to logged-in user ID. 276 *277 292 * @return int|bool Number of rows deleted on success, false on failure. 278 293 */ … … 300 315 * @param bool $show_hidden Optional. Whether to include blogs that are not marked 301 316 * public. Defaults to true when viewing one's own profile. 302 *303 317 * @return array Multidimensional results array, structured as follows: 304 318 * 'blogs' - Array of located blog objects. … … 340 354 * @param int $user_id Optional. ID of the user whose blogs are being 341 355 * queried. Defaults to logged-in user. 342 *343 356 * @return int The number of blogs associated with the user. 344 357 */ … … 358 371 * 359 372 * @param int $blog_id ID of the blog being queried. 360 *361 373 * @return int|null The ID of the first located entry in the BP table 362 374 * on success, otherwise null. … … 379 391 * @param int $user_id Optional. ID of the user whose blogs are being 380 392 * queried. Defaults to logged-in user. 381 *382 393 * @return int Blog count for the user. 383 394 */ … … 409 420 * @param int $page Optional. The page of results to return. Default: 410 421 * null (no limit). 411 *412 422 * @return array Multidimensional results array, structured as follows: 413 423 * 'blogs' - Array of located blog objects. … … 447 457 * @param int $page Optional. The page of results to return. Default: 448 458 * null (no limit). 449 *450 459 * @return array Multidimensional results array, structured as follows: 451 460 * 'blogs' - Array of located blog objects. … … 472 481 * 'bp_moderate' cap. 473 482 * 474 * @param string $letter. The letter you're looking for. 475 * @param int $limit Optional. The maximum number of items to return. 476 * Default: null (no limit). 477 * @param int $page Optional. The page of results to return. Default: 478 * null (no limit). 479 * 483 * @param string $letter The letter you're looking for. 484 * @param int $limit Optional. The maximum number of items to return. 485 * Default: null (no limit). 486 * @param int $page Optional. The page of results to return. Default: 487 * null (no limit). 480 488 * @return array Multidimensional results array, structured as follows: 481 489 * 'blogs' - Array of located blog objects. … … 516 524 * @param array $blog_ids Array of IDs returned from the original query. 517 525 * @param string|bool $type Not currently used. Default: false. 518 *519 526 * @return array $paged_blogs The located blogs array, with the extras added. 520 527 */ … … 534 541 $images = array(); 535 542 536 // Add URLs to any Featured Image this post might have 543 // Add URLs to any Featured Image this post might have. 537 544 if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) { 538 545 … … 542 549 $images['thumbnail'] = $image[0]; 543 550 544 // Medium 551 // Medium. 545 552 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false ); 546 553 if ( ! empty( $image ) ) 547 554 $images['medium'] = $image[0]; 548 555 549 // Large 556 // Large. 550 557 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false ); 551 558 if ( ! empty( $image ) ) 552 559 $images['large'] = $image[0]; 553 560 554 // Post thumbnail 561 // Post thumbnail. 555 562 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false ); 556 563 if ( ! empty( $image ) ) 557 564 $images['post-thumbnail'] = $image[0]; 558 565 559 // Add the images to the latest_post object 566 // Add the images to the latest_post object. 560 567 $paged_blogs[$i]->latest_post->images = $images; 561 568 } … … 581 588 * 582 589 * @param int $blog_id The ID of the blog being checked. 583 *584 590 * @return bool True if hidden (public = 0), false otherwise. 585 591 */ … … 599 605 * @param int $user_id ID of user. 600 606 * @param int $blog_id ID of blog. 601 *602 607 * @return int|bool ID of user-blog link, or false if not found. 603 608 */
Note: See TracChangeset
for help on using the changeset viewer.