Changeset 54145
- Timestamp:
- 09/13/2022 07:27:19 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r54080 r54145 131 131 */ 132 132 $pre = apply_filters( "pre_option_{$option}", false, $option, $default ); 133 134 /** 135 * Filters the value of all existing options before it is retrieved. 136 * 137 * Returning a truthy value from the filter will effectively short-circuit retrieval 138 * and return the passed value instead. 139 * 140 * @since 6.1.0 141 * 142 * @param mixed $pre_option The value to return instead of the option value. This differs 143 * from `$default`, which is used as the fallback value in the event 144 * the option doesn't exist elsewhere in get_option(). 145 * Default false (to skip past the short-circuit). 146 * @param string $option Name of the option. 147 * @param mixed $default The fallback value to return if the option does not exist. 148 * Default false. 149 */ 150 $pre = apply_filters( 'pre_option', $pre, $option, $default ); 133 151 134 152 if ( false !== $pre ) { -
trunk/tests/phpunit/tests/option/option.php
r53865 r54145 298 298 ); 299 299 } 300 301 /** 302 * @ticket 37930 303 * 304 * @covers ::get_option 305 */ 306 public function test_filter_pre_option_all_filter_is_called() { 307 $filter = new MockAction(); 308 309 add_filter( 'pre_option', array( $filter, 'filter' ) ); 310 311 get_option( 'ignored' ); 312 313 $this->assertSame( 1, $filter->get_call_count() ); 314 } 300 315 }
Note: See TracChangeset
for help on using the changeset viewer.