PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.6
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.6
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / deprecated / FrmDeprecated.php

FrmDeprecated.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.6, at deprecated/FrmDeprecated.php

613 lines 16.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 4.06.02
171 * @deprecated 4.09.01
172 * @codeCoverageIgnore
173 */
174 public static function ajax_multiple_addons() {
175 _deprecated_function( __FUNCTION__, '4.09.01', 'FrmProAddonsController::' . __METHOD__ );
176 echo json_encode( __( 'Your plugin has been not been installed. Please update Formidable Pro to get downloads.', 'formidable' ) );
177 wp_die();
178 }
179
180 /**
181 * @since 3.04.03
182 * @deprecated 3.06
183 * @codeCoverageIgnore
184 * @return array
185 */
186 public static function error_for_license( $license ) {
187 _deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::error_for_license' );
188 $api = new FrmFormApi( $license );
189 return $api->error_for_license();
190 }
191
192 /**
193 * @since 3.04.03
194 * @deprecated 3.06
195 */
196 public static function reset_cached_addons( $license = '' ) {
197 _deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::reset_cached' );
198 $api = new FrmFormApi( $license );
199 $api->reset_cached();
200 }
201
202 /**
203 * @since 3.04.03
204 * @deprecated 3.06
205 * @return string
206 */
207 public static function get_cache_key( $license ) {
208 _deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::get_cache_key' );
209 $api = new FrmFormApi( $license );
210 return $api->get_cache_key();
211 }
212
213 /**
214 * @since 3.04.03
215 * @deprecated 3.06
216 * @codeCoverageIgnore
217 * @return array
218 */
219 public static function get_addon_info( $license = '' ) {
220 _deprecated_function( __FUNCTION__, '3.06', 'FrmFormApi::get_api_info' );
221 $api = new FrmFormApi( $license );
222 return $api->get_api_info();
223 }
224
225 /**
226 * Add a filter to shorten the EDD filename for Formidable plugin, and add-on, updates
227 *
228 * @since 2.03.08
229 * @deprecated 3.04.03
230 *
231 * @param boolean $return
232 * @param string $package
233 *
234 * @return boolean
235 */
236 public static function add_shorten_edd_filename_filter( $return, $package ) {
237 _deprecated_function( __FUNCTION__, '3.04.03' );
238
239 if ( strpos( $package, '/edd-sl/package_download/' ) !== false && strpos( $package, 'formidableforms.com' ) !== false ) {
240 add_filter( 'wp_unique_filename', 'FrmDeprecated::shorten_edd_filename', 10, 2 );
241 }
242
243 return $return;
244 }
245
246 /**
247 * Shorten the EDD filename for automatic updates
248 * Decreases size of file path so file path limit is not hit on Windows servers
249 *
250 * @since 2.03.08
251 * @deprecated 3.04.03
252 *
253 * @param string $filename
254 * @param string $ext
255 *
256 * @return string
257 */
258 public static function shorten_edd_filename( $filename, $ext ) {
259 _deprecated_function( __FUNCTION__, '3.04.03' );
260
261 $filename = substr( $filename, 0, 50 ) . $ext;
262 remove_filter( 'wp_unique_filename', 'FrmDeprecated::shorten_edd_filename', 10 );
263
264 return $filename;
265 }
266
267 /**
268 * @deprecated 3.0.04
269 */
270 public static function activation_install() {
271 _deprecated_function( __FUNCTION__, '3.0.04', 'FrmAppController::install' );
272 FrmDb::delete_cache_and_transient( 'frm_plugin_version' );
273 FrmFormActionsController::actions_init();
274 FrmAppController::install();
275 }
276
277 /**
278 * Routes for wordpress pages -- we're just replacing content
279 *
280 * @deprecated 3.0
281 */
282 public static function page_route( $content ) {
283 _deprecated_function( __FUNCTION__, '3.0' );
284 global $post;
285
286 if ( $post && isset( $_GET['form'] ) ) {
287 $content = FrmFormsController::page_preview();
288 }
289
290 return $content;
291 }
292
293 /**
294 * @deprecated 3.0
295 */
296 public static function edit_name( $field = 'name', $id = '' ) {
297 _deprecated_function( __FUNCTION__, '3.0' );
298
299 FrmAppHelper::permission_check( 'frm_edit_forms' );
300 check_ajax_referer( 'frm_ajax', 'nonce' );
301
302 if ( empty( $field ) ) {
303 $field = 'name';
304 }
305
306 if ( empty( $id ) ) {
307 $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
308 $id = str_replace( 'field_label_', '', $id );
309 }
310
311 $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
312 $value = trim( $value );
313 if ( trim( strip_tags( $value ) ) === '' ) {
314 // set blank value if there is no content
315 $value = '';
316 }
317
318 FrmField::update( $id, array( $field => $value ) );
319
320 do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
321
322 echo stripslashes( wp_kses_post( $value ) );
323 wp_die();
324 }
325
326 /**
327 * Load a single field in the form builder along with all needed variables
328 *
329 * @deprecated 3.0
330 *
331 * @param int $field_id
332 * @param array $values
333 * @param int $form_id
334 *
335 * @return array
336 */
337 public static function include_single_field( $field_id, $values, $form_id = 0 ) {
338 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldsController::load_single_field' );
339
340 $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
341 FrmFieldsController::load_single_field( $field, $values, $form_id );
342
343 return $field;
344 }
345
346 /**
347 * @deprecated 3.0
348 */
349 public static function bulk_create_template( $ids ) {
350 _deprecated_function( __FUNCTION__, '3.0', 'FrmForm::duplicate( $id, true, true )' );
351 FrmAppHelper::permission_check( 'frm_edit_forms' );
352
353 foreach ( $ids as $id ) {
354 FrmForm::duplicate( $id, true, true );
355 }
356
357 return __( 'Form template was Successfully Created', 'formidable' );
358 }
359
360 /**
361 * @deprecated 3.0
362 */
363 public static function edit_key() {
364 _deprecated_function( __FUNCTION__, '3.0' );
365 $values = self::edit_in_place_value( 'form_key' );
366 echo wp_kses( stripslashes( FrmForm::get_key_by_id( $values['form_id'] ) ), array() );
367 wp_die();
368 }
369
370 /**
371 * @deprecated 3.0
372 */
373 public static function edit_description() {
374 _deprecated_function( __FUNCTION__, '3.0' );
375 $values = self::edit_in_place_value( 'description' );
376 echo wp_kses_post( FrmAppHelper::use_wpautop( stripslashes( $values['description'] ) ) );
377 wp_die();
378 }
379
380 /**
381 * @deprecated 3.0
382 */
383 private static function edit_in_place_value( $field ) {
384 _deprecated_function( __FUNCTION__, '3.0' );
385 check_ajax_referer( 'frm_ajax', 'nonce' );
386 FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
387
388 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
389 $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
390
391 $values = array( $field => trim( $value ) );
392 FrmForm::update( $form_id, $values );
393 $values['form_id'] = $form_id;
394
395 return $values;
396 }
397
398 /**
399 * @deprecated 3.01
400 */
401 public static function sanitize_array( &$values ) {
402 _deprecated_function( __FUNCTION__, '3.01', 'FrmAppHelper::sanitize_value' );
403 FrmAppHelper::sanitize_value( 'wp_kses_post', $values );
404 }
405
406 /**
407 * @deprecated 3.0
408 *
409 * @param string $html
410 * @param array $field
411 * @param array $errors
412 * @param object $form
413 * @param array $args
414 *
415 * @return string
416 */
417 public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
418 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::prepare_field_html' );
419 $field_obj = FrmFieldFactory::get_field_type( $field['type'], $field );
420 return $field_obj->prepare_field_html( compact( 'errors', 'form' ) );
421 }
422
423 /**
424 * @deprecated 3.0
425 */
426 public static function get_default_field_opts( $type, $field = null, $limit = false ) {
427 if ( $limit ) {
428 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldHelper::get_default_field_options' );
429 $field_options = FrmFieldsHelper::get_default_field_options( $type );
430 } else {
431 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldHelper::get_default_field' );
432 $field_options = FrmFieldsHelper::get_default_field( $type );
433 }
434
435 return $field_options;
436 }
437
438 /**
439 * @deprecated 3.0
440 */
441 public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
442 _deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::remove_inline_conditions' );
443 FrmShortcodeHelper::remove_inline_conditions( $no_vars, $code, $replace_with, $html );
444 }
445
446 /**
447 * @deprecated 3.0
448 */
449 public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
450 _deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' );
451 return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
452 }
453
454 /**
455 * @deprecated 3.01
456 */
457 public static function get_sigle_label_postitions() {
458 _deprecated_function( __FUNCTION__, '3.01', 'FrmStylesHelper::get_single_label_positions' );
459 return FrmStylesHelper::get_single_label_positions();
460 }
461
462 /**
463 * @deprecated 3.02.03
464 */
465 public static function jquery_themes() {
466 _deprecated_function( __FUNCTION__, '3.02.03', 'FrmProStylesController::jquery_themes' );
467
468 $themes = array(
469 'ui-lightness' => 'UI Lightness',
470 'ui-darkness' => 'UI Darkness',
471 'smoothness' => 'Smoothness',
472 'start' => 'Start',
473 'redmond' => 'Redmond',
474 'sunny' => 'Sunny',
475 'overcast' => 'Overcast',
476 'le-frog' => 'Le Frog',
477 'flick' => 'Flick',
478 'pepper-grinder' => 'Pepper Grinder',
479 'eggplant' => 'Eggplant',
480 'dark-hive' => 'Dark Hive',
481 'cupertino' => 'Cupertino',
482 'south-street' => 'South Street',
483 'blitzer' => 'Blitzer',
484 'humanity' => 'Humanity',
485 'hot-sneaks' => 'Hot Sneaks',
486 'excite-bike' => 'Excite Bike',
487 'vader' => 'Vader',
488 'dot-luv' => 'Dot Luv',
489 'mint-choc' => 'Mint Choc',
490 'black-tie' => 'Black Tie',
491 'trontastic' => 'Trontastic',
492 'swanky-purse' => 'Swanky Purse',
493 );
494
495 $themes = apply_filters( 'frm_jquery_themes', $themes );
496 return $themes;
497 }
498
499 /**
500 * @deprecated 3.02.03
501 */
502 public static function enqueue_jquery_css() {
503 _deprecated_function( __FUNCTION__, '3.02.03', 'FrmProStylesController::enqueue_jquery_css' );
504
505 $form = self::get_form_for_page();
506 $theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
507 if ( $theme_css != -1 ) {
508 wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
509 }
510 }
511
512 /**
513 * @deprecated 3.02.03
514 */
515 public static function jquery_css_url( $theme_css ) {
516 _deprecated_function( __FUNCTION__, '3.02.03', 'FrmProStylesController::jquery_css_url' );
517
518 if ( ! is_callable( 'FrmProStylesController::jquery_css_url' ) ) {
519 return;
520 }
521
522 return FrmProStylesController::jquery_css_url( $theme_css );
523 }
524
525 /**
526 * @deprecated 3.02.03
527 */
528 public static function get_form_for_page() {
529 _deprecated_function( __FUNCTION__, '3.02.03' );
530
531 global $frm_vars;
532 $form_id = 'default';
533 if ( ! empty( $frm_vars['forms_loaded'] ) ) {
534 foreach ( $frm_vars['forms_loaded'] as $form ) {
535 if ( is_object( $form ) ) {
536 $form_id = $form->id;
537 break;
538 }
539 }
540 }
541 return $form_id;
542 }
543
544 /**
545 * @deprecated 3.0
546 */
547 public static function validate_url_field( &$errors, $field, $value, $args ) {
548 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' );
549
550 if ( $value == '' || ! in_array( $field->type, array( 'website', 'url' ) ) ) {
551 return;
552 }
553
554 FrmEntryValidate::validate_field_types( $errors, $field, $value, $args );
555 }
556
557 /**
558 * @deprecated 3.0
559 */
560 public static function validate_email_field( &$errors, $field, $value, $args ) {
561 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' );
562
563 if ( $field->type != 'email' ) {
564 return;
565 }
566
567 FrmEntryValidate::validate_field_types( $errors, $field, $value, $args );
568 }
569
570 /**
571 * @deprecated 3.0
572 */
573 public static function validate_number_field( &$errors, $field, $value, $args ) {
574 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' );
575
576 //validate the number format
577 if ( $field->type != 'number' ) {
578 return;
579 }
580
581 FrmEntryValidate::validate_field_types( $errors, $field, $value, $args );
582 }
583
584 /**
585 * @deprecated 3.0
586 */
587 public static function validate_recaptcha( &$errors, $field, $args ) {
588 _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldType::validate' );
589
590 if ( $field->type != 'captcha' ) {
591 return;
592 }
593
594 FrmEntryValidate::validate_field_types( $errors, $field, '', $args );
595 }
596
597 /**
598 * @deprecated 2.02.07
599 */
600 public static function dropdown_categories( $args ) {
601 _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
602
603 if ( FrmAppHelper::pro_is_installed() ) {
604 $args['location'] = 'front';
605 $dropdown = FrmProPost::get_category_dropdown( $args['field'], $args );
606 } else {
607 $dropdown = '';
608 }
609
610 return $dropdown;
611 }
612 }
613