PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.06.03
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.06.03
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 / classes / controllers / FrmFormsController.php

FrmFormsController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 4.06.03, at classes/controllers/FrmFormsController.php

2,110 lines 60.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class FrmFormsController {
4
5 public static function menu() {
6 $menu_label = __( 'Forms', 'formidable' );
7 if ( ! FrmAppHelper::pro_is_installed() ) {
8 $menu_label .= ' (Lite)';
9 }
10 add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11
12 self::maybe_load_listing_hooks();
13 }
14
15 public static function maybe_load_listing_hooks() {
16 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
17 if ( ! empty( $action ) && ! in_array( $action, array( 'list', 'trash', 'untrash', 'destroy' ) ) ) {
18 return;
19 }
20
21 add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22
23 add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24 add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 }
26
27 public static function head() {
28 if ( wp_is_mobile() ) {
29 wp_enqueue_script( 'jquery-touch-punch' );
30 }
31 }
32
33 public static function register_widgets() {
34 require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
35 register_widget( 'FrmShowForm' );
36 }
37
38 /**
39 * Show a message about conditional logic
40 *
41 * @since 4.06.03
42 */
43 public static function logic_tip() {
44 echo '<a href="javascript:void(0)" class="frm_noallow frm_show_upgrade frm_add_logic_link" data-upgrade="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '" data-message="' . esc_attr__( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' ) . esc_attr( ' <img src="https://cdn.formidableforms.com/wp-content/themes/fp2015git/images/survey/survey-logic.png" srcset="https://cdn.formidableforms.com/wp-content/themes/fp2015git/images/survey/survey-logic@2x.png 2x" alt="Conditional Logic options"/>' ) . '" data-medium="builder" data-content="logic">';
45 FrmAppHelper::icon_by_class( 'frmfont frm_swap_icon' );
46 esc_html_e( 'Add Conditional Logic', 'formidable' );
47 echo '</a>';
48 }
49
50 /**
51 * By default, Divi processes form shortcodes on the edit post page.
52 * Now that won't do.
53 *
54 * @since 3.01
55 */
56 public static function prevent_divi_conflict( $shortcodes ) {
57 $shortcodes[] = 'formidable';
58
59 return $shortcodes;
60 }
61
62 public static function list_form() {
63 FrmAppHelper::permission_check( 'frm_view_forms' );
64
65 $message = '';
66 $params = FrmForm::list_page_params();
67 $errors = self::process_bulk_form_actions( array() );
68 if ( isset( $errors['message'] ) ) {
69 $message = $errors['message'];
70 unset( $errors['message'] );
71 }
72 $errors = apply_filters( 'frm_admin_list_form_action', $errors );
73
74 return self::display_forms_list( $params, $message, $errors );
75 }
76
77 /**
78 * Choose which type of form to create
79 *
80 * @since 3.06
81 */
82 public static function add_new() {
83 self::list_templates();
84 }
85
86 /**
87 * Load the scripts before a modal can be triggered.
88 *
89 * @since 4.0
90 */
91 private static function init_modal() {
92 wp_enqueue_script( 'jquery-ui-dialog' );
93 wp_enqueue_style( 'jquery-ui-dialog' );
94 }
95
96 /**
97 * Create the default email action
98 *
99 * @since 2.02.11
100 *
101 * @param object $form
102 */
103 private static function create_default_email_action( $form ) {
104 FrmForm::maybe_get_form( $form );
105 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
106
107 if ( $create_email ) {
108 $action_control = FrmFormActionsController::get_form_actions( 'email' );
109 $action_control->create( $form->id );
110 }
111 }
112
113 public static function edit( $values = false ) {
114 FrmAppHelper::permission_check( 'frm_edit_forms' );
115
116 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
117
118 return self::get_edit_vars( $id );
119 }
120
121 public static function settings( $id = false, $message = '' ) {
122 FrmAppHelper::permission_check( 'frm_edit_forms' );
123
124 if ( ! $id || ! is_numeric( $id ) ) {
125 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
126 }
127
128 return self::get_settings_vars( $id, array(), $message );
129 }
130
131 public static function update_settings() {
132 FrmAppHelper::permission_check( 'frm_edit_forms' );
133
134 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135
136 $errors = FrmForm::validate( $_POST );
137 $warnings = FrmFormsHelper::check_for_warnings( $_POST );
138
139 if ( count( $errors ) > 0 ) {
140 return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
141 }
142
143 do_action( 'frm_before_update_form_settings', $id );
144
145 FrmForm::update( $id, $_POST );
146
147 $message = __( 'Settings Successfully Updated', 'formidable' );
148
149 return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
150 }
151
152 public static function update( $values = array() ) {
153 if ( empty( $values ) ) {
154 $values = $_POST;
155 }
156
157 // Set radio button and checkbox meta equal to "other" value.
158 if ( FrmAppHelper::pro_is_installed() ) {
159 $values = FrmProEntry::mod_other_vals( $values, 'back' );
160 }
161
162 $errors = FrmForm::validate( $values );
163 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
164 if ( $permission_error !== false ) {
165 $errors['form'] = $permission_error;
166 }
167
168 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
169
170 if ( count( $errors ) > 0 ) {
171 return self::get_edit_vars( $id, $errors );
172 } else {
173 FrmForm::update( $id, $values );
174 $message = __( 'Form was successfully updated.', 'formidable' );
175
176 if ( self::is_too_long( $values ) ) {
177 $message .= '<br/> ' . sprintf(
178 /* translators: %1$s: Start link HTML, %2$s: end link HTML */
179 __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
180 '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
181 '</a>'
182 );
183 }
184
185 if ( defined( 'DOING_AJAX' ) ) {
186 wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // WPCS: XSS ok.
187 }
188
189 return self::get_edit_vars( $id, array(), $message );
190 }
191 }
192
193 /**
194 * Check if the value at the end of the form was included.
195 * If it's missing, it means other values at the end of the form
196 * were likely not saved either.
197 *
198 * @since 3.06.01
199 */
200 private static function is_too_long( $values ) {
201 return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
202 }
203
204 /**
205 * Redirect to the url for creating from a template
206 * Also delete the current form
207 *
208 * @since 2.0
209 * @deprecated 3.06
210 */
211 public static function _create_from_template() {
212 _deprecated_function( __FUNCTION__, '3.06' );
213
214 FrmAppHelper::permission_check( 'frm_edit_forms' );
215 check_ajax_referer( 'frm_ajax', 'nonce' );
216
217 $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
218 $template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
219
220 if ( $current_form ) {
221 FrmForm::destroy( $current_form );
222 }
223
224 echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
225 wp_die();
226 }
227
228 public static function duplicate() {
229 FrmAppHelper::permission_check( 'frm_edit_forms' );
230
231 $params = FrmForm::list_page_params();
232 $form = FrmForm::duplicate( $params['id'], $params['template'], true );
233 $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
234 if ( $form ) {
235 return self::get_edit_vars( $form, array(), $message, true );
236 } else {
237 return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
238 }
239 }
240
241 public static function page_preview() {
242 $params = FrmForm::list_page_params();
243 if ( ! $params['form'] ) {
244 return;
245 }
246
247 $form = FrmForm::getOne( $params['form'] );
248 if ( $form ) {
249 return self::show_form( $form->id, '', true, true );
250 }
251 }
252
253 /**
254 * @since 3.0
255 */
256 public static function show_page_preview() {
257 echo self::page_preview(); // WPCS: XSS ok.
258 }
259
260 public static function preview() {
261 do_action( 'frm_wp' );
262
263 global $frm_vars;
264 $frm_vars['preview'] = true;
265
266 self::load_wp();
267
268 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
269 if ( $include_theme ) {
270 self::set_preview_query();
271 self::load_theme_preview();
272 } else {
273 self::load_direct_preview();
274 }
275
276 wp_die();
277 }
278
279 /**
280 * @since 3.0
281 */
282 private static function load_wp() {
283 if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284 global $wp;
285 $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
286 include_once( $root . '/wp-config.php' );
287 $wp->init();
288 $wp->register_globals();
289 }
290 }
291
292 private static function set_preview_query() {
293 $random_page = get_posts(
294 array(
295 'numberposts' => 1,
296 'orderby' => 'date',
297 'order' => 'ASC',
298 'post_type' => 'page',
299 )
300 );
301
302 if ( ! empty( $random_page ) ) {
303 $random_page = reset( $random_page );
304 query_posts(
305 array(
306 'post_type' => 'page',
307 'page_id' => $random_page->ID,
308 )
309 );
310 }
311 }
312
313 /**
314 * @since 3.0
315 */
316 private static function load_theme_preview() {
317 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
318 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
319 add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
320 add_action( 'loop_no_results', 'FrmFormsController::show_page_preview' );
321 add_filter( 'is_active_sidebar', '__return_false' );
322 FrmStylesController::enqueue_css( 'enqueue', true );
323 get_template_part( 'page' );
324 }
325
326 /**
327 * Set the page title for the theme preview page
328 *
329 * @since 3.0
330 */
331 public static function preview_page_title( $title ) {
332 if ( in_the_loop() ) {
333 $title = self::preview_title( $title );
334 }
335
336 return $title;
337 }
338
339 /**
340 * Set the page title for the theme preview page
341 *
342 * @since 3.0
343 */
344 public static function preview_title( $title ) {
345 return __( 'Form Preview', 'formidable' );
346 }
347
348 /**
349 * Set the page content for the theme preview page
350 *
351 * @since 3.0
352 */
353 public static function preview_content( $content ) {
354 if ( in_the_loop() ) {
355 $content = self::show_page_preview();
356 }
357
358 return $content;
359 }
360
361 /**
362 * @since 3.0
363 */
364 private static function load_direct_preview() {
365 header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
366
367 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
368 if ( $key == '' ) {
369 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
370 }
371
372 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
373 if ( empty( $form ) ) {
374 $form = FrmForm::getAll( array(), '', 1 );
375 }
376
377 require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
378 }
379
380 public static function untrash() {
381 self::change_form_status( 'untrash' );
382 }
383
384 public static function bulk_untrash( $ids ) {
385 FrmAppHelper::permission_check( 'frm_edit_forms' );
386
387 $count = FrmForm::set_status( $ids, 'published' );
388
389 /* translators: %1$s: Number of forms */
390 $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
391
392 return $message;
393 }
394
395 /**
396 * @since 3.06
397 */
398 public static function ajax_trash() {
399 FrmAppHelper::permission_check( 'frm_delete_forms' );
400 check_ajax_referer( 'frm_ajax', 'nonce' );
401 $form_id = FrmAppHelper::get_param( 'id', '', 'post', 'absint' );
402 FrmForm::set_status( $form_id, 'trash' );
403 wp_die();
404 }
405
406 public static function trash() {
407 self::change_form_status( 'trash' );
408 }
409
410 /**
411 * @param string $status
412 *
413 * @return int The number of forms changed
414 */
415 public static function change_form_status( $status ) {
416 $available_status = array(
417 'untrash' => array(
418 'permission' => 'frm_edit_forms',
419 'new_status' => 'published',
420 ),
421 'trash' => array(
422 'permission' => 'frm_delete_forms',
423 'new_status' => 'trash',
424 ),
425 );
426
427 if ( ! isset( $available_status[ $status ] ) ) {
428 return;
429 }
430
431 FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
432
433 $params = FrmForm::list_page_params();
434
435 //check nonce url
436 check_admin_referer( $status . '_form_' . $params['id'] );
437
438 $count = 0;
439 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
440 $count ++;
441 }
442
443 $form_type = FrmAppHelper::get_simple_request(
444 array(
445 'param' => 'form_type',
446 'type' => 'request',
447 )
448 );
449
450 /* translators: %1$s: Number of forms */
451 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
452
453 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
454 $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
455
456 $message = $available_status[ $status ]['message'];
457
458 self::display_forms_list( $params, $message );
459 }
460
461 public static function bulk_trash( $ids ) {
462 FrmAppHelper::permission_check( 'frm_delete_forms' );
463
464 $count = 0;
465 foreach ( $ids as $id ) {
466 if ( FrmForm::trash( $id ) ) {
467 $count ++;
468 }
469 }
470
471 $current_page = FrmAppHelper::get_simple_request(
472 array(
473 'param' => 'form_type',
474 'type' => 'request',
475 )
476 );
477 $message = sprintf(
478 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
479 _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ),
480 $count,
481 '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">',
482 '</a>'
483 );
484
485 return $message;
486 }
487
488 public static function destroy() {
489 FrmAppHelper::permission_check( 'frm_delete_forms' );
490
491 $params = FrmForm::list_page_params();
492
493 // Check nonce url.
494 check_admin_referer( 'destroy_form_' . $params['id'] );
495
496 $count = 0;
497 if ( FrmForm::destroy( $params['id'] ) ) {
498 $count ++;
499 }
500
501 /* translators: %1$s: Number of forms */
502 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
503
504 self::display_forms_list( $params, $message );
505 }
506
507 public static function bulk_destroy( $ids ) {
508 FrmAppHelper::permission_check( 'frm_delete_forms' );
509
510 $count = 0;
511 foreach ( $ids as $id ) {
512 $d = FrmForm::destroy( $id );
513 if ( $d ) {
514 $count ++;
515 }
516 }
517
518 /* translators: %1$s: Number of forms */
519 $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
520
521 return $message;
522 }
523
524 private static function delete_all() {
525 // Check nonce url.
526 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
527 if ( $permission_error !== false ) {
528 self::display_forms_list( array(), '', array( $permission_error ) );
529
530 return;
531 }
532
533 $count = FrmForm::scheduled_delete( time() );
534
535 /* translators: %1$s: Number of forms */
536 $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
537
538 self::display_forms_list( array(), $message );
539 }
540
541 /**
542 * Create a new form from the modal.
543 *
544 * @since 4.0
545 */
546 public static function build_new_form() {
547 global $wpdb;
548
549 FrmAppHelper::permission_check( 'frm_edit_forms' );
550 check_ajax_referer( 'frm_ajax', 'nonce' );
551
552 $new_values = self::get_modal_values();
553 $new_values['form_key'] = $new_values['name'];
554
555 $form_id = FrmForm::create( $new_values );
556
557 self::create_default_email_action( $form_id );
558
559 $response = array(
560 'redirect' => FrmForm::get_edit_link( $form_id ),
561 );
562
563 echo wp_json_encode( $response );
564 wp_die();
565 }
566
567 /**
568 * Create a custom template from a form
569 *
570 * @since 3.06
571 */
572 public static function build_template() {
573 global $wpdb;
574
575 FrmAppHelper::permission_check( 'frm_edit_forms' );
576 check_ajax_referer( 'frm_ajax', 'nonce' );
577
578 $form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
579 $new_form_id = FrmForm::duplicate( $form_id, 1, true );
580 if ( empty( $new_form_id ) ) {
581 $response = array(
582 'message' => __( 'There was an error creating a template.', 'formidable' ),
583 );
584 } else {
585 $new_values = self::get_modal_values();
586 $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) );
587 if ( $query_results ) {
588 FrmForm::clear_form_cache();
589 }
590
591 $response = array(
592 'redirect' => admin_url( 'admin.php?page=formidable&frm_action=list_templates' ),
593 );
594 }
595
596 echo wp_json_encode( $response );
597 wp_die();
598 }
599
600 /**
601 * Before creating a new form, get the name and description from the modal.
602 *
603 * @since 4.0
604 */
605 private static function get_modal_values() {
606 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
607 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
608
609 return array(
610 'name' => $name,
611 'description' => $desc,
612 );
613 }
614
615 /**
616 * Inserts Formidable button
617 * Hook exists since 2.5.0
618 *
619 * @since 2.0.15
620 */
621 public static function insert_form_button() {
622 if ( current_user_can( 'frm_view_forms' ) ) {
623 FrmAppHelper::load_admin_wide_js();
624 $menu_name = FrmAppHelper::get_menu_name();
625 $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
626 echo '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' .
627 FrmAppHelper::kses( $icon, 'all' ) .
628 ' ' . esc_html( $menu_name ) . '</a>'; // WPCS: XSS ok.
629 }
630 }
631
632 public static function insert_form_popup() {
633 $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
634 if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
635 return;
636 }
637
638 FrmAppHelper::load_admin_wide_js();
639
640 $shortcodes = array(
641 'formidable' => array(
642 'name' => __( 'Form', 'formidable' ),
643 'label' => __( 'Insert a Form', 'formidable' ),
644 ),
645 );
646
647 $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
648
649 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
650 }
651
652 public static function get_shortcode_opts() {
653 FrmAppHelper::permission_check( 'frm_view_forms' );
654 check_ajax_referer( 'frm_ajax', 'nonce' );
655
656 $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
657 if ( empty( $shortcode ) ) {
658 wp_die();
659 }
660
661 echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
662 echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
663
664 $form_id = '';
665 $opts = array();
666 switch ( $shortcode ) {
667 case 'formidable':
668 $opts = array(
669 'form_id' => 'id',
670 'title' => array(
671 'val' => 1,
672 'label' => __( 'Display form title', 'formidable' ),
673 ),
674 'description' => array(
675 'val' => 1,
676 'label' => __( 'Display form description', 'formidable' ),
677 ),
678 'minimize' => array(
679 'val' => 1,
680 'label' => __( 'Minimize form HTML', 'formidable' ),
681 ),
682 );
683 }
684 $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
685
686 if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
687 // allow other shortcodes to use the required form id option
688 $form_id = $opts['form_id'];
689 unset( $opts['form_id'] );
690 }
691
692 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
693
694 echo '</div>';
695
696 wp_die();
697 }
698
699 public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
700 FrmAppHelper::permission_check( 'frm_view_forms' );
701
702 global $wpdb, $frm_vars;
703
704 if ( empty( $params ) ) {
705 $params = FrmForm::list_page_params();
706 }
707
708 $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
709
710 $pagenum = $wp_list_table->get_pagenum();
711
712 $wp_list_table->prepare_items();
713
714 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
715 if ( $pagenum > $total_pages && $total_pages > 0 ) {
716 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
717 die();
718 }
719
720 require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
721 }
722
723 public static function get_columns( $columns ) {
724 $columns['cb'] = '<input type="checkbox" />';
725 $columns['id'] = 'ID';
726
727 $type = FrmAppHelper::get_simple_request(
728 array(
729 'param' => 'form_type',
730 'type' => 'request',
731 'default' => 'published',
732 )
733 );
734
735 if ( 'template' == $type ) {
736 $columns['name'] = __( 'Template Name', 'formidable' );
737 $columns['type'] = __( 'Type', 'formidable' );
738 $columns['form_key'] = __( 'Key', 'formidable' );
739 } else {
740 $columns['name'] = __( 'Form Title', 'formidable' );
741 $columns['entries'] = __( 'Entries', 'formidable' );
742 $columns['form_key'] = __( 'Key', 'formidable' );
743 $columns['shortcode'] = __( 'Shortcodes', 'formidable' );
744 }
745
746 $columns['created_at'] = __( 'Date', 'formidable' );
747
748 add_screen_option(
749 'per_page',
750 array(
751 'label' => __( 'Forms', 'formidable' ),
752 'default' => 20,
753 'option' => 'formidable_page_formidable_per_page',
754 )
755 );
756
757 return $columns;
758 }
759
760 public static function get_sortable_columns() {
761 return array(
762 'id' => 'id',
763 'name' => 'name',
764 'description' => 'description',
765 'form_key' => 'form_key',
766 'created_at' => 'created_at',
767 );
768 }
769
770 public static function hidden_columns( $hidden_columns ) {
771 $type = FrmAppHelper::get_simple_request(
772 array(
773 'param' => 'form_type',
774 'type' => 'request',
775 )
776 );
777
778 if ( $type === 'template' ) {
779 $hidden_columns[] = 'id';
780 $hidden_columns[] = 'form_key';
781 }
782
783 return $hidden_columns;
784 }
785
786 public static function save_per_page( $save, $option, $value ) {
787 if ( $option == 'formidable_page_formidable_per_page' ) {
788 $save = (int) $value;
789 }
790
791 return $save;
792 }
793
794 /**
795 * Show the template listing page
796 *
797 * @since 3.06
798 */
799 private static function list_templates() {
800 self::init_modal();
801
802 $where = apply_filters( 'frm_forms_dropdown', array(), '' );
803 $forms = FrmForm::get_published_forms( $where );
804
805 $api = new FrmFormTemplateApi();
806 $templates = $api->get_api_info();
807
808 $custom_templates = array();
809 self::add_user_templates( $custom_templates );
810
811 $error = '';
812 $expired = false;
813 $license_type = '';
814 if ( isset( $templates['error'] ) ) {
815 $error = $templates['error']['message'];
816 $error = str_replace( 'utm_medium=addons', 'utm_medium=form-templates', $error );
817 $expired = ( $templates['error']['code'] === 'expired' );
818
819 $license_type = isset( $templates['error']['type'] ) ? $templates['error']['type'] : '';
820 unset( $templates['error'] );
821 }
822
823 $pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' );
824
825 $categories = self::get_template_categories( $templates );
826
827 require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list-templates.php' );
828 }
829
830 /**
831 * @since 4.03.01
832 */
833 private static function get_template_categories( $templates ) {
834 $categories = array();
835 foreach ( $templates as $template ) {
836 if ( isset( $template['categories'] ) ) {
837 $categories = array_merge( $categories, $template['categories'] );
838 }
839 }
840 $exclude_cats = FrmFormsHelper::ignore_template_categories();
841 $categories = array_unique( $categories );
842 $categories = array_diff( $categories, $exclude_cats );
843 sort( $categories );
844 return $categories;
845 }
846
847 private static function add_user_templates( &$templates ) {
848 $user_templates = array(
849 'is_template' => 1,
850 'default_template' => 0,
851 );
852 $user_templates = FrmForm::getAll( $user_templates, 'name' );
853 foreach ( $user_templates as $template ) {
854 $template = array(
855 'id' => $template->id,
856 'name' => $template->name,
857 'key' => $template->form_key,
858 'description' => $template->description,
859 'url' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ),
860 'released' => $template->created_at,
861 'installed' => 1,
862 );
863 array_unshift( $templates, $template );
864 unset( $template );
865 }
866 }
867
868 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
869 global $frm_vars;
870
871 $form = FrmForm::getOne( $id );
872 if ( ! $form ) {
873 wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
874 }
875
876 if ( $form->parent_form_id ) {
877 /* translators: %1$s: Start link HTML, %2$s: End link HTML */
878 wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( FrmForm::get_edit_link( $form->parent_form_id ) ) . '">', '</a>' ) );
879 }
880
881 $frm_field_selection = FrmField::field_selection();
882
883 $fields = FrmField::get_all_for_form( $form->id );
884
885 // Automatically add end section fields if they don't exist (2.0 migration).
886 $reset_fields = false;
887 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
888
889 if ( $reset_fields ) {
890 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
891 }
892
893 unset( $end_section_values, $last_order, $open, $reset_fields );
894
895 $args = array( 'parent_form_id' => $form->id );
896 $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
897 $values['fields'] = $fields;
898
899 $edit_message = __( 'Form was successfully updated.', 'formidable' );
900 if ( $form->is_template && $message == $edit_message ) {
901 $message = __( 'Template was successfully updated.', 'formidable' );
902 }
903
904 $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
905 $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
906
907 if ( defined( 'DOING_AJAX' ) ) {
908 wp_die();
909 } else {
910 require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
911 }
912 }
913
914 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
915 FrmAppHelper::permission_check( 'frm_edit_forms' );
916
917 global $frm_vars;
918
919 if ( ! is_array( $args ) ) {
920 // For reverse compatibility.
921 $args = array(
922 'message' => $args,
923 );
924 }
925
926 $defaults = array(
927 'message' => '',
928 'warnings' => array(),
929 );
930 $args = array_merge( $defaults, $args );
931 $message = $args['message'];
932 $warnings = $args['warnings'];
933
934 $form = FrmForm::getOne( $id );
935 $fields = FrmField::get_all_for_form( $id );
936 $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
937
938 self::clean_submit_html( $values );
939
940 $sections = self::get_settings_tabs( $values );
941 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
942
943 require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
944 }
945
946 /**
947 * @since 4.0
948 */
949 public static function form_publish_button( $atts ) {
950 $values = $atts['values'];
951 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
952 }
953
954 /**
955 * Get a list of all the settings tabs for the form settings page.
956 *
957 * @since 4.0
958 *
959 * @param array $values
960 * @return array
961 */
962 private static function get_settings_tabs( $values ) {
963 $sections = array(
964 'advanced' => array(
965 'name' => __( 'General', 'formidable' ),
966 'title' => __( 'General Form Settings', 'formidable' ),
967 'function' => array( __CLASS__, 'advanced_settings' ),
968 'icon' => 'frm_icon_font frm_settings_icon',
969 ),
970 'email' => array(
971 'name' => __( 'Actions & Notifications', 'formidable' ),
972 'function' => array( 'FrmFormActionsController', 'email_settings' ),
973 'id' => 'frm_notification_settings',
974 'icon' => 'frm_icon_font frm_mail_bulk_icon',
975 ),
976 'permissions' => array(
977 'name' => __( 'Form Permissions', 'formidable' ),
978 'icon' => 'frm_icon_font frm_lock_icon',
979 'html_class' => 'frm_show_upgrade frm_noallow',
980 'data' => array(
981 'medium' => 'permissions',
982 'upgrade' => __( 'Form Permissions', 'formidable' ),
983 ),
984 ),
985 'scheduling' => array(
986 'name' => __( 'Form Scheduling', 'formidable' ),
987 'icon' => 'frm_icon_font frm_calendar_icon',
988 'html_class' => 'frm_show_upgrade frm_noallow',
989 'data' => array(
990 'medium' => 'scheduling',
991 'upgrade' => __( 'Form scheduling settings', 'formidable' ),
992 ),
993 ),
994 'buttons' => array(
995 'name' => __( 'Styling & Buttons', 'formidable' ),
996 'class' => __CLASS__,
997 'function' => 'buttons_settings',
998 'icon' => 'frm_icon_font frm_pallet_icon',
999 ),
1000 'html' => array(
1001 'name' => __( 'Customize HTML', 'formidable' ),
1002 'class' => __CLASS__,
1003 'function' => 'html_settings',
1004 'icon' => 'frm_icon_font frm_code_icon',
1005 ),
1006 );
1007
1008 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1009
1010 if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1011 // Prevent settings from showing in 2 spots.
1012 unset( $sections['permissions'], $sections['scheduling'] );
1013 }
1014
1015 foreach ( $sections as $key => $section ) {
1016 $defaults = array(
1017 'html_class' => '',
1018 'name' => ucfirst( $key ),
1019 'icon' => 'frm_icon_font frm_settings_icon',
1020 );
1021
1022 $section = array_merge( $defaults, $section );
1023
1024 if ( ! isset( $section['anchor'] ) ) {
1025 $section['anchor'] = $key;
1026 }
1027 $section['anchor'] .= '_settings';
1028
1029 if ( ! isset( $section['title'] ) ) {
1030 $section['title'] = $section['name'];
1031 }
1032
1033 if ( ! isset( $section['id'] ) ) {
1034 $section['id'] = $section['anchor'];
1035 }
1036
1037 $sections[ $key ] = $section;
1038 }
1039
1040 return $sections;
1041 }
1042
1043 /**
1044 * @since 4.0
1045 *
1046 * @param array $values
1047 */
1048 public static function advanced_settings( $values ) {
1049 $first_h3 = 'frm_first_h3';
1050
1051 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-advanced.php' );
1052 }
1053
1054 /**
1055 * @since 4.0
1056 *
1057 * @param array $values
1058 */
1059 public static function buttons_settings( $values ) {
1060 $styles = apply_filters( 'frm_get_style_opts', array() );
1061
1062 $frm_settings = FrmAppHelper::get_settings();
1063 $no_global_style = $frm_settings->load_style === 'none';
1064
1065 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1066 }
1067
1068 /**
1069 * @since 4.0
1070 *
1071 * @param array $values
1072 */
1073 public static function html_settings( $values ) {
1074 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1075 }
1076
1077 /**
1078 * Replace old Submit Button href with new href to avoid errors in Chrome
1079 *
1080 * @since 2.03.08
1081 *
1082 * @param array|boolean $values
1083 */
1084 private static function clean_submit_html( &$values ) {
1085 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1086 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
1087 }
1088 }
1089
1090 public static function mb_tags_box( $form_id, $class = '' ) {
1091 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1092 $linked_forms = array();
1093 $col = 'one';
1094 $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1095
1096 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1097 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1098
1099 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1100
1101 include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1102 }
1103
1104 /**
1105 * @since 3.04.01
1106 */
1107 private static function advanced_helpers( $atts ) {
1108 $advanced_helpers = array(
1109 'default' => array(
1110 'heading' => __( 'Customize field values with the following parameters.', 'formidable' ),
1111 'codes' => self::get_advanced_shortcodes(),
1112 ),
1113 );
1114
1115 $user_fields = self::user_shortcodes();
1116 if ( ! empty( $user_fields ) ) {
1117 $user_helpers = array();
1118 foreach ( $user_fields as $uk => $uf ) {
1119 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1120 unset( $uk, $uf );
1121 }
1122
1123 $advanced_helpers['user_id'] = array(
1124 'codes' => $user_helpers,
1125 );
1126 }
1127
1128 /**
1129 * Add extra helper shortcodes on the Advanced tab in form settings and views
1130 *
1131 * @since 3.04.01
1132 *
1133 * @param array $atts - Includes fields and form_id
1134 */
1135 return apply_filters( 'frm_advanced_helpers', $advanced_helpers, $atts );
1136 }
1137
1138 /**
1139 * Get an array of the options to display in the advanced tab
1140 * of the customization panel
1141 *
1142 * @since 2.0.6
1143 */
1144 private static function get_advanced_shortcodes() {
1145 $adv_shortcodes = array(
1146 'x sep=", "' => array(
1147 'label' => __( 'Separator', 'formidable' ),
1148 'title' => __( 'Use a different separator for checkbox fields', 'formidable' ),
1149 ),
1150 'x format="d-m-Y"' => array(
1151 'label' => __( 'Date Format', 'formidable' ),
1152 ),
1153 'x show="field_label"' => array(
1154 'label' => __( 'Field Label', 'formidable' ),
1155 ),
1156 'x wpautop=0' => array(
1157 'label' => __( 'No Auto P', 'formidable' ),
1158 'title' => __( 'Do not automatically add any paragraphs or line breaks', 'formidable' ),
1159 ),
1160 );
1161 $adv_shortcodes = apply_filters( 'frm_advanced_shortcodes', $adv_shortcodes );
1162
1163 // __( 'Leave blank instead of defaulting to User Login', 'formidable' ) : blank=1
1164
1165 return $adv_shortcodes;
1166 }
1167
1168 /**
1169 * @since 3.04.01
1170 */
1171 private static function user_shortcodes() {
1172 $options = array(
1173 'ID' => __( 'User ID', 'formidable' ),
1174 'first_name' => __( 'First Name', 'formidable' ),
1175 'last_name' => __( 'Last Name', 'formidable' ),
1176 'display_name' => __( 'Display Name', 'formidable' ),
1177 'user_login' => __( 'User Login', 'formidable' ),
1178 'user_email' => __( 'Email', 'formidable' ),
1179 'avatar' => __( 'Avatar', 'formidable' ),
1180 'author_link' => __( 'Author Link', 'formidable' ),
1181 );
1182
1183 return apply_filters( 'frm_user_shortcodes', $options );
1184 }
1185
1186 /**
1187 * Get an array of the helper shortcodes to display in the customization panel
1188 *
1189 * @since 2.0.6
1190 */
1191 private static function get_shortcode_helpers( $settings_tab ) {
1192 $entry_shortcodes = array(
1193 'id' => __( 'Entry ID', 'formidable' ),
1194 'key' => __( 'Entry Key', 'formidable' ),
1195 'post_id' => __( 'Post ID', 'formidable' ),
1196 'ip' => __( 'User IP', 'formidable' ),
1197 'created-at' => __( 'Entry created', 'formidable' ),
1198 'updated-at' => __( 'Entry updated', 'formidable' ),
1199 '' => '',
1200 'siteurl' => __( 'Site URL', 'formidable' ),
1201 'sitename' => __( 'Site Name', 'formidable' ),
1202 );
1203
1204 if ( ! FrmAppHelper::pro_is_installed() ) {
1205 unset( $entry_shortcodes['post_id'] );
1206 }
1207
1208 if ( $settings_tab ) {
1209 $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1210 $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1211 $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1212 }
1213
1214 /**
1215 * Use this hook to add or remove buttons in the helpers section
1216 * in the customization panel
1217 *
1218 * @since 2.0.6
1219 */
1220 $entry_shortcodes = apply_filters( 'frm_helper_shortcodes', $entry_shortcodes, $settings_tab );
1221
1222 return $entry_shortcodes;
1223 }
1224
1225 /**
1226 * Insert the form class setting into the form
1227 */
1228 public static function form_classes( $form ) {
1229 if ( isset( $form->options['form_class'] ) ) {
1230 echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
1231 }
1232
1233 if ( isset( $form->options['js_validate'] ) && $form->options['js_validate'] ) {
1234 echo ' frm_js_validate ';
1235 }
1236 }
1237
1238 public static function get_email_html() {
1239 FrmAppHelper::permission_check( 'frm_view_forms' );
1240 check_ajax_referer( 'frm_ajax', 'nonce' );
1241
1242 echo FrmEntriesController::show_entry_shortcode( // WPCS: XSS ok.
1243 array(
1244 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1245 'default_email' => true,
1246 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1247 )
1248 );
1249 wp_die();
1250 }
1251
1252 public static function filter_content( $content, $form, $entry = false ) {
1253 self::get_entry_by_param( $entry );
1254 if ( ! $entry ) {
1255 return $content;
1256 }
1257
1258 if ( is_object( $form ) ) {
1259 $form = $form->id;
1260 }
1261
1262 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1263 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1264
1265 return $content;
1266 }
1267
1268 private static function get_entry_by_param( &$entry ) {
1269 if ( ! $entry || ! is_object( $entry ) ) {
1270 if ( ! $entry || ! is_numeric( $entry ) ) {
1271 $entry = FrmAppHelper::get_post_param( 'id', false, 'sanitize_title' );
1272 }
1273
1274 FrmEntry::maybe_get_entry( $entry );
1275 }
1276 }
1277
1278 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1279 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1280 }
1281
1282 public static function process_bulk_form_actions( $errors ) {
1283 if ( ! $_REQUEST ) {
1284 return $errors;
1285 }
1286
1287 $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1288 if ( $bulkaction == - 1 ) {
1289 $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1290 }
1291
1292 if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
1293 FrmAppHelper::remove_get_action();
1294
1295 $bulkaction = str_replace( 'bulk_', '', $bulkaction );
1296 }
1297
1298 $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
1299 if ( empty( $ids ) ) {
1300 $errors[] = __( 'No forms were specified', 'formidable' );
1301
1302 return $errors;
1303 }
1304
1305 $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
1306 if ( $permission_error !== false ) {
1307 $errors[] = $permission_error;
1308
1309 return $errors;
1310 }
1311
1312 if ( ! is_array( $ids ) ) {
1313 $ids = explode( ',', $ids );
1314 }
1315
1316 switch ( $bulkaction ) {
1317 case 'delete':
1318 $message = self::bulk_destroy( $ids );
1319 break;
1320 case 'trash':
1321 $message = self::bulk_trash( $ids );
1322 break;
1323 case 'untrash':
1324 $message = self::bulk_untrash( $ids );
1325 }
1326
1327 if ( isset( $message ) && ! empty( $message ) ) {
1328 $errors['message'] = $message;
1329 }
1330
1331 return $errors;
1332 }
1333
1334 public static function route() {
1335 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1336 $vars = array();
1337 FrmAppHelper::include_svg();
1338
1339 if ( isset( $_POST['frm_compact_fields'] ) ) {
1340 FrmAppHelper::permission_check( 'frm_edit_forms' );
1341
1342 // Javascript needs to be allowed in some field settings.
1343 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1344 $json_vars = htmlspecialchars_decode( nl2br( str_replace( '&quot;', '"', wp_unslash( $_POST['frm_compact_fields'] ) ) ) );
1345 $json_vars = json_decode( $json_vars, true );
1346 if ( empty( $json_vars ) ) {
1347 // json decoding failed so we should return an error message.
1348 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1349 if ( 'edit' == $action ) {
1350 $action = 'update';
1351 }
1352
1353 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1354 } else {
1355 $vars = FrmAppHelper::json_to_array( $json_vars );
1356 $action = $vars[ $action ];
1357 unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1358 $_REQUEST = array_merge( $_REQUEST, $vars );
1359 $_POST = array_merge( $_POST, $_REQUEST );
1360 }
1361 } else {
1362 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1363 if ( isset( $_REQUEST['delete_all'] ) ) {
1364 // Override the action for this page.
1365 $action = 'delete_all';
1366 }
1367 }
1368
1369 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1370 FrmAppHelper::trigger_hook_load( 'form' );
1371
1372 switch ( $action ) {
1373 case 'new':
1374 return self::new_form( $vars );
1375 case 'add_new':
1376 case 'list_templates':
1377 return self::list_templates();
1378 case 'create':
1379 case 'edit':
1380 case 'update':
1381 case 'duplicate':
1382 case 'trash':
1383 case 'untrash':
1384 case 'destroy':
1385 case 'delete_all':
1386 case 'settings':
1387 case 'update_settings':
1388 return self::$action( $vars );
1389 default:
1390 do_action( 'frm_form_action_' . $action );
1391 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1392 return;
1393 }
1394
1395 $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1396 if ( $action == - 1 ) {
1397 $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1398 }
1399
1400 if ( strpos( $action, 'bulk_' ) === 0 ) {
1401 FrmAppHelper::remove_get_action();
1402
1403 return self::list_form();
1404 }
1405
1406 return self::display_forms_list();
1407 }
1408 }
1409
1410 public static function json_error( $errors ) {
1411 $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1412
1413 return $errors;
1414 }
1415
1416 /**
1417 * Education for premium features.
1418 *
1419 * @since 4.05
1420 */
1421 public static function add_form_style_tab_options() {
1422 include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1423 }
1424
1425 /* FRONT-END FORMS */
1426 public static function admin_bar_css() {
1427 if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1428 return;
1429 }
1430
1431 self::move_menu_to_footer();
1432
1433 add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
1434 FrmAppHelper::load_font_style();
1435 }
1436
1437 /**
1438 * @since 4.05.02
1439 */
1440 private static function move_menu_to_footer() {
1441 $settings = FrmAppHelper::get_settings();
1442 if ( empty( $settings->admin_bar ) ) {
1443 remove_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
1444 }
1445 }
1446
1447 public static function admin_bar_configure() {
1448 global $frm_vars;
1449 if ( empty( $frm_vars['forms_loaded'] ) ) {
1450 return;
1451 }
1452
1453 $actions = array();
1454 foreach ( $frm_vars['forms_loaded'] as $form ) {
1455 if ( is_object( $form ) ) {
1456 $actions[ $form->id ] = $form->name;
1457 }
1458 unset( $form );
1459 }
1460
1461 if ( empty( $actions ) ) {
1462 return;
1463 }
1464
1465 self::add_menu_to_admin_bar();
1466 self::add_forms_to_admin_bar( $actions );
1467 }
1468
1469 /**
1470 * @since 2.05.07
1471 */
1472 public static function add_menu_to_admin_bar() {
1473 global $wp_admin_bar;
1474
1475 $wp_admin_bar->add_node(
1476 array(
1477 'id' => 'frm-forms',
1478 'title' => '<span class="ab-icon"></span><span class="ab-label">' . FrmAppHelper::get_menu_name() . '</span>',
1479 'href' => admin_url( 'admin.php?page=formidable' ),
1480 'meta' => array(
1481 'title' => FrmAppHelper::get_menu_name(),
1482 ),
1483 )
1484 );
1485 }
1486
1487 /**
1488 * @since 2.05.07
1489 */
1490 private static function add_forms_to_admin_bar( $actions ) {
1491 global $wp_admin_bar;
1492
1493 asort( $actions );
1494
1495 foreach ( $actions as $form_id => $name ) {
1496
1497 $wp_admin_bar->add_node(
1498 array(
1499 'parent' => 'frm-forms',
1500 'id' => 'edit_form_' . $form_id,
1501 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
1502 'href' => FrmForm::get_edit_link( $form_id ),
1503 )
1504 );
1505 }
1506 }
1507
1508 /**
1509 * The formidable shortcode
1510 *
1511 * @param array $atts The params from the shortcode.
1512 */
1513 public static function get_form_shortcode( $atts ) {
1514 global $frm_vars;
1515 if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1516 $sc = '[formidable';
1517 $sc .= FrmAppHelper::array_to_html_params( $atts );
1518 return $sc . ']';
1519 }
1520
1521 $shortcode_atts = shortcode_atts(
1522 array(
1523 'id' => '',
1524 'key' => '',
1525 'title' => false,
1526 'description' => false,
1527 'readonly' => false,
1528 'entry_id' => false,
1529 'fields' => array(),
1530 'exclude_fields' => array(),
1531 'minimize' => false,
1532 ),
1533 $atts
1534 );
1535 do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1536
1537 return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
1538 }
1539
1540 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1541 if ( empty( $id ) ) {
1542 $id = $key;
1543 }
1544
1545 $form = self::maybe_get_form_to_show( $id );
1546 if ( ! $form ) {
1547 return __( 'Please select a valid form', 'formidable' );
1548 }
1549
1550 FrmAppController::maybe_update_styles();
1551
1552 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1553 FrmAppHelper::trigger_hook_load( 'form', $form );
1554
1555 $form = apply_filters( 'frm_pre_display_form', $form );
1556
1557 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
1558
1559 if ( self::is_viewable_draft_form( $form ) ) {
1560 // don't show a draft form on a page
1561 $form = __( 'Please select a valid form', 'formidable' );
1562 } elseif ( ! FrmForm::is_visible_to_user( $form ) ) {
1563 $form = do_shortcode( $frm_settings->login_msg );
1564 } else {
1565 do_action( 'frm_pre_get_form', $form );
1566 $form = self::get_form( $form, $title, $description, $atts );
1567
1568 /**
1569 * Use this shortcode to check for external shortcodes that may span
1570 * across multiple fields in the customizable HTML
1571 *
1572 * @since 2.0.8
1573 */
1574 $form = apply_filters( 'frm_filter_final_form', $form );
1575 }
1576
1577 return $form;
1578 }
1579
1580 private static function maybe_get_form_to_show( $id ) {
1581 $form = false;
1582
1583 if ( ! empty( $id ) ) { // no form id or key set
1584 $form = FrmForm::getOne( $id );
1585 if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) {
1586 $form = false;
1587 }
1588 }
1589
1590 return $form;
1591 }
1592
1593 private static function is_viewable_draft_form( $form ) {
1594 return $form->status == 'draft' && current_user_can( 'frm_edit_forms' ) && ! FrmAppHelper::is_preview_page();
1595 }
1596
1597 public static function get_form( $form, $title, $description, $atts = array() ) {
1598 ob_start();
1599
1600 do_action( 'frm_before_get_form', $atts );
1601
1602 self::get_form_contents( $form, $title, $description, $atts );
1603 self::enqueue_scripts( FrmForm::get_params( $form ) );
1604
1605 $contents = ob_get_contents();
1606 ob_end_clean();
1607
1608 self::maybe_minimize_form( $atts, $contents );
1609
1610 return $contents;
1611 }
1612
1613 public static function enqueue_scripts( $params ) {
1614 do_action( 'frm_enqueue_form_scripts', $params );
1615 }
1616
1617 public static function get_form_contents( $form, $title, $description, $atts ) {
1618 $params = FrmForm::get_params( $form );
1619 $errors = self::get_saved_errors( $form, $params );
1620 $fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
1621 $reset = false;
1622 $pass_args = compact( 'form', 'fields', 'errors', 'title', 'description', 'reset' );
1623
1624 $handle_process_here = $params['action'] == 'create' && $params['posted_form_id'] == $form->id && $_POST;
1625
1626 if ( ! $handle_process_here ) {
1627 do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1628 if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1629 self::show_form_after_submit( $pass_args );
1630 }
1631 } elseif ( ! empty( $errors ) ) {
1632 self::show_form_after_submit( $pass_args );
1633
1634 } else {
1635
1636 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1637
1638 if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1639 $entry_id = self::just_created_entry( $form->id );
1640 $pass_args['entry_id'] = $entry_id;
1641 $pass_args['reset'] = true;
1642 $pass_args['conf_method'] = self::get_confirmation_method( compact( 'form', 'entry_id' ) );
1643
1644 self::run_success_action( $pass_args );
1645
1646 do_action(
1647 'frm_after_entry_processed',
1648 array(
1649 'entry_id' => $entry_id,
1650 'form' => $form,
1651 )
1652 );
1653 }
1654 }
1655 }
1656
1657 /**
1658 * If the form was processed earlier (init), get the generated errors
1659 *
1660 * @since 2.05
1661 */
1662 private static function get_saved_errors( $form, $params ) {
1663 global $frm_vars;
1664
1665 if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
1666 $errors = $frm_vars['created_entries'][ $form->id ]['errors'];
1667 } else {
1668 $errors = array();
1669 }
1670
1671 return $errors;
1672 }
1673
1674 /**
1675 * @since 2.2.7
1676 */
1677 public static function just_created_entry( $form_id ) {
1678 global $frm_vars;
1679
1680 return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
1681 }
1682
1683 /**
1684 * @since 3.0
1685 */
1686 private static function get_confirmation_method( $atts ) {
1687 $opt = 'success_action';
1688 $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
1689 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' );
1690
1691 if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
1692 $method = 'message';
1693 }
1694
1695 return $method;
1696 }
1697
1698 public static function maybe_trigger_redirect( $form, $params, $args ) {
1699 if ( ! isset( $params['id'] ) ) {
1700 global $frm_vars;
1701 $params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
1702 }
1703
1704 $conf_method = self::get_confirmation_method(
1705 array(
1706 'form' => $form,
1707 'entry_id' => $params['id'],
1708 )
1709 );
1710
1711 if ( 'redirect' === $conf_method ) {
1712 self::trigger_redirect( $form, $params, $args );
1713 }
1714 }
1715
1716 public static function trigger_redirect( $form, $params, $args ) {
1717 $success_args = array(
1718 'action' => $params['action'],
1719 'conf_method' => 'redirect',
1720 'form' => $form,
1721 'entry_id' => $params['id'],
1722 );
1723
1724 if ( isset( $args['ajax'] ) ) {
1725 $success_args['ajax'] = $args['ajax'];
1726 }
1727
1728 self::run_success_action( $success_args );
1729 }
1730
1731 /**
1732 * Used when the success action is not 'message'
1733 *
1734 * @since 2.05
1735 */
1736 public static function run_success_action( $args ) {
1737 $extra_args = $args;
1738 unset( $extra_args['form'] );
1739
1740 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
1741
1742 $opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit';
1743
1744 $args['success_opt'] = $opt;
1745 if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) {
1746 self::load_page_after_submit( $args );
1747 } elseif ( $args['conf_method'] == 'redirect' ) {
1748 self::redirect_after_submit( $args );
1749 } else {
1750 self::show_message_after_save( $args );
1751 }
1752 }
1753
1754 /**
1755 * @since 3.0
1756 */
1757 private static function load_page_after_submit( $args ) {
1758 global $post;
1759 $opt = $args['success_opt'];
1760 if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
1761 $page = get_post( $args['form']->options[ $opt . '_page_id' ] );
1762 $old_post = $post;
1763 $post = $page;
1764 $content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
1765 echo apply_filters( 'the_content', $content ); // WPCS: XSS ok.
1766 $post = $old_post;
1767 }
1768 }
1769
1770 /**
1771 * @since 3.0
1772 */
1773 private static function redirect_after_submit( $args ) {
1774 global $frm_vars;
1775
1776 add_filter( 'frm_use_wpautop', '__return_false' );
1777
1778 $opt = $args['success_opt'];
1779 $success_url = trim( $args['form']->options[ $opt . '_url' ] );
1780 $success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
1781 $success_url = do_shortcode( $success_url );
1782
1783 $success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1784
1785 $redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args );
1786
1787 $args['id'] = $args['entry_id'];
1788 FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args );
1789
1790 add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' );
1791 $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
1792
1793 $doing_ajax = FrmAppHelper::doing_ajax();
1794
1795 if ( isset( $args['ajax'] ) && $args['ajax'] && $doing_ajax ) {
1796 echo json_encode( array( 'redirect' => $success_url ) );
1797 wp_die();
1798 } elseif ( ! headers_sent() ) {
1799 wp_redirect( esc_url_raw( $success_url ) );
1800 die(); // do not use wp_die or redirect fails
1801 } else {
1802 add_filter( 'frm_use_wpautop', '__return_true' );
1803
1804 echo $redirect_msg; // WPCS: XSS ok.
1805 echo "<script type='text/javascript'>window.onload = function(){setTimeout(window.location='" . esc_url_raw( $success_url ) . "', 8000);}</script>";
1806 }
1807 }
1808
1809 /**
1810 * @since 3.0
1811 *
1812 * @param string $success_url
1813 * @param string $success_msg
1814 * @param array $args
1815 */
1816 private static function get_redirect_message( $success_url, $success_msg, $args ) {
1817 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message" role="status">' . $success_msg . '<br/>' .
1818 /* translators: %1$s: Start link HTML, %2$s: End link HTML */
1819 sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) .
1820 '</div></div>';
1821
1822 $redirect_args = array(
1823 'entry_id' => $args['entry_id'],
1824 'form_id' => $args['form']->id,
1825 'form' => $args['form'],
1826 );
1827
1828 return apply_filters( 'frm_redirect_msg', $redirect_msg, $redirect_args );
1829 }
1830
1831 /**
1832 * Prepare to show the success message and empty form after submit
1833 *
1834 * @since 2.05
1835 */
1836 public static function show_message_after_save( $atts ) {
1837 $atts['message'] = self::prepare_submit_message( $atts['form'], $atts['entry_id'] );
1838
1839 if ( ! isset( $atts['form']->options['show_form'] ) || $atts['form']->options['show_form'] ) {
1840 self::show_form_after_submit( $atts );
1841 } else {
1842 self::show_lone_success_messsage( $atts );
1843 }
1844 }
1845
1846 /**
1847 * Show an empty form
1848 *
1849 * @since 2.05
1850 */
1851 private static function show_form_after_submit( $args ) {
1852 self::fill_atts_for_form_display( $args );
1853
1854 $errors = $args['errors'];
1855 $message = $args['message'];
1856 $form = $args['form'];
1857 $title = $args['title'];
1858 $description = $args['description'];
1859
1860 if ( empty( $args['fields'] ) ) {
1861 $values = array();
1862 } else {
1863 $values = FrmEntriesHelper::setup_new_vars( $args['fields'], $form, $args['reset'] );
1864 }
1865 unset( $args );
1866
1867 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1868
1869 $frm_settings = FrmAppHelper::get_settings();
1870 $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1871
1872 global $frm_vars;
1873 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1874
1875 $message_placement = self::message_placement( $form, $message );
1876
1877 include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1878 }
1879
1880 /**
1881 * @return string - 'before' or 'after'
1882 *
1883 * @since 4.05.02
1884 */
1885 private static function message_placement( $form, $message ) {
1886 $place = 'before';
1887 if ( ! empty( $message ) && isset( $form->options['form_class'] ) && strpos( $form->options['form_class'], 'frm_below_success' ) !== false ) {
1888 $place = 'after';
1889 }
1890
1891 /**
1892 * @return string - 'before' or 'after'
1893 *
1894 * @since 4.05.02
1895 */
1896 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
1897 }
1898
1899 /**
1900 * Get all the values needed on the new.php entry page
1901 *
1902 * @since 2.05
1903 */
1904 private static function fill_atts_for_form_display( &$args ) {
1905 $defaults = array(
1906 'errors' => array(),
1907 'message' => '',
1908 'fields' => array(),
1909 'form' => array(),
1910 'title' => true,
1911 'description' => false,
1912 'reset' => false,
1913 );
1914 $args = wp_parse_args( $args, $defaults );
1915 }
1916
1917 /**
1918 * Show the success message without the form
1919 *
1920 * @since 2.05
1921 */
1922 private static function show_lone_success_messsage( $atts ) {
1923 global $frm_vars;
1924 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
1925 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
1926
1927 $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1928
1929 $errors = array();
1930 $form = $atts['form'];
1931 $message = $atts['message'];
1932
1933 include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1934 }
1935
1936 /**
1937 * Prepare the success message before it's shown
1938 *
1939 * @since 2.05
1940 */
1941 private static function prepare_submit_message( $form, $entry_id ) {
1942 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
1943
1944 if ( $entry_id && is_numeric( $entry_id ) ) {
1945 $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1946 $class = 'frm_message';
1947 } else {
1948 $message = $frm_settings->failed_msg;
1949 $class = FrmFormsHelper::form_error_class();
1950 }
1951
1952 $message = FrmFormsHelper::get_success_message( compact( 'message', 'form', 'entry_id', 'class' ) );
1953
1954 return apply_filters( 'frm_main_feedback', $message, $form, $entry_id );
1955 }
1956
1957 public static function front_head() {
1958 $version = FrmAppHelper::plugin_version();
1959 $suffix = FrmAppHelper::js_suffix();
1960
1961 if ( ! empty( $suffix ) && self::has_combo_js_file() ) {
1962 wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/frm.min.js', array( 'jquery' ), $version, true );
1963 } else {
1964 wp_register_script( 'formidable', FrmAppHelper::plugin_url() . "/js/formidable{$suffix}.js", array( 'jquery' ), $version, true );
1965 }
1966
1967 add_filter( 'script_loader_tag', 'FrmFormsController::defer_script_loading', 10, 2 );
1968
1969 if ( FrmAppHelper::is_admin() ) {
1970 // don't load this in back-end
1971 return;
1972 }
1973
1974 FrmAppHelper::localize_script( 'front' );
1975 FrmStylesController::enqueue_css( 'register' );
1976 }
1977
1978 /**
1979 * @since 3.0
1980 */
1981 public static function has_combo_js_file() {
1982 return is_readable( FrmAppHelper::plugin_path() . '/js/frm.min.js' );
1983 }
1984
1985 public static function maybe_load_css( $form, $this_load, $global_load ) {
1986 $load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load );
1987
1988 if ( ! $load_css ) {
1989 return;
1990 }
1991
1992 global $frm_vars;
1993 self::footer_js( 'header' );
1994 $frm_vars['css_loaded'] = true;
1995
1996 self::load_late_css();
1997 }
1998
1999 /**
2000 * If css is loaded only on applicable pages, include it before the form loads
2001 * to prevent a flash of unstyled form.
2002 *
2003 * @since 4.01
2004 */
2005 private static function load_late_css() {
2006 $frm_settings = FrmAppHelper::get_settings();
2007 $late_css = $frm_settings->load_style === 'dynamic';
2008 if ( ! $late_css ) {
2009 return;
2010 }
2011
2012 global $wp_styles;
2013 if ( is_array( $wp_styles->queue ) && in_array( 'formidable', $wp_styles->queue ) ) {
2014 wp_print_styles( 'formidable' );
2015 }
2016 }
2017
2018 public static function defer_script_loading( $tag, $handle ) {
2019 if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
2020 $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
2021 }
2022
2023 return $tag;
2024 }
2025
2026 public static function footer_js( $location = 'footer' ) {
2027 global $frm_vars;
2028
2029 FrmStylesController::enqueue_css();
2030
2031 if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2032 // load formidable js
2033 wp_enqueue_script( 'formidable' );
2034 }
2035 }
2036
2037 /**
2038 * @since 2.0.8
2039 */
2040 private static function maybe_minimize_form( $atts, &$content ) {
2041 // check if minimizing is turned on
2042 if ( self::is_minification_on( $atts ) ) {
2043 $content = str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', $content );
2044 }
2045 }
2046
2047 /**
2048 * @since 2.0.8
2049 * @return boolean
2050 */
2051 private static function is_minification_on( $atts ) {
2052 return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
2053 }
2054
2055 /**
2056 * @deprecated 4.0
2057 */
2058 public static function new_form( $values = array() ) {
2059 FrmDeprecated::new_form( $values );
2060 }
2061
2062 /**
2063 * @deprecated 4.0
2064 */
2065 public static function create( $values = array() ) {
2066 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
2067 self::update( $values );
2068 }
2069
2070 /**
2071 * @deprecated 1.07.05
2072 * @codeCoverageIgnore
2073 */
2074 public static function add_default_templates( $path, $default = true, $template = true ) {
2075 FrmDeprecated::add_default_templates( $path, $default, $template );
2076 }
2077
2078 /**
2079 * @deprecated 3.0
2080 * @codeCoverageIgnore
2081 */
2082 public static function bulk_create_template( $ids ) {
2083 return FrmDeprecated::bulk_create_template( $ids );
2084 }
2085
2086 /**
2087 * @deprecated 2.03
2088 * @codeCoverageIgnore
2089 */
2090 public static function register_pro_scripts() {
2091 FrmDeprecated::register_pro_scripts();
2092 }
2093
2094 /**
2095 * @deprecated 3.0
2096 * @codeCoverageIgnore
2097 */
2098 public static function edit_key() {
2099 FrmDeprecated::edit_key();
2100 }
2101
2102 /**
2103 * @deprecated 3.0
2104 * @codeCoverageIgnore
2105 */
2106 public static function edit_description() {
2107 FrmDeprecated::edit_description();
2108 }
2109 }
2110