| @@ -1,181 +1,114 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Plugin Name: Formidable Forms | |
| 4 | - * Description: Quickly and easily create drag-and-drop forms | |
| 5 | - * Version: 6.28 | |
| 6 | - * Plugin URI: https://formidableforms.com/ | |
| 7 | - * Author URI: https://formidableforms.com/ | |
| 8 | - * Author: Strategy11 Form Builder Team | |
| 9 | - * Text Domain: formidable | |
| 10 | - * | |
| 11 | - * @package Formidable | |
| 12 | - */ | |
| 13 | - | |
| 14 | 2 | /* |
| 15 | - Copyright 2010 Formidable Forms | |
| 16 | - | |
| 17 | - This program is free software; you can redistribute it and/or modify | |
| 18 | - it under the terms of the GNU General Public License, version 2, as | |
| 19 | - published by the Free Software Foundation. | |
| 20 | - | |
| 21 | - This program is distributed in the hope that it will be useful, | |
| 22 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 23 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 24 | - GNU General Public License for more details. | |
| 3 | +Plugin Name: Formidable | |
| 4 | +Description: Quickly and easily create drag-and-drop forms | |
| 5 | +Version: 1.07.11 | |
| 6 | +Plugin URI: http://formidablepro.com/ | |
| 7 | +Author URI: http://strategy11.com | |
| 8 | +Author: Strategy11 | |
| 9 | +Text Domain: formidable | |
| 25 | 10 | */ |
| 26 | 11 | |
| 27 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 28 | - die( 'You are not allowed to call this page directly.' ); | |
| 29 | -} | |
| 12 | +/* Copyright 2010 Strategy11 (email : support@strategy11.com) | |
| 30 | 13 | |
| 31 | -add_action( 'plugins_loaded', 'load_formidable_forms', 0 ); | |
| 32 | -/** | |
| 33 | - * @return void | |
| 34 | - */ | |
| 35 | -function load_formidable_forms() { | |
| 36 | - global $frm_vars; | |
| 37 | - $frm_vars = array( | |
| 38 | - 'load_css' => false, | |
| 39 | - 'forms_loaded' => array(), | |
| 40 | - 'created_entries' => array(), | |
| 41 | - 'pro_is_authorized' => false, | |
| 42 | - ); | |
| 14 | + This program is free software; you can redistribute it and/or modify | |
| 15 | + it under the terms of the GNU General Public License, version 2, as | |
| 16 | + published by the Free Software Foundation. | |
| 43 | 17 | |
| 44 | - // For reverse compatibility. Load Pro if it's still nested. | |
| 45 | - $frm_path = __DIR__; | |
| 18 | + This program is distributed in the hope that it will be useful, | |
| 19 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | + GNU General Public License for more details. | |
| 22 | +*/ | |
| 46 | 23 | |
| 47 | - if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) { | |
| 48 | - include $frm_path . '/pro/formidable-pro.php'; | |
| 49 | - } | |
| 24 | +require_once(dirname( __FILE__ ) .'/classes/models/FrmSettings.php'); | |
| 50 | 25 | |
| 51 | - FrmHooksController::trigger_load_hook(); | |
| 52 | -} | |
| 26 | +global $frm_vars; | |
| 27 | +$frm_vars = array( | |
| 28 | + 'load_css' => false, 'forms_loaded' => array(), | |
| 29 | + 'created_entries' => array(), 'pro_is_installed' => false | |
| 30 | +); | |
| 53 | 31 | |
| 54 | -// If __autoload is active, put it on the spl_autoload stack. | |
| 55 | -if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions(), true ) ) { | |
| 56 | - spl_autoload_register( '__autoload' ); | |
| 57 | -} | |
| 32 | +require_once(dirname( __FILE__ ) .'/classes/helpers/FrmAppHelper.php'); | |
| 33 | +$obj = new FrmAppHelper(); | |
| 58 | 34 | |
| 59 | -// Add the autoloader. | |
| 60 | -spl_autoload_register( 'frm_forms_autoloader' ); | |
| 35 | +/***** SETUP SETTINGS OBJECT *****/ | |
| 36 | +global $frm_settings; | |
| 61 | 37 | |
| 62 | -/** | |
| 63 | - * @param string $class_name Class name. | |
| 64 | - * | |
| 65 | - * @return void | |
| 66 | - */ | |
| 67 | -function frm_forms_autoloader( $class_name ) { | |
| 68 | - // Only load Frm classes here. | |
| 69 | - if ( ! preg_match( '/^Frm.+$/', $class_name ) || preg_match( '/^FrmPro.+$/', $class_name ) ) { | |
| 70 | - return; | |
| 71 | - } | |
| 38 | +$frm_settings = get_transient('frm_options'); | |
| 39 | +if(!is_object($frm_settings)){ | |
| 40 | + if($frm_settings){ //workaround for W3 total cache conflict | |
| 41 | + $frm_settings = unserialize(serialize($frm_settings)); | |
| 42 | + }else{ | |
| 43 | + $frm_settings = get_option('frm_options'); | |
| 72 | 44 | |
| 73 | - frm_class_autoloader( $class_name, __DIR__ ); | |
| 45 | + // If unserializing didn't work | |
| 46 | + if(!is_object($frm_settings)){ | |
| 47 | + if($frm_settings) //workaround for W3 total cache conflict | |
| 48 | + $frm_settings = unserialize(serialize($frm_settings)); | |
| 49 | + else | |
| 50 | + $frm_settings = new FrmSettings(); | |
| 51 | + update_option('frm_options', $frm_settings); | |
| 52 | + set_transient('frm_options', $frm_settings); | |
| 53 | + } | |
| 54 | + } | |
| 74 | 55 | } |
| 56 | +$frm_settings->set_default_options(); // Sets defaults for unset options | |
| 75 | 57 | |
| 76 | -/** | |
| 77 | - * Autoload the Formidable and Pro classes | |
| 78 | - * | |
| 79 | - * @since 3.0 | |
| 80 | - * | |
| 81 | - * @param string $class_name Class name. | |
| 82 | - * @param string $filepath File path. | |
| 83 | - * | |
| 84 | - * @return void | |
| 85 | - */ | |
| 86 | -function frm_class_autoloader( $class_name, $filepath ) { | |
| 87 | - $original_filepath = $filepath; | |
| 88 | - $filepath .= '/classes/'; | |
| 58 | +$frm_path = FrmAppHelper::plugin_path(); | |
| 89 | 59 | |
| 90 | - if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 91 | - $filepath .= 'helpers/'; | |
| 92 | - } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 93 | - $filepath .= 'controllers/'; | |
| 94 | - } elseif ( preg_match( '/^.+Factory$/', $class_name ) ) { | |
| 95 | - $filepath .= 'factories/'; | |
| 96 | - } elseif ( preg_match( '/^.+StyleComponent$/', $class_name ) ) { | |
| 97 | - $filepath .= 'views/styles/components/'; | |
| 98 | - } else { | |
| 99 | - $filepath .= 'models/'; | |
| 60 | +// Instansiate Models | |
| 61 | +require_once($frm_path .'/classes/models/FrmDb.php'); | |
| 62 | +require_once($frm_path .'/classes/models/FrmField.php'); | |
| 63 | +require_once($frm_path .'/classes/models/FrmForm.php'); | |
| 64 | +require_once($frm_path .'/classes/models/FrmEntry.php'); | |
| 65 | +require_once($frm_path .'/classes/models/FrmEntryMeta.php'); | |
| 66 | +require_once($frm_path .'/classes/models/FrmNotification.php'); | |
| 100 | 67 | |
| 101 | - if ( str_contains( $class_name, 'Field' ) && ! file_exists( $filepath . $class_name . '.php' ) ) { | |
| 102 | - $filepath .= 'fields/'; | |
| 103 | - } | |
| 104 | - } | |
| 68 | +global $frmdb; | |
| 69 | +global $frm_field; | |
| 70 | +global $frm_form; | |
| 71 | +global $frm_entry; | |
| 72 | +global $frm_entry_meta; | |
| 105 | 73 | |
| 106 | - if ( file_exists( $filepath . $class_name . '.php' ) ) { | |
| 107 | - require $filepath . $class_name . '.php'; | |
| 108 | - return; | |
| 109 | - } | |
| 74 | +$frmdb = new FrmDb(); | |
| 75 | +$frm_field = new FrmField(); | |
| 76 | +$frm_form = new FrmForm(); | |
| 77 | +$frm_entry = new FrmEntry(); | |
| 78 | +$frm_entry_meta = new FrmEntryMeta(); | |
| 79 | +$obj = new FrmNotification(); | |
| 110 | 80 | |
| 111 | - if ( preg_match( '/^FrmStrpLite.+$/', $class_name ) || preg_match( '/^FrmTransLite.+$/', $class_name ) ) { | |
| 112 | - // Autoload for /stripe/ folder. | |
| 113 | - $filepath = $original_filepath . '/stripe/'; | |
| 114 | 81 | |
| 115 | - if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 116 | - $filepath .= 'helpers/'; | |
| 117 | - } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 118 | - $filepath .= 'controllers/'; | |
| 119 | - } else { | |
| 120 | - $filepath .= 'models/'; | |
| 121 | - } | |
| 82 | +// Instansiate Controllers | |
| 83 | +require_once($frm_path .'/classes/controllers/FrmAppController.php'); | |
| 84 | +require_once($frm_path .'/classes/controllers/FrmFieldsController.php'); | |
| 85 | +require_once($frm_path .'/classes/controllers/FrmFormsController.php'); | |
| 86 | +require_once($frm_path .'/classes/controllers/FrmEntriesController.php'); | |
| 122 | 87 | |
| 123 | - $filepath .= $class_name . '.php'; | |
| 88 | +FrmAppController::load_hooks(); | |
| 89 | +FrmEntriesController::load_hooks(); | |
| 90 | +FrmFieldsController::load_hooks(); | |
| 91 | +FrmFormsController::load_hooks(); | |
| 124 | 92 | |
| 125 | - if ( file_exists( $filepath ) ) { | |
| 126 | - require $filepath; | |
| 127 | - } | |
| 128 | - | |
| 129 | - return; | |
| 130 | - } | |
| 131 | - | |
| 132 | - if ( ! preg_match( '/^FrmSquareLite.+$/', $class_name ) ) { | |
| 133 | - return; | |
| 134 | - } | |
| 135 | - | |
| 136 | - $filepath = $original_filepath . '/square/'; | |
| 137 | - | |
| 138 | - if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 139 | - $filepath .= 'helpers/'; | |
| 140 | - } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 141 | - $filepath .= 'controllers/'; | |
| 142 | - } else { | |
| 143 | - $filepath .= 'models/'; | |
| 144 | - } | |
| 145 | - | |
| 146 | - $filepath .= $class_name . '.php'; | |
| 147 | - | |
| 148 | - if ( file_exists( $filepath ) ) { | |
| 149 | - require $filepath; | |
| 150 | - } | |
| 93 | +if(is_admin()){ | |
| 94 | + require_once($frm_path .'/classes/controllers/FrmSettingsController.php'); | |
| 95 | + FrmSettingsController::load_hooks(); | |
| 96 | + | |
| 97 | + require_once($frm_path .'/classes/controllers/FrmStatisticsController.php'); | |
| 98 | + FrmStatisticsController::load_hooks(); | |
| 99 | + | |
| 100 | + require_once($frm_path .'/classes/controllers/FrmXMLController.php'); | |
| 101 | + FrmXMLController::load_hooks(); | |
| 151 | 102 | } |
| 152 | 103 | |
| 153 | -add_action( 'activate_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'frm_maybe_install' ); | |
| 104 | +// Instansiate Helpers | |
| 105 | +require_once($frm_path .'/classes/helpers/FrmEntriesHelper.php'); | |
| 106 | +require_once($frm_path .'/classes/helpers/FrmFieldsHelper.php'); | |
| 107 | +require_once($frm_path .'/classes/helpers/FrmFormsHelper.php'); | |
| 154 | 108 | |
| 155 | -/** | |
| 156 | - * This function is triggered when Formidable is activated. | |
| 157 | - * | |
| 158 | - * @return void | |
| 159 | - */ | |
| 160 | -function frm_maybe_install() { | |
| 161 | - if ( get_transient( FrmOnboardingWizardController::TRANSIENT_NAME ) !== 'no' ) { | |
| 162 | - set_transient( | |
| 163 | - FrmOnboardingWizardController::TRANSIENT_NAME, | |
| 164 | - FrmOnboardingWizardController::TRANSIENT_VALUE, | |
| 165 | - 60 | |
| 166 | - ); | |
| 167 | - } | |
| 168 | - | |
| 169 | - FrmAppController::handle_activation(); | |
| 109 | +if ( file_exists($frm_path . '/pro/formidable-pro.php') ) { | |
| 110 | + require_once($frm_path .'/pro/formidable-pro.php'); | |
| 170 | 111 | } |
| 171 | 112 | |
| 172 | -register_deactivation_hook( | |
| 173 | - __FILE__, | |
| 174 | - function () { | |
| 175 | - if ( ! class_exists( 'FrmCronController', false ) ) { | |
| 176 | - require_once __DIR__ . '/classes/controllers/FrmCronController.php'; | |
| 177 | - } | |
| 178 | - | |
| 179 | - FrmCronController::remove_crons(); | |
| 180 | - } | |
| 181 | -); | |
| 113 | +include_once($frm_path .'/deprecated.php'); | |
| 114 | +unset($frm_path); | |