Skip to content

Commit

Permalink
Prevent form creation attempts if WPForms Lite version is < 1.5.2
Browse files Browse the repository at this point in the history
Creating a working form via the WPForms API requires 1.5.2 or higher.

If the site already has WPForms Lite installed but it's an older
version, form creation will fail, breaking the onboarding process.
  • Loading branch information
nickcernis authored and dreamwhisper committed May 1, 2019
1 parent ad63d66 commit 6ef3b1d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/wpforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ function studiopress_maybe_create_wpforms_form() { // phpcs:ignore -- studiopres
return;
}

// Form creation requires WPForms 1.5.2 or higher.
// If the site already as an earlier version of the plugin installed, don't create a form.
// Plugins do not get upgraded during one-click theme setup.
if ( function_exists( 'get_plugins' ) ) {
$plugin_data = get_plugins();
$wpforms_lite_version = isset( $plugin_data['wpforms-lite/wpforms.php']['Version'] ) ? $plugin_data['wpforms-lite/wpforms.php']['Version'] : '';

if ( version_compare( $wpforms_lite_version, '1.5.2', '<' ) ) {
return;
}
}

$existing_form_id = get_option( 'genesis_onboarding_wpforms_id' );

if ( $existing_form_id ) {
Expand Down

0 comments on commit 6ef3b1d

Please sign in to comment.