WordPress.org

Make WordPress Core

Ticket #14766: wp-includes-meta-filters-refresh.patch

File wp-includes-meta-filters-refresh.patch, 1.9 KB (added by sc0ttkclark, 10 years ago)

Refreshed patch to use latest revision of trunk, relative to WP root folder, and returning (bool) $check as per @scribu's suggestion

  • wp-includes/meta.php

     
    4545        // expected_slashed ($meta_key)
    4646        $meta_key = stripslashes($meta_key);
    4747
     48        $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
     49        if ( null !== $check )
     50                return (bool) $check;
     51
    4852        if ( $unique && $wpdb->get_var( $wpdb->prepare(
    4953                "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d",
    5054                $meta_key, $object_id ) ) )
     
    108112        // expected_slashed ($meta_key)
    109113        $meta_key = stripslashes($meta_key);
    110114
     115        $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
     116        if ( null !== $check )
     117                return (bool) $check;
     118
    111119        if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
    112120                return add_metadata($meta_type, $object_id, $meta_key, $meta_value);
    113121
     
    180188        $meta_key = stripslashes($meta_key);
    181189        $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
    182190
     191        $check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
     192        if ( null !== $check )
     193                return (bool) $check;
     194
    183195        $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key );
    184196
    185197        if ( !$delete_all )
     
    231243        if ( !$object_id = absint($object_id) )
    232244                return false;
    233245
     246        $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );
     247        if ( null !== $check ) {
     248                if ( !is_array( $check ) )
     249                        return $check;
     250                elseif ( $single )
     251                        return maybe_unserialize( $check[0] );
     252                else
     253                        return array_map( 'maybe_unserialize', $check );
     254        }
     255
    234256        $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
    235257
    236258        if ( !$meta_cache ) {