从数据库条目

时间:2015-10-14 17:04:43

标签: html sql database wordpress

我做了WP网站的迁移 - 转移了所有文件和数据库,配置了设置,更新了网址。一切正常,除了一个特定的数据库条目:wp_options et_divi,主题存储一些自定义元数据和其他主题设置。

问题在于,当我更新此字段中存储的任何设置时,它会与所有html标记一起存储,并删除/更改其他代码。

例如,此Google Analytics代码:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'xxxxxxxx', 'auto');
  ga('send', 'pageview');

</script>

存储方式如下:

s:409:"
  (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\');

  ga(\'create\', \'xxxxxxxx\', \'auto\');
  ga(\'send\', \'pageview\');

";

正在删除所有HTML标记,并且正在合并一些斜杠。

我认为这可能是格式/编码问题,但我真的不知道该怎么做。当我备份数据库时,我选择了SQL格式的PhpMyAdmin快速导出选项,当我在新服务器中恢复它时,我使用了带有utf-8,SQL格式和NONE SQL兼容模式选项的导入选项。

但请注意,当我更新此字段中的任何条目时(通过主题的设置页面 - 如果我手动恢复该字段,一切都恢复正常),它只会被弄乱。

那么,谁知道这里会发生什么?

更新1:我尝试停用所有插件和自定义功能,但同样的情况仍然存在。

更新2 :这是将表单字段存储到“正文代码集成”的数组,用于上面的Google Analytics代码(文件是options_divi.php):

array( "name" => esc_html__("Add code to the < body > (good for tracking codes such as google analytics)",$themename),
                   "id" => $shortname."_integration_body",
                   "type" => "textarea",
                   "std" => "",
                   "desc" => esc_html__("Any code you place here will appear in body section of all pages of your blog. This is usefull if you need to input a tracking pixel for a state counter such as Google Analytics.",$themename)
            ),

更新3 :这是上面文件的标题(开头)(options_divi.php)。我不知道它是否可以提供帮助,但是像“htmlspecialchars”这样的术语引起了我的注意(不知道它是否有价值,无论如何)。

<?php
global $epanelMainTabs, $themename, $shortname, $options;

$epanelMainTabs = array('general','navigation','layout','ad','seo','integration','support');

$cats_array = get_categories('hide_empty=0');
$pages_array = get_pages('hide_empty=0');
$pages_number = count($pages_array);

$site_pages = array();
$site_cats = array();
$pages_ids = array();
$cats_ids = array();

foreach ($pages_array as $pagg) {
    $site_pages[$pagg->ID] = htmlspecialchars($pagg->post_title);
    $pages_ids[] = $pagg->ID;
}

foreach ($cats_array as $categs) {
    $site_cats[$categs->cat_ID] = $categs->cat_name;
    $cats_ids[] = $categs->cat_ID;
}

$shortname  = esc_html( $shortname );
$pages_ids  = array_map( 'intval', $pages_ids );
$cats_ids   = array_map( 'intval', $cats_ids );

$options = array ( //... the code goes on with the options arrays

如果您需要更多代码/信息,请告诉我: - )

0 个答案:

没有答案
相关问题