Changeset 11356 for trunk/src/bp-activity/bp-activity-functions.php
- Timestamp:
- 12/29/2016 07:38:58 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r11351 r11356 838 838 */ 839 839 return apply_filters( 'bp_activity_get_types', $actions ); 840 } 841 842 /** 843 * Gets the current activity context. 844 * 845 * The "context" is the current view type, corresponding roughly to the 846 * current component. Use this context to determine which activity actions 847 * should be whitelisted for the filter dropdown. 848 * 849 * @since 2.8.0 850 * 851 * @return string Activity context. 'member', 'member_groups', 'group', 'activity'. 852 */ 853 function bp_activity_get_current_context() { 854 // On member pages, default to 'member', unless this is a user's Groups activity. 855 if ( bp_is_user() ) { 856 if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) { 857 $context = 'member_groups'; 858 } else { 859 $context = 'member'; 860 } 861 862 // On individual group pages, default to 'group'. 863 } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) { 864 $context = 'group'; 865 866 // 'activity' everywhere else. 867 } else { 868 $context = 'activity'; 869 } 870 871 return $context; 872 } 873 874 /** 875 * Gets a flat list of activity actions compatible with a given context. 876 * 877 * @since 2.8.0 878 * 879 * @param string $context Optional. Name of the context. Defaults to the current context. 880 * @return array 881 */ 882 function bp_activity_get_actions_for_context( $context = '' ) { 883 if ( ! $context ) { 884 $context = bp_activity_get_current_context(); 885 } 886 887 $actions = array(); 888 foreach ( bp_activity_get_actions() as $component_actions ) { 889 foreach ( $component_actions as $component_action ) { 890 if ( in_array( $context, (array) $component_action['context'], true ) ) { 891 $actions[] = $component_action; 892 } 893 } 894 } 895 896 return $actions; 840 897 } 841 898
Note: See TracChangeset
for help on using the changeset viewer.