• Resolved SeizedPropaganda

    (@seizedpropaganda)


    Hey everyone, I’m having a bit of trouble with an import/export option I’m building into my theme. Hopefully I explain this well, let me start with the function.

    function ifeature_import_options() {
    	$options = get_option('ifeature');
    	$import = $options['if_import_code'];
    
    	if ($import != '');
    		$options_array = (unserialize($import));
    			foreach( $options_array as $option_name => $option_value ) {
    			update_option( $option_name, $option_value );
    			}
    }

    if_import_code returns the serialized output of $options (which the user enters into a textarea in my options panel), and I’ve tested that $options_array is properly unserializing the import code as it prints the following:

    Array ( [if_menu_color] => Pink [if_font] => Arial [if_css_options] => [if_favicon] => [if_ga_code] => [if_import_code] => [if_export_code] => b:0; [if_logo] => [if_menuicon] => [if_header_contact] => [if_facebook] => [if_twitter] => [if_linkedin] => [if_youtube] => [if_googlemaps] => [if_email] => [if_rsslink] => [if_home_description] => [if_home_keywords] => [if_home_title] => [if_callout_title] => [if_callout_text] => [if_callout_img] => [if_callout_image_link] => [if_slider_type] => posts [if_slider_placement] => feature [if_slider_category] => [if_slider_posts_number] => [if_slider_height] => [if_slider_delay] => [if_slider_animation] => random [if_footer_text] => [if_hide_callout] => 0 [if_show_fb_like] => 0 [if_hide_slider] => 0 [if_hide_boxes] => 0 [if_hide_link] => 0 [if_slider_navigation] => 0 )

    So I have the new array that needs to be written to my options, but the option_update code I’ve used isn’t working. What am I missing?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter SeizedPropaganda

    (@seizedpropaganda)

    Sorry for the bump but I’m still having trouble with update_option. I’ve tried a couple different variations of my function, all to no avail.

    I’ve echoed $option_name and $option_value and it’s giving the correct output:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    However, update_option just doesn’t seem to be writing the options properly. Can anyone see what I’m missing?

    Thread Starter SeizedPropaganda

    (@seizedpropaganda)

    Sorry for not using pastebin, I will do so in the future.

    I just wanted to update that I have resolved the issue myself, thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘trouble with update_option()’ is closed to new replies.