Site Title and Tagline in Theme Options Page

I’m using the Options Framework Theme to put together an options page. The user(s) I’m building this for would like to be able to edit a few settings directly from this page, including of which – the Site Title and Tagline.

Concept:

Read More

enter image description here

Options.php:

$options[] = array(
    'name' => __('Site Title', 'options_framework_theme'),
    'desc' => __('The name of your site.', 'options_framework_theme'),
    'id' => 'title',
    'std' => 'PHP CODE FOR SITE TITLE HERE ...',
    'class' => 'medium',
    'type' => 'text');

Is there a way to do this (add their own Site Title and Taglines) within a text-field for example, click the Save Options button to output it to the front-end of the site and display an updated version in the WP API Settings > General Settings sub-menu page?

Related posts

Leave a Reply

1 comment

  1. 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;
    }