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
的序列化输出(用户将其输入到我的选项面板中的文本区域中),并且我已经测试了 $options_array
正确反序列化导入代码,因为它打印以下内容:
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_linkedin] => [if_youtube] => [if_googlemaps] => [if_email] => [if_rsslink] => [if_home_描述] => [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 代码不起作用。我缺少什么?
I am 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 update_options code I've used isn't working. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$options_array = 反序列化($importOptions);
$options_array = unserialize($importOptions);