Skip to content
Docs
Get RestroPress

Filter

rpress_get_option

Updated
On this page

Filters the value returned by rpress_get_option() for any setting.

Runs on every rpress_get_option() call, after the stored value is read from the settings array. If the stored value is empty, the supplied default is already in place when the filter runs. The key-specific filter rpress_get_option_{$key} runs next.

Parameters#

ParameterTypeDescription
$valuemixedThe stored value, or the default when the stored value is empty.
$keystringThe option key.
$defaultmixedThe default passed to rpress_get_option().

Return value#

mixed. The option value.

Example#

function my_force_currency_option( $value, $key, $default ) {
	if ( 'currency' === $key && defined( 'MY_STORE_CURRENCY' ) ) {
		return MY_STORE_CURRENCY;
	}
	return $value;
}
add_filter( 'rpress_get_option', 'my_force_currency_option', 10, 3 );

Notes#

Runs on every option read, which is frequent. Keep callbacks light.

Source#

Applied in:

  • includes/admin/settings/register-settings.php (line 27), in rpress_get_option()

See also#

Was this page helpful?