Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have problem with my theme options settings saving.

My settings is to saving to permanently , its just only save when you stay on the theme options page after saving the settings. But when I go to any other page or reload the current page the settings disappeared.

HERE is Code

    function theme_options_do_page() {
        global  $theme_options, $icons_options, $new_values, $shortname, $values_array;

        if( !isset( $_REQUEST['submit'] ) ) {
            $_REQUEST['submit'] = false;
        }
    $values_array = array(
     array( 
               "name" => "Footer copyright text:",
               "desc" => "Enter text in the footer.",
               "id" => "footer_text",
               "type" => "text",
               "std" => array ('footer_text'=>$_POST['footer_text'],)
             ),
     array( 
               "name" => "Facebook URL :",
               "desc" => "Enter your Facebook URL here.",
               "id" => 'facebook',
               "type" => "text",
               "std" => array ('facebook'=>$_POST['facebook'],)
             ),
     array( 
               "name" => "Twitter URL :",
               "desc" => "Enter your Twitter URL here.",
               "id" => 'twitter',
               "type" => "text",
               "std" => array ('twitter'=>$_POST['twitter'],)
             ),
     array( 
               "name" => "Google+ URL :",
               "desc" => "Enter your Google+ URL here.",
               "id" => 'google',
               "type" => "text",
               "std" => array ('google'=>$_POST['google'],)
             ),
     array( 
               "name" => "Instagram URL :",
               "desc" => "Enter your Instagram URL here.",
               "id" => 'instagram',
               "type" => "text",
               "std" => array ('instagram'=>$_POST['instagram'],)
             ),
     array( 
               "name" => "Linkedin URL :",
               "desc" => "Enter your Linkedin URL here.",
               "id" => 'linkedin',
               "type" => "text",
               "std" => array ('linkedin'=>$_POST['linkedin'],)
             ),
     array( 
               "name" => "Pinterest URL :",
               "desc" => "Enter your Pinterest URL here.",
               "id" => 'pinterest',
               "type" => "text",
               "std" => array ('pinterest'=>$_POST['pinterest'],)
             ),
     array( 
               "name" => "Rss URL :",
               "desc" => "Enter your Rss URL here.",
               "id" => 'rss',
               "type" => "text",
               "std" => array ('rss'=>$_POST['rss'],)
             ),
     array( 
               "name" => "Stumbleupon URL :",
               "desc" => "Enter your Stumbleupon URL here.",
               "id" => 'stumbleupon',
               "type" => "text",
               "std" => array ('stumbleupon'=>$_POST['stumbleupon'],)
             ),
     array( 
               "name" => "Vimeo URL :",
               "desc" => "Enter your Vimeo URL here.",
               "id" => 'vimeo',
               "type" => "text",
               "std" => array ('vimeo'=>$_POST['vimeo'],)
             ),
     array( 
               "name" => "YouTube URL :",
               "desc" => "Enter your YouTube URL here.",
               "id" => 'youtube',
               "type" => "text",
               "std" => array ('youtube'=>$_POST['youtube'],)
             ),
        );
if ( $_GET['page'] == basename(__FILE__) ) {



        if (isset ( $_POST[ 'submit' ] ) ) {
            update_option( 'new_theme_options', serialize( $values_array )); 
        } 
    $theme_options = get_option('new_theme_options',false);
    $theme_values = unserialize($theme_options);

}

    if (isset ($_POST['submit'])) {
            $icons_size = array (
                'width'=>$_POST['width'],
                'height'=>$_POST['height'],
            );
            update_option('social_settings_responsivetheme_options', serialize($icons_size));
    };
    $icons_options = get_option('social_settings_responsivetheme_options');
    $icons_values = unserialize($icons_options);

    ?>
    <?php if( false !== $_REQUEST['submit'] ) : ?>
        <div class="updated fade"><p><strong><?php _e( 'Options Saved', 'responsivetheme' ); ?></strong></p></div>
    <?php endif; ?>
        <div class="wrap">
        <?php $theme_name = wp_get_theme() ?>
        <?php screen_icon(); echo "<h2>" . $theme_name . __( ' Options', 'responsivetheme' ) . "</h2>"; ?>




<form method="post" action="themes.php?page=theme-options.php">
<?php foreach ($values_array as  $value) {

?>
<table width="100%" border="0" style=" padding:10px;">
<?php 

?>

<?php 
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php foreach ($value['std'] as $key){echo $key;}?>" /></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>


<?php

}//end foreach
?>
</table>
    <p class="submit">
             <input type="submit" name="submit" class="button-primary"  id="submit" value="<?php _e( 'Save Options', 'responsivetheme' ); ?>" />
        </p>
    </form>
</div>

I hope I will get my problems solution.

Many thanks in advance.

share|improve this question

migrated from stackoverflow.com Mar 29 at 14:39

This question came from our site for professional and enthusiast programmers.

    
No one is answering ??? :( –  Mr.beginner Mar 29 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.