简体   繁体   中英

Error: How to fix import demo for wordpress theme

while i import demo in wordpress theme, i got the following

"Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in E:\\xampp\\htdocs\\wordpress\\wp-content\\themes\\random\\framework\\includes\\wpalchemy\\MetaBox.php on line 545" error.

When the line of the shortcut to go to the

"// try to fix corrupted serialized data, specifically "\\r\\n" being converted to "\\n" during wordpress XML export (WXR) // "maybe_unserialize()" fixes a wordpress bug which double serializes already serialized data during export/import $value = maybe_unserialize( preg_replace( '!s:(\\d+):"(.*?)";!es', "'s:'.strlen('$2').':\\"$2\\";'", stripslashes( $meta['value'] ) ) );

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

was already written.

What to do to be corrected in this case. if there is no problem in staying the error, it will not do anything because it works theme. This was my first message so I will always remember the person who answered. thank you. Best regards

This is because of PHP Deprecated function usage.

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

Replace with below code:

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

And add below function in same file (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] );
    }

If this is not work upgrade your framework. I think framework author fixed this issue

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM