wppaste
WordPress

apply_filters( "pre_option_{$option}", mixed $pre_option, string $option, mixed $default_value )

Since
1.5.0, 4.4.0, 4.9.0
Filters the value of an existing option before it is retrieved.

Description

The dynamic portion of the hook name, $option, refers to the option name.

Returning a value other than false from the filter will short-circuit retrieval and return that value instead.

Compatibility

WordPress
since 4.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$pre_optionmixed
The value to return instead of the option value. This differs from $default_value, which is used as the fallback value in the event the option doesn't exist elsewhere in get_option().
Default false (to skip past the short-circuit).
$optionstring
Option name.
$default_valuemixed
The fallback value to return if the option does not exist.
Default false.

Where this hook fires · 1

  • wp-includes/option.php:132get_option()

Source code

<?php	 *                              the option doesn't exist elsewhere in get_option().	 *                              Default false (to skip past the short-circuit).	 * @param string $option        Option name.	 * @param mixed  $default_value The fallback value to return if the option does not exist.	 *                              Default false.	 */	$pre = apply_filters( "pre_option_{$option}", false, $option, $default_value ); 	/**	 * Filters the value of any existing option before it is retrieved.	 *	 * Returning a value other than false from the filter will short-circuit retrieval	 * and return that value instead.

Changelog

Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

4.9.0
The $default_value parameter was added.from the docblock
4.4.0
The $option parameter was added.from the docblock
1.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.