@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return $values; |
|
| 33 | - } |
|
| 32 | + return $values; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | public static function get_html_id( $field, $plus = '' ) { |
| 36 | 36 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public static function setup_edit_vars( $field, $doing_ajax = false ) { |
|
| 39 | + public static function setup_edit_vars( $field, $doing_ajax = false ) { |
|
| 40 | 40 | $values = self::field_object_to_array( $field ); |
| 41 | 41 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | public static function field_object_to_array( $field ) { |
| 45 | 45 | $values = (array) $field; |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | return $field_type->get_new_field_defaults(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 243 | - global $wpdb; |
|
| 242 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 243 | + global $wpdb; |
|
| 244 | 244 | |
| 245 | 245 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 246 | - $values['form_id'] = $form_id; |
|
| 246 | + $values['form_id'] = $form_id; |
|
| 247 | 247 | $values['options'] = maybe_serialize( $field->options ); |
| 248 | 248 | $values['default_value'] = maybe_serialize( $field->default_value ); |
| 249 | 249 | |
| 250 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 251 | - $values[ $col ] = $field->{$col}; |
|
| 252 | - } |
|
| 253 | - } |
|
| 250 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 251 | + $values[ $col ] = $field->{$col}; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * @since 2.0 |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 407 | 407 | _deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' ); |
| 408 | - return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
| 409 | - } |
|
| 408 | + return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | 411 | public static function get_checkbox_id( $field, $opt_key ) { |
| 412 | 412 | $id = $field['id']; |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public static function display_recaptcha( $field ) { |
| 424 | 424 | _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' ); |
| 425 | - } |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | public static function show_single_option( $field ) { |
| 428 | 428 | if ( ! is_array( $field['options'] ) ) { |
@@ -433,26 +433,26 @@ discard block |
||
| 433 | 433 | $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field ); |
| 434 | 434 | |
| 435 | 435 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 436 | - $field_val = self::get_value_from_array( $opt, $opt_key, $field ); |
|
| 437 | - $opt = self::get_label_from_array( $opt, $opt_key, $field ); |
|
| 436 | + $field_val = self::get_value_from_array( $opt, $opt_key, $field ); |
|
| 437 | + $opt = self::get_label_from_array( $opt, $opt_key, $field ); |
|
| 438 | 438 | |
| 439 | 439 | // Get string for Other text field, if needed |
| 440 | 440 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 441 | 441 | |
| 442 | 442 | $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : ''; |
| 443 | 443 | |
| 444 | - // If this is an "Other" option, get the HTML for it |
|
| 444 | + // If this is an "Other" option, get the HTML for it |
|
| 445 | 445 | if ( self::is_other_opt( $opt_key ) ) { |
| 446 | 446 | if ( FrmAppHelper::pro_is_installed() ) { |
| 447 | 447 | require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' ); |
| 448 | 448 | } |
| 449 | - } else { |
|
| 449 | + } else { |
|
| 450 | 450 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | 453 | unset( $checked, $other_val ); |
| 454 | 454 | } |
| 455 | - } |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | 457 | public static function get_value_from_array( $opt, $opt_key, $field ) { |
| 458 | 458 | $opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
@@ -471,18 +471,18 @@ discard block |
||
| 471 | 471 | */ |
| 472 | 472 | public static function get_term_link( $tax_id ) { |
| 473 | 473 | $tax = get_taxonomy( $tax_id ); |
| 474 | - if ( ! $tax ) { |
|
| 475 | - return ''; |
|
| 476 | - } |
|
| 474 | + if ( ! $tax ) { |
|
| 475 | + return ''; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - $link = sprintf( |
|
| 479 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 478 | + $link = sprintf( |
|
| 479 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 480 | 480 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 481 | - ); |
|
| 481 | + ); |
|
| 482 | 482 | unset( $tax ); |
| 483 | 483 | |
| 484 | - return $link; |
|
| 485 | - } |
|
| 484 | + return $link; |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | 487 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 488 | 488 | $hide_opt = self::get_value_for_comparision( $hide_opt ); |
@@ -490,9 +490,9 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | if ( is_array( $observed_value ) ) { |
| 492 | 492 | return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
| 493 | - } |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - $m = false; |
|
| 495 | + $m = false; |
|
| 496 | 496 | if ( $cond == '==' ) { |
| 497 | 497 | $m = $observed_value == $hide_opt; |
| 498 | 498 | } elseif ( $cond == '!=' ) { |
@@ -513,8 +513,8 @@ discard block |
||
| 513 | 513 | $m = ( $m === false ) ? false : true; |
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | - return $m; |
|
| 517 | - } |
|
| 516 | + return $m; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | 520 | * Trim and sanitize the values |
@@ -530,8 +530,8 @@ discard block |
||
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 533 | - $m = false; |
|
| 534 | - if ( $cond == '==' ) { |
|
| 533 | + $m = false; |
|
| 534 | + if ( $cond == '==' ) { |
|
| 535 | 535 | if ( is_array( $hide_opt ) ) { |
| 536 | 536 | $m = array_intersect( $hide_opt, $observed_value ); |
| 537 | 537 | $m = empty( $m ) ? false : true; |
@@ -555,35 +555,35 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - if ( $cond == 'not LIKE' ) { |
|
| 559 | - $m = ( $m === false ) ? true : false; |
|
| 560 | - } |
|
| 561 | - } |
|
| 558 | + if ( $cond == 'not LIKE' ) { |
|
| 559 | + $m = ( $m === false ) ? true : false; |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - return $m; |
|
| 564 | - } |
|
| 563 | + return $m; |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - /** |
|
| 567 | - * Replace a few basic shortcodes and field ids |
|
| 568 | - * @since 2.0 |
|
| 569 | - * @return string |
|
| 570 | - */ |
|
| 566 | + /** |
|
| 567 | + * Replace a few basic shortcodes and field ids |
|
| 568 | + * @since 2.0 |
|
| 569 | + * @return string |
|
| 570 | + */ |
|
| 571 | 571 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 572 | 572 | if ( strpos( $value, '[sitename]' ) !== false ) { |
| 573 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 573 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 574 | 574 | $value = str_replace( '[sitename]', $new_value, $value ); |
| 575 | - } |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | 577 | $value = apply_filters( 'frm_content', $value, $form, $entry ); |
| 578 | 578 | $value = do_shortcode( $value ); |
| 579 | 579 | |
| 580 | - return $value; |
|
| 581 | - } |
|
| 580 | + return $value; |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | public static function get_shortcodes( $content, $form_id ) { |
| 584 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 584 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 585 | 585 | return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
| 586 | - } |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | 588 | $fields = FrmField::getAll( array( |
| 589 | 589 | 'fi.form_id' => (int) $form_id, |
@@ -594,23 +594,23 @@ discard block |
||
| 594 | 594 | |
| 595 | 595 | preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
| 596 | 596 | |
| 597 | - return $matches; |
|
| 598 | - } |
|
| 597 | + return $matches; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | public static function allowed_shortcodes( $fields = array() ) { |
| 601 | 601 | $tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' ); |
| 602 | 602 | |
| 603 | - foreach ( $fields as $field ) { |
|
| 604 | - $tagregexp[] = $field->id; |
|
| 605 | - $tagregexp[] = $field->field_key; |
|
| 606 | - } |
|
| 603 | + foreach ( $fields as $field ) { |
|
| 604 | + $tagregexp[] = $field->id; |
|
| 605 | + $tagregexp[] = $field->field_key; |
|
| 606 | + } |
|
| 607 | 607 | |
| 608 | 608 | $tagregexp = implode( '|', $tagregexp ); |
| 609 | - return $tagregexp; |
|
| 610 | - } |
|
| 609 | + return $tagregexp; |
|
| 610 | + } |
|
| 611 | 611 | |
| 612 | 612 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 613 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 613 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 614 | 614 | if ( empty( $tag ) ) { |
| 615 | 615 | continue; |
| 616 | 616 | } |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | return $content; |
| 634 | - } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | /** |
| 637 | 637 | * Prevent shortcodes in fields from being processed |
@@ -740,44 +740,44 @@ discard block |
||
| 740 | 740 | return $replace_with; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - /** |
|
| 744 | - * Get the value to replace a few standard shortcodes |
|
| 745 | - * |
|
| 746 | - * @since 2.0 |
|
| 747 | - * @return string |
|
| 748 | - */ |
|
| 749 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 750 | - $new_value = ''; |
|
| 751 | - switch ( $tag ) { |
|
| 752 | - case 'admin_email': |
|
| 743 | + /** |
|
| 744 | + * Get the value to replace a few standard shortcodes |
|
| 745 | + * |
|
| 746 | + * @since 2.0 |
|
| 747 | + * @return string |
|
| 748 | + */ |
|
| 749 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 750 | + $new_value = ''; |
|
| 751 | + switch ( $tag ) { |
|
| 752 | + case 'admin_email': |
|
| 753 | 753 | $new_value = get_option( 'admin_email' ); |
| 754 | - break; |
|
| 755 | - case 'siteurl': |
|
| 756 | - $new_value = FrmAppHelper::site_url(); |
|
| 757 | - break; |
|
| 758 | - case 'frmurl': |
|
| 759 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 760 | - break; |
|
| 761 | - case 'sitename': |
|
| 762 | - $new_value = FrmAppHelper::site_name(); |
|
| 763 | - break; |
|
| 764 | - case 'get': |
|
| 765 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - return $new_value; |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * Process the [get] shortcode |
|
| 773 | - * |
|
| 774 | - * @since 2.0 |
|
| 775 | - * @return string|array |
|
| 776 | - */ |
|
| 777 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 754 | + break; |
|
| 755 | + case 'siteurl': |
|
| 756 | + $new_value = FrmAppHelper::site_url(); |
|
| 757 | + break; |
|
| 758 | + case 'frmurl': |
|
| 759 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 760 | + break; |
|
| 761 | + case 'sitename': |
|
| 762 | + $new_value = FrmAppHelper::site_name(); |
|
| 763 | + break; |
|
| 764 | + case 'get': |
|
| 765 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + return $new_value; |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * Process the [get] shortcode |
|
| 773 | + * |
|
| 774 | + * @since 2.0 |
|
| 775 | + * @return string|array |
|
| 776 | + */ |
|
| 777 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 778 | 778 | if ( ! isset( $atts['param'] ) ) { |
| 779 | - return ''; |
|
| 780 | - } |
|
| 779 | + return ''; |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | 782 | if ( strpos( $atts['param'], '[' ) ) { |
| 783 | 783 | $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
@@ -785,22 +785,22 @@ discard block |
||
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); |
| 788 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 788 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 789 | 789 | |
| 790 | - if ( $new_value == '' ) { |
|
| 790 | + if ( $new_value == '' ) { |
|
| 791 | 791 | if ( ! isset( $atts['prev_val'] ) ) { |
| 792 | - $atts['prev_val'] = ''; |
|
| 793 | - } |
|
| 792 | + $atts['prev_val'] = ''; |
|
| 793 | + } |
|
| 794 | 794 | |
| 795 | 795 | $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
| 796 | - } |
|
| 796 | + } |
|
| 797 | 797 | |
| 798 | 798 | if ( is_array( $new_value ) && ! $return_array ) { |
| 799 | 799 | $new_value = implode( ', ', $new_value ); |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - return $new_value; |
|
| 803 | - } |
|
| 802 | + return $new_value; |
|
| 803 | + } |
|
| 804 | 804 | |
| 805 | 805 | public static function get_display_value( $value, $field, $atts = array() ) { |
| 806 | 806 | |
@@ -870,27 +870,27 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 872 | 872 | |
| 873 | - $field_types = array(); |
|
| 873 | + $field_types = array(); |
|
| 874 | 874 | if ( in_array( $type, $single_input ) ) { |
| 875 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 875 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 876 | 876 | } elseif ( in_array( $type, $multiple_input ) ) { |
| 877 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 877 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 878 | 878 | } elseif ( in_array( $type, $other_type ) ) { |
| 879 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 879 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 880 | 880 | } elseif ( isset( $field_selection[ $type ] ) ) { |
| 881 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 882 | - } |
|
| 881 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 882 | + } |
|
| 883 | 883 | |
| 884 | 884 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 885 | - return $field_types; |
|
| 886 | - } |
|
| 885 | + return $field_types; |
|
| 886 | + } |
|
| 887 | 887 | |
| 888 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 889 | - foreach ( $inputs as $input ) { |
|
| 890 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 888 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 889 | + foreach ( $inputs as $input ) { |
|
| 890 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 891 | 891 | unset( $input ); |
| 892 | - } |
|
| 893 | - } |
|
| 892 | + } |
|
| 893 | + } |
|
| 894 | 894 | |
| 895 | 895 | /** |
| 896 | 896 | * Check if current field option is an "other" option |
@@ -904,14 +904,14 @@ discard block |
||
| 904 | 904 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - /** |
|
| 908 | - * Get value that belongs in "Other" text box |
|
| 909 | - * |
|
| 910 | - * @since 2.0.6 |
|
| 911 | - * |
|
| 912 | - * @param array $args |
|
| 913 | - */ |
|
| 914 | - public static function get_other_val( $args ) { |
|
| 907 | + /** |
|
| 908 | + * Get value that belongs in "Other" text box |
|
| 909 | + * |
|
| 910 | + * @since 2.0.6 |
|
| 911 | + * |
|
| 912 | + * @param array $args |
|
| 913 | + */ |
|
| 914 | + public static function get_other_val( $args ) { |
|
| 915 | 915 | $defaults = array( |
| 916 | 916 | 'opt_key' => 0, |
| 917 | 917 | 'field' => array(), |
@@ -989,20 +989,20 @@ discard block |
||
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | return $other_val; |
| 992 | - } |
|
| 993 | - |
|
| 994 | - /** |
|
| 995 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 996 | - * Intended for front-end use |
|
| 997 | - * |
|
| 998 | - * @since 2.0.6 |
|
| 999 | - * |
|
| 1000 | - * @param array $args should include field, opt_key and field name |
|
| 1001 | - * @param boolean $other_opt |
|
| 1002 | - * @param string $checked |
|
| 1003 | - * @return array $other_args |
|
| 1004 | - */ |
|
| 1005 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + /** |
|
| 995 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 996 | + * Intended for front-end use |
|
| 997 | + * |
|
| 998 | + * @since 2.0.6 |
|
| 999 | + * |
|
| 1000 | + * @param array $args should include field, opt_key and field name |
|
| 1001 | + * @param boolean $other_opt |
|
| 1002 | + * @param string $checked |
|
| 1003 | + * @return array $other_args |
|
| 1004 | + */ |
|
| 1005 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1006 | 1006 | //Check if this is an "Other" option |
| 1007 | 1007 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1008 | 1008 | return; |
@@ -1018,8 +1018,8 @@ discard block |
||
| 1018 | 1018 | $checked = 'checked="checked" '; |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | - return $other_args; |
|
| 1022 | - } |
|
| 1021 | + return $other_args; |
|
| 1022 | + } |
|
| 1023 | 1023 | |
| 1024 | 1024 | /** |
| 1025 | 1025 | * @param array $args |
@@ -1074,8 +1074,8 @@ discard block |
||
| 1074 | 1074 | * @since 2.0.6 |
| 1075 | 1075 | */ |
| 1076 | 1076 | public static function include_other_input( $args ) { |
| 1077 | - if ( ! $args['other_opt'] ) { |
|
| 1078 | - return; |
|
| 1077 | + if ( ! $args['other_opt'] ) { |
|
| 1078 | + return; |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | $classes = array( 'frm_other_input' ); |
@@ -1100,15 +1100,15 @@ discard block |
||
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | /** |
| 1103 | - * Get the HTML id for an "Other" text field |
|
| 1104 | - * Note: This does not affect fields in repeating sections |
|
| 1105 | - * |
|
| 1106 | - * @since 2.0.08 |
|
| 1107 | - * @param string $type - field type |
|
| 1108 | - * @param string $html_id |
|
| 1109 | - * @param string|boolean $opt_key |
|
| 1110 | - * @return string $other_id |
|
| 1111 | - */ |
|
| 1103 | + * Get the HTML id for an "Other" text field |
|
| 1104 | + * Note: This does not affect fields in repeating sections |
|
| 1105 | + * |
|
| 1106 | + * @since 2.0.08 |
|
| 1107 | + * @param string $type - field type |
|
| 1108 | + * @param string $html_id |
|
| 1109 | + * @param string|boolean $opt_key |
|
| 1110 | + * @return string $other_id |
|
| 1111 | + */ |
|
| 1112 | 1112 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1113 | 1113 | $other_id = $html_id; |
| 1114 | 1114 | |
@@ -1172,10 +1172,10 @@ discard block |
||
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | public static function switch_field_ids( $val ) { |
| 1175 | - global $frm_duplicate_ids; |
|
| 1176 | - $replace = array(); |
|
| 1177 | - $replace_with = array(); |
|
| 1178 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1175 | + global $frm_duplicate_ids; |
|
| 1176 | + $replace = array(); |
|
| 1177 | + $replace_with = array(); |
|
| 1178 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1179 | 1179 | $replace[] = '[if ' . $old . ']'; |
| 1180 | 1180 | $replace_with[] = '[if ' . $new . ']'; |
| 1181 | 1181 | $replace[] = '[if ' . $old . ' '; |
@@ -1191,18 +1191,18 @@ discard block |
||
| 1191 | 1191 | $replace[] = '[' . $old . ' '; |
| 1192 | 1192 | $replace_with[] = '[' . $new . ' '; |
| 1193 | 1193 | unset( $old, $new ); |
| 1194 | - } |
|
| 1194 | + } |
|
| 1195 | 1195 | if ( is_array( $val ) ) { |
| 1196 | 1196 | foreach ( $val as $k => $v ) { |
| 1197 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1197 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1198 | 1198 | unset( $k, $v ); |
| 1199 | - } |
|
| 1200 | - } else { |
|
| 1199 | + } |
|
| 1200 | + } else { |
|
| 1201 | 1201 | $val = str_replace( $replace, $replace_with, $val ); |
| 1202 | - } |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | - return $val; |
|
| 1205 | - } |
|
| 1204 | + return $val; |
|
| 1205 | + } |
|
| 1206 | 1206 | |
| 1207 | 1207 | public static function get_us_states() { |
| 1208 | 1208 | return apply_filters( 'frm_us_states', array( |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1268 | 1268 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1269 | 1269 | |
| 1270 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1270 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1271 | 1271 | $state_abv = array_keys( $states ); |
| 1272 | 1272 | sort( $state_abv ); |
| 1273 | 1273 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
@@ -1316,7 +1316,7 @@ discard block |
||
| 1316 | 1316 | ); |
| 1317 | 1317 | |
| 1318 | 1318 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1319 | - } |
|
| 1319 | + } |
|
| 1320 | 1320 | |
| 1321 | 1321 | /** |
| 1322 | 1322 | * Display a field value selector |
@@ -1326,10 +1326,10 @@ discard block |
||
| 1326 | 1326 | * @param int $selector_field_id |
| 1327 | 1327 | * @param array $selector_args |
| 1328 | 1328 | */ |
| 1329 | - public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1330 | - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1331 | - $field_value_selector->display(); |
|
| 1332 | - } |
|
| 1329 | + public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1330 | + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1331 | + $field_value_selector->display(); |
|
| 1332 | + } |
|
| 1333 | 1333 | |
| 1334 | 1334 | /** |
| 1335 | 1335 | * Convert a field object to a flat array |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
| 26 | 26 | $values['field_options']['data_type'] = $setting; |
| 27 | 27 | } else { |
| 28 | - $values['field_options'][ $setting ] = 1; |
|
| 28 | + $values['field_options'][$setting] = 1; |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | foreach ( $defaults as $opt => $default ) { |
| 130 | - $values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default; |
|
| 130 | + $values[$opt] = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default; |
|
| 131 | 131 | |
| 132 | 132 | if ( $check_post ) { |
| 133 | - self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] ); |
|
| 133 | + self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | unset( $opt, $default ); |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @param mixed $value |
| 174 | 174 | */ |
| 175 | 175 | private static function get_posted_field_setting( $setting, &$value ) { |
| 176 | - if ( isset( $_POST['field_options'][ $setting ] ) ) { |
|
| 177 | - $value = maybe_unserialize( $_POST['field_options'][ $setting ] ); |
|
| 176 | + if ( isset( $_POST['field_options'][$setting] ) ) { |
|
| 177 | + $value = maybe_unserialize( $_POST['field_options'][$setting] ); |
|
| 178 | 178 | if ( strpos( $setting, 'html' ) !== false ) { |
| 179 | 179 | // strip slashes from HTML but not regex |
| 180 | 180 | $value = stripslashes_deep( $value ); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $values['default_value'] = maybe_serialize( $field->default_value ); |
| 249 | 249 | |
| 250 | 250 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 251 | - $values[ $col ] = $field->{$col}; |
|
| 251 | + $values[$col] = $field->{$col}; |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | 288 | $msg = FrmField::get_option( $field, $error ); |
| 289 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 289 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 290 | 290 | $msg = do_shortcode( $msg ); |
| 291 | 291 | return $msg; |
| 292 | 292 | } |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | continue; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 618 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] ); |
|
| 619 | 619 | $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key ); |
| 620 | 620 | |
| 621 | 621 | $atts['entry'] = $entry; |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | |
| 625 | 625 | if ( $replace_with !== null ) { |
| 626 | 626 | self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with ); |
| 627 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 627 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | unset( $atts, $replace_with ); |
@@ -666,8 +666,8 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | $dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' ); |
| 668 | 668 | |
| 669 | - if ( isset( $shortcode_values[ $atts['tag'] ] ) ) { |
|
| 670 | - $replace_with = $shortcode_values[ $atts['tag'] ]; |
|
| 669 | + if ( isset( $shortcode_values[$atts['tag']] ) ) { |
|
| 670 | + $replace_with = $shortcode_values[$atts['tag']]; |
|
| 671 | 671 | } elseif ( in_array( $atts['tag'], $dynamic_default ) ) { |
| 672 | 672 | $replace_with = self::dynamic_default_values( $atts['tag'], $atts ); |
| 673 | 673 | } elseif ( $clean_tag == 'user_agent' ) { |
@@ -877,8 +877,8 @@ discard block |
||
| 877 | 877 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 878 | 878 | } elseif ( in_array( $type, $other_type ) ) { |
| 879 | 879 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
| 880 | - } elseif ( isset( $field_selection[ $type ] ) ) { |
|
| 881 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 880 | + } elseif ( isset( $field_selection[$type] ) ) { |
|
| 881 | + $field_types[$type] = $field_selection[$type]; |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | |
| 888 | 888 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
| 889 | 889 | foreach ( $inputs as $input ) { |
| 890 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 890 | + $field_types[$input] = $fields[$input]; |
|
| 891 | 891 | unset( $input ); |
| 892 | 892 | } |
| 893 | 893 | } |
@@ -935,21 +935,21 @@ discard block |
||
| 935 | 935 | // Check posted vals before checking saved values |
| 936 | 936 | |
| 937 | 937 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 938 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
| 938 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
| 939 | 939 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 940 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 940 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
| 941 | 941 | } else { |
| 942 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
| 942 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
| 943 | 943 | } |
| 944 | 944 | return $other_val; |
| 945 | 945 | |
| 946 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
| 946 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
| 947 | 947 | // For normal fields |
| 948 | 948 | |
| 949 | 949 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 950 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 950 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
| 951 | 951 | } else { |
| 952 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
| 952 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
| 953 | 953 | } |
| 954 | 954 | return $other_val; |
| 955 | 955 | } |
@@ -958,8 +958,8 @@ discard block |
||
| 958 | 958 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
| 959 | 959 | // Check if there is an "other" val in saved value and make sure the |
| 960 | 960 | // "other" val is not equal to the Other checkbox option |
| 961 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 962 | - $other_val = $field['value'][ $opt_key ]; |
|
| 961 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 962 | + $other_val = $field['value'][$opt_key]; |
|
| 963 | 963 | } |
| 964 | 964 | } else { |
| 965 | 965 | /** |
@@ -971,8 +971,8 @@ discard block |
||
| 971 | 971 | // Multi-select dropdowns - key is not preserved |
| 972 | 972 | if ( is_array( $field['value'] ) ) { |
| 973 | 973 | $o_key = array_search( $temp_val, $field['value'] ); |
| 974 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 975 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 974 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 975 | + unset( $field['value'][$o_key], $o_key ); |
|
| 976 | 976 | } |
| 977 | 977 | } else if ( $temp_val == $field['value'] ) { |
| 978 | 978 | // For radio and regular dropdowns |
@@ -1194,7 +1194,7 @@ discard block |
||
| 1194 | 1194 | } |
| 1195 | 1195 | if ( is_array( $val ) ) { |
| 1196 | 1196 | foreach ( $val as $k => $v ) { |
| 1197 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1197 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1198 | 1198 | unset( $k, $v ); |
| 1199 | 1199 | } |
| 1200 | 1200 | } else { |
@@ -1265,19 +1265,19 @@ discard block |
||
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1268 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
| 1268 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
| 1269 | 1269 | |
| 1270 | 1270 | $states = FrmFieldsHelper::get_us_states(); |
| 1271 | 1271 | $state_abv = array_keys( $states ); |
| 1272 | 1272 | sort( $state_abv ); |
| 1273 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 1273 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 1274 | 1274 | |
| 1275 | 1275 | $states = array_values( $states ); |
| 1276 | 1276 | sort( $states ); |
| 1277 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 1277 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 1278 | 1278 | unset( $state_abv, $states ); |
| 1279 | 1279 | |
| 1280 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
| 1280 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
| 1281 | 1281 | __( 'Under 18', 'formidable' ), |
| 1282 | 1282 | __( '18-24', 'formidable' ), |
| 1283 | 1283 | __( '25-34', 'formidable' ), |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | __( 'Prefer Not to Answer', 'formidable' ), |
| 1289 | 1289 | ); |
| 1290 | 1290 | |
| 1291 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
| 1291 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
| 1292 | 1292 | __( 'Very Satisfied', 'formidable' ), |
| 1293 | 1293 | __( 'Satisfied', 'formidable' ), |
| 1294 | 1294 | __( 'Neutral', 'formidable' ), |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | __( 'N/A', 'formidable' ), |
| 1298 | 1298 | ); |
| 1299 | 1299 | |
| 1300 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
| 1300 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
| 1301 | 1301 | __( 'Very Important', 'formidable' ), |
| 1302 | 1302 | __( 'Important', 'formidable' ), |
| 1303 | 1303 | __( 'Neutral', 'formidable' ), |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | __( 'N/A', 'formidable' ), |
| 1307 | 1307 | ); |
| 1308 | 1308 | |
| 1309 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
| 1309 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
| 1310 | 1310 | __( 'Strongly Agree', 'formidable' ), |
| 1311 | 1311 | __( 'Agree', 'formidable' ), |
| 1312 | 1312 | __( 'Neutral', 'formidable' ), |