Current Path : /storage/v11800/affypharma/public_html/wp-content/plugins/mailchimp-for-wp/includes/admin/migrations/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/affypharma/public_html/wp-content/plugins/mailchimp-for-wp/includes/admin/migrations/4.0.0-hidden-fields-value-delimiter.php |
<?php
defined( 'ABSPATH' ) or exit;
/** @ignore */
function _mc4wp_400_replace_comma_with_pipe( $matches ) {
$old = $matches[1];
$new = str_replace( ',', '|', $old );
return str_replace( $old, $new, $matches[0] );
}
// get all forms
$posts = get_posts(
array(
'post_type' => 'mc4wp-form',
'numberposts' => -1,
)
);
foreach ( $posts as $post ) {
// find hidden field values in form and pass through replace function
$old = $post->post_content;
$new = preg_replace_callback( '/type="hidden" .* value="(.*)"/i', '_mc4wp_400_replace_comma_with_pipe', $old );
// update post if we replaced something
if ( $new != $old ) {
$post->post_content = $new;
wp_update_post( $post );
}
}