Completed
Push — master ( e9e32c...86f6ee )
by Stephanie
03:56
created

FrmFormsController::is_too_long()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
		wp_enqueue_script( 'formidable-editinplace' );
29
30
        if ( wp_is_mobile() ) {
31
    		wp_enqueue_script( 'jquery-touch-punch' );
32
    	}
33
    }
34
35
	public static function register_widgets() {
36
		require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
		register_widget( 'FrmShowForm' );
38
	}
39
40
	/**
41
	 * By default, Divi processes form shortcodes on the edit post page.
42
	 * Now that won't do.
43
	 *
44
	 * @since 3.01
45
	 */
46
	public static function prevent_divi_conflict( $shortcodes ) {
47
		$shortcodes[] = 'formidable';
48
		return $shortcodes;
49
	}
50
51
	public static function list_form() {
52
		FrmAppHelper::permission_check( 'frm_view_forms' );
53
54
		$message = '';
55
		$params = FrmForm::list_page_params();
56
		$errors = self::process_bulk_form_actions( array() );
57
		if ( isset( $errors['message'] ) ) {
58
			$message = $errors['message'];
59
			unset( $errors['message'] );
60
		}
61
		$errors = apply_filters( 'frm_admin_list_form_action', $errors );
62
63
		return self::display_forms_list( $params, $message, $errors );
64
	}
65
66
	/**
67
	 * Choose which type of form to create
68
	 *
69
	 * @since 3.06
70
	 */
71
	public static function add_new() {
72
		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add-new.php' );
73
	}
74
75
	public static function new_form( $values = array() ) {
76
		FrmAppHelper::permission_check( 'frm_edit_forms' );
77
78
        global $frm_vars;
79
80
		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
81
		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
82
83
		if ( $action == 'create' ) {
84
			self::create( $values );
85
			return;
86
		} else if ( $action == 'new' ) {
87
			$frm_field_selection = FrmField::field_selection();
88
			$values = FrmFormsHelper::setup_new_vars( $values );
89
            $id = FrmForm::create( $values );
90
			$form = FrmForm::getOne( $id );
91
92
			self::create_default_email_action( $form );
93
94
			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
95
96
            $values['id'] = $id;
97
			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
98
        }
99
    }
100
101
	/**
102
	 * Create the default email action
103
	 *
104
	 * @since 2.02.11
105
	 *
106
	 * @param object $form
107
	 */
108
    private static function create_default_email_action( $form ) {
109
    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
110
111
	    if ( $create_email ) {
112
		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
113
		    $action_control->create( $form->id );
114
	    }
115
    }
116
117
	public static function create( $values = array() ) {
118
		FrmAppHelper::permission_check( 'frm_edit_forms' );
119
120
        global $frm_vars;
121
        if ( empty( $values ) ) {
122
            $values = $_POST;
123
        }
124
125
        //Set radio button and checkbox meta equal to "other" value
126
        if ( FrmAppHelper::pro_is_installed() ) {
127
            $values = FrmProEntry::mod_other_vals( $values, 'back' );
128
        }
129
130
		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
131
132
        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
133
            $frm_settings = FrmAppHelper::get_settings();
134
            $errors = array( 'form' => $frm_settings->admin_permission );
135
        } else {
136
			$errors = FrmForm::validate( $values );
137
        }
138
139
		if ( count( $errors ) > 0 ) {
140
            $hide_preview = true;
141
			$frm_field_selection = FrmField::field_selection();
142
            $form = FrmForm::getOne( $id );
143
			$fields = FrmField::get_all_for_form( $id );
144
145
			$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true );
146
			$values['fields'] = $fields;
147
			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
148
149
			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
150
        } else {
151
            FrmForm::update( $id, $values, true );
152
			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
153
			die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok.
154
        }
155
    }
156
157
    public static function edit( $values = false ) {
158
		FrmAppHelper::permission_check( 'frm_edit_forms' );
159
160
		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
161
		return self::get_edit_vars( $id );
162
    }
163
164
    public static function settings( $id = false, $message = '' ) {
165
		FrmAppHelper::permission_check( 'frm_edit_forms' );
166
167
		if ( ! $id || ! is_numeric( $id ) ) {
168
			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
169
        }
170
		return self::get_settings_vars( $id, array(), $message );
171
    }
172
173
    public static function update_settings() {
174
		FrmAppHelper::permission_check( 'frm_edit_forms' );
175
176
		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
177
178
		$errors = FrmForm::validate( $_POST );
179
		if ( count( $errors ) > 0 ) {
180
			return self::get_settings_vars( $id, $errors );
181
		}
182
183
		do_action( 'frm_before_update_form_settings', $id );
184
185
		FrmForm::update( $id, $_POST );
186
187
        $message = __( 'Settings Successfully Updated', 'formidable' );
188
		return self::get_settings_vars( $id, array(), $message );
189
    }
190
191
	public static function update( $values = array() ) {
192
		if ( empty( $values ) ) {
193
            $values = $_POST;
194
        }
195
196
        //Set radio button and checkbox meta equal to "other" value
197
        if ( FrmAppHelper::pro_is_installed() ) {
198
            $values = FrmProEntry::mod_other_vals( $values, 'back' );
199
        }
200
201
        $errors = FrmForm::validate( $values );
202
        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
        if ( $permission_error !== false ) {
204
            $errors['form'] = $permission_error;
205
        }
206
207
		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
208
209
		if ( count( $errors ) > 0 ) {
210
            return self::get_edit_vars( $id, $errors );
211
		} else {
212
            FrmForm::update( $id, $values );
213
            $message = __( 'Form was Successfully Updated', 'formidable' );
214
215
			if ( self::is_too_long( $values ) ) {
216
				$message .= '<br/> ' . sprintf(
217
					/* translators: %1$s: Start link HTML, %2$s: end link HTML */
218
					__( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
219
					'<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">',
220
					'</a>'
221
				);
222
			}
223
224
            if ( defined( 'DOING_AJAX' ) ) {
225
				wp_die( esc_html( $message ) );
226
            }
227
			return self::get_edit_vars( $id, array(), $message );
228
        }
229
    }
230
231
	/**
232
	 * Check if the value at the end of the form was included.
233
	 * If it's missing, it means other values at the end of the form
234
	 * were likely not saved either.
235
	 *
236
	 * @since 3.06.01
237
	 */
238
	private static function is_too_long( $values ) {
239
		return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
240
	}
241
242
	/**
243
	 * Redirect to the url for creating from a template
244
	 * Also delete the current form
245
	 *
246
	 * @since 2.0
247
	 * @deprecated 3.06
248
	 */
249
	public static function _create_from_template() {
250
		_deprecated_function( __FUNCTION__, '3.06' );
251
252
		FrmAppHelper::permission_check( 'frm_edit_forms' );
253
		check_ajax_referer( 'frm_ajax', 'nonce' );
254
255
		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
256
		$template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
257
258
		if ( $current_form ) {
259
			FrmForm::destroy( $current_form );
260
		}
261
262
		echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
263
		wp_die();
264
	}
265
266
    public static function duplicate() {
267
		FrmAppHelper::permission_check( 'frm_edit_forms' );
268
269
		$params = FrmForm::list_page_params();
270
        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
271
        $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
272
        if ( $form ) {
273
			return self::get_edit_vars( $form, array(), $message, true );
274
        } else {
275
			return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
276
        }
277
    }
278
279
    public static function page_preview() {
280
		$params = FrmForm::list_page_params();
281
        if ( ! $params['form'] ) {
282
            return;
283
        }
284
285
        $form = FrmForm::getOne( $params['form'] );
286
		if ( $form ) {
287
			return self::show_form( $form->id, '', true, true );
288
		}
289
    }
290
291
	/**
292
	 * @since 3.0
293
	 */
294
	public static function show_page_preview() {
295
		echo self::page_preview(); // WPCS: XSS ok.
296
	}
297
298
    public static function preview() {
299
        do_action( 'frm_wp' );
300
301
        global $frm_vars;
302
        $frm_vars['preview'] = true;
303
304
		self::load_wp();
305
306
		$include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
307
		if ( $include_theme ) {
308
			self::set_preview_query();
309
			self::load_theme_preview();
310
		} else {
311
			self::load_direct_preview();
312
		}
313
314
		wp_die();
315
	}
316
317
	/**
318
	 * @since 3.0
319
	 */
320
	private static function load_wp() {
321
		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
322
			global $wp;
323
			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
324
			include_once( $root . '/wp-config.php' );
325
			$wp->init();
326
			$wp->register_globals();
327
		}
328
	}
