| @@ -17,22 +17,22 @@ | ||
| 17 | 17 | $new_values = array( |
| 18 | 18 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 19 | 19 | 'name' => $values['name'], |
| 20 | 20 | 'description' => $values['description'], |
| 21 | - 'status' => $values['status'] ?? 'published', | |
| 22 | - 'logged_in' => $values['logged_in'] ?? 0, | |
| 21 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'published', | |
| 22 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, | |
| 23 | 23 | 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
| 24 | 24 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 25 | 25 | 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
| 26 | - 'created_at' => $values['created_at'] ?? current_time( 'mysql', 1 ), | |
| 26 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), | |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 30 | 30 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 31 | 31 | |
| 32 | - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' ); | |
| 33 | - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' ); | |
| 34 | - $options['submit_html'] = $values['options']['submit_html'] ?? FrmFormsHelper::get_default_html( 'submit' ); | |
| 32 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); | |
| 33 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); | |
| 34 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); | |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Allows modifying form options before updating or creating. |
| 38 | 38 | * |
| @@ -279,11 +279,11 @@ | ||
| 279 | 279 | |
| 280 | 280 | $options = ! empty( $values['options'] ) ? (array) $values['options'] : array(); |
| 281 | 281 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 282 | 282 | |
| 283 | - $options['custom_style'] = $values['options']['custom_style'] ?? 0; | |
| 284 | - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' ); | |
| 285 | - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' ); | |
| 283 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; | |
| 284 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); | |
| 285 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); | |
| 286 | 286 | $options['submit_html'] = isset( $values['options']['submit_html'] ) && '' !== $values['options']['submit_html'] ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Allows modifying form options before updating or creating. |
| @@ -354,14 +354,10 @@ | ||
| 354 | 354 | // Don't check for POST html. |
| 355 | 355 | unset( $update_options['custom_html'] ); |
| 356 | 356 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 357 | 357 | |
| 358 | - if ( ! is_array( $field->field_options ) ) { | |
| 359 | - $field->field_options = array(); | |
| 360 | - } | |
| 361 | - | |
| 362 | 358 | foreach ( $update_options as $opt => $default ) { |
| 363 | - $field->field_options[ $opt ] = $values['field_options'][ $opt . '_' . $field_id ] ?? $default; | |
| 359 | + $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default; | |
| 364 | 360 | self::sanitize_field_opt( $opt, $field->field_options[ $opt ] ); |
| 365 | 361 | } |
| 366 | 362 | |
| 367 | 363 | $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
| @@ -477,16 +473,14 @@ | ||
| 477 | 473 | * @return string |
| 478 | 474 | */ |
| 479 | 475 | private static function normalize_calc_spaces( $calc ) { |
| 480 | 476 | // Check for a pattern with 5 parts |
| 481 | - // $1 \d|\] the first comparison digit or the end of a comparison shortcode. | |
| 477 | + // $1 \d the first comparison digit. | |
| 482 | 478 | // $2 a space (optional). |
| 483 | 479 | // $3 an equals sign (optional) that follows the < operator for <= comparisons. |
| 484 | 480 | // $4 another space (optional). |
| 485 | - // $5 \d|\[ the second comparison digit or the start of a comparison shortcode. | |
| 486 | - $calc = preg_replace( '/(\d|\])( ){0,1}<(=){0,1}( ){0,1}(\d|\[)/', '$1 <$3 $5', $calc ); | |
| 487 | - | |
| 488 | - return $calc; | |
| 481 | + // $5 \d the second comparison digit. | |
| 482 | + return preg_replace( '/(\d)( ){0,1}<(=){0,1}( ){0,1}(\d)/', '$1 <$3 $5', $calc ); | |
| 489 | 483 | } |
| 490 | 484 | |
| 491 | 485 | /** |
| 492 | 486 | * Updating the settings page |
| @@ -493,11 +487,11 @@ | ||
| 493 | 487 | */ |
| 494 | 488 | private static function get_settings_page_html( $values, &$field ) { |
| 495 | 489 | if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) { |
| 496 | 490 | $prev_opts = array(); |
| 497 | - $fallback_html = $field->field_options['custom_html'] ?? FrmFieldsHelper::get_default_html( $field->type ); | |
| 491 | + $fallback_html = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ); | |
| 498 | 492 | |
| 499 | - $field->field_options['custom_html'] = $values['field_options'][ 'custom_html_' . $field->id ] ?? $fallback_html; | |
| 493 | + $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ? $values['field_options'][ 'custom_html_' . $field->id ] : $fallback_html; | |
| 500 | 494 | } elseif ( $field->type === 'hidden' || $field->type === 'user_id' ) { |
| 501 | 495 | $prev_opts = $field->field_options; |
| 502 | 496 | } |
| 503 | 497 | |
| @@ -519,14 +513,11 @@ | ||
| 519 | 513 | 'options' => '', |
| 520 | 514 | 'name' => '', |
| 521 | 515 | ); |
| 522 | 516 | foreach ( $field_cols as $col => $default ) { |
| 523 | - $default = $default === '' ? $field->{$col} : $default; | |
| 524 | - $new_field[ $col ] = $values['field_options'][ $col . '_' . $field->id ] ?? $default; | |
| 525 | - } | |
| 517 | + $default = $default === '' ? $field->{$col} : $default; | |
| 526 | 518 | |
| 527 | - if ( $field->type === 'submit' && isset( $new_field['field_order'] ) && (int) $new_field['field_order'] === FrmSubmitHelper::DEFAULT_ORDER ) { | |
| 528 | - $new_field['field_order'] = $field->field_order; | |
| 519 | + $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default; | |
| 529 | 520 | } |
| 530 | 521 | |
| 531 | 522 | // Don't save the template option. |
| 532 | 523 | if ( is_array( $new_field['options'] ) && isset( $new_field['options']['000'] ) ) { |
| @@ -609,12 +600,8 @@ | ||
| 609 | 600 | if ( ! $form ) { |
| 610 | 601 | return false; |
| 611 | 602 | } |
| 612 | 603 | |
| 613 | - if ( $form->status === 'trash' ) { | |
| 614 | - return false; | |
| 615 | - } | |
| 616 | - | |
| 617 | 604 | $options = $form->options; |
| 618 | 605 | $options['trash_time'] = time(); |
| 619 | 606 | |
| 620 | 607 | global $wpdb; |
| @@ -854,9 +841,9 @@ | ||
| 854 | 841 | * @return array|object of objects |
| 855 | 842 | */ |
| 856 | 843 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
| 857 | 844 | if ( is_array( $where ) && ! empty( $where ) ) { |
| 858 | - if ( ! empty( $where['is_template'] ) && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) { | |
| 845 | + if ( isset( $where['is_template'] ) && $where['is_template'] && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) { | |
| 859 | 846 | // don't get trashed templates |
| 860 | 847 | $where['status'] = array( null, '', 'published' ); |
| 861 | 848 | } |
| 862 | 849 | |
| @@ -1096,9 +1083,9 @@ | ||
| 1096 | 1083 | |
| 1097 | 1084 | public static function maybe_get_current_form( $form_id = 0 ) { |
| 1098 | 1085 | global $frm_vars; |
| 1099 | 1086 | |
| 1100 | - if ( ! empty( $frm_vars['current_form'] ) && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) { | |
| 1087 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) { | |
| 1101 | 1088 | return $frm_vars['current_form']; |
| 1102 | 1089 | } |
| 1103 | 1090 | |
| 1104 | 1091 | $form_id = FrmAppHelper::get_param( 'form', $form_id, 'get', 'absint' ); |
| @@ -1145,9 +1132,9 @@ | ||
| 1145 | 1132 | $global_load = true; |
| 1146 | 1133 | $frm_vars['load_css'] = true; |
| 1147 | 1134 | } |
| 1148 | 1135 | |
| 1149 | - return empty( $frm_vars['css_loaded'] ) && $global_load; | |
| 1136 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); | |
| 1150 | 1137 | } |
| 1151 | 1138 | |
| 1152 | 1139 | /** |
| 1153 | 1140 | * @since 4.06.03 |
| @@ -1162,16 +1149,8 @@ | ||
| 1162 | 1149 | } else { |
| 1163 | 1150 | $visible = true; |
| 1164 | 1151 | } |
| 1165 | 1152 | |
| 1166 | - /** | |
| 1167 | - * @since 6.25 | |
| 1168 | - * | |
| 1169 | - * @param bool $visible | |
| 1170 | - * @param object $form | |
| 1171 | - */ | |
| 1172 | - $visible = (bool) apply_filters( 'frm_form_is_visible', $visible, $form ); | |
| 1173 | - | |
| 1174 | 1153 | return $visible; |
| 1175 | 1154 | } |
| 1176 | 1155 | |
| 1177 | 1156 | public static function show_submit( $form ) { |
| @@ -1185,11 +1164,11 @@ | ||
| 1185 | 1164 | * @since 2.3 |
| 1186 | 1165 | */ |
| 1187 | 1166 | public static function get_option( $atts ) { |
| 1188 | 1167 | $form = $atts['form']; |
| 1189 | - $default = $atts['default'] ?? ''; | |
| 1168 | + $default = isset( $atts['default'] ) ? $atts['default'] : ''; | |
| 1190 | 1169 | |
| 1191 | - return $form->options[ $atts['option'] ] ?? $default; | |
| 1170 | + return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $default; | |
| 1192 | 1171 | } |
| 1193 | 1172 | |
| 1194 | 1173 | /** |
| 1195 | 1174 | * Get the link to edit this form. |