wpforms-lite
Last commit date
assets
4 years ago
includes
4 years ago
libs
4 years ago
lite
4 years ago
src
4 years ago
templates
4 years ago
vendor
4 years ago
changelog.txt
4 years ago
readme.txt
4 years ago
uninstall.php
4 years ago
wpforms.php
4 years ago
wpforms.php
231 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: WPForms Lite |
| 4 | * Plugin URI: https://wpforms.com |
| 5 | * Description: Beginner friendly WordPress contact form plugin. Use our Drag & Drop form builder to create your WordPress forms. |
| 6 | * Requires at least: 4.9 |
| 7 | * Requires PHP: 5.5 |
| 8 | * Author: WPForms |
| 9 | * Author URI: https://wpforms.com |
| 10 | * Version: 1.6.9 |
| 11 | * Text Domain: wpforms-lite |
| 12 | * Domain Path: assets/languages |
| 13 | * |
| 14 | * WPForms is free software: you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation, either version 2 of the License, or |
| 17 | * any later version. |
| 18 | * |
| 19 | * WPForms is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with WPForms. If not, see <https://www.gnu.org/licenses/>. |
| 26 | */ |
| 27 | |
| 28 | // Exit if accessed directly. |
| 29 | if ( ! defined( 'ABSPATH' ) ) { |
| 30 | exit; |
| 31 | } |
| 32 | |
| 33 | // Plugin version. |
| 34 | if ( ! defined( 'WPFORMS_VERSION' ) ) { |
| 35 | define( 'WPFORMS_VERSION', '1.6.9' ); |
| 36 | } |
| 37 | |
| 38 | // Plugin Folder Path. |
| 39 | if ( ! defined( 'WPFORMS_PLUGIN_DIR' ) ) { |
| 40 | define( 'WPFORMS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 41 | } |
| 42 | |
| 43 | // Plugin Folder URL. |
| 44 | if ( ! defined( 'WPFORMS_PLUGIN_URL' ) ) { |
| 45 | define( 'WPFORMS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 46 | } |
| 47 | |
| 48 | // Plugin Root File. |
| 49 | if ( ! defined( 'WPFORMS_PLUGIN_FILE' ) ) { |
| 50 | define( 'WPFORMS_PLUGIN_FILE', __FILE__ ); |
| 51 | } |
| 52 | |
| 53 | // Don't allow multiple versions to be active. |
| 54 | if ( function_exists( 'wpforms' ) ) { |
| 55 | |
| 56 | if ( ! function_exists( 'wpforms_pro_just_activated' ) ) { |
| 57 | /** |
| 58 | * When we activate a Pro version, we need to do additional operations: |
| 59 | * 1) deactivate a Lite version; |
| 60 | * 2) register option which help to run all activation process for Pro version (custom tables creation, etc.). |
| 61 | * |
| 62 | * @since 1.6.2 |
| 63 | */ |
| 64 | function wpforms_pro_just_activated() { |
| 65 | |
| 66 | wpforms_deactivate(); |
| 67 | add_option( 'wpforms_install', 1 ); |
| 68 | } |
| 69 | } |
| 70 | add_action( 'activate_wpforms/wpforms.php', 'wpforms_pro_just_activated' ); |
| 71 | |
| 72 | if ( ! function_exists( 'wpforms_lite_just_activated' ) ) { |
| 73 | /** |
| 74 | * Store temporarily that the Lite version of the plugin was activated. |
| 75 | * This is needed because WP does a redirect after activation and |
| 76 | * we need to preserve this state to know whether user activated Lite or not. |
| 77 | * |
| 78 | * @since 1.5.8 |
| 79 | */ |
| 80 | function wpforms_lite_just_activated() { |
| 81 | |
| 82 | set_transient( 'wpforms_lite_just_activated', true ); |
| 83 | } |
| 84 | } |
| 85 | add_action( 'activate_wpforms-lite/wpforms.php', 'wpforms_lite_just_activated' ); |
| 86 | |
| 87 | if ( ! function_exists( 'wpforms_lite_just_deactivated' ) ) { |
| 88 | /** |
| 89 | * Store temporarily that Lite plugin was deactivated. |
| 90 | * Convert temporary "activated" value to a global variable, |
| 91 | * so it is available through the request. Remove from the storage. |
| 92 | * |
| 93 | * @since 1.5.8 |
| 94 | */ |
| 95 | function wpforms_lite_just_deactivated() { |
| 96 | |
| 97 | global $wpforms_lite_just_activated, $wpforms_lite_just_deactivated; |
| 98 | |
| 99 | $wpforms_lite_just_activated = (bool) get_transient( 'wpforms_lite_just_activated' ); |
| 100 | $wpforms_lite_just_deactivated = true; |
| 101 | |
| 102 | delete_transient( 'wpforms_lite_just_activated' ); |
| 103 | } |
| 104 | } |
| 105 | add_action( 'deactivate_wpforms-lite/wpforms.php', 'wpforms_lite_just_deactivated' ); |
| 106 | |
| 107 | if ( ! function_exists( 'wpforms_deactivate' ) ) { |
| 108 | /** |
| 109 | * Deactivate Lite if WPForms already activated. |
| 110 | * |
| 111 | * @since 1.0.0 |
| 112 | */ |
| 113 | function wpforms_deactivate() { |
| 114 | |
| 115 | $plugin = 'wpforms-lite/wpforms.php'; |
| 116 | |
| 117 | deactivate_plugins( $plugin ); |
| 118 | |
| 119 | do_action( 'wpforms_plugin_deactivated', $plugin ); |
| 120 | } |
| 121 | } |
| 122 | add_action( 'admin_init', 'wpforms_deactivate' ); |
| 123 | |
| 124 | if ( ! function_exists( 'wpforms_lite_notice' ) ) { |
| 125 | /** |
| 126 | * Display the notice after deactivation when Pro is still active |
| 127 | * and user wanted to activate the Lite version of the plugin. |
| 128 | * |
| 129 | * @since 1.0.0 |
| 130 | */ |
| 131 | function wpforms_lite_notice() { |
| 132 | |
| 133 | global $wpforms_lite_just_activated, $wpforms_lite_just_deactivated; |
| 134 | |
| 135 | if ( |
| 136 | empty( $wpforms_lite_just_activated ) || |
| 137 | empty( $wpforms_lite_just_deactivated ) |
| 138 | ) { |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | // Currently tried to activate Lite with Pro still active, so display the message. |
| 143 | printf( |
| 144 | '<div class="notice notice-warning"> |
| 145 | <p>%1$s</p> |
| 146 | <p>%2$s</p> |
| 147 | </div>', |
| 148 | esc_html__( 'Heads up!', 'wpforms-lite' ), |
| 149 | esc_html__( 'Your site already has WPForms Pro activated. If you want to switch to WPForms Lite, please first go to Plugins → Installed Plugins and deactivate WPForms. Then, you can activate WPForms Lite.', 'wpforms-lite' ) |
| 150 | ); |
| 151 | |
| 152 | if ( isset( $_GET['activate'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 153 | unset( $_GET['activate'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 154 | } |
| 155 | |
| 156 | unset( $wpforms_lite_just_activated, $wpforms_lite_just_deactivated ); |
| 157 | } |
| 158 | } |
| 159 | add_action( 'admin_notices', 'wpforms_lite_notice' ); |
| 160 | |
| 161 | // Do not process the plugin code further. |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | // We require PHP 5.5+ for the whole plugin to work. |
| 166 | if ( version_compare( phpversion(), '5.5', '<' ) ) { |
| 167 | |
| 168 | if ( ! function_exists( 'wpforms_php52_notice' ) ) { |
| 169 | /** |
| 170 | * Display the notice after deactivation. |
| 171 | * |
| 172 | * @since 1.5.0 |
| 173 | */ |
| 174 | function wpforms_php52_notice() { |
| 175 | ?> |
| 176 | <div class="notice notice-error"> |
| 177 | <p> |
| 178 | <?php |
| 179 | printf( |
| 180 | wp_kses( /* translators: %s - WPBeginner URL for recommended WordPress hosting. */ |
| 181 | __( 'Your site is running an <strong>insecure version</strong> of PHP that is no longer supported. Please contact your web hosting provider to update your PHP version or switch to a <a href="%s" target="_blank" rel="noopener noreferrer">recommended WordPress hosting company</a>.', 'wpforms-lite' ), |
| 182 | [ |
| 183 | 'a' => [ |
| 184 | 'href' => [], |
| 185 | 'target' => [], |
| 186 | 'rel' => [], |
| 187 | ], |
| 188 | 'strong' => [], |
| 189 | ] |
| 190 | ), |
| 191 | 'https://www.wpbeginner.com/wordpress-hosting/' |
| 192 | ); |
| 193 | ?> |
| 194 | <br><br> |
| 195 | <?php |
| 196 | printf( |
| 197 | wp_kses( /* translators: %s - WPForms.com URL for documentation with more details. */ |
| 198 | __( '<strong>Note:</strong> WPForms plugin is disabled on your site until you fix the issue. <a href="%s" target="_blank" rel="noopener noreferrer">Read more for additional information.</a>', 'wpforms-lite' ), |
| 199 | [ |
| 200 | 'a' => [ |
| 201 | 'href' => [], |
| 202 | 'target' => [], |
| 203 | 'rel' => [], |
| 204 | ], |
| 205 | 'strong' => [], |
| 206 | ] |
| 207 | ), |
| 208 | 'https://wpforms.com/docs/supported-php-version/' |
| 209 | ); |
| 210 | ?> |
| 211 | </p> |
| 212 | </div> |
| 213 | |
| 214 | <?php |
| 215 | // In case this is on plugin activation. |
| 216 | if ( isset( $_GET['activate'] ) ) { //phpcs:ignore |
| 217 | unset( $_GET['activate'] ); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | add_action( 'admin_notices', 'wpforms_php52_notice' ); |
| 222 | |
| 223 | // Do not process the plugin code further. |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | // Define the class and the function. |
| 228 | require_once dirname( __FILE__ ) . '/src/WPForms.php'; |
| 229 | |
| 230 | wpforms(); |
| 231 |