| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | class FrmForm { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * @param array $values |
| 10 | - * @return int|bool id on success or false on failure. | |
| 10 | + * @return int|boolean id on success or false on failure | |
| 11 | 11 | */ |
| 12 | 12 | public static function create( $values ) { |
| 13 | 13 | global $wpdb; |
| 14 | 14 | |
| @@ -284,8 +284,13 @@ | ||
| 284 | 284 | $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
| 285 | 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 | + if ( ! empty( $options['success_url'] ) && ! empty( $args['form_id'] ) ) { | |
| 289 | + $options['success_url'] = FrmFormsHelper::maybe_add_sanitize_url_attr( $options['success_url'], (int) $args['form_id'] ); | |
| 290 | + $values['options']['success_url'] = $options['success_url']; | |
| 291 | + } | |
| 292 | + | |
| 288 | 293 | /** |
| 289 | 294 | * Allows modifying form options before updating or creating. |
| 290 | 295 | * |
| 291 | 296 | * @since 5.4 Added the third param. |
| @@ -365,18 +370,8 @@ | ||
| 365 | 370 | 'field_options' => $field->field_options, |
| 366 | 371 | 'default_value' => isset( $values[ 'default_value_' . $field_id ] ) ? FrmAppHelper::maybe_json_encode( $values[ 'default_value_' . $field_id ] ) : '', |
| 367 | 372 | ); |
| 368 | 373 | |
| 369 | - if ( ! FrmAppHelper::allow_unfiltered_html() && isset( $values['field_options'][ 'options_' . $field_id ] ) && is_array( $values['field_options'][ 'options_' . $field_id ] ) ) { | |
| 370 | - foreach ( $values['field_options'][ 'options_' . $field_id ] as $option_key => $option ) { | |
| 371 | - if ( is_array( $option ) ) { | |
| 372 | - foreach ( $option as $key => $item ) { | |
| 373 | - $values['field_options'][ 'options_' . $field_id ][ $option_key ][ $key ] = FrmAppHelper::kses( $item, 'all' ); | |
| 374 | - } | |
| 375 | - } | |
| 376 | - } | |
| 377 | - } | |
| 378 | - | |
| 379 | 374 | self::prepare_field_update_values( $field, $values, $new_field ); |
| 380 | 375 | |
| 381 | 376 | FrmField::update( $field_id, $new_field ); |
| 382 | 377 | |
| @@ -386,40 +381,17 @@ | ||
| 386 | 381 | |
| 387 | 382 | return $values; |
| 388 | 383 | } |
| 389 | 384 | |
| 390 | - /** | |
| 391 | - * @param string $opt | |
| 392 | - * @param mixed $value | |
| 393 | - * @return void | |
| 394 | - */ | |
| 395 | 385 | private static function sanitize_field_opt( $opt, &$value ) { |
| 396 | - if ( ! is_string( $value ) ) { | |
| 397 | - return; | |
| 386 | + if ( is_string( $value ) ) { | |
| 387 | + if ( $opt === 'calc' ) { | |
| 388 | + $value = self::sanitize_calc( $value ); | |
| 389 | + } else { | |
| 390 | + $value = FrmAppHelper::kses( $value, 'all' ); | |
| 391 | + } | |
| 392 | + $value = trim( $value ); | |
| 398 | 393 | } |
| 399 | - | |
| 400 | - /** | |
| 401 | - * Allow the option to turn off sanitization for a field. This way a custom rule can be used instead. | |
| 402 | - * Make sure to add custom sanitization using the frm_update_field_options filter as the data will no longer be sanitized. | |
| 403 | - * | |
| 404 | - * @since 6.0 | |
| 405 | - * | |
| 406 | - * @param bool $should_sanitize | |
| 407 | - * @param string $opt | |
| 408 | - */ | |
| 409 | - $should_sanitize = apply_filters( 'frm_should_sanitize_field_opt_string', true, $opt ); | |
| 410 | - | |
| 411 | - if ( ! $should_sanitize ) { | |
| 412 | - return; | |
| 413 | - } | |
| 414 | - | |
| 415 | - if ( $opt === 'calc' ) { | |
| 416 | - $value = self::sanitize_calc( $value ); | |
| 417 | - } else { | |
| 418 | - $value = FrmAppHelper::kses( $value, 'all' ); | |
| 419 | - } | |
| 420 | - | |
| 421 | - $value = trim( $value ); | |
| 422 | 394 | } |
| 423 | 395 | |
| 424 | 396 | /** |
| 425 | 397 | * @param string $value |
| @@ -510,12 +482,8 @@ | ||
| 510 | 482 | 'description', |
| 511 | 483 | 'submit_value', |
| 512 | 484 | 'submit_msg', |
| 513 | 485 | 'success_msg', |
| 514 | - 'invalid_msg', | |
| 515 | - 'failed_msg', | |
| 516 | - 'login_msg', | |
| 517 | - 'admin_permission', | |
| 518 | 486 | ); |
| 519 | 487 | |
| 520 | 488 | return apply_filters( 'frm_form_strings', $strings, $form ); |
| 521 | 489 | } |
| @@ -754,9 +722,9 @@ | ||
| 754 | 722 | if ( isset( $cache->options ) ) { |
| 755 | 723 | FrmAppHelper::unserialize_or_decode( $cache->options ); |
| 756 | 724 | } |
| 757 | 725 | |
| 758 | - return apply_filters( 'frm_form_object', wp_unslash( $cache ) ); | |
| 726 | + return wp_unslash( $cache ); | |
| 759 | 727 | } |
| 760 | 728 | } |
| 761 | 729 | |
| 762 | 730 | if ( is_numeric( $id ) ) { |
| @@ -812,13 +780,9 @@ | ||
| 812 | 780 | /** |
| 813 | 781 | * Get all published forms |
| 814 | 782 | * |
| 815 | 783 | * @since 2.0 |
| 816 | - * | |
| 817 | - * @param array $query | |
| 818 | - * @param int $limit | |
| 819 | - * @param string $inc_children | |
| 820 | - * @return array|object of forms A single form object would be passed if $limit was set to 1. | |
| 784 | + * @return array of forms | |
| 821 | 785 | */ |
| 822 | 786 | public static function get_published_forms( $query = array(), $limit = 999, $inc_children = 'exclude' ) { |
| 823 | 787 | $query['is_template'] = 0; |
| 824 | 788 | $query['status'] = array( null, '', 'published' ); |
| @@ -1118,39 +1082,23 @@ | ||
| 1118 | 1082 | return admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ); |
| 1119 | 1083 | } |
| 1120 | 1084 | |
| 1121 | 1085 | /** |
| 1122 | - * Check if the "Submit this form with AJAX" setting is toggled on. | |
| 1123 | - * | |
| 1124 | - * @since 6.2 | |
| 1125 | - * | |
| 1126 | - * @param stdClass $form | |
| 1127 | - * @return bool | |
| 1128 | - */ | |
| 1129 | - public static function is_ajax_on( $form ) { | |
| 1130 | - return ! empty( $form->options['ajax_submit'] ); | |
| 1131 | - } | |
| 1132 | - | |
| 1133 | - /** | |
| 1134 | - * @deprecated 2.03.05 This is still referenced in a few add ons (API, locations). | |
| 1086 | + * @deprecated 3.0 | |
| 1135 | 1087 | * @codeCoverageIgnore |
| 1136 | 1088 | * |
| 1137 | 1089 | * @param string $key |
| 1090 | + * | |
| 1138 | 1091 | * @return int form id |
| 1139 | 1092 | */ |
| 1140 | 1093 | public static function getIdByKey( $key ) { |
| 1141 | - _deprecated_function( __FUNCTION__, '2.03.05', 'FrmForm::get_id_by_key' ); | |
| 1142 | - return self::get_id_by_key( $key ); | |
| 1094 | + return FrmFormDeprecated::getIdByKey( $key ); | |
| 1143 | 1095 | } |
| 1144 | 1096 | |
| 1145 | 1097 | /** |
| 1146 | - * @deprecated 2.03.05 This is still referenced in the API add on as of v1.13. | |
| 1098 | + * @deprecated 3.0 | |
| 1147 | 1099 | * @codeCoverageIgnore |
| 1148 | - * | |
| 1149 | - * @param string|int $id | |
| 1150 | - * @return string | |
| 1151 | 1100 | */ |
| 1152 | 1101 | public static function getKeyById( $id ) { |
| 1153 | - _deprecated_function( __FUNCTION__, '2.03.05', 'FrmForm::get_key_by_id' ); | |
| 1154 | - return self::get_key_by_id( $id ); | |
| 1102 | + return FrmFormDeprecated::getKeyById( $id ); | |
| 1155 | 1103 | } |
| 1156 | 1104 | } |