Skip to content
Closed
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
20 changes: 10 additions & 10 deletions classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public static function get_pro_license() {
$creds = get_option( $pro_cred_store );
}

if ( empty( $creds ) || ! is_array( $creds ) || ! isset( $creds['license'] ) ) {
if ( ! $creds || ! is_array( $creds ) || ! isset( $creds['license'] ) ) {
return '';
}

Expand Down Expand Up @@ -498,7 +498,7 @@ public static function is_license_expired() {

$expires = $version_info['error']['expires'] ?? 0;

if ( empty( $expires ) || $expires > time() ) {
if ( ! $expires || $expires > time() ) {
return false;
}

Expand All @@ -521,7 +521,7 @@ public static function is_license_expired() {
public static function get_primary_license_info() {
$installed_addons = apply_filters( 'frm_installed_addons', array() );

if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
if ( ! $installed_addons || ! isset( $installed_addons['formidable_pro'] ) ) {
return false;
}

Expand Down Expand Up @@ -551,7 +551,7 @@ public static function check_update( $transient ) {

$installed_addons = apply_filters( 'frm_installed_addons', array() );

if ( empty( $installed_addons ) ) {
if ( ! $installed_addons ) {
return $transient;
}

Expand Down Expand Up @@ -643,28 +643,28 @@ protected static function fill_update_addon_info( $installed_addons ) {

$new_license = $addon->license;

if ( empty( $new_license ) || in_array( $new_license, $checked_licenses, true ) ) {
if ( ! $new_license || in_array( $new_license, $checked_licenses, true ) ) {
continue;
}

$checked_licenses[] = $new_license;

$api = new FrmFormApi( $new_license );

if ( empty( $version_info ) ) {
if ( ! $version_info ) {
$version_info = $api->get_api_info();
continue;
}

$plugin = $api->get_addon_for_license( $addon, $version_info );

if ( empty( $plugin ) ) {
if ( ! $plugin ) {
continue;
}

$download_id = $plugin['id'] ?? 0;

if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
if ( $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();

Expand Down Expand Up @@ -775,7 +775,7 @@ public static function get_addon_for_license( $addons, $license ) {
$download_id = $license->download_id;
$plugin = array();

if ( empty( $download_id ) && ! empty( $addons ) ) {
if ( ! $download_id && ! empty( $addons ) ) {
foreach ( $addons as $addon ) {
if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) {
return $addon;
Expand Down Expand Up @@ -1303,7 +1303,7 @@ protected static function install_addon_permissions() {
public static function connect_link() {
$auth = get_option( 'frm_connect_token' );

if ( empty( $auth ) ) {
if ( ! $auth ) {
$auth = hash( 'sha512', wp_rand() );
update_option( 'frm_connect_token', $auth, 'no' );
}
Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function add_admin_class( $classes ) {

$page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) );

if ( empty( $page ) || $page === 'formidable' ) {
if ( ! $page || $page === 'formidable' ) {
$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );

if ( in_array( $action, array( 'settings', 'edit', 'list' ), true ) ) {
Expand All @@ -72,7 +72,7 @@ public static function add_admin_class( $classes ) {
}
}

if ( ! empty( $page ) ) {
if ( $page ) {
$classes .= ' frm-admin-page-' . $page;
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmEmailStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public static function ajax_send_test_email() {
foreach ( $emails as $email ) {
$email = trim( $email );

if ( empty( $email ) || ! is_email( $email ) ) {
if ( ! $email || ! is_email( $email ) ) {
continue;
}
$valid_emails[] = $email;
Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/FrmEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private static function get_columns_for_form( $form_id, &$columns ) {
private static function add_subform_cols( $field, $form_id, &$columns ) {
$sub_form_cols = FrmField::get_all_for_form( $field->field_options['form_select'] );

if ( empty( $sub_form_cols ) ) {
if ( ! $sub_form_cols ) {
return;
}

Expand Down Expand Up @@ -526,7 +526,7 @@ public static function hidden_columns( $result ) {
$i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
$max_columns = 11;

if ( ! empty( $hidden ) ) {
if ( $hidden ) {
$result = $hidden;
$i = $i - count( $result );
}
Expand Down
6 changes: 3 additions & 3 deletions classes/controllers/FrmFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function load_field() {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$fields = isset( $_POST['field'] ) ? wp_unslash( $_POST['field'] ) : array();

if ( empty( $fields ) ) {
if ( ! $fields ) {
wp_die();
}

Expand Down Expand Up @@ -738,7 +738,7 @@ public static function get_default_value_from_name( $field ) {
public static function add_placeholder_to_select( $field ) {
$placeholder = FrmField::get_option( $field, 'placeholder' );

if ( empty( $placeholder ) ) {
if ( ! $placeholder ) {
$placeholder = self::get_default_value_from_name( $field );
}

Expand Down Expand Up @@ -1010,7 +1010,7 @@ private static function add_shortcodes_to_html( $field, array &$add_html ) {

if ( is_numeric( $k ) && str_contains( $v, '=' ) ) {
$add_html[] = $v;
} elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
} elseif ( $k && isset( $add_html[ $k ] ) ) {
$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
} else {
$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
Expand Down
8 changes: 4 additions & 4 deletions classes/controllers/FrmFormActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static function show_action_icon_link( $action_control, $allowed ) {
public static function get_form_actions( $action = 'all' ) {
$temp_actions = self::$registered_actions;

if ( empty( $temp_actions ) ) {
if ( ! $temp_actions ) {
self::actions_init();
$temp_actions = self::$registered_actions->actions;
} else {
Expand Down Expand Up @@ -486,7 +486,7 @@ public static function fill_action() {

$action_control = self::get_form_actions( $action_type );

if ( empty( $action_control ) ) {
if ( ! $action_control ) {
wp_die();
}

Expand Down Expand Up @@ -588,7 +588,7 @@ public static function update_settings( $form_id ) {
foreach ( $registered_actions as $registered_action ) {
$action_ids = $registered_action->update_callback( $form_id );

if ( ! empty( $action_ids ) ) {
if ( $action_ids ) {
$new_actions[] = $action_ids;
}
}
Expand Down Expand Up @@ -658,7 +658,7 @@ public static function trigger_actions( $event, $form, $entry, $type = 'all', $a
);
$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status );

if ( empty( $form_actions ) ) {
if ( ! $form_actions ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmFormTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public static function ajax_get_free_templates() {

$email = FrmAppHelper::get_post_param( 'email', '', 'sanitize_email' );

if ( empty( $email ) || ! is_email( $email ) ) {
if ( ! $email || ! is_email( $email ) ) {
wp_send_json_error(
array( 'message' => __( 'Please enter a valid email address.', 'formidable' ) ),
WP_Http::BAD_REQUEST
Expand Down
16 changes: 8 additions & 8 deletions classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@

$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );

if ( empty( $shortcode ) ) {
if ( ! $shortcode ) {
wp_die();
}

Expand Down Expand Up @@ -2033,15 +2033,15 @@
$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
}

if ( ! empty( $bulkaction ) && str_starts_with( $bulkaction, 'bulk_' ) ) {
if ( $bulkaction && str_starts_with( $bulkaction, 'bulk_' ) ) {
FrmAppHelper::remove_get_action();

$bulkaction = str_replace( 'bulk_', '', $bulkaction );
}

$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );

if ( empty( $ids ) ) {
if ( ! $ids ) {
$errors[] = __( 'No forms were specified', 'formidable' );

return $errors;
Expand Down Expand Up @@ -2070,7 +2070,7 @@
$message = self::bulk_untrash( $ids );
}

if ( ! empty( $message ) ) {
if ( $message ) {

Check failure on line 2073 in classes/controllers/FrmFormsController.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyUndefinedVariable

classes/controllers/FrmFormsController.php:2073:8: PossiblyUndefinedVariable: Possibly undefined variable $message, first seen on line 2064 (see https://psalm.dev/018)
$errors['message'] = $message;
}

Expand Down Expand Up @@ -2105,7 +2105,7 @@
$json_vars = htmlspecialchars_decode( nl2br( str_replace( '"', '"', wp_unslash( $_POST['frm_compact_fields'] ) ) ) );
$json_vars = json_decode( $json_vars, true );

if ( empty( $json_vars ) ) {
if ( ! $json_vars ) {
// json decoding failed so we should return an error message.
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );

Expand Down Expand Up @@ -2567,7 +2567,7 @@
if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
self::show_form_after_submit( $pass_args );
}
} elseif ( ! empty( $errors ) ) {
} elseif ( $errors ) {
self::show_form_after_submit( $pass_args );

} else {
Expand Down Expand Up @@ -2848,7 +2848,7 @@
*/
$met_actions = apply_filters( 'frm_get_met_on_submit_actions', $met_actions, $args );

if ( empty( $met_actions ) ) {
if ( ! $met_actions ) {
$met_actions = array( FrmOnSubmitHelper::get_fallback_action( $event ) );
}

Expand Down Expand Up @@ -3442,7 +3442,7 @@
$version = FrmAppHelper::plugin_version();
$suffix = FrmAppHelper::js_suffix();

if ( ! empty( $suffix ) && self::has_combo_js_file() ) {
if ( $suffix && self::has_combo_js_file() ) {
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/frm.min.js', array( 'jquery' ), $version, true );
} else {
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . "/js/formidable{$suffix}.js", array( 'jquery' ), $version, true );
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmInboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function dismiss_message() {

$key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' );

if ( ! empty( $key ) ) {
if ( $key ) {
$message = new FrmInbox();
$message->dismiss( $key );

Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/FrmStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ public static function custom_css( $message = '', $extra_args = array() ) {
'id' => $id,
);

if ( ! empty( $settings ) ) {
if ( $settings ) {
$textarea_params['class'] = 'hide-if-js';
}
include FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php';
Expand Down Expand Up @@ -1228,7 +1228,7 @@ public static function get_form_style( $form = 'default' ) {
$style = FrmFormsHelper::get_form_style( $form );

// phpcs:ignore Universal.Operators.StrictComparisons
if ( empty( $style ) || 1 == $style ) {
if ( ! $style || 1 == $style ) {
$style = 'default';
}

Expand Down
16 changes: 8 additions & 8 deletions classes/controllers/FrmXMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@
$pages = $imported['posts'];
}

if ( ! empty( $form ) ) {
if ( $form ) {
// Create selected pages with the correct shortcodes.
$pages = self::create_pages_for_import( $form );
}

if ( ! empty( $pages ) ) {
if ( $pages ) {

Check failure on line 106 in classes/controllers/FrmXMLController.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyUndefinedVariable

classes/controllers/FrmXMLController.php:106:9: PossiblyUndefinedVariable: Possibly undefined variable $pages, first seen on line 98 (see https://psalm.dev/018)
$post_id = end( $pages );
$response['redirect'] = get_permalink( $post_id );
}
Expand Down Expand Up @@ -228,7 +228,7 @@
$shortcode = '[' . esc_html( $for ) . ' id=%1$s]';
}

if ( empty( $item_key ) ) {
if ( ! $item_key ) {
// Don't create it if the shortcode won't show anything.
continue;
}
Expand Down Expand Up @@ -427,7 +427,7 @@
public static function export_xml() {
$error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );

if ( ! empty( $error ) ) {
if ( $error ) {
wp_die( esc_html( $error ) );
}

Expand Down Expand Up @@ -656,7 +656,7 @@
} else {
$sitename = sanitize_key( get_bloginfo( 'name' ) );

if ( ! empty( $sitename ) ) {
if ( $sitename ) {
$sitename .= '.';
}

Expand All @@ -679,7 +679,7 @@
public static function generate_csv( $atts ) {
$form_ids = $atts['ids'];

if ( empty( $form_ids ) ) {
if ( ! $form_ids ) {
wp_die( esc_html__( 'Please select a form', 'formidable' ) );
}
self::csv( reset( $form_ids ) );
Expand Down Expand Up @@ -730,7 +730,7 @@

$item_id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'sanitize_text_field' );

if ( ! empty( $item_id ) ) {
if ( $item_id ) {
$item_id = explode( ',', $item_id );
}

Expand All @@ -753,7 +753,7 @@
$entry_ids = FrmDb::get_col( $wpdb->prefix . 'frm_items it', $query );
unset( $query );

if ( empty( $entry_ids ) ) {
if ( ! $entry_ids ) {
esc_html_e( 'There are no entries for that form.', 'formidable' );
} else {
FrmCSVExportHelper::generate_csv( compact( 'form', 'entry_ids', 'form_cols' ) );
Expand Down
Loading
Loading