rebase on oct-10-2023
This commit is contained in:
@@ -1,7 +1,44 @@
|
||||
<?php
|
||||
|
||||
add_action( 'wpcf7_upgrade', 'wpcf7_upgrade_58', 10, 2 );
|
||||
|
||||
/**
|
||||
* Runs functions necessary when upgrading from old plugin versions before 5.8.
|
||||
*
|
||||
* @since 5.8.0 New `_config_validation` post meta is introduced.
|
||||
*/
|
||||
function wpcf7_upgrade_58( $new_ver, $old_ver ) {
|
||||
if ( ! version_compare( $old_ver, '5.8-dev', '<' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$posts = WPCF7_ContactForm::find( array(
|
||||
'post_status' => 'any',
|
||||
'posts_per_page' => -1,
|
||||
) );
|
||||
|
||||
foreach ( $posts as $post ) {
|
||||
$post_id = $post->id();
|
||||
|
||||
// Delete the old post meta for config-validation results.
|
||||
delete_post_meta( $post_id, '_config_errors' );
|
||||
|
||||
// Add the contact form hash.
|
||||
add_post_meta( $post_id, '_hash',
|
||||
wpcf7_generate_contact_form_hash( $post_id ),
|
||||
true // Unique
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wpcf7_upgrade', 'wpcf7_convert_to_cpt', 10, 2 );
|
||||
|
||||
/**
|
||||
* Converts old data in the dedicated database table to custom posts.
|
||||
*
|
||||
* @since 3.0.0 `wpcf7_contact_form` CPT is introduced.
|
||||
*/
|
||||
function wpcf7_convert_to_cpt( $new_ver, $old_ver ) {
|
||||
global $wpdb;
|
||||
|
||||
@@ -44,18 +81,29 @@ function wpcf7_convert_to_cpt( $new_ver, $old_ver ) {
|
||||
if ( $post_id ) {
|
||||
update_post_meta( $post_id, '_old_cf7_unit_id', $row->cf7_unit_id );
|
||||
|
||||
$metas = array( 'form', 'mail', 'mail_2', 'messages', 'additional_settings' );
|
||||
$metas = array(
|
||||
'form',
|
||||
'mail',
|
||||
'mail_2',
|
||||
'messages',
|
||||
'additional_settings',
|
||||
);
|
||||
|
||||
foreach ( $metas as $meta ) {
|
||||
update_post_meta( $post_id, '_' . $meta,
|
||||
wpcf7_normalize_newline_deep( maybe_unserialize( $row->{$meta} ) ) );
|
||||
wpcf7_normalize_newline_deep( maybe_unserialize( $row->{$meta} ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wpcf7_upgrade', 'wpcf7_prepend_underscore', 10, 2 );
|
||||
|
||||
/**
|
||||
* Prepends an underscore to post meta keys.
|
||||
*/
|
||||
function wpcf7_prepend_underscore( $new_ver, $old_ver ) {
|
||||
if ( version_compare( $old_ver, '3.0-dev', '<' ) ) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user