ankur0101 Posted July 30, 2011 Share Posted July 30, 2011 Hi guys, I just have converted html theme into wordpres, my themes name is blue mania. All sidebars and xtra additional sidebars are done. So I headed to create Theme options. On my theme at bottom, there are 3 icons, Facebook, Twitter and FLickr. I want admin to enter their values from backend (i.e. Theme Options) Following is a code in my functions.php <?php if (get_option('bluemania_theme_options')) { $theme_options = get_option('bluemania_theme_options'); } else { add_option('bluemania_theme_options', array( 'facebook_url' => 'http://www.facebook.com/pages/xyz', 'twitter_url' => 'http://twitter.com/#!/xyz', 'flickr_url' => 'http://www.flickr.com' )); $theme_options = get_option('bluemania_theme_options'); } ?> <?php add_action('admin_menu', 'theme_page_add'); function theme_page_add() { add_submenu_page('themes.php', 'Theme Options', 'Theme Options', 8, 'themeoptions', 'theme_page_options'); } function theme_page_options(){ global $theme_options; $new_values = array ( 'facebook_url' => htmlentities($_POST['facebook_url'], ENT_QUOTES), 'twitter_url' => htmlentities($_POST['twitter_url'], ENT_QUOTES), 'flickr_url' => htmlentities($_POST['flickr_url'], ENT_QUOTES) ); update_option('bluemania_theme_options', $new_values); $theme_options = $new_values; echo '<div>'; echo '<h2>Blue Mania Theme Options</h2>'; ?> <form id="form1" name="form1" method="post" action="themes.php?page=themeoptions"> <label for="facebook_url">Facebook URL : <input type="text" name="facebook_url" id="facebook_url" value="<?php echo $theme_options['facebook_url']; ?>"/> </label> <p> <label for="twitter_url">Twitter URL : <input type="text" name="twitter_url" id="twitter_url" value="<?php echo $theme_options['twitter_url']; ?>"/> </label> </p> <p> <label for="flickr_url">Flickr URL : <input type="text" name="flickr_url" id="flickr_url" value="<?php echo $theme_options['flickr_url']; ?>"/> </label> </p> <p> <label> <input type="submit" name="submit" id="submit" value="Update Options" /> </label> </p> </form> <?php echo '<>'; } ?> So problem starts here >> I go to Theme Options I enter links I press update button. I refresh my wordpres home page to check whether given entered vales are giving output or not. It gives output. I come back to admin part and again click on Theme options. Now in those 3 text box, it should fetch data which I have already entered but it shows nothing in textbox. I dont click on Update Button. I just go to my wordpress home url and refresh and that previous links disappeared. Conclusion : After entering values on keyboard and submitting, it just wipe outs entered values from database once I open theme options again. Whats wrong in code ? Link to comment https://forums.phpfreaks.com/topic/243279-wordpress-theme-options-bug/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.