2011-05-06 43 views
0

我對構建到我的主題中的導入/導出選項有點麻煩。希望我解釋得很好,讓我從這個函數開始。在WordPress導入設置函數中update_option()的問題

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返回$options的串行化輸出(其用戶進入在我的選擇面板一個textarea),我已經測試了$options_array正確反序列化導入碼,因爲它打印如下:

陣列([if_menu_color] =>粉紅[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_linke囂] => [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] =>帖[if_slider_placement] =>設有 [if_slider_category] ​​=> [if_slider_posts_number] => [if_slider_height] => [if_slider_delay] => [if_slider_animation] =>隨機 [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)

所以我有新的數組需要寫入我的選項,但我使用的update_options代碼不起作用。我錯過了什麼?

回答

1

$ options_array = unserialize($ importOptions);

foreach ($options_array as $option_name=>$value) { 
    if ($value != '') update_option($key, $value); 
} 
相關問題