Author: bibhu 566 views

Options specific to restropress are stored in an array in a single WordPress option. For this reason, it’s best to use rpress_get_option() to get those options. rpress_get_option() safely finds the desired option and returns it.  Additionally, it applies a filter to the output.


rpress_get_option() takes two input variables. The first is the key name of the option desired.  The second is a default value if the key is not found in the option array. The second value defaults to false.


Here’s an example, looking for the position of the currency indicator.  If it’s not found, $position will get a value of ‘before’.

$position = rpress_get_option( 'currency_position', 'before' );


The output of this function will be whatever was stored in the option, OR the default. The return function applies a filter that looks like this:

return apply_filters( 'rpress_get_option_' . $key, $value, $key, $default );

Using the example from the Usage section then the filter would be named rpress_get_option_currency_position.