329
330
	private static function set_preview_query() {
331
		$random_page = get_posts(
332
			array(
333
				'numberposts' => 1,
334
				'orderby'     => 'date',
335
				'order'       => 'ASC',
336
				'post_type'   => 'page',
337
			)
338
		);
339
340
		if ( ! empty( $random_page ) ) {
341
			$random_page = reset( $random_page );
342
			query_posts(
0 ignored issues
show
Coding Style introduced by
The use of function query_posts() is discouraged; use WP_Query() instead
Loading history...
343
				array(
344
					'post_type' => 'page',
345
					'page_id'   => $random_page->ID,
346
				)
347
			);
348
		}
349
	}
350
351
	/**
352
	 * @since 3.0
353
	 */
354
	private static function load_theme_preview() {
355
		add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
356
		add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
357
		add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
358
		add_action( 'loop_no_results', 'FrmFormsController::show_page_preview' );
359
		add_filter( 'is_active_sidebar', '__return_false' );
360
		get_template_part( 'page' );
361
	}
362
363
364
	/**
365
	 * Set the page title for the theme preview page
366
	 *
367
	 * @since 3.0
368
	 */
369
	public static function preview_page_title( $title ) {
370
		if ( in_the_loop() ) {
371
			$title = self::preview_title( $title );
372
		}
373
		return $title;
374
	}
375
376
	/**
377
	 * Set the page title for the theme preview page
378
	 *
379
	 * @since 3.0
380
	 */
381
	public static function preview_title( $title ) {
382
		return __( 'Form Preview', 'formidable' );
383
	}
384
385
	/**
386
	 * Set the page content for the theme preview page
387
	 *
388
	 * @since 3.0
389
	 */
390
	public static function preview_content( $content ) {
391
		if ( in_the_loop() ) {
392
			$content = self::show_page_preview();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $content is correct as self::show_page_preview() (which targets FrmFormsController::show_page_preview()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
393
		}
394
		return $content;
395
	}
396
397
	/**
398
	 * @since 3.0
399
	 */
400
	private static function load_direct_preview() {
401
		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
402
403
		$key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
404
		if ( $key == '' ) {
405
			$key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
406
		}
407
408
		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
409
		if ( empty( $form ) ) {
410
			$form = FrmForm::getAll( array(), '', 1 );
411
		}
412
413
		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
414
	}
415
416
    public static function untrash() {
417
		self::change_form_status( 'untrash' );
418
    }
419
420
	public static function bulk_untrash( $ids ) {
421
		FrmAppHelper::permission_check( 'frm_edit_forms' );
422
423
        $count = FrmForm::set_status( $ids, 'published' );
424
425
		$message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
426
        return $message;
427
    }
428
429
	/**
430
	 * @since 3.06
431
	 */
432
	public static function ajax_trash() {
433
		FrmAppHelper::permission_check( 'frm_delete_forms' );
434
		check_ajax_referer( 'frm_ajax', 'nonce' );
435
		$form_id = FrmAppHelper::get_param( 'id', '', 'post', 'absint' );
436
		FrmForm::set_status( $form_id, 'trash' );
437
		wp_die();
438
	}
439
440
    public static function trash() {
441
		self::change_form_status( 'trash' );
442
    }
443
444
	/**
445
	 * @param string $status
446
	 *
447
	 * @return int The number of forms changed
448
	 */
449
	public static function change_form_status( $status ) {
450
		$available_status = array(
451
			'untrash' => array(
452
				'permission' => 'frm_edit_forms',
453
				'new_status' => 'published',
454
			),
455
			'trash'   => array(
456
				'permission' => 'frm_delete_forms',
457
				'new_status' => 'trash',
458
			),
459
		);
460
461
		if ( ! isset( $available_status[ $status ] ) ) {
462
			return;
463
		}
464
465
		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
466
467
		$params = FrmForm::list_page_params();
468
469
		//check nonce url
470
		check_admin_referer( $status . '_form_' . $params['id'] );
471
472
		$count = 0;
473
		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
474
			$count++;
475
		}
476
477
		$form_type = FrmAppHelper::get_simple_request(
478
			array(
479
				'param' => 'form_type',
480
				'type' => 'request',
481
			)
482
		);
483
484
		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
485
		$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>' );
486
487
		$message = $available_status[ $status ]['message'];
488
489
		self::display_forms_list( $params, $message );
490
	}
491
492
	public static function bulk_trash( $ids ) {
493
		FrmAppHelper::permission_check( 'frm_delete_forms' );
494
495
        $count = 0;
496
        foreach ( $ids as $id ) {
497
            if ( FrmForm::trash( $id ) ) {
498
                $count++;
499
            }
500
        }
501
502
		$current_page = FrmAppHelper::get_simple_request(
503
			array(
504
				'param' => 'form_type',
505
				'type' => 'request',
506
			)
507
		);
508
		$message = sprintf(
509
			_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' ),
510
			$count,
511
			'<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' ) ) . '">',
512
			'</a>'
513
		);
514
515
        return $message;
516
    }
517
518
    public static function destroy() {
519
		FrmAppHelper::permission_check( 'frm_delete_forms' );
520
521
		$params = FrmForm::list_page_params();
522
523
        //check nonce url
524
		check_admin_referer( 'destroy_form_' . $params['id'] );
525
526
        $count = 0;
527
        if ( FrmForm::destroy( $params['id'] ) ) {
528
            $count++;
529
        }
530
531
		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
532
533
		self::display_forms_list( $params, $message );
534
    }
