Make WordPress Core

Changeset 39383


Ignore:
Timestamp:
11/30/2016 09:31:38 PM (8 years ago)
Author:
ocean90
Message:

Options: Pass the $passed_default parameter to the default_option_{$option} filter in add_option().

This was missed in [38910].

Merge of [39382] to the 4.7 branch.

Props joehoyle, lucasstark.
See #38176, #38930.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/option.php

    r39335 r39383  
    422422    if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
    423423        /** This filter is documented in wp-includes/option.php */
    424         if ( apply_filters( 'default_option_' . $option, false, $option ) !== get_option( $option ) )
     424        if ( apply_filters( 'default_option_' . $option, false, $option, false ) !== get_option( $option ) )
    425425            return false;
    426426
  • branches/4.7/tests/phpunit/tests/option/registration.php

    r38910 r39383  
    6363
    6464    /**
     65     * @ticket 38930
     66     */
     67    public function test_add_option_with_no_options_cache() {
     68        register_setting( 'test_group', 'test_default', array(
     69            'default' => 'My Default :)',
     70        ));
     71        wp_cache_delete( 'notoptions', 'options' );
     72        $this->assertTrue( add_option( 'test_default', 'hello' ) );
     73        $this->assertEquals( 'hello', get_option( 'test_default' ) );
     74    }
     75
     76    /**
    6577     * @expectedDeprecated register_setting
    6678     */
Note: See TracChangeset for help on using the changeset viewer.