PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 2.05.09
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v2.05.09
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 / helpers / FrmFormsHelper.php

FrmFormsHelper.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 2.05.09, at classes/helpers/FrmFormsHelper.php

696 lines 23.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined('ABSPATH') ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmFormsHelper {
7
8 public static function maybe_get_form( &$form ) {
9 _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::maybe_get_form' );
10 FrmForm::maybe_get_form( $form );
11 }
12
13 /**
14 * @since 2.2.10
15 */
16 public static function form_error_class() {
17 return apply_filters( 'frm_form_error_class', 'frm_error_style' );
18 }
19
20 public static function get_direct_link( $key, $form = false ) {
21 $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
22 $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
23
24 return $target_url;
25 }
26
27 public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
28 $defaults = array(
29 'blank' => true,
30 'field_id' => false,
31 'onchange' => false,
32 'exclude' => false,
33 'class' => '',
34 'inc_children' => 'exclude',
35 );
36 $args = wp_parse_args( $args, $defaults );
37
38 if ( ! $args['field_id'] ) {
39 $args['field_id'] = $field_name;
40 }
41
42 $query = array();
43 if ( $args['exclude'] ) {
44 $query['id !'] = $args['exclude'];
45 }
46
47 $where = apply_filters('frm_forms_dropdown', $query, $field_name);
48 $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
49 $add_html = array();
50 self::add_html_attr( $args['onchange'], 'onchange', $add_html );
51 self::add_html_attr( $args['class'], 'class', $add_html );
52
53 ?>
54 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
55 <?php if ( $args['blank'] ) { ?>
56 <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
57 <?php } ?>
58 <?php foreach ( $forms as $form ) { ?>
59 <option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>>
60 <?php echo esc_html( '' === $form->name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 50 ) . ( $form->parent_form_id ? __( ' (child)', 'formidable' ) : '' ) ); ?>
61 </option>
62 <?php } ?>
63 </select>
64 <?php
65 }
66
67 /**
68 * @param string $class
69 * @param string $param
70 * @param array $add_html
71 *
72 * @since 2.0.6
73 */
74 public static function add_html_attr( $class, $param, &$add_html ) {
75 if ( ! empty( $class ) ) {
76 $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
77 }
78 }
79
80 public static function form_switcher() {
81 $where = apply_filters( 'frm_forms_dropdown', array(), '' );
82 $forms = FrmForm::get_published_forms( $where );
83
84 $args = array(
85 'id' => 0,
86 'form' => 0,
87 );
88 if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
89 unset( $args['form'] );
90 } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
91 unset( $args['id'] );
92 }
93
94 $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
95 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
96 $args['frm_action'] = 'list';
97 $args['form'] = 0;
98 } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
99 $args['frm_action'] = 'edit';
100 } else if ( isset( $_GET['post'] ) ) {
101 $args['form'] = 0;
102 $base = admin_url('edit.php?post_type=frm_display');
103 }
104
105 ?>
106 <li class="dropdown last" id="frm_bs_dropdown">
107 <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
108 <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
109 <?php
110 foreach ( $forms as $form ) {
111 if ( isset( $args['id'] ) ) {
112 $args['id'] = $form->id;
113 }
114 if ( isset( $args['form'] ) ) {
115 $args['form'] = $form->id;
116 }
117 ?>
118 <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
119 <?php
120 unset( $form );
121 }
122 ?>
123 </ul>
124 </li>
125 <?php
126 }
127
128 public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
129 echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
130 echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc';
131 }
132
133 /**
134 * Get the invalid form error message
135 *
136 * @since 2.02.07
137 * @param array $args
138 * @return string
139 */
140 public static function get_invalid_error_message( $args ) {
141 $frm_settings = FrmAppHelper::get_settings();
142
143 $invalid_msg = apply_filters( 'frm_invalid_error_message', $frm_settings->invalid_msg, $args );
144
145 return $invalid_msg;
146 }
147
148 public static function get_success_message( $atts ) {
149 $message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] );
150 $message = FrmAppHelper::use_wpautop( do_shortcode( $message ) );
151 $message = '<div class="' . esc_attr( $atts['class'] ) . '">' . $message . '</div>';
152 return $message;
153 }
154
155 /**
156 * Used when a form is created
157 */
158 public static function setup_new_vars( $values = array() ) {
159 global $wpdb;
160
161 if ( ! empty( $values ) ) {
162 $post_values = $values;
163 } else {
164 $values = array();
165 $post_values = isset($_POST) ? $_POST : array();
166 }
167
168 $defaults = array(
169 'name' => '',
170 'description' => '',
171 );
172 foreach ( $defaults as $var => $default ) {
173 if ( ! isset( $values[ $var ] ) ) {
174 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
175 }
176 }
177
178 $values['description'] = FrmAppHelper::use_wpautop($values['description']);
179
180 $defaults = array(
181 'form_id' => '',
182 'logged_in' => '',
183 'editable' => '',
184 'default_template' => 0,
185 'is_template' => 0,
186 'status' => 'draft',
187 'parent_form_id' => 0,
188 );
189 foreach ( $defaults as $var => $default ) {
190 if ( ! isset( $values[ $var ] ) ) {
191 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
192 }
193 }
194 unset( $defaults );
195
196 if ( ! isset( $values['form_key'] ) ) {
197 $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
198 }
199
200 $values = self::fill_default_opts( $values, false, $post_values );
201 $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
202
203 return apply_filters('frm_setup_new_form_vars', $values);
204 }
205
206 /**
207 * Used when editing a form
208 */
209 public static function setup_edit_vars( $values, $record, $post_values = array() ) {
210 if ( empty( $post_values ) ) {
211 $post_values = stripslashes_deep( $_POST );
212 }
213
214 $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
215 $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
216 $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
217 $values['status'] = $record->status;
218
219 $values = self::fill_default_opts($values, $record, $post_values);
220
221 return apply_filters('frm_setup_edit_form_vars', $values);
222 }
223
224 public static function fill_default_opts( $values, $record, $post_values ) {
225
226 $defaults = self::get_default_opts();
227 foreach ( $defaults as $var => $default ) {
228 if ( is_array($default) ) {
229 if ( ! isset( $values[ $var ] ) ) {
230 $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
231 }
232
233 foreach ( $default as $k => $v ) {
234 $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v );
235
236 if ( is_array( $v ) ) {
237 foreach ( $v as $k1 => $v1 ) {
238 $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
239 unset( $k1, $v1 );
240 }
241 }
242
243 unset($k, $v);
244 }
245 } else {
246 $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
247 }
248
249 unset($var, $default);
250 }
251
252 return $values;
253 }
254
255 public static function get_default_opts() {
256 $frm_settings = FrmAppHelper::get_settings();
257
258 return array(
259 'submit_value' => $frm_settings->submit_value,
260 'success_action' => 'message',
261 'success_msg' => $frm_settings->success_msg,
262 'show_form' => 0,
263 'akismet' => '',
264 'no_save' => 0,
265 'ajax_load' => 0,
266 'form_class' => '',
267 'custom_style' => 1,
268 'before_html' => self::get_default_html( 'before' ),
269 'after_html' => '',
270 'submit_html' => self::get_default_html( 'submit' ),
271 );
272 }
273
274 /**
275 * @param array $options
276 * @param array $values
277 * @since 2.0.6
278 */
279 public static function fill_form_options( &$options, $values ) {
280 $defaults = self::get_default_opts();
281 foreach ( $defaults as $var => $default ) {
282 $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
283 unset( $var, $default );
284 }
285 }
286
287 /**
288 * @param string $loc
289 */
290 public static function get_default_html( $loc ) {
291 if ( $loc == 'submit' ) {
292 $draft_link = self::get_draft_link();
293 $default_html = <<<SUBMIT_HTML
294 <div class="frm_submit">
295 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
296 <button class="frm_button_submit" type="submit" [button_action]>[button_label]</button>
297 $draft_link
298 </div>
299 SUBMIT_HTML;
300 } else if ( $loc == 'before' ) {
301 $default_html = <<<BEFORE_HTML
302 <legend class="frm_hidden">[form_name]</legend>
303 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
304 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
305 BEFORE_HTML;
306 } else {
307 $default_html = '';
308 }
309
310 return $default_html;
311 }
312
313 public static function get_draft_link() {
314 $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
315 return $link;
316 }
317
318 public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
319 $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
320 if ( ! strpos( $button, '[button_action]' ) ) {
321 echo $button;
322 return;
323 }
324
325 $button_parts = explode( '[button_action]', $button );
326
327 $classes = apply_filters( 'frm_submit_button_class', array(), $form );
328 if ( ! empty( $classes ) ) {
329 $classes = implode( ' ', $classes );
330 $button_class = ' class="frm_button_submit';
331 if ( strpos( $button_parts[0], $button_class ) !== false ) {
332 $button_parts[0] = str_replace( $button_class, $button_class . ' ' . esc_attr( $classes ), $button_parts[0] );
333 } else {
334 $button_parts[0] .= ' class="' . esc_attr( $classes ) . '"';
335 }
336 }
337
338 echo $button_parts[0];
339 do_action( 'frm_submit_button_action', $form, $form_action );
340 echo $button_parts[1];
341 }
342
343 /**
344 * Automatically add end section fields if they don't exist (2.0 migration)
345 * @since 2.0
346 *
347 * @param boolean $reset_fields
348 */
349 public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
350 if ( empty( $fields ) ) {
351 return;
352 }
353
354 $end_section_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( 'end_divider', $form->id ) );
355 $open = false;
356 $prev_order = false;
357 $add_order = 0;
358 $last_field = false;
359 foreach ( $fields as $field ) {
360 if ( $prev_order === $field->field_order ) {
361 $add_order++;
362 }
363
364 if ( $add_order ) {
365 $reset_fields = true;
366 $field->field_order = $field->field_order + $add_order;
367 FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
368 }
369
370 switch ( $field->type ) {
371 case 'divider':
372 // create an end section if open
373 self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
374
375 // mark it open for the next end section
376 $open = true;
377 break;
378 case 'break':
379 self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
380 break;
381 case 'end_divider':
382 if ( ! $open ) {
383 // the section isn't open, so this is an extra field that needs to be removed
384 FrmField::destroy( $field->id );
385 $reset_fields = true;
386 }
387
388 // There is already an end section here, so there is no need to create one
389 $open = false;
390 }
391 $prev_order = $field->field_order;
392
393 $last_field = $field;
394 unset( $field );
395 }
396
397 self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
398 }
399
400 /**
401 * Create end section field if it doesn't exist. This is for migration from < 2.0
402 * Fix any ordering that may be messed up
403 */
404 public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
405 if ( ! $open ) {
406 return;
407 }
408
409 $end_section_values['field_order'] = $field->field_order + 1;
410
411 FrmField::create( $end_section_values );
412
413 if ( $move == 'move' ) {
414 // bump the order of current field unless we're at the end of the form
415 FrmField::update( $field->id, array( 'field_order' => $field->field_order + 2 ) );
416 }
417
418 $add_order += 2;
419 $open = false;
420 $reset_fields = true;
421 }
422
423 public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
424 $codes = array(
425 'form_name' => $title,
426 'form_description' => $description,
427 'entry_key' => true,
428 );
429 foreach ( $codes as $code => $show ) {
430 if ( $code == 'form_name' ) {
431 $replace_with = $form->name;
432 } else if ( $code == 'form_description' ) {
433 $replace_with = FrmAppHelper::use_wpautop($form->description);
434 } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
435 $replace_with = FrmAppHelper::simple_get( 'entry' );
436 } else {
437 $replace_with = '';
438 }
439
440 FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
441 }
442
443 //replace [form_key]
444 $html = str_replace('[form_key]', $form->form_key, $html);
445
446 //replace [frmurl]
447 $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
448
449 if ( strpos( $html, '[button_label]' ) ) {
450 add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
451 $submit_label = apply_filters( 'frm_submit_button', $title, $form );
452 $submit_label = esc_attr( do_shortcode( $submit_label ) );
453 $html = str_replace( '[button_label]', $submit_label, $html );
454 }
455
456 $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
457
458 if ( strpos( $html, '[if back_button]' ) ) {
459 $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
460 }
461
462 if ( strpos( $html, '[if save_draft]' ) ) {
463 $html = preg_replace( '/(\[if\s+save_draft\])(.*?)(\[\/if\s+save_draft\])/mis', '', $html );
464 }
465
466 if ( apply_filters( 'frm_do_html_shortcodes', true ) ) {
467 $html = do_shortcode( $html );
468 }
469
470 return $html;
471 }
472
473 public static function submit_button_label( $submit ) {
474 if ( ! $submit || empty($submit) ) {
475 $frm_settings = FrmAppHelper::get_settings();
476 $submit = $frm_settings->submit_value;
477 }
478
479 return $submit;
480 }
481
482 /**
483 * If the Formidable styling isn't being loaded,
484 * use inline styling to hide the element
485 * @since 2.03.05
486 */
487 public static function maybe_hide_inline() {
488 $frm_settings = FrmAppHelper::get_settings();
489 if ( $frm_settings->load_style == 'none' ) {
490 echo ' style="display:none;"';
491 } elseif ( $frm_settings->load_style == 'dynamic' ) {
492 FrmStylesController::enqueue_style();
493 }
494 }
495
496 public static function get_form_style_class( $form = false ) {
497 $style = self::get_form_style($form);
498 $class = ' with_frm_style';
499
500 if ( empty($style) ) {
501 if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
502 return $class;
503 } else {
504 return;
505 }
506 }
507
508 //If submit button needs to be inline or centered
509 if ( is_object($form) ) {
510 $form = $form->options;
511 }
512
513 $submit_align = isset( $form['submit_align'] ) ? $form['submit_align'] : '';
514
515 if ( $submit_align == 'inline' ) {
516 $class .= ' frm_inline_form';
517 } else if ( $submit_align == 'center' ) {
518 $class .= ' frm_center_submit';
519 }
520
521 $class = apply_filters('frm_add_form_style_class', $class, $style);
522
523 return $class;
524 }
525
526 /**
527 * @param string|boolean $form
528 *
529 * @return string
530 */
531 public static function get_form_style( $form ) {
532 $style = 1;
533 if ( empty( $form ) || 'default' == 'form' ) {
534 return $style;
535 } else if ( is_object( $form ) && $form->parent_form_id ) {
536 // get the parent form if this is a child
537 $form = $form->parent_form_id;
538 } else if ( is_array( $form ) && isset( $form['parent_form_id'] ) && $form['parent_form_id'] ) {
539 $form = $form['parent_form_id'];
540 } else if ( is_array( $form ) && isset( $form['custom_style'] ) ) {
541 $style = $form['custom_style'];
542 }
543
544 if ( $form && is_string( $form ) ) {
545 $form = FrmForm::getOne( $form );
546 }
547
548 $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
549
550 return $style;
551 }
552
553 /**
554 * Display the validation error messages when an entry is submitted
555 *
556 * @param array $args - includes img, errors
557 * @since 2.0.6
558 */
559 public static function show_errors( $args ) {
560 $invalid_msg = self::get_invalid_error_message( $args );
561
562 if ( empty( $invalid_msg ) ) {
563 $show_img = false;
564 } else {
565 echo wp_kses_post( $invalid_msg );
566 $show_img = true;
567 }
568
569 self::show_error( array(
570 'img' => $args['img'],
571 'errors' => $args['errors'],
572 'show_img' => $show_img,
573 ) );
574 }
575
576 /**
577 * Display the error message in the front-end along with the image if set
578 * The image was removed from the styling settings, but it may still be set with a hook
579 * If the message in the global settings is empty, show every validation message in the error box
580 *
581 * @param array $args - includes img, errors, and show_img
582 * @since 2.0.6
583 */
584 public static function show_error( $args ) {
585 $line_break_first = $args['show_img'];
586 foreach ( $args['errors'] as $error_key => $error ) {
587 if ( $line_break_first && ! is_numeric( $error_key ) && ( $error_key == 'cptch_number' || strpos( $error_key, 'field' ) === 0 ) ) {
588 continue;
589 }
590
591 if ( $line_break_first ) {
592 echo '<br/>';
593 }
594
595 if ( $args['show_img'] && ! empty( $args['img'] ) ) {
596 echo '<img src="' . esc_attr( $args['img'] ) . '" alt="" />';
597 } else {
598 $args['show_img'] = true;
599 }
600
601 echo wp_kses_post( $error );
602
603 if ( ! $line_break_first ) {
604 echo '<br/>';
605 }
606 }
607 }
608
609 public static function maybe_get_scroll_js( $id ) {
610 $offset = apply_filters( 'frm_scroll_offset', 4, array( 'form_id' => $id ) );
611 if ( $offset != -1 ) {
612 self::get_scroll_js( $id );
613 }
614 }
615
616 public static function get_scroll_js( $form_id ) {
617 echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
618 }
619
620 public static function edit_form_link( $form_id ) {
621 if ( is_object($form_id) ) {
622 $form = $form_id;
623 $name = $form->name;
624 $form_id = $form->id;
625 } else {
626 $name = FrmForm::getName($form_id);
627 }
628
629 if ( $form_id ) {
630 $val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
631 } else {
632 $val = '';
633 }
634
635 return $val;
636 }
637
638 public static function delete_trash_link( $id, $status, $length = 'long' ) {
639 $link = '';
640 $labels = array(
641 'restore' => array(
642 'long' => __( 'Restore from Trash', 'formidable' ),
643 'short' => __( 'Restore', 'formidable' ),
644 ),
645 'trash' => array(
646 'long' => __( 'Move to Trash', 'formidable' ),
647 'short' => __( 'Trash', 'formidable' ),
648 ),
649 'delete' => array(
650 'long' => __( 'Delete Permanently', 'formidable' ),
651 'short' => __( 'Delete', 'formidable' ),
652 ),
653 );
654
655 $current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) );
656 $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
657 if ( 'trash' == $status ) {
658 $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
659 } else if ( current_user_can('frm_delete_forms') ) {
660 if ( EMPTY_TRASH_DAYS ) {
661 $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
662 } else {
663 $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
664 }
665 }
666
667 return $link;
668 }
669
670 public static function status_nice_name( $status ) {
671 $nice_names = array(
672 'draft' => __( 'Draft', 'formidable' ),
673 'trash' => __( 'Trash', 'formidable' ),
674 'publish' => __( 'Published', 'formidable' ),
675 );
676
677 if ( ! in_array($status, array_keys($nice_names)) ) {
678 $status = 'publish';
679 }
680
681 $name = $nice_names[ $status ];
682
683 return $name;
684 }
685
686 public static function get_params() {
687 _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
688 return FrmForm::list_page_params();
689 }
690
691 public static function form_loaded( $form, $this_load, $global_load ) {
692 _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::maybe_load_css' );
693 FrmFormsController::maybe_load_css( $form, $this_load, $global_load );
694 }
695 }
696