535
536
	public static function bulk_destroy( $ids ) {
537
		FrmAppHelper::permission_check( 'frm_delete_forms' );
538
539
        $count = 0;
540
        foreach ( $ids as $id ) {
541
            $d = FrmForm::destroy( $id );
542
            if ( $d ) {
543
                $count++;
544
            }
545
        }
546
547
		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
548
549
        return $message;
550
    }
551
552
    private static function delete_all() {
553
        //check nonce url
554
		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
555
        if ( $permission_error !== false ) {
556
			self::display_forms_list( array(), '', array( $permission_error ) );
557
            return;
558
        }
559
560
		$count = FrmForm::scheduled_delete( time() );
561
		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
562
563
		self::display_forms_list( array(), $message );
564
    }
565
566
	/**
567
	 * Create a custom template from a form
568
	 *
569
	 * @since 3.06
570
	 */
571
	public static function build_template() {
572
		global $wpdb;
573
574
		FrmAppHelper::permission_check( 'frm_edit_forms' );
575
		check_ajax_referer( 'frm_ajax', 'nonce' );
576
577
		$form_id     = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
578
		$new_form_id = FrmForm::duplicate( $form_id, 1, true );
579
		if ( empty( $new_form_id ) ) {
580
			$response = array(
581
				'message' => __( 'There was an error creating a template.', 'formidable' ),
582
			);
583
		} else {
584
			// Update the new form name and description.
585
			$name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
586
			$desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
587
588
			$new_values = array(
589
				'name' => $name,
590
				'description' => $desc,
591
			);
592
			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) );
593
			if ( $query_results ) {
594
				FrmForm::clear_form_cache();
595
			}
596
597
			$response = array(
598
				'redirect' => admin_url( 'admin.php?page=formidable&frm_action=list_templates' ),
599
			);
600
		}
601
602
		echo wp_json_encode( $response );
603
		wp_die();
604
	}
605
606
	/**
607
	* Inserts Formidable button
608
	* Hook exists since 2.5.0
609
	*
610
	* @since 2.0.15
611
	*/
612
	public static function insert_form_button() {
613
		if ( current_user_can( 'frm_view_forms' ) ) {
614
			$menu_name = FrmAppHelper::get_menu_name();
615
			$icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
616
			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' ) . '">' .
617
				FrmAppHelper::kses( $icon, 'all' ) .
618
				' ' . esc_html( $menu_name ) . '</a>'; // WPCS: XSS ok.
619
		}
620
	}
621
622
    public static function insert_form_popup() {
623
		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
624
		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
625
            return;
626
        }
627
628
        FrmAppHelper::load_admin_wide_js();
629
630
        $shortcodes = array(
631
			'formidable' => array(
632
				'name'  => __( 'Form', 'formidable' ),
633
				'label' => __( 'Insert a Form', 'formidable' ),
634
			),
635
        );
636
637
		$shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
638
639
		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
640
    }
641
642
    public static function get_shortcode_opts() {
643
		FrmAppHelper::permission_check( 'frm_view_forms' );
644
        check_ajax_referer( 'frm_ajax', 'nonce' );
645
646
		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
647
		if ( empty( $shortcode ) ) {
648
            wp_die();
649
        }
650
651
		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
652
		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
653
654
        $form_id = '';
655
        $opts = array();
656
		switch ( $shortcode ) {
657
            case 'formidable':
658
                $opts = array(
659
					'form_id'       => 'id',
660
                    //'key' => ',
661
					'title'         => array(
662
						'val'   => 1,
663
						'label' => __( 'Display form title', 'formidable' ),
664
					),
665
					'description'   => array(
666
						'val'   => 1,
667
						'label' => __( 'Display form description', 'formidable' ),
668
					),
669
					'minimize'      => array(
670
						'val'   => 1,
671
						'label' => __( 'Minimize form HTML', 'formidable' ),
672
					),
673
                );
674
        }
675
		$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
676
677
		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
678
			// allow other shortcodes to use the required form id option
679
			$form_id = $opts['form_id'];
680
			unset( $opts['form_id'] );
681
		}
682
683
		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
684
685
        echo '</div>';
686
687
        wp_die();
688
    }
689
690
	public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
691
        FrmAppHelper::permission_check( 'frm_view_forms' );
692
693
        global $wpdb, $frm_vars;
694
695
		if ( empty( $params ) ) {
696
			$params = FrmForm::list_page_params();
697
        }
698
699
        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
700
701
        $pagenum = $wp_list_table->get_pagenum();
702
703
        $wp_list_table->prepare_items();
704
705
        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
706
        if ( $pagenum > $total_pages && $total_pages > 0 ) {
707
			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
708
            die();
709
        }
710
711
		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
712
    }
713
714
	public static function get_columns( $columns ) {
715
	    $columns['cb'] = '<input type="checkbox" />';
716
	    $columns['id'] = 'ID';
717
718
		$type = FrmAppHelper::get_simple_request(
719
			array(
720
				'param'   => 'form_type',
721
				'type'    => 'request',
722
				'default' => 'published',
723
			)
724
		);
725
726
        if ( 'template' == $type ) {
727
            $columns['name']        = __( 'Template Name', 'formidable' );
728
            $columns['type']        = __( 'Type', 'formidable' );
729
            $columns['form_key']    = __( 'Key', 'formidable' );
730
        } else {
731
            $columns['name']        = __( 'Form Title', 'formidable' );
732
            $columns['entries']     = __( 'Entries', 'formidable' );
733
            $columns['form_key']    = __( 'Key', 'formidable' );
734
            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
735
        }
736
737
        $columns['created_at'] = __( 'Date', 'formidable' );
738
739
		add_screen_option(
740
			'per_page',
741
			array(
742
				'label'   => __( 'Forms', 'formidable' ),
743
				'default' => 20,
744
				'option'  => 'formidable_page_formidable_per_page',
745
			)
746
		);
747
748
        return $columns;
749
	}
750
751
	public static function get_sortable_columns() {
752
		return array(
753
			'id'            => 'id',
754
			'name'          => 'name',
755
			'description'   => 'description',
756
			'form_key'      => 'form_key',
757
			'created_at'    => 'created_at',
758
		);
759
	}
760
761
	public static function hidden_columns( $hidden_columns ) {
762
		$type = FrmAppHelper::get_simple_request(
763
			array(
764
				'param' => 'form_type',
765
				'type'  => 'request',
766
			)
767
		);
768
769
		if ( $type === 'template' ) {
770
			$hidden_columns[] = 'id';
771
			$hidden_columns[] = 'form_key';
772
		}
773
774
		return $hidden_columns;
775
	}
