mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Options: Add 'default' to register_setting
Add a `default` argument to `register_setting` that will be used an the default option value viet `get_option()` in the event of no other option being specified. This means (if chosen) developers can define their default once via `register_option` and not have to duplicate the value every time they make a call to `get_option()`. Props rmccue, jorbin, jtsternberg. Fixes #38176. git-svn-id: https://develop.svn.wordpress.org/trunk@38910 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -39,6 +39,28 @@ class Tests_Option_Registration extends WP_UnitTestCase {
|
||||
return 'S-M-R-T';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38176
|
||||
*/
|
||||
public function test_register_with_default() {
|
||||
register_setting( 'test_group', 'test_default', array(
|
||||
'default' => 'Fuck Cancer'
|
||||
));
|
||||
|
||||
$this->assertEquals( 'Fuck Cancer', get_option( 'test_default' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38176
|
||||
*/
|
||||
public function test_register_with_default_override() {
|
||||
register_setting( 'test_group', 'test_default', array(
|
||||
'default' => 'Fuck Cancer'
|
||||
));
|
||||
|
||||
$this->assertEquals( 'Fuck Leukemia', get_option( 'test_default', 'Fuck Leukemia' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedDeprecated register_setting
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user