Changeset 14025
- Timestamp:
- 09/23/2024 02:35:01 PM (19 months ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-taxonomy.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-taxonomy.php
r13968 r14025 142 142 * 143 143 * @since 2.2.0 144 * 145 * @see wp_get_object_terms() for a full description of function and parameters. 144 * @since 15.0.0 Added a `_doing_it_wrong` check to prevent errors when using the function too early. 145 * 146 * @see wp_get_object_terms() for a full description of function and parameters 146 147 * 147 148 * @param int|array $object_ids ID or IDs of objects. 148 149 * @param string|array $taxonomies Name or names of taxonomies to match. 149 150 * @param array $args See {@see wp_get_object_terms()}. 150 * @return array 151 * 152 * @return WP_Term[]|int[]|string[] 151 153 */ 152 154 function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) { 155 156 // Check if the bp_register_taxonomies hook is set. 157 if ( ! did_action( 'bp_register_taxonomies' ) ) { 158 _doing_it_wrong( 159 __FUNCTION__, 160 sprintf( 161 /* translators: 1: the name of the function. 2: the name of the hook. */ 162 esc_html__( 'The %1$s function requires the %2$s hook to be fired before is used.', 'buddypress' ), 163 '<code>bp_get_object_terms</code>', 164 '<code>bp_register_taxonomies</code>' 165 ), 166 '15.0.0' 167 ); 168 169 // Return empty array since we don't have any taxonomies registered yet. 170 return array(); 171 } 172 153 173 // Different taxonomies must be stored on different sites. 154 174 $taxonomy_site_map = array(); … … 161 181 foreach ( $taxonomy_site_map as $taxonomy_site_id => $site_taxonomies ) { 162 182 $switched = false; 183 163 184 if ( $taxonomy_site_id !== get_current_blog_id() ) { 164 185 switch_to_blog( $taxonomy_site_id ); … … 168 189 169 190 $site_terms = wp_get_object_terms( $object_ids, $site_taxonomies, $args ); 170 $retval = array_merge( $retval, $site_terms ); 191 192 // Handle the case where wp_get_object_terms() returns an error. 193 if ( is_wp_error( $site_terms ) || empty( $site_terms ) ) { 194 $site_terms = array(); 195 } 196 197 $retval = array_merge( $retval, $site_terms ); 171 198 172 199 if ( $switched ) {
Note: See TracChangeset
for help on using the changeset viewer.