776
777
	public static function save_per_page( $save, $option, $value ) {
778
        if ( $option == 'formidable_page_formidable_per_page' ) {
779
            $save = (int) $value;
780
        }
781
        return $save;
782
    }
783
784
	/**
785
	 * Show the template listing page
786
	 *
787
	 * @since 3.06
788
	 */
789
	private static function list_templates() {
790
		wp_enqueue_script( 'jquery-ui-dialog' );
791
		wp_enqueue_style( 'jquery-ui-dialog' );
792
793
		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
794
		$forms = FrmForm::get_published_forms( $where );
795
796
		$api = new FrmFormTemplateApi();
797
		$templates = $api->get_api_info();
798
		self::add_user_templates( $templates );
799
800
		$error   = '';
801
		$expired = false;
802
		if ( isset( $templates['error'] ) ) {
803
			$error   = $templates['error']['message'];
804
			$error   = str_replace( 'utm_medium=addons', 'utm_medium=form-templates', $error );
805
			$expired = ( $templates['error']['code'] === 'expired' );
806
			unset( $templates['error'] );
807
		}
808
809
		$pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' );
810
		$plans = array( 'free', 'Personal', 'Business', 'Elite' );
811
812
		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list-templates.php' );
813
	}
814
815
	private static function add_user_templates( &$templates ) {
816
		$user_templates = array(
817
			'is_template'      => 1,
818
			'default_template' => 0,
819
		);
820
		$user_templates = FrmForm::getAll( $user_templates, 'name' );
821
		foreach ( $user_templates as $template ) {
822
			$template = array(
823
				'id'          => $template->id,
824
				'name'        => $template->name,
825
				'key'         => $template->form_key,
826
				'description' => $template->description,
827
				'url'         => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ),
828
				'released'    => $template->created_at,
829
				'installed'   => 1,
830
			);
831
			array_unshift( $templates, $template );
832
			unset( $template );
833
		}
834
	}
835
836
	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
837
        global $frm_vars;
838
839
        $form = FrmForm::getOne( $id );
840
        if ( ! $form ) {
841
            wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
842
        }
843
844
        if ( $form->parent_form_id ) {
845
			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( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
846
        }
847
848
		$frm_field_selection = FrmField::field_selection();
849
		$fields = FrmField::get_all_for_form( $form->id );
850
851
        // Automatically add end section fields if they don't exist (2.0 migration)
852
        $reset_fields = false;
853
        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
854
855
        if ( $reset_fields ) {
856
            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
857
        }
858
859
		unset( $end_section_values, $last_order, $open, $reset_fields );
860
861
		$args = array( 'parent_form_id' => $form->id );
862
		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
863
		$values['fields'] = $fields;
864
865
        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
866
        if ( $form->is_template && $message == $edit_message ) {
867
            $message = __( 'Template was Successfully Updated', 'formidable' );
868
        }
869
870
		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
871
872
		if ( defined( 'DOING_AJAX' ) ) {
873
            wp_die();
874
        } else if ( $create_link ) {
875
			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
876
        } else {
877
			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
878
        }
879
    }
880
881
	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
882
		FrmAppHelper::permission_check( 'frm_edit_forms' );
883
884
        global $frm_vars;
885
886
        $form = FrmForm::getOne( $id );
887
888
		$fields = FrmField::get_all_for_form( $id );
889
		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
890
891
		self::clean_submit_html( $values );
892
893
        $action_controls = FrmFormActionsController::get_form_actions();
894
895
		$sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
896
        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
897
898
		$styles = apply_filters( 'frm_get_style_opts', array() );
899
900
		$first_h3 = 'frm_first_h3';
901
902
		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
903
    }
904
905
	/**
906
	 * Replace old Submit Button href with new href to avoid errors in Chrome
907
	 *
908
	 * @since 2.03.08
909
	 *
910
	 * @param array|boolean $values
911
	 */
912
	private static function clean_submit_html( &$values ) {
913
		if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
914
			$values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
915
		}
916
	}
917
918
    public static function mb_tags_box( $form_id, $class = '' ) {
919
		$fields = FrmField::get_all_for_form( $form_id, '', 'include' );
920
        $linked_forms = array();
921
        $col = 'one';
922
		$settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
923
924
		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
925
		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
926
927
		$advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
928
929
		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
930
    }
931
932
	/**
933
	 * @since 3.04.01
934
	 */
935
	private static function advanced_helpers( $atts ) {
936
		$advanced_helpers = array(
937
			'default' => array(
938
				'heading' => __( 'Customize the field values with the following parameters. Click to see a sample.', 'formidable' ),
939
				'codes'   => self::get_advanced_shortcodes(),
940
			),
941
		);
942
943
		$user_fields = self::user_shortcodes();
944
		if ( ! empty( $user_fields ) ) {
945
			$user_helpers = array();
946
			foreach ( $user_fields as $uk => $uf ) {
947
				$user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
948
				unset( $uk, $uf );
949
			}
950
951
			$advanced_helpers['user_id'] = array(
952
				'heading' => __( 'Insert user information', 'formidable' ),
953
				'codes'   => $user_helpers,
954
			);
955
		}
956
957
		/**
958
		 * Add extra helper shortcodes on the Advanced tab in form settings and views
959
		 *
960
		 * @since 3.04.01
961
		 * @param array $atts - Includes fields and form_id
962
		 */
963
		return apply_filters( 'frm_advanced_helpers', $advanced_helpers, $atts );
964
	}
965
966
	/**
967
	 * Get an array of the options to display in the advanced tab
968
	 * of the customization panel
969
	 *
970
	 * @since 2.0.6
971
	 */
972
	private static function get_advanced_shortcodes() {
973
		$adv_shortcodes = array(
974
			'x sep=", "'           => array(
975
				'label' => __( 'Separator', 'formidable' ),
976
				'title' => __( 'Use a different separator for checkbox fields', 'formidable' ),
977
			),
978
			'x format="d-m-Y"'     => __( 'Date Format', 'formidable' ),
979
			'x show="field_label"' => __( 'Field Label', 'formidable' ),
980
			'x wpautop=0'          => array(
981
				'label' => __( 'No Auto P', 'formidable' ),
982
				'title' => __( 'Do not automatically add any paragraphs or line breaks', 'formidable' ),
983
			),
984
		);
985
		$adv_shortcodes = apply_filters( 'frm_advanced_shortcodes', $adv_shortcodes );
986
		// __( 'Leave blank instead of defaulting to User Login', 'formidable' ) : blank=1
987
988
		return $adv_shortcodes;
989
	}
990
991
	/**
992
	 * @since 3.04.01
993
	 */
994
	private static function user_shortcodes() {
995
		$options = array(
996
			'ID'            => __( 'User ID', 'formidable' ),
997
			'first_name'    => __( 'First Name', 'formidable' ),
998
			'last_name'     => __( 'Last Name', 'formidable' ),
999
			'display_name'  => __( 'Display Name', 'formidable' ),
1000
			'user_login'    => __( 'User Login', 'formidable' ),
1001
			'user_email'    => __( 'Email', 'formidable' ),
1002
			'avatar'        => __( 'Avatar', 'formidable' ),
1003
			'author_link'   => __( 'Author Link', 'formidable' ),
1004
		);
1005
		return apply_filters( 'frm_user_shortcodes', $options );
1006
	}
