|
1
|
|
|
<?php |
|
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
3
|
|
|
die( 'You are not allowed to call this page directly.' ); |
|
4
|
|
|
} |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class FrmDeprecated |
|
8
|
|
|
* |
|
9
|
|
|
* @since 3.04.03 |
|
10
|
|
|
* @codeCoverageIgnore |
|
11
|
|
|
*/ |
|
12
|
|
|
class FrmDeprecated { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @deprecated 2.3 |
|
16
|
|
|
*/ |
|
17
|
|
|
public static function deprecated( $function, $version ) { |
|
18
|
|
|
_deprecated_function( $function, $version ); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @deprecated 4.0 |
|
23
|
|
|
*/ |
|
24
|
|
|
public static function new_form( $values = array() ) { |
|
25
|
|
|
_deprecated_function( __FUNCTION__, '4.0', 'FrmFormsController::edit' ); |
|
26
|
|
|
|
|
27
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
28
|
|
|
|
|
29
|
|
|
$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
30
|
|
|
$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
31
|
|
|
|
|
32
|
|
|
if ( $action === 'create' ) { |
|
33
|
|
|
FrmFormsController::update( $values ); |
|
34
|
|
|
return; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$values = FrmFormsHelper::setup_new_vars( $values ); |
|
38
|
|
|
$id = FrmForm::create( $values ); |
|
39
|
|
|
$values['id'] = $id; |
|
40
|
|
|
|
|
41
|
|
|
FrmFormsController::edit( $values ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @deprecated 4.0 |
|
46
|
|
|
*/ |
|
47
|
|
|
public static function update_order() { |
|
48
|
|
|
_deprecated_function( __FUNCTION__, '4.0' ); |
|
49
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
50
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
51
|
|
|
|
|
52
|
|
|
$fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
|
53
|
|
|
foreach ( (array) $fields as $position => $item ) { |
|
54
|
|
|
FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
|
55
|
|
|
} |
|
56
|
|
|
wp_die(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @deprecated 4.0 |
|
61
|
|
|
* @param array $values - The form array |
|
62
|
|
|
*/ |
|
63
|
|
|
public static function builder_submit_button( $values ) { |
|
64
|
|
|
_deprecated_function( __FUNCTION__, '4.0' ); |
|
65
|
|
|
$page_action = FrmAppHelper::get_param( 'frm_action' ); |
|
66
|
|
|
$label = ( $page_action == 'edit' || $page_action == 'update' ) ? __( 'Update', 'formidable' ) : __( 'Create', 'formidable' ); |
|
67
|
|
|
|
|
68
|
|
|
?> |
|
69
|
|
|
<div class="postbox"> |
|
70
|
|
|
<p class="inside"> |
|
71
|
|
|
<button class="frm_submit_<?php echo esc_attr( ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_' ); ?>ajax button-primary frm_button_submit" type="button"> |
|
72
|
|
|
<?php echo esc_html( $label ); ?> |
|
73
|
|
|
</button> |
|
74
|
|
|
</p> |
|
75
|
|
|
</div> |
|
76
|
|
|
<?php |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @deprecated 3.04.03 |
|
81
|
|
|
*/ |
|
82
|
|
|
public static function get_licenses() { |
|
83
|
|
|
_deprecated_function( __FUNCTION__, '3.04.03' ); |
|
84
|
|
|
|
|
85
|
|
|
$allow_autofill = self::allow_autofill(); |
|
86
|
|
|
$required_role = $allow_autofill ? 'setup_network' : 'frm_change_settings'; |
|
87
|
|
|
FrmAppHelper::permission_check( $required_role ); |
|
88
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
89
|
|
|
|
|
90
|
|
|
if ( is_multisite() && get_site_option( 'frmpro-wpmu-sitewide' ) ) { |
|
91
|
|
|
$license = get_site_option( 'frmpro-credentials' ); |
|
92
|
|
|
} else { |
|
93
|
|
|
$license = get_option( 'frmpro-credentials' ); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
if ( $license && is_array( $license ) && isset( $license['license'] ) ) { |
|
97
|
|
|
$url = 'https://formidableforms.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) ); |
|
98
|
|
|
$licenses = self::send_api_request( |
|
99
|
|
|
$url, |
|
100
|
|
|
array( |
|
101
|
|
|
'name' => 'frm_api_licence', |
|
102
|
|
|
'expires' => 60 * 60 * 5, |
|
103
|
|
|
) |
|
104
|
|
|
); |
|
105
|
|
|
echo json_encode( $licenses ); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
wp_die(); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Don't allow subsite addon licenses to be fetched |
|
114
|
|
|
* unless the current user has super admin permissions |
|
115
|
|
|
* |
|
116
|
|
|
* @since 2.03.10 |
|
117
|
|
|
* @deprecated 3.04.03 |
|
118
|
|
|
*/ |
|
119
|
|
|
private static function allow_autofill() { |
|
120
|
|
|
$allow_autofill = FrmAppHelper::pro_is_installed(); |
|
121
|
|
|
if ( $allow_autofill && is_multisite() ) { |
|
122
|
|
|
$sitewide_activated = get_site_option( 'frmpro-wpmu-sitewide' ); |
|
123
|
|
|
if ( $sitewide_activated ) { |
|
124
|
|
|
$allow_autofill = current_user_can( 'setup_network' ); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
return $allow_autofill; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @deprecated 3.04.03 |
|
132
|
|
|
*/ |
|
133
|
|
|
private static function send_api_request( $url, $transient = array() ) { |
|
134
|
|
|
$data = get_transient( $transient['name'] ); |
|
135
|
|
|
if ( $data !== false ) { |
|
136
|
|
|
return $data; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
$arg_array = array( |
|
140
|
|
|
'body' => array( |
|
141
|
|
|
'url' => home_url(), |
|
142
|
|
|
), |
|
143
|
|
|
'timeout' => 15, |
|
144
|
|
|
'user-agent' => 'Formidable/' . FrmAppHelper::$plug_version . '; ' . home_url(), |
|
145
|
|
|
); |
|
146
|
|
|
|
|
147
|
|
|
$response = wp_remote_post( $url, $arg_array ); |
|
148
|
|
|
$body = wp_remote_retrieve_body( $response ); |
|
149
|
|
|
$data = false; |
|
150
|
|
|
if ( ! is_wp_error( $response ) && ! is_wp_error( $body ) ) { |
|
151
|
|
|
$data = json_decode( $body, true ); |
|
152
|
|
|
set_transient( $transient['name'], $data, $transient['expires'] ); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
return $data; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @since 3.04.03 |
|
160
|
|
|
* @deprecated 3.06 |
|
161
|
|
|
* @codeCoverageIgnore |
|
162
|
|
|
*/ |
|
163
|
|
|
public static function get_pro_updater() { |
|
164
|
|
|
_deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::get_pro_updater' ); |
|
165
|
|
|
$api = new FrmFormApi(); |
|
166
|
|
|
return $api->get_pro_updater(); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @since 3.04.02 |
|
171
|
|
|
* @deprecated 4.09.01 |
|
172
|
|
|
*/ |
|
173
|
|
|
public static function ajax_install_addon() { |
|
174
|
|
|
_deprecated_function( __FUNCTION__, '4.09.01', 'FrmProAddonsController::' . __METHOD__ ); |
|
175
|
|
|
echo json_encode( __( 'Your plugin has been not been installed. Please update Formidable Pro to get downloads.', 'formidable' ) ); |
|
176
|
|
|
wp_die(); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @since 4.06.02 |
|
181
|
|
|
* @deprecated 4.09.01 |
|
182
|
|
|
* @codeCoverageIgnore |
|
183
|
|
|
*/ |
|
184
|
|
|
public static function ajax_multiple_addons() { |
|
185
|
|
|
_deprecated_function( __FUNCTION__, '4.09.01', 'FrmProAddonsController::' . __METHOD__ ); |
|
186
|
|
|
echo json_encode( __( 'Your plugin has been not been installed. Please update Formidable Pro to get downloads.', 'formidable' ) ); |
|
187
|
|
|
wp_die(); |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @since 3.04.03 |
|
192
|
|
|
* @deprecated 3.06 |
|
193
|
|
|
* @codeCoverageIgnore |
|
194
|
|
|
* @return array |
|
195
|
|
|
*/ |
|
196
|
|
|
public static function error_for_license( $license ) { |
|
197
|
|
|
_deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::error_for_license' ); |
|
198
|
|
|
$api = new FrmFormApi( $license ); |
|
199
|
|
|
return $api->error_for_license(); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @since 3.04.03 |
|
204
|
|
|
* @deprecated 3.06 |
|
205
|
|
|
*/ |
|
206
|
|
|
public static function reset_cached_addons( $license = '' ) { |
|
207
|
|
|
_deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::reset_cached' ); |
|
208
|
|
|
$api = new FrmFormApi( $license ); |
|
209
|
|
|
$api->reset_cached(); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @since 3.04.03 |
|
214
|
|
|
* @deprecated 3.06 |
|
215
|
|
|
* @return string |
|
216
|
|
|
*/ |
|
217
|
|
|
public static function get_cache_key( $license ) { |
|
218
|
|
|
_deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::get_cache_key' ); |
|
219
|
|
|
$api = new FrmFormApi( $license ); |
|
220
|
|
|
return $api->get_cache_key(); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @since 3.04.03 |
|
225
|
|
|
* @deprecated 3.06 |
|
226
|
|
|
* @codeCoverageIgnore |
|
227
|
|
|
* @return array |
|
228
|
|
|
*/ |
|
229
|
|
|
public static function get_addon_info( $license = '' ) { |
|
230
|
|
|
_deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::get_api_info' ); |
|
231
|
|
|
$api = new FrmFormApi( $license ); |
|
232
|
|
|
return $api->get_api_info(); |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Add a filter to shorten the EDD filename for Formidable plugin, and add-on, updates |
|
237
|
|
|
* |
|
238
|
|
|
* @since 2.03.08 |
|
239
|
|
|
* @deprecated 3.04.03 |
|
240
|
|
|
* |
|
241
|
|
|
* @param boolean $return |
|
242
|
|
|
* @param string $package |
|
243
|
|
|
* |
|
244
|
|
|
* @return boolean |
|
245
|
|
|
*/ |
|
246
|
|
|
public static function add_shorten_edd_filename_filter( $return, $package ) { |
|
247
|
|
|
_deprecated_function( __FUNCTION__, '3.04.03' ); |
|
248
|
|
|
|
|
249
|
|
|
if ( strpos( $package, '/edd-sl/package_download/' ) !== false && strpos( $package, 'formidableforms.com' ) !== false ) { |
|
250
|
|
|
add_filter( 'wp_unique_filename', 'FrmDeprecated::shorten_edd_filename', 10, 2 ); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
return $return; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* Shorten the EDD filename for automatic updates |
|
258
|
|
|
* Decreases size of file path so file path limit is not hit on Windows servers |
|
259
|
|
|
* |
|
260
|
|
|
* @since 2.03.08 |
|
261
|
|
|
* @deprecated 3.04.03 |
|
262
|
|
|
* |
|
263
|
|
|
* @param string $filename |
|
264
|
|
|
* @param string $ext |
|
265
|
|
|
* |
|
266
|
|
|
* @return string |
|
267
|
|
|
*/ |
|
268
|
|
|
public static function shorten_edd_filename( $filename, $ext ) { |
|
269
|
|
|
_deprecated_function( __FUNCTION__, '3.04.03' ); |
|
270
|
|
|
|
|
271
|
|
|
$filename = substr( $filename, 0, 50 ) . $ext; |
|
272
|
|
|
remove_filter( 'wp_unique_filename', 'FrmDeprecated::shorten_edd_filename', 10 ); |
|
273
|
|
|
|
|
274
|
|
|
return $filename; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* Filter shortcodes in text widgets |
|
279
|
|
|
* |
|
280
|
|
|
* @deprecated 2.5.4 |
|
281
|
|
|
*/ |
|
282
|
|
|
public static function widget_text_filter( $content ) { |
|
283
|
|
|
_deprecated_function( __FUNCTION__, '2.5.4' ); |
|
284
|
|
|
$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
285
|
|
|
return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* Used to filter shortcode in text widgets |
|
290
|
|
|
* |
|
291
|
|
|
* @deprecated 2.5.4 |
|
292
|
|
|
*/ |
|
293
|
|
|
public static function widget_text_filter_callback( $matches ) { |
|
294
|
|
|
_deprecated_function( __FUNCTION__, '2.5.4' ); |
|
295
|
|
|
return do_shortcode( $matches[0] ); |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Deprecated in favor of wpmu_upgrade_site |
|
300
|
|
|
* |
|
301
|
|
|
* @deprecated 2.3 |
|
302
|
|
|
*/ |
|
303
|
|
|
public static function front_head() { |
|
304
|
|
|
_deprecated_function( __FUNCTION__, '2.3' ); |
|
305
|
|
|
if ( is_multisite() && FrmAppController::needs_update() ) { |
|
306
|
|
|
FrmAppController::install(); |
|
307
|
|
|
} |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* @deprecated 3.0.04 |
|
312
|
|
|
*/ |
|
313
|
|
|
public static function activation_install() { |
|
314
|
|
|
_deprecated_function( __FUNCTION__, '3.0.04', 'FrmAppController::install' ); |
|
315
|
|
|
FrmDb::delete_cache_and_transient( 'frm_plugin_version' ); |
|
316
|
|
|
FrmFormActionsController::actions_init(); |
|
317
|
|
|
FrmAppController::install(); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* Routes for wordpress pages -- we're just replacing content |
|
322
|
|
|
* |
|
323
|
|
|
* @deprecated 3.0 |
|
324
|
|
|
*/ |
|
325
|
|
|
public static function page_route( $content ) { |
|
326
|
|
|
_deprecated_function( __FUNCTION__, '3.0' ); |
|
327
|
|
|
global $post; |
|
328
|
|
|
|
|
329
|
|
|
if ( $post && isset( $_GET['form'] ) ) { |
|
330
|
|
|
$content = FrmFormsController::page_preview(); |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
return $content; |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* @deprecated 1.07.05 |
|
338
|
|
|
*/ |
|
339
|
|
|
public static function get_form_shortcode( $atts ) { |
|
340
|
|
|
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
341
|
|
|
return FrmFormsController::get_form_shortcode( $atts ); |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* @deprecated 1.07.05 |
|
346
|
|
|
*/ |
|
347
|
|
|
public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
348
|
|
|
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
349
|
|
|
return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* @deprecated 1.07.05 |
|
354
|
|
|
*/ |
|
355
|
|
|
public static function get_form( $filename, $form, $title, $description ) { |
|
356
|
|
|
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
357
|
|
|
return FrmFormsController::get_form( $form, $title, $description ); |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
/** |
|
361
|
|
|
* @deprecated 3.0 |
|
362
|
|
|
*/ |
|
363
|
|
|
public static function edit_name( $field = 'name', $id = '' ) { |
|
364
|
|
|
_deprecated_function( __FUNCTION__, '3.0' ); |
|
365
|
|
|
|
|
366
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
367
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
368
|
|
|
|
|
369
|
|
|
if ( empty( $field ) ) { |
|
370
|
|
|
$field = 'name'; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
if ( empty( $id ) ) { |
|
374
|
|
|
$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
|
375
|
|
|
$id = str_replace( 'field_label_', '', $id ); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
|
379
|
|
|
$value = trim( $value ); |
|
380
|
|
|
if ( trim( strip_tags( $value ) ) === '' ) { |
|
381
|
|
|
// set blank value if there is no content |
|
382
|
|
|
$value = ''; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
FrmField::update( $id, array( $field => $value ) ); |
|
386
|
|
|
|
|
387
|
|
|
do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
|
388
|
|
|
|
|
389
|
|
|
echo stripslashes( wp_kses_post( $value ) ); // WPCS: XSS ok. |
|
390
|
|
|
wp_die(); |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* Load a single field in the form builder along with all needed variables |
|
395
|
|
|
* |
|
396
|
|
|
* @deprecated 3.0 |
|
397
|
|
|
* |
|
398
|
|
|
* @param int $field_id |
|
399
|
|
|
* @param array $values |
|
400
|
|
|
* @param int $form_id |
|
401
|
|
|
* |
|
402
|
|
|
* @return array |
|
403
|
|
|
*/ |
|
404
|
|
|
public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
405
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldsController::load_single_field' ); |
|
406
|
|
|
|
|
407
|
|
|
$field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
408
|
|
|
FrmFieldsController::load_single_field( $field, $values, $form_id ); |
|
409
|
|
|
|
|
410
|
|
|
return $field; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/** |
|
414
|
|
|
* @deprecated 3.0 |
|
415
|
|
|
*/ |
|
416
|
|
|
public static function bulk_create_template( $ids ) { |
|
417
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmForm::duplicate( $id, true, true )' ); |
|
418
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
419
|
|
|
|
|
420
|
|
|
foreach ( $ids as $id ) { |
|
421
|
|
|
FrmForm::duplicate( $id, true, true ); |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
return __( 'Form template was Successfully Created', 'formidable' ); |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
/** |
|
428
|
|
|
* @deprecated 2.03 |
|
429
|
|
|
*/ |
|
430
|
|
|
public static function register_pro_scripts() { |
|
431
|
|
|
_deprecated_function( __FUNCTION__, '2.03', 'FrmProEntriesController::register_scripts' ); |
|
432
|
|
|
if ( FrmAppHelper::pro_is_installed() ) { |
|
433
|
|
|
FrmProEntriesController::register_scripts(); |
|
434
|
|
|
} |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
/** |
|
438
|
|
|
* @deprecated 3.0 |
|
439
|
|
|
*/ |
|
440
|
|
|
public static function edit_key() { |
|
441
|
|
|
_deprecated_function( __FUNCTION__, '3.0' ); |
|
442
|
|
|
$values = self::edit_in_place_value( 'form_key' ); |
|
443
|
|
|
echo wp_kses( stripslashes( FrmForm::get_key_by_id( $values['form_id'] ) ), array() ); |
|
444
|
|
|
wp_die(); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* @deprecated 3.0 |
|
449
|
|
|
*/ |
|
450
|
|
|
public static function edit_description() { |
|
451
|
|
|
_deprecated_function( __FUNCTION__, '3.0' ); |
|
452
|
|
|
$values = self::edit_in_place_value( 'description' ); |
|
453
|
|
|
echo wp_kses_post( FrmAppHelper::use_wpautop( stripslashes( $values['description'] ) ) ); |
|
454
|
|
|
wp_die(); |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* @deprecated 3.0 |
|
459
|
|
|
*/ |
|
460
|
|
|
private static function edit_in_place_value( $field ) { |
|
461
|
|
|
_deprecated_function( __FUNCTION__, '3.0' ); |
|
462
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
463
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
464
|
|
|
|
|
465
|
|
|
$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
|
466
|
|
|
$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
|
467
|
|
|
|
|
468
|
|
|
$values = array( $field => trim( $value ) ); |
|
469
|
|
|
FrmForm::update( $form_id, $values ); |
|
470
|
|
|
$values['form_id'] = $form_id; |
|
471
|
|
|
|
|
472
|
|
|
return $values; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
/** |
|
476
|
|
|
* @deprecated 1.07.05 |
|
477
|
|
|
*/ |
|
478
|
|
|
public static function add_default_templates( $path, $default = true, $template = true ) { |
|
479
|
|
|
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
480
|
|
|
|
|
481
|
|
|
$path = untrailingslashit( trim( $path ) ); |
|
482
|
|
|
$templates = glob( $path . '/*.php' ); |
|
483
|
|
|
|
|
484
|
|
|
for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
485
|
|
|
$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
486
|
|
|
$template_query = array( 'form_key' => $filename ); |
|
487
|
|
|
if ( $template ) { |
|
488
|
|
|
$template_query['is_template'] = 1; |
|
489
|
|
|
} |
|
490
|
|
|
if ( $default ) { |
|
491
|
|
|
$template_query['default_template'] = 1; |
|
492
|
|
|
} |
|
493
|
|
|
$form = FrmForm::getAll( $template_query, '', 1 ); |
|
494
|
|
|
|
|
495
|
|
|
$values = FrmFormsHelper::setup_new_vars(); |
|
496
|
|
|
$values['form_key'] = $filename; |
|
497
|
|
|
$values['is_template'] = $template; |
|
498
|
|
|
$values['status'] = 'published'; |
|
499
|
|
|
|
|
500
|
|
|
include( $templates[ $i ] ); |
|
501
|
|
|
|
|
502
|
|
|
//get updated form |
|
503
|
|
|
if ( isset( $form ) && ! empty( $form ) ) { |
|
504
|
|
|
$old_id = $form->id; |
|
505
|
|
|
$form = FrmForm::getOne( $form->id ); |
|
506
|
|
|
} else { |
|
507
|
|
|
$old_id = false; |
|
508
|
|
|
$form = FrmForm::getAll( $template_query, '', 1 ); |
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
if ( $form ) { |
|
512
|
|
|
do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
|
513
|
|
|
} |
|
514
|
|
|
} |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
|
|
* @deprecated 3.01 |
|
519
|
|
|
*/ |
|
520
|
|
|
public static function sanitize_array( &$values ) { |
|
521
|
|
|
_deprecated_function( __FUNCTION__, '3.01', 'FrmAppHelper::sanitize_value' ); |
|
522
|
|
|
FrmAppHelper::sanitize_value( 'wp_kses_post', $values ); |
|
523
|
|
|
} |
|
524
|
|
|
|
|
525
|
|
|
/** |
|
526
|
|
|
* Prepare and save settings in styles and actions |
|
527
|
|
|
* |
|
528
|
|
|
* @param array $settings |
|
529
|
|
|
* @param string $group |
|
530
|
|
|
* |
|
531
|
|
|
* @since 2.0.6 |
|
532
|
|
|
* @deprecated 2.05.06 |
|
533
|
|
|
*/ |
|
534
|
|
|
public static function save_settings( $settings, $group ) { |
|
535
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
536
|
|
|
return FrmDb::save_settings( $settings, $group ); |
|
537
|
|
|
} |
|
538
|
|
|
|
|
539
|
|
|
/** |
|
540
|
|
|
* Since actions are JSON encoded, we don't want any filters messing with it. |
|
541
|
|
|
* Remove the filters and then add them back in case any posts or views are |
|
542
|
|
|
* also being imported. |
|
543
|
|
|
* |
|
544
|
|
|
* Used when saving form actions and styles |
|
545
|
|
|
* |
|
546
|
|
|
* @since 2.0.4 |
|
547
|
|
|
* @deprecated 2.05.06 |
|
548
|
|
|
*/ |
|
549
|
|
|
public static function save_json_post( $settings ) { |
|
550
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
551
|
|
|
return FrmDb::save_json_post( $settings ); |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
|
|
/** |
|
555
|
|
|
* Check cache before fetching values and saving to cache |
|
556
|
|
|
* |
|
557
|
|
|
* @since 2.0 |
|
558
|
|
|
* @deprecated 2.05.06 |
|
559
|
|
|
* |
|
560
|
|
|
* @param string $cache_key The unique name for this cache |
|
561
|
|
|
* @param string $group The name of the cache group |
|
562
|
|
|
* @param string $query If blank, don't run a db call |
|
563
|
|
|
* @param string $type The wpdb function to use with this query |
|
564
|
|
|
* @return mixed $results The cache or query results |
|
565
|
|
|
*/ |
|
566
|
|
|
public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
567
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
568
|
|
|
return FrmDb::check_cache( $cache_key, $group, $query, $type, $time ); |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
|
|
/** |
|
572
|
|
|
* @deprecated 2.05.06 |
|
573
|
|
|
*/ |
|
574
|
|
|
public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) { |
|
575
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
576
|
|
|
FrmDb::set_cache( $cache_key, $results, $group, $time ); |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
/** |
|
580
|
|
|
* Keep track of the keys cached in each group so they can be deleted |
|
581
|
|
|
* in Redis and Memcache |
|
582
|
|
|
* @deprecated 2.05.06 |
|
583
|
|
|
*/ |
|
584
|
|
|
public static function add_key_to_group_cache( $key, $group ) { |
|
585
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
586
|
|
|
FrmDb::add_key_to_group_cache( $key, $group ); |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
|
|
/** |
|
590
|
|
|
* @deprecated 2.05.06 |
|
591
|
|
|
*/ |
|
592
|
|
|
public static function get_group_cached_keys( $group ) { |
|
593
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
594
|
|
|
return FrmDb::get_group_cached_keys( $group ); |
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
/** |
|
598
|
|
|
* @since 2.0 |
|
599
|
|
|
* @deprecated 2.05.06 |
|
600
|
|
|
* @param string $cache_key |
|
601
|
|
|
*/ |
|
602
|
|
|
public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
|
603
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
604
|
|
|
FrmDb::delete_cache_and_transient( $cache_key, $group ); |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
/** |
|
608
|
|
|
* @since 2.0 |
|
609
|
|
|
* @deprecated 2.05.06 |
|
610
|
|
|
* |
|
611
|
|
|
* @param string $group The name of the cache group |
|
612
|
|
|
*/ |
|
613
|
|
|
public static function cache_delete_group( $group ) { |
|
614
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
615
|
|
|
FrmDb::cache_delete_group( $group ); |
|
616
|
|
|
} |
|
617
|
|
|
|
|
618
|
|
|
/** |
|
619
|
|
|
* Added for < WP 4.0 compatability |
|
620
|
|
|
* |
|
621
|
|
|
* @since 1.07.10 |
|
622
|
|
|
* @deprecated 2.05.06 |
|
623
|
|
|
* |
|
624
|
|
|
* @param string $term The value to escape |
|
625
|
|
|
* @return string The escaped value |
|
626
|
|
|
*/ |
|
627
|
|
|
public static function esc_like( $term ) { |
|
628
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
629
|
|
|
return FrmDb::esc_like( $term ); |
|
630
|
|
|
} |
|
631
|
|
|
|
|
632
|
|
|
/** |
|
633
|
|
|
* @param string $order_query |
|
634
|
|
|
* @deprecated 2.05.06 |
|
635
|
|
|
*/ |
|
636
|
|
|
public static function esc_order( $order_query ) { |
|
637
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
638
|
|
|
return FrmDb::esc_order( $order_query ); |
|
639
|
|
|
} |
|
640
|
|
|
|
|
641
|
|
|
/** |
|
642
|
|
|
* Make sure this is ordering by either ASC or DESC |
|
643
|
|
|
* @deprecated 2.05.06 |
|
644
|
|
|
*/ |
|
645
|
|
|
public static function esc_order_by( &$order_by ) { |
|
646
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
647
|
|
|
FrmDb::esc_order_by( $order_by ); |
|
648
|
|
|
} |
|
649
|
|
|
|
|
650
|
|
|
/** |
|
651
|
|
|
* @param string $limit |
|
652
|
|
|
* @deprecated 2.05.06 |
|
653
|
|
|
*/ |
|
654
|
|
|
public static function esc_limit( $limit ) { |
|
655
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
656
|
|
|
return FrmDb::esc_limit( $limit ); |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
|
|
/** |
|
660
|
|
|
* Get an array of values ready to go through $wpdb->prepare |
|
661
|
|
|
* @since 2.0 |
|
662
|
|
|
* @deprecated 2.05.06 |
|
663
|
|
|
*/ |
|
664
|
|
|
public static function prepare_array_values( $array, $type = '%s' ) { |
|
665
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
666
|
|
|
return FrmDb::prepare_array_values( $array, $type ); |
|
667
|
|
|
} |
|
668
|
|
|
|
|
669
|
|
|
/** |
|
670
|
|
|
* @deprecated 2.05.06 |
|
671
|
|
|
*/ |
|
672
|
|
|
public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
673
|
|
|
_deprecated_function( __FUNCTION__, '2.05.06', 'FrmDb::' . __FUNCTION__ ); |
|
674
|
|
|
return FrmDb::prepend_and_or_where( $starts_with, $where ); |
|
675
|
|
|
} |
|
676
|
|
|
|
|
677
|
|
|
/** |
|
678
|
|
|
* @deprecated 2.05.06 |
|
679
|
|
|
*/ |
|
680
|
|
|
public static function upgrade() { |
|
681
|
|
|
$db = new FrmDbDeprecated(); |
|
682
|
|
|
$db->upgrade(); |
|
683
|
|
|
} |
|
684
|
|
|
|
|
685
|
|
|
/** |
|
686
|
|
|
* @deprecated 2.05.06 |
|
687
|
|
|
*/ |
|
688
|
|
|
public static function collation() { |
|
689
|
|
|
$db = new FrmDbDeprecated(); |
|
690
|
|
|
return $db->collation(); |
|
691
|
|
|
} |
|
692
|
|
|
|
|
693
|
|
|
/** |
|
694
|
|
|
* @deprecated 2.05.06 |
|
695
|
|
|
*/ |
|
696
|
|
|
public static function uninstall() { |
|
697
|
|
|
$db = new FrmDbDeprecated(); |
|
698
|
|
|
$db->uninstall(); |
|
699
|
|
|
} |
|
700
|
|
|
|
|
701
|
|
|
/** |
|
702
|
|
|
* @deprecated 3.0 |
|
703
|
|
|
* |
|
704
|
|
|
* @param string $html |
|
705
|
|
|
* @param array $field |
|
706
|
|
|
* @param array $errors |
|
707
|
|
|
* @param object $form |
|
708
|
|
|
* @param array $args |
|
709
|
|
|
* |
|
710
|
|
|
* @return string |
|
711
|
|
|
*/ |
|
712
|
|
|
public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
|
713
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::prepare_field_html' ); |
|
714
|
|
|
$field_obj = FrmFieldFactory::get_field_type( $field['type'], $field ); |
|
715
|
|
|
return $field_obj->prepare_field_html( compact( 'errors', 'form' ) ); |
|
716
|
|
|
} |
|
717
|
|
|
|
|
718
|
|
|
/** |
|
719
|
|
|
* @deprecated 3.0 |
|
720
|
|
|
*/ |
|
721
|
|
|
public static function get_default_field_opts( $type, $field = null, $limit = false ) { |
|
722
|
|
|
if ( $limit ) { |
|
723
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldHelper::get_default_field_options' ); |
|
724
|
|
|
$field_options = FrmFieldsHelper::get_default_field_options( $type ); |
|
725
|
|
|
} else { |
|
726
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldHelper::get_default_field' ); |
|
727
|
|
|
$field_options = FrmFieldsHelper::get_default_field( $type ); |
|
728
|
|
|
} |
|
729
|
|
|
|
|
730
|
|
|
return $field_options; |
|
731
|
|
|
} |
|
732
|
|
|
|
|
733
|
|
|
/** |
|
734
|
|
|
* @deprecated 2.02.07 |
|
735
|
|
|
*/ |
|
736
|
|
|
public static function dropdown_categories( $args ) { |
|
737
|
|
|
_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |
|
738
|
|
|
|
|
739
|
|
|
if ( FrmAppHelper::pro_is_installed() ) { |
|
740
|
|
|
$args['location'] = 'front'; |
|
741
|
|
|
$dropdown = FrmProPost::get_category_dropdown( $args['field'], $args ); |
|
742
|
|
|
} else { |
|
743
|
|
|
$dropdown = ''; |
|
744
|
|
|
} |
|
745
|
|
|
|
|
746
|
|
|
return $dropdown; |
|
747
|
|
|
} |
|
748
|
|
|
|
|
749
|
|
|
/** |
|
750
|
|
|
* @deprecated 3.0 |
|
751
|
|
|
*/ |
|
752
|
|
|
public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
753
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::remove_inline_conditions' ); |
|
754
|
|
|
FrmShortcodeHelper::remove_inline_conditions( $no_vars, $code, $replace_with, $html ); |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
/** |
|
758
|
|
|
* @deprecated 3.0 |
|
759
|
|
|
*/ |
|
760
|
|
|
public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
|
761
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' ); |
|
762
|
|
|
return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
763
|
|
|
} |
|
764
|
|
|
|
|
765
|
|
|
/** |
|
766
|
|
|
* @deprecated 3.01 |
|
767
|
|
|
*/ |
|
768
|
|
|
public static function get_sigle_label_postitions() { |
|
769
|
|
|
_deprecated_function( __FUNCTION__, '3.01', 'FrmStylesHelper::get_single_label_positions' ); |
|
770
|
|
|
return FrmStylesHelper::get_single_label_positions(); |
|
771
|
|
|
} |
|
772
|
|
|
|
|
773
|
|
|
/** |
|
774
|
|
|
* @deprecated 3.02.03 |
|
775
|
|
|
*/ |
|
776
|
|
|
public static function jquery_themes() { |
|
777
|
|
|
_deprecated_function( __FUNCTION__, '3.02.03', 'FrmProStylesController::jquery_themes' ); |
|
778
|
|
|
|
|
779
|
|
|
$themes = array( |
|
780
|
|
|
'ui-lightness' => 'UI Lightness', |
|
781
|
|
|
'ui-darkness' => 'UI Darkness', |
|
782
|
|
|
'smoothness' => 'Smoothness', |
|
783
|
|
|
'start' => 'Start', |
|
784
|
|
|
'redmond' => 'Redmond', |
|
785
|
|
|
'sunny' => 'Sunny', |
|
786
|
|
|
'overcast' => 'Overcast', |
|
787
|
|
|
'le-frog' => 'Le Frog', |
|
788
|
|
|
'flick' => 'Flick', |
|
789
|
|
|
'pepper-grinder' => 'Pepper Grinder', |
|
790
|
|
|
'eggplant' => 'Eggplant', |
|
791
|
|
|
'dark-hive' => 'Dark Hive', |
|
792
|
|
|
'cupertino' => 'Cupertino', |
|
793
|
|
|
'south-street' => 'South Street', |
|
794
|
|
|
'blitzer' => 'Blitzer', |
|
795
|
|
|
'humanity' => 'Humanity', |
|
796
|
|
|
'hot-sneaks' => 'Hot Sneaks', |
|
797
|
|
|
'excite-bike' => 'Excite Bike', |
|
798
|
|
|
'vader' => 'Vader', |
|
799
|
|
|
'dot-luv' => 'Dot Luv', |
|
800
|
|
|
'mint-choc' => 'Mint Choc', |
|
801
|
|
|
'black-tie' => 'Black Tie', |
|
802
|
|
|
'trontastic' => 'Trontastic', |
|
803
|
|
|
'swanky-purse' => 'Swanky Purse', |
|
804
|
|
|
); |
|
805
|
|
|
|
|
806
|
|
|
$themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
807
|
|
|
return $themes; |
|
808
|
|
|
} |
|
809
|
|
|
|
|
810
|
|
|
/** |
|
811
|
|
|
* @deprecated 3.02.03 |
|
812
|
|
|
*/ |
|
813
|
|
|
public static function enqueue_jquery_css() { |
|
814
|
|
|
_deprecated_function( __FUNCTION__, '3.02.03', 'FrmProStylesController::enqueue_jquery_css' ); |
|
815
|
|
|
|
|
816
|
|
|
$form = self::get_form_for_page(); |
|
817
|
|
|
$theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
|
818
|
|
|
if ( $theme_css != -1 ) { |
|
819
|
|
|
wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
820
|
|
|
} |
|
821
|
|
|
} |
|
822
|
|
|
|
|
823
|
|
|
/** |
|
824
|
|
|
* @deprecated 3.02.03 |
|
825
|
|
|
*/ |
|
826
|
|
|
public static function jquery_css_url( $theme_css ) { |
|
827
|
|
|
_deprecated_function( __FUNCTION__, '3.02.03', 'FrmProStylesController::jquery_css_url' ); |
|
828
|
|
|
|
|
829
|
|
|
if ( $theme_css == -1 ) { |
|
830
|
|
|
return; |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
834
|
|
|
$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
835
|
|
|
} elseif ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
836
|
|
|
$css_file = $theme_css; |
|
837
|
|
|
} else { |
|
838
|
|
|
$uploads = FrmStylesHelper::get_upload_base(); |
|
839
|
|
|
$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
|
840
|
|
|
if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
841
|
|
|
$css_file = $uploads['baseurl'] . $file_path; |
|
842
|
|
|
} else { |
|
843
|
|
|
$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
|
844
|
|
|
} |
|
845
|
|
|
} |
|
846
|
|
|
|
|
847
|
|
|
return $css_file; |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
/** |
|
851
|
|
|
* @deprecated 3.02.03 |
|
852
|
|
|
*/ |
|
853
|
|
|
public static function get_form_for_page() { |
|
854
|
|
|
_deprecated_function( __FUNCTION__, '3.02.03' ); |
|
855
|
|
|
|
|
856
|
|
|
global $frm_vars; |
|
857
|
|
|
$form_id = 'default'; |
|
858
|
|
|
if ( ! empty( $frm_vars['forms_loaded'] ) ) { |
|
859
|
|
|
foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
860
|
|
|
if ( is_object( $form ) ) { |
|
861
|
|
|
$form_id = $form->id; |
|
862
|
|
|
break; |
|
863
|
|
|
} |
|
864
|
|
|
} |
|
865
|
|
|
} |
|
866
|
|
|
return $form_id; |
|
867
|
|
|
} |
|
868
|
|
|
|
|
869
|
|
|
/** |
|
870
|
|
|
* @deprecated 3.0 |
|
871
|
|
|
*/ |
|
872
|
|
|
public static function validate_url_field( &$errors, $field, $value, $args ) { |
|
873
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' ); |
|
874
|
|
|
|
|
875
|
|
|
if ( $value == '' || ! in_array( $field->type, array( 'website', 'url' ) ) ) { |
|
876
|
|
|
return; |
|
877
|
|
|
} |
|
878
|
|
|
|
|
879
|
|
|
FrmEntryValidate::validate_field_types( $errors, $field, $value, $args ); |
|
880
|
|
|
} |
|
881
|
|
|
|
|
882
|
|
|
/** |
|
883
|
|
|
* @deprecated 3.0 |
|
884
|
|
|
*/ |
|
885
|
|
View Code Duplication |
public static function validate_email_field( &$errors, $field, $value, $args ) { |
|
|
|
|
|
|
886
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' ); |
|
887
|
|
|
|
|
888
|
|
|
if ( $field->type != 'email' ) { |
|
889
|
|
|
return; |
|
890
|
|
|
} |
|
891
|
|
|
|
|
892
|
|
|
FrmEntryValidate::validate_field_types( $errors, $field, $value, $args ); |
|
893
|
|
|
} |
|
894
|
|
|
|
|
895
|
|
|
/** |
|
896
|
|
|
* @deprecated 3.0 |
|
897
|
|
|
*/ |
|
898
|
|
View Code Duplication |
public static function validate_number_field( &$errors, $field, $value, $args ) { |
|
|
|
|
|
|
899
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' ); |
|
900
|
|
|
|
|
901
|
|
|
//validate the number format |
|
902
|
|
|
if ( $field->type != 'number' ) { |
|
903
|
|
|
return; |
|
904
|
|
|
} |
|
905
|
|
|
|
|
906
|
|
|
FrmEntryValidate::validate_field_types( $errors, $field, $value, $args ); |
|
907
|
|
|
} |
|
908
|
|
|
|
|
909
|
|
|
/** |
|
910
|
|
|
* @deprecated 3.0 |
|
911
|
|
|
*/ |
|
912
|
|
View Code Duplication |
public static function validate_recaptcha( &$errors, $field, $args ) { |
|
|
|
|
|
|
913
|
|
|
_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' ); |
|
914
|
|
|
|
|
915
|
|
|
if ( $field->type != 'captcha' ) { |
|
916
|
|
|
return; |
|
917
|
|
|
} |
|
918
|
|
|
|
|
919
|
|
|
FrmEntryValidate::validate_field_types( $errors, $field, '', $args ); |
|
920
|
|
|
} |
|
921
|
|
|
} |
|
922
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.