From 6c44f1498932b06fb232a2dbeb0f2f9a241b74ea Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Thu, 25 Sep 2025 09:56:37 -0300 Subject: [PATCH 1/5] Run some rector changes --- classes/controllers/FrmAddonsController.php | 20 ++++++------- classes/controllers/FrmAntiSpamController.php | 4 +-- classes/controllers/FrmAppController.php | 2 +- .../controllers/FrmApplicationsController.php | 4 +-- .../controllers/FrmDashboardController.php | 6 ++-- classes/controllers/FrmEntriesController.php | 4 +-- classes/controllers/FrmFieldsController.php | 10 +++---- .../FrmFormTemplatesController.php | 12 ++++---- classes/controllers/FrmFormsController.php | 12 ++++---- .../FrmOnboardingWizardController.php | 16 +++++----- classes/controllers/FrmSettingsController.php | 16 +++++----- classes/controllers/FrmUsageController.php | 8 ++--- classes/factories/FrmFieldFactory.php | 2 +- classes/helpers/FrmAppHelper.php | 24 +++++++-------- classes/helpers/FrmCSVExportHelper.php | 2 +- classes/helpers/FrmEntriesHelper.php | 12 ++++---- classes/helpers/FrmFieldsHelper.php | 22 +++++++------- classes/helpers/FrmFormsHelper.php | 28 ++++++++--------- classes/helpers/FrmFormsListHelper.php | 2 +- classes/helpers/FrmHtmlHelper.php | 2 +- classes/helpers/FrmListHelper.php | 4 +-- classes/helpers/FrmOnSubmitHelper.php | 21 ++++++------- classes/helpers/FrmSubmitHelper.php | 6 +--- classes/helpers/FrmTipsHelper.php | 2 +- classes/helpers/FrmXMLHelper.php | 12 ++++---- classes/models/FrmAddon.php | 4 +-- classes/models/FrmApplicationTemplate.php | 2 +- classes/models/FrmCreateFile.php | 4 +-- classes/models/FrmEntry.php | 8 ++--- classes/models/FrmEntryFormatter.php | 2 +- classes/models/FrmEntryMeta.php | 2 +- classes/models/FrmEntryValidate.php | 4 +-- classes/models/FrmEntryValues.php | 2 +- classes/models/FrmField.php | 4 +-- classes/models/FrmFieldCaptchaSettings.php | 2 +- classes/models/FrmFieldFormHtml.php | 4 +-- classes/models/FrmFieldOption.php | 2 +- classes/models/FrmFieldValueSelector.php | 2 +- classes/models/FrmForm.php | 30 +++++++++---------- classes/models/FrmFormAction.php | 4 +-- classes/models/FrmFormApi.php | 2 +- classes/models/FrmFormMigrator.php | 2 +- classes/models/FrmFormState.php | 5 +--- classes/models/FrmHoneypot.php | 2 +- classes/models/FrmInbox.php | 2 +- classes/models/FrmSettings.php | 8 ++--- classes/models/FrmSolution.php | 4 +-- classes/models/FrmSpamCheckDenylist.php | 2 +- classes/models/FrmStyle.php | 6 ++-- classes/models/FrmTableHTMLGenerator.php | 2 +- classes/models/FrmYoutubeFeedApi.php | 5 +--- classes/models/fields/FrmFieldCombo.php | 10 +++---- classes/models/fields/FrmFieldName.php | 2 +- classes/models/fields/FrmFieldNumber.php | 2 +- classes/models/fields/FrmFieldType.php | 12 ++++---- classes/models/fields/FrmFieldUserID.php | 2 +- classes/views/frm-entries/form.php | 2 +- classes/views/frm-entries/new.php | 2 +- .../combo-field/sub-field-options.php | 4 +-- .../back-end/default-value-setting.php | 2 +- .../front-end/combo-field/combo-field.php | 2 +- .../views/frm-form-actions/_action_inside.php | 2 +- classes/views/frm-forms/form.php | 2 +- classes/views/frm-forms/mb_html_tab.php | 2 +- classes/views/frm-forms/settings.php | 2 +- classes/views/frm-settings/payments.php | 4 +-- classes/views/shared/mb_adv_info.php | 2 +- classes/views/shared/toggle.php | 12 ++++---- classes/views/solutions/_import.php | 2 +- classes/views/summary-emails/stats-plain.php | 2 +- classes/views/xml/import_form.php | 4 +-- classes/widgets/FrmShowForm.php | 4 +-- rector.php | 11 ++++--- .../FrmStrpLiteActionsController.php | 2 +- .../FrmStrpLiteEventsController.php | 2 +- .../FrmStrpLiteSettingsController.php | 2 +- .../FrmTransLiteActionsController.php | 15 ++++------ .../FrmTransLiteEntriesController.php | 2 +- .../FrmTransLiteListsController.php | 4 +-- stripe/helpers/FrmStrpLiteConnectHelper.php | 2 +- .../helpers/FrmStrpLiteSubscriptionHelper.php | 2 +- stripe/helpers/FrmStrpLiteUrlParamHelper.php | 2 +- stripe/helpers/FrmTransLiteAppHelper.php | 8 ++--- stripe/models/FrmStrpLiteAuth.php | 2 +- 84 files changed, 244 insertions(+), 257 deletions(-) diff --git a/classes/controllers/FrmAddonsController.php b/classes/controllers/FrmAddonsController.php index 4ac16dd37d..b54159f874 100644 --- a/classes/controllers/FrmAddonsController.php +++ b/classes/controllers/FrmAddonsController.php @@ -29,13 +29,13 @@ class FrmAddonsController { * @since 6.15 */ public static function load_admin_hooks() { - add_action( 'admin_menu', __CLASS__ . '::menu', 100 ); - add_filter( 'pre_set_site_transient_update_plugins', __CLASS__ . '::check_update' ); + add_action( 'admin_menu', self::class . '::menu', 100 ); + add_filter( 'pre_set_site_transient_update_plugins', self::class . '::check_update' ); if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) { self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/'; - add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 ); + add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 ); add_filter( 'frm_show_footer_links', '__return_false' ); } } @@ -143,7 +143,7 @@ public static function list_addons() { if ( isset( $addons['error'] ) ) { $api = new FrmFormApi(); $errors = $api->get_error_from_response( $addons ); - $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : ''; + $license_type = $addons['error']['type'] ?? ''; unset( $addons['error'] ); } @@ -415,7 +415,7 @@ public static function get_pro_download_url() { $downloads = $api->get_api_info(); $pro = self::get_pro_from_addons( $downloads ); - return isset( $pro['url'] ) ? $pro['url'] : ''; + return $pro['url'] ?? ''; } /** @@ -453,7 +453,7 @@ public static function get_pro_license() { * @return array */ protected static function get_pro_from_addons( $addons ) { - return isset( $addons['93790'] ) ? $addons['93790'] : array(); + return $addons['93790'] ?? array(); } /** @@ -478,7 +478,7 @@ public static function is_license_expired() { return false; } - $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0; + $expires = $version_info['error']['expires'] ?? 0; if ( empty( $expires ) || $expires > time() ) { return false; } @@ -549,8 +549,8 @@ public static function check_update( $transient ) { continue; } - $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); - $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; + $wp_plugin = $wp_plugins[ $folder ] ?? array(); + $wp_version = $wp_plugin['Version'] ?? '1.0'; $plugin->slug = explode( '/', $folder )[0]; if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) { @@ -630,7 +630,7 @@ protected static function fill_update_addon_info( $installed_addons ) { continue; } - $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0; + $download_id = $plugin['id'] ?? 0; if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) { // if this addon is using its own license, get the update url $addon_info = $api->get_api_info(); diff --git a/classes/controllers/FrmAntiSpamController.php b/classes/controllers/FrmAntiSpamController.php index 25448ef9c4..b87d7dd76b 100644 --- a/classes/controllers/FrmAntiSpamController.php +++ b/classes/controllers/FrmAntiSpamController.php @@ -28,11 +28,11 @@ public static function is_spam( $values ) { ); foreach ( $methods as $method ) { - if ( ! is_callable( array( __CLASS__, $method ) ) ) { + if ( ! is_callable( array( self::class, $method ) ) ) { continue; } - $is_spam = call_user_func( array( __CLASS__, $method ), $values ); + $is_spam = call_user_func( array( self::class, $method ), $values ); if ( $is_spam ) { return $is_spam; } diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 923e494400..7b0d03f867 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -1031,7 +1031,7 @@ public static function create_rest_routes() { $args = array( 'methods' => 'GET', 'callback' => 'FrmAppController::api_install', - 'permission_callback' => __CLASS__ . '::can_update_db', + 'permission_callback' => self::class . '::can_update_db', ); register_rest_route( 'frm-admin/v1', '/install', $args ); diff --git a/classes/controllers/FrmApplicationsController.php b/classes/controllers/FrmApplicationsController.php index 7dca076e28..4f4904cd71 100644 --- a/classes/controllers/FrmApplicationsController.php +++ b/classes/controllers/FrmApplicationsController.php @@ -28,7 +28,7 @@ public static function menu() { if ( ! isset( $slug ) ) { $slug = 'formidable-applications'; - $callback = array( __CLASS__, 'landing_page' ); + $callback = array( self::class, 'landing_page' ); } add_submenu_page( 'formidable', 'Formidable | ' . $label, $label, $cap, $slug, $callback ); @@ -131,7 +131,7 @@ private static function get_prepared_template_data() { FrmApplicationTemplate::init(); - return array_reduce( $applications, array( __CLASS__, 'reduce_template' ), array() ); + return array_reduce( $applications, array( self::class, 'reduce_template' ), array() ); } /** diff --git a/classes/controllers/FrmDashboardController.php b/classes/controllers/FrmDashboardController.php index 467e35c60c..c5028e191d 100644 --- a/classes/controllers/FrmDashboardController.php +++ b/classes/controllers/FrmDashboardController.php @@ -21,7 +21,7 @@ class FrmDashboardController { * @return void */ public static function load_admin_hooks() { - add_action( 'admin_menu', __CLASS__ . '::menu', 9 ); + add_action( 'admin_menu', self::class . '::menu', 9 ); } /** @@ -462,13 +462,13 @@ private static function get_youtube_embed_video( $entries_count ) { return null; } if ( 0 === (int) $entries_count && false !== $welcome_video ) { - return isset( $welcome_video['video-id'] ) ? $welcome_video['video-id'] : null; + return $welcome_video['video-id'] ?? null; } // We might receive the most recent video feed as the featured selection. if ( isset( $featured_video[0] ) ) { return $featured_video[0]['video-id']; } - return isset( $featured_video['video-id'] ) ? $featured_video['video-id'] : null; + return $featured_video['video-id'] ?? null; } /** diff --git a/classes/controllers/FrmEntriesController.php b/classes/controllers/FrmEntriesController.php index 55603eec64..3ffb39d250 100644 --- a/classes/controllers/FrmEntriesController.php +++ b/classes/controllers/FrmEntriesController.php @@ -100,7 +100,7 @@ private static function load_manage_entries_hooks() { add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' ); add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' ); } else { - add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 ); + add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 ); } } @@ -517,7 +517,7 @@ public static function display_list( $message = '', $errors = array() ) { private static function get_delete_form_time( $form, &$errors ) { if ( 'trash' === $form->status ) { $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? $form->options['trash_time'] : time() ) ); + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) ); /* translators: %1$s: Time string */ $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php index 0f1c87f6c8..836006836d 100644 --- a/classes/controllers/FrmFieldsController.php +++ b/classes/controllers/FrmFieldsController.php @@ -184,7 +184,7 @@ public static function load_single_field( $field_object, $values, $form_id = 0 ) } if ( ! isset( $field ) && is_object( $field_object ) ) { - $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id; + $field_object->parent_form_id = $values['id'] ?? $field_object->form_id; $field = FrmFieldsHelper::setup_edit_vars( $field_object ); } @@ -675,7 +675,7 @@ private static function add_html_placeholder( $field, array &$add_html, array &$ * @return string */ private static function prepare_placeholder( $field ) { - $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; + $placeholder = $field['placeholder'] ?? ''; return $placeholder; } @@ -999,9 +999,9 @@ private static function add_pattern_attribute( $field, array &$add_html ) { public static function check_value( $opt, $opt_key, $field ) { if ( is_array( $opt ) ) { if ( FrmField::is_option_true( $field, 'separate_value' ) ) { - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); + $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt ); } else { - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); + $opt = $opt['label'] ?? reset( $opt ); } } @@ -1010,7 +1010,7 @@ public static function check_value( $opt, $opt_key, $field ) { public static function check_label( $opt ) { if ( is_array( $opt ) ) { - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); + $opt = $opt['label'] ?? reset( $opt ); } return $opt; diff --git a/classes/controllers/FrmFormTemplatesController.php b/classes/controllers/FrmFormTemplatesController.php index a4cdfdfc67..dfbd43cf6f 100644 --- a/classes/controllers/FrmFormTemplatesController.php +++ b/classes/controllers/FrmFormTemplatesController.php @@ -141,13 +141,13 @@ public static function load_admin_hooks() { self::init_template_resources(); // Use the same priority as Applications so Form Templates appear directly under Applications. - add_action( 'admin_menu', __CLASS__ . '::menu', 14 ); - add_action( 'admin_footer', __CLASS__ . '::render_modal' ); - add_filter( 'frm_form_nav_list', __CLASS__ . '::append_new_template_to_nav', 10, 2 ); + add_action( 'admin_menu', self::class . '::menu', 14 ); + add_action( 'admin_footer', self::class . '::render_modal' ); + add_filter( 'frm_form_nav_list', self::class . '::append_new_template_to_nav', 10, 2 ); if ( self::is_templates_page() ) { - add_action( 'admin_init', __CLASS__ . '::set_form_templates_data' ); - add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 ); + add_action( 'admin_init', self::class . '::set_form_templates_data' ); + add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 ); add_filter( 'frm_show_footer_links', '__return_false' ); } } @@ -168,7 +168,7 @@ public static function menu() { $label, self::REQUIRED_CAPABILITY, self::PAGE_SLUG, - array( __CLASS__, 'render' ) + array( self::class, 'render' ) ); } diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index 9002a13941..7cb80a720f 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -1411,7 +1411,7 @@ private static function get_settings_tabs( $values ) { 'advanced' => array( 'name' => __( 'General', 'formidable' ), 'title' => __( 'General Form Settings', 'formidable' ), - 'function' => array( __CLASS__, 'advanced_settings' ), + 'function' => array( self::class, 'advanced_settings' ), 'icon' => 'frm_icon_font frm_settings_icon', ), 'email' => array( @@ -1443,7 +1443,7 @@ private static function get_settings_tabs( $values ) { ), 'buttons' => array( 'name' => __( 'Buttons', 'formidable' ), - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'buttons_settings', 'icon' => 'frm_icon_font frm_button_icon', ), @@ -1481,7 +1481,7 @@ private static function get_settings_tabs( $values ) { ), 'html' => array( 'name' => __( 'Customize HTML', 'formidable' ), - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'html_settings', 'icon' => 'frm_icon_font frm_code_icon', ), @@ -3026,7 +3026,7 @@ private static function show_form_after_submit( $args ) { $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); $frm_settings = FrmAppHelper::get_settings(); - $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; + $submit = $form->options['submit_value'] ?? $frm_settings->submit_value; global $frm_vars; self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); @@ -3116,10 +3116,10 @@ private static function show_lone_success_message( $atts ) { */ private static function prepare_submit_message( $form, $entry_id, $args = array() ) { $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); - $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success'; + $opt = $args['success_opt'] ?? 'success'; if ( $entry_id && is_numeric( $entry_id ) ) { - $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg; + $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg; $class = 'frm_message'; } else { $message = $frm_settings->failed_msg; diff --git a/classes/controllers/FrmOnboardingWizardController.php b/classes/controllers/FrmOnboardingWizardController.php index 7dcf1b8d94..3b31b6ca26 100644 --- a/classes/controllers/FrmOnboardingWizardController.php +++ b/classes/controllers/FrmOnboardingWizardController.php @@ -123,10 +123,10 @@ class FrmOnboardingWizardController { */ public static function load_admin_hooks() { self::set_page_url(); - add_action( 'admin_init', __CLASS__ . '::do_admin_redirects' ); + add_action( 'admin_init', self::class . '::do_admin_redirects' ); if ( self::has_onboarding_been_skipped() ) { - add_filter( 'option_frm_inbox', __CLASS__ . '::add_wizard_to_floating_links' ); + add_filter( 'option_frm_inbox', self::class . '::add_wizard_to_floating_links' ); } // Load page if admin page is Onboarding Wizard. @@ -204,12 +204,12 @@ public static function maybe_load_page() { $message = new FrmInbox(); $message->dismiss( 'onboarding_wizard' ); - add_action( 'admin_menu', __CLASS__ . '::menu', 99 ); - add_action( 'admin_init', __CLASS__ . '::assign_properties' ); - add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 ); - add_action( 'admin_head', __CLASS__ . '::remove_menu' ); + add_action( 'admin_menu', self::class . '::menu', 99 ); + add_action( 'admin_init', self::class . '::assign_properties' ); + add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 ); + add_action( 'admin_head', self::class . '::remove_menu' ); - add_filter( 'admin_body_class', __CLASS__ . '::add_admin_body_classes', 999 ); + add_filter( 'admin_body_class', self::class . '::add_admin_body_classes', 999 ); add_filter( 'frm_show_footer_links', '__return_false' ); } } @@ -254,7 +254,7 @@ public static function menu() { $label, self::REQUIRED_CAPABILITY, self::PAGE_SLUG, - array( __CLASS__, 'render' ) + array( self::class, 'render' ) ); } diff --git a/classes/controllers/FrmSettingsController.php b/classes/controllers/FrmSettingsController.php index b30160ac16..bb15071bb7 100644 --- a/classes/controllers/FrmSettingsController.php +++ b/classes/controllers/FrmSettingsController.php @@ -59,19 +59,19 @@ public static function display_form( $errors = array(), $message = '' ) { private static function get_settings_tabs() { $sections = array( 'general' => array( - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'general_settings', 'name' => __( 'General Settings', 'formidable' ), 'icon' => 'frm_icon_font frm_settings_icon', ), 'messages' => array( - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'message_settings', 'name' => __( 'Message Defaults', 'formidable' ), 'icon' => 'frm_icon_font frm_stamp_icon', ), 'permissions' => array( - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'permission_settings', 'name' => __( 'Permissions', 'formidable' ), 'icon' => 'frm_icon_font frm_lock_icon', @@ -79,7 +79,7 @@ private static function get_settings_tabs() { 'payments' => array( 'name' => __( 'Payments', 'formidable' ), 'icon' => 'frm_icon_font frm_simple_cc_icon', - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'payments_settings', ), 'custom_css' => array( @@ -95,7 +95,7 @@ private static function get_settings_tabs() { 'icon' => 'frm_icon_font frm_pallet_icon', ), 'captcha' => array( - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'captcha_settings', 'name' => __( 'Captcha/Spam', 'formidable' ), 'icon' => 'frm_icon_font frm_shield_check_icon', @@ -153,7 +153,7 @@ private static function get_settings_tabs() { $sections['misc'] = array( 'name' => __( 'Miscellaneous', 'formidable' ), 'icon' => 'frm_icon_font frm_shuffle_icon', - 'class' => __CLASS__, + 'class' => self::class, 'function' => 'misc_settings', ); @@ -203,7 +203,7 @@ private static function remove_payments_sections( &$sections ) { } } - uksort( self::$removed_payments_sections, array( __CLASS__, 'payment_sections_sort_callback' ) ); + uksort( self::$removed_payments_sections, array( self::class, 'payment_sections_sort_callback' ) ); } /** @@ -240,7 +240,7 @@ public static function load_settings_tab() { if ( isset( $section['class'] ) ) { call_user_func( array( $section['class'], $section['function'] ) ); } else { - call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) ); + call_user_func( ( $section['function'] ?? $section ) ); } wp_die(); } diff --git a/classes/controllers/FrmUsageController.php b/classes/controllers/FrmUsageController.php index e1f34f09a8..f138d7add5 100644 --- a/classes/controllers/FrmUsageController.php +++ b/classes/controllers/FrmUsageController.php @@ -40,10 +40,10 @@ public static function schedule_send() { } $tracking = array( - 'day' => rand( 0, 6 ) * DAY_IN_SECONDS, - 'hour' => rand( 0, 23 ) * HOUR_IN_SECONDS, - 'minute' => rand( 0, 59 ) * MINUTE_IN_SECONDS, - 'second' => rand( 0, 59 ), + 'day' => random_int( 0, 6 ) * DAY_IN_SECONDS, + 'hour' => random_int( 0, 23 ) * HOUR_IN_SECONDS, + 'minute' => random_int( 0, 59 ) * MINUTE_IN_SECONDS, + 'second' => random_int( 0, 59 ), ); $offset = array_sum( $tracking ); diff --git a/classes/factories/FrmFieldFactory.php b/classes/factories/FrmFieldFactory.php index 765469754c..ca3f722648 100644 --- a/classes/factories/FrmFieldFactory.php +++ b/classes/factories/FrmFieldFactory.php @@ -112,7 +112,7 @@ private static function get_field_type_class( $field_type ) { FrmFieldGdprHelper::FIELD_TYPE => FrmFieldGdprHelper::get_gdpr_field_class( $field_type ), ); - $class = isset( $type_classes[ $field_type ] ) ? $type_classes[ $field_type ] : ''; + $class = $type_classes[ $field_type ] ?? ''; return apply_filters( 'frm_get_field_type_class', $class, $field_type ); } diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 761463645d..0be2ec6de2 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -56,7 +56,7 @@ public static function plugin_folder() { * @return string */ public static function plugin_path() { - return dirname( dirname( __DIR__ ) ); + return dirname(__DIR__, 2); } /** @@ -128,7 +128,7 @@ public static function admin_upgrade_link( $args, $page = '' ) { $anchor = ''; if ( is_array( $args ) ) { - $medium = isset( $args['medium'] ) ? $args['medium'] : ''; + $medium = $args['medium'] ?? ''; if ( isset( $args['content'] ) ) { $content = $args['content']; } @@ -663,7 +663,7 @@ public static function get_param( $param, $default = '', $src = 'get', $sanitize } $p = trim( $p, ']' ); - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; + $value = $value[ $p ] ?? $default; } } @@ -1024,7 +1024,7 @@ private static function allowed_html( $allowed ) { $allowed_html = $html; } elseif ( ! empty( $allowed ) ) { foreach ( (array) $allowed as $a ) { - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); + $allowed_html[ $a ] = $html[ $a ] ?? array(); } } @@ -1833,8 +1833,8 @@ public static function maybe_autocomplete_options( $args ) { */ private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) { if ( is_array( $option ) ) { - $value = isset( $option[ $args['value_key'] ] ) ? $option[ $args['value_key'] ] : ''; - $label = isset( $option[ $args['label_key'] ] ) ? $option[ $args['label_key'] ] : ''; + $value = $option[ $args['value_key'] ] ?? ''; + $label = $option[ $args['label_key'] ] ?? ''; } else { $value = $key; $label = $option; @@ -2536,11 +2536,11 @@ private static function maybe_clear_long_key( $key, $column ) { * @return string */ public static function generate_new_key( $num_chars ) { - $max_slug_value = pow( 36, $num_chars ); + $max_slug_value = 36 ** $num_chars; // We want to have at least 2 characters in the slug. $min_slug_value = 37; - return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); + return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 ); } /** @@ -2594,7 +2594,7 @@ public static function setup_edit_vars( $record, $table, $fields = '', $default ); foreach ( array( 'name', 'description' ) as $var ) { - $default_val = isset( $record->{$var} ) ? $record->{$var} : ''; + $default_val = $record->{$var} ?? ''; $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); unset( $var, $default_val ); } @@ -2621,7 +2621,7 @@ private static function prepare_field_arrays( $fields, $record, array &$values, // Don't prep default values on the form settings page. $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); } - $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; + $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id; self::fill_field_defaults( $field, $record, $values, $args ); } } @@ -2651,7 +2651,7 @@ private static function fill_field_defaults( $field, $record, array &$values, $a $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); }//end if - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; + $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type; if ( isset( $post_values['item_meta'][ $field->id ] ) ) { $new_value = $post_values['item_meta'][ $field->id ]; self::unserialize_or_decode( $new_value ); @@ -2755,7 +2755,7 @@ private static function fill_form_defaults( $post_values, array &$values ) { foreach ( array( 'before', 'after', 'submit' ) as $h ) { if ( ! isset( $values[ $h . '_html' ] ) ) { - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); + $values[ $h . '_html' ] = ( $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h ) ); } unset( $h ); } diff --git a/classes/helpers/FrmCSVExportHelper.php b/classes/helpers/FrmCSVExportHelper.php index df747a5e78..c07f9796b5 100644 --- a/classes/helpers/FrmCSVExportHelper.php +++ b/classes/helpers/FrmCSVExportHelper.php @@ -591,7 +591,7 @@ private static function get_field( $field_id ) { private static function add_field_values_to_csv( &$row ) { foreach ( self::$fields as $col ) { - $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false; + $field_value = self::$entry->metas[ $col->id ] ?? false; FrmFieldsHelper::prepare_field_value( $field_value, $col->type ); self::add_array_values_to_columns( $row, compact( 'col', 'field_value' ) ); diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php index c51172c5af..8a05031218 100644 --- a/classes/helpers/FrmEntriesHelper.php +++ b/classes/helpers/FrmEntriesHelper.php @@ -43,9 +43,9 @@ public static function setup_new_vars( $fields, $form = '', $reset = false, $arg $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 ); - $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; + $field_array['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id; $field_array['reset_value'] = $reset; - $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0'; + $field_array['in_embed_form'] = $args['in_embed_form'] ?? '0'; $field_array['original_default'] = $original_default; FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args ); @@ -195,7 +195,7 @@ public static function replace_default_message( $message, $atts ) { * @return string */ public static function prepare_display_value( $entry, $field, $atts ) { - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; + $field_value = $entry->metas[ $field->id ] ?? false; if ( FrmAppHelper::pro_is_installed() ) { $empty = empty( $field_value ); @@ -223,7 +223,7 @@ public static function prepare_display_value( $entry, $field, $atts ) { $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true ); } else { // Get all values for this field. - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; + $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false; if ( $child_values ) { $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); @@ -308,7 +308,7 @@ public static function display_value( $value, $field, $atts = array() ) { if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; - $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; + $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0; $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); $atts['truncate'] = $atts['pre_truncate']; @@ -639,7 +639,7 @@ public static function get_browser( $u_agent ) { * @since 3.0 */ public static function actions_dropdown( $atts ) { - $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); + $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); $links = self::get_action_links( $id, $atts['entry'] ); foreach ( $links as $link ) { diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index 46fe3e205a..ccec14eb64 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -71,7 +71,7 @@ public static function field_object_to_array( $field ) { self::fill_field_array( $field, $values ); - $values['custom_html'] = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : self::get_default_html( $field->type ); + $values['custom_html'] = $field->field_options['custom_html'] ?? self::get_default_html( $field->type ); return $values; } @@ -121,7 +121,7 @@ private static function prepare_front_field( &$field_array, $field, $args ) { self::fill_cleared_strings( $field, $field_array ); // Track the original field's type - $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; + $field_array['original_type'] = $field->field_options['original_type'] ?? $field->type; self::prepare_field_options_for_display( $field_array, $field, $args ); @@ -172,7 +172,7 @@ private static function fill_default_field_opts( $field, array &$values ) { } foreach ( $defaults as $opt => $default ) { - $values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default; + $values[ $opt ] = $field->field_options[ $opt ] ?? $default; if ( $check_post ) { self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] ); @@ -533,7 +533,7 @@ public static function show_fields( $fields, $errors, $form, $form_action ) { * @param array|string $value */ public static function run_wpautop( $atts, &$value ) { - $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; + $autop = $atts['wpautop'] ?? true; if ( apply_filters( 'frm_use_wpautop', $autop ) ) { if ( is_array( $value ) ) { $value = implode( "\n", $value ); @@ -599,7 +599,7 @@ public static function show_single_option( $field ) { } $base_name = 'default_value_' . $field['id']; - $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field ); + $html_id = $field['html_id'] ?? self::get_html_id( $field ); $default_type = self::get_default_value_type( $field ); $options_count = count( $field['options'] ); @@ -643,7 +643,7 @@ private static function hidden_field_option( $field ) { $opt = __( 'New Option', 'formidable' ); $checked = false; $field_name = 'default_value_' . $field['id']; - $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field ); + $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 . ']' : '' ); @@ -1098,7 +1098,7 @@ private static function get_field_shortcode_value( $atts ) { $replace_with = FrmEntryMeta::get_meta_value( $atts['entry'], $field->id ); $string_value = $replace_with; if ( is_array( $replace_with ) ) { - $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; + $sep = $atts['sep'] ?? ', '; $string_value = FrmAppHelper::safe_implode( $sep, $replace_with ); } @@ -1174,7 +1174,7 @@ public static function process_get_shortcode( $atts, $return_array = false ) { $atts['prev_val'] = ''; } - $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; + $new_value = $atts['default'] ?? $atts['prev_val']; } if ( is_array( $new_value ) && ! $return_array ) { @@ -1200,7 +1200,7 @@ public static function get_display_value( $value, $field, $atts = array() ) { public static function get_unfiltered_display_value( $atts ) { $value = $atts['value']; $field = $atts['field']; - $atts = isset( $atts['atts'] ) ? $atts['atts'] : $atts; + $atts = $atts['atts'] ?? $atts; if ( is_array( $field ) ) { $field = $field['id']; @@ -1236,7 +1236,7 @@ public static function get_user_display_name( $user_id, $user_info = 'display_na } elseif ( $user_info === 'author_link' ) { $info = get_author_posts_url( $user_id ); } else { - $info = isset( $user->$user_info ) ? $user->$user_info : ''; + $info = $user->$user_info ?? ''; } if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) { @@ -1535,7 +1535,7 @@ public static function include_other_input( $args ) { // Set up HTML ID for Other field $other_id = self::get_other_field_html_id( $args['field']['type'], $args['html_id'], $args['opt_key'] ); - $label = isset( $args['opt_label'] ) ? $args['opt_label'] : $args['field']['name']; + $label = $args['opt_label'] ?? $args['field']['name']; echo '