1007
1008
	/**
1009
	 * Get an array of the helper shortcodes to display in the customization panel
1010
	 *
1011
	 * @since 2.0.6
1012
	 */
1013
	private static function get_shortcode_helpers( $settings_tab ) {
1014
		$entry_shortcodes = array(
1015
			'id'        => __( 'Entry ID', 'formidable' ),
1016
			'key'       => __( 'Entry Key', 'formidable' ),
1017
			'post_id'   => __( 'Post ID', 'formidable' ),
1018
			'ip'        => __( 'User IP', 'formidable' ),
1019
			'created-at' => __( 'Entry created', 'formidable' ),
1020
			'updated-at' => __( 'Entry updated', 'formidable' ),
1021
			''          => '',
1022
			'siteurl'   => __( 'Site URL', 'formidable' ),
1023
			'sitename'  => __( 'Site Name', 'formidable' ),
1024
        );
1025
1026
		if ( ! FrmAppHelper::pro_is_installed() ) {
1027
			unset( $entry_shortcodes['post_id'] );
1028
		}
1029
1030
		if ( $settings_tab ) {
1031
			$entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1032
			$entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1033
			$entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1034
		}
1035
1036
		/**
1037
		 * Use this hook to add or remove buttons in the helpers section
1038
		 * in the customization panel
1039
		 *
1040
		 * @since 2.0.6
1041
		 */
1042
		$entry_shortcodes = apply_filters( 'frm_helper_shortcodes', $entry_shortcodes, $settings_tab );
1043
1044
		return $entry_shortcodes;
1045
	}
1046
1047
	/**
1048
	 * Insert the form class setting into the form
1049
	 */
1050
	public static function form_classes( $form ) {
1051
		if ( isset( $form->options['form_class'] ) ) {
1052
			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
1053
		}
1054
1055
		if ( isset( $form->options['js_validate'] ) && $form->options['js_validate'] ) {
1056
			echo ' frm_js_validate ';
1057
		}
1058
	}
1059
1060
	public static function get_email_html() {
1061
		FrmAppHelper::permission_check( 'frm_view_forms' );
1062
		check_ajax_referer( 'frm_ajax', 'nonce' );
1063
1064
		echo FrmEntriesController::show_entry_shortcode( // WPCS: XSS ok.
1065
			array(
1066
				'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1067
				'default_email' => true,
1068
				'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1069
			)
1070
		);
1071
		wp_die();
1072
	}
1073
1074
    public static function filter_content( $content, $form, $entry = false ) {
1075
		self::get_entry_by_param( $entry );
1076
        if ( ! $entry ) {
1077
            return $content;
1078
        }
1079
1080
        if ( is_object( $form ) ) {
1081
            $form = $form->id;
1082
        }
1083
1084
        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1085
        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1086
1087
        return $content;
1088
    }
1089
1090
	private static function get_entry_by_param( &$entry ) {
1091
		if ( ! $entry || ! is_object( $entry ) ) {
1092
			if ( ! $entry || ! is_numeric( $entry ) ) {
1093
				$entry = FrmAppHelper::get_post_param( 'id', false, 'sanitize_title' );
1094
			}
1095
1096
			FrmEntry::maybe_get_entry( $entry );
1097
		}
1098
	}
1099
1100
    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1101
        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1102
    }
1103
1104
    public static function process_bulk_form_actions( $errors ) {
1105
        if ( ! $_REQUEST ) {
1106
            return $errors;
1107
        }
1108
1109
		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1110
        if ( $bulkaction == -1 ) {
1111
			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1112
        }
1113
1114
        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
1115
            FrmAppHelper::remove_get_action();
1116
1117
            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
1118
        }
1119
1120
		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
1121
        if ( empty( $ids ) ) {
1122
            $errors[] = __( 'No forms were specified', 'formidable' );
1123
            return $errors;
1124
        }
1125
1126
        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
1127
        if ( $permission_error !== false ) {
1128
            $errors[] = $permission_error;
1129
            return $errors;
1130
        }
1131
1132
        if ( ! is_array( $ids ) ) {
1133
            $ids = explode( ',', $ids );
1134
        }
1135
1136
        switch ( $bulkaction ) {
1137
            case 'delete':
1138
                $message = self::bulk_destroy( $ids );
1139
				break;
1140
            case 'trash':
1141
                $message = self::bulk_trash( $ids );
1142
				break;
1143
            case 'untrash':
1144
                $message = self::bulk_untrash( $ids );
1145
        }
1146
1147
        if ( isset( $message ) && ! empty( $message ) ) {
1148
			$errors['message'] = $message;
1149
        }
1150
1151
        return $errors;
1152
    }
1153
1154
    public static function route() {
1155
		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1156
        $vars = array();
1157
		if ( isset( $_POST['frm_compact_fields'] ) ) {
1158
			FrmAppHelper::permission_check( 'frm_edit_forms' );
1159
1160
			$json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
1161
			$json_vars = json_decode( $json_vars, true );
1162
			if ( empty( $json_vars ) ) {
1163
                // json decoding failed so we should return an error message
1164
				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1165
                if ( 'edit' == $action ) {
1166
                    $action = 'update';
1167
                }
1168
1169
				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1170
            } else {
1171
				$vars = FrmAppHelper::json_to_array( $json_vars );
1172
                $action = $vars[ $action ];
1173
				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1174
				$_REQUEST = array_merge( $_REQUEST, $vars );
1175
				$_POST = array_merge( $_POST, $_REQUEST );
1176
            }
1177
        } else {
1178
			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1179
    		if ( isset( $_REQUEST['delete_all'] ) ) {
1180
                // override the action for this page
1181
    			$action = 'delete_all';
1182
            }
1183
        }
1184
1185
		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1186
        FrmAppHelper::trigger_hook_load( 'form' );
1187
1188
        switch ( $action ) {
1189
            case 'new':
1190
				return self::new_form( $vars );
1191
			case 'add_new':
1192
			case 'list_templates':
1193
            case 'create':
1194
            case 'edit':
1195
            case 'update':
1196
            case 'duplicate':
1197
            case 'trash':
1198
            case 'untrash':
1199
            case 'destroy':
1200
            case 'delete_all':
1201
            case 'settings':
1202
            case 'update_settings':
1203
				return self::$action( $vars );
1204
            default:
1205
				do_action( 'frm_form_action_' . $action );
1206
				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1207
                    return;
1208
                }
1209
1210
				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1211
                if ( $action == -1 ) {
1212
					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1213
                }
1214
1215
				if ( strpos( $action, 'bulk_' ) === 0 ) {
1216
                    FrmAppHelper::remove_get_action();
1217
                    return self::list_form();
1218
                }
1219
1220
                return self::display_forms_list();
1221
        }
