| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Bit Form |
| 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.1 |
| 8 |
* Author: Contact Form Builder - Bit Form |
| 9 |
* Author URI: https://www.bitapps.pro |
| 10 |
* Text Domain: bit-form |
| 11 |
* Requires at least: 6.4 |
| 12 |
* Requires PHP: 7.4 |
| 13 |
* Domain Path: /languages |
| 14 |
* License: GPLv2 or later |
| 15 |
*/ |
| 16 |
|
| 17 |
/*** |
| 18 |
* If try to direct access plugin folder it will Exit |
| 19 |
**/ |
| 20 |
if (!defined('ABSPATH')) { |
| 21 |
exit; |
| 22 |
} |
| 23 |
|
| 24 |
// Define most essential constants. |
| 25 |
define('BITFORMS_VERSION', '3.2.1'); |
| 26 |
define('BITFORMS_PLUGIN_MAIN_FILE', __FILE__); |
| 27 |
define('BITFORMS_REQUIRED_BITFORMPRO_VERSION', '3.2.1'); |
| 28 |
|
| 29 |
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'); |
| 35 |
|
| 36 |
if (version_compare(PHP_VERSION, '5.6.0', '>=')) { |
| 37 |
require_once plugin_dir_path(__FILE__) . 'includes/loader.php'; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Handles plugin activation. |
| 42 |
* |
| 43 |
* Throws an error if the plugin is activated on an older version than PHP 5.6. |
| 44 |
*/ |
| 45 |
function bitforms_activate_plugin($network_wide) |
| 46 |
{ |
| 47 |
if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
| 48 |
wp_die( |
| 49 |
'Bit Form requires PHP version 5.6 or higher.', |
| 50 |
'Error Activating' |
| 51 |
); |
| 52 |
} |
| 53 |
|
| 54 |
do_action('bitforms_activation', $network_wide); |
| 55 |
} |
| 56 |
|
| 57 |
register_activation_hook(__FILE__, 'bitforms_activate_plugin'); |
| 58 |
|
| 59 |
/** |
| 60 |
* Handles plugin deactivation. |
| 61 |
*/ |
| 62 |
function bitforms_deactivate_plugin($network_wide) |
| 63 |
{ |
| 64 |
if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
do_action('bitforms_deactivation', $network_wide); |
| 69 |
} |
| 70 |
|
| 71 |
register_deactivation_hook(__FILE__, 'bitforms_deactivate_plugin'); |
| 72 |
|
| 73 |
/** |
| 74 |
* Handles plugin uninstall. |
| 75 |
* |
| 76 |
* @access private |
| 77 |
*/ |
| 78 |
function bitforms_uninstall_plugin() |
| 79 |
{ |
| 80 |
if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
| 81 |
return; |
| 82 |
} |
| 83 |
|
| 84 |
do_action('bitforms_uninstall'); |
| 85 |
} |
| 86 |
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" triggers WordPress core's native plugin-update flow (Plugin_Upgrader: |
| 109 |
// maintenance mode, filesystem creds, rollback UI) for users who can update plugins. |
| 110 |
// Others fall back to the filtered Plugins screen. The update itself is staged into the |
| 111 |
// update_plugins transient by Bit Form Pro's own Updater. |
| 112 |
$pro_plugin_file = 'bitformpro/bitformpro.php'; |
| 113 |
if (current_user_can('update_plugins')) { |
| 114 |
$update_url = wp_nonce_url( |
| 115 |
self_admin_url('update.php?action=upgrade-plugin&plugin=' . $pro_plugin_file), |
| 116 |
'upgrade-plugin_' . $pro_plugin_file |
| 117 |
); |
| 118 |
} else { |
| 119 |
// Users who cannot update plugins: send them to the Updates screen with a forced |
| 120 |
// refresh so Bit Form Pro's Updater re-checks and stages the update for detection. |
| 121 |
$update_url = self_admin_url('update-core.php?force-check=1'); |
| 122 |
} |
| 123 |
$required = esc_html(BITFORMS_REQUIRED_BITFORMPRO_VERSION); |
| 124 |
|
| 125 |
// Keep HTML out of translatable strings to prevent translator HTML injection |
| 126 |
$message = '<strong>' . esc_html__('Bit Form Pro', 'bit-form') . '</strong> ' |
| 127 |
. sprintf( |
| 128 |
/* translators: %s: minimum required version number */ |
| 129 |
esc_html__('requires an update to version %s or higher for full compatibility.', 'bit-form'), |
| 130 |
'<strong>' . $required . '</strong>' |
| 131 |
) |
| 132 |
. ' <a href="' . esc_url($update_url) . '">' . esc_html__('Update now', 'bit-form') . '</a>'; |
| 133 |
|
| 134 |
wp_admin_notice( |
| 135 |
$message, |
| 136 |
[ |
| 137 |
'type' => 'error', |
| 138 |
'dismissible' => true, |
| 139 |
'additional_classes' => ['bitforms-pro-upgrade-notice'], |
| 140 |
'attributes' => [ |
| 141 |
'data-nonce' => wp_create_nonce('bitforms_dismiss_pro_notice'), |
| 142 |
'data-ajax-url' => esc_url(admin_url('admin-ajax.php')), |
| 143 |
], |
| 144 |
'paragraph_wrap' => true, |
| 145 |
] |
| 146 |
); |
| 147 |
|
| 148 |
// Script at footer — avoids mid-page inline script |
| 149 |
add_action('admin_footer', 'bitformsProUpgradeNoticeScript'); |
| 150 |
} |
| 151 |
|
| 152 |
function bitformsProUpgradeNoticeScript() |
| 153 |
{ |
| 154 |
?> |
| 155 |
<script> |
| 156 |
(function () { |
| 157 |
var notice = document.querySelector('.bitforms-pro-upgrade-notice'); |
| 158 |
if (!notice) return; |
| 159 |
notice.addEventListener('click', function (e) { |
| 160 |
if (!e.target.classList.contains('notice-dismiss')) return; |
| 161 |
var fd = new FormData(); |
| 162 |
fd.append('action', 'bitforms_dismiss_pro_notice'); |
| 163 |
fd.append('nonce', notice.dataset.nonce); |
| 164 |
fetch(notice.dataset.ajaxUrl, { method: 'POST', credentials: 'same-origin', body: fd }); |
| 165 |
}); |
| 166 |
}()); |
| 167 |
</script> |
| 168 |
<?php |
| 169 |
} |
| 170 |
|