mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Options, Meta APIs: Add a filter to allow the shortcut return to wp_load_alloptions function.
Add a new filter `pre_wp_load_alloptions` in the `wp_load_alloptions` function to short circuit the return value. Props pbearne, spacedmonkey, joyously, SergeyBiryukov, mukesh27, costdev. Fixes #56045. git-svn-id: https://develop.svn.wordpress.org/trunk@55256 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -120,4 +120,31 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase {
|
||||
$this->alloptions = $alloptions;
|
||||
return $this->alloptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that `$alloptions` can be filtered with a custom value, short circuiting `wp_load_alloptions()`.
|
||||
*
|
||||
* @ticket 56045
|
||||
*
|
||||
* @covers ::wp_load_alloptions
|
||||
*/
|
||||
public function test_filter_pre_wp_load_alloptions_filter_is_called() {
|
||||
$filter = new MockAction();
|
||||
|
||||
add_filter( 'pre_wp_load_alloptions', array( &$filter, 'filter' ) );
|
||||
|
||||
wp_load_alloptions();
|
||||
|
||||
$this->assertSame(
|
||||
1,
|
||||
$filter->get_call_count(),
|
||||
'The filter was not called 1 time.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
array( 'pre_wp_load_alloptions' ),
|
||||
$filter->get_hook_names(),
|
||||
'The hook name was incorrect.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user