1222
    }
1223
1224
    public static function json_error( $errors ) {
1225
        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1226
        return $errors;
1227
    }
1228
1229
1230
    /* FRONT-END FORMS */
1231
    public static function admin_bar_css() {
1232
		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1233
            return;
1234
        }
1235
1236
		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
1237
		FrmAppHelper::load_font_style();
1238
	}
1239
1240
	public static function admin_bar_configure() {
1241
        global $frm_vars;
1242
		if ( empty( $frm_vars['forms_loaded'] ) ) {
1243
            return;
1244
        }
1245
1246
        $actions = array();
1247
		foreach ( $frm_vars['forms_loaded'] as $form ) {
1248
			if ( is_object( $form ) ) {
1249
				$actions[ $form->id ] = $form->name;
1250
			}
1251
			unset( $form );
1252
		}
1253
1254
		if ( empty( $actions ) ) {
1255
			return;
1256
		}
1257
1258
		self::add_menu_to_admin_bar();
1259
		self::add_forms_to_admin_bar( $actions );
1260
	}
1261
1262
	/**
1263
	 * @since 2.05.07
1264
	 */
1265
	public static function add_menu_to_admin_bar() {
1266
		global $wp_admin_bar;
1267
1268
		$wp_admin_bar->add_node(
1269
			array(
1270
				'id'    => 'frm-forms',
1271
				'title' => '<span class="ab-icon"></span><span class="ab-label">' . FrmAppHelper::get_menu_name() . '</span>',
1272
				'href'  => admin_url( 'admin.php?page=formidable' ),
1273
				'meta'  => array(
1274
					'title' => FrmAppHelper::get_menu_name(),
1275
				),
1276
			)
1277
		);
1278
	}
1279
1280
	/**
1281
	 * @since 2.05.07
1282
	 */
1283
	private static function add_forms_to_admin_bar( $actions ) {
1284
		global $wp_admin_bar;
1285
1286
		asort( $actions );
1287
1288
		foreach ( $actions as $form_id => $name ) {
1289
1290
			$wp_admin_bar->add_node(
1291
				array(
1292
					'parent'    => 'frm-forms',
1293
					'id'        => 'edit_form_' . $form_id,
1294
					'title'     => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
1295
					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$form_id'
Loading history...
1296
				)
1297
			);
1298
		}
1299
	}
1300
1301
    //formidable shortcode
1302
	public static function get_form_shortcode( $atts ) {
1303
        global $frm_vars;
1304
		if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1305
            $sc = '[formidable';
1306
			if ( ! empty( $atts ) ) {
1307
				foreach ( $atts as $k => $v ) {
1308
					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1309
				}
1310
			}
1311
			return $sc . ']';
1312
        }
1313
1314
		$shortcode_atts = shortcode_atts(
1315
			array(
1316
				'id'          => '',
1317
				'key'         => '',
1318
				'title'       => false,
1319
				'description' => false,
1320
				'readonly'    => false,
1321
				'entry_id'    => false,
1322
				'fields'      => array(),
1323
				'exclude_fields' => array(),
1324
				'minimize'    => false,
1325
			),
1326
			$atts
1327
		);
1328
		do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1329
1330
        return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
1331
    }
1332
1333
    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1334
        if ( empty( $id ) ) {
1335
            $id = $key;
1336
        }
1337
1338
        $form = self::maybe_get_form_to_show( $id );
1339
        if ( ! $form ) {
1340
            return __( 'Please select a valid form', 'formidable' );
1341
        }
1342
1343
		FrmAppController::maybe_update_styles();
1344
1345
		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1346
        FrmAppHelper::trigger_hook_load( 'form', $form );
1347
1348
        $form = apply_filters( 'frm_pre_display_form', $form );
1349
1350
        $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
1351
1352
		if ( self::is_viewable_draft_form( $form ) ) {
1353
			// don't show a draft form on a page
1354
			$form = __( 'Please select a valid form', 'formidable' );
1355
		} else if ( self::user_should_login( $form ) ) {
1356
			$form = do_shortcode( $frm_settings->login_msg );
1357
		} else if ( self::user_has_permission_to_view( $form ) ) {
1358
			$form = do_shortcode( $frm_settings->login_msg );
1359
		} else {
1360
			do_action( 'frm_pre_get_form', $form );
1361
			$form = self::get_form( $form, $title, $description, $atts );
1362
1363
			/**
1364
			 * Use this shortcode to check for external shortcodes that may span
1365
			 * across multiple fields in the customizable HTML
1366
			 *
1367
			 * @since 2.0.8
1368
			 */
1369
			$form = apply_filters( 'frm_filter_final_form', $form );
1370
		}
1371
1372
		return $form;
1373
    }
1374
1375
	private static function maybe_get_form_to_show( $id ) {
1376
		$form = false;
1377
1378
		if ( ! empty( $id ) ) { // no form id or key set
1379
			$form = FrmForm::getOne( $id );
1380
			if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) {
1381
				$form = false;
1382
			}
1383
		}
1384
1385
		return $form;
1386
	}
1387
1388
	private static function is_viewable_draft_form( $form ) {
1389
		global $post;
1390
		$frm_settings = FrmAppHelper::get_settings();
0 ignored issues
show
Unused Code introduced by
$frm_settings is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1391
		return $form->status == 'draft' && current_user_can( 'frm_edit_forms' ) && ! FrmAppHelper::is_preview_page();
1392
	}
1393
1394
	private static function user_should_login( $form ) {
1395
		return $form->logged_in && ! is_user_logged_in();
1396
	}
1397
1398
	private static function user_has_permission_to_view( $form ) {
1399
		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1400
	}
1401
1402
    public static function get_form( $form, $title, $description, $atts = array() ) {
1403
		ob_start();
1404
1405
		do_action( 'frm_before_get_form', $atts );
1406
1407
        self::get_form_contents( $form, $title, $description, $atts );
1408
		self::enqueue_scripts( FrmForm::get_params( $form ) );
1409
1410
        $contents = ob_get_contents();
1411
        ob_end_clean();
1412
1413
		self::maybe_minimize_form( $atts, $contents );
1414
1415
        return $contents;
1416
    }
1417
1418
	public static function enqueue_scripts( $params ) {
1419
		do_action( 'frm_enqueue_form_scripts', $params );
1420
	}
