WordPress.org

Make WordPress Core

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

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

Updated filter to use null instead of false

  • 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 true;
     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 ) ) )
     
    106110        // expected_slashed ($meta_key)
    107111        $meta_key = stripslashes($meta_key);
    108112
     113        $check = apply_filters( "update_{$meta_type}_metadata" , null, $object_id, $meta_key, $meta_value, $prev_value );
     114        if ( null !== $check )
     115                return true;
     116
    109117        if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
    110118                return add_metadata($meta_type, $object_id, $meta_key, $meta_value);
    111119
     
    178186        $meta_key = stripslashes($meta_key);
    179187        $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
    180188
     189        $check = apply_filters( "delete_{$meta_type}_metadata" , null, $object_id, $meta_key, $meta_value, $delete_all );
     190        if ( null !== $check )
     191                return true;
     192
    181193        $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key );
    182194
    183195        if ( !$delete_all )
     
    227239        if ( !$object_id = absint($object_id) )
    228240                return false;
    229241
     242        $check = apply_filters( "get_{$meta_type}_metadata" , null, $object_id, $meta_key, $single );
     243        if ( null !== $check ) {
     244                if ( !is_array( $check ) )
     245                        return $check;
     246                elseif ( $single )
     247                        return maybe_unserialize( $check[0] );
     248                else
     249                        return array_map('maybe_unserialize', $check);
     250        }
     251
    230252        $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
    231253
    232254        if ( !$meta_cache ) {