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