diff --git a/classes/controllers/FrmEntriesController.php b/classes/controllers/FrmEntriesController.php index 43f87cf5a7..089761cf40 100644 --- a/classes/controllers/FrmEntriesController.php +++ b/classes/controllers/FrmEntriesController.php @@ -276,7 +276,7 @@ private static function add_subform_cols( $field, $form_id, &$columns ) { private static function add_field_cols( $field, $form_id, &$columns ) { $col_id = $field->field_key; - if ( $field->form_id != $form_id ) { + if ( (int) $field->form_id !== (int) $form_id ) { $col_id .= '-_-form' . $field->form_id; } @@ -338,6 +338,7 @@ private static function maybe_add_ip_col( $form_id, &$columns ) { public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { $this_page_name = self::hidden_column_key(); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { return $check; } @@ -366,6 +367,7 @@ public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_v public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { $this_page_name = self::hidden_column_key(); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $meta_key != $this_page_name ) { return; } @@ -777,6 +779,7 @@ public static function process_entry( $errors = '', $ajax = false ) { return; } + // phpcs:ignore Universal.Operators.StrictComparisons if ( $errors == '' && ! $ajax ) { $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing } diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php index c12dbc602f..91f175bf2c 100644 --- a/classes/controllers/FrmFieldsController.php +++ b/classes/controllers/FrmFieldsController.php @@ -299,7 +299,8 @@ public static function import_options() { } // Keep other options after bulk update. - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { + // phpcs:ignore Universal.Operators.StrictComparisons + if ( ! empty( $field['field_options']['other'] ) ) { $other_array = array(); foreach ( $field['options'] as $opt_key => $opt ) { @@ -676,6 +677,7 @@ private static function add_html_length( $field, array &$add_html ) { * @return void */ private static function add_html_placeholder( $field, array &$add_html, array &$class ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $field['default_value'] != '' ) { if ( is_array( $field['default_value'] ) ) { $add_html['data-frmval'] = 'data-frmval="' . esc_attr( json_encode( $field['default_value'] ) ) . '"'; @@ -686,6 +688,7 @@ private static function add_html_placeholder( $field, array &$add_html, array &$ $field['placeholder'] = self::prepare_placeholder( $field ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $field['placeholder'] == '' || is_array( $field['placeholder'] ) ) { // don't include a json placeholder return; @@ -785,6 +788,7 @@ private static function add_placeholder_to_input( $field, &$add_html ) { * @return void */ private static function add_frmval_to_input( $field, &$add_html ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $field['placeholder'] != '' ) { $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['placeholder'] ) . '"'; @@ -793,6 +797,7 @@ private static function add_frmval_to_input( $field, &$add_html ) { } } + // phpcs:ignore Universal.Operators.StrictComparisons if ( $field['default_value'] != '' ) { $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; } diff --git a/classes/controllers/FrmFormActionsController.php b/classes/controllers/FrmFormActionsController.php index 18c17021a0..e5603a2d7d 100644 --- a/classes/controllers/FrmFormActionsController.php +++ b/classes/controllers/FrmFormActionsController.php @@ -337,7 +337,7 @@ public static function get_form_actions( $action = 'all' ) { $actions = array(); foreach ( $temp_actions as $a ) { - if ( 'all' !== $action && $a->id_base == $action ) { + if ( 'all' !== $action && $a->id_base === $action ) { return $a; } @@ -699,7 +699,7 @@ public static function trigger_actions( $event, $form, $entry, $type = 'all', $a continue; } - $child_entry = ( is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ! empty( $args['is_child'] ); + $child_entry = ( is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( (int) $entry->form_id !== (int) $form->id || $entry->parent_item_id ) ) || ! empty( $args['is_child'] ); if ( $child_entry ) { // maybe trigger actions for sub forms diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index a836106658..71865cfa94 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -715,6 +715,7 @@ public static function preview_content( $content ) { private static function load_direct_preview() { $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $key == '' ) { $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' ); } @@ -1380,7 +1381,7 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c $edit_message = __( 'Form was successfully updated.', 'formidable' ); - if ( $form->is_template && $message == $edit_message ) { + if ( $form->is_template && $message === $edit_message ) { $message = __( 'Template was successfully updated.', 'formidable' ); } @@ -2027,6 +2028,7 @@ public static function process_bulk_form_actions( $errors ) { $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $bulkaction == - 1 ) { $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); } @@ -2156,6 +2158,7 @@ public static function route() { $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $action == - 1 ) { $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); } @@ -2552,7 +2555,8 @@ public static function get_form_contents( $form, $title, $description, $atts ) { $pass_args = compact( 'form', 'fields', 'errors', 'title', 'description', 'reset' ); $pass_args['action'] = $params['action']; - $handle_process_here = $params['action'] === 'create' && $params['posted_form_id'] == $form->id && $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing + // phpcs:ignore WordPress.Security.NonceVerification.Missing, Universal.Operators.StrictComparisons + $handle_process_here = $params['action'] === 'create' && $params['posted_form_id'] == $form->id && $_POST; if ( ! $handle_process_here ) { FrmFormState::set_initial_value( 'title', $title ); @@ -2601,7 +2605,8 @@ public static function get_form_contents( $form, $title, $description, $atts ) { private static function get_saved_errors( $form, $params ) { global $frm_vars; - if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing + // phpcs:ignore WordPress.Security.NonceVerification.Missing, Universal.Operators.StrictComparisons + if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { $errors = $frm_vars['created_entries'][ $form->id ]['errors']; } else { $errors = array(); @@ -3010,6 +3015,7 @@ private static function load_page_after_submit( $args ) { global $post; $opt = $args['success_opt']; + // phpcs:ignore Universal.Operators.StrictComparisons if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) { $page = get_post( $args['form']->options[ $opt . '_page_id' ] ); $old_post = $post; diff --git a/classes/controllers/FrmStylesController.php b/classes/controllers/FrmStylesController.php index 87aced6cf5..fbe1cd96ab 100644 --- a/classes/controllers/FrmStylesController.php +++ b/classes/controllers/FrmStylesController.php @@ -1226,6 +1226,7 @@ public static function get_style_opts() { public static function get_form_style( $form = 'default' ) { $style = FrmFormsHelper::get_form_style( $form ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( empty( $style ) || 1 == $style ) { $style = 'default'; } @@ -1241,6 +1242,7 @@ public static function get_form_style( $form = 'default' ) { * @return string */ public static function get_form_style_class( $class, $style ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( 1 == $style ) { $style = 'default'; } diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 81a1514b40..0e44f85290 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -1339,6 +1339,7 @@ public static function remove_get_action() { * @return array|string */ public static function get_query_var( $value, $param ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $value != '' ) { return $value; } @@ -1828,7 +1829,7 @@ public static function save_combined_js() { * @return bool */ public static function is_true( $value ) { - return true === $value || 1 == $value || 'true' === $value || 'yes' === $value; + return true === $value || 1 === (int) $value || 'true' === $value || 'yes' === $value; } /** @@ -2279,7 +2280,7 @@ public static function current_user_can( $role ) { return is_user_logged_in(); } - if ( $role == 1 ) { + if ( (int) $role === 1 ) { $role = 'administrator'; } @@ -2319,7 +2320,7 @@ public static function user_has_permission( $needed_role ) { return true; } - if ( $role == $needed_role ) { + if ( $role === $needed_role ) { break; } } @@ -2447,7 +2448,7 @@ public static function check_selected( $values, $current ) { $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) ); - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); } @@ -3023,6 +3024,7 @@ private static function fill_form_defaults( $post_values, array &$values ) { $form_defaults = FrmFormsHelper::get_default_opts(); foreach ( $form_defaults as $opt => $default ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default; } @@ -3428,6 +3430,7 @@ public static function get_last_record_num( $r_count, $current_p, $p_size ) { * @return int */ public static function get_first_record_num( $r_count, $current_p, $p_size ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current_p == 1 ) { return 1; } @@ -3502,6 +3505,7 @@ public static function json_to_array( $json_vars ) { * @return void */ public static function add_value_to_array( $name, $l1, $val, &$vars ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $name == '' ) { $vars[] = $val; } elseif ( ! isset( $vars[ $l1 ] ) ) { @@ -3556,6 +3560,7 @@ public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = * @return void */ public static function select_current_page( $page, $current_page, $action = array() ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( $current_page != $page ) { return; } @@ -3792,11 +3797,12 @@ public static function maybe_json_encode( $value ) { public static function maybe_highlight_menu( $post_type ) { global $post; + // phpcs:ignore Universal.Operators.StrictComparisons if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { return; } - if ( is_object( $post ) && $post->post_type != $post_type ) { + if ( is_object( $post ) && $post->post_type !== $post_type ) { return; } diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php index d23711bddc..4e6272d7a0 100644 --- a/classes/helpers/FrmEntriesHelper.php +++ b/classes/helpers/FrmEntriesHelper.php @@ -233,6 +233,7 @@ public static function prepare_display_value( $entry, $field, $atts ) { } } + // phpcs:ignore Universal.Operators.StrictComparisons if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { return self::display_value( $field_value, $field, $atts ); } @@ -344,6 +345,7 @@ public static function display_value( $value, $field, $atts = array() ) { $atts['truncate'] = $atts['pre_truncate']; } + // phpcs:ignore Universal.Operators.StrictComparisons if ( $value == '' ) { return $value; } @@ -354,6 +356,7 @@ public static function display_value( $value, $field, $atts = array() ) { $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts ); $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $value == $unfiltered_value ) { $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) ); } @@ -597,7 +600,7 @@ public static function set_other_validation_val( &$value, $other_vals, $field, & unset( $value[ $other_key ] ); } } - } elseif ( $field->options[ $other_key ] == $value ) { + } elseif ( $field->options[ $other_key ] == $value ) { // phpcs:ignore Universal.Operators.StrictComparisons $value = $other_vals; }//end if }//end if diff --git a/classes/helpers/FrmEntriesListHelper.php b/classes/helpers/FrmEntriesListHelper.php index ee247fa203..e0b18ff041 100644 --- a/classes/helpers/FrmEntriesListHelper.php +++ b/classes/helpers/FrmEntriesListHelper.php @@ -177,7 +177,7 @@ protected function get_search_query( &$join_form_in_query ) { ) ); - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { + if ( $s !== '' && FrmAppHelper::pro_is_installed() ) { $fid = self::get_param( array( 'param' => 'fid' ) ); $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); } @@ -379,6 +379,7 @@ public function single_row( $item, $style = '' ) { $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item ); $r .= ""; + // phpcs:ignore Universal.Operators.StrictComparisons if ( $column_name == $action_col ) { $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id ); $r .= '' . $val . ' '; diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php index ac9860ca24..25f5063489 100644 --- a/classes/helpers/FrmFieldsHelper.php +++ b/classes/helpers/FrmFieldsHelper.php @@ -280,6 +280,7 @@ private static function context_is_safe_to_load_field_options_from_request_data( * @return void */ private static function fill_cleared_strings( $field, array &$field_array ) { + // phpcs:ignore Universal.Operators.StrictComparisons if ( '' == $field_array['blank'] && '1' === $field_array['required'] ) { $field_array['blank'] = self::default_blank_msg(); } @@ -293,6 +294,7 @@ private static function fill_cleared_strings( $field, array &$field_array ) { } } + // phpcs:ignore Universal.Operators.StrictComparisons if ( '' == $field_array['custom_html'] ) { $field_array['custom_html'] = self::get_default_html( $field->type ); } @@ -620,7 +622,7 @@ public static function run_wpautop( $atts, &$value ) { * @return string */ public static function &label_position( $position, $field, $form ) { - if ( $position && $position != '' ) { + if ( $position ) { if ( $position === 'inside' && ! self::is_placeholder_field_type( $field['type'] ) ) { $position = 'top'; } @@ -698,7 +700,7 @@ public static function show_single_option( $field ) { $field_name = $base_name . ( $default_type === 'checkbox' ? '[' . $opt_key . ']' : '' ); - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons $checked = ( isset( $field['default_value'] ) && ( ( ! is_array( $field['default_value'] ) && $field['default_value'] == $field_val ) || ( is_array( $field['default_value'] ) && in_array( $field_val, $field['default_value'] ) ) ) ); // If this is an "Other" option, get the HTML for it. @@ -888,9 +890,9 @@ public static function value_meets_condition( $observed_value, $cond, $hide_opt $m = false; if ( $cond === '==' ) { - $m = $observed_value == $hide_opt; + $m = $observed_value == $hide_opt; // phpcs:ignore Universal.Operators.StrictComparisons } elseif ( $cond === '!=' ) { - $m = $observed_value != $hide_opt; + $m = $observed_value != $hide_opt; // phpcs:ignore Universal.Operators.StrictComparisons } elseif ( $cond === '>' ) { $m = $observed_value > $hide_opt; } elseif ( $cond === '>=' ) { @@ -1268,6 +1270,7 @@ private static function get_field_shortcode_value( $atts ) { $string_value = FrmAppHelper::safe_implode( $sep, $replace_with ); } + // phpcs:ignore Universal.Operators.StrictComparisons if ( ! $string_value && $string_value != '0' ) { $replace_with = ''; } else { @@ -1344,6 +1347,7 @@ public static function process_get_shortcode( $atts, $return_array = false ) { $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); + // phpcs:ignore Universal.Operators.StrictComparisons if ( $new_value == '' ) { if ( ! isset( $atts['prev_val'] ) ) { $atts['prev_val'] = ''; @@ -1577,6 +1581,7 @@ public static function get_other_val( $args ) { if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) { // Check if there is an "other" val in saved value and make sure the // "other" val is not equal to the Other checkbox option + // phpcs:ignore Universal.Operators.StrictComparisons if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { $other_val = $field['value'][ $opt_key ]; } @@ -1596,7 +1601,7 @@ public static function get_other_val( $args ) { if ( isset( $field['value'][ $o_key ] ) ) { unset( $field['value'][ $o_key ], $o_key ); } - } elseif ( $temp_val == $field['value'] ) { + } elseif ( $temp_val == $field['value'] ) { // phpcs:ignore Universal.Operators.StrictComparisons // For radio and regular dropdowns return ''; } else { diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index 0b7c759b0d..c4fbf99ed2 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -74,7 +74,7 @@ public static function forms_dropdown( $field_name, $field_value = '', $args = a id="" > - +