13 add_action(
'wp_import_post_meta',
'gravityview_import_helper_fix_line_breaks', 10, 3 );
51 if ( empty(
$post[
'postmeta'] ) ) {
55 if (
'gravityview' !==
$post[
'post_type'] ) {
60 '_gravityview_directory_fields',
61 '_gravityview_directory_widgets',
64 $performed_fix =
false;
66 foreach ( $postmeta as &$meta ) {
69 if ( ! in_array( $key, $keys_to_fix,
true ) ) {
73 $is_valid_serialized_data = maybe_unserialize( $meta[
'value'] );
76 if (
false !== $is_valid_serialized_data ) {
80 $meta[
'value'] = str_replace(
"\n",
"\n\n", $meta[
'value'] );
82 $performed_fix =
true;
86 if ( $performed_fix ) {
88 'key' =>
'_gravityview_fixed_import_serialization',
96 add_action(
'import_post_meta',
'gravityview_import_helper_restore_line_breaks', 10, 3 );
111 $keys_to_fix = array(
112 '_gravityview_directory_fields',
113 '_gravityview_directory_widgets',
116 if ( ! in_array( $key, $keys_to_fix,
true ) ) {
120 if (
false === get_post_meta( $post_id,
'_gravityview_fixed_import_serialization' ) ) {
128 if (
false === strpos(
$value,
"\n\n" ) ) {
133 $updated_value = str_replace(
"\n\n",
"\n",
$value );
135 update_post_meta( $updated_value, $key, $updated_value );
gravityview_import_helper_fix_line_breaks( $postmeta=array(), $post_id=0, $post=array())
Fixes broken serialization character counts when new line characters are in the exported XML...
gravityview_import_helper_restore_line_breaks( $post_id, $key, $value)
Restores the single new line for imported Views that have been modified.