| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Formidable Forms |
| 4 |
* Description: Quickly and easily create drag-and-drop forms |
| 5 |
* Version: 6.26 |
| 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 |
/* |
| 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. |
| 25 |
*/ |
| 26 |
|
| 27 |
if ( ! defined( 'ABSPATH' ) ) { |
| 28 |
die( 'You are not allowed to call this page directly.' ); |
| 29 |
} |
| 30 |
|
| 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 |
); |
| 43 |
|
| 44 |
// For reverse compatibility. Load Pro if it's still nested. |
| 45 |
$frm_path = __DIR__; |
| 46 |
|
| 47 |
if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) { |
| 48 |
include $frm_path . '/pro/formidable-pro.php'; |
| 49 |
} |
| 50 |
|
| 51 |
FrmHooksController::trigger_load_hook(); |
| 52 |
} |
| 53 |
|
| 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 |
} |
| 58 |
|
| 59 |
// Add the autoloader. |
| 60 |
spl_autoload_register( 'frm_forms_autoloader' ); |
| 61 |
|
| 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 |
} |
| 72 |
|
| 73 |
frm_class_autoloader( $class_name, __DIR__ ); |
| 74 |
} |
| 75 |
|
| 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/'; |
| 89 |
|
| 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/'; |
| 100 |
|
| 101 |
if ( strpos( $class_name, 'Field' ) && ! file_exists( $filepath . $class_name . '.php' ) ) { |
| 102 |
$filepath .= 'fields/'; |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
if ( file_exists( $filepath . $class_name . '.php' ) ) { |
| 107 |
require $filepath . $class_name . '.php'; |
| 108 |
return; |
| 109 |
} |
| 110 |
|
| 111 |
if ( preg_match( '/^FrmStrpLite.+$/', $class_name ) || preg_match( '/^FrmTransLite.+$/', $class_name ) ) { |
| 112 |
// Autoload for /stripe/ folder. |
| 113 |
$filepath = $original_filepath . '/stripe/'; |
| 114 |
|
| 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 |
} |
| 122 |
|
| 123 |
$filepath .= $class_name . '.php'; |
| 124 |
|
| 125 |
if ( file_exists( $filepath ) ) { |
| 126 |
require $filepath; |
| 127 |
} |
| 128 |
|
| 129 |
return; |
| 130 |
} |
| 131 |
|
| 132 |
if ( preg_match( '/^FrmSquareLite.+$/', $class_name ) ) { |
| 133 |
$filepath = $original_filepath . '/square/'; |
| 134 |
|
| 135 |
if ( preg_match( '/^.+Helper$/', $class_name ) ) { |
| 136 |
$filepath .= 'helpers/'; |
| 137 |
} elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { |
| 138 |
$filepath .= 'controllers/'; |
| 139 |
} else { |
| 140 |
$filepath .= 'models/'; |
| 141 |
} |
| 142 |
|
| 143 |
$filepath .= $class_name . '.php'; |
| 144 |
|
| 145 |
if ( file_exists( $filepath ) ) { |
| 146 |
require $filepath; |
| 147 |
} |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
add_action( 'activate_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'frm_maybe_install' ); |
| 152 |
|
| 153 |
/** |
| 154 |
* This function is triggered when Formidable is activated. |
| 155 |
* |
| 156 |
* @return void |
| 157 |
*/ |
| 158 |
function frm_maybe_install() { |
| 159 |
if ( get_transient( FrmOnboardingWizardController::TRANSIENT_NAME ) !== 'no' ) { |
| 160 |
set_transient( |
| 161 |
FrmOnboardingWizardController::TRANSIENT_NAME, |
| 162 |
FrmOnboardingWizardController::TRANSIENT_VALUE, |
| 163 |
60 |
| 164 |
); |
| 165 |
} |
| 166 |
|
| 167 |
FrmAppController::handle_activation(); |
| 168 |
} |
| 169 |
|
| 170 |
register_deactivation_hook( |
| 171 |
__FILE__, |
| 172 |
function () { |
| 173 |
if ( ! class_exists( 'FrmCronController', false ) ) { |
| 174 |
require_once __DIR__ . '/classes/controllers/FrmCronController.php'; |
| 175 |
} |
| 176 |
|
| 177 |
FrmCronController::remove_crons(); |
| 178 |
} |
| 179 |
); |
| 180 |
|