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