Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
6 changes: 1 addition & 5 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 1 addition & 7 deletions classes/controllers/FrmXMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
8 changes: 1 addition & 7 deletions classes/factories/FrmFieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down
42 changes: 7 additions & 35 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
}

/**
Expand Down
6 changes: 1 addition & 5 deletions classes/helpers/FrmEmailSummaryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 2 additions & 10 deletions classes/helpers/FrmEntriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 2 additions & 7 deletions classes/helpers/FrmEntriesListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,8 @@ public function single_row( $item, $style = '' ) {
if ( $this->column_name === 'cb' ) {
$r .= "<th scope='row' class='check-column'>$checkbox</th>";
} else {
if ( in_array( $column_name, $hidden, true ) ) {
$val = '';
} else {
$val = $this->column_value( $item );
}

$r .= "<td $attributes>";
$val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item );
$r .= "<td $attributes>";

if ( $column_name == $action_col ) {
$edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id );
Expand Down
18 changes: 3 additions & 15 deletions classes/helpers/FrmFieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down
29 changes: 4 additions & 25 deletions classes/helpers/FrmFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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';
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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();
}
Expand Down
6 changes: 1 addition & 5 deletions classes/helpers/FrmFormsListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
20 changes: 3 additions & 17 deletions classes/helpers/FrmListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );

Expand Down
6 changes: 1 addition & 5 deletions classes/helpers/FrmStylesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
Loading
Loading