wpcf7_upgrade_58()CF7 5.8.0

Runs functions necessary when upgrading from old plugin versions before 5.8.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wpcf7_upgrade_58( $new_ver, $old_ver );
$new_ver (обязательный)
-
$old_ver (обязательный)
-

Список изменений

С версии 5.8.0 Введена.
С версии 5.8.0 New _config_validation post meta is introduced.

Код wpcf7_upgrade_58() CF7 5.8

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
		);
	}
}