The framework offers a filter for validating input values inside the optionsframework_validate
function.
Just for reference, here's the relevant part from the file wp-content/themes/your-theme/inc/options-framework.php
:
/**
* Validate Options.
*
* This runs after the submit/reset button has been clicked and
* validates the inputs.
*/
function optionsframework_validate( $input ) {
/* code */
$clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option );
/* code */
So, considering that we have the following options in the file wp-content/themes/your-theme/options.php
:
$options[] = array(
'name' => __('Input Text Mini', 'options_framework_theme'),
'desc' => __('A mini text input field.', 'options_framework_theme'),
'id' => 'blogname',
'std' => 'Default',
'class' => 'mini',
'type' => 'text');
$options[] = array(
'name' => __('Input Text', 'options_framework_theme'),
'desc' => __('A text input field.', 'options_framework_theme'),
'id' => 'blogdescription',
'std' => 'Default Value',
'type' => 'text');
And in wp-content/themes/your-theme/functions.php
, we filter the text
input type (of_sanitize_
+ text
) and if it matches our defined ids (blogname
and blogdescription
, just like in General Settings), it will update the site options that have the same id.
Please note, that this doesn't work the other way around: changes made in Settings -> General
won't be reflected inside the theme options page...
add_filter( 'of_sanitize_text', 'wpse_77233_framework_to_settings', 10, 2 );
function wpse_77233_framework_to_settings( $input, $option )
{
if( 'blogname' == $option['id'] )
update_option( 'blogname', sanitize_text_field( $input ) );
if( 'blogdescription' == $option['id'] )
update_option( 'blogdescription', sanitize_text_field( $input ) );
return $input;
}