Make WordPress Core

Changeset 42655


Ignore:
Timestamp:
02/06/2018 02:48:46 PM (7 years ago)
Author:
flixos90
Message:

Options: Unhook default option filter when setting is unregistered.

Fixes #43207.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r42359 r42655  
    21832183        }
    21842184
     2185        // Remove the default filter if a default was provided during registration.
     2186        if ( array_key_exists( 'default', $wp_registered_settings[ $option_name ] ) ) {
     2187            remove_filter( "default_option_{$option_name}", 'filter_default_option', 10 );
     2188        }
     2189
    21852190        unset( $wp_registered_settings[ $option_name ] );
    21862191    }
  • trunk/tests/phpunit/tests/option/registration.php

    r42343 r42655  
    9595        register_setting( 'privacy', 'test_option' );
    9696    }
     97
     98    /**
     99     * @ticket 43207
     100     */
     101    public function test_unregister_setting_removes_default() {
     102        register_setting(
     103            'test_group', 'test_default', array(
     104                'default' => 'Fuck Cancer',
     105            )
     106        );
     107
     108        unregister_setting( 'test_group', 'test_default' );
     109
     110        $this->assertFalse( has_filter( 'default_option_test_default', 'filter_default_option' ) );
     111    }
    97112}
Note: See TracChangeset for help on using the changeset viewer.