wpseek.com
A WordPress-centric search engine for devs and theme authors
filter_default_metadata › WordPress Function
Since5.5.0
Deprecatedn/a
› filter_default_metadata ( $value, $object_id, $meta_key, $single, $meta_type )
Parameters: (5) |
|
Returns: |
|
Defined at: |
|
Codex: |
Filters into default_{$object_type}_metadata and adds in default value.
Related Functions: filter_default_option, delete_metadata, register_default_headers, unregister_default_headers, get_metadata
Source
function filter_default_metadata( $value, $object_id, $meta_key, $single, $meta_type ) { global $wp_meta_keys; if ( wp_installing() ) { return $value; } if ( ! is_array( $wp_meta_keys ) || ! isset( $wp_meta_keys[ $meta_type ] ) ) { return $value; } $defaults = array(); foreach ( $wp_meta_keys[ $meta_type ] as $sub_type => $meta_data ) { foreach ( $meta_data as $_meta_key => $args ) { if ( $_meta_key === $meta_key && array_key_exists( 'default', $args ) ) { $defaults[ $sub_type ] = $args; } } } if ( ! $defaults ) { return $value; } // If this meta type does not have subtypes, then the default is keyed as an empty string. if ( isset( $defaults[''] ) ) { $metadata = $defaults['']; } else { $sub_type = get_object_subtype( $meta_type, $object_id ); if ( ! isset( $defaults[ $sub_type ] ) ) { return $value; } $metadata = $defaults[ $sub_type ]; } if ( $single ) { $value = $metadata['default']; } else { $value = array( $metadata['default'] ); } return $value; }