错误:如何修复Wordpress主题的导入演示

时间:2019-01-03 19:54:11

标签: php wordpress importerror

当我以wordpress主题导入演示时,我得到了以下内容

“警告:preg_replace():不再支持/ e修饰符,而是在以下E:\ xampp \ htdocs \ wordpress \ wp-content \ themes \ random \ framework \ includes \ wpalchemy \ MetaBox.php中使用preg_replace_callback第545行”错误。

当该行的快捷方式转到

“ ///尝试修复损坏的序列化数据,特别是在wordpress XML导出(WXR)期间将“ \ r \ n”转换为“ \ n” //“ maybe_unserialize()”修复了一个wordpress错误,该错误会在导出/导入过程中对已序列化的数据进行双序列化$ value = may_unserialize(preg_replace('!s:(\ d +):“(。*?)” ;! es',“ 's:'。strlen('$ 2')。':\“ $ 2 \”;'',stripslashes($ meta ['value']))));

                        update_post_meta( $post_id, $key,  $value );" 

已经写好了。

在这种情况下要采取的纠正措施。如果保持错误没有问题,那么它将不会做任何事情,因为它可以正常工作。这是我的第一个信息,因此我将永远记住回答的人。谢谢。最好的问候

1 个答案:

答案 0 :(得分:0)

这是因为不推荐使用PHP函数。

 maybe_unserialize( preg_replace( '!s:(\d+):"(.*?)";!es', "'s:'.strlen('$2').':\"$2\";'", stripslashes( $meta['value'] ) ) )

替换为以下代码:

preg_replace_callback( '!s:(\d+):"(.*?)";!s', array( $this, 'fix_serialized_string_type_callback' ), stripslashes( $meta['value'] ) );

并在同一文件(wp-content \ themes \ random \ framework \ includes \ wpalchemy \ MetaBox.php)中添加以下功能,

protected function fix_serialized_string_type_callback( $matches ) {
        return sprintf( 's:%s:"%s";', strlen( $matches[2] ), $matches[2] );
    }

如果这不起作用,请升级您的框架。我认为框架作者已解决此问题

https://github.com/farinspace/wpalchemy/blob/master/wp-content/wpalchemy/MetaBox.php

相关问题