1421
1422
	public static function get_form_contents( $form, $title, $description, $atts ) {
1423
		$params = FrmForm::get_params( $form );
1424
		$errors = self::get_saved_errors( $form, $params );
1425
		$fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
1426
		$reset = false;
1427
		$pass_args = compact( 'form', 'fields', 'errors', 'title', 'description', 'reset' );
1428
1429
		$handle_process_here = $params['action'] == 'create' && $params['posted_form_id'] == $form->id && $_POST;
1430
1431
		if ( ! $handle_process_here ) {
1432
			do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1433
			if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1434
				self::show_form_after_submit( $pass_args );
1435
			}
1436
		} elseif ( ! empty( $errors ) ) {
1437
			self::show_form_after_submit( $pass_args );
1438
1439
		} else {
1440
1441
			do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1442
1443
			if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1444
				$entry_id = self::just_created_entry( $form->id );
1445
				$pass_args['entry_id'] = $entry_id;
1446
				$pass_args['reset'] = true;
1447
				$pass_args['conf_method'] = self::get_confirmation_method( compact( 'form', 'entry_id' ) );
1448
1449
				self::run_success_action( $pass_args );
1450
1451
				do_action(
1452
					'frm_after_entry_processed',
1453
					array(
1454
						'entry_id' => $entry_id,
1455
						'form'     => $form,
1456
					)
1457
				);
1458
			}
1459
		}
1460
	}
1461
1462
	/**
1463
	 * If the form was processed earlier (init), get the generated errors
1464
	 *
1465
	 * @since 2.05
1466
	 */
1467
	private static function get_saved_errors( $form, $params ) {
1468
		global $frm_vars;
1469
1470
		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
1471
			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
1472
		} else {
1473
			$errors = array();
1474
		}
1475
		return $errors;
1476
	}
1477
1478
	/**
1479
	 * @since 2.2.7
1480
	 */
1481
	public static function just_created_entry( $form_id ) {
1482
		global $frm_vars;
1483
		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;
1484
	}
1485
1486
	/**
1487
	 * @since 3.0
1488
	 */
1489
	private static function get_confirmation_method( $atts ) {
1490
		$opt = 'success_action';
1491
		$method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
1492
		$method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' );
1493
1494
		if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
1495
			$method = 'message';
1496
		}
1497
1498
		return $method;
1499
	}
1500
1501
	public static function maybe_trigger_redirect( $form, $params, $args ) {
1502
		if ( ! isset( $params['id'] ) ) {
1503
			global $frm_vars;
1504
			$params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
1505
		}
1506
1507
		$conf_method = self::get_confirmation_method(
1508
			array(
1509
				'form'     => $form,
1510
				'entry_id' => $params['id'],
1511
			)
1512
		);
1513
1514
		if ( 'redirect' === $conf_method ) {
1515
			self::trigger_redirect( $form, $params, $args );
1516
		}
1517
	}
1518
1519
	public static function trigger_redirect( $form, $params, $args ) {
1520
		$success_args = array(
1521
			'action'      => $params['action'],
1522
			'conf_method' => 'redirect',
1523
			'form'        => $form,
1524
			'entry_id'    => $params['id'],
1525
		);
1526
1527
		if ( isset( $args['ajax'] ) ) {
1528
			$success_args['ajax'] = $args['ajax'];
1529
		}
1530
1531
		self::run_success_action( $success_args );
1532
	}
1533
1534
	/**
1535
	 * Used when the success action is not 'message'
1536
	 *
1537
	 * @since 2.05
1538
	 */
1539
	public static function run_success_action( $args ) {
1540
		$extra_args = $args;
1541
		unset( $extra_args['form'] );
1542
1543
		do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
1544
1545
		$opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit';
1546
		$args['success_opt'] = $opt;
1547
		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) {
1548
			self::load_page_after_submit( $args );
1549
		} elseif ( $args['conf_method'] == 'redirect' ) {
1550
			self::redirect_after_submit( $args );
1551
		} else {
1552
			self::show_message_after_save( $args );
1553
		}
1554
	}
1555
1556
	/**
1557
	 * @since 3.0
1558
	 */
1559
	private static function load_page_after_submit( $args ) {
1560
		global $post;
1561
		$opt = $args['success_opt'];
1562
		if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
1563
			$page = get_post( $args['form']->options[ $opt . '_page_id' ] );
1564
			$old_post = $post;
1565
			$post = $page;
0 ignored issues
show
introduced by
Overridding WordPress globals is prohibited
Loading history...
1566
			$content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
1567
			echo apply_filters( 'the_content', $content ); // WPCS: XSS ok.
1568
			$post = $old_post;
0 ignored issues
show
introduced by
Overridding WordPress globals is prohibited
Loading history...
1569
		}
1570
	}
1571
1572
	/**
1573
	 * @since 3.0
1574
	 */
1575
	private static function redirect_after_submit( $args ) {
1576
		global $frm_vars;
1577
1578
		add_filter( 'frm_use_wpautop', '__return_false' );
1579
1580
		$opt = $args['success_opt'];
1581
		$success_url = trim( $args['form']->options[ $opt . '_url' ] );
1582
		$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
1583
		$success_url = do_shortcode( $success_url );
1584
1585
		$success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1586
1587
		$redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args );
1588
1589
		$args['id'] = $args['entry_id'];
1590
		FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args );
1591
1592
		add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' );
1593
		$success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
1594
1595
		$doing_ajax = FrmAppHelper::doing_ajax();
1596
1597
		if ( isset( $args['ajax'] ) && $args['ajax'] && $doing_ajax ) {
1598
			echo json_encode( array( 'redirect' => $success_url ) );
1599
			wp_die();
1600
		} elseif ( ! headers_sent() ) {
1601
			wp_redirect( esc_url_raw( $success_url ) );
1602
			die(); // do not use wp_die or redirect fails
1603
		} else {
1604
			add_filter( 'frm_use_wpautop', '__return_true' );
1605
1606
			echo $redirect_msg; // WPCS: XSS ok.
1607
			echo "<script type='text/javascript'>window.onload = function(){setTimeout(window.location='" . esc_url_raw( $success_url ) . "', 8000);}</script>";
1608
		}
1609
	}
1610
1611
	/**
1612
	 * @since 3.0
1613
	 * @param string $success_url
1614
	 * @param string $success_msg
1615
	 * @param array $args
1616
	 */
1617
	private static function get_redirect_message( $success_url, $success_msg, $args ) {
1618
		$redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message">' . $success_msg . '<br/>' .
1619
			sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) .
1620
			'</div></div>';
1621
1622
		$redirect_args = array(
1623
			'entry_id' => $args['entry_id'],
1624
			'form_id'  => $args['form']->id,
1625
			'form'     => $args['form'],
1626
		);
1627
		return apply_filters( 'frm_redirect_msg', $redirect_msg, $redirect_args );
1628
	}
1629
1630
	/**
1631
	 * Prepare to show the success message and empty form after submit
1632
	 *
1633
	 * @since 2.05
1634
	 */
1635
	public static function show_message_after_save( $atts ) {
1636
		$atts['message'] = self::prepare_submit_message( $atts['form'], $atts['entry_id'] );
1637
1638
		if ( ! isset( $atts['form']->options['show_form'] ) || $atts['form']->options['show_form'] ) {
1639
			self::show_form_after_submit( $atts );
1640
		} else {
1641
			self::show_lone_success_messsage( $atts );
1642
		}
1643
	}
