diff --git a/classes/controllers/FrmAddonsController.php b/classes/controllers/FrmAddonsController.php
index a46525f51c..ef6354639b 100644
--- a/classes/controllers/FrmAddonsController.php
+++ b/classes/controllers/FrmAddonsController.php
@@ -805,11 +805,7 @@ protected static function prepare_addons( &$addons ) {
} else {
$slug = $id;
- if ( isset( $addon['file'] ) ) {
- $base_file = $addon['file'];
- } else {
- $base_file = 'formidable-' . $slug;
- }
+ $base_file = $addon['file'] ?? 'formidable-' . $slug;
$file_name = $base_file . '/' . $base_file . '.php';
diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php
index 5afd75eb96..5a2cfed69b 100644
--- a/classes/controllers/FrmAppController.php
+++ b/classes/controllers/FrmAppController.php
@@ -611,11 +611,7 @@ public static function admin_init() {
'content' => 'submenu-upgrade',
);
- if ( $redirect ) {
- $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm );
- } else {
- $redirect = FrmAppHelper::admin_upgrade_link( $utm );
- }
+ $redirect = $redirect ? FrmAppHelper::maybe_add_missing_utm( $redirect, $utm ) : FrmAppHelper::admin_upgrade_link( $utm );
wp_redirect( $redirect );
die();
diff --git a/classes/controllers/FrmXMLController.php b/classes/controllers/FrmXMLController.php
index ff153a66a0..3fdfa89727 100644
--- a/classes/controllers/FrmXMLController.php
+++ b/classes/controllers/FrmXMLController.php
@@ -109,16 +109,10 @@ public static function install_template() {
$response['redirect'] = get_permalink( $post_id );
}
} else {
- if ( isset( $imported['error'] ) ) {
- $message = $imported['error'];
- } else {
- $message = __( 'There was an error importing form', 'formidable' );
- }
-
+ $message = $imported['error'] ?? __( 'There was an error importing form', 'formidable' );
$response = array(
'message' => $message,
);
-
}//end if
/**
diff --git a/classes/factories/FrmFieldFactory.php b/classes/factories/FrmFieldFactory.php
index c1f6a5bc0f..9f56188b2c 100644
--- a/classes/factories/FrmFieldFactory.php
+++ b/classes/factories/FrmFieldFactory.php
@@ -75,13 +75,7 @@ public static function get_field_object( $field ) {
public static function get_field_type( $field_type, $field = 0 ) {
$class = self::get_field_type_class( $field_type );
- if ( empty( $class ) ) {
- $field = new FrmFieldDefault( $field, $field_type );
- } else {
- $field = new $class( $field, $field_type );
- }
-
- return $field;
+ return empty( $class ) ? new FrmFieldDefault( $field, $field_type ) : new $class( $field, $field_type );
}
/**
diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php
index 365a7c2ed7..695faf4fb6 100644
--- a/classes/helpers/FrmAppHelper.php
+++ b/classes/helpers/FrmAppHelper.php
@@ -130,11 +130,7 @@ public static function admin_upgrade_link( $args, $page = '' ) {
$page = 'https://formidableforms.com/lite-upgrade/';
}
- if ( is_array( $args ) ) {
- $args = self::adjust_legacy_utm_args( $args );
- } else {
- $args = array( 'campaign' => $args );
- }
+ $args = is_array( $args ) ? self::adjust_legacy_utm_args( $args ) : array( 'campaign' => $args );
$query_args = array(
'utm_source' => 'plugin',
@@ -178,11 +174,7 @@ public static function admin_upgrade_link( $args, $page = '' ) {
* @return array
*/
private static function maybe_add_utm_license( $query_args, $link = '' ) {
- if ( isset( $query_args['utm_medium'] ) ) {
- $medium = $query_args['utm_medium'];
- } else {
- $medium = self::pull_medium_from_link( $link );
- }
+ $medium = $query_args['utm_medium'] ?? self::pull_medium_from_link( $link );
if ( 'pro' === $medium && is_callable( 'FrmProAddonsController::get_readable_license_type' ) ) {
$query_args['utm_license'] = strtolower( FrmProAddonsController::get_readable_license_type() );
@@ -1631,11 +1623,7 @@ public static function print_admin_banner( $should_show_lite_upgrade ) {
'content' => 'lite-banner',
);
- if ( $upgrade_link ) {
- $upgrade_link = self::maybe_add_missing_utm( $upgrade_link, $utm );
- } else {
- $upgrade_link = self::admin_upgrade_link( $utm );
- }
+ $upgrade_link = $upgrade_link ? self::maybe_add_missing_utm( $upgrade_link, $utm ) : self::admin_upgrade_link( $utm );
printf(
/* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */
@@ -2470,11 +2458,7 @@ public static function recursive_function_map( $value, $function ) {
if ( is_array( $value ) ) {
$original_function = $function;
- if ( count( $value ) ) {
- $function = explode( ', ', FrmDb::prepare_array_values( $value, $function ) );
- } else {
- $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 );
@@ -2673,11 +2657,7 @@ public static function get_user_id_param( $user_id ) {
if ( $user_id === 'current' ) {
$user_id = get_current_user_id();
} else {
- if ( is_email( $user_id ) ) {
- $user = get_user_by( 'email', $user_id );
- } else {
- $user = get_user_by( 'login', $user_id );
- }
+ $user = is_email( $user_id ) ? get_user_by( 'email', $user_id ) : get_user_by( 'login', $user_id );
if ( $user ) {
$user_id = $user->ID;
@@ -3257,11 +3237,7 @@ public static function get_localized_date( $date_format, $date ) {
* @return string $time_ago
*/
public static function human_time_diff( $from, $to = '', $levels = 1 ) {
- if ( empty( $to ) && 0 !== $to ) {
- $now = new DateTime();
- } else {
- $now = new DateTime( '@' . $to );
- }
+ $now = empty( $to ) && 0 !== $to ? new DateTime() : new DateTime( '@' . $to );
$ago = new DateTime( '@' . $from );
@@ -3671,11 +3647,7 @@ public static function unserialize_or_decode( &$value ) {
return;
}
- if ( is_serialized( $value ) ) {
- $value = self::maybe_unserialize_array( $value );
- } else {
- $value = self::maybe_json_decode( $value, false );
- }
+ $value = is_serialized( $value ) ? self::maybe_unserialize_array( $value ) : self::maybe_json_decode( $value, false );
}
/**
diff --git a/classes/helpers/FrmEmailSummaryHelper.php b/classes/helpers/FrmEmailSummaryHelper.php
index 12c9d6aef4..1b9f267d49 100644
--- a/classes/helpers/FrmEmailSummaryHelper.php
+++ b/classes/helpers/FrmEmailSummaryHelper.php
@@ -402,11 +402,7 @@ public static function show_comparison( $diff ) {
* @return string
*/
public static function get_section_style( $border_pos = 'top' ) {
- if ( $border_pos ) {
- $border = 'border-' . $border_pos . ': 1px solid #eaecf0;';
- } else {
- $border = '';
- }
+ $border = $border_pos ? 'border-' . $border_pos . ': 1px solid #eaecf0;' : '';
return 'padding: 3em 4.375em;' . $border;
}
diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php
index 4e5cb1b4e2..d380d0c0ce 100644
--- a/classes/helpers/FrmEntriesHelper.php
+++ b/classes/helpers/FrmEntriesHelper.php
@@ -202,11 +202,7 @@ public static function replace_default_message( $message, $atts ) {
foreach ( $shortcodes[0] as $short_key => $tag ) {
$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
- if ( ! empty( $add_atts ) ) {
- $this_atts = array_merge( $atts, $add_atts );
- } else {
- $this_atts = $atts;
- }
+ $this_atts = ! empty( $add_atts ) ? array_merge( $atts, $add_atts ) : $atts;
$default = FrmEntriesController::show_entry_shortcode( $this_atts );
@@ -691,11 +687,7 @@ public static function get_browser( $u_agent ) {
if ( $i > 1 ) {
// We will have two since we are not using 'other' argument yet
// see if version is before or after the name.
- if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
- $version = $matches['version'][0];
- } else {
- $version = $matches['version'][1];
- }
+ $version = strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ? $matches['version'][0] : $matches['version'][1];
} elseif ( $i === 1 ) {
$version = $matches['version'][0];
} else {
diff --git a/classes/helpers/FrmEntriesListHelper.php b/classes/helpers/FrmEntriesListHelper.php
index 7589f14c31..d0666b4dcb 100644
--- a/classes/helpers/FrmEntriesListHelper.php
+++ b/classes/helpers/FrmEntriesListHelper.php
@@ -376,13 +376,8 @@ public function single_row( $item, $style = '' ) {
if ( $this->column_name === 'cb' ) {
$r .= "
$checkbox | ";
} else {
- if ( in_array( $column_name, $hidden, true ) ) {
- $val = '';
- } else {
- $val = $this->column_value( $item );
- }
-
- $r .= "";
+ $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item );
+ $r .= " | ";
if ( $column_name == $action_col ) {
$edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id );
diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php
index 2cdf621e7f..5737492f05 100644
--- a/classes/helpers/FrmFieldsHelper.php
+++ b/classes/helpers/FrmFieldsHelper.php
@@ -499,11 +499,7 @@ private static function maybe_replace_substrings_with_field_name( $msg, $error,
// Use the "This value"/"This field" placeholder strings if field name is empty.
if ( ! $field_name ) {
- if ( 'unique_msg' === $error ) {
- $field_name = __( 'This value', 'formidable' );
- } else {
- $field_name = __( 'This field', 'formidable' );
- }
+ $field_name = 'unique_msg' === $error ? __( 'This value', 'formidable' ) : __( 'This field', 'formidable' );
}
return str_replace( $substrings, $field_name, $msg );
}
@@ -907,11 +903,7 @@ public static function value_meets_condition( $observed_value, $cond, $hide_opt
} elseif ( $cond === 'LIKE' || $cond === 'not LIKE' ) {
$m = stripos( $observed_value, $hide_opt );
- if ( $cond === 'not LIKE' ) {
- $m = $m === false;
- } else {
- $m = $m !== false;
- }
+ $m = $cond === 'not LIKE' ? $m === false : $m !== false;
} elseif ( $cond === '%LIKE' ) {
// ends with
$length = strlen( $hide_opt );
@@ -2620,11 +2612,7 @@ private static function fill_image_setting_addon_link( $option ) {
$upgrading = FrmAddonsController::install_link( $option['addon'] );
- if ( isset( $upgrading['url'] ) ) {
- $install_data = wp_json_encode( $upgrading );
- } else {
- $install_data = '';
- }
+ $install_data = isset( $upgrading['url'] ) ? wp_json_encode( $upgrading ) : '';
$custom_attrs['data-oneclick'] = $install_data;
$custom_attrs['data-requires'] = FrmFormsHelper::get_plan_required( $upgrading );
diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php
index 2350cc4a8f..4e5e7dabb6 100644
--- a/classes/helpers/FrmFormsHelper.php
+++ b/classes/helpers/FrmFormsHelper.php
@@ -255,13 +255,7 @@ public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
* @return string
*/
public static function get_field_link_name( $field_type ) {
- if ( is_array( $field_type ) ) {
- $field_label = $field_type['name'];
- } else {
- $field_label = $field_type;
- }
-
- return $field_label;
+ return is_array( $field_type ) ? $field_type['name'] : $field_type;
}
/**
@@ -272,13 +266,7 @@ public static function get_field_link_name( $field_type ) {
* @return string
*/
public static function get_field_link_icon( $field_type ) {
- if ( is_array( $field_type ) && isset( $field_type['icon'] ) ) {
- $icon = $field_type['icon'];
- } else {
- $icon = 'frm_icon_font frm_pencil_icon';
- }
-
- return $icon;
+ return is_array( $field_type ) && isset( $field_type['icon'] ) ? $field_type['icon'] : 'frm_icon_font frm_pencil_icon';
}
/**
@@ -1324,12 +1312,7 @@ public static function edit_form_link_label( $data ) {
* @return int|string
*/
private static function get_form_id_from_data( $data ) {
- if ( is_object( $data ) ) {
- $form_id = $data->id;
- } else {
- $form_id = $data;
- }
- return $form_id;
+ return is_object( $data ) ? $data->id : $data;
}
/**
@@ -1409,11 +1392,7 @@ public static function delete_trash_info( $id, $status ) {
if ( 'trash' === $status ) {
$info = $labels['restore'];
} elseif ( current_user_can( 'frm_delete_forms' ) ) {
- if ( EMPTY_TRASH_DAYS ) {
- $info = $labels['trash'];
- } else {
- $info = $labels['delete'];
- }
+ $info = EMPTY_TRASH_DAYS ? $labels['trash'] : $labels['delete'];
} else {
$info = array();
}
diff --git a/classes/helpers/FrmFormsListHelper.php b/classes/helpers/FrmFormsListHelper.php
index af9928f77e..9f91c8bf44 100644
--- a/classes/helpers/FrmFormsListHelper.php
+++ b/classes/helpers/FrmFormsListHelper.php
@@ -202,11 +202,7 @@ public function get_views() {
foreach ( $statuses as $status => $name ) {
- if ( $status == $form_type ) {
- $class = ' class="current"';
- } else {
- $class = '';
- }
+ $class = $status == $form_type ? ' class="current"' : '';
if ( $counts->{$status} || 'draft' !== $status ) {
/* translators: %1$s: Status, %2$s: Number of items */
diff --git a/classes/helpers/FrmListHelper.php b/classes/helpers/FrmListHelper.php
index 68ec069ac2..1f2b95716e 100644
--- a/classes/helpers/FrmListHelper.php
+++ b/classes/helpers/FrmListHelper.php
@@ -764,13 +764,7 @@ private function current_url() {
* @return string
*/
private function add_page_link( $atts ) {
- if ( $atts['disabled'] ) {
- $link = $this->add_disabled_link( $atts['arrow'] );
- } else {
- $link = $this->add_active_link( $atts );
- }
-
- return $link;
+ return $atts['disabled'] ? $this->add_disabled_link( $atts['arrow'] ) : $this->add_active_link( $atts );
}
/**
@@ -966,17 +960,9 @@ public function print_column_headers( $with_id = true ) {
$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 );
- if ( isset( $_GET['orderby'] ) ) {
- $current_orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
- } else {
- $current_orderby = '';
- }
+ $current_orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : '';
- if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
- $current_order = 'desc';
- } else {
- $current_order = 'asc';
- }
+ $current_order = isset( $_GET['order'] ) && 'desc' === $_GET['order'] ? 'desc' : 'asc';
FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
diff --git a/classes/helpers/FrmStylesHelper.php b/classes/helpers/FrmStylesHelper.php
index 8e0752faa1..c3895d2eb1 100644
--- a/classes/helpers/FrmStylesHelper.php
+++ b/classes/helpers/FrmStylesHelper.php
@@ -231,11 +231,7 @@ public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
* @return string RGB value without the rgb() wrapper.
*/
public static function hex2rgb( $color ) {
- if ( 0 === strpos( $color, 'rgb' ) ) {
- $rgb = self::get_rgb_array_from_rgb( $color );
- } else {
- $rgb = self::get_rgb_array_from_hex( $color );
- }
+ $rgb = 0 === strpos( $color, 'rgb' ) ? self::get_rgb_array_from_rgb( $color ) : self::get_rgb_array_from_hex( $color );
return implode( ',', $rgb );
}
diff --git a/classes/helpers/FrmXMLHelper.php b/classes/helpers/FrmXMLHelper.php
index 94a70715a4..bb3aad7b5c 100644
--- a/classes/helpers/FrmXMLHelper.php
+++ b/classes/helpers/FrmXMLHelper.php
@@ -222,11 +222,7 @@ private static function get_term_parent_id( $t ) {
if ( ! empty( $parent ) ) {
$parent = term_exists( (string) $t->term_parent, (string) $t->term_taxonomy );
- if ( $parent ) {
- $parent = $parent['term_id'];
- } else {
- $parent = 0;
- }
+ $parent = $parent ? $parent['term_id'] : 0;
}
return $parent;
@@ -1705,11 +1701,7 @@ public static function prepare_form_options_for_export( $options ) {
$style_name = FrmDb::get_var( $table, $where, $select );
- if ( $style_name ) {
- $options['custom_style'] = $style_name;
- } else {
- $options['custom_style'] = 1;
- }
+ $options['custom_style'] = $style_name ? $style_name : 1;
}
self::remove_default_form_options( $options );
$options = serialize( $options );
@@ -2261,11 +2253,7 @@ private static function format_email_data( &$atts, $notification ) {
* @return void
*/
private static function format_email_to_data( &$atts, $notification ) {
- if ( isset( $notification['email_to'] ) ) {
- $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
- } else {
- $atts['email_to'] = array();
- }
+ $atts['email_to'] = isset( $notification['email_to'] ) ? preg_split( '/ (,|;) /', $notification['email_to'] ) : array();
if ( isset( $notification['also_email_to'] ) ) {
$email_fields = (array) $notification['also_email_to'];
diff --git a/classes/models/FrmAddon.php b/classes/models/FrmAddon.php
index 0f1d13e7eb..659d58e928 100644
--- a/classes/models/FrmAddon.php
+++ b/classes/models/FrmAddon.php
@@ -732,11 +732,7 @@ private function checked_recently( $time, $required_status = '' ) {
* @return array
*/
private function last_checked() {
- if ( is_multisite() ) {
- $last_checked = get_site_option( $this->transient_key() );
- } else {
- $last_checked = get_option( $this->transient_key() );
- }
+ $last_checked = is_multisite() ? get_site_option( $this->transient_key() ) : get_option( $this->transient_key() );
if ( $last_checked && ! is_array( $last_checked ) ) {
// Get string into array for existing values.
@@ -1031,11 +1027,7 @@ public function send_mothership_request( $action ) {
$json_res = json_decode( $body, true );
if ( null !== $json_res ) {
- if ( is_array( $json_res ) && isset( $json_res['error'] ) ) {
- $message = $json_res['error'];
- } else {
- $message = $json_res;
- }
+ $message = is_array( $json_res ) && isset( $json_res['error'] ) ? $json_res['error'] : $json_res;
} elseif ( ! empty( $resp['response'] ) && ! empty( $resp['response']['code'] ) ) {
$resp['body'] = wp_strip_all_tags( $resp['body'] );
diff --git a/classes/models/FrmAntiSpam.php b/classes/models/FrmAntiSpam.php
index 64bad48afd..b9d6d7d2cd 100644
--- a/classes/models/FrmAntiSpam.php
+++ b/classes/models/FrmAntiSpam.php
@@ -56,11 +56,7 @@ public function init() {
private function get( $current = true ) {
// If $current was not passed, or it is true, we use the current timestamp.
// If $current was passed in as a string, we'll use that passed in timestamp.
- if ( $current !== true ) {
- $time = $current;
- } else {
- $time = time();
- }
+ $time = $current !== true ? $current : time();
// Format the timestamp to be less exact, as we want to deal in days.
// June 19th, 2020 would get formatted as: 1906202017125.
diff --git a/classes/models/FrmEmail.php b/classes/models/FrmEmail.php
index cf42d50d00..4706084801 100644
--- a/classes/models/FrmEmail.php
+++ b/classes/models/FrmEmail.php
@@ -672,13 +672,7 @@ private function prepare_email_setting( $value, $user_id_args ) {
private function explode_emails( $emails ) {
$emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
- if ( is_array( $emails ) ) {
- $emails = array_map( 'trim', $emails );
- } else {
- $emails = trim( $emails );
- }
-
- return $emails;
+ return is_array( $emails ) ? array_map( 'trim', $emails ) : trim( $emails );
}
/**
diff --git a/classes/models/FrmEntry.php b/classes/models/FrmEntry.php
index 6bafaffb0b..b56077202c 100644
--- a/classes/models/FrmEntry.php
+++ b/classes/models/FrmEntry.php
@@ -604,11 +604,7 @@ public static function exists( $id ) {
return true;
}
- if ( is_numeric( $id ) ) {
- $where = array( 'id' => $id );
- } else {
- $where = array( 'item_key' => $id );
- }
+ $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'item_key' => $id );
$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
@@ -960,13 +956,7 @@ private static function get_created_at( $values ) {
* @return string
*/
private static function get_updated_at( $values ) {
- if ( isset( $values['updated_at'] ) ) {
- $updated_at = $values['updated_at'];
- } else {
- $updated_at = self::get_created_at( $values );
- }
-
- return $updated_at;
+ return $values['updated_at'] ?? self::get_created_at( $values );
}
/**
@@ -1027,13 +1017,7 @@ private static function insert_entry_into_database( $new_values ) {
$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
- if ( ! $query_results ) {
- $entry_id = false;
- } else {
- $entry_id = $wpdb->insert_id;
- }
-
- return $entry_id;
+ return ! $query_results ? false : $wpdb->insert_id;
}
/**
diff --git a/classes/models/FrmEntryFormatter.php b/classes/models/FrmEntryFormatter.php
index 1bf67f9d81..6face9330e 100644
--- a/classes/models/FrmEntryFormatter.php
+++ b/classes/models/FrmEntryFormatter.php
@@ -142,12 +142,7 @@ public function __construct( $atts ) {
*/
protected function init_entry( $atts ) {
if ( isset( $atts['entry'] ) && is_object( $atts['entry'] ) ) {
-
- if ( isset( $atts['entry']->metas ) ) {
- $this->entry = $atts['entry'];
- } else {
- $this->entry = FrmEntry::getOne( $atts['entry']->id, true );
- }
+ $this->entry = isset( $atts['entry']->metas ) ? $atts['entry'] : FrmEntry::getOne( $atts['entry']->id, true );
} elseif ( ! empty( $atts['id'] ) ) {
$this->entry = FrmEntry::getOne( $atts['id'], true );
}
@@ -205,11 +200,7 @@ protected function init_format( $atts ) {
} elseif ( $atts['format'] === 'json' ) {
$this->format = 'json';
} elseif ( $atts['format'] === 'text' ) {
- if ( $this->is_plain_text === true ) {
- $this->format = 'plain_text_block';
- } else {
- $this->format = 'table';
- }
+ $this->format = $this->is_plain_text === true ? 'plain_text_block' : 'table';
}
/**
diff --git a/classes/models/FrmEntryMeta.php b/classes/models/FrmEntryMeta.php
index 004c969f17..5c41a15cd9 100644
--- a/classes/models/FrmEntryMeta.php
+++ b/classes/models/FrmEntryMeta.php
@@ -537,11 +537,7 @@ private static function get_ids_query( $where, $order_by, $limit, $unique, $args
if ( ! $args['is_draft'] ) {
$where['e.is_draft'] = 0;
} elseif ( is_numeric( $args['is_draft'] ) ) {
- if ( class_exists( 'FrmAbandonmentHooksController', false ) ) {
- $where['e.is_draft'] = absint( $args['is_draft'] );
- } else {
- $where['e.is_draft'] = 1;
- }
+ $where['e.is_draft'] = class_exists( 'FrmAbandonmentHooksController', false ) ? absint( $args['is_draft'] ) : 1;
} elseif ( 'both' === $args['is_draft'] && class_exists( 'FrmAbandonmentHooksController', false ) ) {
$where['e.is_draft'] = array( 0, 1 );
} elseif ( false !== strpos( $args['is_draft'], ',' ) ) {
diff --git a/classes/models/FrmEntryValidate.php b/classes/models/FrmEntryValidate.php
index 75ed323b57..9de7072c05 100644
--- a/classes/models/FrmEntryValidate.php
+++ b/classes/models/FrmEntryValidate.php
@@ -149,12 +149,7 @@ public static function validate_field( $posted_field, &$errors, $values, $args =
);
$args = wp_parse_args( $args, $defaults );
- if ( empty( $args['parent_field_id'] ) ) {
- $value = $values['item_meta'][ $args['id'] ] ?? '';
- } else {
- // value is from a nested form
- $value = $values;
- }
+ $value = empty( $args['parent_field_id'] ) ? ( $values['item_meta'][ $args['id'] ] ?? '' ) : $values;
// Check for values in "Other" fields
FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
diff --git a/classes/models/FrmEntryValues.php b/classes/models/FrmEntryValues.php
index 0e0e557c68..3e85ed98f9 100644
--- a/classes/models/FrmEntryValues.php
+++ b/classes/models/FrmEntryValues.php
@@ -179,12 +179,7 @@ protected function init_exclude_fields( $atts ) {
*/
private function prepare_array_property( $index, $atts ) {
if ( ! empty( $atts[ $index ] ) ) {
-
- if ( is_array( $atts[ $index ] ) ) {
- $property = $atts[ $index ];
- } else {
- $property = explode( ',', $atts[ $index ] );
- }
+ $property = is_array( $atts[ $index ] ) ? $atts[ $index ] : explode( ',', $atts[ $index ] );
} else {
$property = array();
}
diff --git a/classes/models/FrmField.php b/classes/models/FrmField.php
index 1bc3a695f0..4c15297ebc 100644
--- a/classes/models/FrmField.php
+++ b/classes/models/FrmField.php
@@ -411,11 +411,7 @@ public static function create( $values, $return = true ) {
foreach ( $new_values as $k => $v ) {
if ( is_array( $v ) ) {
- if ( $k === 'default_value' ) {
- $new_values[ $k ] = FrmAppHelper::maybe_json_encode( $v );
- } else {
- $new_values[ $k ] = serialize( $v );
- }
+ $new_values[ $k ] = $k === 'default_value' ? FrmAppHelper::maybe_json_encode( $v ) : serialize( $v );
}
unset( $k, $v );
}
@@ -867,13 +863,8 @@ public static function get_type( $id, $col = 'type' ) {
if ( $field ) {
$type = $field->{$col};
} else {
- if ( is_numeric( $id ) ) {
- $where = array( 'id' => $id );
- } else {
- $where = array( 'field_key' => $id );
- }
-
- $type = FrmDb::get_var( 'frm_fields', $where, $col );
+ $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'field_key' => $id );
+ $type = FrmDb::get_var( 'frm_fields', $where, $col );
}
return $type;
@@ -1480,13 +1471,7 @@ public static function is_option_value_in_object( $field, $option ) {
* @return mixed
*/
public static function get_option( $field, $option ) {
- if ( is_array( $field ) ) {
- $option = self::get_option_in_array( $field, $option );
- } else {
- $option = self::get_option_in_object( $field, $option );
- }
-
- return $option;
+ return is_array( $field ) ? self::get_option_in_array( $field, $option ) : self::get_option_in_object( $field, $option );
}
/**
@@ -1525,11 +1510,7 @@ public static function get_option_in_object( $field, $option ) {
* @return bool
*/
public static function is_repeating_field( $field ) {
- if ( is_array( $field ) ) {
- $is_repeating_field = ( 'divider' === $field['type'] );
- } else {
- $is_repeating_field = ( 'divider' === $field->type );
- }
+ $is_repeating_field = is_array( $field ) ? 'divider' === $field['type'] : 'divider' === $field->type;
return $is_repeating_field && self::is_option_true( $field, 'repeat' );
}
diff --git a/classes/models/FrmFieldOption.php b/classes/models/FrmFieldOption.php
index 124b3f5662..023a185a8b 100644
--- a/classes/models/FrmFieldOption.php
+++ b/classes/models/FrmFieldOption.php
@@ -58,11 +58,7 @@ public function __construct( $option_key, $option, $args = array() ) {
* @return void
*/
private function set_option_label() {
- if ( is_array( $this->option ) ) {
- $this->option_label = ( $this->option['label'] ?? reset( $this->option ) );
- } else {
- $this->option_label = $this->option;
- }
+ $this->option_label = is_array( $this->option ) ? ( $this->option['label'] ?? reset( $this->option ) ) : $this->option;
}
/**
diff --git a/classes/models/FrmForm.php b/classes/models/FrmForm.php
index b754cabe5f..7dd9a2653a 100644
--- a/classes/models/FrmForm.php
+++ b/classes/models/FrmForm.php
@@ -365,11 +365,7 @@ public static function update_fields( $id, $values ) {
unset( $all_fields );
foreach ( $values['item_meta'] as $field_id => $default_value ) {
- if ( isset( $field_array[ $field_id ] ) ) {
- $field = $field_array[ $field_id ];
- } else {
- $field = FrmField::getOne( $field_id );
- }
+ $field = $field_array[ $field_id ] ?? FrmField::getOne( $field_id );
if ( ! $field ) {
continue;
@@ -481,11 +477,7 @@ private static function sanitize_field_opt( $opt, &$value ) {
return;
}
- if ( $opt === 'calc' ) {
- $value = self::sanitize_calc( $value );
- } else {
- $value = FrmAppHelper::kses( $value, 'all' );
- }
+ $value = $opt === 'calc' ? self::sanitize_calc( $value ) : FrmAppHelper::kses( $value, 'all' );
$value = trim( $value );
}
@@ -882,11 +874,7 @@ public static function getOne( $id, $blog_id = false ) {
}
}
- if ( is_numeric( $id ) ) {
- $where = array( 'id' => $id );
- } else {
- $where = array( 'form_key' => $id );
- }
+ $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'form_key' => $id );
$results = FrmDb::get_row( $table_name, $where );
@@ -1190,11 +1178,7 @@ public static function get_admin_params( $form = null ) {
* @return int|string
*/
public static function get_current_form_id( $default_form = 'none' ) {
- if ( 'first' === $default_form ) {
- $form = self::get_current_form();
- } else {
- $form = self::maybe_get_current_form();
- }
+ $form = 'first' === $default_form ? self::get_current_form() : self::maybe_get_current_form();
return $form ? $form->id : 0;
}
diff --git a/classes/models/FrmInstallPlugin.php b/classes/models/FrmInstallPlugin.php
index 6666e4f6b9..fbba701816 100644
--- a/classes/models/FrmInstallPlugin.php
+++ b/classes/models/FrmInstallPlugin.php
@@ -36,13 +36,7 @@ public function get_activate_link() {
if ( $this->is_installed() && $this->is_active() ) {
return '';
}
-
- if ( $this->is_installed() ) {
- $url = $this->activate_url();
- } else {
- $url = $this->install_url();
- }
- return $url;
+ return $this->is_installed() ? $this->activate_url() : $this->install_url();
}
/**
diff --git a/classes/models/FrmReviews.php b/classes/models/FrmReviews.php
index 984d46bdd6..4bdc96233f 100644
--- a/classes/models/FrmReviews.php
+++ b/classes/models/FrmReviews.php
@@ -107,13 +107,7 @@ private function review() {
return;
}
- if ( $entries <= 100 ) {
- // round to the nearest 10
- $entries = floor( $entries / 10 ) * 10;
- } else {
- // round to the nearest 50
- $entries = floor( $entries / 50 ) * 50;
- }
+ $entries = $entries <= 100 ? floor( $entries / 10 ) * 10 : floor( $entries / 50 ) * 50;
$name = $user->first_name;
diff --git a/classes/models/FrmStyle.php b/classes/models/FrmStyle.php
index 10965b4b38..4705c417a4 100644
--- a/classes/models/FrmStyle.php
+++ b/classes/models/FrmStyle.php
@@ -265,11 +265,7 @@ public function sanitize_post_content( $settings ) {
$sanitized_settings = array();
foreach ( $valid_keys as $key ) {
- if ( isset( $settings[ $key ] ) ) {
- $sanitized_settings[ $key ] = sanitize_textarea_field( $settings[ $key ] );
- } else {
- $sanitized_settings[ $key ] = $defaults[ $key ];
- }
+ $sanitized_settings[ $key ] = isset( $settings[ $key ] ) ? sanitize_textarea_field( $settings[ $key ] ) : $defaults[ $key ];
if ( 'custom_css' !== $key && 'single_style_custom_css' !== $key ) {
$sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] );
@@ -489,11 +485,7 @@ public function get_one() {
if ( 'default' === $this->id ) {
$style = $this->get_default_style();
- if ( $style ) {
- $this->id = $style->ID;
- } else {
- $this->id = 0;
- }
+ $this->id = $style ? $style->ID : 0;
return $style;
}
diff --git a/classes/models/fields/FrmFieldCaptcha.php b/classes/models/fields/FrmFieldCaptcha.php
index cb70d6c327..9af6e9b19d 100644
--- a/classes/models/fields/FrmFieldCaptcha.php
+++ b/classes/models/fields/FrmFieldCaptcha.php
@@ -31,13 +31,7 @@ public static function get_captcha_image_name() {
$frm_settings = FrmAppHelper::get_settings();
$active_captcha = $frm_settings->active_captcha;
- if ( $active_captcha === 'recaptcha' && $frm_settings->re_type === 'v3' ) {
- $image_name = 'recaptcha_v3';
- } else {
- $image_name = $active_captcha;
- }
-
- return $image_name;
+ return $active_captcha === 'recaptcha' && $frm_settings->re_type === 'v3' ? 'recaptcha_v3' : $active_captcha;
}
/**
diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php
index e1e341ca5b..97e3ac05cc 100644
--- a/classes/models/fields/FrmFieldType.php
+++ b/classes/models/fields/FrmFieldType.php
@@ -259,13 +259,7 @@ protected function primary_label_element() {
* @return string
*/
protected function for_label_html() {
- if ( $this->has_for_label ) {
- $for = 'for="field_[key]"';
- } else {
- $for = '';
- }
-
- return $for;
+ return $this->has_for_label ? 'for="field_[key]"' : '';
}
/** Form builder **/
@@ -828,11 +822,7 @@ public function default_value_to_string( &$default_value ) {
$is_empty = array_filter( $default_value );
- if ( empty( $is_empty ) ) {
- $default_value = '';
- } else {
- $default_value = implode( ',', $default_value );
- }
+ $default_value = empty( $is_empty ) ? '' : implode( ',', $default_value );
}
/**
@@ -1565,11 +1555,7 @@ 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;
- if ( $aria_describedby_exists ) {
- $describedby = preg_split( '/\s+/', esc_attr( trim( $matches[1][0] ) ) );
- } else {
- $describedby = array();
- }
+ $describedby = $aria_describedby_exists ? preg_split( '/\s+/', esc_attr( trim( $matches[1][0] ) ) ) : array();
$error_comes_first = true;
@@ -1939,11 +1925,7 @@ protected function get_multi_opts_for_import( $value ) {
* @return void
*/
protected function fill_values( &$value, $defaults ) {
- if ( empty( $value ) ) {
- $value = $defaults;
- } else {
- $value = array_merge( $defaults, (array) $value );
- }
+ $value = empty( $value ) ? $defaults : array_merge( $defaults, (array) $value );
}
/**
diff --git a/classes/models/fields/FrmFieldUserID.php b/classes/models/fields/FrmFieldUserID.php
index 948cbd3a97..4d2d479d10 100644
--- a/classes/models/fields/FrmFieldUserID.php
+++ b/classes/models/fields/FrmFieldUserID.php
@@ -113,11 +113,7 @@ protected function prepare_display_value( $value, $atts ) {
*/
private function prepare_user_info_attribute( $atts ) {
if ( isset( $atts['show'] ) ) {
- if ( $atts['show'] === 'id' ) {
- $user_info = 'ID';
- } else {
- $user_info = $atts['show'];
- }
+ $user_info = $atts['show'] === 'id' ? 'ID' : $atts['show'];
} else {
$user_info = apply_filters( 'frm_user_id_display', 'display_name' );
}
diff --git a/classes/views/frm-entries/_sidebar-shared-pub.php b/classes/views/frm-entries/_sidebar-shared-pub.php
index 66df1bdbb4..1976caf8f2 100644
--- a/classes/views/frm-entries/_sidebar-shared-pub.php
+++ b/classes/views/frm-entries/_sidebar-shared-pub.php
@@ -15,13 +15,7 @@
$date_format = get_option( 'date_format' );
- if ( $date_format ) {
- // Use short months since the sidebar space is limited.
- $date_format = str_replace( 'F', 'M', $date_format );
- } else {
- // Fallback if there is no option in the database.
- $date_format = __( 'M j, Y', 'formidable' );
- }
+ $date_format = $date_format ? str_replace( 'F', 'M', $date_format ) : __( 'M j, Y', 'formidable' );
/**
* @since 6.25
diff --git a/classes/views/shared/admin-cta.php b/classes/views/shared/admin-cta.php
index b837feef3d..cd9aab6ed1 100644
--- a/classes/views/shared/admin-cta.php
+++ b/classes/views/shared/admin-cta.php
@@ -12,11 +12,7 @@
die( 'You are not allowed to call this page directly.' );
}
-if ( false === strpos( $attributes['class'], 'frm-gradient' ) ) {
- $button_class = 'frm-button-primary';
-} else {
- $button_class = 'frm-button-secondary';
-}
+$button_class = false === strpos( $attributes['class'], 'frm-gradient' ) ? 'frm-button-primary' : 'frm-button-secondary';
?>
>
$code_label ) {
- if ( isset( $uid ) ) {
- $code = str_replace( '|user_id|', $uid, $code );
- } else {
- $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 ';
diff --git a/rector.php b/rector.php
index c90ffa0f5c..fc465e1465 100644
--- a/rector.php
+++ b/rector.php
@@ -12,12 +12,10 @@
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
-use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector;
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
-use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector;
use Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector;
@@ -87,7 +85,6 @@
CountArrayToEmptyArrayComparisonRector::class,
DisallowedEmptyRuleFixerRector::class,
SimplifyIfReturnBoolRector::class,
- SimplifyIfElseToTernaryRector::class,
LocallyCalledStaticMethodToNonStaticRector::class,
// This changes \t to an actual tab character. We don't want this rule.
JoinStringConcatRector::class,
diff --git a/square/controllers/FrmSquareLiteEventsController.php b/square/controllers/FrmSquareLiteEventsController.php
index 6f46649422..c314d4104c 100644
--- a/square/controllers/FrmSquareLiteEventsController.php
+++ b/square/controllers/FrmSquareLiteEventsController.php
@@ -127,11 +127,7 @@ private function count_failed_event( $event_id ) {
$transient_name = 'frm_square_failed_event_' . $event_id;
$transient = get_transient( $transient_name );
- if ( is_int( $transient ) ) {
- $failed_count = $transient + 1;
- } else {
- $failed_count = 1;
- }
+ $failed_count = is_int( $transient ) ? $transient + 1 : 1;
$maximum_retries = 3;
diff --git a/square/helpers/FrmSquareLiteConnectHelper.php b/square/helpers/FrmSquareLiteConnectHelper.php
index 9093a5544c..921f71787c 100644
--- a/square/helpers/FrmSquareLiteConnectHelper.php
+++ b/square/helpers/FrmSquareLiteConnectHelper.php
@@ -76,15 +76,8 @@ private static function render_settings_for_mode( $mode ) {
|