| @@ -2,15 +2,14 @@ | ||
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * Plugin Name: Bit Form |
| 5 | 5 | * Plugin URI: https://www.bitapps.pro/bit-form |
| 6 | - * Description: Contact Form Builder Plugin: Multi Step Contact Form, Payment Form, Custom Contact Form Plugin by Bit Form | |
| 7 | - * Version: 3.2.2 | |
| 8 | - * Author: Contact Form Builder - Bit Form | |
| 6 | + * Description: Contact Form Builder: Multi Step Contact form, Payment form, WPForm Calculator form, Registration Form & WP Forms with form integrations | |
| 7 | + * Version: 2.7.0 | |
| 8 | + * Author: Contact Form Builder Plugin - WPForm by Bit Form | |
| 9 | 9 | * Author URI: https://www.bitapps.pro |
| 10 | 10 | * Text Domain: bit-form |
| 11 | - * Requires at least: 6.4 | |
| 12 | - * Requires PHP: 7.4 | |
| 11 | + * Requires PHP: 5.6 | |
| 13 | 12 | * Domain Path: /languages |
| 14 | 13 | * License: GPLv2 or later |
| 15 | 14 | */ |
| 16 | 15 | |
| @@ -21,23 +20,35 @@ | ||
| 21 | 20 | exit; |
| 22 | 21 | } |
| 23 | 22 | |
| 24 | 23 | // Define most essential constants. |
| 25 | -define('BITFORMS_VERSION', '3.2.2'); | |
| 24 | +define('BITFORMS_VERSION', '2.7.0'); | |
| 26 | 25 | define('BITFORMS_PLUGIN_MAIN_FILE', __FILE__); |
| 27 | -define('BITFORMS_REQUIRED_BITFORMPRO_VERSION', '3.2.1'); | |
| 28 | 26 | |
| 29 | 27 | global $bitforms_db_version; |
| 30 | -$bitforms_db_version = '3.2'; | |
| 31 | -define('BITFORMS_DB_VERSION', $bitforms_db_version); | |
| 32 | -define('BITFORMS_REQUIRED_WP_VERSION', '5.1'); | |
| 33 | -define('BITFORMS_REQUIRED_PHP_VERSION', '7.4'); | |
| 34 | -define('BITFORMS_API_VERSION', '1.0'); | |
| 28 | +$bitforms_db_version = '2.2'; | |
| 35 | 29 | |
| 36 | 30 | if (version_compare(PHP_VERSION, '5.6.0', '>=')) { |
| 37 | - require_once plugin_dir_path(__FILE__) . 'includes/loader.php'; | |
| 31 | + $rootVersionFolder = ''; | |
| 32 | + $olderVersion = get_option('bitforms_version'); | |
| 33 | + if ('2.0-beta.1' === $olderVersion) { | |
| 34 | + update_option('bitforms_migrated_to_v2', true); | |
| 35 | + update_option('bitforms_migrating_to_v2', false); | |
| 36 | + } | |
| 37 | + $isMigratedToV2 = get_option('bitforms_migrated_to_v2'); | |
| 38 | + $isMigratingToV2 = get_option('bitforms_migrating_to_v2'); | |
| 39 | + | |
| 40 | + if (!$isMigratingToV2 && !$isMigratedToV2) { | |
| 41 | + global $wpdb; | |
| 42 | + $oldForms = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}bitforms_form"); | |
| 43 | + if (count($oldForms) > 0) { | |
| 44 | + $rootVersionFolder = 'v1/'; | |
| 45 | + } else { | |
| 46 | + update_option('bitforms_migrated_to_v2', true); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + require_once plugin_dir_path(__FILE__) . $rootVersionFolder . 'includes/loader.php'; | |
| 38 | 50 | } |
| 39 | - | |
| 40 | 51 | /** |
| 41 | 52 | * Handles plugin activation. |
| 42 | 53 | * |
| 43 | 54 | * Throws an error if the plugin is activated on an older version than PHP 5.6. |
| @@ -45,10 +56,10 @@ | ||
| 45 | 56 | function bitforms_activate_plugin($network_wide) |
| 46 | 57 | { |
| 47 | 58 | if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
| 48 | 59 | wp_die( |
| 49 | - 'Bit Form requires PHP version 5.6 or higher.', | |
| 50 | - 'Error Activating' | |
| 60 | + esc_html__('bitforms requires PHP version 5.6.', 'bit-form'), | |
| 61 | + esc_html__('Error Activating', 'bit-form') | |
| 51 | 62 | ); |
| 52 | 63 | } |
| 53 | 64 | |
| 54 | 65 | do_action('bitforms_activation', $network_wide); |
| @@ -83,129 +94,4 @@ | ||
| 83 | 94 | |
| 84 | 95 | do_action('bitforms_uninstall'); |
| 85 | 96 | } |
| 86 | 97 | register_uninstall_hook(__FILE__, 'bitforms_uninstall_plugin'); |
| 87 | - | |
| 88 | -add_action('plugins_loaded', 'bitforms_check_pro_version'); | |
| 89 | - | |
| 90 | -function bitforms_check_pro_version() | |
| 91 | -{ | |
| 92 | - if (!defined('BITFORMPRO_VERSION')) { | |
| 93 | - return; | |
| 94 | - } | |
| 95 | - if (!version_compare(BITFORMPRO_VERSION, BITFORMS_REQUIRED_BITFORMPRO_VERSION, '>=')) { | |
| 96 | - add_action('admin_notices', 'bitformsProUpgradeNotice'); | |
| 97 | - } | |
| 98 | -} | |
| 99 | - | |
| 100 | -function bitformsProUpgradeNotice() | |
| 101 | -{ | |
| 102 | - // user meta calls safe here — admin_notices fires well after user initialisation | |
| 103 | - $dismissed_for = get_user_meta(get_current_user_id(), 'bitforms_dismiss_pro_upgrade_notice', true); | |
| 104 | - if (BITFORMS_REQUIRED_BITFORMPRO_VERSION === $dismissed_for) { | |
| 105 | - return; | |
| 106 | - } | |
| 107 | - | |
| 108 | - // "Update now" routes through bitforms_force_pro_update_check(), which busts the cached | |
| 109 | - // update data before handing off to WordPress core's native plugin-update flow | |
| 110 | - // (Plugin_Upgrader: maintenance mode, filesystem creds, rollback UI). Going straight to | |
| 111 | - if (current_user_can('update_plugins')) { | |
| 112 | - $update_url = wp_nonce_url( | |
| 113 | - admin_url('admin-post.php?action=bitforms_force_pro_update_check'), | |
| 114 | - 'bitforms_force_pro_update_check' | |
| 115 | - ); | |
| 116 | - } else { | |
| 117 | - // Users who cannot update plugins: send them to the Updates screen with a forced | |
| 118 | - // refresh so Bit Form Pro's Updater re-checks and stages the update for detection. | |
| 119 | - $update_url = self_admin_url('update-core.php?force-check=1'); | |
| 120 | - } | |
| 121 | - $required = esc_html(BITFORMS_REQUIRED_BITFORMPRO_VERSION); | |
| 122 | - | |
| 123 | - // Keep HTML out of translatable strings to prevent translator HTML injection | |
| 124 | - $message = '<strong>' . esc_html__('Bit Form Pro', 'bit-form') . '</strong> ' | |
| 125 | - . sprintf( | |
| 126 | - /* translators: %s: minimum required version number */ | |
| 127 | - esc_html__('requires an update to version %s or higher for full compatibility.', 'bit-form'), | |
| 128 | - '<strong>' . $required . '</strong>' | |
| 129 | - ) | |
| 130 | - . ' <a href="' . esc_url($update_url) . '">' . esc_html__('Update now', 'bit-form') . '</a>'; | |
| 131 | - | |
| 132 | - wp_admin_notice( | |
| 133 | - $message, | |
| 134 | - [ | |
| 135 | - 'type' => 'error', | |
| 136 | - 'dismissible' => true, | |
| 137 | - 'additional_classes' => ['bitforms-pro-upgrade-notice'], | |
| 138 | - 'attributes' => [ | |
| 139 | - 'data-nonce' => wp_create_nonce('bitforms_dismiss_pro_notice'), | |
| 140 | - 'data-ajax-url' => esc_url(admin_url('admin-ajax.php')), | |
| 141 | - ], | |
| 142 | - 'paragraph_wrap' => true, | |
| 143 | - ] | |
| 144 | - ); | |
| 145 | - | |
| 146 | - // Script at footer — avoids mid-page inline script | |
| 147 | - add_action('admin_footer', 'bitformsProUpgradeNoticeScript'); | |
| 148 | -} | |
| 149 | - | |
| 150 | -add_action('admin_post_bitforms_force_pro_update_check', 'bitforms_force_pro_update_check'); | |
| 151 | - | |
| 152 | -/** | |
| 153 | - * Force a fresh Bit Form Pro update check, then hand off to core's plugin upgrader. | |
| 154 | - */ | |
| 155 | -function bitforms_force_pro_update_check() | |
| 156 | -{ | |
| 157 | - if (!current_user_can('update_plugins')) { | |
| 158 | - wp_die( | |
| 159 | - esc_html__('You are not allowed to update plugins on this site.', 'bit-form'), | |
| 160 | - esc_html__('Bit Form', 'bit-form'), | |
| 161 | - ['response' => 403] | |
| 162 | - ); | |
| 163 | - } | |
| 164 | - check_admin_referer('bitforms_force_pro_update_check'); | |
| 165 | - | |
| 166 | - $pro_plugin_file = 'bitformpro/bitformpro.php'; | |
| 167 | - | |
| 168 | - // Drop Bit Form Pro's cached version lookup. | |
| 169 | - delete_option(md5(sanitize_key('bitformpro') . '_plugin_info')); | |
| 170 | - delete_site_transient('bitformpro_api_request_' . md5(serialize('bitformpro'))); | |
| 171 | - delete_site_transient('update_plugins'); | |
| 172 | - | |
| 173 | - // Let Pro (or any add-on) flush additional update caches without another Free release. | |
| 174 | - do_action('bitforms_force_pro_update_check'); | |
| 175 | - | |
| 176 | - if (function_exists('wp_update_plugins')) { | |
| 177 | - wp_update_plugins(); | |
| 178 | - } | |
| 179 | - | |
| 180 | - // Build the URL with add_query_arg() | |
| 181 | - $upgrade_url = add_query_arg( | |
| 182 | - [ | |
| 183 | - 'action' => 'upgrade-plugin', | |
| 184 | - 'plugin' => $pro_plugin_file, | |
| 185 | - '_wpnonce' => wp_create_nonce('upgrade-plugin_' . $pro_plugin_file), | |
| 186 | - ], | |
| 187 | - self_admin_url('update.php') | |
| 188 | - ); | |
| 189 | - | |
| 190 | - wp_safe_redirect($upgrade_url); | |
| 191 | - exit; | |
| 192 | -} | |
| 193 | - | |
| 194 | -function bitformsProUpgradeNoticeScript() | |
| 195 | -{ | |
| 196 | - ?> | |
| 197 | - <script> | |
| 198 | - (function () { | |
| 199 | - var notice = document.querySelector('.bitforms-pro-upgrade-notice'); | |
| 200 | - if (!notice) return; | |
| 201 | - notice.addEventListener('click', function (e) { | |
| 202 | - if (!e.target.classList.contains('notice-dismiss')) return; | |
| 203 | - var fd = new FormData(); | |
| 204 | - fd.append('action', 'bitforms_dismiss_pro_notice'); | |
| 205 | - fd.append('nonce', notice.dataset.nonce); | |
| 206 | - fetch(notice.dataset.ajaxUrl, { method: 'POST', credentials: 'same-origin', body: fd }); | |
| 207 | - }); | |
| 208 | - }()); | |
| 209 | - </script> | |
| 210 | - <?php | |
| 211 | -} | |