1644
1645
	/**
1646
	 * Show an empty form
1647
	 *
1648
	 * @since 2.05
1649
	 */
1650
	private static function show_form_after_submit( $args ) {
1651
		self::fill_atts_for_form_display( $args );
1652
1653
		$errors = $args['errors'];
1654
		$message = $args['message'];
1655
		$form = $args['form'];
1656
		$title = $args['title'];
1657
		$description = $args['description'];
1658
1659
		if ( empty( $args['fields'] ) ) {
1660
			$values = array();
1661
		} else {
1662
			$values = FrmEntriesHelper::setup_new_vars( $args['fields'], $form, $args['reset'] );
1663
		}
1664
		unset( $args );
1665
1666
		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1667
1668
		$frm_settings = FrmAppHelper::get_settings();
1669
		$submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1670
1671
		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1672
	}
1673
1674
	/**
1675
	 * Get all the values needed on the new.php entry page
1676
	 *
1677
	 * @since 2.05
1678
	 */
1679
	private static function fill_atts_for_form_display( &$args ) {
1680
		$defaults = array(
1681
			'errors'  => array(),
1682
			'message' => '',
1683
			'fields'  => array(),
1684
			'form'    => array(),
1685
			'title'   => true,
1686
			'description' => false,
1687
			'reset'   => false,
1688
		);
1689
		$args = wp_parse_args( $args, $defaults );
1690
	}
1691
1692
	/**
1693
	 * Show the success message without the form
1694
	 *
1695
	 * @since 2.05
1696
	 */
1697
	private static function show_lone_success_messsage( $atts ) {
1698
		global $frm_vars;
1699
		$values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
1700
		self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
1701
1702
		$include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1703
		$errors = array();
1704
		$form = $atts['form'];
1705
		$message = $atts['message'];
1706
1707
		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1708
	}
1709
1710
	/**
1711
	 * Prepare the success message before it's shown
1712
	 *
1713
	 * @since 2.05
1714
	 */
1715
	private static function prepare_submit_message( $form, $entry_id ) {
1716
		$frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
1717
1718
		if ( $entry_id && is_numeric( $entry_id ) ) {
1719
			$message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1720
			$class = 'frm_message';
1721
		} else {
1722
			$message = $frm_settings->failed_msg;
1723
			$class = FrmFormsHelper::form_error_class();
1724
		}
1725
1726
		$message = FrmFormsHelper::get_success_message( compact( 'message', 'form', 'entry_id', 'class' ) );
1727
		return apply_filters( 'frm_main_feedback', $message, $form, $entry_id );
1728
	}
1729
1730
	public static function front_head() {
1731
		$version = FrmAppHelper::plugin_version();
1732
		$suffix = FrmAppHelper::js_suffix();
1733
1734
		if ( ! empty( $suffix ) && self::has_combo_js_file() ) {
1735
			wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/frm.min.js', array( 'jquery' ), $version, true );
1736
		} else {
1737
			wp_register_script( 'formidable', FrmAppHelper::plugin_url() . "/js/formidable{$suffix}.js", array( 'jquery' ), $version, true );
1738
		}
1739
1740
		add_filter( 'script_loader_tag', 'FrmFormsController::defer_script_loading', 10, 2 );
1741
1742
		if ( FrmAppHelper::is_admin() ) {
1743
			// don't load this in back-end
1744
			return;
1745
		}
1746
1747
		FrmAppHelper::localize_script( 'front' );
1748
		FrmStylesController::enqueue_css( 'register' );
1749
	}
1750
1751
	/**
1752
	 * @since 3.0
1753
	 */
1754
	public static function has_combo_js_file() {
1755
		return is_readable( FrmAppHelper::plugin_path() . '/js/frm.min.js' );
1756
	}
1757
1758
	public static function maybe_load_css( $form, $this_load, $global_load ) {
1759
		$load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load );
1760
1761
		if ( $load_css ) {
1762
			global $frm_vars;
1763
			self::footer_js( 'header' );
1764
			$frm_vars['css_loaded'] = true;
1765
		}
1766
	}
1767
1768
	public static function defer_script_loading( $tag, $handle ) {
1769
	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1770
	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1771
		}
1772
	    return $tag;
1773
	}
1774
1775
	public static function footer_js( $location = 'footer' ) {
1776
		global $frm_vars;
1777
1778
		FrmStylesController::enqueue_css();
1779
1780
		if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
1781
			//load formidable js
1782
			wp_enqueue_script( 'formidable' );
1783
		}
1784
	}
1785
1786
	/**
1787
	 * @since 2.0.8
1788
	 */
1789
	private static function maybe_minimize_form( $atts, &$content ) {
1790
		// check if minimizing is turned on
1791
		if ( self::is_minification_on( $atts ) ) {
1792
			$content = str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', $content );
1793
		}
1794
	}
1795
1796
	/**
1797
	 * @since 2.0.8
1798
	 * @return boolean
1799
	 */
1800
	private static function is_minification_on( $atts ) {
1801
		return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
1802
	}
1803
1804
	/**
1805
	 * @deprecated 1.07.05
1806
	 * @codeCoverageIgnore
1807
	 */
1808
	public static function add_default_templates( $path, $default = true, $template = true ) {
1809
		FrmDeprecated::add_default_templates( $path, $default, $template );
1 ignored issue
show
Deprecated Code introduced by
The method FrmDeprecated::add_default_templates() has been deprecated with message: 1.07.05

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1810
	}
1811
1812
	/**
1813
	 * @deprecated 3.0
1814
	 * @codeCoverageIgnore
1815
	 */
1816
	public static function bulk_create_template( $ids ) {
1817
		return FrmDeprecated::bulk_create_template( $ids );
1 ignored issue
show
Deprecated Code introduced by
The method FrmDeprecated::bulk_create_template() has been deprecated with message: 3.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1818
	}
1819
1820
	/**
1821
	 * @deprecated 2.03
1822
	 * @codeCoverageIgnore
1823
	 */
1824
	public static function register_pro_scripts() {
1825
		FrmDeprecated::register_pro_scripts();
1 ignored issue
show
Deprecated Code introduced by
The method FrmDeprecated::register_pro_scripts() has been deprecated with message: 2.03

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1826
	}
1827
1828
	/**
1829
	 * @deprecated 3.0
1830
	 * @codeCoverageIgnore
1831
	 */
1832
	public static function edit_key() {
1833
		FrmDeprecated::edit_key();
1 ignored issue
show
Deprecated Code introduced by
The method FrmDeprecated::edit_key() has been deprecated with message: 3.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1834
	}
1835
1836
	/**
1837
	 * @deprecated 3.0
1838
	 * @codeCoverageIgnore
1839
	 */
1840
	public static function edit_description() {
1841
		FrmDeprecated::edit_description();
1 ignored issue
show
Deprecated Code introduced by
The method FrmDeprecated::edit_description() has been deprecated with message: 3.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1842
	}
1843
}
1844