diff --git a/classes/controllers/FrmAddonsController.php b/classes/controllers/FrmAddonsController.php
index a42c7b29c4..2fdaff2c48 100644
--- a/classes/controllers/FrmAddonsController.php
+++ b/classes/controllers/FrmAddonsController.php
@@ -34,12 +34,14 @@ public static function load_admin_hooks() {
add_action( 'admin_menu', self::class . '::menu', 100 );
add_filter( 'pre_set_site_transient_update_plugins', self::class . '::check_update' );
- if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) {
- self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/';
-
- add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
- add_filter( 'frm_show_footer_links', '__return_false' );
+ if ( ! FrmAppHelper::is_admin_page( 'formidable-addons' ) ) {
+ return;
}
+
+ self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/';
+
+ add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
+ add_filter( 'frm_show_footer_links', '__return_false' );
}
/**
@@ -660,18 +662,20 @@ protected static function fill_update_addon_info( $installed_addons ) {
$download_id = $plugin['id'] ?? 0;
- if ( $download_id && ! isset( $version_info[ $download_id ]['package'] ) ) {
- // If this addon is using its own license, get the update url
- $addon_info = $api->get_api_info();
+ if ( ! $download_id || isset( $version_info[ $download_id ]['package'] ) ) {
+ continue;
+ }
- $version_info[ $download_id ] = $addon_info[ $download_id ];
+ // If this addon is using its own license, get the update url
+ $addon_info = $api->get_api_info();
- if ( isset( $addon_info['error'] ) ) {
- $version_info[ $download_id ]['error'] = array(
- 'message' => $addon_info['error']['message'],
- 'code' => $addon_info['error']['code'],
- );
- }
+ $version_info[ $download_id ] = $addon_info[ $download_id ];
+
+ if ( isset( $addon_info['error'] ) ) {
+ $version_info[ $download_id ]['error'] = array(
+ 'message' => $addon_info['error']['message'],
+ 'code' => $addon_info['error']['code'],
+ );
}
}//end foreach
@@ -1277,10 +1281,12 @@ private static function get_activating_page() {
protected static function install_addon_permissions() {
check_ajax_referer( 'frm_ajax', 'nonce' );
- if ( ! current_user_can( 'activate_plugins' ) || ! self::get_current_plugin() ) {
- echo json_encode( true );
- wp_die();
+ if ( current_user_can( 'activate_plugins' ) && self::get_current_plugin() ) {
+ return;
}
+
+ echo json_encode( true );
+ wp_die();
}
/**
diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php
index 3b45ccd633..614959b02d 100644
--- a/classes/controllers/FrmAppController.php
+++ b/classes/controllers/FrmAppController.php
@@ -642,22 +642,24 @@ public static function admin_init() {
self::trigger_page_load_hooks();
- if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
- // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
- // This provides backward compatibility for old addons that use legacy modal templates.
- $action = FrmAppHelper::get_param( 'frm_action' );
- $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
-
- if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
- $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
- $url_param = $application_id ? '&applicationId=' . $application_id : '';
-
- wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
- exit;
- }
+ if ( ! FrmAppHelper::is_admin_page( 'formidable' ) ) {
+ return;
+ }
+
+ // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
+ // This provides backward compatibility for old addons that use legacy modal templates.
+ $action = FrmAppHelper::get_param( 'frm_action' );
+ $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
+
+ if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
+ $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
+ $url_param = $application_id ? '&applicationId=' . $application_id : '';
- FrmInbox::maybe_disable_screen_options();
+ wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
+ exit;
}
+
+ FrmInbox::maybe_disable_screen_options();
}
/**
@@ -996,10 +998,12 @@ private static function maybe_deregister_popper1() {
$popper = $wp_scripts->registered['popper'];
- if ( version_compare( $popper->ver, '2.0', '<' ) ) {
- wp_deregister_script( 'popper' );
- self::register_popper2();
+ if ( ! version_compare( $popper->ver, '2.0', '<' ) ) {
+ return;
}
+
+ wp_deregister_script( 'popper' );
+ self::register_popper2();
}
/**
@@ -1548,19 +1552,21 @@ private static function remember_custom_sort() {
$current_sort = $current_sort[ $form_id ];
}
- if ( $new_sort !== $current_sort ) {
- $new_meta = $new_sort;
+ if ( $new_sort === $current_sort ) {
+ return;
+ }
- if ( $is_entry_list && $form_id && is_int( $form_id ) ) {
- // Index meta by form ID.
- $temp_meta = is_array( $previous_meta ) ? $previous_meta : array();
- $temp_meta[ $form_id ] = $new_meta;
- $new_meta = $temp_meta;
- unset( $temp_meta );
- }
+ $new_meta = $new_sort;
- update_user_meta( $user_id, $meta_key, $new_meta );
+ if ( $is_entry_list && $form_id && is_int( $form_id ) ) {
+ // Index meta by form ID.
+ $temp_meta = is_array( $previous_meta ) ? $previous_meta : array();
+ $temp_meta[ $form_id ] = $new_meta;
+ $new_meta = $temp_meta;
+ unset( $temp_meta );
}
+
+ update_user_meta( $user_id, $meta_key, $new_meta );
}
/**
@@ -1588,12 +1594,14 @@ public static function apply_saved_sort_preference( &$orderby, &$order ) {
$preferred_list_sort = $preferred_list_sort[ $form_id ];
}
- if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) {
- $orderby = $preferred_list_sort['orderby'];
+ if ( ! is_array( $preferred_list_sort ) || empty( $preferred_list_sort['orderby'] ) ) {
+ return;
+ }
- if ( ! empty( $preferred_list_sort['order'] ) ) {
- $order = $preferred_list_sort['order'];
- }
+ $orderby = $preferred_list_sort['orderby'];
+
+ if ( ! empty( $preferred_list_sort['order'] ) ) {
+ $order = $preferred_list_sort['order'];
}
}
diff --git a/classes/controllers/FrmDashboardController.php b/classes/controllers/FrmDashboardController.php
index 7d251657ad..95c0e5aa05 100644
--- a/classes/controllers/FrmDashboardController.php
+++ b/classes/controllers/FrmDashboardController.php
@@ -489,10 +489,12 @@ private static function get_youtube_embed_video( $entries_count ) {
private static function save_subscribed_email( $email ) {
$subscribed_emails = self::get_subscribed_emails();
- if ( ! in_array( $email, $subscribed_emails, true ) ) {
- $subscribed_emails[] = $email;
- self::update_dashboard_options( $subscribed_emails, 'inbox-subscribed-emails' );
+ if ( in_array( $email, $subscribed_emails, true ) ) {
+ return;
}
+
+ $subscribed_emails[] = $email;
+ self::update_dashboard_options( $subscribed_emails, 'inbox-subscribed-emails' );
}
/**
@@ -553,9 +555,11 @@ private static function add_welcome_closed_banner_user_id() {
$users_list = self::get_closed_welcome_banner_user_ids();
$user_id = get_current_user_id();
- if ( ! in_array( $user_id, $users_list, true ) ) {
- $users_list[] = $user_id;
- self::update_dashboard_options( $users_list, 'closed-welcome-banner-user-ids' );
+ if ( in_array( $user_id, $users_list, true ) ) {
+ return;
}
+
+ $users_list[] = $user_id;
+ self::update_dashboard_options( $users_list, 'closed-welcome-banner-user-ids' );
}
}
diff --git a/classes/controllers/FrmEntriesController.php b/classes/controllers/FrmEntriesController.php
index 6796e47d7b..40ebf4d8a7 100644
--- a/classes/controllers/FrmEntriesController.php
+++ b/classes/controllers/FrmEntriesController.php
@@ -410,10 +410,12 @@ public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $met
unset( $form_prefix );
}
- if ( $save ) {
- $user_id = get_current_user_id();
- update_user_option( $user_id, $this_page_name, $meta_value, true );
+ if ( ! $save ) {
+ return;
}
+
+ $user_id = get_current_user_id();
+ update_user_option( $user_id, $this_page_name, $meta_value, true );
}
/**
@@ -790,26 +792,28 @@ public static function process_entry( $errors = '', $ajax = false ) {
$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
- if ( ! $errors ) {
- $_POST['frm_skip_cookie'] = 1;
- $do_success = false;
+ if ( $errors ) {
+ return;
+ }
- if ( $params['action'] === 'create' ) {
- if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
- $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $_POST['frm_skip_cookie'] = 1;
+ $do_success = false;
- $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
- $do_success = true;
- }
+ if ( $params['action'] === 'create' ) {
+ if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
+ $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
+
+ $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
+ $do_success = true;
}
+ }
- do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
+ do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
- if ( $do_success ) {
- FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
- }
- unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ if ( $do_success ) {
+ FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
}
+ unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
}
/**
@@ -865,10 +869,12 @@ private static function _delete_entry( $entry_id, $form ) {
FrmAppHelper::unserialize_or_decode( $form->options );
- if ( ! empty( $form->options['no_save'] ) ) {
- self::unlink_post( $entry_id );
- FrmEntry::destroy( $entry_id );
+ if ( empty( $form->options['no_save'] ) ) {
+ return;
}
+
+ self::unlink_post( $entry_id );
+ FrmEntry::destroy( $entry_id );
}
/**
diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php
index 48f175d960..01390d3d17 100644
--- a/classes/controllers/FrmFieldsController.php
+++ b/classes/controllers/FrmFieldsController.php
@@ -868,10 +868,12 @@ private static function maybe_add_error_html_for_js_validation( $field, array &$
$error_body = self::pull_custom_error_body_from_custom_html( $form, $field );
- if ( false !== $error_body ) {
- $error_body = urlencode( $error_body );
- $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
+ if ( false === $error_body ) {
+ return;
}
+
+ $error_body = urlencode( $error_body );
+ $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
}
/**
@@ -1038,12 +1040,14 @@ private static function add_pattern_attribute( $field, array &$add_html ) {
$has_format = $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value );
$format_field = FrmField::is_field_type( $field, 'text' );
- if ( $field['type'] === 'phone' || ( $has_format && $format_field ) ) {
- $format = FrmEntryValidate::phone_format( $field );
- $format = substr( $format, 2, - 1 );
-
- $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
+ if ( $field['type'] !== 'phone' && ( ! $has_format || ! $format_field ) ) {
+ return;
}
+
+ $format = FrmEntryValidate::phone_format( $field );
+ $format = substr( $format, 2, - 1 );
+
+ $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
}
/**
diff --git a/classes/controllers/FrmFormTemplatesController.php b/classes/controllers/FrmFormTemplatesController.php
index 6109e89c47..2d75b0a6a3 100644
--- a/classes/controllers/FrmFormTemplatesController.php
+++ b/classes/controllers/FrmFormTemplatesController.php
@@ -154,11 +154,13 @@ public static function load_admin_hooks() {
add_action( 'admin_footer', self::class . '::render_modal' );
add_filter( 'frm_form_nav_list', self::class . '::append_new_template_to_nav', 10, 2 );
- if ( self::is_templates_page() ) {
- add_action( 'admin_init', self::class . '::set_form_templates_data' );
- add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
- add_filter( 'frm_show_footer_links', '__return_false' );
+ if ( ! self::is_templates_page() ) {
+ return;
}
+
+ add_action( 'admin_init', self::class . '::set_form_templates_data' );
+ add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
+ add_filter( 'frm_show_footer_links', '__return_false' );
}
/**
diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php
index 267ccca9cd..aa38a3cd80 100644
--- a/classes/controllers/FrmFormsController.php
+++ b/classes/controllers/FrmFormsController.php
@@ -127,13 +127,15 @@ private static function create_default_email_action( $form ) {
$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
- if ( $create_email ) {
- /**
- * @var FrmFormAction
- */
- $action_control = FrmFormActionsController::get_form_actions( 'email' );
- $action_control->create( $form->id );
+ if ( ! $create_email ) {
+ return;
}
+
+ /**
+ * @var FrmFormAction
+ */
+ $action_control = FrmFormActionsController::get_form_actions( 'email' );
+ $action_control->create( $form->id );
}
/**
@@ -162,13 +164,15 @@ private static function create_default_on_submit_action( $form ) {
*/
$create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
- if ( $create ) {
- /**
- * @var FrmFormAction
- */
- $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
- $action_control->create( $form->id );
+ if ( ! $create ) {
+ return;
}
+
+ /**
+ * @var FrmFormAction
+ */
+ $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
+ $action_control->create( $form->id );
}
/**
@@ -567,12 +571,14 @@ private static function load_theme_preview() {
add_filter( 'is_active_sidebar', '__return_false' );
FrmStylesController::enqueue_css( 'enqueue', true );
- if ( false === get_template_part( 'page' ) ) {
- if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
- add_filter( 'body_class', 'FrmFormsController::preview_block_theme_body_classnames' );
- }
- self::fallback_when_page_template_part_is_not_supported_by_theme();
+ if ( false !== get_template_part( 'page' ) ) {
+ return;
+ }
+
+ if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
+ add_filter( 'body_class', 'FrmFormsController::preview_block_theme_body_classnames' );
}
+ self::fallback_when_page_template_part_is_not_supported_by_theme();
}
/**
@@ -1092,17 +1098,19 @@ public static function insert_form_popup() {
include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php';
- if ( FrmAppHelper::is_form_builder_page() && ! class_exists( '_WP_Editors', false ) ) {
- // Initialize a wysiwyg so we have usable settings defined in tinyMCEPreInit.mceInit
- require ABSPATH . WPINC . '/class-wp-editor.php';
- // phpcs:disable Generic.WhiteSpace.ScopeIndent
- ?>
-
-
-
-
+
+
+
+ $data['title'],
- 'rel' => $is_installed ? $plugin_file : $addon['url'],
- 'is-checked' => false,
- 'is-installed' => $is_installed,
- 'help-text' => $addon['excerpt'],
- );
+ if ( is_plugin_active( $plugin_file ) || ! isset( $addon['url'] ) ) {
+ continue;
}
+
+ $is_installed = array_key_exists( $plugin_file, $plugins );
+
+ self::$available_addons[ $key ] = array(
+ 'title' => $data['title'],
+ 'rel' => $is_installed ? $plugin_file : $addon['url'],
+ 'is-checked' => false,
+ 'is-installed' => $is_installed,
+ 'help-text' => $addon['excerpt'],
+ );
}
}//end if
// Gravity Forms Migrator add-on.
$gravity_forms_plugin = 'formidable-gravity-forms-importer/formidable-gravity-forms-importer.php';
- if ( class_exists( 'GFForms' ) && ! is_plugin_active( $gravity_forms_plugin ) ) {
- $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
-
- self::$available_addons['formidable-gravity-forms-importer'] = array(
- 'title' => esc_html__( 'Gravity Forms Migrator', 'formidable' ),
- 'rel' => $is_installed_gravity_forms ? $gravity_forms_plugin : 'formidable-gravity-forms-importer',
- 'is-checked' => false,
- 'is-vendor' => true,
- 'is-installed' => $is_installed_gravity_forms,
- 'help-text' => esc_html__( 'Easily migrate your forms from Gravity Forms to Formidable.', 'formidable' ),
- );
+ if ( ! class_exists( 'GFForms' ) || is_plugin_active( $gravity_forms_plugin ) ) {
+ return;
}
+
+ $is_installed_gravity_forms = array_key_exists( $gravity_forms_plugin, $plugins );
+
+ self::$available_addons['formidable-gravity-forms-importer'] = array(
+ 'title' => esc_html__( 'Gravity Forms Migrator', 'formidable' ),
+ 'rel' => $is_installed_gravity_forms ? $gravity_forms_plugin : 'formidable-gravity-forms-importer',
+ 'is-checked' => false,
+ 'is-vendor' => true,
+ 'is-installed' => $is_installed_gravity_forms,
+ 'help-text' => esc_html__( 'Easily migrate your forms from Gravity Forms to Formidable.', 'formidable' ),
+ );
}
/**
diff --git a/classes/controllers/FrmStylesController.php b/classes/controllers/FrmStylesController.php
index 27cc5c7a46..a746001dc0 100644
--- a/classes/controllers/FrmStylesController.php
+++ b/classes/controllers/FrmStylesController.php
@@ -1196,10 +1196,12 @@ public static function enqueue_style() {
$frm_settings = FrmAppHelper::get_settings();
- if ( $frm_settings->load_style !== 'none' ) {
- wp_enqueue_style( 'formidable' );
- $frm_vars['css_loaded'] = true;
+ if ( $frm_settings->load_style === 'none' ) {
+ return;
}
+
+ wp_enqueue_style( 'formidable' );
+ $frm_vars['css_loaded'] = true;
}
/**
diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php
index 57ded23530..9b0a40908e 100644
--- a/classes/helpers/FrmAppHelper.php
+++ b/classes/helpers/FrmAppHelper.php
@@ -2377,13 +2377,15 @@ public static function force_capability( $cap = 'frm_change_settings' ) {
public static function permission_check( $permission, $show_message = 'show' ) {
$permission_error = self::permission_nonce_error( $permission );
- if ( $permission_error !== false ) {
- if ( 'hide' === $show_message ) {
- $permission_error = '';
- }
+ if ( $permission_error === false ) {
+ return;
+ }
- wp_die( esc_html( $permission_error ) );
+ if ( 'hide' === $show_message ) {
+ $permission_error = '';
}
+
+ wp_die( esc_html( $permission_error ) );
}
/**
diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php
index ebdc23f097..fb8553743c 100644
--- a/classes/helpers/FrmEntriesHelper.php
+++ b/classes/helpers/FrmEntriesHelper.php
@@ -495,19 +495,20 @@ public static function maybe_set_other_validation( $field, &$value, &$args ) {
self::set_other_repeating_vals( $field, $value, $args );
// Check if there are any posted "Other" values.
- if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ if ( ! FrmField::is_option_true( $field, 'other' ) || ! isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ return;
+ }
- // Save original value.
- $args['temp_value'] = $value;
- $args['other'] = true;
+ // Save original value.
+ $args['temp_value'] = $value;
+ $args['other'] = true;
- // Sanitizing is done next.
- $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
- FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
+ // Sanitizing is done next.
+ $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
+ FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
- // Set the validation value now
- self::set_other_validation_val( $value, $other_vals, $field, $args );
- }
+ // Set the validation value now
+ self::set_other_validation_val( $value, $other_vals, $field, $args );
}
/**
diff --git a/classes/helpers/FrmFieldGridHelper.php b/classes/helpers/FrmFieldGridHelper.php
index aeb9550035..25e47be440 100644
--- a/classes/helpers/FrmFieldGridHelper.php
+++ b/classes/helpers/FrmFieldGridHelper.php
@@ -93,11 +93,13 @@ public function set_field( $field ) {
$this->active_field_size = self::get_size_of_class( $this->field_layout_class );
}
- if ( 'divider' === $field->type && empty( $this->nested ) ) {
- $this->section_size = $this->active_field_size;
- $this->active_field_size = 0;
- $this->section_helper = new self( true );
+ if ( 'divider' !== $field->type || ! empty( $this->nested ) ) {
+ return;
}
+
+ $this->section_size = $this->active_field_size;
+ $this->active_field_size = 0;
+ $this->section_helper = new self( true );
}
/**
@@ -231,13 +233,15 @@ public function sync_list_size() {
return;
}
- if ( false !== $this->parent_li ) {
- ++$this->current_field_count;
- $this->current_list_size += $this->active_field_size;
+ if ( false === $this->parent_li ) {
+ return;
+ }
- if ( 12 === $this->current_list_size ) {
- $this->close_field_wrapper();
- }
+ ++$this->current_field_count;
+ $this->current_list_size += $this->active_field_size;
+
+ if ( 12 === $this->current_list_size ) {
+ $this->close_field_wrapper();
}
}
diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php
index c27c9ed769..e3eaf1ec5c 100644
--- a/classes/helpers/FrmFieldsHelper.php
+++ b/classes/helpers/FrmFieldsHelper.php
@@ -606,13 +606,15 @@ public static function show_fields( $fields, $errors, $form, $form_action ) {
public static function run_wpautop( $atts, &$value ) {
$autop = $atts['wpautop'] ?? true;
- if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
- if ( is_array( $value ) ) {
- $value = implode( "\n", $value );
- }
+ if ( ! apply_filters( 'frm_use_wpautop', $autop ) ) {
+ return;
+ }
- $value = wpautop( $value );
+ if ( is_array( $value ) ) {
+ $value = implode( "\n", $value );
}
+
+ $value = wpautop( $value );
}
/**
@@ -818,13 +820,15 @@ public static function inline_modal( $args ) {
public static function smart_values() {
$continue = apply_filters( 'frm_smart_values_box', true );
- if ( $continue === true ) {
- $upgrade_link = array(
- 'medium' => 'builder',
- 'content' => 'smart-tags',
- );
- include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/smart-values.php';
+ if ( $continue !== true ) {
+ return;
}
+
+ $upgrade_link = array(
+ 'medium' => 'builder',
+ 'content' => 'smart-tags',
+ );
+ include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/smart-values.php';
}
/**
diff --git a/classes/helpers/FrmFormsListHelper.php b/classes/helpers/FrmFormsListHelper.php
index 22dcc40614..6f0b8e8148 100644
--- a/classes/helpers/FrmFormsListHelper.php
+++ b/classes/helpers/FrmFormsListHelper.php
@@ -171,15 +171,17 @@ public function extra_tablenav( $which ) {
return;
}
- if ( 'trash' === $this->status && current_user_can( 'frm_delete_forms' ) ) {
- // phpcs:disable Generic.WhiteSpace.ScopeIndent
- ?>
-
-
-
- status || ! current_user_can( 'frm_delete_forms' ) ) {
+ return;
}
+
+ // phpcs:disable Generic.WhiteSpace.ScopeIndent
+ ?>
+
+
+
+ ' );
$content_before_channel_tag = substr( $xml_string, 0, $channel_start_position );
- if ( ! str_starts_with( $content_before_channel_tag, ']*name="generator"[^>]*\/>/i',
- '',
- $content_before_channel_tag,
- 1
- );
- $xml_string = $content_before_channel_tag . substr( $xml_string, $channel_start_position );
+ if ( str_starts_with( $content_before_channel_tag, ']*name="generator"[^>]*\/>/i',
+ '',
+ $content_before_channel_tag,
+ 1
+ );
+ $xml_string = $content_before_channel_tag . substr( $xml_string, $channel_start_position );
}
/**
@@ -624,12 +626,14 @@ private static function set_default_value( &$f ) {
'tag',
);
- if ( is_array( $f['default_value'] ) && in_array( $f['type'], $has_default, true ) ) {
- if ( count( $f['default_value'] ) === 1 ) {
- $f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
- } else {
- $f['default_value'] = reset( $f['default_value'] );
- }
+ if ( ! is_array( $f['default_value'] ) || ! in_array( $f['type'], $has_default, true ) ) {
+ return;
+ }
+
+ if ( count( $f['default_value'] ) === 1 ) {
+ $f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
+ } else {
+ $f['default_value'] = reset( $f['default_value'] );
}
}
@@ -688,14 +692,18 @@ private static function maybe_update_form_select( &$f, $imported ) {
return;
}
- if ( $f['type'] === 'form' || ( $f['type'] === 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
- if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
- $form_select = (int) $f['field_options']['form_select'];
+ if ( $f['type'] !== 'form' && ( $f['type'] !== 'divider' || ! FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
+ return;
+ }
- if ( isset( $imported['forms'][ $form_select ] ) ) {
- $f['field_options']['form_select'] = $imported['forms'][ $form_select ];
- }
- }
+ if ( ! FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
+ return;
+ }
+
+ $form_select = (int) $f['field_options']['form_select'];
+
+ if ( isset( $imported['forms'][ $form_select ] ) ) {
+ $f['field_options']['form_select'] = $imported['forms'][ $form_select ];
}
}
@@ -714,12 +722,14 @@ private static function maybe_update_get_values_form_setting( $imported, &$f ) {
return;
}
- if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
- $old_form = $f['field_options']['get_values_form'];
+ if ( ! FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
+ return;
+ }
- if ( isset( $imported['forms'][ $old_form ] ) ) {
- $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
- }
+ $old_form = $f['field_options']['get_values_form'];
+
+ if ( isset( $imported['forms'][ $old_form ] ) ) {
+ $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
}
}
@@ -821,10 +831,12 @@ private static function create_imported_field( $f, &$imported ) {
$new_id = FrmField::create( $f );
- if ( $new_id ) {
- ++$imported['imported']['fields'];
- do_action( 'frm_after_field_is_imported', $f, $new_id );
+ if ( ! $new_id ) {
+ return;
}
+
+ ++$imported['imported']['fields'];
+ do_action( 'frm_after_field_is_imported', $f, $new_id );
}
/**
@@ -892,13 +904,15 @@ protected static function maybe_update_field_ids( $form_id, $keys_by_original_fi
$frm_duplicate_ids = $keys_by_original_field_id;
$after = FrmFieldsHelper::switch_field_ids( $field );
- if ( $before['field_options'] !== $after['field_options'] ) {
- $frm_duplicate_ids = $field_id_by_key;
- $after = FrmFieldsHelper::switch_field_ids( $after );
+ if ( $before['field_options'] === $after['field_options'] ) {
+ continue;
+ }
- if ( $before['field_options'] !== $after['field_options'] ) {
- FrmField::update( $field['id'], array( 'field_options' => $after['field_options'] ) );
- }
+ $frm_duplicate_ids = $field_id_by_key;
+ $after = FrmFieldsHelper::switch_field_ids( $after );
+
+ if ( $before['field_options'] !== $after['field_options'] ) {
+ FrmField::update( $field['id'], array( 'field_options' => $after['field_options'] ) );
}
}
@@ -1596,12 +1610,14 @@ public static function parse_message( $result, &$message, &$errors ) {
unset( $k, $m );
}
- if ( $s_message ) {
- $message .= '' . $t_strings[ $type ] . ': ';
- $message .= implode( ', ', $s_message );
- $message .= '';
+ if ( ! $s_message ) {
+ continue;
}
- }
+
+ $message .= '' . $t_strings[ $type ] . ': ';
+ $message .= implode( ', ', $s_message );
+ $message .= '';
+ }//end foreach
if ( $message === '' ) {
$message = '';
@@ -1688,11 +1704,13 @@ private static function add_form_link_to_message( $result, &$message ) {
$primary_form = reset( $result['forms'] );
- if ( $primary_form ) {
- $primary_form = FrmForm::getOne( $primary_form );
- $form_id = ! empty( $primary_form->parent_form_id ) ? $primary_form->parent_form_id : $primary_form->id;
- $message .= '- ' . esc_html__( 'Go to imported form', 'formidable' ) . '
';
+ if ( ! $primary_form ) {
+ return;
}
+
+ $primary_form = FrmForm::getOne( $primary_form );
+ $form_id = ! empty( $primary_form->parent_form_id ) ? $primary_form->parent_form_id : $primary_form->id;
+ $message .= '- ' . esc_html__( 'Go to imported form', 'formidable' ) . '
';
}
/**
@@ -2034,11 +2052,13 @@ private static function migrate_post_settings_to_action( $form_options, $form_id
)
);
- if ( ! $exists ) {
- // This isn't an email, but we need to use a class that will always be included
- FrmDb::save_json_post( $new_action );
- ++$imported['imported']['actions'];
+ if ( $exists ) {
+ return;
}
+
+ // This isn't an email, but we need to use a class that will always be included
+ FrmDb::save_json_post( $new_action );
+ ++$imported['imported']['actions'];
}
/**
@@ -2283,14 +2303,16 @@ private static function format_email_to_data( &$atts, $notification ) {
$atts['email_to'][ $key ] = '[' . $email_field . ']';
}
- if ( str_contains( $email_field, '|' ) ) {
- $email_opt = explode( '|', $email_field );
+ if ( ! str_contains( $email_field, '|' ) ) {
+ continue;
+ }
- if ( isset( $email_opt[0] ) ) {
- $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
- }
- unset( $email_opt );
+ $email_opt = explode( '|', $email_field );
+
+ if ( isset( $email_opt[0] ) ) {
+ $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
}
+ unset( $email_opt );
}
$atts['email_to'] = implode( ', ', $atts['email_to'] );
diff --git a/classes/models/FrmAddon.php b/classes/models/FrmAddon.php
index 7adc5b1c1d..0c258c8826 100644
--- a/classes/models/FrmAddon.php
+++ b/classes/models/FrmAddon.php
@@ -161,13 +161,15 @@ public function edd_plugin_updater() {
add_action( 'after_plugin_row_' . plugin_basename( $this->plugin_file ), array( $this, 'maybe_show_license_message' ), 10, 2 );
- if ( $license ) {
- if ( 'formidable/formidable.php' !== $this->plugin_folder ) {
- add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
- }
+ if ( ! $license ) {
+ return;
+ }
- add_filter( 'site_transient_update_plugins', array( &$this, 'clear_expired_download' ) );
+ if ( 'formidable/formidable.php' !== $this->plugin_folder ) {
+ add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
}
+
+ add_filter( 'site_transient_update_plugins', array( &$this, 'clear_expired_download' ) );
}
/**
@@ -341,12 +343,14 @@ public function clear_license() {
delete_option( $this->option_name . 'active' );
delete_option( $this->option_name . 'key' );
- if ( $this->should_clear_cache ) {
- delete_site_option( $this->transient_key() );
- delete_option( $this->transient_key() );
- $this->delete_cache();
- $this->should_clear_cache = true;
+ if ( ! $this->should_clear_cache ) {
+ return;
}
+
+ delete_site_option( $this->transient_key() );
+ delete_option( $this->transient_key() );
+ $this->delete_cache();
+ $this->should_clear_cache = true;
}
/**
@@ -549,19 +553,23 @@ private function prepare_update_details( &$transient ) {
$version_info = (object) $this->get_api_info( $this->license );
}
- if ( ! empty( $version_info->new_version ) ) {
- $this->clear_old_plugin_version( $version_info );
+ if ( empty( $version_info->new_version ) ) {
+ return;
+ }
+
+ $this->clear_old_plugin_version( $version_info );
- if ( $version_info === false ) {
- // Was cleared with timeout.
- $transient = false;
- } else {
- $this->maybe_use_beta_url( $version_info );
+ if ( $version_info === false ) {
+ // Was cleared with timeout.
+ $transient = false;
- if ( version_compare( $version_info->new_version, $this->version, '>' ) ) {
- $transient = $version_info;
- }
- }
+ return;
+ }
+
+ $this->maybe_use_beta_url( $version_info );
+
+ if ( version_compare( $version_info->new_version, $this->version, '>' ) ) {
+ $transient = $version_info;
}
}
@@ -603,12 +611,14 @@ protected function get_api_info( $license ) {
private function clear_old_plugin_version( &$version_info ) {
$timeout = ! empty( $version_info->timeout ) ? $version_info->timeout : 0;
- if ( $timeout && time() > $timeout ) {
- // Cache is expired.
- $version_info = false;
- $api = new FrmFormApi( $this->license );
- $api->reset_cached();
+ if ( ! $timeout || time() <= $timeout ) {
+ return;
}
+
+ // Cache is expired.
+ $version_info = false;
+ $api = new FrmFormApi( $this->license );
+ $api->reset_cached();
}
/**
diff --git a/classes/models/FrmCreateFile.php b/classes/models/FrmCreateFile.php
index a583472bc4..b75638d626 100644
--- a/classes/models/FrmCreateFile.php
+++ b/classes/models/FrmCreateFile.php
@@ -91,10 +91,12 @@ public function create_file( $file_content ) {
$this->create_directories( $dirs_exist );
// Only write the file if the folders exist.
- if ( $dirs_exist ) {
- global $wp_filesystem;
- $wp_filesystem->put_contents( $this->new_file_path, $file_content, $this->chmod_file );
+ if ( ! $dirs_exist ) {
+ return;
}
+
+ global $wp_filesystem;
+ $wp_filesystem->put_contents( $this->new_file_path, $file_content, $this->chmod_file );
}
/**
@@ -171,11 +173,13 @@ private function check_permission() {
$this->has_permission = true;
- if ( ! $creds || ! WP_Filesystem( $creds ) ) {
- // Initialize the API - any problems and we exit
- $this->show_error_message();
- $this->has_permission = false;
+ if ( $creds && WP_Filesystem( $creds ) ) {
+ return;
}
+
+ // Initialize the API - any problems and we exit
+ $this->show_error_message();
+ $this->has_permission = false;
}
/**
diff --git a/classes/models/FrmDb.php b/classes/models/FrmDb.php
index fedc2535b8..a393d4263f 100644
--- a/classes/models/FrmDb.php
+++ b/classes/models/FrmDb.php
@@ -445,11 +445,13 @@ private static function convert_options_to_array( &$args, $order_by = '', $limit
}
// Make sure LIMIT is the last argument
- if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) {
- $temp_limit = $args['limit'];
- unset( $args['limit'] );
- $args['limit'] = $temp_limit;
+ if ( ! isset( $args['order_by'] ) || ! isset( $args['limit'] ) ) {
+ return;
}
+
+ $temp_limit = $args['limit'];
+ unset( $args['limit'] );
+ $args['limit'] = $temp_limit;
}
/**
@@ -836,13 +838,15 @@ public static function delete_cache_and_transient( $cache_key, $group = 'default
public static function cache_delete_group( $group ) {
$cached_keys = self::get_group_cached_keys( $group );
- if ( $cached_keys ) {
- foreach ( $cached_keys as $key ) {
- wp_cache_delete( $key, $group );
- }
+ if ( ! $cached_keys ) {
+ return;
+ }
- wp_cache_delete( 'cached_keys', $group );
+ foreach ( $cached_keys as $key ) {
+ wp_cache_delete( $key, $group );
}
+
+ wp_cache_delete( 'cached_keys', $group );
}
/**
diff --git a/classes/models/FrmEmail.php b/classes/models/FrmEmail.php
index 2273c4645a..ec1b1fbcb0 100644
--- a/classes/models/FrmEmail.php
+++ b/classes/models/FrmEmail.php
@@ -688,15 +688,15 @@ private function format_recipients( $recipients ) {
$parts = explode( ' ', $val );
$email = end( $parts );
- if ( is_email( $email ) ) {
- // If user enters a name and email
- $name = trim( str_replace( $email, '', $val ) );
- } else {
+ if ( ! is_email( $email ) ) {
// If user enters a name without an email
unset( $recipients[ $key ] );
continue;
}
+ // If user enters a name and email
+ $name = trim( str_replace( $email, '', $val ) );
+
$recipients[ $key ] = $this->format_from_email( $name, $email );
}//end foreach
diff --git a/classes/models/FrmEntry.php b/classes/models/FrmEntry.php
index e8769191c0..6b9a5fdbe3 100644
--- a/classes/models/FrmEntry.php
+++ b/classes/models/FrmEntry.php
@@ -1059,10 +1059,12 @@ private static function maybe_add_unique_id_meta( $values, $entry_id ) {
// It is used to check for duplicate entries.
$unique_id = sanitize_key( $values['unique_id'] );
- if ( $unique_id ) {
- FrmEntryMeta::add_entry_meta( $entry_id, 0, '', compact( 'unique_id' ) );
- self::flag_new_unique_key( $unique_id );
+ if ( ! $unique_id ) {
+ return;
}
+
+ FrmEntryMeta::add_entry_meta( $entry_id, 0, '', compact( 'unique_id' ) );
+ self::flag_new_unique_key( $unique_id );
}
/**
@@ -1076,10 +1078,12 @@ private static function maybe_add_unique_id_meta( $values, $entry_id ) {
private static function maybe_add_captcha_meta( $form_id, $entry_id ) {
global $frm_vars;
- if ( array_key_exists( 'captcha_scores', $frm_vars ) && array_key_exists( $form_id, $frm_vars['captcha_scores'] ) ) {
- $captcha_score_meta = array( 'captcha_score' => $frm_vars['captcha_scores'][ $form_id ] );
- FrmEntryMeta::add_entry_meta( $entry_id, 0, '', maybe_serialize( $captcha_score_meta ) );
+ if ( ! array_key_exists( 'captcha_scores', $frm_vars ) || ! array_key_exists( $form_id, $frm_vars['captcha_scores'] ) ) {
+ return;
}
+
+ $captcha_score_meta = array( 'captcha_score' => $frm_vars['captcha_scores'][ $form_id ] );
+ FrmEntryMeta::add_entry_meta( $entry_id, 0, '', maybe_serialize( $captcha_score_meta ) );
}
/**
diff --git a/classes/models/FrmEntryMeta.php b/classes/models/FrmEntryMeta.php
index e502b68fec..e1ee627f25 100644
--- a/classes/models/FrmEntryMeta.php
+++ b/classes/models/FrmEntryMeta.php
@@ -87,10 +87,12 @@ public static function update_entry_meta( $entry_id, $field_id, $meta_key, $meta
private static function set_value_before_save( &$values ) {
$field = FrmField::getOne( $values['field_id'] );
- if ( $field ) {
- $field_obj = FrmFieldFactory::get_field_object( $field );
- $values['meta_value'] = $field_obj->set_value_before_save( $values['meta_value'] );
+ if ( ! $field ) {
+ return;
}
+
+ $field_obj = FrmFieldFactory::get_field_object( $field );
+ $values['meta_value'] = $field_obj->set_value_before_save( $values['meta_value'] );
}
/**
diff --git a/classes/models/FrmEntryValidate.php b/classes/models/FrmEntryValidate.php
index b7ea7684a7..5614bc2cc5 100644
--- a/classes/models/FrmEntryValidate.php
+++ b/classes/models/FrmEntryValidate.php
@@ -278,6 +278,9 @@ private static function option_is_valid( $field, $value, $options ) { // phpcs:i
$option_value = $option;
}
+ /**
+ * @var string $current_value
+ */
$match = trim( $current_value ) === trim( $option_value );
if ( $match ) {
@@ -296,12 +299,14 @@ private static function option_is_valid( $field, $value, $options ) { // phpcs:i
break;
}
- if ( is_numeric( $current_value ) ) {
- $match = (int) $current_value === (int) $option_value;
+ if ( ! is_numeric( $current_value ) ) {
+ continue;
+ }
- if ( $match ) {
- break;
- }
+ $match = (int) $current_value === (int) $option_value;
+
+ if ( $match ) {
+ break;
}
}//end foreach
@@ -451,12 +456,14 @@ public static function validate_field_types( &$errors, $posted_field, $value, $a
public static function validate_phone_field( &$errors, $field, $value, $args ) {
$format_value = FrmField::get_option( $field, 'format' );
- if ( $field->type === 'phone' || ( $field->type === 'text' && $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value ) ) ) {
- $pattern = self::phone_format( $field );
+ if ( $field->type !== 'phone' && ( $field->type !== 'text' || ! $format_value || FrmCurrencyHelper::is_currency_format( $format_value ) ) ) {
+ return;
+ }
+
+ $pattern = self::phone_format( $field );
- if ( ! preg_match( $pattern, $value ) ) {
- $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
- }
+ if ( ! preg_match( $pattern, $value ) ) {
+ $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
}
}
@@ -822,11 +829,13 @@ private static function recursive_add_akismet_guest_info( &$datas, $values, $cus
foreach ( $datas['missing_keys'] as $key_index => $key ) {
$found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'], $values );
- if ( $found ) {
- $datas[ $key ] = $value;
- $datas['frm_duplicated'][] = $field_id;
- unset( $datas['missing_keys'][ $key_index ] );
+ if ( ! $found ) {
+ continue;
}
+
+ $datas[ $key ] = $value;
+ $datas['frm_duplicated'][] = $field_id;
+ unset( $datas['missing_keys'][ $key_index ] );
}
}//end foreach
}
@@ -976,12 +985,14 @@ private static function skip_adding_values_to_akismet( &$values ) {
continue;
}
- if ( self::should_really_skip_field( $skipped_field, $values ) ) {
- unset( $values['item_meta'][ $skipped_field->id ] );
+ if ( ! self::should_really_skip_field( $skipped_field, $values ) ) {
+ continue;
+ }
- if ( isset( $values['item_meta']['other'][ $skipped_field->id ] ) ) {
- unset( $values['item_meta']['other'][ $skipped_field->id ] );
- }
+ unset( $values['item_meta'][ $skipped_field->id ] );
+
+ if ( isset( $values['item_meta']['other'][ $skipped_field->id ] ) ) {
+ unset( $values['item_meta']['other'][ $skipped_field->id ] );
}
}
}
diff --git a/classes/models/FrmField.php b/classes/models/FrmField.php
index 1799e461da..1eab1f9971 100644
--- a/classes/models/FrmField.php
+++ b/classes/models/FrmField.php
@@ -1184,12 +1184,14 @@ private static function prepare_options( &$results ) {
$field_object = FrmFieldFactory::get_field_type( $results->type );
- if ( $field_object->should_unserialize_value() ) {
- FrmAppHelper::unserialize_or_decode( $results->default_value );
+ if ( ! $field_object->should_unserialize_value() ) {
+ return;
+ }
- if ( $before === $results->default_value && is_string( $before ) && str_starts_with( $before, '["' ) ) {
- $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
- }
+ FrmAppHelper::unserialize_or_decode( $results->default_value );
+
+ if ( $before === $results->default_value && is_string( $before ) && str_starts_with( $before, '["' ) ) {
+ $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
}
}
@@ -1226,15 +1228,19 @@ private static function get_next_transient( &$fields, $base_name, $next = 0 ) {
$name = $next ? $base_name . $next : $base_name;
$next_fields = get_transient( $name );
- if ( $next_fields ) {
- $fields = array_merge( $fields, $next_fields );
+ if ( ! $next_fields ) {
+ return;
+ }
+
+ $fields = array_merge( $fields, $next_fields );
- if ( count( $next_fields ) >= self::$transient_size ) {
- // If this transient is full, check for another
- ++$next;
- self::get_next_transient( $fields, $base_name, $next );
- }
+ if ( count( $next_fields ) < self::$transient_size ) {
+ return;
}
+
+ // If this transient is full, check for another
+ ++$next;
+ self::get_next_transient( $fields, $base_name, $next );
}
/**
diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php
index d7b73f22e0..ca20ece772 100644
--- a/classes/models/FrmFieldFormHtml.php
+++ b/classes/models/FrmFieldFormHtml.php
@@ -269,14 +269,18 @@ private function add_element_id( $param, $id ) {
$inner_html[2] = $inner_html[2][0];
}
- if ( is_string( $inner_html[2] ) ) {
- $has_id = str_contains( $inner_html[2], ' id=' );
+ if ( ! is_string( $inner_html[2] ) ) {
+ return;
+ }
- if ( ! $has_id ) {
- $id = 'frm_' . $id . '_' . $this->html_id;
- $this->html = str_replace( 'class="frm_' . $param, 'id="' . esc_attr( $id ) . '" class="frm_' . esc_attr( $param ), $this->html );
- }
+ $has_id = str_contains( $inner_html[2], ' id=' );
+
+ if ( $has_id ) {
+ return;
}
+
+ $id = 'frm_' . $id . '_' . $this->html_id;
+ $this->html = str_replace( 'class="frm_' . $param, 'id="' . esc_attr( $id ) . '" class="frm_' . esc_attr( $param ), $this->html );
}
/**
diff --git a/classes/models/FrmFieldValueSelector.php b/classes/models/FrmFieldValueSelector.php
index 3b57b3fc53..a2466b46ec 100644
--- a/classes/models/FrmFieldValueSelector.php
+++ b/classes/models/FrmFieldValueSelector.php
@@ -103,11 +103,13 @@ public function __construct( $field_id, $args ) {
$this->set_db_row();
- if ( $this->has_db_row() ) {
- $this->set_field_key();
- $this->set_field_settings();
- $this->set_options();
+ if ( ! $this->has_db_row() ) {
+ return;
}
+
+ $this->set_field_key();
+ $this->set_field_settings();
+ $this->set_options();
}
/**
diff --git a/classes/models/FrmForm.php b/classes/models/FrmForm.php
index 84d28a9abf..7ecae888eb 100644
--- a/classes/models/FrmForm.php
+++ b/classes/models/FrmForm.php
@@ -535,13 +535,15 @@ private static function get_settings_page_html( $values, &$field ) {
$prev_opts = $field->field_options;
}
- if ( isset( $prev_opts ) ) {
- $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
+ if ( ! isset( $prev_opts ) ) {
+ return;
+ }
- // phpcs:ignore Universal.Operators.StrictComparisons
- if ( $prev_opts != $field->field_options ) {
- FrmField::update( $field->id, array( 'field_options' => $field->field_options ) );
- }
+ $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
+
+ // phpcs:ignore Universal.Operators.StrictComparisons
+ if ( $prev_opts != $field->field_options ) {
+ FrmField::update( $field->id, array( 'field_options' => $field->field_options ) );
}
}
diff --git a/classes/models/FrmFormMigrator.php b/classes/models/FrmFormMigrator.php
index 85016dceb2..790a2256f2 100644
--- a/classes/models/FrmFormMigrator.php
+++ b/classes/models/FrmFormMigrator.php
@@ -319,13 +319,15 @@ protected function prepare_fields( $fields, &$form ) {
// List field, as field_order would already be prepared to be used.
++$field_order;
- if ( ! empty( $new_field['fields'] ) && is_array( $new_field['fields'] ) ) {
- // we have (inner) fields to merge
-
- $form['fields'] = array_merge( $form['fields'], $new_field['fields'] );
- // Set the new field_order as it would have changed
- $field_order = $new_field['current_order'];
+ if ( empty( $new_field['fields'] ) || ! is_array( $new_field['fields'] ) ) {
+ continue;
}
+
+ // we have (inner) fields to merge
+
+ $form['fields'] = array_merge( $form['fields'], $new_field['fields'] );
+ // Set the new field_order as it would have changed
+ $field_order = $new_field['current_order'];
}//end foreach
}
diff --git a/classes/models/FrmInbox.php b/classes/models/FrmInbox.php
index 7ef650e58d..e7d5dd3593 100644
--- a/classes/models/FrmInbox.php
+++ b/classes/models/FrmInbox.php
@@ -173,10 +173,12 @@ private function clean_messages() {
$read = ! empty( $message['read'] ) && isset( $message['read'][ get_current_user_id() ] ) && $message['read'][ get_current_user_id() ] < strtotime( '-1 month' );
$dismissed = ! empty( $message['dismissed'] ) && isset( $message['dismissed'][ get_current_user_id() ] ) && $message['dismissed'][ get_current_user_id() ] < strtotime( '-1 week' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
- if ( $read || $dismissed || ! $this->within_valid_timeframe( $message ) ) {
- unset( self::$messages[ $t ] );
- $removed = true;
+ if ( ! $read && ! $dismissed && $this->within_valid_timeframe( $message ) ) {
+ continue;
}
+
+ unset( self::$messages[ $t ] );
+ $removed = true;
}
if ( $removed ) {
@@ -295,10 +297,12 @@ public function mark_read( $key ) {
public function mark_unread( $key ) {
$is_read = isset( self::$messages[ $key ] ) && isset( self::$messages[ $key ]['read'] ) && isset( self::$messages[ $key ]['read'][ get_current_user_id() ] );
- if ( $is_read ) {
- unset( self::$messages[ $key ]['read'][ get_current_user_id() ] );
- $this->update_list();
+ if ( ! $is_read ) {
+ return;
}
+
+ unset( self::$messages[ $key ]['read'][ get_current_user_id() ] );
+ $this->update_list();
}
/**
diff --git a/classes/models/FrmInstallerSkin.php b/classes/models/FrmInstallerSkin.php
index 1a1e549e77..fbe2d9a7ed 100644
--- a/classes/models/FrmInstallerSkin.php
+++ b/classes/models/FrmInstallerSkin.php
@@ -87,11 +87,11 @@ public function error( $errors ) {
)
);
- if ( wp_doing_ajax() ) {
- wp_die();
- } else {
+ if ( ! wp_doing_ajax() ) {
die();
}
+
+ wp_die();
}
/**
diff --git a/classes/models/FrmMigrate.php b/classes/models/FrmMigrate.php
index f122bf9823..d4562c7321 100644
--- a/classes/models/FrmMigrate.php
+++ b/classes/models/FrmMigrate.php
@@ -86,10 +86,12 @@ public function upgrade() {
FrmAppHelper::save_combined_js();
// Update the styling settings
- if ( function_exists( 'get_filesystem_method' ) ) {
- $frm_style = new FrmStyle();
- $frm_style->update( 'default' );
+ if ( ! function_exists( 'get_filesystem_method' ) ) {
+ return;
}
+
+ $frm_style = new FrmStyle();
+ $frm_style->update( 'default' );
}
/**
diff --git a/classes/models/FrmSettings.php b/classes/models/FrmSettings.php
index 2c3052ee62..d5eccc38e3 100644
--- a/classes/models/FrmSettings.php
+++ b/classes/models/FrmSettings.php
@@ -549,11 +549,13 @@ public function update( $params ) {
do_action( 'frm_update_settings', $params );
- if ( function_exists( 'get_filesystem_method' ) ) {
- // Save styling settings in case fallback setting changes.
- $frm_style = new FrmStyle();
- $frm_style->update( 'default' );
+ if ( ! function_exists( 'get_filesystem_method' ) ) {
+ return;
}
+
+ // Save styling settings in case fallback setting changes.
+ $frm_style = new FrmStyle();
+ $frm_style->update( 'default' );
}
/**
diff --git a/classes/models/FrmSolution.php b/classes/models/FrmSolution.php
index 5de65b7609..ad23c79d7e 100644
--- a/classes/models/FrmSolution.php
+++ b/classes/models/FrmSolution.php
@@ -247,14 +247,18 @@ public function settings_page() {
if ( $all_imported ) {
$step['description'] = __( 'The following form(s) have been created.', 'formidable' );
}
+
$this->show_app_install( $step );
- if ( ! $all_imported ) {
- $step = $steps['complete'];
- $step['current'] = false;
- $step['button_class'] .= ' frm_grey disabled';
- $this->show_page_links( $step );
+ if ( $all_imported ) {
+ return;
}
+
+ $step = $steps['complete'];
+ $step['current'] = false;
+ $step['button_class'] .= ' frm_grey disabled';
+
+ $this->show_page_links( $step );
}
/**
diff --git a/classes/models/FrmSpamCheckDenylist.php b/classes/models/FrmSpamCheckDenylist.php
index 7b4289824e..fd8ee6766c 100644
--- a/classes/models/FrmSpamCheckDenylist.php
+++ b/classes/models/FrmSpamCheckDenylist.php
@@ -494,14 +494,16 @@ protected function read_lines_and_check( $file_path, $callback, $callback_args =
$is_spam = $callback( $line, $callback_args );
- if ( $is_spam ) {
- if ( is_array( $callback ) && isset( $callback[1] ) && 'single_line_check_values' === $callback[1] ) {
- self::add_spam_keyword_to_option( $line );
- }
+ if ( ! $is_spam ) {
+ continue;
+ }
- fclose( $fp );
- return true;
+ if ( is_array( $callback ) && isset( $callback[1] ) && 'single_line_check_values' === $callback[1] ) {
+ self::add_spam_keyword_to_option( $line );
}
+
+ fclose( $fp );
+ return true;
}
fclose( $fp );
diff --git a/classes/models/fields/FrmFieldCombo.php b/classes/models/fields/FrmFieldCombo.php
index bed36177ff..d418ee5d0d 100644
--- a/classes/models/fields/FrmFieldCombo.php
+++ b/classes/models/fields/FrmFieldCombo.php
@@ -408,10 +408,12 @@ protected function print_input_atts( $args ) {
do_action( 'frm_field_input_html', $field );
// Print custom attributes.
- if ( ! empty( $sub_field['atts'] ) && is_array( $sub_field['atts'] ) ) {
- foreach ( $sub_field['atts'] as $att_name => $att_value ) {
- echo esc_attr( trim( $att_name ) ) . '="' . esc_attr( trim( $att_value ) ) . '" ';
- }
+ if ( empty( $sub_field['atts'] ) || ! is_array( $sub_field['atts'] ) ) {
+ return;
+ }
+
+ foreach ( $sub_field['atts'] as $att_name => $att_value ) {
+ echo esc_attr( trim( $att_name ) ) . '="' . esc_attr( trim( $att_value ) ) . '" ';
}
}
diff --git a/classes/models/fields/FrmFieldName.php b/classes/models/fields/FrmFieldName.php
index 82a9c286fd..e5704646b1 100644
--- a/classes/models/fields/FrmFieldName.php
+++ b/classes/models/fields/FrmFieldName.php
@@ -221,13 +221,15 @@ protected function process_args_for_field_output( &$args ) {
parent::process_args_for_field_output( $args );
// Show all subfields in form builder then use JS to show or hide them.
- if ( $this->should_print_hidden_sub_fields() && count( $args['sub_fields'] ) !== count( $this->sub_fields ) ) {
- $hidden_fields = array_diff_key( $this->sub_fields, $args['sub_fields'] );
- $args['sub_fields'] = $this->sub_fields;
+ if ( ! $this->should_print_hidden_sub_fields() || count( $args['sub_fields'] ) === count( $this->sub_fields ) ) {
+ return;
+ }
- foreach ( $hidden_fields as $name => $hidden_field ) {
- $args['sub_fields'][ $name ]['wrapper_classes'] .= ' frm_hidden';
- }
+ $hidden_fields = array_diff_key( $this->sub_fields, $args['sub_fields'] );
+ $args['sub_fields'] = $this->sub_fields;
+
+ foreach ( $hidden_fields as $name => $hidden_field ) {
+ $args['sub_fields'][ $name ]['wrapper_classes'] .= ' frm_hidden';
}
}
diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php
index 455ec2c4f9..93cc0e815c 100644
--- a/classes/models/fields/FrmFieldType.php
+++ b/classes/models/fields/FrmFieldType.php
@@ -826,10 +826,12 @@ public function default_value_to_string( &$default_value ) {
protected function auto_width_setting( $args ) {
$use_style = ! isset( $args['values']['custom_style'] ) || $args['values']['custom_style'];
- if ( $use_style ) {
- $field = $args['field'];
- include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/automatic-width.php';
+ if ( ! $use_style ) {
+ return;
}
+
+ $field = $args['field'];
+ include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/automatic-width.php';
}
/**
diff --git a/formidable.php b/formidable.php
index e869fe3de9..1c2d4a410d 100644
--- a/formidable.php
+++ b/formidable.php
@@ -129,22 +129,24 @@ function frm_class_autoloader( $class_name, $filepath ) {
return;
}
- if ( preg_match( '/^FrmSquareLite.+$/', $class_name ) ) {
- $filepath = $original_filepath . '/square/';
+ if ( ! preg_match( '/^FrmSquareLite.+$/', $class_name ) ) {
+ return;
+ }
- if ( preg_match( '/^.+Helper$/', $class_name ) ) {
- $filepath .= 'helpers/';
- } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) {
- $filepath .= 'controllers/';
- } else {
- $filepath .= 'models/';
- }
+ $filepath = $original_filepath . '/square/';
- $filepath .= $class_name . '.php';
+ if ( preg_match( '/^.+Helper$/', $class_name ) ) {
+ $filepath .= 'helpers/';
+ } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) {
+ $filepath .= 'controllers/';
+ } else {
+ $filepath .= 'models/';
+ }
- if ( file_exists( $filepath ) ) {
- require $filepath;
- }
+ $filepath .= $class_name . '.php';
+
+ if ( file_exists( $filepath ) ) {
+ require $filepath;
}
}
diff --git a/phpcs.xml b/phpcs.xml
index 2dacebb2bd..fd6d4b7605 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -167,6 +167,14 @@
models/FrmEntryFormatter.php
+
+
+
+
+
+
+
+
diff --git a/square/controllers/FrmSquareLiteAppController.php b/square/controllers/FrmSquareLiteAppController.php
index 688e4e2215..2dbcc59ab0 100644
--- a/square/controllers/FrmSquareLiteAppController.php
+++ b/square/controllers/FrmSquareLiteAppController.php
@@ -231,11 +231,13 @@ private static function generate_false_entry() {
continue;
}
- if ( is_array( $v ) ) {
- foreach ( $v as $f => $value ) {
- FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
- $entry->metas[ absint( $f ) ] = $value;
- }
+ if ( ! is_array( $v ) ) {
+ continue;
+ }
+
+ foreach ( $v as $f => $value ) {
+ FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
+ $entry->metas[ absint( $f ) ] = $value;
}
}
diff --git a/stripe/controllers/FrmTransLiteActionsController.php b/stripe/controllers/FrmTransLiteActionsController.php
index f4401159b8..21cec8af7d 100755
--- a/stripe/controllers/FrmTransLiteActionsController.php
+++ b/stripe/controllers/FrmTransLiteActionsController.php
@@ -284,11 +284,13 @@ public static function trigger_actions_after_payment( $payment, $atts = array()
public static function prepare_description( &$action, $atts ) {
$description = $action->post_content['description'];
- if ( $description ) {
- $atts['value'] = $description;
- $description = FrmTransLiteAppHelper::process_shortcodes( $atts );
- $action->post_content['description'] = $description;
+ if ( ! $description ) {
+ return;
}
+
+ $atts['value'] = $description;
+ $description = FrmTransLiteAppHelper::process_shortcodes( $atts );
+ $action->post_content['description'] = $description;
}
/**
diff --git a/stripe/models/FrmStrpLiteAuth.php b/stripe/models/FrmStrpLiteAuth.php
index 423396f8e9..f6ee6399e7 100644
--- a/stripe/models/FrmStrpLiteAuth.php
+++ b/stripe/models/FrmStrpLiteAuth.php
@@ -173,12 +173,14 @@ private static function prepare_success_atts( &$atts ) {
$actions = FrmFormsController::get_met_on_submit_actions( $atts, 'create' );
- if ( $actions ) {
- $action = reset( $actions );
+ if ( ! $actions ) {
+ return;
+ }
- if ( ! empty( $action->post_content['success_action'] ) && 'message' === $action->post_content['success_action'] ) {
- $atts['conf_method'] = $action->post_content['success_action'];
- }
+ $action = reset( $actions );
+
+ if ( ! empty( $action->post_content['success_action'] ) && 'message' === $action->post_content['success_action'] ) {
+ $atts['conf_method'] = $action->post_content['success_action'];
}
}
diff --git a/tests/phpunit/base/FrmUnitTest.php b/tests/phpunit/base/FrmUnitTest.php
index 99799aa6c6..3f308e3e9a 100644
--- a/tests/phpunit/base/FrmUnitTest.php
+++ b/tests/phpunit/base/FrmUnitTest.php
@@ -235,13 +235,15 @@ public static function create_files() {
unset( $form_id_path );
}
- if ( file_exists( $path ) ) {
- if ( ! is_array( $media_ids ) ) {
- $media_ids = array();
- }
+ if ( ! file_exists( $path ) ) {
+ continue;
+ }
- $media_ids[] = $test->run_private_method( array( 'FrmProFileImport', 'attach_existing_image' ), array( $filename ) );
+ if ( ! is_array( $media_ids ) ) {
+ $media_ids = array();
}
+
+ $media_ids[] = $test->run_private_method( array( 'FrmProFileImport', 'attach_existing_image' ), array( $filename ) );
}
if ( is_array( $media_ids ) ) {
@@ -419,19 +421,23 @@ protected function set_get_params( $url ) {
$_GET['pagenow'] = $base;
$_POST['pagenow'] = $base;
- if ( ! empty( $url_params ) ) {
- $url_params = explode( '&', $url_params );
+ if ( empty( $url_params ) ) {
+ return;
+ }
- foreach ( $url_params as $param ) {
- list( $name, $value ) = explode( '=', $param );
- $_GET[ $name ] = $value;
- $_REQUEST[ $name ] = $value;
+ $url_params = explode( '&', $url_params );
- if ( $name === 'post' ) {
- global $post;
- $post = $this->factory->post->get_object_by_id( $value );
- }
+ foreach ( $url_params as $param ) {
+ list( $name, $value ) = explode( '=', $param );
+ $_GET[ $name ] = $value;
+ $_REQUEST[ $name ] = $value;
+
+ if ( $name !== 'post' ) {
+ continue;
}
+
+ global $post;
+ $post = $this->factory->post->get_object_by_id( $value );
}
}
@@ -443,6 +449,7 @@ public function clean_up_global_scope() {
}
global $frm_vars;
+
$frm_vars = array(
'load_css' => false,
'forms_loaded' => array(),
@@ -452,6 +459,7 @@ public function clean_up_global_scope() {
'prev_page' => array(),
);
+ // phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
if ( class_exists( 'FrmProEddController' ) ) {
$frmedd_update = new FrmProEddController();
$frm_vars['pro_is_authorized'] = $frmedd_update->pro_is_authorized();
diff --git a/tests/phpunit/fields/test_FrmFieldValidate.php b/tests/phpunit/fields/test_FrmFieldValidate.php
index 90894d67ba..0e608ec366 100644
--- a/tests/phpunit/fields/test_FrmFieldValidate.php
+++ b/tests/phpunit/fields/test_FrmFieldValidate.php
@@ -244,13 +244,15 @@ protected function set_required_field( $field ) {
global $wpdb;
$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', array( 'required' => 1 ), array( 'id' => $field->id ) );
- if ( $query_results ) {
- wp_cache_delete( $field->id, 'frm_field' );
- FrmField::delete_form_transient( $this->form->id );
-
- $field = FrmField::getOne( $field->id );
- $this->assertNotEmpty( $field->required );
+ if ( ! $query_results ) {
+ return;
}
+
+ wp_cache_delete( $field->id, 'frm_field' );
+ FrmField::delete_form_transient( $this->form->id );
+
+ $field = FrmField::getOne( $field->id );
+ $this->assertNotEmpty( $field->required );
}
/**
diff --git a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php
index 5649541ae3..7b779ac1c5 100644
--- a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php
+++ b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php
@@ -191,24 +191,26 @@ public function test_organize_and_set_categories() {
$this->assertArrayHasKey( $expected_category, $categories, "Should contain the '{$expected_category}' category." );
// Calculate the expected count for each category and validate it.
- if ( isset( $categories[ $expected_category ] ) ) {
- $expected_count = 0;
- switch ( $expected_category ) {
- case 'favorites':
- $expected_count = $this->controller::get_favorite_templates_count();
- break;
- case 'custom':
- $expected_count = count( $this->controller::get_custom_templates() );
- break;
- case 'all-items':
- $expected_count = count( $this->controller::get_templates() );
- break;
- case 'available-templates':
- $expected_count = 0;
- break;
- }
- $this->assertSame( $expected_count, $categories[ $expected_category ]['count'], "The '{$expected_category}' category count should match the expected number." );
+ if ( ! isset( $categories[ $expected_category ] ) ) {
+ continue;
}
+
+ $expected_count = 0;
+ switch ( $expected_category ) {
+ case 'favorites':
+ $expected_count = $this->controller::get_favorite_templates_count();
+ break;
+ case 'custom':
+ $expected_count = count( $this->controller::get_custom_templates() );
+ break;
+ case 'all-items':
+ $expected_count = count( $this->controller::get_templates() );
+ break;
+ case 'available-templates':
+ $expected_count = 0;
+ break;
+ }
+ $this->assertSame( $expected_count, $categories[ $expected_category ]['count'], "The '{$expected_category}' category count should match the expected number." );
}
}