From 9aa53c78ebf65de2e9b142f6d6ed27c26d14a516 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 9 Jan 2026 13:11:06 -0400 Subject: [PATCH 1/8] Add a new sniff for grouping simple assignments --- classes/controllers/FrmAddonsController.php | 7 +- classes/controllers/FrmAppController.php | 6 +- .../controllers/FrmApplicationsController.php | 13 +- .../controllers/FrmDashboardController.php | 6 +- .../controllers/FrmEmailStylesController.php | 13 +- classes/controllers/FrmEntriesController.php | 17 +- classes/controllers/FrmFieldsController.php | 25 +- .../controllers/FrmFormActionsController.php | 29 +- classes/controllers/FrmFormsController.php | 50 ++- classes/controllers/FrmHooksController.php | 3 +- classes/controllers/FrmInboxController.php | 3 +- classes/controllers/FrmSMTPController.php | 3 +- classes/controllers/FrmSettingsController.php | 16 +- classes/controllers/FrmStylesController.php | 13 +- classes/controllers/FrmXMLController.php | 24 +- classes/helpers/FrmAppHelper.php | 33 +- classes/helpers/FrmCSVExportHelper.php | 3 +- classes/helpers/FrmDashboardHelper.php | 3 +- classes/helpers/FrmEmailSummaryHelper.php | 7 +- classes/helpers/FrmEntriesHelper.php | 9 +- classes/helpers/FrmEntriesListHelper.php | 11 +- classes/helpers/FrmFieldsHelper.php | 45 +-- classes/helpers/FrmFormsHelper.php | 17 +- classes/helpers/FrmFormsListHelper.php | 4 +- classes/helpers/FrmListHelper.php | 28 +- classes/helpers/FrmOnSubmitHelper.php | 3 +- classes/helpers/FrmStylesCardHelper.php | 18 +- classes/helpers/FrmStylesPreviewHelper.php | 3 +- classes/helpers/FrmSubmitHelper.php | 3 +- classes/helpers/FrmXMLHelper.php | 20 +- classes/models/FrmCreateFile.php | 3 +- classes/models/FrmDb.php | 11 +- classes/models/FrmEmail.php | 4 +- classes/models/FrmEmailStats.php | 3 +- classes/models/FrmEmailSummary.php | 3 +- classes/models/FrmEntry.php | 15 +- classes/models/FrmEntryFormatter.php | 3 +- classes/models/FrmEntryMeta.php | 21 +- classes/models/FrmEntryShortcodeFormatter.php | 3 +- classes/models/FrmEntryValidate.php | 3 +- classes/models/FrmField.php | 15 +- classes/models/FrmFieldFormHtml.php | 3 +- classes/models/FrmForm.php | 10 +- classes/models/FrmFormAction.php | 3 +- classes/models/FrmFormMigrator.php | 7 +- classes/models/FrmHoneypot.php | 3 +- classes/models/FrmMigrate.php | 14 +- classes/models/FrmNotification.php | 3 +- classes/models/FrmPersonalData.php | 9 +- classes/models/FrmPluginSearch.php | 3 +- classes/models/FrmReviews.php | 3 +- classes/models/FrmSolution.php | 8 +- classes/models/FrmSpamCheckStopForumSpam.php | 3 +- classes/models/FrmStyle.php | 8 +- classes/models/FrmTableHTMLGenerator.php | 7 +- classes/models/FrmUsage.php | 9 +- classes/models/fields/FrmFieldCaptcha.php | 3 +- classes/models/fields/FrmFieldCombo.php | 3 +- classes/models/fields/FrmFieldName.php | 6 +- classes/models/fields/FrmFieldType.php | 28 +- .../views/frm-entries/_sidebar-shared-pub.php | 1 - .../views/frm-fields/back-end/radio-field.php | 3 +- .../frm-fields/front-end/dropdown-field.php | 3 +- .../frm-fields/front-end/radio-field.php | 3 +- .../views/frm-form-actions/form_action.php | 3 +- classes/views/shared/mb_adv_info.php | 3 +- classes/views/shared/toggle.php | 19 +- css/_single_theme.css.php | 6 +- .../ConsecutiveAssignmentSpacingSniff.php | 312 ++++++++++++++++++ phpcs.xml | 1 + .../FrmSquareLiteActionsController.php | 3 +- .../FrmSquareLiteAppController.php | 9 +- .../FrmSquareLiteEventsController.php | 11 +- .../FrmStrpLiteActionsController.php | 3 +- .../FrmStrpLiteEventsController.php | 8 +- .../controllers/FrmStrpLiteLinkController.php | 11 +- .../FrmStrpLitePaymentsController.php | 3 +- .../FrmTransLiteActionsController.php | 9 +- .../controllers/FrmTransLiteAppController.php | 5 +- .../FrmTransLiteListsController.php | 15 +- .../FrmTransLitePaymentsController.php | 16 +- .../helpers/FrmStrpLiteConnectApiAdapter.php | 5 +- stripe/helpers/FrmTransLiteListHelper.php | 18 +- stripe/models/FrmStrpLiteAuth.php | 1 - tests/phpunit/base/FrmUnitTest.php | 18 +- tests/phpunit/base/frm_factory.php | 3 +- tests/phpunit/database/test_FrmMigrate.php | 6 +- tests/phpunit/emails/test_FrmEmail.php | 13 +- .../emails/test_FrmEmailStylesController.php | 3 +- .../entries/test_FrmEntriesController.php | 3 +- .../entries/test_FrmEntryFormatter.php | 3 +- .../phpunit/entries/test_FrmPersonalData.php | 3 +- .../entries/test_FrmShowEntryShortcode.php | 21 +- .../entries/test_FrmTableHTMLGenerator.php | 6 +- tests/phpunit/fields/test_FrmFieldName.php | 3 +- tests/phpunit/fields/test_FrmFieldType.php | 3 +- .../phpunit/fields/test_FrmFieldValidate.php | 9 +- .../fields/test_FrmFieldsController.php | 7 +- tests/phpunit/fields/test_FrmFieldsHelper.php | 3 +- tests/phpunit/forms/test_FrmForm.php | 3 +- .../phpunit/forms/test_FrmFormsController.php | 19 +- .../forms/test_FrmFormsControllerAjax.php | 3 +- tests/phpunit/misc/test_FrmAppHelper.php | 12 +- .../phpunit/misc/test_FrmCSVExportHelper.php | 3 +- tests/phpunit/settings/test_FrmSettings.php | 3 +- .../test_FrmTransLiteActionsController.php | 3 +- tests/phpunit/test_ajax.php | 3 +- .../shortcodes/test_FrmFieldShortcodes.php | 3 +- tests/phpunit/xml/test_FrmXMLHelper.php | 3 +- 109 files changed, 664 insertions(+), 618 deletions(-) create mode 100644 phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php diff --git a/classes/controllers/FrmAddonsController.php b/classes/controllers/FrmAddonsController.php index 8370a3547b..84541e4f6b 100644 --- a/classes/controllers/FrmAddonsController.php +++ b/classes/controllers/FrmAddonsController.php @@ -807,10 +807,8 @@ protected static function prepare_addons( &$addons ) { $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] ); $file_name = $addon['plugin']; } else { - $slug = $id; - + $slug = $id; $base_file = $addon['file'] ?? 'formidable-' . $slug; - $file_name = $base_file . '/' . $base_file . '.php'; if ( ! isset( $addon['plugin'] ) ) { @@ -1250,8 +1248,7 @@ protected static function handle_addon_action( $installed, $action ) { */ private static function get_addon_activation_response() { $activating_page = self::get_activating_page(); - - $message = $activating_page ? __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ) : __( 'Your plugin has been activated.', 'formidable' ); + $message = $activating_page ? __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ) : __( 'Your plugin has been activated.', 'formidable' ); return array( 'message' => $message, diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 02062e6081..e476553e6c 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -59,8 +59,7 @@ public static function add_admin_class( $classes ) { if ( self::is_white_page() ) { $classes .= ' frm-white-body '; $classes .= self::get_os(); - - $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ); + $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ); if ( ! $page || $page === 'formidable' ) { $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); @@ -116,8 +115,7 @@ public static function add_admin_class( $classes ) { private static function get_full_screen_setting() { global $wpdb; $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences'; - - $prefs = get_user_meta( get_current_user_id(), $meta_key, true ); + $prefs = get_user_meta( get_current_user_id(), $meta_key, true ); if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) { return $prefs['core/edit-post']['fullscreenMode']; diff --git a/classes/controllers/FrmApplicationsController.php b/classes/controllers/FrmApplicationsController.php index 295024e016..bc27f1faa9 100644 --- a/classes/controllers/FrmApplicationsController.php +++ b/classes/controllers/FrmApplicationsController.php @@ -103,10 +103,9 @@ public static function get_applications_data() { * @return array */ private static function get_prepared_template_data() { - $api = new FrmApplicationApi(); - $applications = $api->get_api_info(); - $applications = array_filter( $applications, 'is_array' ); - + $api = new FrmApplicationApi(); + $applications = $api->get_api_info(); + $applications = array_filter( $applications, 'is_array' ); $unlocked_templates = array(); $locked_templates = array(); @@ -124,8 +123,7 @@ private static function get_prepared_template_data() { } $unlocked_templates = self::sort_templates( $unlocked_templates ); - - $applications = $unlocked_templates; + $applications = $unlocked_templates; if ( current_user_can( 'administrator' ) || current_user_can( 'frm_change_settings' ) ) { $locked_templates = self::sort_templates( $locked_templates ); @@ -144,8 +142,7 @@ private static function get_prepared_template_data() { * @return array */ private static function reduce_template( $total, $current ) { - $template = new FrmApplicationTemplate( $current ); - + $template = new FrmApplicationTemplate( $current ); $js_object = $template->as_js_object(); if ( $js_object ) { diff --git a/classes/controllers/FrmDashboardController.php b/classes/controllers/FrmDashboardController.php index 37083fd6ec..dacab13dea 100644 --- a/classes/controllers/FrmDashboardController.php +++ b/classes/controllers/FrmDashboardController.php @@ -124,8 +124,7 @@ public static function get_dashboard_helper() { * @return void */ public static function route() { - $dashboard_view = self::get_dashboard_helper(); - + $dashboard_view = self::get_dashboard_helper(); $should_display_videos = is_callable( 'FrmProDashboardHelper::should_display_videos' ) ? FrmProDashboardHelper::should_display_videos() : true; require FrmAppHelper::plugin_path() . '/classes/views/dashboard/dashboard.php'; @@ -227,8 +226,7 @@ public static function view_args_build_cta( $title, $link = '#', $display = true * @return array */ private static function view_args_payments() { - $prepared_data = array(); - + $prepared_data = array(); $model_payments = new FrmTransLitePayment(); $payments = $model_payments->get_payments_stats(); diff --git a/classes/controllers/FrmEmailStylesController.php b/classes/controllers/FrmEmailStylesController.php index 2c1a3b1d1c..eb19d2a9ca 100644 --- a/classes/controllers/FrmEmailStylesController.php +++ b/classes/controllers/FrmEmailStylesController.php @@ -166,8 +166,7 @@ private static function get_test_rich_text_email_content( $style_key, $table_row $should_remove_top_bottom_border = 'classic' !== $style_key; $table_generator = self::get_table_generator( $style_key ); - - $content = $table_generator->generate_table_header(); + $content = $table_generator->generate_table_header(); // By default, table has the bottom border and table cells have top border. if ( $should_remove_top_bottom_border ) { @@ -316,10 +315,9 @@ public static function ajax_send_test_email() { } $email_style = self::get_default_email_style(); - - $subject = __( 'Formidable Test Email', 'formidable' ); - $content = self::get_test_email_content(); - $headers = array( + $subject = __( 'Formidable Test Email', 'formidable' ); + $content = self::get_test_email_content(); + $headers = array( self::get_content_type_header( $email_style ), ); @@ -395,8 +393,7 @@ public static function get_email_style_settings() { */ public static function wrap_email_message( $message ) { $style_settings = self::get_email_style_settings(); - - $header_img = ''; + $header_img = ''; if ( $style_settings['img'] ) { $img_align = $style_settings['img_align'] ? $style_settings['img_align'] : 'center'; diff --git a/classes/controllers/FrmEntriesController.php b/classes/controllers/FrmEntriesController.php index 19386b67ae..3166a32c92 100644 --- a/classes/controllers/FrmEntriesController.php +++ b/classes/controllers/FrmEntriesController.php @@ -584,8 +584,7 @@ private static function remove_excess_cols( $atts, &$result ) { $atts['form_id'] . '_id' => '', ); $cols = $remove_first + array_reverse( $frm_vars['cols'], true ); - - $i = $atts['i']; + $i = $atts['i']; foreach ( $cols as $col_key => $col ) { if ( $i <= $atts['max_columns'] ) { @@ -620,11 +619,9 @@ public static function display_list( $message = '', $errors = array() ) { self::get_delete_form_time( $form, $errors ); } - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); - + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); $wp_list_table = new $table_class( array( 'params' => $params ) ); - - $pagenum = $wp_list_table->get_pagenum(); + $pagenum = $wp_list_table->get_pagenum(); $wp_list_table->prepare_items(); @@ -926,8 +923,7 @@ public static function show_entry_shortcode( $atts ) { 'array_separator' => ', ', ); $defaults = apply_filters( 'frm_show_entry_defaults', $defaults ); - - $atts = shortcode_atts( $defaults, $atts ); + $atts = shortcode_atts( $defaults, $atts ); if ( $atts['default_email'] ) { $shortcode_atts = array( @@ -949,9 +945,8 @@ public static function show_entry_shortcode( $atts ) { * @return void */ public static function entry_sidebar( $entry = false ) { - $data = array(); - $id = 0; - + $data = array(); + $id = 0; $date_format = get_option( 'date_format' ); $time_format = get_option( 'time_format' ); diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php index 813a4e8782..987be4517d 100644 --- a/classes/controllers/FrmFieldsController.php +++ b/classes/controllers/FrmFieldsController.php @@ -109,8 +109,7 @@ public static function include_new_field( $field_type, $form_id, $field_options return false; } - $field = self::get_field_array_from_id( $field_id ); - + $field = self::get_field_array_from_id( $field_id ); $values = array(); if ( FrmAppHelper::pro_is_installed() ) { @@ -132,9 +131,8 @@ public static function duplicate() { FrmAppHelper::permission_check( 'frm_edit_forms' ); check_ajax_referer( 'frm_ajax', 'nonce' ); - $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); - + $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); $new_field = FrmField::duplicate_single_field( $field_id, $form_id ); if ( is_array( $new_field ) && ! empty( $new_field['field_id'] ) ) { @@ -177,9 +175,8 @@ public static function load_single_field( $field_object, $values, $form_id = 0 ) $field_object = FrmField::getOne( $field['id'] ); } - $field_obj = FrmFieldFactory::get_field_factory( $field_object ); - $display = self::display_field_options( array(), $field_obj ); - + $field_obj = FrmFieldFactory::get_field_factory( $field_object ); + $display = self::display_field_options( array(), $field_obj ); $ajax_loading = ! empty( $values['ajax_load'] ); $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ), true ); @@ -276,11 +273,10 @@ public static function import_options() { return; } - $field = FrmFieldsHelper::setup_edit_vars( $field ); - $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); - $opts = explode( "\n", rtrim( $opts, "\n" ) ); - $opts = array_map( 'trim', $opts ); - + $field = FrmFieldsHelper::setup_edit_vars( $field ); + $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); + $opts = explode( "\n", rtrim( $opts, "\n" ) ); + $opts = array_map( 'trim', $opts ); $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' ); $field['separate_value'] = $separate === 'true'; @@ -921,8 +917,7 @@ public static function pull_custom_error_body_from_custom_html( $form, $field, $ $custom_html = $field['custom_html']; $custom_html = apply_filters( 'frm_before_replace_shortcodes', $custom_html, $field, $errors, $form ); - - $start = strpos( $custom_html, '[if error]' ); + $start = strpos( $custom_html, '[if error]' ); if ( false === $start ) { return false; diff --git a/classes/controllers/FrmFormActionsController.php b/classes/controllers/FrmFormActionsController.php index 4a0f9d4668..2378f86c77 100644 --- a/classes/controllers/FrmFormActionsController.php +++ b/classes/controllers/FrmFormActionsController.php @@ -114,9 +114,8 @@ private static function maybe_unset_highrise( $action_classes ) { * @param array $values */ public static function email_settings( $values ) { - $form = FrmForm::getOne( $values['id'] ); - $groups = self::form_action_groups(); - + $form = FrmForm::getOne( $values['id'] ); + $groups = self::form_action_groups(); $action_controls = self::get_form_actions(); self::maybe_add_action_to_group( $action_controls, $groups ); @@ -266,9 +265,8 @@ private static function active_actions( $action_controls ) { * @param array $allowed */ public static function show_action_icon_link( $action_control, $allowed ) { - $data = array(); - $classes = ' frm_' . $action_control->id_base . '_action frm_single_action'; - + $data = array(); + $classes = ' frm_' . $action_control->id_base . '_action frm_single_action'; $group_class = ' frm-group-' . $action_control->action_options['group']; /* translators: %s: Name of form action */ @@ -465,13 +463,11 @@ public static function add_form_action() { $action_control = self::get_form_actions( $action_type ); $action_control->_set( $action_key ); - $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' ); - + $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' ); $form_action = $action_control->prepare_new( $form_id ); $use_logging = self::should_show_log_message( $action_type ); - - $values = array(); - $form = self::fields_to_values( $form_id, $values ); + $values = array(); + $form = self::fields_to_values( $form_id, $values ); include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php'; wp_die(); @@ -481,9 +477,8 @@ public static function fill_action() { FrmAppHelper::permission_check( 'frm_edit_forms' ); check_ajax_referer( 'frm_ajax', 'nonce' ); - $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' ); - $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' ); - + $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' ); + $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' ); $action_control = self::get_form_actions( $action_type ); if ( ! $action_control ) { @@ -491,10 +486,8 @@ public static function fill_action() { } $form_action = $action_control->get_single_action( $action_key ); - - $values = array(); - $form = self::fields_to_values( $form_action->menu_order, $values ); - + $values = array(); + $form = self::fields_to_values( $form_action->menu_order, $values ); $use_logging = self::should_show_log_message( $action_type ); include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php'; diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index 15885f9ba2..432245e2a8 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -252,8 +252,7 @@ public static function update_settings() { return; } - $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); - + $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing @@ -985,8 +984,7 @@ public static function delete_all() { $count = FrmForm::scheduled_delete( time() ); $url = remove_query_arg( array( 'delete_all' ) ); - - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count; + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count; wp_safe_redirect( $url ); die(); @@ -1199,8 +1197,7 @@ public static function display_forms_list( $params = array(), $message = '', $er */ $table_class = apply_filters( 'frm_forms_list_class', 'FrmFormsListHelper' ); $wp_list_table = new $table_class( compact( 'params' ) ); - - $pagenum = $wp_list_table->get_pagenum(); + $pagenum = $wp_list_table->get_pagenum(); $wp_list_table->prepare_items(); @@ -1352,8 +1349,7 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c } $frm_field_selection = FrmField::field_selection(); - - $fields = FrmField::get_all_for_form( $form->id ); + $fields = FrmField::get_all_for_form( $form->id ); // Automatically add end section fields if they don't exist (2.0 migration). $reset_fields = false; @@ -1447,10 +1443,9 @@ public static function get_settings_vars( $id, $errors = array(), $args = array( $args = array_merge( $defaults, $args ); $message = $args['message']; $warnings = $args['warnings']; - - $form = FrmForm::getOne( $id ); - $fields = FrmField::get_all_for_form( $id ); - $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); + $form = FrmForm::getOne( $id ); + $fields = FrmField::get_all_for_form( $id ); + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); /** * Allows changing fields in the form settings. @@ -1729,14 +1724,12 @@ public static function mb_tags_box( $form_id, $class = '', $template_path = 'def * @param array $fields The list of fields. * @param array $args The arguments. Contains `form_id`. */ - $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) ); - $linked_forms = array(); - $col = 'one'; - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ); - + $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) ); + $linked_forms = array(); + $col = 'one'; + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ); $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); - $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); if ( 'default' === $template_path || ! file_exists( $template_path ) ) { @@ -2208,8 +2201,7 @@ public static function rename_form() { // Get posted data $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' ); - - $form = FrmForm::getOne( $form_id ); + $form = FrmForm::getOne( $form_id ); if ( ! $form ) { wp_send_json_error( __( 'Form not found', 'formidable' ) ); @@ -2452,8 +2444,7 @@ public static function show_form( $id = '', $key = '', $title = false, $descript add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); FrmAppHelper::trigger_hook_load( 'form', $form ); - $form = apply_filters( 'frm_pre_display_form', $form ); - + $form = apply_filters( 'frm_pre_display_form', $form ); $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); if ( self::is_viewable_draft_form( $form ) ) { @@ -3057,8 +3048,7 @@ private static function redirect_after_submit( $args ) { add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' ); $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args ); - - $doing_ajax = FrmAppHelper::doing_ajax(); + $doing_ajax = FrmAppHelper::doing_ajax(); if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs. @@ -3308,9 +3298,8 @@ private static function show_form_after_submit( $args ) { unset( $args ); $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); - - $frm_settings = FrmAppHelper::get_settings(); - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value; + $frm_settings = FrmAppHelper::get_settings(); + $submit = $form->options['submit_value'] ?? $frm_settings->submit_value; global $frm_vars; self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); @@ -3398,10 +3387,9 @@ private static function show_lone_success_message( $atts ) { self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] ); $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); - - $errors = array(); - $form = $atts['form']; - $message = $atts['message']; + $errors = array(); + $form = $atts['form']; + $message = $atts['message']; include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php'; } diff --git a/classes/controllers/FrmHooksController.php b/classes/controllers/FrmHooksController.php index 5d9ddd4ba1..1bb9c9f88c 100644 --- a/classes/controllers/FrmHooksController.php +++ b/classes/controllers/FrmHooksController.php @@ -13,8 +13,7 @@ class FrmHooksController { * @return void */ public static function trigger_load_hook( $hooks = 'load_hooks' ) { - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); - + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); $trigger_hooks = $hooks; $hooks = (array) $hooks; diff --git a/classes/controllers/FrmInboxController.php b/classes/controllers/FrmInboxController.php index 2945a73c01..f77fa4b83e 100644 --- a/classes/controllers/FrmInboxController.php +++ b/classes/controllers/FrmInboxController.php @@ -89,8 +89,7 @@ private static function add_tracking_request() { return; } - $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' ); - + $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' ); $message = new FrmInbox(); $message->add_message( array( diff --git a/classes/controllers/FrmSMTPController.php b/classes/controllers/FrmSMTPController.php index 304f4a4fac..0898d9e15b 100644 --- a/classes/controllers/FrmSMTPController.php +++ b/classes/controllers/FrmSMTPController.php @@ -381,8 +381,7 @@ protected function is_smtp_configured() { return false; } - $phpmailer = $this->get_phpmailer(); - + $phpmailer = $this->get_phpmailer(); $mailer = WPMailSMTP\Options::init()->get( 'mail', 'mailer' ); $is_mailer_complete = wp_mail_smtp()->get_providers()->get_mailer( $mailer, $phpmailer )->is_mailer_complete(); diff --git a/classes/controllers/FrmSettingsController.php b/classes/controllers/FrmSettingsController.php index 2d7b9053c7..ffe3110496 100644 --- a/classes/controllers/FrmSettingsController.php +++ b/classes/controllers/FrmSettingsController.php @@ -46,12 +46,10 @@ public static function display_form( $errors = array(), $message = '' ) { global $frm_vars; $frm_settings = FrmAppHelper::get_settings(); - - $uploads = wp_upload_dir(); - $target_path = $uploads['basedir'] . '/formidable/css'; - - $sections = self::get_settings_tabs(); - $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); + $uploads = wp_upload_dir(); + $target_path = $uploads['basedir'] . '/formidable/css'; + $sections = self::get_settings_tabs(); + $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { $current = 'payments_settings'; @@ -353,8 +351,7 @@ public static function permission_settings() { */ public static function payments_settings() { $payment_sections = self::$removed_payments_sections; - - $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); + $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { $tab = str_replace( '_settings', '', $tab ); @@ -506,8 +503,7 @@ public static function page_search() { 'order_by' => 'post_title', ); - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); - + $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); $results = array(); foreach ( $pages as $page ) { diff --git a/classes/controllers/FrmStylesController.php b/classes/controllers/FrmStylesController.php index 789e3a5f9c..b6a66fa9e0 100644 --- a/classes/controllers/FrmStylesController.php +++ b/classes/controllers/FrmStylesController.php @@ -762,10 +762,9 @@ public static function save() { * @return void */ private static function maybe_redirect_after_save( $ids ) { - $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); - $parsed = parse_url( $referer ); - $query = $parsed['query']; - + $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); + $parsed = parse_url( $referer ); + $query = $parsed['query']; $current_action = false; $actions_to_redirect = array( 'duplicate', 'new_style' ); @@ -782,8 +781,7 @@ private static function maybe_redirect_after_save( $ids ) { } parse_str( $query, $parsed_query ); - $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0; - + $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0; $style = new stdClass(); $style->ID = end( $ids ); wp_safe_redirect( esc_url_raw( FrmStylesHelper::get_edit_url( $style, $form_id ) ) ); @@ -1377,8 +1375,7 @@ public static function do_accordion_sections( $screen, $context, $data_object ) } ++$i; - $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id']; - + $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id']; $open_class = ''; if ( ! $first_open ) { diff --git a/classes/controllers/FrmXMLController.php b/classes/controllers/FrmXMLController.php index fb2562eb2f..3c02700f16 100644 --- a/classes/controllers/FrmXMLController.php +++ b/classes/controllers/FrmXMLController.php @@ -23,8 +23,7 @@ public static function add_default_templates() { $set_err = libxml_use_internal_errors( true ); $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true ); - - $files = apply_filters( 'frm_default_templates_files', array() ); + $files = apply_filters( 'frm_default_templates_files', array() ); foreach ( (array) $files as $file ) { FrmXMLHelper::import_xml( $file ); @@ -208,8 +207,7 @@ private static function create_pages_for_import( $form ) { $form_key = self::get_selected_in_form( $form, 'form' ); $view_keys = self::get_selected_in_form( $form, 'view' ); - - $page_ids = array(); + $page_ids = array(); foreach ( (array) $form['pages'] as $for => $name ) { if ( empty( $name ) ) { @@ -346,9 +344,8 @@ public static function form( $errors = array(), $message = '' ) { * @return void */ public static function import_xml() { - $errors = array(); - $message = ''; - + $errors = array(); + $message = ''; $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' ); if ( false !== $permission_error ) { @@ -409,8 +406,7 @@ public static function import_xml() { $set_err = libxml_use_internal_errors( true ); $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true ); - - $result = FrmXMLHelper::import_xml( $file ); + $result = FrmXMLHelper::import_xml( $file ); FrmXMLHelper::parse_message( $result, $message, $errors ); unset( $file ); @@ -492,10 +488,9 @@ public static function generate_xml( $type, $args = array() ) { // phpcs:ignore $records = array(); foreach ( $type as $tb_type ) { - $where = array(); - $join = ''; - $table = $tables[ $tb_type ]; - + $where = array(); + $join = ''; + $table = $tables[ $tb_type ]; $select = $table . '.id'; $query_vars = array(); @@ -727,8 +722,7 @@ public static function csv( $form_id = false, $search = '', $fid = '' ) { $form_id = $form->id; $form_cols = self::get_fields_for_csv_export( $form_id, $form ); - - $item_id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'sanitize_text_field' ); + $item_id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'sanitize_text_field' ); if ( $item_id ) { $item_id = explode( ',', $item_id ); diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index f772deb40d..a4c8370ab8 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -833,8 +833,7 @@ public static function get_simple_request( $args ) { 'serialized' => false, ); $args = wp_parse_args( $args, $defaults ); - - $value = $args['default']; + $value = $args['default']; if ( $args['type'] === 'get' ) { if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { @@ -1374,8 +1373,7 @@ public static function icon_by_class( $class, $atts = array() ) { } $html_atts = self::array_to_html_params( $atts ); - - $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) ); + $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) ); // Replace icons that have been removed or renamed. $deprecated = array( @@ -1891,8 +1889,7 @@ public static function get_post_ids_and_titles( $post_type = 'page' ) { * @param array $args Selection arguments. */ public static function maybe_autocomplete_pages_options( $args ) { - $args = self::preformat_selection_args( $args ); - + $args = self::preformat_selection_args( $args ); $pages_count = wp_count_posts( $args['post_type'] ); if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) { @@ -1941,8 +1938,7 @@ public static function maybe_autocomplete_options( $args ) { 'label_key' => 'label', ); - $args = wp_parse_args( $args, $defaults ); - + $args = wp_parse_args( $args, $defaults ); $html_attrs = array(); if ( ! empty( $args['name'] ) ) { @@ -2447,9 +2443,8 @@ public static function checked( $values, $current ) { * @return bool */ public static function check_selected( $values, $current ) { - $values = self::recursive_function_map( $values, 'trim' ); - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' ); - + $values = self::recursive_function_map( $values, 'trim' ); + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' ); $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) ); // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons @@ -2465,8 +2460,7 @@ public static function check_selected( $values, $current ) { public static function recursive_function_map( $value, $function ) { if ( is_array( $value ) ) { $original_function = $function; - - $function = count( $value ) ? explode( ', ', FrmDb::prepare_array_values( $value, $function ) ) : array( $function ); + $function = count( $value ) ? explode( ', ', FrmDb::prepare_array_values( $value, $function ) ) : array( $function ); if ( ! self::is_assoc( $value ) ) { $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function ); @@ -3092,9 +3086,8 @@ public static function truncate( $original_string, $length, $minword = 3, $conti return $sub . ( $length < $original_len ? $continue : '' ); } - $sub = ''; - $len = 0; - + $sub = ''; + $len = 0; $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); if ( ! is_array( $words ) ) { @@ -3189,8 +3182,7 @@ public static function get_formatted_time( $date, $date_format = '', $time_forma } $formatted = self::get_localized_date( $date_format, $date ); - - $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00' ); + $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00' ); if ( $do_time ) { $formatted .= self::add_time_to_date( $time_format, $date ); @@ -3244,7 +3236,6 @@ public static function get_localized_date( $date_format, $date ) { */ public static function human_time_diff( $from, $to = '', $levels = 1 ) { $now = empty( $to ) && 0 !== $to ? new DateTime() : new DateTime( '@' . $to ); - $ago = new DateTime( '@' . $from ); // Get the time difference @@ -3309,7 +3300,6 @@ private static function time_format( $unit, $diff ) { } $total = $diff['days'] * self::convert_time( 'd', $unit ); - $times = array( 'h', 'i', 's' ); foreach ( $times as $time ) { @@ -4257,8 +4247,7 @@ public static function get_menu_icon_class() { * } */ public static function images_dropdown( $args ) { - $args = self::fill_default_images_dropdown_args( $args ); - + $args = self::fill_default_images_dropdown_args( $args ); $input_attrs_str = self::get_images_dropdown_input_attrs( $args ); ob_start(); include self::plugin_path() . '/classes/views/shared/images-dropdown.php'; diff --git a/classes/helpers/FrmCSVExportHelper.php b/classes/helpers/FrmCSVExportHelper.php index b29304c674..548fec8a6c 100644 --- a/classes/helpers/FrmCSVExportHelper.php +++ b/classes/helpers/FrmCSVExportHelper.php @@ -419,8 +419,7 @@ private static function csv_headings( &$headings ) { // phpcs:ignore SlevomatCod foreach ( $headings as $key => $heading ) { if ( is_array( $heading ) ) { - $repeater_id = str_replace( 'repeater', '', $key ); - + $repeater_id = str_replace( 'repeater', '', $key ); $repeater_headings = array(); foreach ( $fields_by_repeater_id[ $repeater_id ] as $col ) { diff --git a/classes/helpers/FrmDashboardHelper.php b/classes/helpers/FrmDashboardHelper.php index a18ff1c3af..8a698d9d81 100644 --- a/classes/helpers/FrmDashboardHelper.php +++ b/classes/helpers/FrmDashboardHelper.php @@ -247,8 +247,7 @@ public static function get_license_buttons() { * @return void */ public function get_inbox() { - $template = $this->view['inbox']; - + $template = $this->view['inbox']; $subscribe_inbox_classnames = 'frm-inbox-subscribe frmcenter'; $subscribe_inbox_classnames .= ! empty( $template['unread'] ) ? ' frm_hidden' : ''; $subscribe_inbox_classnames .= true === FrmDashboardController::email_is_subscribed( $template['user']->user_email ) ? ' frm-inbox-hide-form' : ''; diff --git a/classes/helpers/FrmEmailSummaryHelper.php b/classes/helpers/FrmEmailSummaryHelper.php index 8508c8b377..30acd3e540 100644 --- a/classes/helpers/FrmEmailSummaryHelper.php +++ b/classes/helpers/FrmEmailSummaryHelper.php @@ -576,10 +576,9 @@ public static function maybe_remove_recipients_from_api( &$recipients ) { } $skip_emails = is_string( $addons['no_emails'] ) ? explode( ',', $addons['no_emails'] ) : (array) $addons['no_emails']; - - $recipients = array_map( 'trim', explode( ',', $recipients ) ); - $recipients = array_diff( $recipients, $skip_emails ); - $recipients = implode( ',', $recipients ); + $recipients = array_map( 'trim', explode( ',', $recipients ) ); + $recipients = array_diff( $recipients, $skip_emails ); + $recipients = implode( ',', $recipients ); } /** diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php index 07172ae38a..af5e4566dd 100644 --- a/classes/helpers/FrmEntriesHelper.php +++ b/classes/helpers/FrmEntriesHelper.php @@ -49,8 +49,7 @@ public static function setup_new_vars( $fields, $form = '', $reset = false, $arg foreach ( (array) $fields as $field ) { $original_default = $field->default_value; self::prepare_field_default_value( $field ); - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); - + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); $field_array = FrmAppHelper::start_field_array( $field ); $field_array['value'] = $new_value; $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value ); @@ -200,11 +199,9 @@ public static function replace_default_message( $message, $atts ) { preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); foreach ( $shortcodes[0] as $short_key => $tag ) { - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); - + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); $this_atts = ! empty( $add_atts ) ? array_merge( $atts, $add_atts ) : $atts; - - $default = FrmEntriesController::show_entry_shortcode( $this_atts ); + $default = FrmEntriesController::show_entry_shortcode( $this_atts ); // Add the default message. $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); diff --git a/classes/helpers/FrmEntriesListHelper.php b/classes/helpers/FrmEntriesListHelper.php index d73e9db361..850be75c57 100644 --- a/classes/helpers/FrmEntriesListHelper.php +++ b/classes/helpers/FrmEntriesListHelper.php @@ -31,8 +31,7 @@ public function __construct( $args ) { */ public function prepare_items() { $this->set_per_page(); - $s_query = array(); - + $s_query = array(); $join_form_in_query = false; $this->items = $this->get_entry_items( $s_query, $join_form_in_query ); @@ -297,9 +296,8 @@ protected function extra_tablenav( $which ) { * @return string $primary_column */ protected function get_primary_column_name() { - $columns = get_column_headers( $this->screen ); - $hidden = get_hidden_columns( $this->screen ); - + $columns = get_column_headers( $this->screen ); + $hidden = get_hidden_columns( $this->screen ); $primary_column = ''; foreach ( $columns as $column_key => $column_display_name ) { @@ -368,8 +366,7 @@ public function single_row( $item, $style = '' ) { $attributes = 'class="' . esc_attr( $class ) . '"'; unset( $class ); - $attributes .= ' data-colname="' . $column_display_name . '"'; - + $attributes .= ' data-colname="' . $column_display_name . '"'; $form_id = $this->params['form'] ? $this->params['form'] : 0; $this->column_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name ); diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index bc4854567b..fe6b6c783f 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -373,8 +373,7 @@ private static function get_posted_field_setting( $setting, &$value ) { public static function get_default_field_options_from_field( $field, $values = array() ) { $field_type = self::get_original_field( $field ); $opts = $field_type->get_default_field_options(); - - $opts = apply_filters( 'frm_default_field_opts', $opts, $values, $field ); + $opts = apply_filters( 'frm_default_field_opts', $opts, $values, $field ); return apply_filters( 'frm_default_' . $field->type . '_field_opts', $opts, $values, $field ); } @@ -454,9 +453,8 @@ public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { */ public static function get_error_msg( $field, $error ) { $frm_settings = FrmAppHelper::get_settings(); - - $conf_msg = __( 'The entered values do not match', 'formidable' ); - $defaults = array( + $conf_msg = __( 'The entered values do not match', 'formidable' ); + $defaults = array( 'unique_msg' => array( 'full' => self::default_unique_msg(), /* translators: %s: Field name */ @@ -688,16 +686,14 @@ public static function show_single_option( $field ) { return; } - $base_name = 'default_value_' . $field['id']; - $html_id = $field['html_id'] ?? self::get_html_id( $field ); - + $base_name = 'default_value_' . $field['id']; + $html_id = $field['html_id'] ?? self::get_html_id( $field ); $default_type = self::get_default_value_type( $field ); $options_count = count( $field['options'] ); foreach ( $field['options'] as $opt_key => $opt ) { - $field_val = self::get_value_from_array( $opt, $opt_key, $field ); - $opt = self::get_label_from_array( $opt, $opt_key, $field ); - + $field_val = self::get_value_from_array( $opt, $opt_key, $field ); + $opt = self::get_label_from_array( $opt, $opt_key, $field ); $field_name = $base_name . ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' ); // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons @@ -733,13 +729,12 @@ private static function hidden_field_option( $field ) { return; } - $opt_key = '000'; - $field_val = __( 'New Option', 'formidable' ); - $opt = __( 'New Option', 'formidable' ); - $checked = false; - $field_name = 'default_value_' . $field['id']; - $html_id = $field['html_id'] ?? self::get_html_id( $field ); - + $opt_key = '000'; + $field_val = __( 'New Option', 'formidable' ); + $opt = __( 'New Option', 'formidable' ); + $checked = false; + $field_name = 'default_value_' . $field['id']; + $html_id = $field['html_id'] ?? self::get_html_id( $field ); $default_type = self::get_default_value_type( $field ); $field_name .= ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' ); @@ -903,7 +898,6 @@ public static function value_meets_condition( $observed_value, $cond, $hide_opt $m = $observed_value <= $hide_opt; } elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) { $m = stripos( $observed_value, $hide_opt ); - $m = $cond === 'not LIKE' ? $m === false : $m !== false; } elseif ( $cond === '%LIKE' ) { // ends with @@ -1374,7 +1368,6 @@ public static function process_get_shortcode( $atts, $return_array = false ) { public static function get_display_value( $value, $field, $atts = array() ) { $value = apply_filters( 'frm_get_' . $field->type . '_display_value', $value, $field, $atts ); $value = apply_filters( 'frm_get_display_value', $value, $field, $atts ); - $value = self::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) ); return apply_filters( 'frm_display_value', $value, $field, $atts ); @@ -1418,7 +1411,6 @@ public static function get_user_display_name( $user_id, $user_info = 'display_na ); $args = wp_parse_args( $args, $defaults ); - $user = get_userdata( $user_id ); $info = ''; @@ -1531,14 +1523,13 @@ public static function is_other_opt( $opt_key ) { * @return string */ public static function get_other_val( $args ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh - $defaults = array( + $defaults = array( 'opt_key' => 0, 'field' => array(), 'parent' => false, 'pointer' => false, ); - $args = wp_parse_args( $args, $defaults ); - + $args = wp_parse_args( $args, $defaults ); $opt_key = $args['opt_key']; $field = $args['field']; $parent = $args['parent']; @@ -2515,8 +2506,7 @@ private static function update_params_with_limit_data( $li_params, $form_id, $fi */ public static function show_radio_display_format( $field ) { $options = self::get_display_format_options( $field ); - - $args = self::get_display_format_args( $field, $options ); + $args = self::get_display_format_args( $field, $options ); include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-display-format.php'; } @@ -2651,8 +2641,7 @@ private static function fill_image_setting_addon_link( $option ) { return $custom_attrs; } - $upgrading = FrmAddonsController::install_link( $option['addon'] ); - + $upgrading = FrmAddonsController::install_link( $option['addon'] ); $install_data = isset( $upgrading['url'] ) ? wp_json_encode( $upgrading ) : ''; $custom_attrs['data-oneclick'] = $install_data; diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index 9b2405f53a..9d4089a5d4 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -566,8 +566,7 @@ public static function get_custom_submit( $html, $form, $submit, $form_action, $ } $button_parts = explode( '[button_action]', $button ); - - $classes = apply_filters( 'frm_submit_button_class', array(), $form ); + $classes = apply_filters( 'frm_submit_button_class', array(), $form ); if ( $classes ) { $classes = implode( ' ', $classes ); @@ -1769,12 +1768,11 @@ public static function convert_legacy_package_names( $package_name ) { * @return array */ public static function get_license_types( $args = array() ) { - $defaults = array( + $defaults = array( 'include_all' => true, 'case_lower' => false, ); - $args = wp_parse_args( $args, $defaults ); - + $args = wp_parse_args( $args, $defaults ); $license_types = array( 'Basic', 'Plus', 'Business', 'Elite' ); if ( $args['include_all'] ) { @@ -1798,8 +1796,7 @@ public static function get_license_types( $args = array() ) { * @return array An array of warnings or an empty array. */ public static function check_for_warnings( $values ) { - $warnings = array(); - + $warnings = array(); $redirect_warning = self::check_redirect_url_for_unsafe_params( $values ); if ( $redirect_warning ) { @@ -1971,8 +1968,7 @@ public static function maybe_add_sanitize_url_attr( $url, $form_id ) { $original_query = $parsed['query']; $query = $parsed['query']; - - $shortcodes = FrmFieldsHelper::get_shortcodes( $query, $form_id ); + $shortcodes = FrmFieldsHelper::get_shortcodes( $query, $form_id ); if ( empty( $shortcodes[0] ) ) { // No shortcodes found, do nothing. @@ -1999,8 +1995,7 @@ public static function maybe_add_sanitize_url_attr( $url, $form_id ) { } $new_shortcode .= ' sanitize_url=1]'; - - $query = str_replace( $shortcode, $new_shortcode, $query ); + $query = str_replace( $shortcode, $new_shortcode, $query ); }//end foreach if ( $query === $original_query ) { diff --git a/classes/helpers/FrmFormsListHelper.php b/classes/helpers/FrmFormsListHelper.php index 557c8b5c79..785c9e68c7 100644 --- a/classes/helpers/FrmFormsListHelper.php +++ b/classes/helpers/FrmFormsListHelper.php @@ -256,8 +256,7 @@ public function single_row( $item, $style = '' ) { ); $checkbox .= ''; - - $r = ''; + $r = ''; list( $columns, $hidden ) = $this->get_column_info(); @@ -269,7 +268,6 @@ public function single_row( $item, $style = '' ) { foreach ( $columns as $column_name => $column_display_name ) { $class = $column_name . ' column-' . $column_name . ( 'name' === $column_name ? ' post-title page-title column-title' : '' ); - $style = ''; if ( in_array( $column_name, $hidden, true ) ) { diff --git a/classes/helpers/FrmListHelper.php b/classes/helpers/FrmListHelper.php index ece6140347..da0da42efc 100644 --- a/classes/helpers/FrmListHelper.php +++ b/classes/helpers/FrmListHelper.php @@ -500,8 +500,7 @@ private function get_bulk_action( $action_name ) { */ protected function row_actions( $actions, $always_visible = false ) { $action_count = count( $actions ); - - $i = 0; + $i = 0; if ( ! $action_count ) { return ''; @@ -625,14 +624,11 @@ protected function pagination( $which ) { /* translators: %s: Number of items */ $output = '' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . ''; - $current = $this->get_pagenum(); - - $page_links = array(); - + $current = $this->get_pagenum(); + $page_links = array(); $total_pages_before = ''; $total_pages_after = ''; - - $disable = $this->disabled_pages( $total_pages ); + $disable = $this->disabled_pages( $total_pages ); $page_links[] = $this->add_page_link( array( @@ -892,9 +888,8 @@ protected function get_column_info() { return $column_headers; } - $columns = get_column_headers( $this->screen ); - $hidden = get_hidden_columns( $this->screen ); - + $columns = get_column_headers( $this->screen ); + $hidden = get_hidden_columns( $this->screen ); $sortable_columns = $this->get_sortable_columns(); /** * Filter the list table sortable columns for a specific screen. @@ -959,12 +954,10 @@ public function get_column_count() { public function print_column_headers( $with_id = true ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); - $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); - $current_url = remove_query_arg( 'paged', $current_url ); - + $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); + $current_url = remove_query_arg( 'paged', $current_url ); $current_orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : ''; - - $current_order = isset( $_GET['order'] ) && 'desc' === $_GET['order'] ? 'desc' : 'asc'; + $current_order = isset( $_GET['order'] ) && 'desc' === $_GET['order'] ? 'desc' : 'asc'; FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order ); @@ -1295,8 +1288,7 @@ public function ajax_response() { $this->display_rows_or_placeholder(); } - $rows = ob_get_clean(); - + $rows = ob_get_clean(); $response = array( 'rows' => $rows ); if ( isset( $this->_pagination_args['total_items'] ) ) { diff --git a/classes/helpers/FrmOnSubmitHelper.php b/classes/helpers/FrmOnSubmitHelper.php index 04bedc01b6..7ae25cbac6 100644 --- a/classes/helpers/FrmOnSubmitHelper.php +++ b/classes/helpers/FrmOnSubmitHelper.php @@ -422,8 +422,7 @@ private static function save_migrated_success_actions( $form ) { * @return object */ public static function get_fallback_action( $event = 'create' ) { - $action = new stdClass(); - + $action = new stdClass(); $default_msg = self::get_default_msg(); if ( current_user_can( 'frm_edit_forms' ) ) { diff --git a/classes/helpers/FrmStylesCardHelper.php b/classes/helpers/FrmStylesCardHelper.php index f769ed9a4a..93b29c2dec 100644 --- a/classes/helpers/FrmStylesCardHelper.php +++ b/classes/helpers/FrmStylesCardHelper.php @@ -291,8 +291,7 @@ public static function get_style_param_for_card( $style ) { continue; } - $value = $style->post_content[ $key ]; - + $value = $style->post_content[ $key ]; $is_hex = in_array( $key, $color_settings, true ) && $value && '#' !== $value[0] && ! str_contains( $value, 'rgb' ) && $value !== 'transparent'; if ( $is_hex ) { @@ -383,14 +382,13 @@ public function echo_card_wrapper( $id, $styles ) { private function get_style_attribute_value_for_wrapper() { $frm_style = new FrmStyle(); $defaults = $frm_style->get_defaults(); - - $styles = array(); - $styles[] = '--field-font-size: ' . $defaults['field_font_size']; - $styles[] = '--field-height: ' . $defaults['field_height']; - $styles[] = '--field-pad: ' . $defaults['field_pad']; - $styles[] = '--font-size: ' . $defaults['font_size']; - $styles[] = '--label-padding: ' . $defaults['label_padding']; - $styles[] = '--form-align: ' . $defaults['form_align']; + $styles = array(); + $styles[] = '--field-font-size: ' . $defaults['field_font_size']; + $styles[] = '--field-height: ' . $defaults['field_height']; + $styles[] = '--field-pad: ' . $defaults['field_pad']; + $styles[] = '--font-size: ' . $defaults['font_size']; + $styles[] = '--label-padding: ' . $defaults['label_padding']; + $styles[] = '--form-align: ' . $defaults['form_align']; return implode( ';', $styles ); } diff --git a/classes/helpers/FrmStylesPreviewHelper.php b/classes/helpers/FrmStylesPreviewHelper.php index 7358e424d9..4b84e19a1a 100644 --- a/classes/helpers/FrmStylesPreviewHelper.php +++ b/classes/helpers/FrmStylesPreviewHelper.php @@ -192,8 +192,7 @@ public function get_html_for_form_preview() { * @return array */ public function get_notes_for_styler_preview() { - $notes = array(); - + $notes = array(); $fallback_form_note = $this->get_fallback_form_note(); if ( is_string( $fallback_form_note ) ) { diff --git a/classes/helpers/FrmSubmitHelper.php b/classes/helpers/FrmSubmitHelper.php index ac868d6270..775000e178 100644 --- a/classes/helpers/FrmSubmitHelper.php +++ b/classes/helpers/FrmSubmitHelper.php @@ -162,8 +162,7 @@ public static function maybe_create_submit_field( $form, $fields, &$reset_fields return; } - $field_data = FrmFieldsHelper::setup_new_vars( self::FIELD_TYPE, $form->id ); - + $field_data = FrmFieldsHelper::setup_new_vars( self::FIELD_TYPE, $form->id ); $submit_settings = self::get_submit_settings_from_form( $form ); $field_data['field_options'] = $submit_settings + $field_data['field_options']; $field_data['name'] = FrmForm::get_option( diff --git a/classes/helpers/FrmXMLHelper.php b/classes/helpers/FrmXMLHelper.php index 0842570445..f7f62c773c 100644 --- a/classes/helpers/FrmXMLHelper.php +++ b/classes/helpers/FrmXMLHelper.php @@ -221,7 +221,6 @@ private static function get_term_parent_id( $t ) { if ( $parent ) { $parent = term_exists( (string) $t->term_parent, (string) $t->term_taxonomy ); - $parent = $parent ? $parent['term_id'] : 0; } @@ -245,8 +244,7 @@ public static function import_xml_forms( $forms, $imported ) { self::update_custom_style_setting_on_import( $form ); - $this_form = self::maybe_get_form( $form ); - + $this_form = self::maybe_get_form( $form ); $old_id = false; $form_fields = false; @@ -347,8 +345,7 @@ private static function maybe_get_form( $form ) { } $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form ); - - $form = FrmForm::getAll( $edit_query, '', 1 ); + $form = FrmForm::getAll( $edit_query, '', 1 ); if ( is_object( $form ) && $form->status === 'trash' ) { FrmForm::destroy( $form->id ); @@ -1134,8 +1131,7 @@ private static function clear_forms_style_caches( $imported_forms ) { 'post_type' => FrmStylesController::$post_type, ); - $select = 'ID'; - + $select = 'ID'; $cache_key = FrmDb::generate_cache_key( $where, array( 'limit' => 1 ), $select, 'var' ); FrmDb::delete_cache_and_transient( $cache_key, 'post' ); } @@ -1678,8 +1674,7 @@ private static function add_form_link_to_message( $result, &$message ) { if ( $primary_form ) { $primary_form = FrmForm::getOne( $primary_form ); $form_id = empty( $primary_form->parent_form_id ) ? $primary_form->id : $primary_form->parent_form_id; - - $message .= '
  • ' . esc_html__( 'Go to imported form', 'formidable' ) . '
  • '; + $message .= '
  • ' . esc_html__( 'Go to imported form', 'formidable' ) . '
  • '; } } @@ -1699,10 +1694,9 @@ public static function prepare_form_options_for_export( $options ) { if ( $not_default ) { global $wpdb; - $table = $wpdb->prefix . 'posts'; - $where = array( 'ID' => $options['custom_style'] ); - $select = 'post_name'; - + $table = $wpdb->prefix . 'posts'; + $where = array( 'ID' => $options['custom_style'] ); + $select = 'post_name'; $style_name = FrmDb::get_var( $table, $where, $select ); $options['custom_style'] = $style_name ? $style_name : 1; diff --git a/classes/models/FrmCreateFile.php b/classes/models/FrmCreateFile.php index 940c9f1108..d0a861e83a 100644 --- a/classes/models/FrmCreateFile.php +++ b/classes/models/FrmCreateFile.php @@ -208,8 +208,7 @@ private function create_directories( &$dirs_exist ) { private function get_needed_dirs() { $dir_names = explode( '/', $this->folder_name ); $needed_dirs = array(); - - $next_dir = ''; + $next_dir = ''; foreach ( $dir_names as $dir ) { $next_dir .= '/' . $dir; diff --git a/classes/models/FrmDb.php b/classes/models/FrmDb.php index 7c05b7ffb5..615fb9a349 100644 --- a/classes/models/FrmDb.php +++ b/classes/models/FrmDb.php @@ -254,8 +254,7 @@ public static function get_var( $table, $where = array(), $field = 'id', $args = $args['limit'] = 1; } - $query = self::generate_query_string_from_pieces( $field, $table, $where, $args ); - + $query = self::generate_query_string_from_pieces( $field, $table, $where, $args ); $cache_key = self::generate_cache_key( $where, $args, $field, $type ); return self::check_cache( $cache_key, $group, $query, 'get_' . $type ); @@ -470,8 +469,7 @@ public static function get_associative_array_results( $columns, $table, $where ) $group = ''; self::get_group_and_table_name( $table, $group ); - $query = self::generate_query_string_from_pieces( $columns, $table, $where ); - + $query = self::generate_query_string_from_pieces( $columns, $table, $where ); $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) ); return self::check_cache( $cache_key, $group, $query, 'get_associative_results' ); @@ -560,9 +558,8 @@ public static function esc_order( $order_query ) { } $order_query = explode( ' ', trim( $order_query ) ); - - $order = trim( reset( $order_query ) ); - $safe_order = array( 'count(*)' ); + $order = trim( reset( $order_query ) ); + $safe_order = array( 'count(*)' ); if ( ! in_array( strtolower( $order ), $safe_order, true ) ) { $order = preg_replace( '/[^a-zA-Z0-9\-\_\.\+]/', '', $order ); diff --git a/classes/models/FrmEmail.php b/classes/models/FrmEmail.php index 89f0bb8db0..a76107e10b 100644 --- a/classes/models/FrmEmail.php +++ b/classes/models/FrmEmail.php @@ -224,7 +224,6 @@ private function set_bcc( $user_id_args ) { private function prepare_additional_recipients( $recipients, $user_id_args ) { $recipients = $this->prepare_email_setting( $recipients, $user_id_args ); $recipients = $this->explode_emails( $recipients ); - $recipients = array_unique( (array) $recipients ); return $this->format_recipients( $recipients ); @@ -561,8 +560,7 @@ private function send_single( $recipient ) { ); $subject = $this->encode_subject( $this->subject ); - - $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments ); + $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments ); if ( ! $sent ) { if ( is_array( $header ) ) { diff --git a/classes/models/FrmEmailStats.php b/classes/models/FrmEmailStats.php index a81331a289..0d5566e000 100644 --- a/classes/models/FrmEmailStats.php +++ b/classes/models/FrmEmailStats.php @@ -92,8 +92,7 @@ protected function get_inner_content() { } protected function get_content_args() { - $args = parent::get_content_args(); - + $args = parent::get_content_args(); $entries_count = FrmEmailSummaryHelper::get_entries_count( $this->from_date, $this->to_date ); $entries_stat = array( 'entries' => array( diff --git a/classes/models/FrmEmailSummary.php b/classes/models/FrmEmailSummary.php index 429c4f2d58..0a035a7cd4 100644 --- a/classes/models/FrmEmailSummary.php +++ b/classes/models/FrmEmailSummary.php @@ -192,8 +192,7 @@ public function send() { $subject = $this->get_subject(); $headers = $this->get_headers(); - - $sent = wp_mail( $recipients, $subject, $content, $headers ); + $sent = wp_mail( $recipients, $subject, $content, $headers ); if ( ! $sent ) { $headers = implode( "\r\n", $headers ); diff --git a/classes/models/FrmEntry.php b/classes/models/FrmEntry.php index bfcd517f75..01ee2d08d2 100644 --- a/classes/models/FrmEntry.php +++ b/classes/models/FrmEntry.php @@ -278,8 +278,7 @@ private static function is_duplicate_check_needed( $values, $duplicate_entry_tim public static function duplicate( $id ) { global $wpdb; - $values = self::getOne( $id ); - + $values = self::getOne( $id ); $new_values = array(); $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); $new_values['name'] = $values->name; @@ -345,8 +344,7 @@ private static function update_entry( $id, $values, $update_type ) { return false; } - $new_values = self::package_entry_to_update( $id, $values ); - + $new_values = self::package_entry_to_update( $id, $values ); $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) ); self::after_update_entry( $query_results, $id, $values, $new_values ); @@ -603,8 +601,7 @@ public static function exists( $id ) { } $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'item_key' => $id ); - - $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); + $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); return $id && $id > 0; } @@ -621,8 +618,7 @@ public static function exists( $id ) { public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { global $wpdb; - $limit = FrmDb::esc_limit( $limit ); - + $limit = FrmDb::esc_limit( $limit ); $cache_key = FrmAppHelper::maybe_json_encode( $where ) . $order_by . $limit . $inc_form; $entries = wp_cache_get( $cache_key, 'frm_entry' ); @@ -713,8 +709,7 @@ public static function getAll( $where, $order_by = '', $limit = '', $meta = fals */ private static function sort_by_field( $field_id ) { global $wpdb; - $field_id = (int) $field_id; - + $field_id = (int) $field_id; $field_options = FrmDb::get_var( 'frm_fields', array( 'id' => $field_id ), 'field_options' ); FrmAppHelper::unserialize_or_decode( $field_options ); diff --git a/classes/models/FrmEntryFormatter.php b/classes/models/FrmEntryFormatter.php index 1503f4e7ff..655316ba73 100644 --- a/classes/models/FrmEntryFormatter.php +++ b/classes/models/FrmEntryFormatter.php @@ -172,8 +172,7 @@ protected function init_entry_values( $atts ) { * @return array */ protected function prepare_entry_attributes( $atts ) { - $entry_atts = array(); - + $entry_atts = array(); $conditionally_add = array( 'include_fields', 'fields', 'exclude_fields', 'entry' ); foreach ( $conditionally_add as $index ) { diff --git a/classes/models/FrmEntryMeta.php b/classes/models/FrmEntryMeta.php index 18d6885265..c0e97a3ada 100644 --- a/classes/models/FrmEntryMeta.php +++ b/classes/models/FrmEntryMeta.php @@ -29,8 +29,7 @@ public static function add_entry_meta( $entry_id, $field_id, $meta_key, $meta_va ); self::set_value_before_save( $new_values ); - $new_values = apply_filters( 'frm_add_entry_meta', $new_values ); - + $new_values = apply_filters( 'frm_add_entry_meta', $new_values ); $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); if ( $query_results ) { @@ -294,8 +293,7 @@ public static function get_entry_meta_by_field( $entry_id, $field_id ) { $query['fi.field_key'] = $field_id; } - $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); - + $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); $field_type = FrmField::get_type( $field_id ); FrmFieldsHelper::prepare_field_value( $result, $field_type ); @@ -318,11 +316,9 @@ public static function get_entry_metas_for_field( $field_id, $order = '', $limit 'is_draft' => false, ); $args = wp_parse_args( $args, $defaults ); - - $query = array(); + $query = array(); self::meta_field_query( $field_id, $order, $limit, $args, $query ); - $query = implode( ' ', $query ); - + $query = implode( ' ', $query ); $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . FrmAppHelper::maybe_json_encode( $args ); $values = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_col' ); @@ -430,11 +426,9 @@ public static function getEntryIds( $where = array(), $order_by = '', $limit = ' 'group_by' => '', ); $args = wp_parse_args( $args, $defaults ); - - $query = array(); + $query = array(); self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query ); - $query = implode( ' ', $query ); - + $query = implode( ' ', $query ); $cache_key = 'ids_' . FrmAppHelper::maybe_json_encode( $where ) . $order_by . 'l' . $limit . 'u' . $unique . FrmAppHelper::maybe_json_encode( $args ); $type = 'get_' . ( ' LIMIT 1' === $limit ? 'var' : 'col' ); return FrmDb::check_cache( $cache_key, 'frm_entry', $query, $type ); @@ -521,8 +515,7 @@ private static function get_ids_query( $where, $order_by, $limit, $unique, $args $query[] = 'it.item_id'; } - $from = 'FROM ' . $wpdb->prefix . 'frm_item_metas it'; - + $from = 'FROM ' . $wpdb->prefix . 'frm_item_metas it'; $should_join_fields_table__where = self::should_join_fields_table( $where ); $should_join_fields_table__order_by = self::should_join_fields_table( $order_by ); diff --git a/classes/models/FrmEntryShortcodeFormatter.php b/classes/models/FrmEntryShortcodeFormatter.php index feecae1278..0c3e1818b7 100644 --- a/classes/models/FrmEntryShortcodeFormatter.php +++ b/classes/models/FrmEntryShortcodeFormatter.php @@ -265,8 +265,7 @@ protected function generate_field_content( $field ) { * @return string */ protected function generate_two_cell_shortcode_row( $field, $value = null ) { - $row = '[if ' . $field->id . ']'; - + $row = '[if ' . $field->id . ']'; $label = '[' . $field->id . ' show=field_label]'; if ( $value === null ) { diff --git a/classes/models/FrmEntryValidate.php b/classes/models/FrmEntryValidate.php index c5ac10264f..fda938daae 100644 --- a/classes/models/FrmEntryValidate.php +++ b/classes/models/FrmEntryValidate.php @@ -148,8 +148,7 @@ public static function validate_field( $posted_field, &$errors, $values, $args = 'exclude' => array(), ); - $args = wp_parse_args( $args, $defaults ); - + $args = wp_parse_args( $args, $defaults ); $value = empty( $args['parent_field_id'] ) ? ( $values['item_meta'][ $args['id'] ] ?? '' ) : $values; // Check for values in "Other" fields diff --git a/classes/models/FrmField.php b/classes/models/FrmField.php index 37ad36d54c..4d98ecf147 100644 --- a/classes/models/FrmField.php +++ b/classes/models/FrmField.php @@ -367,8 +367,7 @@ private static function field_is_new( $type ) { return false; } - $release_date = $release_dates[ $type ]; - + $release_date = $release_dates[ $type ]; $three_months_after_release = gmdate( 'Y-m-d', strtotime( $release_date . ' + 90 days' ) ); return gmdate( 'Y-m-d' ) < $three_months_after_release; } @@ -561,8 +560,7 @@ public static function duplicate_single_field( $field_id, $form_id ) { 'id' => $copy_field->id, ); FrmFieldsHelper::fill_field( $values, $copy_field, $copy_field->form_id ); - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); - + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); $field_id = self::create( $values ); /** @@ -708,8 +706,7 @@ public static function update( $id, $values ) { } $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) ); - - $form_id = 0; + $form_id = 0; if ( isset( $values['form_id'] ) ) { $form_id = absint( $values['form_id'] ); @@ -1084,8 +1081,7 @@ public static function getAll( $where = array(), $order_by = '', $limit = '', $b global $wpdb; if ( $blog_id && is_multisite() ) { - $prefix = $wpdb->get_blog_prefix( $blog_id ); - + $prefix = $wpdb->get_blog_prefix( $blog_id ); $table_name = $prefix . 'frm_fields'; $form_table_name = $prefix . 'frm_forms'; } else { @@ -1097,8 +1093,7 @@ public static function getAll( $where = array(), $order_by = '', $limit = '', $b $order_by = ' ORDER BY ' . $order_by; } - $limit = FrmDb::esc_limit( $limit ); - + $limit = FrmDb::esc_limit( $limit ); $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi JOIN {$form_table_name} fr ON fi.form_id=fr.id"; $query_type = $limit === ' LIMIT 1' || $limit == 1 ? 'row' : 'results'; // phpcs:ignore Universal.Operators.StrictComparisons diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php index 3459c3681b..2e8f4e32d4 100644 --- a/classes/models/FrmFieldFormHtml.php +++ b/classes/models/FrmFieldFormHtml.php @@ -426,8 +426,7 @@ private function replace_shortcodes_with_atts() { foreach ( $shortcodes[0] as $short_key => $tag ) { $shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key ); - - $replace_with = ''; + $replace_with = ''; if ( $tag === 'deletelink' && FrmAppHelper::pro_is_installed() ) { $replace_with = FrmProEntriesController::entry_delete_link( $shortcode_atts ); diff --git a/classes/models/FrmForm.php b/classes/models/FrmForm.php index 7bc7b93d2b..57cbc9f9c9 100644 --- a/classes/models/FrmForm.php +++ b/classes/models/FrmForm.php @@ -264,8 +264,7 @@ public static function update( $id, $values, $create_link = false ) { } $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); - - $new_values = self::set_update_options( array(), $values, array( 'form_id' => $id ) ); + $new_values = self::set_update_options( array(), $values, array( 'form_id' => $id ) ); foreach ( $values as $value_key => $value ) { if ( $value_key && in_array( $value_key, $form_fields, true ) ) { @@ -480,7 +479,6 @@ private static function sanitize_field_opt( $opt, &$value ) { } $value = $opt === 'calc' ? self::sanitize_calc( $value ) : FrmAppHelper::kses( $value, 'all' ); - $value = trim( $value ); } @@ -874,8 +872,7 @@ public static function getOne( $id, $blog_id = false ) { } } - $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'form_key' => $id ); - + $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'form_key' => $id ); $results = FrmDb::get_row( $table_name, $where ); if ( isset( $results->options ) ) { @@ -979,8 +976,7 @@ public static function get_published_forms( $query = array(), $limit = 999, $inc */ public static function get_count() { $cache_key = 'frm_form_counts'; - - $counts = wp_cache_get( $cache_key, 'frm_form' ); + $counts = wp_cache_get( $cache_key, 'frm_form' ); if ( false !== $counts ) { return $counts; diff --git a/classes/models/FrmFormAction.php b/classes/models/FrmFormAction.php index fe932ff7a3..de8ea0ec2f 100644 --- a/classes/models/FrmFormAction.php +++ b/classes/models/FrmFormAction.php @@ -616,8 +616,7 @@ public static function get_action_for_form( $form_id, $type = 'all', $atts = arr self::prepare_get_action( $atts ); - $limit = self::get_action_limit( $form_id, $atts['limit'] ); - + $limit = self::get_action_limit( $form_id, $atts['limit'] ); $args = self::action_args( $form_id, $limit ); $args['post_status'] = $atts['post_status']; $actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' ); diff --git a/classes/models/FrmFormMigrator.php b/classes/models/FrmFormMigrator.php index b9a2224640..8903d11e4a 100644 --- a/classes/models/FrmFormMigrator.php +++ b/classes/models/FrmFormMigrator.php @@ -277,7 +277,6 @@ protected function prepare_fields( $fields, &$form ) { foreach ( $fields as $field ) { $field = (array) $field; - $label = $this->get_field_label( $field ); $type = $this->get_field_type( $field ); @@ -292,8 +291,7 @@ protected function prepare_fields( $fields, &$form ) { continue; } - $new_type = $this->convert_field_type( $type, $field ); - + $new_type = $this->convert_field_type( $type, $field ); $new_field = FrmFieldsHelper::setup_new_vars( $new_type ); $new_field['name'] = $label; $new_field['field_order'] = $field_order; @@ -364,8 +362,7 @@ protected function maybe_add_end_fields( &$fields ) { return; } - $open = array(); - + $open = array(); $order = 0; foreach ( $fields as $field ) { diff --git a/classes/models/FrmHoneypot.php b/classes/models/FrmHoneypot.php index fba133b816..2234a7c71d 100644 --- a/classes/models/FrmHoneypot.php +++ b/classes/models/FrmHoneypot.php @@ -122,8 +122,7 @@ public static function maybe_render_field( $form_id ) { global $frm_vars; $offset = isset( $frm_vars['honeypot_selectors'] ) ? count( $frm_vars['honeypot_selectors'] ) + 1 : 1; $honeypot_field_id = $max_field_id ? $max_field_id + $offset : $offset; - - $class = class_exists( 'FrmProFormState' ) ? 'FrmProFormState' : 'FrmFormState'; + $class = class_exists( 'FrmProFormState' ) ? 'FrmProFormState' : 'FrmFormState'; $class::set_initial_value( 'honeypot_field_id', $honeypot_field_id ); $honeypot->render_field( $honeypot_field_id ); diff --git a/classes/models/FrmMigrate.php b/classes/models/FrmMigrate.php index 4404a30415..553cd051f6 100644 --- a/classes/models/FrmMigrate.php +++ b/classes/models/FrmMigrate.php @@ -358,8 +358,7 @@ private function add_default_template() { $set_err = libxml_use_internal_errors( true ); $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true ); - - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml'; + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml'; FrmXMLHelper::import_xml( $file ); libxml_use_internal_errors( $set_err ); @@ -680,8 +679,7 @@ private function maybe_convert_migrated_size( &$size ) { } $pixel_conversion = 9; - - $size = round( (int) $int_size / $pixel_conversion ); + $size = round( (int) $int_size / $pixel_conversion ); } /** @@ -782,9 +780,8 @@ private function adjust_widget_size() { */ private function convert_character_to_px( &$size ) { $pixel_conversion = 9; - - $size = round( $pixel_conversion * (int) $size ); - $size .= 'px'; + $size = round( $pixel_conversion * (int) $size ); + $size .= 'px'; } /** @@ -840,8 +837,7 @@ private function migrate_to_16() { private function migrate_to_11() { global $wpdb; - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); - + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); $sending = __( 'Sending', 'formidable' ); $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; $old_default_html = << $this->get_current_page(), ); - $user = get_user_by( 'email', $email ); - + $user = get_user_by( 'email', $email ); $entries_by_email = FrmDb::get_col( 'frm_item_metas', array( 'meta_value' => $email ), 'item_id', $query_args ); if ( ! $user ) { @@ -158,8 +157,7 @@ private function get_user_entries( $email ) { $query_args['order_by'] = 'id ASC'; $entries_by_user = FrmDb::get_col( 'frm_items', array( 'user_id' => $user->ID ), 'id', $query_args ); - - $entry_ids = array_merge( $entries_by_user, $entries_by_email ); + $entry_ids = array_merge( $entries_by_user, $entries_by_email ); return array_unique( array_filter( $entry_ids ) ); } @@ -179,8 +177,7 @@ private function get_current_page() { * @return array */ private function prepare_entry_data( $entry ) { - $entry = FrmEntry::getOne( $entry, true ); - + $entry = FrmEntry::getOne( $entry, true ); $entry_data = array(); foreach ( $entry->metas as $field_id => $meta ) { diff --git a/classes/models/FrmPluginSearch.php b/classes/models/FrmPluginSearch.php index 3ceb1bbef5..f90cc6c40f 100644 --- a/classes/models/FrmPluginSearch.php +++ b/classes/models/FrmPluginSearch.php @@ -130,8 +130,7 @@ private function matching_addon( $addon_list, $normalized_term ) { $addon_opts['search_terms'] = ''; } - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] ); - + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] ); $matched_terms = array_intersect( $addon_terms, $normalized_term ); if ( count( $matched_terms ) === count( $normalized_term ) ) { diff --git a/classes/models/FrmReviews.php b/classes/models/FrmReviews.php index e8c436d43a..a43b42bd90 100644 --- a/classes/models/FrmReviews.php +++ b/classes/models/FrmReviews.php @@ -106,8 +106,7 @@ private function review() { } $entries = $entries <= 100 ? floor( $entries / 10 ) * 10 : floor( $entries / 50 ) * 50; - - $name = $user->first_name; + $name = $user->first_name; if ( $name ) { $name = ' ' . $name; diff --git a/classes/models/FrmSolution.php b/classes/models/FrmSolution.php index 77d69020e0..ad9f6d9efb 100644 --- a/classes/models/FrmSolution.php +++ b/classes/models/FrmSolution.php @@ -231,8 +231,7 @@ public function settings_page() { return; } - $all_imported = $this->is_complete( 'all' ); - + $all_imported = $this->is_complete( 'all' ); $step = $steps['import']; $step['label'] = ''; $step['nested'] = true; @@ -561,9 +560,8 @@ protected function show_app_install( $step ) { $this->step_top( $step ); - $api = new FrmFormApi(); - $addons = $api->get_api_info(); - + $api = new FrmFormApi(); + $addons = $api->get_api_info(); $id = $this->download_id(); $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] ); diff --git a/classes/models/FrmSpamCheckStopForumSpam.php b/classes/models/FrmSpamCheckStopForumSpam.php index dd98e90054..e42c4d49e0 100644 --- a/classes/models/FrmSpamCheckStopForumSpam.php +++ b/classes/models/FrmSpamCheckStopForumSpam.php @@ -89,8 +89,7 @@ private function send_request( $request_data ) { */ $api_url = apply_filters( 'frm_stopforumspam_api_url', 'https://api.stopforumspam.org/api', array( 'values' => $this->values ) ); - $url = add_query_arg( $request_data, $api_url ); - + $url = add_query_arg( $request_data, $api_url ); $response = wp_remote_get( $url, array( 'timeout' => 15 ) ); return wp_remote_retrieve_body( $response ); diff --git a/classes/models/FrmStyle.php b/classes/models/FrmStyle.php index d4de9a2b3d..3b4ad7f2a9 100644 --- a/classes/models/FrmStyle.php +++ b/classes/models/FrmStyle.php @@ -192,7 +192,6 @@ private function maybe_sanitize_rgba_value( &$color_val ) { // phpcs:ignore Slev // Remove all leading ')' braces, then add one back. This way there's always a single brace. $color_val = rtrim( $color_val, ')' ); $color_val .= ')'; - $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 ); // Remove any excessive braces from the rgba like rgba((. $color_rgba = trim( $color_rgba, '()' ); @@ -249,7 +248,6 @@ private function maybe_sanitize_rgba_value( &$color_val ) { // phpcs:ignore Slev // Limit the number of opening braces after rgb/rgba. There should only be one. $prefix = rtrim( $prefix, '(' ) . '('; $new_color = $prefix . $new_color . ')'; - $color_val = $new_color; } @@ -432,8 +430,7 @@ public function save_settings() { * @return string */ private function get_css_content( $filename ) { - $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; - + $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; $saving = true; $frm_style = $this; @@ -546,8 +543,7 @@ public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { $default_values = $this->get_defaults(); $default_style = false; - - $styles = array(); + $styles = array(); foreach ( $temp_styles as $style ) { $this->id = $style->ID; diff --git a/classes/models/FrmTableHTMLGenerator.php b/classes/models/FrmTableHTMLGenerator.php index a6abeefd6e..8310249726 100644 --- a/classes/models/FrmTableHTMLGenerator.php +++ b/classes/models/FrmTableHTMLGenerator.php @@ -372,10 +372,9 @@ public function generate_table_footer() { * @return string */ public function generate_two_cell_table_row( $label, $value, $args = array() ) { - $row = 'tr_style(); - $row .= $this->add_row_class( $value === '' ); - $row .= '>'; - + $row = 'tr_style(); + $row .= $this->add_row_class( $value === '' ); + $row .= '>'; $label = 'td_style . '>' . wp_kses_post( $label ) . ''; $value = 'td_style . '>' . $this->filter_value_for_display( $value, $args ) . ''; diff --git a/classes/models/FrmUsage.php b/classes/models/FrmUsage.php index a4854278d7..7daf1b6e46 100644 --- a/classes/models/FrmUsage.php +++ b/classes/models/FrmUsage.php @@ -186,8 +186,7 @@ private function payments( $table = 'frm_payments' ) { */ private function plugins() { $plugin_list = FrmAppHelper::get_plugins(); - - $plugins = array(); + $plugins = array(); foreach ( $plugin_list as $slug => $info ) { $plugins[] = array( @@ -272,8 +271,7 @@ private function messages( $settings_list ) { 'admin_permission', ); - $default = $settings_list->default_options(); - + $default = $settings_list->default_options(); $message_settings = array(); foreach ( $messages as $message ) { @@ -471,8 +469,7 @@ private function actions() { 'numberposts' => 100, ); - $actions = array(); - + $actions = array(); $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' ); foreach ( $saved_actions as $action ) { diff --git a/classes/models/fields/FrmFieldCaptcha.php b/classes/models/fields/FrmFieldCaptcha.php index 7c06594f08..16b8827682 100644 --- a/classes/models/fields/FrmFieldCaptcha.php +++ b/classes/models/fields/FrmFieldCaptcha.php @@ -203,8 +203,7 @@ protected function recaptcha_api_url( $frm_settings ) { */ protected function hcaptcha_api_url() { $api_js_url = 'https://js.hcaptcha.com/1/api.js'; - - $lang = $this->get_captcha_language(); + $lang = $this->get_captcha_language(); if ( $lang ) { // Language might be in the format of en-US, fr-FR, etc. In that case, we need to extract the first part to comply with the hcaptcha api request format. diff --git a/classes/models/fields/FrmFieldCombo.php b/classes/models/fields/FrmFieldCombo.php index 3c969a5914..ccbdbe8763 100644 --- a/classes/models/fields/FrmFieldCombo.php +++ b/classes/models/fields/FrmFieldCombo.php @@ -436,8 +436,7 @@ public function validate( $args ) { return $errors; } - $blank_msg = FrmFieldsHelper::get_error_msg( $this->field, 'blank' ); - + $blank_msg = FrmFieldsHelper::get_error_msg( $this->field, 'blank' ); $sub_fields = $this->get_processed_sub_fields(); // Validate not empty. diff --git a/classes/models/fields/FrmFieldName.php b/classes/models/fields/FrmFieldName.php index e33f2eac52..bc2a25c922 100644 --- a/classes/models/fields/FrmFieldName.php +++ b/classes/models/fields/FrmFieldName.php @@ -64,8 +64,7 @@ protected function get_processed_sub_fields() { $name_layout = $this->get_name_layout(); $names = explode( '_', $name_layout ); $col_class = 'frm' . intval( 12 / count( $names ) ); - - $result = array(); + $result = array(); foreach ( $names as $name ) { if ( empty( $this->sub_fields[ $name ] ) ) { @@ -334,8 +333,7 @@ public static function track_first_name_field( $fields ) { * @return array */ protected function get_sub_field_input_attrs( $sub_field, $args ) { - $attrs = parent::get_sub_field_input_attrs( $sub_field, $args ); - + $attrs = parent::get_sub_field_input_attrs( $sub_field, $args ); $form_id = (int) ( is_array( $args['field'] ) ? $args['field']['form_id'] : $args['field']->form_id ); if ( ! self::$first_name_field_ids || empty( self::$first_name_field_ids[ $form_id ] ) ) { diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php index d8e8a6ffa3..1986063400 100644 --- a/classes/models/fields/FrmFieldType.php +++ b/classes/models/fields/FrmFieldType.php @@ -335,8 +335,7 @@ protected function include_form_builder_file() { * @return string */ protected function builder_text_field( $name = '' ) { - $read_only = FrmField::get_option( $this->field, 'read_only' ); - + $read_only = FrmField::get_option( $this->field, 'read_only' ); $placeholder = FrmField::get_option( $this->field, 'placeholder' ); if ( is_array( $placeholder ) ) { @@ -814,8 +813,7 @@ public function default_value_to_string( &$default_value ) { return; } - $is_empty = array_filter( $default_value ); - + $is_empty = array_filter( $default_value ); $default_value = $is_empty === array() ? '' : implode( ',', $default_value ); } @@ -1070,8 +1068,7 @@ public function get_container_class() { $is_radio = FrmField::is_radio( $this->field ); $is_checkbox = FrmField::is_checkbox( $this->field ); $align = FrmField::get_option( $this->field, 'align' ); - - $class = ''; + $class = ''; if ( $align && ( $is_radio || $is_checkbox ) ) { self::prepare_align_class( $align ); @@ -1549,13 +1546,10 @@ protected function get_field_input_html_hook( $field ) { */ protected function add_aria_description( $args, &$input_html ) { $aria_describedby_exists = preg_match_all( '/aria-describedby=\"([^\"]*)\"/', $input_html, $matches ) === 1; - - $describedby = $aria_describedby_exists ? preg_split( '/\s+/', esc_attr( trim( $matches[1][0] ) ) ) : array(); - - $error_comes_first = true; - - $custom_error_fields = preg_grep( '/frm_error_field_*/', $describedby ); - $custom_desc_fields = preg_grep( '/frm_desc_field_*/', $describedby ); + $describedby = $aria_describedby_exists ? preg_split( '/\s+/', esc_attr( trim( $matches[1][0] ) ) ) : array(); + $error_comes_first = true; + $custom_error_fields = preg_grep( '/frm_error_field_*/', $describedby ); + $custom_desc_fields = preg_grep( '/frm_desc_field_*/', $describedby ); if ( $custom_desc_fields && $custom_error_fields ) { if ( array_key_first( $custom_error_fields ) > array_key_first( $custom_desc_fields ) ) { @@ -1885,9 +1879,8 @@ protected function get_multi_opts_for_import( $value ) { if ( ! is_array( $checked ) ) { $filtered_checked = $checked; $csv_values_checked = array(); - - $options = (array) $this->field->options; - $options = array_reverse( $options ); + $options = (array) $this->field->options; + $options = array_reverse( $options ); foreach ( $options as $option ) { if ( isset( $option['value'] ) && str_contains( $filtered_checked, $option['value'] ) ) { @@ -1897,8 +1890,7 @@ protected function get_multi_opts_for_import( $value ) { } $csv_values_checked = array_reverse( $csv_values_checked ); - - $checked = array_merge( $csv_values_checked, array_filter( explode( ',', $filtered_checked ) ) ); + $checked = array_merge( $csv_values_checked, array_filter( explode( ',', $filtered_checked ) ) ); } if ( count( $checked ) > 1 ) { diff --git a/classes/views/frm-entries/_sidebar-shared-pub.php b/classes/views/frm-entries/_sidebar-shared-pub.php index 86c1779f19..d9d98a1ea0 100644 --- a/classes/views/frm-entries/_sidebar-shared-pub.php +++ b/classes/views/frm-entries/_sidebar-shared-pub.php @@ -14,7 +14,6 @@ "> diff --git a/classes/views/frm-fields/front-end/dropdown-field.php b/classes/views/frm-fields/front-end/dropdown-field.php index 90e5969052..c9039488d6 100644 --- a/classes/views/frm-fields/front-end/dropdown-field.php +++ b/classes/views/frm-fields/front-end/dropdown-field.php @@ -27,8 +27,7 @@ diff --git a/classes/views/frm-form-actions/form_action.php b/classes/views/frm-form-actions/form_action.php index 84d9d986b7..dc7e66e1f3 100644 --- a/classes/views/frm-form-actions/form_action.php +++ b/classes/views/frm-form-actions/form_action.php @@ -3,8 +3,7 @@ die( 'You are not allowed to call this page directly.' ); } -$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' ); - +$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' ); $form_action = apply_filters( 'frm_form_action_settings', $form_action, $form_action->post_excerpt ); $form_action = apply_filters( 'frm_form_' . $form_action->post_excerpt . '_action_settings', $form_action ); diff --git a/classes/views/shared/mb_adv_info.php b/classes/views/shared/mb_adv_info.php index 8190f38d14..13a8043194 100644 --- a/classes/views/shared/mb_adv_info.php +++ b/classes/views/shared/mb_adv_info.php @@ -238,8 +238,7 @@ } foreach ( $helper['codes'] as $code => $code_label ) { - $code = isset( $uid ) ? str_replace( '|user_id|', $uid, $code ) : str_replace( '|user_id|', 'x', $code ); - + $code = isset( $uid ) ? str_replace( '|user_id|', $uid, $code ) : str_replace( '|user_id|', 'x', $code ); $include_x = strpos( $code, ' ' ) ? '' : 'x '; if ( ! is_array( $code_label ) ) { diff --git a/classes/views/shared/toggle.php b/classes/views/shared/toggle.php index 15fbdc580c..477e0ffb62 100644 --- a/classes/views/shared/toggle.php +++ b/classes/views/shared/toggle.php @@ -14,16 +14,15 @@ } ?> diff --git a/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php new file mode 100644 index 0000000000..dfa4851d62 --- /dev/null +++ b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php @@ -0,0 +1,312 @@ +getTokens(); + + // Check if this is a simple assignment (variable at start of statement). + if ( ! $this->isSimpleAssignmentStart( $phpcsFile, $stackPtr ) ) { + return; + } + + // Find the end of this assignment (the semicolon). + $semicolon = $this->findAssignmentEnd( $phpcsFile, $stackPtr ); + + if ( false === $semicolon ) { + return; + } + + // Check if this assignment spans multiple lines (not simple). + if ( ! $this->isSingleLineAssignment( $phpcsFile, $stackPtr, $semicolon ) ) { + return; + } + + // Look for the next statement. + $nextStatement = $this->findNextStatement( $phpcsFile, $semicolon ); + + if ( false === $nextStatement ) { + return; + } + + // Check if the next statement is also a simple one-line assignment. + if ( ! $this->isSimpleAssignmentStart( $phpcsFile, $nextStatement ) ) { + return; + } + + $nextSemicolon = $this->findAssignmentEnd( $phpcsFile, $nextStatement ); + + if ( false === $nextSemicolon ) { + return; + } + + if ( ! $this->isSingleLineAssignment( $phpcsFile, $nextStatement, $nextSemicolon ) ) { + return; + } + + // Check if there are blank lines between the two assignments. + $currentLine = $tokens[ $semicolon ]['line']; + $nextLine = $tokens[ $nextStatement ]['line']; + + // If there's more than one line difference, there are blank lines. + if ( $nextLine - $currentLine <= 1 ) { + return; + } + + $fix = $phpcsFile->addFixableError( + 'Blank lines found between consecutive simple assignments. Remove blank lines to group related assignments.', + $nextStatement, + 'BlankLineBetweenAssignments' + ); + + if ( true === $fix ) { + $this->removeBlankLines( $phpcsFile, $semicolon, $nextStatement ); + } + } + + /** + * Check if the token is the start of a simple variable assignment. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the variable token. + * + * @return bool + */ + private function isSimpleAssignmentStart( File $phpcsFile, $stackPtr ) { + $tokens = $phpcsFile->getTokens(); + + // Must be a variable. + if ( $tokens[ $stackPtr ]['code'] !== T_VARIABLE ) { + return false; + } + + // Check what's before the variable - should be start of statement. + $prevToken = $phpcsFile->findPrevious( T_WHITESPACE, $stackPtr - 1, null, true ); + + if ( false === $prevToken ) { + return true; + } + + // Valid tokens before a statement-starting variable. + $validBefore = array( + T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET, + T_SEMICOLON, + T_COLON, + T_OPEN_TAG, + T_CLOSE_TAG, + ); + + if ( ! in_array( $tokens[ $prevToken ]['code'], $validBefore, true ) ) { + return false; + } + + // Check what's after the variable - should be an assignment operator. + $nextToken = $phpcsFile->findNext( T_WHITESPACE, $stackPtr + 1, null, true ); + + if ( false === $nextToken ) { + return false; + } + + // Must be followed by an assignment operator. + $assignmentOps = array( + \T_EQUAL, + \T_PLUS_EQUAL, + \T_MINUS_EQUAL, + \T_MUL_EQUAL, + \T_DIV_EQUAL, + \T_CONCAT_EQUAL, + \T_COALESCE_EQUAL, + ); + + return in_array( $tokens[ $nextToken ]['code'], $assignmentOps, true ); + } + + /** + * Find the semicolon that ends this assignment. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the variable token. + * + * @return false|int + */ + private function findAssignmentEnd( File $phpcsFile, $stackPtr ) { + $tokens = $phpcsFile->getTokens(); + + // Find the semicolon, but be careful of nested structures. + $nestingLevel = 0; + + for ( $i = $stackPtr; $i < $phpcsFile->numTokens; $i++ ) { + $code = $tokens[ $i ]['code']; + + if ( in_array( $code, array( T_OPEN_PARENTHESIS, T_OPEN_SQUARE_BRACKET, T_OPEN_CURLY_BRACKET ), true ) ) { + ++$nestingLevel; + } elseif ( in_array( $code, array( T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET ), true ) ) { + --$nestingLevel; + } elseif ( $code === T_SEMICOLON && $nestingLevel === 0 ) { + return $i; + } + } + + return false; + } + + /** + * Check if the assignment is on a single line. + * + * @param File $phpcsFile The file being scanned. + * @param int $startPtr The position of the variable token. + * @param int $endPtr The position of the semicolon. + * + * @return bool + */ + private function isSingleLineAssignment( File $phpcsFile, $startPtr, $endPtr ) { + $tokens = $phpcsFile->getTokens(); + $startLine = $tokens[ $startPtr ]['line']; + $endLine = $tokens[ $endPtr ]['line']; + + return $startLine === $endLine; + } + + /** + * Find the next statement after the semicolon. + * + * @param File $phpcsFile The file being scanned. + * @param int $semicolon The position of the semicolon. + * + * @return false|int + */ + private function findNextStatement( File $phpcsFile, $semicolon ) { + $tokens = $phpcsFile->getTokens(); + + // Skip whitespace and comments to find the next meaningful token. + $skip = array( + T_WHITESPACE, + T_COMMENT, + T_DOC_COMMENT, + T_DOC_COMMENT_OPEN_TAG, + T_DOC_COMMENT_CLOSE_TAG, + T_DOC_COMMENT_STAR, + T_DOC_COMMENT_STRING, + T_DOC_COMMENT_TAG, + T_DOC_COMMENT_WHITESPACE, + ); + + $next = $phpcsFile->findNext( $skip, $semicolon + 1, null, true ); + + if ( false === $next ) { + return false; + } + + // If there's a comment between the statements, don't flag this. + for ( $i = $semicolon + 1; $i < $next; $i++ ) { + if ( in_array( $tokens[ $i ]['code'], array( T_COMMENT, T_DOC_COMMENT, T_DOC_COMMENT_OPEN_TAG ), true ) ) { + return false; + } + } + + // Must be a variable for us to consider it. + if ( $tokens[ $next ]['code'] !== T_VARIABLE ) { + return false; + } + + return $next; + } + + /** + * Remove blank lines between two tokens. + * + * @param File $phpcsFile The file being scanned. + * @param int $semicolon The position of the first semicolon. + * @param int $nextStatement The position of the next statement. + * + * @return void + */ + private function removeBlankLines( File $phpcsFile, $semicolon, $nextStatement ) { + $tokens = $phpcsFile->getTokens(); + + $phpcsFile->fixer->beginChangeset(); + + // Get the indentation of the next statement. + $indent = ''; + + if ( $tokens[ $nextStatement ]['column'] > 1 ) { + // Look at the whitespace token right before the next statement to determine indent style. + $prevToken = $nextStatement - 1; + + if ( $tokens[ $prevToken ]['code'] === T_WHITESPACE ) { + $wsContent = $tokens[ $prevToken ]['content']; + + // Extract just the indentation part (after the last newline). + $lastNewline = strrpos( $wsContent, "\n" ); + + if ( false !== $lastNewline ) { + $indent = substr( $wsContent, $lastNewline + 1 ); + } else { + $indent = $wsContent; + } + } + } + + // Replace all whitespace between semicolon and next statement with single newline + indent. + $first = true; + + for ( $i = $semicolon + 1; $i < $nextStatement; $i++ ) { + if ( $tokens[ $i ]['code'] === T_WHITESPACE ) { + if ( $first ) { + $phpcsFile->fixer->replaceToken( $i, "\n" . $indent ); + $first = false; + } else { + $phpcsFile->fixer->replaceToken( $i, '' ); + } + } + } + + $phpcsFile->fixer->endChangeset(); + } +} diff --git a/phpcs.xml b/phpcs.xml index e3fdaa452c..caa289b488 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -282,6 +282,7 @@ + diff --git a/square/controllers/FrmSquareLiteActionsController.php b/square/controllers/FrmSquareLiteActionsController.php index cae084869c..98665b8865 100644 --- a/square/controllers/FrmSquareLiteActionsController.php +++ b/square/controllers/FrmSquareLiteActionsController.php @@ -107,8 +107,7 @@ public static function trigger_gateway( $action, $entry, $form ) { 'show_errors' => true, ); $atts = compact( 'action', 'entry', 'form' ); - - $amount = self::prepare_amount( $action->post_content['amount'], $atts ); + $amount = self::prepare_amount( $action->post_content['amount'], $atts ); // phpcs:ignore Universal.Operators.StrictComparisons if ( ! $amount || $amount == 000 ) { diff --git a/square/controllers/FrmSquareLiteAppController.php b/square/controllers/FrmSquareLiteAppController.php index b25c955487..0c7ea6f81e 100644 --- a/square/controllers/FrmSquareLiteAppController.php +++ b/square/controllers/FrmSquareLiteAppController.php @@ -136,11 +136,10 @@ public static function get_billing_contact( $action ) { $first_name_setting = $action->post_content['billing_first_name']; $last_name_setting = $action->post_content['billing_last_name']; $address_setting = $action->post_content['billing_address']; - - $entry = self::generate_false_entry(); - $first_name = $first_name_setting && isset( $entry->metas[ $first_name_setting ] ) ? $entry->metas[ $first_name_setting ] : ''; - $last_name = $last_name_setting && isset( $entry->metas[ $last_name_setting ] ) ? $entry->metas[ $last_name_setting ] : ''; - $address = $address_setting && isset( $entry->metas[ $address_setting ] ) ? $entry->metas[ $address_setting ] : ''; + $entry = self::generate_false_entry(); + $first_name = $first_name_setting && isset( $entry->metas[ $first_name_setting ] ) ? $entry->metas[ $first_name_setting ] : ''; + $last_name = $last_name_setting && isset( $entry->metas[ $last_name_setting ] ) ? $entry->metas[ $last_name_setting ] : ''; + $address = $address_setting && isset( $entry->metas[ $address_setting ] ) ? $entry->metas[ $address_setting ] : ''; if ( is_array( $first_name ) && isset( $first_name['first'] ) ) { $first_name = $first_name['first']; diff --git a/square/controllers/FrmSquareLiteEventsController.php b/square/controllers/FrmSquareLiteEventsController.php index 9dc53af9a8..6825406da4 100644 --- a/square/controllers/FrmSquareLiteEventsController.php +++ b/square/controllers/FrmSquareLiteEventsController.php @@ -124,11 +124,9 @@ private function last_attempt_to_process_event_is_too_recent( $event_id ) { * @return void */ private function count_failed_event( $event_id ) { - $transient_name = 'frm_square_failed_event_' . $event_id; - $transient = get_transient( $transient_name ); - - $failed_count = is_int( $transient ) ? $transient + 1 : 1; - + $transient_name = 'frm_square_failed_event_' . $event_id; + $transient = get_transient( $transient_name ); + $failed_count = is_int( $transient ) ? $transient + 1 : 1; $maximum_retries = 3; if ( $failed_count >= $maximum_retries ) { @@ -233,8 +231,7 @@ private function handle_event() { * @return void */ private function add_subscription_payment( $subscription_id ) { - $payment_id = $this->event->data->id; - + $payment_id = $this->event->data->id; $frm_payment = new FrmTransLitePayment(); $payment = $frm_payment->get_one_by( $payment_id, 'receipt_id' ); diff --git a/stripe/controllers/FrmStrpLiteActionsController.php b/stripe/controllers/FrmStrpLiteActionsController.php index 9cc14b5b23..65105a2e83 100644 --- a/stripe/controllers/FrmStrpLiteActionsController.php +++ b/stripe/controllers/FrmStrpLiteActionsController.php @@ -119,8 +119,7 @@ public static function trigger_gateway( $action, $entry, $form ) { 'show_errors' => true, ); $atts = compact( 'action', 'entry', 'form' ); - - $amount = self::prepare_amount( $action->post_content['amount'], $atts ); + $amount = self::prepare_amount( $action->post_content['amount'], $atts ); // phpcs:ignore Universal.Operators.StrictComparisons if ( ! $amount || $amount == 000 ) { diff --git a/stripe/controllers/FrmStrpLiteEventsController.php b/stripe/controllers/FrmStrpLiteEventsController.php index 086947d7ad..c40e67c699 100644 --- a/stripe/controllers/FrmStrpLiteEventsController.php +++ b/stripe/controllers/FrmStrpLiteEventsController.php @@ -527,11 +527,9 @@ private function last_attempt_to_process_event_is_too_recent( $event_id ) { * @return void */ private function count_failed_event( $event_id ) { - $transient_name = 'frm_failed_event_' . $event_id; - $transient = get_transient( $transient_name ); - - $failed_count = is_int( $transient ) ? $transient + 1 : 1; - + $transient_name = 'frm_failed_event_' . $event_id; + $transient = get_transient( $transient_name ); + $failed_count = is_int( $transient ) ? $transient + 1 : 1; $maximum_retries = 3; if ( $failed_count >= $maximum_retries ) { diff --git a/stripe/controllers/FrmStrpLiteLinkController.php b/stripe/controllers/FrmStrpLiteLinkController.php index bd3b547c14..27e43938ec 100644 --- a/stripe/controllers/FrmStrpLiteLinkController.php +++ b/stripe/controllers/FrmStrpLiteLinkController.php @@ -56,8 +56,7 @@ public static function handle_return_url() { private static function handle_one_time_stripe_link_return_url( $intent_id, $client_secret ) { $redirect_helper = new FrmStrpLiteLinkRedirectHelper( $intent_id, $client_secret ); $frm_payment = new FrmTransLitePayment(); - - $payment = $frm_payment->get_one_by( $intent_id, 'receipt_id' ); + $payment = $frm_payment->get_one_by( $intent_id, 'receipt_id' ); if ( ! $payment ) { $redirect_helper->handle_error( 'no_payment_record' ); @@ -437,11 +436,9 @@ private static function verify_intent( $form_id ) { $client_secret = reset( $client_secrets ); list( $prefix, $intent_id ) = explode( '_', $client_secret ); $intent_id = $prefix . '_' . $intent_id; - - $is_setup_intent = str_starts_with( $intent_id, 'seti_' ); - - $function_name = $is_setup_intent ? 'get_setup_intent' : 'get_intent'; - $intent = FrmStrpLiteAppHelper::call_stripe_helper_class( $function_name, $intent_id ); + $is_setup_intent = str_starts_with( $intent_id, 'seti_' ); + $function_name = $is_setup_intent ? 'get_setup_intent' : 'get_intent'; + $intent = FrmStrpLiteAppHelper::call_stripe_helper_class( $function_name, $intent_id ); if ( ! $intent || $intent->client_secret !== $client_secret ) { return false; diff --git a/stripe/controllers/FrmStrpLitePaymentsController.php b/stripe/controllers/FrmStrpLitePaymentsController.php index db95e7d00e..3b09be9722 100644 --- a/stripe/controllers/FrmStrpLitePaymentsController.php +++ b/stripe/controllers/FrmStrpLitePaymentsController.php @@ -23,8 +23,7 @@ public static function get_receipt_link( $receipt ) { $url .= 'payments/'; } - $url .= $receipt; - + $url .= $receipt; $link = ''; $link .= esc_html( $receipt ); return $link . ''; diff --git a/stripe/controllers/FrmTransLiteActionsController.php b/stripe/controllers/FrmTransLiteActionsController.php index c2d8b392a6..c2ff845a43 100755 --- a/stripe/controllers/FrmTransLiteActionsController.php +++ b/stripe/controllers/FrmTransLiteActionsController.php @@ -262,10 +262,8 @@ public static function trigger_actions_after_payment( $payment, $atts = array() return; } - $entry = FrmEntry::getOne( $payment->item_id ); - - $trigger_event = isset( $atts['trigger'] ) ? 'payment-' . $atts['trigger'] : 'payment-' . $payment->status; - + $entry = FrmEntry::getOne( $payment->item_id ); + $trigger_event = isset( $atts['trigger'] ) ? 'payment-' . $atts['trigger'] : 'payment-' . $payment->status; $allowed_triggers = array_keys( self::add_payment_trigger( array() ) ); if ( ! in_array( $trigger_event, $allowed_triggers, true ) ) { @@ -312,8 +310,7 @@ public static function prepare_amount( $amount, $atts = array() ) { } $currency = self::get_currency_for_action( $atts ); - - $total = 0; + $total = 0; foreach ( (array) $amount as $a ) { $this_amount = self::get_amount_from_string( $a ); diff --git a/stripe/controllers/FrmTransLiteAppController.php b/stripe/controllers/FrmTransLiteAppController.php index e1110cfd57..371a331d1f 100755 --- a/stripe/controllers/FrmTransLiteAppController.php +++ b/stripe/controllers/FrmTransLiteAppController.php @@ -59,9 +59,8 @@ public static function remove_cron() { * @return void */ public static function run_payment_cron() { - $frm_sub = new FrmTransLiteSubscription(); - $frm_payment = new FrmTransLitePayment(); - + $frm_sub = new FrmTransLiteSubscription(); + $frm_payment = new FrmTransLitePayment(); $overdue_subscriptions = $frm_sub->get_overdue_subscriptions(); FrmTransLiteLog::log_message( 'Stripe Cron Message', count( $overdue_subscriptions ) . ' subscriptions found to be processed.', false ); diff --git a/stripe/controllers/FrmTransLiteListsController.php b/stripe/controllers/FrmTransLiteListsController.php index 6917e91156..f4022d8b0f 100755 --- a/stripe/controllers/FrmTransLiteListsController.php +++ b/stripe/controllers/FrmTransLiteListsController.php @@ -92,8 +92,7 @@ public static function remove_screen_options( $show_screen, $screen ) { return $show_screen; } - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); - + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); if ( $unread_count ) { @@ -167,17 +166,15 @@ public static function list_page_params() { public static function display_list( $response = array() ) { FrmAppHelper::include_svg(); - $defaults = array( + $defaults = array( 'errors' => array(), 'message' => '', ); - $response = array_merge( $defaults, $response ); - $errors = $response['errors']; - $message = $response['message']; - + $response = array_merge( $defaults, $response ); + $errors = $response['errors']; + $message = $response['message']; $wp_list_table = new FrmTransLiteListHelper( self::list_page_params() ); - - $pagenum = $wp_list_table->get_pagenum(); + $pagenum = $wp_list_table->get_pagenum(); $wp_list_table->prepare_items(); diff --git a/stripe/controllers/FrmTransLitePaymentsController.php b/stripe/controllers/FrmTransLitePaymentsController.php index 05d8cf0f4c..f9a0a7cd23 100755 --- a/stripe/controllers/FrmTransLitePaymentsController.php +++ b/stripe/controllers/FrmTransLitePaymentsController.php @@ -52,10 +52,9 @@ private static function payments_menu_title( $payments_string ) { * @return void */ public static function route() { - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; - $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); - $type = FrmAppHelper::get_param( 'type', '', 'get', 'sanitize_title' ); - + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; + $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); + $type = FrmAppHelper::get_param( 'type', '', 'get', 'sanitize_title' ); $class_name = $type === 'subscriptions' ? 'FrmTransLiteSubscriptionsController' : 'FrmTransLitePaymentsController'; if ( method_exists( $class_name, $action ) ) { @@ -160,11 +159,10 @@ public static function refund_link( $payment ) { $link = esc_html__( 'Refunded', 'formidable' ); } else { $confirm = __( 'Are you sure you want to refund that payment?', 'formidable' ); - - $link = admin_url( 'admin-ajax.php?action=frm_trans_refund&payment_id=' . $payment->id . '&nonce=' . wp_create_nonce( 'frm_trans_ajax' ) ); - $link = ''; - $link .= esc_html__( 'Refund', 'formidable' ); - $link .= ''; + $link = admin_url( 'admin-ajax.php?action=frm_trans_refund&payment_id=' . $payment->id . '&nonce=' . wp_create_nonce( 'frm_trans_ajax' ) ); + $link = ''; + $link .= esc_html__( 'Refund', 'formidable' ); + $link .= ''; } $paysys = $payment->paysys; diff --git a/stripe/helpers/FrmStrpLiteConnectApiAdapter.php b/stripe/helpers/FrmStrpLiteConnectApiAdapter.php index 9b83c20bee..eb4290a2be 100644 --- a/stripe/helpers/FrmStrpLiteConnectApiAdapter.php +++ b/stripe/helpers/FrmStrpLiteConnectApiAdapter.php @@ -71,9 +71,8 @@ public static function get_customer_subscriptions() { * @return object|string */ public static function get_customer( $options = array() ) { - $user_id = ! empty( $options['user_id'] ) ? $options['user_id'] : get_current_user_id(); - $meta_name = FrmStrpLiteAppHelper::get_customer_id_meta_name(); - + $user_id = ! empty( $options['user_id'] ) ? $options['user_id'] : get_current_user_id(); + $meta_name = FrmStrpLiteAppHelper::get_customer_id_meta_name(); $customer_id_error_message = ''; if ( $user_id ) { diff --git a/stripe/helpers/FrmTransLiteListHelper.php b/stripe/helpers/FrmTransLiteListHelper.php index c90dc0b307..3dc2a4418a 100755 --- a/stripe/helpers/FrmTransLiteListHelper.php +++ b/stripe/helpers/FrmTransLiteListHelper.php @@ -120,8 +120,7 @@ public function get_views() { 'subscriptions' => __( 'Subscriptions', 'formidable' ), ); - $links = array(); - + $links = array(); $frm_payment = new FrmTransLitePayment(); $frm_sub = new FrmTransLiteSubscription(); $counts = array( @@ -228,11 +227,9 @@ public function extra_tablenav( $which ) { public function display_rows() { $date_format = FrmTransLiteAppHelper::get_date_format(); $gateways = FrmTransLiteAppHelper::get_gateways(); - - $alt = 0; - - $form_ids = $this->get_form_ids(); - $args = compact( 'form_ids', 'date_format', 'gateways' ); + $alt = 0; + $form_ids = $this->get_form_ids(); + $args = compact( 'form_ids', 'date_format', 'gateways' ); // $form_ids is indexed by entry ID. $this->valid_entry_ids = array_keys( $form_ids ); @@ -447,10 +444,9 @@ private function get_url_to_payment( $payment_id, $action = 'show' ) { * @return array */ private function get_row_actions( $item ) { - $base_link = '?page=formidable-payments&action='; - $view_link = $base_link . 'show&id=' . $item->id . '&type=' . $this->table; - $delete_link = $base_link . 'destroy&id=' . $item->id . '&type=' . $this->table; - + $base_link = '?page=formidable-payments&action='; + $view_link = $base_link . 'show&id=' . $item->id . '&type=' . $this->table; + $delete_link = $base_link . 'destroy&id=' . $item->id . '&type=' . $this->table; $actions = array(); $actions['view'] = '' . esc_html__( 'View', 'formidable' ) . ''; diff --git a/stripe/models/FrmStrpLiteAuth.php b/stripe/models/FrmStrpLiteAuth.php index 3f90f41eb1..8232a498cb 100644 --- a/stripe/models/FrmStrpLiteAuth.php +++ b/stripe/models/FrmStrpLiteAuth.php @@ -474,7 +474,6 @@ private static function format_form_data( &$form ) { */ private static function maybe_create_intents( $form_id ) { $intents = array(); - $details = self::check_request_params( $form_id ); if ( is_array( $details ) ) { diff --git a/tests/phpunit/base/FrmUnitTest.php b/tests/phpunit/base/FrmUnitTest.php index dfbb5303ee..f069d29b0f 100644 --- a/tests/phpunit/base/FrmUnitTest.php +++ b/tests/phpunit/base/FrmUnitTest.php @@ -274,11 +274,9 @@ public function get_all_fields_for_form_key( $form_key ) { $this->repeat_sec_form_key => 3, ); $expected_field_num = $field_totals[ $form_key ] ?? 0; - - $form_id = $this->factory->form->get_id_by_key( $form_key ); - $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); - - $actual_field_num = count( $fields ); + $form_id = $this->factory->form->get_id_by_key( $form_key ); + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); + $actual_field_num = count( $fields ); $this->assertEquals( $actual_field_num, $expected_field_num, $actual_field_num . ' fields were retrieved for ' . $form_key . ' form, but ' . $expected_field_num . ' were expected. This could mean that certain fields were not imported correctly.' ); return $fields; @@ -514,10 +512,9 @@ public static function generate_xml( $type, $xml_args ) { // phpcs:ignore Slevom $records = array(); foreach ( $type as $tb_type ) { - $where = array(); - $join = ''; - $table = $tables[ $tb_type ]; - + $where = array(); + $join = ''; + $table = $tables[ $tb_type ]; $select = $table . '.id'; $query_vars = array(); @@ -594,8 +591,7 @@ public static function generate_xml( $type, $xml_args ) { // phpcs:ignore Slevom $xml_body = ob_get_contents(); ob_end_clean(); - $xml = $xml_header . $xml_body; - + $xml = $xml_header . $xml_body; $cwd = getcwd(); $path = "{$cwd}/temp.xml"; @chmod( $path, 0755 ); diff --git a/tests/phpunit/base/frm_factory.php b/tests/phpunit/base/frm_factory.php index 5ccbb1faf6..bbf12f07a9 100644 --- a/tests/phpunit/base/frm_factory.php +++ b/tests/phpunit/base/frm_factory.php @@ -38,8 +38,7 @@ public function __construct( $factory = null ) { } public function create_object( $args ) { - $form = FrmForm::create( $args ); - + $form = FrmForm::create( $args ); $field_values = FrmFieldsHelper::setup_new_vars( 'text', $form ); if ( isset( $args['field_options'] ) ) { diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index a27ef3a545..5e11c097f4 100644 --- a/tests/phpunit/database/test_FrmMigrate.php +++ b/tests/phpunit/database/test_FrmMigrate.php @@ -59,8 +59,7 @@ public function test_migrate_to_17() { ); $this->assertNotEmpty( $field ); $field_id = $field->id; - - $frmdb = new FrmMigrate(); + $frmdb = new FrmMigrate(); update_option( 'frm_db_version', 16 ); // trigger migration 17 $frmdb->upgrade(); @@ -360,8 +359,7 @@ public function test_migrate_from_12_to_current() { // migrate data FrmAppController::install(); - $form = FrmForm::getOne( 'contact-db12-copy' ); - + $form = FrmForm::getOne( 'contact-db12-copy' ); $form_actions = FrmFormAction::get_action_for_form( $form->id, 'email' ); $this->assertTrue( ! isset( $form->options['notification'] ), 'The migrated notification settings are not cleared from form.' ); diff --git a/tests/phpunit/emails/test_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index f6f6a2691e..6fd00bef80 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -184,9 +184,8 @@ public function test_trigger_email_two() { public function test_trigger_email_three() { $entry_clone = clone $this->entry; $expected = array(); - - $name_id = FrmField::get_id_by_key( $this->name_field_key ); - $email_id = FrmField::get_id_by_key( $this->email_field_key ); + $name_id = FrmField::get_id_by_key( $this->name_field_key ); + $email_id = FrmField::get_id_by_key( $this->email_field_key ); // Adjust entry values $entry_clone->metas[ $name_id ] = 'Test Testerson'; @@ -407,9 +406,8 @@ public function test_trigger_email_five() { * @covers FrmNotification::trigger_email */ public function test_trigger_email_six() { - $name_id = FrmField::get_id_by_key( $this->name_field_key ); - $email_id = FrmField::get_id_by_key( $this->email_field_key ); - + $name_id = FrmField::get_id_by_key( $this->name_field_key ); + $email_id = FrmField::get_id_by_key( $this->email_field_key ); $entry_clone = clone $this->entry; $entry_clone->metas[ $name_id ] = 'Test Testerson'; $entry_clone->metas[ $email_id ] = 'tester@mail.com'; @@ -443,8 +441,7 @@ protected function get_email_action_for_form( $form_id ) { protected function create_entry( $form ) { $entry_data = $this->factory->field->generate_entry_array( $form ); $entry_id = $this->factory->entry->create( $entry_data ); - - $entry = FrmEntry::getOne( $entry_id, true ); + $entry = FrmEntry::getOne( $entry_id, true ); $this->assertNotEmpty( $entry ); return $entry; diff --git a/tests/phpunit/emails/test_FrmEmailStylesController.php b/tests/phpunit/emails/test_FrmEmailStylesController.php index 4807b335fb..b3000241a7 100644 --- a/tests/phpunit/emails/test_FrmEmailStylesController.php +++ b/tests/phpunit/emails/test_FrmEmailStylesController.php @@ -3,8 +3,7 @@ class test_FrmEmailStylesController extends FrmUnitTest { public function test_add_inline_css() { - $content = '
    Second div
    '; - + $content = '
    Second div
    '; $css = 'font-size:14px;'; $new_content = '
    Second div
    '; $this->assertEquals( diff --git a/tests/phpunit/entries/test_FrmEntriesController.php b/tests/phpunit/entries/test_FrmEntriesController.php index 34631df592..810003f1f5 100644 --- a/tests/phpunit/entries/test_FrmEntriesController.php +++ b/tests/phpunit/entries/test_FrmEntriesController.php @@ -49,8 +49,7 @@ private function create_post_entry( $form, $entry_key ) { FrmEntry::destroy( $exists ); } - $new_post = $this->factory->post->create_and_get(); - + $new_post = $this->factory->post->create_and_get(); $_POST = $this->factory->field->generate_entry_array( $form ); $_POST['item_key'] = $entry_key; $_POST['action'] = 'create'; diff --git a/tests/phpunit/entries/test_FrmEntryFormatter.php b/tests/phpunit/entries/test_FrmEntryFormatter.php index 3ec493d87c..8ed12e6738 100644 --- a/tests/phpunit/entries/test_FrmEntryFormatter.php +++ b/tests/phpunit/entries/test_FrmEntryFormatter.php @@ -11,8 +11,7 @@ class test_FrmEntryFormatter extends FrmUnitTest { * @covers FrmEntryFormatter::flatten_array */ public function test_flatten_array() { - $values = array( 'Option 1', 'Option 2', 'Option 3' ); - + $values = array( 'Option 1', 'Option 2', 'Option 3' ); $form = $this->factory->form->create_and_get(); $entry_data = $this->factory->field->generate_entry_array( $form ); $entry_id = $this->factory->entry->create( $entry_data ); diff --git a/tests/phpunit/entries/test_FrmPersonalData.php b/tests/phpunit/entries/test_FrmPersonalData.php index ed697dc797..81b2165d77 100644 --- a/tests/phpunit/entries/test_FrmPersonalData.php +++ b/tests/phpunit/entries/test_FrmPersonalData.php @@ -45,8 +45,7 @@ private function create_entries_for_user( $entry_data, $email ) { $user_id_field = $this->factory->field->get_id_by_key( 'contact-user-id' ); $email_field = $this->factory->field->get_id_by_key( 'contact-email' ); - - $entry_ids = $this->create_entries_for_email( $entry_data, $email ); + $entry_ids = $this->create_entries_for_email( $entry_data, $email ); // with user id and matching email $entry_data['item_meta'][ $email_field ] = $email; diff --git a/tests/phpunit/entries/test_FrmShowEntryShortcode.php b/tests/phpunit/entries/test_FrmShowEntryShortcode.php index f5833de85f..3f5fe02637 100644 --- a/tests/phpunit/entries/test_FrmShowEntryShortcode.php +++ b/tests/phpunit/entries/test_FrmShowEntryShortcode.php @@ -265,8 +265,7 @@ public function test_default_message_with_old_fields_parameter() { 'fields' => implode( ',', $this->include_fields ), ); - $content = $this->get_formatted_content( $atts ); - + $content = $this->get_formatted_content( $atts ); $pass_atts = $atts; $pass_atts['include_fields'] = $atts['fields']; unset( $pass_atts['fields'] ); @@ -740,8 +739,7 @@ protected function get_formatted_content( $atts ) { } protected function expected_html_content( $atts ) { - $table = $this->table_header( $atts ); - + $table = $this->table_header( $atts ); $table .= $this->two_cell_table_row( 'free-text-field', $atts ); $table .= $this->two_cell_table_row( 'free-paragraph-field', $atts ); $table .= $this->two_cell_table_row( 'free-checkboxes', $atts ); @@ -753,7 +751,6 @@ protected function expected_html_content( $atts ) { $table .= $this->two_cell_table_row( 'free-phone-field', $atts ); $table .= $this->two_cell_table_row( 'free-hidden-field', $atts ); $table .= $this->one_cell_table_row( 'free-html-field', $atts ); - $table .= $this->user_info_rows( $atts ); return $table . $this->table_footer(); @@ -789,9 +786,8 @@ protected function table_header( $atts ) { $font_size = $atts['font_size']; $border_width = $atts['border_width'] ?? $atts['field_border_width']; $border_color = $atts['border_color']; - - $header .= ' style="border-spacing:0;font-size:' . $font_size . ';line-height:135%;'; - $header .= 'border-bottom:' . $border_width . ' solid ' . $border_color . ';"'; + $header .= ' style="border-spacing:0;font-size:' . $font_size . ';line-height:135%;'; + $header .= 'border-bottom:' . $border_width . ' solid ' . $border_color . ';"'; } return $header . '>' . "\r\n"; @@ -826,8 +822,7 @@ protected function two_cell_table_row_for_value( $label, $field_value, $atts ) { $html .= ' class="frm-child-row"'; } - $html .= '>'; - + $html .= '>'; $label = 'td_style . '>' . wp_kses_post( $label ) . ''; $field_value = 'td_style . '>' . wp_kses_post( $field_value ) . ''; @@ -1054,8 +1049,7 @@ protected function get_expected_default_plain( $atts ) { */ protected function get_expected_default_shortcodes( $type, $atts ) { $content = ''; - - $fields = FrmField::get_all_for_form( $atts['form_id'], '', 'include' ); + $fields = FrmField::get_all_for_form( $atts['form_id'], '', 'include' ); if ( $type === 'html' ) { $content .= $this->table_header( $atts ); @@ -1101,8 +1095,7 @@ protected function after_table_row_tags( $type ) { } protected function expected_default_array( $atts ) { - $fields = FrmField::get_all_for_form( $atts['form_id'], '', 'include' ); - + $fields = FrmField::get_all_for_form( $atts['form_id'], '', 'include' ); $expected = array(); foreach ( $fields as $field ) { diff --git a/tests/phpunit/entries/test_FrmTableHTMLGenerator.php b/tests/phpunit/entries/test_FrmTableHTMLGenerator.php index fc89c0be5d..06e4754695 100644 --- a/tests/phpunit/entries/test_FrmTableHTMLGenerator.php +++ b/tests/phpunit/entries/test_FrmTableHTMLGenerator.php @@ -15,8 +15,7 @@ class test_FrmTableHTMLGenerator extends FrmUnitTest { public function test_init_style_settings() { $colors = $this->_get_colors(); $table_generator = new FrmTableHTMLGenerator( 'entry', $colors['start'] ); - - $style_settings = $this->get_private_property( $table_generator, 'style_settings' ); + $style_settings = $this->get_private_property( $table_generator, 'style_settings' ); foreach ( $colors['expected'] as $name => $color ) { $actual = $style_settings[ $name ]; @@ -29,8 +28,7 @@ public function test_init_style_settings() { */ public function test_is_color_setting() { $table_generator = new FrmTableHTMLGenerator( 'entry' ); - - $colors = array( 'border_color', 'bg_color', 'text_color', 'alt_bg_color' ); + $colors = array( 'border_color', 'bg_color', 'text_color', 'alt_bg_color' ); foreach ( $colors as $color ) { $is_color = $this->run_private_method( array( $table_generator, 'is_color_setting' ), array( $color ) ); diff --git a/tests/phpunit/fields/test_FrmFieldName.php b/tests/phpunit/fields/test_FrmFieldName.php index b7d9421d10..88e405cde3 100644 --- a/tests/phpunit/fields/test_FrmFieldName.php +++ b/tests/phpunit/fields/test_FrmFieldName.php @@ -15,8 +15,7 @@ public function test_get_processed_sub_fields() { $field->field_options['name_layout'] = 'first_middle_last'; - $name_field = new FrmFieldName( $field ); - + $name_field = new FrmFieldName( $field ); $processed_sub_fields = $this->run_private_method( array( $name_field, 'get_processed_sub_fields' ) ); $this->assertEquals( array( 'first', 'middle', 'last' ), array_keys( $processed_sub_fields ) ); diff --git a/tests/phpunit/fields/test_FrmFieldType.php b/tests/phpunit/fields/test_FrmFieldType.php index c643cc9d7c..a3b1080194 100644 --- a/tests/phpunit/fields/test_FrmFieldType.php +++ b/tests/phpunit/fields/test_FrmFieldType.php @@ -314,8 +314,7 @@ public function test_prepare_field_html() { $field = FrmField::getOne( $field->id ); $field_array = FrmFieldsHelper::setup_edit_vars( $field ); $field_object = FrmFieldFactory::get_field_type( 'text', $field_array ); - - $html = $field_object->prepare_field_html( $args ); + $html = $field_object->prepare_field_html( $args ); $this->assertEquals( '', $html ); // Test a draft field on a preview page for a privileged user (the HTML should not be empty). diff --git a/tests/phpunit/fields/test_FrmFieldValidate.php b/tests/phpunit/fields/test_FrmFieldValidate.php index 673570e0eb..64d543a097 100644 --- a/tests/phpunit/fields/test_FrmFieldValidate.php +++ b/tests/phpunit/fields/test_FrmFieldValidate.php @@ -71,8 +71,7 @@ public function test_format_validation() { foreach ( $test_formats as $test_format ) { $field_key = $this->get_field_key( $test_format['type'] ); $field_id = FrmField::get_id_by_key( $field_key ); - - $errors = $this->check_single_value( array( $field_id => $test_format['value'] ) ); + $errors = $this->check_single_value( array( $field_id => $test_format['value'] ) ); if ( $test_format['invalid'] ) { $this->assertNotEmpty( $errors, $test_format['type'] . ' value ' . $test_format['value'] . ' passed validation' ); @@ -151,10 +150,8 @@ public function test_empty_required_fields() { } public function test_filled_required_fields() { - $_POST = $this->factory->field->generate_entry_array( $this->form ); - - $errors = FrmEntryValidate::validate( $_POST ); - + $_POST = $this->factory->field->generate_entry_array( $this->form ); + $errors = FrmEntryValidate::validate( $_POST ); $error_fields = array(); if ( $errors ) { diff --git a/tests/phpunit/fields/test_FrmFieldsController.php b/tests/phpunit/fields/test_FrmFieldsController.php index b58e97a270..871c9efde1 100644 --- a/tests/phpunit/fields/test_FrmFieldsController.php +++ b/tests/phpunit/fields/test_FrmFieldsController.php @@ -95,15 +95,14 @@ public function test_include_new_field() { * @covers FrmFieldsController::add_validation_messages */ public function test_add_validation_messages() { - $form_id = $this->factory->form->create(); - $field = $this->factory->field->create_and_get( + $form_id = $this->factory->form->create(); + $field = $this->factory->field->create_and_get( array( 'form_id' => $form_id, 'type' => 'email', ) ); - $field = FrmFieldsHelper::setup_edit_vars( $field ); - + $field = FrmFieldsHelper::setup_edit_vars( $field ); $add_html = array(); $this->run_private_method( array( 'FrmFieldsController', 'add_validation_messages' ), array( $field, &$add_html ) ); $this->assertArrayHasKey( 'data-invmsg', $add_html ); diff --git a/tests/phpunit/fields/test_FrmFieldsHelper.php b/tests/phpunit/fields/test_FrmFieldsHelper.php index 758b2f787f..eeedcb148b 100644 --- a/tests/phpunit/fields/test_FrmFieldsHelper.php +++ b/tests/phpunit/fields/test_FrmFieldsHelper.php @@ -250,8 +250,7 @@ public function test_sep_option() { 'Option 1', 'Option 2', ); - $entry = $this->factory->entry->create_and_get( $entry_data ); - + $entry = $this->factory->entry->create_and_get( $entry_data ); $shortcode = '[' . $checkbox_field->id . ' sep="
    "]'; $shortcodes = FrmFieldsHelper::get_shortcodes( $shortcode, $form->id ); $this->assertEquals( diff --git a/tests/phpunit/forms/test_FrmForm.php b/tests/phpunit/forms/test_FrmForm.php index f75d8da291..8ec56d20cd 100644 --- a/tests/phpunit/forms/test_FrmForm.php +++ b/tests/phpunit/forms/test_FrmForm.php @@ -25,8 +25,7 @@ public function test_create() { */ public function test_duplicate() { $form = $this->factory->form->get_object_by_id( $this->all_fields_form_key ); - - $id = FrmForm::duplicate( $form->id ); + $id = FrmForm::duplicate( $form->id ); $this->assertTrue( is_numeric( $id ) ); $this->assertNotEmpty( $id ); diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 95f513892b..718242fa45 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -60,8 +60,7 @@ public function test_form_update_no_ajax() { private function _setup_post_values( $form_id ) { $fields = FrmField::get_all_for_form( $form_id ); - - $form = FrmForm::getOne( $form_id ); + $form = FrmForm::getOne( $form_id ); $_POST = array( 'page' => 'formidable', @@ -269,11 +268,9 @@ public function test_redirect_after_create() { wp_cache_delete( $form_id, 'frm_form' ); $this->trigger_migrate_actions( $form_id ); - $form = $this->factory->form->get_object_by_id( $form_id ); - - $entry_key = 'submit-redirect'; - $response = $this->post_new_entry( $form, $entry_key ); - + $form = $this->factory->form->get_object_by_id( $form_id ); + $entry_key = 'submit-redirect'; + $response = $this->post_new_entry( $form, $entry_key ); $created_entry_id = FrmEntry::get_id_by_key( $entry_key ); $this->assertNotEmpty( $created_entry_id, 'No entry found with key ' . $entry_key ); @@ -358,9 +355,8 @@ public function run_message_after_create( $show_form = 0 ) { } private function post_new_entry( $form, $entry_key ) { - $fields = FrmField::get_all_for_form( $form->id, '', 'include' ); - $class = class_exists( 'FrmProFormState' ) ? 'FrmProFormState' : 'FrmFormState'; - + $fields = FrmField::get_all_for_form( $form->id, '', 'include' ); + $class = class_exists( 'FrmProFormState' ) ? 'FrmProFormState' : 'FrmFormState'; $max_field_id = 0; foreach ( $fields as $field ) { @@ -396,8 +392,7 @@ public function test_redirect_in_new_tab() { wp_cache_delete( $form_id, 'frm_form' ); $this->trigger_migrate_actions( $form_id ); - $form = $this->factory->form->get_object_by_id( $form_id ); - + $form = $this->factory->form->get_object_by_id( $form_id ); $entry_key = 'submit-redirect'; $response = $this->post_new_entry( $form, $entry_key ); diff --git a/tests/phpunit/forms/test_FrmFormsControllerAjax.php b/tests/phpunit/forms/test_FrmFormsControllerAjax.php index b6f3eed959..c7caebfcf4 100644 --- a/tests/phpunit/forms/test_FrmFormsControllerAjax.php +++ b/tests/phpunit/forms/test_FrmFormsControllerAjax.php @@ -36,8 +36,7 @@ public function test_form_update_with_ajax() { private function _setup_post_values( $form_id ) { $fields = FrmField::get_all_for_form( $form_id ); - - $form = FrmForm::getOne( $form_id ); + $form = FrmForm::getOne( $form_id ); $this->assertNotEmpty( $form, 'Form not found with id ' . $form_id ); $_POST = array( diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index e7663372e9..4216d60c15 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -307,10 +307,9 @@ public function test_sanitize_request() { * @covers FrmAppHelper::kses */ public function test_kses() { - $start_value = 'test'; $expected_value = 'test'; $_POST['test3'] = $set_value; - - $result = FrmAppHelper::get_post_param( 'test3', '', 'sanitize_text_field' ); + $result = FrmAppHelper::get_post_param( 'test3', '', 'sanitize_text_field' ); $this->assertEquals( $result, $expected_value ); } @@ -247,8 +245,7 @@ public function test_simple_get() { $set_value = 'test'; $expected_value = 'test'; $_GET['test4'] = $set_value; - - $result = FrmAppHelper::simple_get( 'test4' ); + $result = FrmAppHelper::simple_get( 'test4' ); $this->assertEquals( $result, $expected_value ); } diff --git a/tests/phpunit/styles/test_FrmStylesController.php b/tests/phpunit/styles/test_FrmStylesController.php index 5e218f4620..51be848ddc 100644 --- a/tests/phpunit/styles/test_FrmStylesController.php +++ b/tests/phpunit/styles/test_FrmStylesController.php @@ -44,8 +44,7 @@ public function test_front_head() { private function get_custom_stylesheet() { global $frm_vars; $frm_vars['css_loaded'] = false; - - $stylesheet_urls = FrmStylesController::custom_stylesheet(); + $stylesheet_urls = FrmStylesController::custom_stylesheet(); $this->assertTrue( isset( $stylesheet_urls['formidable'] ), 'The stylesheet array is empty' ); return $stylesheet_urls; } From 96b1364edaad1bb2974828b031bb79b6882d2993 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 9 Jan 2026 13:58:31 -0400 Subject: [PATCH 4/8] Revert some grouping --- .../controllers/FrmSimpleBlocksController.php | 3 +- classes/helpers/FrmAppHelper.php | 5 +- classes/helpers/FrmEmailSummaryHelper.php | 7 +- .../ConsecutiveAssignmentSpacingSniff.php | 81 ------------------- 4 files changed, 9 insertions(+), 87 deletions(-) diff --git a/classes/controllers/FrmSimpleBlocksController.php b/classes/controllers/FrmSimpleBlocksController.php index 9816148a85..b186c9510d 100644 --- a/classes/controllers/FrmSimpleBlocksController.php +++ b/classes/controllers/FrmSimpleBlocksController.php @@ -225,7 +225,8 @@ public static function simple_form_render( $attributes ) { // so a default doesn't overwrite the block option. $params['title'] = ! empty( $params['title'] ); $params['description'] = ! empty( $params['description'] ); - $form .= FrmFormsController::get_form_shortcode( $params ); + + $form .= FrmFormsController::get_form_shortcode( $params ); if ( ! empty( $attributes['className'] ) ) { $form = preg_replace( '/\bfrm_forms\b/', 'frm_forms ' . esc_attr( $attributes['className'] ), $form, 1 ); diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 3dfe6eaaf7..a4c8370ab8 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -3243,8 +3243,9 @@ public static function human_time_diff( $from, $to = '', $levels = 1 ) { $diff = get_object_vars( $diff_object ); // Add week amount and update day amount - $diff['w'] = floor( $diff['d'] / 7 ); - $diff['d'] -= $diff['w'] * 7; + $diff['w'] = floor( $diff['d'] / 7 ); + $diff['d'] -= $diff['w'] * 7; + $time_strings = self::get_time_strings(); if ( ! is_numeric( $levels ) ) { diff --git a/classes/helpers/FrmEmailSummaryHelper.php b/classes/helpers/FrmEmailSummaryHelper.php index 3396822b37..b3e4b26ffb 100644 --- a/classes/helpers/FrmEmailSummaryHelper.php +++ b/classes/helpers/FrmEmailSummaryHelper.php @@ -575,9 +575,10 @@ public static function maybe_remove_recipients_from_api( &$recipients ) { } $skip_emails = is_string( $addons['no_emails'] ) ? explode( ',', $addons['no_emails'] ) : (array) $addons['no_emails']; - $recipients = array_map( 'trim', explode( ',', $recipients ) ); - $recipients = array_diff( $recipients, $skip_emails ); - $recipients = implode( ',', $recipients ); + + $recipients = array_map( 'trim', explode( ',', $recipients ) ); + $recipients = array_diff( $recipients, $skip_emails ); + $recipients = implode( ',', $recipients ); } /** diff --git a/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php index 568ae070b3..ff9210f248 100644 --- a/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php @@ -157,12 +157,6 @@ private function collectAssignmentGroup( File $phpcsFile, $stackPtr ) { break; } - // Check if there's a comment before this assignment. - // If so, this assignment should start a new group, not continue the current one. - if ( count( $group ) > 0 && $this->hasCommentBeforeVariable( $phpcsFile, $currentVar ) ) { - break; - } - $group[] = array( 'variable' => $currentVar, 'semicolon' => $semicolon, @@ -175,12 +169,6 @@ private function collectAssignmentGroup( File $phpcsFile, $stackPtr ) { break; } - // Check if there's a comment between this assignment and the next. - // If so, stop the group here - comments indicate intentional separation. - if ( $this->hasCommentBetween( $phpcsFile, $semicolon, $nextStatement ) ) { - break; - } - // Check if there's a blank line - if not, they're already grouped, keep collecting. // If there is a blank line, we still want to collect to check the full group size. $currentLine = $tokens[ $semicolon ]['line']; @@ -230,75 +218,6 @@ private function hasDuplicateVariables( File $phpcsFile, $group ) { return false; } - /** - * Check if there's a comment before the variable on the same or previous lines. - * - * @param File $phpcsFile The file being scanned. - * @param int $varPtr The position of the variable token. - * - * @return bool True if there's a comment before the variable. - */ - private function hasCommentBeforeVariable( File $phpcsFile, $varPtr ) { - $tokens = $phpcsFile->getTokens(); - $commentTypes = array( - T_COMMENT, - T_DOC_COMMENT, - T_DOC_COMMENT_OPEN_TAG, - T_DOC_COMMENT_CLOSE_TAG, - T_DOC_COMMENT_STAR, - T_DOC_COMMENT_STRING, - T_DOC_COMMENT_TAG, - T_DOC_COMMENT_WHITESPACE, - ); - - // Look backwards from the variable to find the previous semicolon or brace. - $prevStatement = $phpcsFile->findPrevious( array( T_SEMICOLON, T_OPEN_CURLY_BRACKET, T_CLOSE_CURLY_BRACKET ), $varPtr - 1 ); - - if ( false === $prevStatement ) { - return false; - } - - // Check if there's a comment between the previous statement and this variable. - for ( $i = $prevStatement + 1; $i < $varPtr; $i++ ) { - if ( in_array( $tokens[ $i ]['code'], $commentTypes, true ) ) { - return true; - } - } - - return false; - } - - /** - * Check if there's a comment between two token positions. - * - * @param File $phpcsFile The file being scanned. - * @param int $startPtr The start position. - * @param int $endPtr The end position. - * - * @return bool True if there's a comment between the positions. - */ - private function hasCommentBetween( File $phpcsFile, $startPtr, $endPtr ) { - $tokens = $phpcsFile->getTokens(); - $commentTypes = array( - T_COMMENT, - T_DOC_COMMENT, - T_DOC_COMMENT_OPEN_TAG, - T_DOC_COMMENT_CLOSE_TAG, - T_DOC_COMMENT_STAR, - T_DOC_COMMENT_STRING, - T_DOC_COMMENT_TAG, - T_DOC_COMMENT_WHITESPACE, - ); - - for ( $i = $startPtr + 1; $i < $endPtr; $i++ ) { - if ( in_array( $tokens[ $i ]['code'], $commentTypes, true ) ) { - return true; - } - } - - return false; - } - /** * Get a signature for the variable being assigned. * This includes array access like $styles[] or $data['key']. From eacb4748090eba0e50c9559eba106dba19dcbbf7 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 9 Jan 2026 14:02:33 -0400 Subject: [PATCH 5/8] Revert a couple more grouping --- classes/controllers/FrmAppController.php | 3 ++- classes/controllers/FrmFieldsController.php | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index e476553e6c..71652478aa 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -59,7 +59,8 @@ public static function add_admin_class( $classes ) { if ( self::is_white_page() ) { $classes .= ' frm-white-body '; $classes .= self::get_os(); - $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ); + + $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ); if ( ! $page || $page === 'formidable' ) { $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php index bbfbe14bad..022e6b1fae 100644 --- a/classes/controllers/FrmFieldsController.php +++ b/classes/controllers/FrmFieldsController.php @@ -272,10 +272,12 @@ public static function import_options() { return; } - $field = FrmFieldsHelper::setup_edit_vars( $field ); - $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); - $opts = explode( "\n", rtrim( $opts, "\n" ) ); - $opts = array_map( 'trim', $opts ); + $field = FrmFieldsHelper::setup_edit_vars( $field ); + + $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); + $opts = explode( "\n", rtrim( $opts, "\n" ) ); + $opts = array_map( 'trim', $opts ); + $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' ); $field['separate_value'] = $separate === 'true'; From 44fd083854641c5827547aa1cedf48025be71d0b Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 9 Jan 2026 14:03:59 -0400 Subject: [PATCH 6/8] Revert a couple more grouping --- classes/models/fields/FrmFieldType.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php index 1986063400..1c20d993d3 100644 --- a/classes/models/fields/FrmFieldType.php +++ b/classes/models/fields/FrmFieldType.php @@ -1879,8 +1879,9 @@ protected function get_multi_opts_for_import( $value ) { if ( ! is_array( $checked ) ) { $filtered_checked = $checked; $csv_values_checked = array(); - $options = (array) $this->field->options; - $options = array_reverse( $options ); + + $options = (array) $this->field->options; + $options = array_reverse( $options ); foreach ( $options as $option ) { if ( isset( $option['value'] ) && str_contains( $filtered_checked, $option['value'] ) ) { From d287b7e4d6cc769984d290f5eefc2fa21c0e228d Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 9 Jan 2026 14:06:58 -0400 Subject: [PATCH 7/8] Revert a couple more grouping --- classes/models/FrmMigrate.php | 5 ++- .../ConsecutiveAssignmentSpacingSniff.php | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/classes/models/FrmMigrate.php b/classes/models/FrmMigrate.php index 553cd051f6..df718be04c 100644 --- a/classes/models/FrmMigrate.php +++ b/classes/models/FrmMigrate.php @@ -780,8 +780,9 @@ private function adjust_widget_size() { */ private function convert_character_to_px( &$size ) { $pixel_conversion = 9; - $size = round( $pixel_conversion * (int) $size ); - $size .= 'px'; + + $size = round( $pixel_conversion * (int) $size ); + $size .= 'px'; } /** diff --git a/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php index ff9210f248..61028ebd9e 100644 --- a/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/ConsecutiveAssignmentSpacingSniff.php @@ -101,6 +101,12 @@ public function process( File $phpcsFile, $stackPtr ) { return; } + // If the first assignment has a comment before it, don't suggest grouping. + // The comment indicates intentional separation from what comes after. + if ( $this->hasCommentBeforeVariable( $phpcsFile, $group[0]['variable'] ) ) { + return; + } + // Now check for blank lines between consecutive assignments in the group. for ( $i = 0; $i < count( $group ) - 1; $i++ ) { $current = $group[ $i ]; @@ -218,6 +224,44 @@ private function hasDuplicateVariables( File $phpcsFile, $group ) { return false; } + /** + * Check if there's a comment before the variable on the same or previous lines. + * + * @param File $phpcsFile The file being scanned. + * @param int $varPtr The position of the variable token. + * + * @return bool True if there's a comment before the variable. + */ + private function hasCommentBeforeVariable( File $phpcsFile, $varPtr ) { + $tokens = $phpcsFile->getTokens(); + $commentTypes = array( + T_COMMENT, + T_DOC_COMMENT, + T_DOC_COMMENT_OPEN_TAG, + T_DOC_COMMENT_CLOSE_TAG, + T_DOC_COMMENT_STAR, + T_DOC_COMMENT_STRING, + T_DOC_COMMENT_TAG, + T_DOC_COMMENT_WHITESPACE, + ); + + // Look backwards from the variable to find the previous semicolon or brace. + $prevStatement = $phpcsFile->findPrevious( array( T_SEMICOLON, T_OPEN_CURLY_BRACKET, T_CLOSE_CURLY_BRACKET ), $varPtr - 1 ); + + if ( false === $prevStatement ) { + return false; + } + + // Check if there's a comment between the previous statement and this variable. + for ( $i = $prevStatement + 1; $i < $varPtr; $i++ ) { + if ( in_array( $tokens[ $i ]['code'], $commentTypes, true ) ) { + return true; + } + } + + return false; + } + /** * Get a signature for the variable being assigned. * This includes array access like $styles[] or $data['key']. From ca9535c6f908558b0102e8c2599794168a15de9e Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 9 Jan 2026 14:12:24 -0400 Subject: [PATCH 8/8] Revert some grouping --- classes/models/FrmStyle.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/models/FrmStyle.php b/classes/models/FrmStyle.php index 695102fe5b..1d7fa7c0de 100644 --- a/classes/models/FrmStyle.php +++ b/classes/models/FrmStyle.php @@ -191,6 +191,7 @@ private function maybe_sanitize_rgba_value( &$color_val ) { // phpcs:ignore Slev // Remove all leading ')' braces, then add one back. This way there's always a single brace. $color_val = rtrim( $color_val, ')' ); $color_val .= ')'; + $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 ); // Remove any excessive braces from the rgba like rgba((. $color_rgba = trim( $color_rgba, '()' );