Changeset 9325
- Timestamp:
- 01/09/2015 08:30:52 AM (11 years ago)
- Location:
- trunk/src/bp-activity
- Files:
-
- 2 edited
-
bp-activity-classes.php (modified) (1 diff)
-
bp-activity-filters.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-classes.php
r9315 r9325 868 868 $scope_args = array(); 869 869 870 switch ( $scope ) { 871 case 'just-me' : 872 $scope_args = array( 873 'column' => 'user_id', 874 'value' => $r['user_id'] 875 ); 876 877 $scope_args['override']['display_comments'] = 'stream'; 878 879 // wipe out the user ID 880 $scope_args['override']['filter']['user_id'] = 0; 881 882 break; 883 884 case 'favorites': 885 $favs = bp_activity_get_user_favorites( $r['user_id'] ); 886 if ( empty( $favs ) ) { 887 return $scope_args; 888 } 889 890 $scope_args = array( 891 'column' => 'id', 892 'compare' => 'IN', 893 'value' => (array) $favs 894 ); 895 $scope_args['override']['display_comments'] = true; 896 897 // wipe out the user ID 898 $scope_args['override']['filter']['user_id'] = 0; 899 900 break; 901 902 case 'mentions': 903 // Are mentions disabled? 904 if ( ! bp_activity_do_mentions() ) { 905 return $scope_args; 906 } 907 908 $scope_args = array( 909 'column' => 'content', 910 'compare' => 'LIKE', 911 912 // Start search at @ symbol and stop search at closing tag delimiter. 913 'value' => '@' . bp_activity_get_user_mentionname( $r['user_id'] ) . '<' 914 ); 915 916 // wipe out current search terms if any 917 // this is so the 'mentions' scope can be combined with other scopes 918 $scope_args['override']['search_terms'] = false; 919 920 $scope_args['override']['display_comments'] = 'stream'; 921 $scope_args['override']['filter']['user_id'] = 0; 922 923 break; 924 925 default : 926 /** 927 * Plugins can hook here to set their activity arguments for custom scopes. 928 * 929 * This is a dynamic filter based on the activity scope. eg: 930 * - 'bp_activity_set_groups_scope_args' 931 * - 'bp_activity_set_friends_scope_args' 932 * 933 * To see how this filter is used, plugin devs should check out: 934 * - bp_groups_filter_activity_scope() - used for 'groups' scope 935 * - bp_friends_filter_activity_scope() - used for 'friends' scope 936 * 937 * @since BuddyPress (2.2.0) 938 * 939 * @param array { 940 * Activity query clauses. 941 * 942 * @type array { 943 * Activity arguments for your custom scope. 944 * See {@link BP_Activity_Query::_construct()} for more details. 945 * } 946 * @type array $override Optional. Override existing activity arguments passed by $r. 947 * } 948 * @param array $r Current activity arguments passed in BP_Activity_Activity::get() 949 */ 950 $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r ); 951 break; 952 } 870 /** 871 * Plugins can hook here to set their activity arguments for custom scopes. 872 * 873 * This is a dynamic filter based on the activity scope. eg: 874 * - 'bp_activity_set_groups_scope_args' 875 * - 'bp_activity_set_friends_scope_args' 876 * 877 * To see how this filter is used, plugin devs should check out: 878 * - bp_groups_filter_activity_scope() - used for 'groups' scope 879 * - bp_friends_filter_activity_scope() - used for 'friends' scope 880 * 881 * @since BuddyPress (2.2.0) 882 * 883 * @param array { 884 * Activity query clauses. 885 * 886 * @type array { 887 * Activity arguments for your custom scope. 888 * See {@link BP_Activity_Query::_construct()} for more details. 889 * } 890 * @type array $override Optional. Override existing activity arguments passed by $r. 891 * } 892 * @param array $r Current activity arguments passed in BP_Activity_Activity::get() 893 */ 894 $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r ); 953 895 954 896 if ( ! empty( $scope_args ) ) { -
trunk/src/bp-activity/bp-activity-filters.php
r9318 r9325 639 639 } 640 640 add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 ); 641 642 /** SCOPES **************************************************************/ 643 644 /** 645 * Set up activity arguments for use with the 'just-me' scope. 646 * 647 * @since BuddyPress (2.2.0) 648 * 649 * @param array $retval Empty array by default 650 * @param array $filter Current activity arguments 651 * @return array 652 */ 653 function bp_activity_filter_just_me_scope( $retval, $filter ) { 654 $retval = array( 655 'column' => 'user_id', 656 'value' => $filter['user_id'] 657 ); 658 659 $retval['override']['display_comments'] = 'stream'; 660 661 // wipe out the user ID 662 $retval['override']['filter']['user_id'] = 0; 663 664 return $retval; 665 } 666 add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_scope', 10, 2 ); 667 668 /** 669 * Set up activity arguments for use with the 'favorites' scope. 670 * 671 * @since BuddyPress (2.2.0) 672 * 673 * @param array $retval Empty array by default 674 * @param array $filter Current activity arguments 675 * @return array 676 */ 677 function bp_activity_filter_favorites_scope( $retval, $filter ) { 678 $favs = bp_activity_get_user_favorites( $filter['user_id'] ); 679 if ( empty( $favs ) ) { 680 return $retval; 681 } 682 683 $retval = array( 684 'column' => 'id', 685 'compare' => 'IN', 686 'value' => (array) $favs 687 ); 688 $retval['override']['display_comments'] = true; 689 690 // wipe out the user ID 691 $retval['override']['filter']['user_id'] = 0; 692 693 return $retval; 694 } 695 add_filter( 'bp_activity_set_favorites_scope_args', 'bp_activity_filter_favorites_scope', 10, 2 ); 696 697 698 /** 699 * Set up activity arguments for use with the 'favorites' scope. 700 * 701 * @since BuddyPress (2.2.0) 702 * 703 * @param array $retval Empty array by default 704 * @param array $filter Current activity arguments 705 * @return array 706 */ 707 function bp_activity_filter_mentions_scope( $retval, $filter ) { 708 // Are mentions disabled? 709 if ( ! bp_activity_do_mentions() ) { 710 return $retval; 711 } 712 713 $retval = array( 714 'column' => 'content', 715 'compare' => 'LIKE', 716 717 // Start search at @ symbol and stop search at closing tag delimiter. 718 'value' => '@' . bp_activity_get_user_mentionname( $filter['user_id'] ) . '<' 719 ); 720 721 // wipe out current search terms if any 722 // this is so the 'mentions' scope can be combined with other scopes 723 $retval['override']['search_terms'] = false; 724 725 $retval['override']['display_comments'] = 'stream'; 726 $retval['override']['filter']['user_id'] = 0; 727 728 return $retval; 729 } 730 add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_scope', 10, 2 );
Note: See TracChangeset
for help on using the changeset viewer.