WordPress.org

Make WordPress Core

Ticket #37928: 37928.diff

File 37928.diff, 1.2 KB (added by flixos90, 3 years ago)
  • src/wp-includes/option.php

     
    412412
    413413        $value = sanitize_option( $option, $value );
    414414
     415        /**
     416         * Filters a specific option before its value is (maybe) serialized and added.
     417         *
     418         * The dynamic portion of the hook name, `$option`, refers to the option name.
     419         *
     420         * @since 4.7.0
     421         *
     422         * @param mixed  $value  The new, unserialized option value.
     423         * @param string $option Option name.
     424         */
     425        $value = apply_filters( "pre_add_option_{$option}", $value, $option );
     426
     427        /**
     428         * Filters an option before its value is (maybe) serialized and added.
     429         *
     430         * @since 4.7.0
     431         *
     432         * @param mixed  $value  The new, unserialized option value.
     433         * @param string $option Name of the option.
     434         */
     435        $value = apply_filters( 'pre_add_option', $value, $option );
     436
     437        // If the value is null, skip adding.
     438        if ( null === $value ) {
     439                return false;
     440        }
     441
    415442        // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
    416443        $notoptions = wp_cache_get( 'notoptions', 'options' );
    417444        if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )