PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.1.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.1.1
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / weforms.php

weforms.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.1.1, at weforms.php

338 lines 9.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: weForms
4 * Description: The best contact form plugin for WordPress
5 * Plugin URI: https://wedevs.com/weforms/
6 * Author: weDevs
7 * Author URI: https://wedevs.com/
8 * Version: 1.1.1
9 * License: GPL2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: weforms
12 * Domain Path: /languages
13 */
14
15 /**
16 * Copyright (c) 2017 weDevs LLC (email: info@wedevs.com). All rights reserved.
17 *
18 * Released under the GPL license
19 * http://www.opensource.org/licenses/gpl-license.php
20 *
21 * This is an add-on for WordPress
22 * http://wordpress.org/
23 *
24 * **********************************************************************
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 2 of the License, or
28 * (at your option) any later version.
29 *
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 * **********************************************************************
39 */
40
41 // don't call the file directly
42 if ( !defined( 'ABSPATH' ) ) exit;
43
44 /**
45 * WeForms class
46 *
47 * @class WeForms The class that holds the entire WeForms plugin
48 */
49 final class WeForms {
50
51 /**
52 * Plugin version
53 *
54 * @var string
55 */
56 public $version = '1.1.1';
57
58 /**
59 * Form field value seperator
60 *
61 * @var string
62 */
63 static $field_separator = '| ';
64
65 /**
66 * Holds various class instances
67 *
68 * @var array
69 */
70 private $container = array();
71
72 /**
73 * Constructor for the WeForms class
74 *
75 * Sets up all the appropriate hooks and actions
76 * within our plugin.
77 */
78 public function __construct() {
79 $this->define_constants();
80
81 register_activation_hook( __FILE__, array( $this, 'activate' ) );
82 register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
83
84 add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
85 }
86
87 /**
88 * Magic getter to bypass referencing plugin.
89 *
90 * @param $prop
91 *
92 * @return mixed
93 */
94 public function __get( $prop ) {
95 if ( array_key_exists( $prop, $this->container ) ) {
96 return $this->container[ $prop ];
97 }
98
99 return $this->{$prop};
100 }
101
102 /**
103 * Magic isset to bypass referencing plugin.
104 *
105 * @param $prop
106 *
107 * @return mixed
108 */
109 public function __isset( $prop ) {
110 return isset( $this->{$prop} ) || isset( $this->container[ $prop ] );
111 }
112
113 /**
114 * Initializes the WeForms() class
115 *
116 * Checks for an existing WeForms() instance
117 * and if it doesn't find one, creates it.
118 */
119 public static function init() {
120 static $instance = false;
121
122 if ( ! $instance ) {
123 $instance = new WeForms();
124 }
125
126 return $instance;
127 }
128
129 /**
130 * Define the constants
131 *
132 * @return void
133 */
134 private function define_constants() {
135 define( 'WEFORMS_VERSION', '1.1.0' );
136 define( 'WEFORMS_FILE', __FILE__ );
137 define( 'WEFORMS_ROOT', dirname( __FILE__ ) );
138 define( 'WEFORMS_INCLUDES', WEFORMS_ROOT . '/includes' );
139 define( 'WEFORMS_ROOT_URI', plugins_url( '', __FILE__ ) );
140 define( 'WEFORMS_ASSET_URI', WEFORMS_ROOT_URI . '/assets' );
141 }
142
143 /**
144 * Load the plugin after WP User Frontend is loaded
145 *
146 * @return void
147 */
148 public function init_plugin() {
149 $this->includes();
150 $this->init_hooks();
151
152 do_action( 'weforms_loaded' );
153 }
154
155 /**
156 * Placeholder for activation function
157 */
158 public function activate() {
159
160 // prepare the environment
161 require_once WEFORMS_INCLUDES . '/class-installer.php';
162 require_once WEFORMS_INCLUDES . '/class-field-manager.php';
163 require_once WEFORMS_INCLUDES . '/class-form-manager.php';
164 require_once WEFORMS_INCLUDES . '/class-template-manager.php';
165
166 if ( ! array_key_exists( 'fields', $this->container ) ) {
167 $this->container['fields'] = new WeForms_Field_Manager();
168 }
169
170 if ( ! array_key_exists( 'form', $this->container ) ) {
171 $this->container['form'] = new WeForms_Form_Manager();
172 }
173
174 if ( ! array_key_exists( 'templates', $this->container ) ) {
175 $this->container['templates'] = new WeForms_Template_Manager();
176 }
177
178 $installer = new WeForms_Installer();
179 $installer->install();
180 }
181
182 /**
183 * Placeholder for deactivation function
184 *
185 * Nothing being called here yet.
186 */
187 public function deactivate() {
188
189 }
190
191 /**
192 * Include the required classes
193 *
194 * @return void
195 */
196 public function includes() {
197
198 require_once WEFORMS_INCLUDES . '/compat/class-abstract-wpuf-integration.php';
199
200 if ( is_admin() ) {
201 // compatibility
202 require_once WEFORMS_INCLUDES . '/class-template-manager.php';
203
204 require_once WEFORMS_INCLUDES . '/admin/class-admin.php';
205 require_once WEFORMS_INCLUDES . '/admin/class-admin-welcome.php';
206 require_once WEFORMS_INCLUDES . '/class-importer-manager.php';
207
208 require_once WEFORMS_INCLUDES . '/admin/class-pro-upgrades.php';
209
210 } else {
211
212 require_once WEFORMS_INCLUDES . '/class-frontend-form.php';
213
214 // add reCaptcha library if not found
215 if ( ! function_exists( 'recaptcha_get_html' ) ) {
216 require_once WEFORMS_INCLUDES . '/library/reCaptcha/recaptchalib.php';
217 require_once WEFORMS_INCLUDES . '/library/reCaptcha/recaptchalib_noCaptcha.php';
218 }
219 }
220
221 require_once WEFORMS_INCLUDES . '/class-scripts-styles.php';
222 require_once WEFORMS_INCLUDES . '/class-emailer.php';
223 require_once WEFORMS_INCLUDES . '/class-field-manager.php';
224 require_once WEFORMS_INCLUDES . '/class-form-manager.php';
225 require_once WEFORMS_INCLUDES . '/class-form-entry-manager.php';
226 require_once WEFORMS_INCLUDES . '/class-form-entry.php';
227 require_once WEFORMS_INCLUDES . '/class-form.php';
228
229 require_once WEFORMS_INCLUDES . '/integrations/class-abstract-integration.php';
230 require_once WEFORMS_INCLUDES . '/class-integration-manager.php';
231
232 require_once WEFORMS_INCLUDES . '/class-ajax.php';
233 require_once WEFORMS_INCLUDES . '/class-ajax-upload.php';
234 require_once WEFORMS_INCLUDES . '/class-notification.php';
235 require_once WEFORMS_INCLUDES . '/class-form-preview.php';
236 require_once WEFORMS_INCLUDES . '/functions.php';
237 }
238
239 /**
240 * Initialize the hooks
241 *
242 * @return void
243 */
244 public function init_hooks() {
245
246 // Localize our plugin
247 add_action( 'init', array( $this, 'localization_setup' ) );
248
249 // initialize the classes
250 add_action( 'init', array( $this, 'init_classes' ) );
251 add_action( 'init', array( $this, 'wpdb_table_shortcuts' ), 0 );
252
253 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
254 }
255
256 /**
257 * Set WPDB table shortcut names
258 *
259 * @return void
260 */
261 public function wpdb_table_shortcuts() {
262 global $wpdb;
263
264 $wpdb->weforms_entries = $wpdb->prefix . 'weforms_entries';
265 $wpdb->weforms_entrymeta = $wpdb->prefix . 'weforms_entrymeta';
266 }
267
268 /**
269 * Initialize plugin for localization
270 *
271 * @uses load_plugin_textdomain()
272 */
273 public function localization_setup() {
274 load_plugin_textdomain( 'weforms', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
275 }
276
277 /**
278 * Instantiate the required classes
279 *
280 * @return void
281 */
282 public function init_classes() {
283
284 if ( is_admin() ) {
285 $this->container['admin'] = new WeForms_Admin();
286 // $this->container['welcome'] = new WeForms_Admin_Welcome();
287 $this->container['templates'] = new WeForms_Template_Manager();
288 $this->container['pro_upgrades'] = new WeForms_Pro_Upgrades();
289 $this->container['importer'] = new WeForms_Importer_Manager();
290 } else {
291 $this->container['frontend'] = new WeForms_Frontend_Form();
292 }
293
294 $this->container['emailer'] = new WeForms_Emailer();
295 $this->container['form'] = new WeForms_Form_Manager();
296 $this->container['fields'] = new WeForms_Field_Manager();
297 $this->container['integrations'] = new WeForms_Integration_Manager();
298 $this->container['preview'] = new WeForms_Form_Preview();
299 $this->container['scripts'] = new WeForms_Scripts_Styles();
300
301 // instantiate the integrations
302 $this->integrations->get_integrations();
303
304 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
305 $this->container['ajax'] = new WeForms_Ajax();
306 $this->container['ajax_upload'] = new WeForms_Ajax_Upload();
307 }
308 }
309
310 /**
311 * Plugin action links
312 *
313 * @param array $links
314 *
315 * @return array
316 */
317 function plugin_action_links( $links ) {
318
319 $links[] = '<a href="https://wedevs.com/docs/weforms/?utm_source=weforms-action-link&utm_medium=textlink&utm_campaign=plugin-docs-link" target="_blank">' . __( 'Docs', 'weforms' ) . '</a>';
320 $links[] = '<a href="' . admin_url( 'admin.php?page=weforms' ) . '">' . __( 'Settings', 'weforms' ) . '</a>';
321
322 return $links;
323 }
324
325 } // WeForms
326
327 /**
328 * Initialize the plugin
329 *
330 * @return \WeForms
331 */
332 function weforms() {
333 return WeForms::init();
334 }
335
336 // kick-off
337 weforms();
338