Changeset 12892 for trunk/src/bp-core/bp-core-functions.php
- Timestamp:
- 04/18/2021 10:18:06 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r12797 r12892 948 948 */ 949 949 return apply_filters( 'bp_core_get_component_search_query_arg', $query_arg, $component ); 950 } 951 952 /** 953 * Get a list of all active component objects. 954 * 955 * @since 8.0.0 956 * 957 * @param array $args { 958 * Optional. An array of key => value arguments to match against the component objects. 959 * Default empty array. 960 * 961 * @type string $name Translatable name for the component. 962 * @type string $id Unique ID for the component. 963 * @type string $slug Unique slug for the component, for use in query strings and URLs. 964 * @type bool $has_directory True if the component has a top-level directory. False otherwise. 965 * @type string $root_slug Slug used by the component's directory page. 966 * } 967 * @param string $output Optional. The type of output to return. Accepts 'ids' 968 * or 'objects'. Default 'ids'. 969 * @param string $operator Optional. The logical operation to perform. 'or' means only one 970 * element from the array needs to match; 'and' means all elements 971 * must match. Accepts 'or' or 'and'. Default 'and'. 972 * @return array A list of component ids or objects. 973 */ 974 function bp_core_get_active_components( $args = array(), $output = 'ids', $operator = 'and' ) { 975 $bp = buddypress(); 976 977 $active_components = array_keys( $bp->active_components ); 978 979 $xprofile_id = array_search( 'xprofile', $active_components, true ); 980 if ( false !== $xprofile_id ) { 981 $active_components[ $xprofile_id ] = 'profile'; 982 } 983 984 $components = array(); 985 foreach ( $active_components as $id ) { 986 if ( isset( $bp->{$id} ) && $bp->{$id} instanceof BP_Component ) { 987 $components[ $id ] = $bp->{$id}; 988 } 989 } 990 991 $components = wp_filter_object_list( $components, $args, $operator ); 992 993 if ( 'ids' === $output ) { 994 $components = wp_list_pluck( $components, 'id' ); 995 } 996 997 return $components; 950 998 } 951 999
Note: See TracChangeset
for help on using the changeset viewer.