Skip to content
Merged
5 changes: 4 additions & 1 deletion classes/controllers/FrmEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion classes/controllers/FrmFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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'] ) ) . '"';
Expand All @@ -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;
Expand Down Expand Up @@ -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'] ) . '"';

Expand All @@ -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'] ) . '"';
}
Expand Down
4 changes: 2 additions & 2 deletions classes/controllers/FrmFormActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
Expand Down Expand Up @@ -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' );
}

Expand Down Expand Up @@ -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' );
}
Expand Down Expand Up @@ -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' );
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions classes/controllers/FrmStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand All @@ -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';
}
Expand Down
16 changes: 11 additions & 5 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Comment thread
Crabcyborg marked this conversation as resolved.

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

Expand Down Expand Up @@ -2319,7 +2320,7 @@ public static function user_has_permission( $needed_role ) {
return true;
}

if ( $role == $needed_role ) {
if ( $role === $needed_role ) {
break;
}
}
Expand Down Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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;
}
Comment thread
Crabcyborg marked this conversation as resolved.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 ] ) ) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Comment thread
Crabcyborg marked this conversation as resolved.

Expand Down
5 changes: 4 additions & 1 deletion classes/helpers/FrmEntriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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' ) );
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion classes/helpers/FrmEntriesListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -379,6 +379,7 @@ public function single_row( $item, $style = '' ) {
$val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item );
$r .= "<td $attributes>";

// 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 .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
Expand Down
15 changes: 10 additions & 5 deletions classes/helpers/FrmFieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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';
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 === '>=' ) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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'] = '';
Expand Down Expand Up @@ -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 ];
}
Expand All @@ -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 {
Expand Down
Loading