diff --git a/classes/controllers/FrmAddonsController.php b/classes/controllers/FrmAddonsController.php index 6287dab0ce..8aa2f54548 100644 --- a/classes/controllers/FrmAddonsController.php +++ b/classes/controllers/FrmAddonsController.php @@ -407,6 +407,7 @@ protected static function fallback_plugin_list() { $info['slug'] = $k; $list[ $k ] = array_merge( $defaults, $info ); } + return $list; } @@ -742,6 +743,7 @@ public static function get_addon( $plugin ) { return $addon; } } + return false; } @@ -757,6 +759,7 @@ protected static function get_license_type() { if ( isset( $addons['error'] ) && isset( $addons['error']['type'] ) ) { $license_type = $addons['error']['type']; } + return $license_type; } @@ -1113,6 +1116,7 @@ protected static function install_addon() { 'success' => false, ); } + return $plugin; } @@ -1230,6 +1234,7 @@ protected static function handle_addon_action( $installed, $action ) { if ( wp_doing_ajax() ) { wp_send_json_error( array( 'error' => $result->get_error_message() ) ); } + return array( 'message' => $result->get_error_message(), 'success' => false, diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index a1d56e2b66..c5f1b02997 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -142,6 +142,7 @@ private static function get_os() { } elseif ( str_contains( $agent, 'windows' ) ) { $os = ' windows'; } + return $os; } @@ -1459,6 +1460,7 @@ private static function in_our_pages() { if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) { return true; } + return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ); } diff --git a/classes/controllers/FrmDashboardController.php b/classes/controllers/FrmDashboardController.php index b826fcdab5..767b3bc523 100644 --- a/classes/controllers/FrmDashboardController.php +++ b/classes/controllers/FrmDashboardController.php @@ -531,6 +531,7 @@ private static function get_dashboard_options( $option_name = null ) { if ( null !== $option_name ) { return $options[ $option_name ]; } + return $options; } diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php index 91f175bf2c..40c3bc6592 100644 --- a/classes/controllers/FrmFieldsController.php +++ b/classes/controllers/FrmFieldsController.php @@ -903,6 +903,7 @@ private static function get_form_for_js_validation( $field ) { return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ]; } } + return false; } diff --git a/classes/controllers/FrmFormActionsController.php b/classes/controllers/FrmFormActionsController.php index 56f14fea6f..e37f774b48 100644 --- a/classes/controllers/FrmFormActionsController.php +++ b/classes/controllers/FrmFormActionsController.php @@ -253,6 +253,7 @@ private static function active_actions( $action_controls ) { $allowed[] = $action_control->id_base; } } + return $allowed; } diff --git a/classes/controllers/FrmSettingsController.php b/classes/controllers/FrmSettingsController.php index 2b4ad476ab..2d7b9053c7 100644 --- a/classes/controllers/FrmSettingsController.php +++ b/classes/controllers/FrmSettingsController.php @@ -243,6 +243,7 @@ private static function payment_sections_sort_callback( $a, $b ) { if ( false === $first_key || false === $second_key ) { return 0; } + return $first_key - $second_key; } diff --git a/classes/controllers/FrmSimpleBlocksController.php b/classes/controllers/FrmSimpleBlocksController.php index a7a1bfa722..b186c9510d 100644 --- a/classes/controllers/FrmSimpleBlocksController.php +++ b/classes/controllers/FrmSimpleBlocksController.php @@ -231,6 +231,7 @@ public static function simple_form_render( $attributes ) { if ( ! empty( $attributes['className'] ) ) { $form = preg_replace( '/\bfrm_forms\b/', 'frm_forms ' . esc_attr( $attributes['className'] ), $form, 1 ); } + return self::maybe_remove_fade_on_load_for_block_preview( $form ); } diff --git a/classes/controllers/FrmStylesController.php b/classes/controllers/FrmStylesController.php index 7654d9ce63..7312b34438 100644 --- a/classes/controllers/FrmStylesController.php +++ b/classes/controllers/FrmStylesController.php @@ -876,6 +876,7 @@ public static function get_custom_css( $single_style_settings = null ) { if ( ! empty( $single_style_settings['single_style_custom_css'] ) && ! empty( $single_style_settings['enable_style_custom_css'] ) ) { return $single_style_settings['single_style_custom_css']; } + return ''; } diff --git a/classes/controllers/FrmUsageController.php b/classes/controllers/FrmUsageController.php index e4c024d5c5..a8b9eacfff 100644 --- a/classes/controllers/FrmUsageController.php +++ b/classes/controllers/FrmUsageController.php @@ -32,6 +32,7 @@ public static function schedule_send() { // Remove the scheduled event if it's not allowed and it's scheduled. wp_unschedule_event( $timestamp, 'formidable_send_usage' ); } + return; } diff --git a/classes/controllers/FrmXMLController.php b/classes/controllers/FrmXMLController.php index 4790844999..0592f12014 100644 --- a/classes/controllers/FrmXMLController.php +++ b/classes/controllers/FrmXMLController.php @@ -148,6 +148,7 @@ private static function get_posted_form() { if ( ! $form ) { return $form; } + return json_decode( $form, true ); } diff --git a/classes/helpers/FrmApiHelper.php b/classes/helpers/FrmApiHelper.php index 43f6737b90..e00f04f142 100644 --- a/classes/helpers/FrmApiHelper.php +++ b/classes/helpers/FrmApiHelper.php @@ -39,6 +39,7 @@ public static function is_for_user( $item ) { if ( in_array( 'free_not_first_30', $who, true ) && self::is_free_not_first_30() ) { return true; } + return self::check_free_segments( $who ); } diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 0e44f85290..a70e4d7b43 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -428,6 +428,7 @@ public static function is_form_builder_page( $check_for_settings = true ) { if ( $check_for_settings ) { $check_actions[] = 'settings'; } + return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true ); } @@ -903,6 +904,7 @@ public static function sanitize_value( $sanitize, &$value ) { foreach ( $temp_values as $k => $v ) { self::sanitize_value( $sanitize, $value[ $k ] ); } + return; } @@ -1103,6 +1105,7 @@ public static function kses_submit_button( $html ) { if ( $included_draft_hook ) { $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html ); } + return $html; } @@ -1484,6 +1487,7 @@ private static function is_a_valid_color( $value ) { } elseif ( str_starts_with( $value, '#' ) ) { $match = preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})\b$/', $value ); } + return (bool) $match; } @@ -2767,6 +2771,7 @@ private static function maybe_truncate_key_before_appending( $column, $key ) { } } } + return $key; } @@ -2823,6 +2828,7 @@ private static function prevent_numeric_and_reserved_keys( $key ) { $key .= 'a'; } } + return $key; } @@ -3358,6 +3364,7 @@ private static function get_unit( $unit ) { return $u; } } + return 1; } @@ -3723,6 +3730,7 @@ public static function maybe_utf8_encode( $value ) { if ( mb_check_encoding( $value, $from_format ) ) { return mb_convert_encoding( $value, $to_format, $from_format ); } + return $value; } @@ -4230,6 +4238,7 @@ public static function get_menu_icon_class() { return $settings->menu_icon; } } + return 'frmfont frm_logo_icon'; } @@ -5014,6 +5023,7 @@ public static function is_valid_utf8( $string ) { if ( function_exists( 'seems_utf8' ) ) { return seems_utf8( $string ); } + return false; } diff --git a/classes/helpers/FrmCSVExportHelper.php b/classes/helpers/FrmCSVExportHelper.php index 47ffe2f5bf..b29304c674 100644 --- a/classes/helpers/FrmCSVExportHelper.php +++ b/classes/helpers/FrmCSVExportHelper.php @@ -649,6 +649,7 @@ private static function get_field( $field_id ) { return $field; } } + return false; } diff --git a/classes/helpers/FrmCurrencyHelper.php b/classes/helpers/FrmCurrencyHelper.php index 3d107d49a0..1f9a3d4fee 100644 --- a/classes/helpers/FrmCurrencyHelper.php +++ b/classes/helpers/FrmCurrencyHelper.php @@ -25,6 +25,7 @@ public static function get_currency( $currency ) { } else { $currency = $currencies['USD']; } + return $currency; } diff --git a/classes/helpers/FrmEmailHelper.php b/classes/helpers/FrmEmailHelper.php index d671159fb9..97e094b4d2 100644 --- a/classes/helpers/FrmEmailHelper.php +++ b/classes/helpers/FrmEmailHelper.php @@ -54,6 +54,7 @@ public static function get_default_from_email() { if ( $settings->from_email && is_email( $settings->from_email ) ) { return $settings->from_email; } + return get_option( 'admin_email' ); } } diff --git a/classes/helpers/FrmFieldGridHelper.php b/classes/helpers/FrmFieldGridHelper.php index d41e0c47c8..d71340a8a2 100644 --- a/classes/helpers/FrmFieldGridHelper.php +++ b/classes/helpers/FrmFieldGridHelper.php @@ -162,6 +162,7 @@ private function should_first_close_the_active_field_wrapper() { if ( 'end_divider' === $this->field->type ) { return false; } + return ! $this->can_support_current_layout() || $this->is_frm_first; } @@ -226,6 +227,7 @@ public function sync_list_size() { if ( 'end_divider' === $this->field->type ) { $this->maybe_close_section_helper(); } + return; } diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index d1357d27c8..eb30390e1d 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -502,6 +502,7 @@ private static function maybe_replace_substrings_with_field_name( $msg, $error, if ( ! $field_name ) { $field_name = 'unique_msg' === $error ? __( 'This value', 'formidable' ) : __( 'This field', 'formidable' ); } + return str_replace( $substrings, $field_name, $msg ); } @@ -1130,6 +1131,7 @@ private static function trigger_shortcode_atts( $replace_with, $atts ) { $function = 'atts_' . $included_att; $replace_with = self::$function( $replace_with ); } + return $replace_with; } @@ -1862,6 +1864,7 @@ private static function switch_ids_except_strings( $replace, $replace_with, $exc unset( $replace[ $index ] ); unset( $replace_with[ $index ] ); } + return str_replace( $replace, $replace_with, $value ); } diff --git a/classes/helpers/FrmFormMigratorsHelper.php b/classes/helpers/FrmFormMigratorsHelper.php index 76b339cb6b..f8382ee00d 100644 --- a/classes/helpers/FrmFormMigratorsHelper.php +++ b/classes/helpers/FrmFormMigratorsHelper.php @@ -86,6 +86,7 @@ private static function import_links() { $forms[] = $form; } + return $forms; } diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index 798d95d2e6..6607b4ca3f 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -1004,6 +1004,7 @@ public static function get_form_style_class( $form = false ) { if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { return $class; } + return null; } @@ -1304,6 +1305,7 @@ public static function edit_form_link_label( $data ) { if ( ! $name ) { return self::get_no_title_text(); } + return FrmAppHelper::truncate( $name, 40 ); } @@ -2077,6 +2079,7 @@ public static function form_is_loaded_by_api() { if ( ! empty( $frm_vars['inplace_edit'] ) ) { return true; } + return self::is_formidable_api_form() || self::is_gutenberg_editor() || self::is_elementor_ajax() || self::is_visual_views_preview(); } diff --git a/classes/helpers/FrmShortcodeHelper.php b/classes/helpers/FrmShortcodeHelper.php index 5f2d03e734..a8030c65ce 100644 --- a/classes/helpers/FrmShortcodeHelper.php +++ b/classes/helpers/FrmShortcodeHelper.php @@ -79,6 +79,7 @@ public static function get_contextual_codes() { foreach ( $contextual_shortcodes as $type => $shortcodes ) { $result[ $type ] = array_keys( $shortcodes ); } + return $result; } diff --git a/classes/helpers/FrmStringReaderHelper.php b/classes/helpers/FrmStringReaderHelper.php index 86c6de51a9..b98cc2598d 100644 --- a/classes/helpers/FrmStringReaderHelper.php +++ b/classes/helpers/FrmStringReaderHelper.php @@ -55,6 +55,7 @@ public function read_until( $char ) { while ( $this->pos <= $this->max && ( $one = $this->string[ $this->pos++ ] ) !== $char ) { $value .= $one; } + return $value; } diff --git a/classes/helpers/FrmStylesHelper.php b/classes/helpers/FrmStylesHelper.php index 4a0f5f3985..a101a0a581 100644 --- a/classes/helpers/FrmStylesHelper.php +++ b/classes/helpers/FrmStylesHelper.php @@ -252,6 +252,7 @@ private static function get_rgb_array_from_rgb( $rgb ) { // Drop the alpha. The function is expected to only return r,g,b with no alpha. array_pop( $rgb ); } + return $rgb; } @@ -1156,6 +1157,7 @@ public static function get_bottom_value( $value ) { if ( count( $parts ) < 3 ) { return $parts[0]; } + return $parts[2]; } } diff --git a/classes/helpers/FrmSubmitHelper.php b/classes/helpers/FrmSubmitHelper.php index 08232eaaee..ac868d6270 100644 --- a/classes/helpers/FrmSubmitHelper.php +++ b/classes/helpers/FrmSubmitHelper.php @@ -212,6 +212,7 @@ public static function only_contains_submit_field( $fields ) { $submit_field = $field; } + return $submit_field; } diff --git a/classes/helpers/FrmTipsHelper.php b/classes/helpers/FrmTipsHelper.php index cf8a55bf60..90af07ddd6 100644 --- a/classes/helpers/FrmTipsHelper.php +++ b/classes/helpers/FrmTipsHelper.php @@ -95,6 +95,7 @@ private static function get_tip_link( $tip ) { if ( is_array( $tip['link'] ) ) { $cta_link = FrmAppHelper::maybe_add_missing_utm( $cta_link, $tip['link'] ); } + return $cta_link; } @@ -114,6 +115,7 @@ private static function cta_label() { if ( $cta_text ) { return $cta_text; } + return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' ); } diff --git a/classes/helpers/FrmXMLHelper.php b/classes/helpers/FrmXMLHelper.php index c049955b05..e727aa4adb 100644 --- a/classes/helpers/FrmXMLHelper.php +++ b/classes/helpers/FrmXMLHelper.php @@ -1246,6 +1246,7 @@ private static function maybe_prepare_json_view_content( $content ) { if ( is_array( $maybe_decoded ) && isset( $maybe_decoded[0] ) && isset( $maybe_decoded[0]['box'] ) ) { return FrmAppHelper::prepare_and_encode( $maybe_decoded ); } + return $content; } @@ -1827,6 +1828,7 @@ private static function default_field_options( $type ) { if ( empty( $defaults['custom_html'] ) ) { $defaults['custom_html'] = FrmFieldsHelper::get_default_html( $type ); } + return $defaults; } @@ -2440,6 +2442,7 @@ public static function get_supported_upload_file_types() { // CSV Importing is only available in Pro. $file_types[] = '.csv'; } + return $file_types; } } diff --git a/classes/models/FrmAntiSpam.php b/classes/models/FrmAntiSpam.php index 43b99c7df2..47262315d1 100644 --- a/classes/models/FrmAntiSpam.php +++ b/classes/models/FrmAntiSpam.php @@ -212,6 +212,7 @@ public function validate() { // add an exception for the entries page. return true; } + return $this->process_antispam_filter( $this->get_missing_token_message() ); } diff --git a/classes/models/FrmApplicationTemplate.php b/classes/models/FrmApplicationTemplate.php index bad9b001ed..ec73a875b0 100644 --- a/classes/models/FrmApplicationTemplate.php +++ b/classes/models/FrmApplicationTemplate.php @@ -286,6 +286,7 @@ private function get_required_license() { if ( 'plus' === $required_license ) { $required_license = 'personal'; } + return $required_license; } diff --git a/classes/models/FrmEntry.php b/classes/models/FrmEntry.php index 0ad1b80740..57d954ffb6 100644 --- a/classes/models/FrmEntry.php +++ b/classes/models/FrmEntry.php @@ -241,6 +241,7 @@ private static function convert_values_to_their_saved_value( $filter_vals, $entr unset( $reduced[ $field_id ] ); } } + return $reduced; } diff --git a/classes/models/FrmEntryMeta.php b/classes/models/FrmEntryMeta.php index 10937bf77f..f0f444bd2e 100644 --- a/classes/models/FrmEntryMeta.php +++ b/classes/models/FrmEntryMeta.php @@ -486,6 +486,7 @@ private static function should_join_fields_table( &$where ) { $where['e.form_id'] = $where['fi.form_id']; unset( $where['fi.form_id'] ); } + return false; } diff --git a/classes/models/FrmEntryValidate.php b/classes/models/FrmEntryValidate.php index fb5d942694..4b1f1d3961 100644 --- a/classes/models/FrmEntryValidate.php +++ b/classes/models/FrmEntryValidate.php @@ -340,6 +340,7 @@ private static function is_filtered_match( $value, $option_value ) { if ( is_numeric( $filter_priority ) ) { add_filter( 'the_content', 'wpautop', $filter_priority ); } + return trim( $value ) === trim( $filtered_option ); } diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php index a5a47cff27..82dc6b8a29 100644 --- a/classes/models/FrmFieldFormHtml.php +++ b/classes/models/FrmFieldFormHtml.php @@ -319,6 +319,7 @@ private static function get_error_body( $html ) { if ( false === $end ) { return false; } + return substr( $html, $start + 10, $end - $start - 10 ); } diff --git a/classes/models/FrmForm.php b/classes/models/FrmForm.php index a51b4f0755..ee1fbbba4a 100644 --- a/classes/models/FrmForm.php +++ b/classes/models/FrmForm.php @@ -869,6 +869,7 @@ public static function getOne( $id, $blog_id = false ) { if ( isset( $cache->options ) ) { FrmAppHelper::unserialize_or_decode( $cache->options ); } + return self::prepare_form_row_data( $cache ); } } diff --git a/classes/models/FrmFormAction.php b/classes/models/FrmFormAction.php index 47672b0715..b4dfea5c2a 100644 --- a/classes/models/FrmFormAction.php +++ b/classes/models/FrmFormAction.php @@ -213,6 +213,7 @@ public function maybe_switch_field_ids( $action ) { if ( $updated_action === $action ) { $updated_action = FrmFieldsHelper::switch_field_ids( $action ); } + return $updated_action; } @@ -609,6 +610,7 @@ public static function get_action_for_form( $form_id, $type = 'all', $atts = arr if ( is_array( $action_controls ) ) { return array(); } + return $action_controls->get_all( $form_id, $atts ); } diff --git a/classes/models/FrmFormState.php b/classes/models/FrmFormState.php index f511fb3425..859de51812 100644 --- a/classes/models/FrmFormState.php +++ b/classes/models/FrmFormState.php @@ -153,6 +153,7 @@ private static function get_state_from_request() { foreach ( $decoded_state as $key => $value ) { self::set_initial_value( self::decompressed_key( $key ), $value ); } + return true; } @@ -208,6 +209,7 @@ private function compressed_state() { foreach ( $this->state as $key => $value ) { $compressed[ self::compressed_key( $key ) ] = $value; } + return $compressed; } diff --git a/classes/models/FrmHoneypot.php b/classes/models/FrmHoneypot.php index 42f768fa8e..fba133b816 100644 --- a/classes/models/FrmHoneypot.php +++ b/classes/models/FrmHoneypot.php @@ -335,6 +335,7 @@ private static function get_honeypot_class_name() { // For backward compatibility use the old class name. return 'frm_verify'; } + return $option; } } diff --git a/classes/models/FrmInbox.php b/classes/models/FrmInbox.php index d3a5d22bc3..a1f2fdb5bf 100644 --- a/classes/models/FrmInbox.php +++ b/classes/models/FrmInbox.php @@ -64,6 +64,7 @@ public function get_messages( $filter = false ) { if ( $filter === 'filter' ) { $this->filter_messages( $messages ); } + return $messages; } @@ -359,6 +360,7 @@ public function unread() { unset( $messages[ $t ] ); } } + return $messages; } diff --git a/classes/models/FrmSalesApi.php b/classes/models/FrmSalesApi.php index 6cdb14356b..73bade588a 100644 --- a/classes/models/FrmSalesApi.php +++ b/classes/models/FrmSalesApi.php @@ -345,6 +345,7 @@ private function get_ab_group_for_current_site() { $option = mt_rand( 0, 1 ); update_option( 'frm_sale_ab_group', $option, false ); } + return (int) $option; } diff --git a/classes/models/FrmSettings.php b/classes/models/FrmSettings.php index 7fe9072e40..f8bdf9a3a3 100644 --- a/classes/models/FrmSettings.php +++ b/classes/models/FrmSettings.php @@ -425,6 +425,7 @@ private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) { // Avoid changing the false default value to an empty string. return $value; } + return sanitize_textarea_field( $value ); } diff --git a/classes/models/FrmSolution.php b/classes/models/FrmSolution.php index f3444d78a1..170f451d45 100644 --- a/classes/models/FrmSolution.php +++ b/classes/models/FrmSolution.php @@ -746,6 +746,7 @@ protected function is_complete( $count = 1 ) { if ( $count === 'all' ) { return count( $imported ) >= count( $this->form_options() ); } + return ! empty( $imported ); } diff --git a/classes/models/FrmSpamCheck.php b/classes/models/FrmSpamCheck.php index 15c54b3b0f..3c3967a1d4 100644 --- a/classes/models/FrmSpamCheck.php +++ b/classes/models/FrmSpamCheck.php @@ -42,6 +42,7 @@ public function is_spam() { if ( ! $is_spam ) { return false; } + return $this->get_spam_message(); } diff --git a/classes/models/FrmSpamCheckDenylist.php b/classes/models/FrmSpamCheckDenylist.php index 1f6ff7b062..bbff43551a 100644 --- a/classes/models/FrmSpamCheckDenylist.php +++ b/classes/models/FrmSpamCheckDenylist.php @@ -290,6 +290,7 @@ protected function single_line_check_values( $line, $args ) { return true; } } + return false; } diff --git a/classes/models/FrmSpamCheckWPDisallowedWords.php b/classes/models/FrmSpamCheckWPDisallowedWords.php index 4aee2d27e0..9e50ac9966 100644 --- a/classes/models/FrmSpamCheckWPDisallowedWords.php +++ b/classes/models/FrmSpamCheckWPDisallowedWords.php @@ -51,6 +51,7 @@ private function get_disallowed_words() { // phpcs:ignore WordPress.WP.DeprecatedParameterValues.Found $keys = get_option( 'blacklist_keys' ); } + return $keys; } diff --git a/classes/models/FrmStyle.php b/classes/models/FrmStyle.php index 51192e71f3..566b2594af 100644 --- a/classes/models/FrmStyle.php +++ b/classes/models/FrmStyle.php @@ -272,6 +272,7 @@ public function sanitize_post_content( $settings ) { $sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] ); } } + return $sanitized_settings; } @@ -343,6 +344,7 @@ private function trim_braces( $input ) { $output .= ')'; } } + return $output; } @@ -835,6 +837,7 @@ public function force_balanced_quotation( $value ) { $value .= $char; } } + return $value; } @@ -853,6 +856,7 @@ public function get_default_template_style( $style_id ) { if ( empty( $default_template ) ) { return FrmAppHelper::prepare_and_encode( $this->get_defaults() ); } + return $default_template; } } diff --git a/classes/models/FrmTableHTMLGenerator.php b/classes/models/FrmTableHTMLGenerator.php index 1eb6dbb885..a6abeefd6e 100644 --- a/classes/models/FrmTableHTMLGenerator.php +++ b/classes/models/FrmTableHTMLGenerator.php @@ -454,6 +454,7 @@ protected function add_row_class( $empty = false ) { if ( $class ) { $class = ' class="' . trim( $class ) . '"'; } + return $class; } } diff --git a/classes/models/FrmUsage.php b/classes/models/FrmUsage.php index f271fb5ecc..f462be0224 100644 --- a/classes/models/FrmUsage.php +++ b/classes/models/FrmUsage.php @@ -456,6 +456,7 @@ private function fields() { FrmAppHelper::unserialize_or_decode( $field->field_options ); $fields[ $k ]->field_options = json_encode( $field->field_options ); } + return $fields; } diff --git a/classes/models/fields/FrmFieldEmail.php b/classes/models/fields/FrmFieldEmail.php index 6a40d19f99..14a8bc476a 100644 --- a/classes/models/fields/FrmFieldEmail.php +++ b/classes/models/fields/FrmFieldEmail.php @@ -55,6 +55,7 @@ public function validate( $args ) { if ( str_contains( $args['value'], '.@' ) || ! is_email( $args['value'] ) ) { $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' ); } + return $errors; } diff --git a/classes/models/fields/FrmFieldName.php b/classes/models/fields/FrmFieldName.php index 4a23da2161..e33f2eac52 100644 --- a/classes/models/fields/FrmFieldName.php +++ b/classes/models/fields/FrmFieldName.php @@ -97,6 +97,7 @@ protected function get_name_layout() { if ( ! $name_layout ) { $name_layout = 'first_last'; } + return $name_layout; } diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php index 2bb958e2e1..90bb3a5ead 100644 --- a/classes/models/fields/FrmFieldType.php +++ b/classes/models/fields/FrmFieldType.php @@ -1258,6 +1258,7 @@ protected function prepare_esc_value() { if ( str_contains( $value, '<' ) ) { $value = htmlentities( $value ); } + return $value; } @@ -1651,6 +1652,7 @@ private function value_has_already_been_validated_as_unique( $value ) { $frm_validated_unique_values[ $field_id ] = array(); return false; } + return in_array( $value, $frm_validated_unique_values[ $field_id ], true ); } @@ -1971,6 +1973,7 @@ private function maintain_option_values( $value, $unsanitized_value ) { } } } + return $return_value; } diff --git a/classes/views/styles/components/FrmStyleComponent.php b/classes/views/styles/components/FrmStyleComponent.php index 22bb8b0121..2eeb69c295 100644 --- a/classes/views/styles/components/FrmStyleComponent.php +++ b/classes/views/styles/components/FrmStyleComponent.php @@ -149,6 +149,7 @@ protected function get_default_wrapper_class_names() { if ( ! empty( $this->data['will_change'] ) ) { return $class . ' frm-style-dependent-updater-component'; } + return $class; } @@ -176,6 +177,7 @@ private function get_component_attributes() { if ( ! empty( $this->data['will_change'] ) ) { $attributes .= 'data-will-change=' . wp_json_encode( $this->data['will_change'] ); } + return $attributes; } diff --git a/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/BlankLineBeforeReturnAfterBraceSniff.php b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/BlankLineBeforeReturnAfterBraceSniff.php new file mode 100644 index 0000000000..e4055f3ecb --- /dev/null +++ b/phpcs-sniffs/Formidable/Sniffs/WhiteSpace/BlankLineBeforeReturnAfterBraceSniff.php @@ -0,0 +1,199 @@ +getTokens(); + + // Find the function/method this return belongs to. + $functionToken = $this->findContainingFunction( $phpcsFile, $stackPtr ); + + if ( false === $functionToken ) { + return; + } + + // Only enforce this rule if the function already uses blank lines for readability. + if ( ! $this->functionHasBlankLines( $phpcsFile, $functionToken ) ) { + return; + } + + // Find the first token on the current line. + $firstOnLine = $stackPtr; + + for ( $i = $stackPtr - 1; $i >= 0; $i-- ) { + if ( $tokens[ $i ]['line'] < $tokens[ $stackPtr ]['line'] ) { + break; + } + $firstOnLine = $i; + } + + // Check if the return is the first non-whitespace token on the line. + $firstNonWhitespace = $phpcsFile->findNext( T_WHITESPACE, $firstOnLine, $stackPtr + 1, true ); + + if ( $firstNonWhitespace !== $stackPtr ) { + return; + } + + // Now find what's on the previous line. + $currentLine = $tokens[ $stackPtr ]['line']; + $previousLine = $currentLine - 1; + + if ( $previousLine < 1 ) { + return; + } + + // Find the last non-whitespace token on the previous line. + $lastTokenOnPrevLine = null; + + for ( $i = $stackPtr - 1; $i >= 0; $i-- ) { + if ( $tokens[ $i ]['line'] < $previousLine ) { + break; + } + + if ( $tokens[ $i ]['line'] === $previousLine && $tokens[ $i ]['code'] !== T_WHITESPACE ) { + // Keep looking for the actual last token on this line (don't break on first match). + if ( null === $lastTokenOnPrevLine || $tokens[ $i ]['column'] > $tokens[ $lastTokenOnPrevLine ]['column'] ) { + $lastTokenOnPrevLine = $i; + } + } + } + + // If we couldn't find a token on the previous line, it's a blank line - we're good. + if ( null === $lastTokenOnPrevLine ) { + return; + } + + // Check if the last token on the previous line is a closing brace. + if ( $tokens[ $lastTokenOnPrevLine ]['code'] !== T_CLOSE_CURLY_BRACKET ) { + return; + } + + // We found a closing brace on the previous line followed by a return statement. + // This is the error condition. + $fix = $phpcsFile->addFixableError( + 'Expected blank line before return statement when previous line ends with closing brace', + $stackPtr, + 'MissingBlankLine' + ); + + if ( true === $fix ) { + $phpcsFile->fixer->beginChangeset(); + + // Add a newline before the first token on the current line. + $phpcsFile->fixer->addNewlineBefore( $firstOnLine ); + + $phpcsFile->fixer->endChangeset(); + } + } + + /** + * Find the function or method that contains the given token. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token. + * + * @return false|int The position of the function token, or false if not found. + */ + private function findContainingFunction( File $phpcsFile, $stackPtr ) { + $tokens = $phpcsFile->getTokens(); + + for ( $i = $stackPtr - 1; $i >= 0; $i-- ) { + if ( $tokens[ $i ]['code'] === T_FUNCTION || $tokens[ $i ]['code'] === T_CLOSURE ) { + // Check if the stackPtr is within this function's scope. + if ( isset( $tokens[ $i ]['scope_opener'], $tokens[ $i ]['scope_closer'] ) ) { + if ( $stackPtr > $tokens[ $i ]['scope_opener'] && $stackPtr < $tokens[ $i ]['scope_closer'] ) { + return $i; + } + } + } + } + + return false; + } + + /** + * Check if a function contains blank lines (lines with only whitespace). + * + * @param File $phpcsFile The file being scanned. + * @param int $functionToken The position of the function token. + * + * @return bool True if the function has blank lines, false otherwise. + */ + private function functionHasBlankLines( File $phpcsFile, $functionToken ) { + $tokens = $phpcsFile->getTokens(); + + if ( ! isset( $tokens[ $functionToken ]['scope_opener'], $tokens[ $functionToken ]['scope_closer'] ) ) { + return false; + } + + $scopeOpener = $tokens[ $functionToken ]['scope_opener']; + $scopeCloser = $tokens[ $functionToken ]['scope_closer']; + + // Build a map of which lines have non-whitespace content. + $linesWithContent = array(); + + for ( $i = $scopeOpener + 1; $i < $scopeCloser; $i++ ) { + if ( $tokens[ $i ]['code'] !== T_WHITESPACE ) { + $linesWithContent[ $tokens[ $i ]['line'] ] = true; + } + } + + // Check if there are any lines between scope opener and closer that have no content. + $startLine = $tokens[ $scopeOpener ]['line'] + 1; + $endLine = $tokens[ $scopeCloser ]['line'] - 1; + + for ( $line = $startLine; $line <= $endLine; $line++ ) { + if ( ! isset( $linesWithContent[ $line ] ) ) { + // This line has no non-whitespace content - it's a blank line. + return true; + } + } + + return false; + } +} diff --git a/phpcs.xml b/phpcs.xml index 5185cfdb36..a728aa8208 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -281,4 +281,5 @@ + diff --git a/square/controllers/FrmSquareLiteActionsController.php b/square/controllers/FrmSquareLiteActionsController.php index 4b80792e3d..b79b662fb8 100644 --- a/square/controllers/FrmSquareLiteActionsController.php +++ b/square/controllers/FrmSquareLiteActionsController.php @@ -86,6 +86,7 @@ public static function get_actions_before_submit( $form_id ) { unset( $payment_actions[ $k ] ); } } + return $payment_actions; } @@ -571,6 +572,7 @@ private static function get_app_id() { if ( 'live' === $mode ) { return 'sq0idp-eR4XI1xgNduJAXcBvjemTg'; } + return 'sandbox-sq0idb-MXl8ilzmhAgsHWKV9c6ycQ'; } diff --git a/square/controllers/FrmSquareLiteEventsController.php b/square/controllers/FrmSquareLiteEventsController.php index c314d4104c..9dc53af9a8 100644 --- a/square/controllers/FrmSquareLiteEventsController.php +++ b/square/controllers/FrmSquareLiteEventsController.php @@ -199,6 +199,7 @@ private function handle_event() { ) ); } + return; } break; diff --git a/square/helpers/FrmSquareLiteConnectHelper.php b/square/helpers/FrmSquareLiteConnectHelper.php index 9b9c6a5130..bc99290e21 100644 --- a/square/helpers/FrmSquareLiteConnectHelper.php +++ b/square/helpers/FrmSquareLiteConnectHelper.php @@ -201,6 +201,7 @@ private static function post_to_connect_server( $action, $additional_body = arra if ( ! empty( $body->data ) && is_string( $body->data ) ) { return $body->data; } + return 'Response from server was not successful'; } @@ -281,6 +282,7 @@ private static function strip_lang_from_url( $url ) { if ( 2 === count( $split_on_language ) ) { $url = $split_on_language[0]; } + return $url; } @@ -314,6 +316,7 @@ private static function maybe_get_pro_license() { $password = $pro_license; } } + return ! empty( $password ) ? $password : false; } @@ -546,6 +549,7 @@ private static function post_with_authenticated_body( $action, $additional_body } else { self::$latest_error_from_square_api = ''; } + return false; } @@ -642,6 +646,7 @@ public static function get_unprocessed_event_ids() { if ( false === $data || empty( $data->event_ids ) ) { return array(); } + return $data->event_ids; } @@ -809,6 +814,7 @@ public static function get_subscription( $subscription_id ) { if ( is_object( $response ) && is_object( $response->subscription ) ) { return $response->subscription; } + return false; } } diff --git a/stripe/controllers/FrmStrpLiteActionsController.php b/stripe/controllers/FrmStrpLiteActionsController.php index 1156a1b877..ce85171ef0 100644 --- a/stripe/controllers/FrmStrpLiteActionsController.php +++ b/stripe/controllers/FrmStrpLiteActionsController.php @@ -81,6 +81,7 @@ public static function get_actions_before_submit( $form_id ) { unset( $payment_actions[ $k ] ); } } + return $payment_actions; } diff --git a/stripe/controllers/FrmStrpLiteEventsController.php b/stripe/controllers/FrmStrpLiteEventsController.php index 630673416c..8cb3001ce6 100644 --- a/stripe/controllers/FrmStrpLiteEventsController.php +++ b/stripe/controllers/FrmStrpLiteEventsController.php @@ -433,6 +433,7 @@ private function is_partial_refund() { $amount_refunded = $this->invoice->amount_refunded; $partial = $amount != $amount_refunded; // phpcs:ignore Universal.Operators.StrictComparisons } + return $partial; } diff --git a/stripe/controllers/FrmTransLiteActionsController.php b/stripe/controllers/FrmTransLiteActionsController.php index def05d623d..7663904684 100755 --- a/stripe/controllers/FrmTransLiteActionsController.php +++ b/stripe/controllers/FrmTransLiteActionsController.php @@ -460,6 +460,7 @@ public static function get_actions_for_form( $form_id ) { if ( ! $payment_actions ) { $payment_actions = array(); } + return $payment_actions; } diff --git a/stripe/helpers/FrmStrpLiteAppHelper.php b/stripe/helpers/FrmStrpLiteAppHelper.php index 6063e790b2..b6d2b34c95 100644 --- a/stripe/helpers/FrmStrpLiteAppHelper.php +++ b/stripe/helpers/FrmStrpLiteAppHelper.php @@ -72,6 +72,7 @@ public static function get_customer_id_meta_name() { if ( 'test' === self::active_mode() ) { $meta_name .= '_test'; } + return $meta_name; } diff --git a/stripe/helpers/FrmStrpLiteConnectApiAdapter.php b/stripe/helpers/FrmStrpLiteConnectApiAdapter.php index 94f2406cd9..9b83c20bee 100644 --- a/stripe/helpers/FrmStrpLiteConnectApiAdapter.php +++ b/stripe/helpers/FrmStrpLiteConnectApiAdapter.php @@ -34,6 +34,7 @@ public static function cancel_subscription( $sub_id ) { $customer_id = $customer->id; } + return FrmStrpLiteConnectHelper::cancel_subscription( $sub_id, $customer_id ); } diff --git a/stripe/helpers/FrmStrpLiteConnectHelper.php b/stripe/helpers/FrmStrpLiteConnectHelper.php index bdac916439..c0148436b0 100644 --- a/stripe/helpers/FrmStrpLiteConnectHelper.php +++ b/stripe/helpers/FrmStrpLiteConnectHelper.php @@ -39,6 +39,7 @@ private static function check_for_stripe_connect_ajax_actions() { FrmAppHelper::permission_check( 'frm_change_settings' ); self::render_settings(); } + return; } @@ -175,6 +176,7 @@ private static function post_to_connect_server( $action, $additional_body = arra if ( ! empty( $body->data ) && is_string( $body->data ) ) { return $body->data; } + return 'Response from server was not successful'; } @@ -481,6 +483,7 @@ public static function check_server_for_connected_account_status() { if ( $success ) { self::set_stripe_details_as_submitted( $mode ); } + return $success; } @@ -566,6 +569,7 @@ private static function strip_lang_from_url( $url ) { if ( 2 === count( $split_on_language ) ) { $url = $split_on_language[0]; } + return $url; } @@ -583,6 +587,7 @@ private static function maybe_get_pro_license() { $password = $pro_license; } } + return ! empty( $password ) ? $password : false; } @@ -704,6 +709,7 @@ public static function get_customer_id( $options ) { if ( empty( $data->customer_id ) ) { return false; } + return $data->customer_id; } @@ -743,6 +749,7 @@ private static function post_with_authenticated_body( $action, $additional_body } else { self::$latest_error_from_stripe_connect = ''; } + return false; } @@ -758,6 +765,7 @@ public static function create_intent( $new_charge ) { if ( ! $success ) { return false; } + return $data; } @@ -869,6 +877,7 @@ public static function maybe_create_plan( $plan ) { if ( false === $data || empty( $data->plan_id ) ) { return false; } + return $data->plan_id; } @@ -901,6 +910,7 @@ public static function get_unprocessed_event_ids() { if ( false === $data || empty( $data->event_ids ) ) { return array(); } + return $data->event_ids; } diff --git a/stripe/helpers/FrmStrpLiteLinkRedirectHelper.php b/stripe/helpers/FrmStrpLiteLinkRedirectHelper.php index bc2b367522..0305c5243d 100644 --- a/stripe/helpers/FrmStrpLiteLinkRedirectHelper.php +++ b/stripe/helpers/FrmStrpLiteLinkRedirectHelper.php @@ -133,6 +133,7 @@ private function url_is_external( $url ) { if ( is_array( $parsed ) ) { $home_url = $parsed['scheme'] . '://' . $parsed['host']; } + return ! str_starts_with( $url, $home_url ); } diff --git a/stripe/helpers/FrmStrpLiteSubscriptionHelper.php b/stripe/helpers/FrmStrpLiteSubscriptionHelper.php index 026d9f23b6..5977bc0279 100644 --- a/stripe/helpers/FrmStrpLiteSubscriptionHelper.php +++ b/stripe/helpers/FrmStrpLiteSubscriptionHelper.php @@ -108,6 +108,7 @@ private static function get_plan_for_action( $action ) { $plan_opts = self::prepare_plan_options( $action->post_content ); $plan_id = self::maybe_create_plan( $plan_opts ); } + return $plan_id; } diff --git a/stripe/helpers/FrmTransLiteAppHelper.php b/stripe/helpers/FrmTransLiteAppHelper.php index 418e5b9cf2..a828018d3e 100755 --- a/stripe/helpers/FrmTransLiteAppHelper.php +++ b/stripe/helpers/FrmTransLiteAppHelper.php @@ -207,6 +207,7 @@ public static function process_shortcodes( $atts ) { $value = apply_filters( 'frm_content', $value, $atts['form'], $atts['entry'] ); } + return do_shortcode( $value ); } @@ -222,6 +223,7 @@ public static function format_billing_cycle( $sub ) { if ( (int) $sub->interval_count === 1 ) { return $amount . '/' . $interval; } + return $amount . ' every ' . $sub->interval_count . ' ' . $interval; } @@ -267,6 +269,7 @@ public static function get_repeat_label_from_value( $value, $number ) { if ( isset( $times[ $value ] ) ) { $value = $times[ $value ]; } + return $value; } @@ -394,6 +397,7 @@ public static function get_user_link( $user_id ) { $user_link = '' . esc_html( $user->display_name ) . ''; } } + return $user_link; } @@ -535,6 +539,7 @@ public static function get_setting_for_gateway( $gateway, $setting ) { if ( isset( $gateways[ $gateway ] ) ) { $value = $gateways[ $gateway ][ $setting ]; } + return $value; } diff --git a/stripe/models/FrmStrpLiteAuth.php b/stripe/models/FrmStrpLiteAuth.php index 1c812c6783..b778ab3d68 100644 --- a/stripe/models/FrmStrpLiteAuth.php +++ b/stripe/models/FrmStrpLiteAuth.php @@ -659,6 +659,7 @@ private static function statement_descriptor_is_valid( &$name ) { if ( strlen( $name ) > 22 ) { $name = substr( $name, 0, 22 ); } + return (bool) preg_match( '/^[a-zA-Z0-9\s\p{P}]+$/', $name ); } @@ -787,6 +788,7 @@ private static function get_message_url( $atts ) { if ( false === $url ) { $url = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); } + return add_query_arg( array( 'frmstrp' => $atts['entry_id'] ), $url ); } diff --git a/stripe/models/FrmTransLiteLog.php b/stripe/models/FrmTransLiteLog.php index a38ffa3731..d2216a33bd 100644 --- a/stripe/models/FrmTransLiteLog.php +++ b/stripe/models/FrmTransLiteLog.php @@ -19,6 +19,7 @@ public static function log_message( $title, $text, $is_error = true ) { if ( $is_error ) { error_log( $title . ': ' . $text ); } + return; } diff --git a/tests/phpunit/base/frm_factory.php b/tests/phpunit/base/frm_factory.php index 951c214431..5ccbb1faf6 100644 --- a/tests/phpunit/base/frm_factory.php +++ b/tests/phpunit/base/frm_factory.php @@ -113,6 +113,7 @@ public function generate_entry_array( $form ) { foreach ( $form_fields as $field ) { $entry_data['item_meta'][ $field->id ] = $this->set_field_value( $field ); } + return $entry_data; } diff --git a/tests/phpunit/stripe/FrmStrpLiteUnitTest.php b/tests/phpunit/stripe/FrmStrpLiteUnitTest.php index a33e339ed0..847820f289 100644 --- a/tests/phpunit/stripe/FrmStrpLiteUnitTest.php +++ b/tests/phpunit/stripe/FrmStrpLiteUnitTest.php @@ -215,6 +215,7 @@ protected function get_new_charge_data( $action_id = 0 ) { 'action' => $action_id, ); } + return $new_charge; }