Repository navigation
Add generic entry storage and field protection APIs #3665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
325c715
6b901b5
c5da052
f207a0d
f3d5263
fad0eaa
fe661c9
2f43596
d69c425
26f4b3b
9248ea7
28d20a7
8516239
1c63d70
9e7aaa0
6fe9533
f0bbee0
2808593
06c1c13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -287,9 +287,12 @@ public static function update_settings() { | |
|
|
||
| // Handle captcha field inclusion | ||
| $include_captcha = isset( $_POST['frm_include_captcha'] ) && '1' === $_POST['frm_include_captcha']; // phpcs:ignore WordPress.Security.NonceVerification.Missing | ||
| self::handle_captcha_field( $id, $include_captcha ); | ||
| $captcha_updated = self::handle_captcha_field( $id, $include_captcha ); | ||
| $gdpr_updated = self::maybe_handle_gdpr_field( $id ); | ||
|
|
||
| self::maybe_handle_gdpr_field( $id ); | ||
| if ( ! $captcha_updated || ! $gdpr_updated ) { | ||
| $warnings[] = __( 'Some fields could not be added or deleted.', 'formidable' ); | ||
| } | ||
|
|
||
| $message = __( 'Settings Successfully Updated', 'formidable' ); | ||
|
|
||
|
|
@@ -314,10 +317,10 @@ private static function antispam_was_on( $form_id ) { | |
| * @param int $form_id Form ID. | ||
| * @param bool $include_captcha Whether to include captcha field. | ||
| * | ||
| * @return void | ||
| * @return bool | ||
| */ | ||
| private static function handle_captcha_field( $form_id, $include_captcha ) { | ||
| self::toggle_field_in_form( $form_id, 'captcha', $include_captcha, __( 'Captcha', 'formidable' ) ); | ||
| return self::toggle_field_in_form( $form_id, 'captcha', $include_captcha, __( 'Captcha', 'formidable' ) ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -328,16 +331,16 @@ private static function handle_captcha_field( $form_id, $include_captcha ) { | |
| * | ||
| * @param int $form_id Form ID. | ||
| * | ||
| * @return void | ||
| * @return bool | ||
| */ | ||
| private static function maybe_handle_gdpr_field( $form_id ) { | ||
| // phpcs:ignore WordPress.Security.NonceVerification.Missing | ||
| if ( ! isset( $_POST['frm_include_gdpr'] ) || FrmFieldGdprHelper::hide_gdpr_field() ) { | ||
| return; | ||
| return true; | ||
| } | ||
|
|
||
| $include_gdpr = '1' === $_POST['frm_include_gdpr']; // phpcs:ignore WordPress.Security.NonceVerification.Missing | ||
| self::toggle_field_in_form( $form_id, FrmFieldGdprHelper::FIELD_TYPE, $include_gdpr, __( 'GDPR', 'formidable' ) ); | ||
| return self::toggle_field_in_form( $form_id, FrmFieldGdprHelper::FIELD_TYPE, $include_gdpr, __( 'GDPR', 'formidable' ) ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -350,7 +353,7 @@ private static function maybe_handle_gdpr_field( $form_id ) { | |
| * @param bool $include Whether the form should include the field. | ||
| * @param string $field_name The name to give a newly created field. | ||
| * | ||
| * @return void | ||
| * @return bool | ||
| */ | ||
| private static function toggle_field_in_form( $form_id, $field_type, $include, $field_name ) { | ||
| $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude' ); | ||
|
|
@@ -376,10 +379,14 @@ private static function toggle_field_in_form( $form_id, $field_type, $include, $ | |
| $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); | ||
| $field_values['name'] = $field_name; | ||
| $field_values['field_order'] = $submit_field_order > 0 ? $submit_field_order - 1 : $last_field_order + 1; | ||
| FrmField::create( $field_values ); | ||
| } elseif ( ! $include && $existing_field_id ) { | ||
| FrmField::destroy( $existing_field_id ); | ||
| return false !== FrmField::create( $field_values ); | ||
| } | ||
|
|
||
| if ( ! $include && $existing_field_id ) { | ||
| return false !== FrmField::destroy( $existing_field_id ); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -2736,16 +2743,21 @@ public static function show_form( $id = '', $key = '', $title = false, $descript | |
| $form = do_shortcode( $frm_settings->login_msg ); | ||
| } else { | ||
| do_action( 'frm_pre_get_form', $form ); | ||
| $form = self::get_form( $form, $title, $description, $atts ); | ||
| $form_object = $form; | ||
| $form = self::get_form( $form, $title, $description, $atts ); | ||
|
|
||
| /** | ||
| * Use this shortcode to check for external shortcodes that may span | ||
| * across multiple fields in the customizable HTML | ||
| * | ||
| * @since 2.0.8 | ||
| * @since x.x The form object is passed as the second argument. | ||
| * | ||
| * @param string $form Rendered form HTML. | ||
| * @param object $form_object Form being rendered. | ||
| */ | ||
| $form = apply_filters( 'frm_filter_final_form', $form ); | ||
| } | ||
| $form = apply_filters( 'frm_filter_final_form', $form, $form_object ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }//end if | ||
|
|
||
| return $form; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function call is not valid, which will result in a fatal runtime error.