Make WordPress Core

Ticket #31047: 31047.patch

File 31047.patch, 928 bytes (added by tyxla, 10 years ago)

Taking advantage of the default_option_* filter in update_option() and add_option().

  • src/wp-includes/option.php

     
    268268        if ( $value === $old_value )
    269269                return false;
    270270
    271         if ( false === $old_value )
     271        if ( apply_filters( 'default_option_' . $option, false ) === $old_value )
    272272                return add_option( $option, $value );
    273273
    274274        $serialized_value = maybe_serialize( $value );
     
    369369        // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
    370370        $notoptions = wp_cache_get( 'notoptions', 'options' );
    371371        if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
    372                 if ( false !== get_option( $option ) )
     372                if ( apply_filters( 'default_option_' . $option, false ) !== get_option( $option ) )
    373373                        return false;
    374374
    375375        $serialized_value = maybe_serialize( $value );