wpforms-lite
Last commit date
assets
10 years ago
includes
10 years ago
languages
10 years ago
lite
10 years ago
readme.txt
10 years ago
wpforms.php
10 years ago
wpforms.php
230 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.1.7.2 |
| 9 | * Text Domain: wpforms |
| 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 | * @package WPForms |
| 26 | * @author WPForms |
| 27 | * @since 1.0.0 |
| 28 | * @license GPL-2.0+ |
| 29 | * @copyright Copyright (c) 2016, WPForms LLC |
| 30 | */ |
| 31 | |
| 32 | // Exit if accessed directly |
| 33 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 34 | |
| 35 | /** |
| 36 | * Main WPForms class |
| 37 | * |
| 38 | * @since 1.0.0 |
| 39 | * @package WPForms |
| 40 | */ |
| 41 | final class WPForms_Lite { |
| 42 | |
| 43 | /** |
| 44 | * One is the loneliest number that you'll ever do. |
| 45 | * |
| 46 | * @since 1.0.0 |
| 47 | * @var object |
| 48 | */ |
| 49 | private static $instance; |
| 50 | |
| 51 | /** |
| 52 | * Plugin version for enqueueing, etc. |
| 53 | * |
| 54 | * @since 1.0.0 |
| 55 | * @var sting |
| 56 | */ |
| 57 | private $version = '1.1.7.2'; |
| 58 | |
| 59 | /** |
| 60 | * The form data handler instance. |
| 61 | * |
| 62 | * @var object WPForms_Form_Handler |
| 63 | * @since 1.0.0 |
| 64 | */ |
| 65 | public $form; |
| 66 | |
| 67 | /** |
| 68 | * The front-end instance. |
| 69 | * |
| 70 | * @var object WPForms_Frontend |
| 71 | * @since 1.0.0 |
| 72 | */ |
| 73 | public $frontend; |
| 74 | |
| 75 | /** |
| 76 | * The process instance. |
| 77 | * |
| 78 | * @var object WPForms_Process |
| 79 | * @since 1.0.0 |
| 80 | */ |
| 81 | public $process; |
| 82 | |
| 83 | /** |
| 84 | * The smart tags instance. |
| 85 | * |
| 86 | * @var object WPForms_Smart_Tags |
| 87 | * @since 1.0.0 |
| 88 | */ |
| 89 | public $smart_tags; |
| 90 | |
| 91 | /** |
| 92 | * The Logging instance. |
| 93 | * |
| 94 | * @var object WPForms_Logging |
| 95 | * @since 1.0.0 |
| 96 | */ |
| 97 | public $logs; |
| 98 | |
| 99 | /** |
| 100 | * Main WPForms Instance. |
| 101 | * |
| 102 | * Insures that only one instance of WPForms exists in memory at any one |
| 103 | * time. Also prevents needing to define globals all over the place. |
| 104 | * |
| 105 | * @since 1.0.0 |
| 106 | * @return WPForms |
| 107 | */ |
| 108 | public static function instance() { |
| 109 | |
| 110 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPForms_Lite ) ) { |
| 111 | |
| 112 | self::$instance = new WPForms_Lite; |
| 113 | self::$instance->constants(); |
| 114 | self::$instance->load_textdomain(); |
| 115 | self::$instance->includes(); |
| 116 | |
| 117 | add_action( 'plugins_loaded', array( self::$instance, 'objects' ), 10 ); |
| 118 | } |
| 119 | return self::$instance; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Include files. |
| 124 | * |
| 125 | * @since 1.0.0 |
| 126 | */ |
| 127 | private function includes() { |
| 128 | |
| 129 | // Global includes |
| 130 | require_once WPFORMS_PLUGIN_DIR . 'includes/functions.php'; |
| 131 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-install.php'; |
| 132 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-db.php'; |
| 133 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-form.php'; |
| 134 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-fields.php'; |
| 135 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-frontend.php'; |
| 136 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-templates.php'; |
| 137 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-process.php'; |
| 138 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-smart-tags.php'; |
| 139 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-logging.php'; |
| 140 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-widget.php'; |
| 141 | require_once WPFORMS_PLUGIN_DIR . 'includes/class-preview.php'; |
| 142 | require_once WPFORMS_PLUGIN_DIR . 'includes/emails/class-emails.php'; |
| 143 | |
| 144 | // Admin/Dashboard only includes |
| 145 | if ( is_admin() ) { |
| 146 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-menu.php'; |
| 147 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-settings.php'; |
| 148 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/overview/class-overview.php'; |
| 149 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/builder/class-builder.php'; |
| 150 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-welcome.php'; |
| 151 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-editor.php'; |
| 152 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/ajax-actions.php'; |
| 153 | require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-upgrades.php'; |
| 154 | require_once WPFORMS_PLUGIN_DIR . 'lite/lite.php'; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Setup objects. |
| 160 | * |
| 161 | * @since 1.0.0 |
| 162 | */ |
| 163 | public function objects() { |
| 164 | |
| 165 | // Global objects |
| 166 | $this->form = new WPForms_Form_Handler; |
| 167 | $this->frontend = new WPForms_Frontend; |
| 168 | $this->process = new WPForms_Process; |
| 169 | $this->smart_tags = new WPForms_Smart_Tags; |
| 170 | $this->logs = new WPForms_Logging; |
| 171 | |
| 172 | // Hook now that all of the WPForms stuff is loaded. |
| 173 | do_action( 'wpforms_loaded' ); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Setup plugin constants. |
| 178 | * |
| 179 | * @since 1.0.0 |
| 180 | */ |
| 181 | private function constants() { |
| 182 | |
| 183 | // Plugin version |
| 184 | if ( ! defined( 'WPFORMS_VERSION' ) ) { |
| 185 | define( 'WPFORMS_VERSION', $this->version ); |
| 186 | } |
| 187 | |
| 188 | // Plugin Folder Path |
| 189 | if ( ! defined( 'WPFORMS_PLUGIN_DIR' ) ) { |
| 190 | define( 'WPFORMS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 191 | } |
| 192 | |
| 193 | // Plugin Folder URL |
| 194 | if ( ! defined( 'WPFORMS_PLUGIN_URL' ) ) { |
| 195 | define( 'WPFORMS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 196 | } |
| 197 | |
| 198 | // Plugin Root File |
| 199 | if ( ! defined( 'WPFORMS_PLUGIN_FILE' ) ) { |
| 200 | define( 'WPFORMS_PLUGIN_FILE', __FILE__ ); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Loads the plugin language files. |
| 206 | * |
| 207 | * @since 1.0.0 |
| 208 | */ |
| 209 | public function load_textdomain() { |
| 210 | |
| 211 | load_plugin_textdomain( 'wpforms', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * The function which returns the one WPForms instance. |
| 217 | * |
| 218 | * Use this function like you would a global variable, except without needing |
| 219 | * to declare the global. |
| 220 | * |
| 221 | * Example: <?php $wpforms = wpforms(); ?> |
| 222 | * |
| 223 | * @since 1.0.0 |
| 224 | * @return object |
| 225 | */ |
| 226 | function wpforms() { |
| 227 | |
| 228 | return WPForms_Lite::instance(); |
| 229 | } |
| 230 | wpforms(); |