From 071b8eaf8caf9d9fd0ab30a13353e190af4d0cc7 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 16 Apr 2026 13:57:52 +0000
Subject: [PATCH 1/6] Initial plan
From 071fafcf5cf0a0af9dac59f58dabb579372dacb3 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 16 Apr 2026 13:59:41 +0000
Subject: [PATCH 2/6] Update alley-coding-standards to ^2.0
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/5aaa55b7-20ff-40ff-8235-425680472340
Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index b2771bb69..44bf8271c 100755
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,7 @@
"composer/installers": "^1.0 || ^2.0"
},
"require-dev": {
- "alleyinteractive/alley-coding-standards": "^1.0",
+ "alleyinteractive/alley-coding-standards": "^2.0",
"mantle-framework/testkit": "^1.3"
},
"scripts": {
From 6821f680ca16e24cfdea43d3afa7a4c0cb989e96 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 16 Apr 2026 14:27:01 +0000
Subject: [PATCH 3/6] Fix all PHPCS issues from alley-coding-standards upgrade
to ^2.0
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/5aaa55b7-20ff-40ff-8235-425680472340
Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
---
fieldmanager.php | 10 ++---
php/class-fieldmanager-autocomplete.php | 5 +--
php/class-fieldmanager-checkbox.php | 4 +-
php/class-fieldmanager-checkboxes.php | 3 +-
php/class-fieldmanager-datepicker.php | 1 -
php/class-fieldmanager-field.php | 44 +++++++++----------
php/class-fieldmanager-grid.php | 3 +-
php/class-fieldmanager-group.php | 21 +++++----
php/class-fieldmanager-hidden.php | 1 -
php/class-fieldmanager-link.php | 1 -
php/class-fieldmanager-media.php | 6 +--
php/class-fieldmanager-options.php | 7 ++-
php/class-fieldmanager-password.php | 1 -
php/class-fieldmanager-richtextarea.php | 3 +-
php/class-fieldmanager-select.php | 2 -
php/class-fieldmanager-textarea.php | 1 -
php/class-fieldmanager-textfield.php | 1 -
.../class-fieldmanager-context-page.php | 21 +++++----
.../class-fieldmanager-context-post.php | 9 ++--
.../class-fieldmanager-context-quickedit.php | 15 +++----
.../class-fieldmanager-context-storable.php | 3 +-
.../class-fieldmanager-context-submenu.php | 4 +-
.../class-fieldmanager-context-term.php | 3 +-
.../class-fieldmanager-datasource-post.php | 13 +++---
.../class-fieldmanager-datasource-term.php | 9 ++--
.../class-fieldmanager-datasource-user.php | 32 ++++++++------
.../class-fieldmanager-datasource.php | 14 +++---
php/util/class-fieldmanager-util-assets.php | 4 +-
.../class-fieldmanager-util-term-meta.php | 5 +--
.../class-fieldmanager-util-validation.php | 19 ++++----
phpcs.xml | 28 +++++++++++-
31 files changed, 148 insertions(+), 145 deletions(-)
diff --git a/fieldmanager.php b/fieldmanager.php
index d639c0e6b..9f8e286b8 100644
--- a/fieldmanager.php
+++ b/fieldmanager.php
@@ -23,7 +23,7 @@
/**
* Filesystem path to Fieldmanager.
*/
-define( 'FM_BASE_DIR', dirname( __FILE__ ) );
+define( 'FM_BASE_DIR', __DIR__ );
/**
* Default version number for static assets registered via Fieldmanager.
@@ -116,7 +116,7 @@ function fieldmanager_load_class( $class ) {
function fieldmanager_load_file( $file ) {
$file = FM_BASE_DIR . '/php/' . $file;
if ( ! file_exists( $file ) ) {
- throw new FM_Class_Not_Found_Exception( $file );
+ throw new FM_Class_Not_Found_Exception( esc_html( $file ) );
}
// phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable -- baseline
require_once $file;
@@ -184,7 +184,7 @@ function fieldmanager_get_template( $tpl_slug ) {
* Default none.
* @param bool $admin Deprecated.
*/
-function fm_add_script( $handle, $path = false, $deps = array(), $ver = false, $in_footer = false, $data_object = '', $data = array(), $plugin_dir = '', $admin = true ) {
+function fm_add_script( $handle, $path = false, $deps = array(), $ver = false, $in_footer = false, $data_object = '', $data = array(), $plugin_dir = '', $admin = true ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $admin is deprecated; other params used via compact()
// Ensure the Fieldmanager loader has been enqueued.
Fieldmanager_Util_Assets::instance()->add_script(
array(
@@ -212,7 +212,7 @@ function fm_add_script( $handle, $path = false, $deps = array(), $ver = false, $
* @param string $media Optional. Media for this stylesheet. Default 'all'.
* @param bool $admin Deprecated.
*/
-function fm_add_style( $handle, $path = false, $deps = array(), $ver = false, $media = 'all', $admin = true ) {
+function fm_add_style( $handle, $path = false, $deps = array(), $ver = false, $media = 'all', $admin = true ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $admin is deprecated; other params used via compact()
Fieldmanager_Util_Assets::instance()->add_style( compact( 'handle', 'path', 'deps', 'ver', 'media' ) );
}
@@ -554,7 +554,7 @@ function fm_register_submenu_page( $group_name, $parent_slug, $page_title, $menu
}
if ( isset( $submenus[ $group_name ] ) ) {
/* translators: %s: group name */
- throw new FM_Duplicate_Submenu_Name_Exception( sprintf( esc_html__( '%s is already in use as a submenu name', 'fieldmanager' ), $group_name ) );
+ throw new FM_Duplicate_Submenu_Name_Exception( esc_html( sprintf( esc_html__( '%s is already in use as a submenu name', 'fieldmanager' ), $group_name ) ) );
}
if ( ! $menu_title ) {
diff --git a/php/class-fieldmanager-autocomplete.php b/php/class-fieldmanager-autocomplete.php
index 8144e2e96..d4acb32aa 100644
--- a/php/class-fieldmanager-autocomplete.php
+++ b/php/class-fieldmanager-autocomplete.php
@@ -87,11 +87,10 @@ public function __construct( $label = '', $options = array() ) {
);
if ( empty( $this->datasource ) ) {
- $message = esc_html__( 'You must supply a datasource for the autocomplete field', 'fieldmanager' );
if ( Fieldmanager_Field::$debug ) {
- throw new FM_Developer_Exception( $message );
+ throw new FM_Developer_Exception( esc_html__( 'You must supply a datasource for the autocomplete field', 'fieldmanager' ) );
} else {
- wp_die( esc_html( $message ), esc_html__( 'No Datasource', 'fieldmanager' ) );
+ wp_die( esc_html__( 'You must supply a datasource for the autocomplete field', 'fieldmanager' ), esc_html__( 'No Datasource', 'fieldmanager' ) );
}
}
$this->datasource->allow_optgroups = false;
diff --git a/php/class-fieldmanager-checkbox.php b/php/class-fieldmanager-checkbox.php
index d9b816bdf..5fa9e0749 100644
--- a/php/class-fieldmanager-checkbox.php
+++ b/php/class-fieldmanager-checkbox.php
@@ -61,7 +61,7 @@ public function form_element( $value = null ) {
esc_attr( (string) $this->checked_value ),
$this->get_element_attributes(),
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- ( $value == $this->checked_value ) ? 'checked="checked"' : '',
+ ( $value === $this->checked_value ) ? 'checked="checked"' : '',
esc_attr( $this->get_element_id() ),
$this->unchecked_value
);
@@ -76,7 +76,7 @@ public function form_element( $value = null ) {
*/
public function presave( $value = null, $current_value = array() ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $value == $this->checked_value || $value === $this->unchecked_value ) {
+ if ( $value === $this->checked_value || $value === $this->unchecked_value ) {
return $value;
} elseif ( empty( $value ) ) {
return $this->unchecked_value;
diff --git a/php/class-fieldmanager-checkboxes.php b/php/class-fieldmanager-checkboxes.php
index c87d4db94..bd94c42c9 100644
--- a/php/class-fieldmanager-checkboxes.php
+++ b/php/class-fieldmanager-checkboxes.php
@@ -53,11 +53,10 @@ public function form_element( $value = array() ) {
*/
public function option_selected( $current_option, $options, $attribute ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
- if ( ( ( null !== $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) || ( 'checked' == $this->default_value && in_array( $this->default_value, $options ) ) ) {
+ if ( ( ( null !== $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) || ( 'checked' === $this->default_value && in_array( $this->default_value, $options ) ) ) {
return $attribute;
} else {
return '';
}
}
-
}
diff --git a/php/class-fieldmanager-datepicker.php b/php/class-fieldmanager-datepicker.php
index c4e4d95cb..80c783f03 100644
--- a/php/class-fieldmanager-datepicker.php
+++ b/php/class-fieldmanager-datepicker.php
@@ -171,5 +171,4 @@ public function get_minute( $value ) {
public function get_am_pm( $value ) {
return ! empty( $value ) ? gmdate( 'a', $value ) : '';
}
-
}
diff --git a/php/class-fieldmanager-field.php b/php/class-fieldmanager-field.php
index 0be1885d0..6357eed49 100644
--- a/php/class-fieldmanager-field.php
+++ b/php/class-fieldmanager-field.php
@@ -386,7 +386,7 @@ abstract class Fieldmanager_Field {
* @param mixed $value The value of the element.
* @return string HTML for the element.
*/
- public function form_element( $value ) {
+ public function form_element( $value ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- $value is used by the included template
if ( ! $this->template ) {
$tpl_slug = strtolower( str_replace( 'Fieldmanager_', '', get_class( $this ) ) );
$this->template = fieldmanager_get_template( $tpl_slug );
@@ -459,7 +459,7 @@ public function set_options( $label, $options ) {
// If this is a single field with a limit of 1, serialize_data has no impact.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! $this->serialize_data && ! $this->is_group() && 1 == $this->limit ) {
+ if ( ! $this->serialize_data && ! $this->is_group() && 1 === $this->limit ) {
$this->serialize_data = true;
}
@@ -484,7 +484,7 @@ public function set_options( $label, $options ) {
public function element_markup( $values = array() ) {
$values = $this->preload_alter_values( $values );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit ) {
+ if ( 1 !== $this->limit ) {
// count() generates a warning when passed non-countable values in PHP 7.2.
if ( is_scalar( $values ) ) {
$count_values = 1;
@@ -528,14 +528,14 @@ public function element_markup( $values = array() ) {
// Find the array position of the "counter" (e.g. in element[0], [0] is the counter, thus the position is 1).
$html_array_position = 0; // default is no counter; i.e. if $this->limit = 0.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit ) {
+ if ( 1 !== $this->limit ) {
$html_array_position = 1; // base situation is formname[0], so the counter is in position 1.
if ( $this->parent ) {
$parent = $this->parent;
while ( $parent ) {
$html_array_position++; // one more for having a parent (e.g. parent[this][0]).
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $parent->limit ) { // and another for the parent having multiple (e.g. parent[0][this][0]).
+ if ( 1 !== $parent->limit ) { // and another for the parent having multiple (e.g. parent[0][this][0]).
$html_array_position++;
}
$parent = $parent->parent; // parent's parent; root element has null parent which breaks while loop.
@@ -595,18 +595,18 @@ public function element_markup( $values = array() ) {
$out = apply_filters( "fm_element_markup_start_{$this->name}", $out, $this, $values );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ( 0 == $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'top' == $this->add_more_position ) {
+ if ( ( 0 === $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'top' === $this->add_more_position ) {
$out .= $this->add_another();
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit ) {
+ if ( 1 !== $this->limit ) {
$out .= $this->single_element_markup( null, true );
}
for ( $i = 0; $i < $max; $i++ ) {
$this->seq = $i;
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 == $this->limit ) {
+ if ( 1 === $this->limit ) {
$value = $values;
} else {
$value = isset( $values[ $i ] ) ? $values[ $i ] : null;
@@ -614,7 +614,7 @@ public function element_markup( $values = array() ) {
$out .= $this->single_element_markup( $value );
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ( 0 == $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'bottom' == $this->add_more_position ) {
+ if ( ( 0 === $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'bottom' === $this->add_more_position ) {
$out .= $this->add_another();
}
@@ -716,7 +716,7 @@ public function single_element_markup( $value = null, $is_proto = false ) {
*/
if ( ! empty( $this->label ) && ! $this->is_tab && $this->one_label_per_item ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit ) {
+ if ( 1 !== $this->limit ) {
$out .= $this->wrap_with_multi_tools( $label, array( 'fmjs-removable-label' ) );
} elseif ( ! $this->label_after_element ) {
$out .= $label;
@@ -736,7 +736,7 @@ public function single_element_markup( $value = null, $is_proto = false ) {
$form_element = $this->form_element( $value );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit && ( ! $this->one_label_per_item || empty( $this->label ) ) ) {
+ if ( 1 !== $this->limit && ( ! $this->one_label_per_item || empty( $this->label ) ) ) {
$out .= $this->wrap_with_multi_tools( $form_element );
} else {
$out .= $form_element;
@@ -791,7 +791,7 @@ public function wrap_with_multi_tools( $html, $classes = array() ) {
$out .= '';
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 == $this->limit || $this->limit > $this->minimum_count ) {
+ if ( 0 === $this->limit || $this->limit > $this->minimum_count ) {
$out .= $this->get_remove_handle();
}
@@ -810,13 +810,13 @@ public function get_form_name( $multiple = '' ) {
$name = '';
foreach ( $tree as $level => $branch ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 == $level ) {
+ if ( 0 === $level ) {
$name .= $branch->name;
} else {
$name .= '[' . $branch->name . ']';
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $branch->limit ) {
+ if ( 1 !== $branch->limit ) {
$name .= '[' . $branch->get_seq() . ']';
}
}
@@ -862,7 +862,7 @@ public function get_element_id() {
public function get_element_key() {
$el = $this;
$key = $el->name;
- // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- baseline
+ // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- baseline
while ( $el = $el->parent ) {
if ( $el->add_to_prefix ) {
$key = "{$el->name}_{$key}";
@@ -878,7 +878,7 @@ public function get_element_key() {
*/
public function is_repeatable() {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit ) {
+ if ( 1 !== $this->limit ) {
return true;
} elseif ( $this->parent ) {
return $this->parent->is_repeatable();
@@ -906,7 +906,7 @@ public function is_group() {
*/
public function presave_all( $values, $current_values ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 == $this->limit && empty( $this->multiple ) ) {
+ if ( 1 === $this->limit && empty( $this->multiple ) ) {
$values = $this->presave_alter_values( array( $values ), array( $current_values ) );
if ( ! empty( $values ) ) {
$value = $this->presave( $values[0], $current_values );
@@ -921,7 +921,7 @@ public function presave_all( $values, $current_values ) {
// If $this->limit != 1, and $values is not an array, that'd just be wrong, and possibly an attack, so...
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 != $this->limit && ! is_array( $values ) ) {
+ if ( 1 !== $this->limit && ! is_array( $values ) ) {
// EXCEPT maybe this is a request to remove indices.
if ( ! empty( $this->index ) && null === $values && ! empty( $current_values ) && is_array( $current_values ) ) {
@@ -985,7 +985,7 @@ public function presave_all( $values, $current_values ) {
// Remove empty values.
$values = array_filter(
$values,
- function( $value ) {
+ function ( $value ) {
if ( is_array( $value ) ) {
return ! empty( $value );
} elseif ( null === $value ) {
@@ -1018,7 +1018,7 @@ function( $value ) {
*/
protected function save_index( $values, $current_values ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'post' != $this->data_type || empty( $this->data_id ) ) {
+ if ( 'post' !== $this->data_type || empty( $this->data_id ) ) {
return;
}
// Must delete current values specifically, then add new ones, to support a scenario where the
@@ -1100,7 +1100,7 @@ protected function presave_alter_values( $values, $current_values = array() ) {
* @param array $current_value The current values.
* @return array The sanitized values.
*/
- public function presave( $value, $current_value = array() ) {
+ public function presave( $value, $current_value = array() ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $current_value is required by the interface and used by subclasses
// It's possible that some elements (Grid is one) would be arrays at
// this point, but those elements must override this function. Let's
// make sure we're dealing with one value here.
@@ -1416,7 +1416,7 @@ public function _unauthorized_access( $debug_message = '' ) { // phpcs:ignore PS
*/
protected function _failed_validation( $debug_message = '' ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- baseline
if ( self::$debug ) {
- throw new FM_Validation_Exception( $debug_message );
+ throw new FM_Validation_Exception( esc_html( $debug_message ) );
} else {
wp_die(
esc_html(
diff --git a/php/class-fieldmanager-grid.php b/php/class-fieldmanager-grid.php
index 933062f61..90b11d1fb 100644
--- a/php/class-fieldmanager-grid.php
+++ b/php/class-fieldmanager-grid.php
@@ -49,7 +49,7 @@ public function __construct( $label = '', $options = array() ) {
'size' => '50',
);
parent::__construct( $label, $options );
- $this->sanitize = function( $row, $col, $values ) {
+ $this->sanitize = function ( $row, $col, $values ) {
foreach ( $values as $k => $val ) {
$values[ $k ] = sanitize_text_field( $val );
}
@@ -116,5 +116,4 @@ public function presave( $value, $current_value = array() ) {
}
return $rows;
}
-
}
diff --git a/php/class-fieldmanager-group.php b/php/class-fieldmanager-group.php
index 8311a2719..873fb4a64 100644
--- a/php/class-fieldmanager-group.php
+++ b/php/class-fieldmanager-group.php
@@ -148,7 +148,7 @@ public function __construct( $label = '', $options = array() ) {
// Repeatable groups cannot used unserialized data.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- $is_repeatable = ( 1 != $this->limit );
+ $is_repeatable = ( 1 !== $this->limit );
if ( ! $this->serialize_data && $is_repeatable ) {
throw new FM_Developer_Exception( esc_html__( 'You cannot use `"serialize_data" => false` with repeating groups', 'fieldmanager' ) );
}
@@ -162,8 +162,8 @@ public function __construct( $label = '', $options = array() ) {
foreach ( $this->children as $name => $element ) {
// if the array key is not an int, and the name attr is set, and they don't match, we got a problem.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $element->name && ! is_int( $name ) && $element->name != $name ) {
- throw new FM_Developer_Exception( esc_html__( 'Group child name conflict: ', 'fieldmanager' ) . $name . ' / ' . $element->name );
+ if ( $element->name && ! is_int( $name ) && $element->name !== $name ) {
+ throw new FM_Developer_Exception( esc_html( esc_html__( 'Group child name conflict: ', 'fieldmanager' ) . $name . ' / ' . $element->name ) );
} elseif ( ! $element->name ) {
$element->name = $name;
}
@@ -247,11 +247,11 @@ public function form_element( $value = null ) {
// Set default classes to display the first tab content and hide others.
$tab_classes = array( 'fm-tab' );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- $tab_classes[] = ( 0 == $this->child_count ) ? 'wp-tab-active' : 'hide-if-no-js';
+ $tab_classes[] = ( 0 === $this->child_count ) ? 'wp-tab-active' : 'hide-if-no-js';
// Generate output for the tab. Depends on whether or not there is a tab limit in place.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 == $this->tab_limit || $this->child_count < $this->tab_limit ) {
+ if ( 0 === $this->tab_limit || $this->child_count < $this->tab_limit ) {
$tab_group .= sprintf(
'
%s ',
esc_attr( implode( ' ', $tab_classes ) ),
@@ -259,13 +259,13 @@ public function form_element( $value = null ) {
$element->escape( 'label' )
);
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- } elseif ( 0 != $this->tab_limit && $this->child_count >= $this->tab_limit ) {
+ } elseif ( 0 !== $this->tab_limit && $this->child_count >= $this->tab_limit ) {
$submenu_item_classes = array( 'fm-submenu-item' );
$submenu_item_link_class = '';
// Create the More tab when first hitting the tab limit.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->child_count == $this->tab_limit ) {
+ if ( $this->child_count === $this->tab_limit ) {
// Create the tab.
$tab_group_submenu .= sprintf(
'';
}
if ( $this->tabbed ) {
@@ -398,7 +398,7 @@ public function presave( $values, $current_values = array() ) {
$current_child_value = ! isset( $current_values[ $element->name ] ) ? array() : $current_values[ $element->name ];
$values[ $element->name ] = $element->presave_all( $values[ $element->name ], $current_child_value );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! $this->save_empty && 1 != $this->limit ) {
+ if ( ! $this->save_empty && 1 !== $this->limit ) {
if ( is_array( $values[ $element->name ] ) ) {
if ( empty( $values[ $element->name ] ) ) {
unset( $values[ $element->name ] );
@@ -474,7 +474,7 @@ public function get_element_label( $classes = array() ) {
$remove = '';
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->one_label_per_item && ( 0 == $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) ) {
+ if ( $this->one_label_per_item && ( 0 === $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) ) {
$remove = $this->get_remove_handle();
}
@@ -540,5 +540,4 @@ protected function add_meta_boxes_to_remove( &$meta_boxes_to_remove ) {
$child->add_meta_boxes_to_remove( $meta_boxes_to_remove );
}
}
-
}
diff --git a/php/class-fieldmanager-hidden.php b/php/class-fieldmanager-hidden.php
index 4ee0e5097..402c26e12 100644
--- a/php/class-fieldmanager-hidden.php
+++ b/php/class-fieldmanager-hidden.php
@@ -32,5 +32,4 @@ public function form_element( $value = '' ) {
$this->get_element_attributes()
);
}
-
}
diff --git a/php/class-fieldmanager-link.php b/php/class-fieldmanager-link.php
index 1f6479587..19017645b 100644
--- a/php/class-fieldmanager-link.php
+++ b/php/class-fieldmanager-link.php
@@ -21,5 +21,4 @@ public function __construct( $label = '', $options = array() ) {
$this->template = fieldmanager_get_template( 'textfield' );
parent::__construct( $label, $options );
}
-
}
diff --git a/php/class-fieldmanager-media.php b/php/class-fieldmanager-media.php
index cb595557a..057c5a1e3 100644
--- a/php/class-fieldmanager-media.php
+++ b/php/class-fieldmanager-media.php
@@ -140,7 +140,7 @@ public function admin_print_scripts() {
*/
public function presave( $value, $current_value = array() ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 == $value || ! is_numeric( $value ) ) {
+ if ( 0 === $value || ! is_numeric( $value ) ) {
return null;
}
return absint( $value );
@@ -176,7 +176,8 @@ public function form_element( $value = array() ) {
) . '';
// phpcs:ignore PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket -- baseline
- $preview .= sprintf( '%1$s
%2$s %3$s ',
+ $preview .= sprintf(
+ '%1$s
%2$s %3$s ',
esc_html( $file_label ),
wp_get_attachment_link( $value, $this->preview_size, true, true, $attachment->post_title ),
esc_html( $attachment->post_mime_type )
@@ -218,5 +219,4 @@ public function form_element( $value = array() ) {
$this->get_element_attributes()
);
}
-
}
diff --git a/php/class-fieldmanager-options.php b/php/class-fieldmanager-options.php
index 6a5a70222..b8ca1ac1e 100644
--- a/php/class-fieldmanager-options.php
+++ b/php/class-fieldmanager-options.php
@@ -155,11 +155,11 @@ public function form_data_elements( $value ) {
// If grouped display is desired, check where to add the start and end points
// Note we are assuming the data has come pre-sorted into groups.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->grouped && ( $current_group != $data_element['group'] ) ) {
+ if ( $this->grouped && ( $current_group !== $data_element['group'] ) ) {
// Append the end for the previous group unless this is the first group.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( '' != $current_group ) {
+ if ( '' !== $current_group ) {
$form_data_elements_html .= $this->form_data_end_group();
}
@@ -181,7 +181,6 @@ public function form_data_elements( $value ) {
}
return $form_data_elements_html;
-
}
/**
@@ -212,7 +211,7 @@ public function form_data_element( $data_row, $value ) {
*/
public function option_selected( $current_option, $options, $attribute ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
- if ( ( null != $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) {
+ if ( ( null !== $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) {
return $attribute;
}
diff --git a/php/class-fieldmanager-password.php b/php/class-fieldmanager-password.php
index 61a93c773..5658bd8ce 100644
--- a/php/class-fieldmanager-password.php
+++ b/php/class-fieldmanager-password.php
@@ -38,5 +38,4 @@ public function __construct( $label = '', $options = array() ) {
);
parent::__construct( $label, $options );
}
-
}
diff --git a/php/class-fieldmanager-richtextarea.php b/php/class-fieldmanager-richtextarea.php
index c84f47722..ef1311d9a 100644
--- a/php/class-fieldmanager-richtextarea.php
+++ b/php/class-fieldmanager-richtextarea.php
@@ -156,7 +156,7 @@ public function form_element( $value = '' ) {
if ( ! isset( $settings['default_editor'] ) ) {
$settings['default_editor'] = 'tinymce';
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- } elseif ( 'cookie' == $settings['default_editor'] ) {
+ } elseif ( 'cookie' === $settings['default_editor'] ) {
if ( $proto ) {
$settings['default_editor'] = 'tinymce';
} else {
@@ -339,5 +339,4 @@ protected function array_merge_deep() {
}
return $result;
}
-
}
diff --git a/php/class-fieldmanager-select.php b/php/class-fieldmanager-select.php
index 8975498c0..8a8ec7b7d 100644
--- a/php/class-fieldmanager-select.php
+++ b/php/class-fieldmanager-select.php
@@ -84,7 +84,6 @@ public function __construct( $label = '', $options = array() ) {
fm_add_script( 'fm_chosen', 'js/chosen/chosen.jquery.min.js', array( 'jquery' ), '1.8.2' );
fm_add_style( 'fm_chosen_css', 'js/chosen/chosen.min.css', array(), '1.8.2' );
}
-
}
/**
@@ -153,7 +152,6 @@ public function form_data_element( $data_row, $value = array() ) {
$option_selected,
esc_html( $data_row['name'] )
);
-
}
/**
diff --git a/php/class-fieldmanager-textarea.php b/php/class-fieldmanager-textarea.php
index 693214044..d51e4f30c 100644
--- a/php/class-fieldmanager-textarea.php
+++ b/php/class-fieldmanager-textarea.php
@@ -57,5 +57,4 @@ public function form_element( $value = '' ) {
esc_textarea( $value )
);
}
-
}
diff --git a/php/class-fieldmanager-textfield.php b/php/class-fieldmanager-textfield.php
index 304db3cdf..fd96ce84b 100644
--- a/php/class-fieldmanager-textfield.php
+++ b/php/class-fieldmanager-textfield.php
@@ -29,5 +29,4 @@ public function __construct( $label = '', $options = array() ) {
);
parent::__construct( $label, $options );
}
-
}
diff --git a/php/context/class-fieldmanager-context-page.php b/php/context/class-fieldmanager-context-page.php
index 5ade4732c..cc4af1e78 100644
--- a/php/context/class-fieldmanager-context-page.php
+++ b/php/context/class-fieldmanager-context-page.php
@@ -40,8 +40,8 @@ public function __construct( $uniqid, $fm ) {
$this->uniqid = $uniqid;
// since this should be set up in init, check for submit now.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.DeprecatedWhitelistCommentFound, WordPress.Security.ValidatedSanitizedInput.DeprecatedWhitelistCommentFound -- baseline
- if ( ! empty( $_POST ) && ! empty( $_POST['fm-page-action'] ) && esc_html( $_POST['fm-page-action'] ) == $uniqid ) { // WPCS: input var okay. CSRF ok. sanitization ok.
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- baseline: deprecated method, nonce is checked in save_page_form()
+ if ( ! empty( $_POST ) && ! empty( $_POST['fm-page-action'] ) && sanitize_text_field( wp_unslash( $_POST['fm-page-action'] ) ) === $uniqid ) {
$this->save_page_form();
}
}
@@ -53,16 +53,16 @@ public function save_page_form() {
_deprecated_function( __METHOD__, '1.2.0' );
if (
- isset( $_POST[ 'fieldmanager-' . $this->fm->name . '-nonce' ] ) // WPCS: input var okay.
- // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.DeprecatedWhitelistCommentFound -- baseline
- && ! wp_verify_nonce( $_POST[ 'fieldmanager-' . $this->fm->name . '-nonce' ], 'fieldmanager-save-' . $this->fm->name ) // WPCS: input var okay. sanitization ok.
+ isset( $_POST[ 'fieldmanager-' . $this->fm->name . '-nonce' ] )
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- wp_verify_nonce handles nonce value safely
+ && ! wp_verify_nonce( $_POST[ 'fieldmanager-' . $this->fm->name . '-nonce' ], 'fieldmanager-save-' . $this->fm->name )
) {
$this->fm->_unauthorized_access( __( 'Nonce validation failed', 'fieldmanager' ) );
}
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- baseline
$this->fm->data_id = $user_id;
- // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.IncorrectWarning, WordPress.Security.ValidatedSanitizedInput.DeprecatedWhitelistCommentFound -- baseline
- $value = isset( $_POST[ $this->fm->name ] ) ? $_POST[ $this->fm->name ] : ''; // WPCS: input var okay. sanitization ok.
+ // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.IncorrectWarning, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- baseline: raw form data is sanitized later in the processing pipeline
+ $value = isset( $_POST[ $this->fm->name ] ) ? $_POST[ $this->fm->name ] : '';
if ( empty( $this->fm->data_type ) ) {
$this->fm->data_type = 'page';
}
@@ -87,10 +87,10 @@ public function render_page_form() {
echo '';
@@ -112,7 +112,6 @@ public static function get_form( $uniqid ) {
return self::$forms[ $uniqid ];
}
-
}
/**
diff --git a/php/context/class-fieldmanager-context-post.php b/php/context/class-fieldmanager-context-post.php
index 180a223b0..9a8237106 100644
--- a/php/context/class-fieldmanager-context-post.php
+++ b/php/context/class-fieldmanager-context-post.php
@@ -181,7 +181,7 @@ public function save_fields_for_post( $post_id ) {
empty( $_POST['post_ID'] )
|| ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- || ( isset( $_POST['action'] ) && 'editpost' != $_POST['action'] )
+ || ( isset( $_POST['action'] ) && 'editpost' !== $_POST['action'] )
) {
return;
}
@@ -194,7 +194,7 @@ public function save_fields_for_post( $post_id ) {
// Prevent saving the same post twice; FM does not yet use revisions.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( get_post_type( $post_id ) == 'revision' ) {
+ if ( get_post_type( $post_id ) === 'revision' ) {
return;
}
@@ -206,7 +206,7 @@ public function save_fields_for_post( $post_id ) {
// Do not handle quickedit in this context.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( 'inline-save' == $_POST['action'] ) {
+ if ( 'inline-save' === $_POST['action'] ) {
return;
}
@@ -219,7 +219,7 @@ public function save_fields_for_post( $post_id ) {
// Make sure the current user is authorized to save this post.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( isset( $_POST['post_type'] ) && 'post' == $_POST['post_type'] ) {
+ if ( isset( $_POST['post_type'] ) && 'post' === $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
$this->fm->_unauthorized_access( __( 'User cannot edit this post', 'fieldmanager' ) );
return;
@@ -337,5 +337,4 @@ protected function update_data( $post_id, $meta_key, $meta_value, $data_prev_val
protected function delete_data( $post_id, $meta_key, $meta_value = '' ) {
return delete_post_meta( $post_id, $meta_key, $meta_value );
}
-
}
diff --git a/php/context/class-fieldmanager-context-quickedit.php b/php/context/class-fieldmanager-context-quickedit.php
index 473a9ef58..b3aeef473 100644
--- a/php/context/class-fieldmanager-context-quickedit.php
+++ b/php/context/class-fieldmanager-context-quickedit.php
@@ -121,7 +121,7 @@ public function add_custom_columns( $columns ) {
*/
public function manage_custom_columns( $column_name, $post_id ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $column_name != $this->fm->name ) {
+ if ( $column_name !== $this->fm->name ) {
return;
}
$data = get_post_meta( $post_id, $this->fm->name, true );
@@ -141,7 +141,7 @@ public function manage_custom_columns( $column_name, $post_id ) {
*/
public function add_quickedit_box( $column_name, $post_type, $values = array() ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $column_name != $this->fm->name ) {
+ if ( $column_name !== $this->fm->name ) {
return;
}
?>
@@ -174,7 +174,7 @@ public function render_ajax_form() {
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Recommended -- baseline
- if ( 'fm_quickedit_render' != $_GET['action'] ) {
+ if ( 'fm_quickedit_render' !== $_GET['action'] ) {
return;
}
@@ -184,7 +184,7 @@ public function render_ajax_form() {
$post_id = intval( $_GET['post_id'] );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! $post_id || $column_name != $this->fm->name ) {
+ if ( ! $post_id || $column_name !== $this->fm->name ) {
return;
}
@@ -211,7 +211,7 @@ public function save_fields_for_quickedit( $post_id ) {
! isset( $_POST['post_type'] )
|| ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- || ( isset( $_POST['action'] ) && 'inline-save' != $_POST['action'] )
+ || ( isset( $_POST['action'] ) && 'inline-save' !== $_POST['action'] )
) {
return;
}
@@ -219,7 +219,7 @@ public function save_fields_for_quickedit( $post_id ) {
$use_this_post_type = false;
foreach ( $this->post_types as $type ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( $type == $_POST['post_type'] ) {
+ if ( $type === $_POST['post_type'] ) {
$use_this_post_type = true;
break;
}
@@ -235,7 +235,7 @@ public function save_fields_for_quickedit( $post_id ) {
// Make sure the current user can save this post.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( 'post' == $_POST['post_type'] ) {
+ if ( 'post' === $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
$this->fm->_unauthorized_access( __( 'User cannot edit this post', 'fieldmanager' ) );
return;
@@ -316,5 +316,4 @@ protected function update_data( $post_id, $meta_key, $meta_value, $data_prev_val
protected function delete_data( $post_id, $meta_key, $meta_value = '' ) {
return delete_post_meta( $post_id, $meta_key, $meta_value );
}
-
}
diff --git a/php/context/class-fieldmanager-context-storable.php b/php/context/class-fieldmanager-context-storable.php
index d6da35a5a..565632e37 100644
--- a/php/context/class-fieldmanager-context-storable.php
+++ b/php/context/class-fieldmanager-context-storable.php
@@ -112,7 +112,7 @@ protected function save_field( $field, $data ) {
if ( isset( $this->save_keys[ $field->get_element_key() ] ) ) {
/* translators: %s: element key for the field */
- throw new FM_Developer_Exception( sprintf( esc_html__( 'You have two fields in this group saving to the same key: %s', 'fieldmanager' ), $field->get_element_key() ) );
+ throw new FM_Developer_Exception( esc_html( sprintf( esc_html__( 'You have two fields in this group saving to the same key: %s', 'fieldmanager' ), $field->get_element_key() ) ) );
} else {
$this->save_keys[ $field->get_element_key() ] = true;
}
@@ -276,5 +276,4 @@ abstract protected function update_data( $data_id, $data_key, $data_value, $data
* {@see delete_post_meta()}.
*/
abstract protected function delete_data( $data_id, $data_key, $data_value = '' );
-
}
diff --git a/php/context/class-fieldmanager-context-submenu.php b/php/context/class-fieldmanager-context-submenu.php
index b81ee401f..bb8c36f5e 100644
--- a/php/context/class-fieldmanager-context-submenu.php
+++ b/php/context/class-fieldmanager-context-submenu.php
@@ -112,7 +112,7 @@ public function render_submenu_page() {
@@ -145,7 +145,7 @@ public function render_submenu_page() {
*/
public function handle_submenu_save() {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Recommended -- baseline
- if ( empty( $_GET['page'] ) || $_GET['page'] != $this->menu_slug ) {
+ if ( empty( $_GET['page'] ) || $_GET['page'] !== $this->menu_slug ) {
return;
}
diff --git a/php/context/class-fieldmanager-context-term.php b/php/context/class-fieldmanager-context-term.php
index 6f9ce6a5e..5e6ee90b8 100644
--- a/php/context/class-fieldmanager-context-term.php
+++ b/php/context/class-fieldmanager-context-term.php
@@ -224,7 +224,7 @@ public function add_term_fields( $taxonomy ) {
public function edit_term_fields( $term, $taxonomy ) {
// Check if this term's parent matches the specified term if it is set.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 !== strlen( $this->parent ) && $this->parent != $term->parent ) {
+ if ( 0 !== strlen( $this->parent ) && $this->parent !== $term->parent ) {
return;
}
@@ -500,5 +500,4 @@ protected function delete_data( $term_id, $meta_key, $meta_value = '' ) {
return delete_term_meta( $term_id, $meta_key, $meta_value );
}
}
-
}
diff --git a/php/datasource/class-fieldmanager-datasource-post.php b/php/datasource/class-fieldmanager-datasource-post.php
index 730c32f11..e904e598e 100644
--- a/php/datasource/class-fieldmanager-datasource-post.php
+++ b/php/datasource/class-fieldmanager-datasource-post.php
@@ -159,9 +159,9 @@ public function get_items( $fragment = null ) {
$exact_post = get_post( $post_id );
if ( $exact_post && (
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- 'any' == $post_args['post_type'] ||
+ 'any' === $post_args['post_type'] ||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- $post_args['post_type'] == $exact_post->post_type ||
+ $post_args['post_type'] === $exact_post->post_type ||
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
in_array( $exact_post->post_type, $post_args['post_type'] )
) ) {
@@ -243,7 +243,7 @@ public function title_like( $where, $wp_query ) {
*/
public function presave_alter_values( Fieldmanager_Field $field, $values, $current_values ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'post' == $field->data_type && ! empty( $this->reciprocal ) && ! empty( $current_values ) && is_array( $current_values ) ) {
+ if ( 'post' === $field->data_type && ! empty( $this->reciprocal ) && ! empty( $current_values ) && is_array( $current_values ) ) {
foreach ( $current_values as $reciprocal_post_id ) {
delete_post_meta( $reciprocal_post_id, $this->reciprocal, $field->data_id );
}
@@ -282,7 +282,7 @@ public function presave( Fieldmanager_Field $field, $value, $current_value ) {
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->save_to_post_parent && 1 == $field->limit && 'post' == $field->data_type ) {
+ if ( $this->save_to_post_parent && 1 === $field->limit && 'post' === $field->data_type ) {
if ( ! wp_is_post_revision( $field->data_id ) ) {
Fieldmanager_Context_Post::safe_update_post(
array(
@@ -332,7 +332,7 @@ public function preload_alter_values( Fieldmanager_Field $field, $values ) {
$post_parent = wp_get_post_parent_id( $field->data_id );
if ( $post_parent ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- return ( 1 == $field->limit && empty( $field->multiple ) ) ? $post_parent : array( $post_parent );
+ return ( 1 === $field->limit && empty( $field->multiple ) ) ? $post_parent : array( $post_parent );
}
}
return $values;
@@ -367,7 +367,6 @@ public function get_edit_link( $value ) {
esc_html__( 'Edit', 'fieldmanager' )
);
}
-
}
/**
@@ -447,7 +446,7 @@ function fm_url_to_post_id( $url ) {
// If the requesting file is the anchor of the match, prepend it
// to the path info.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
+ if ( ! empty( $url ) && ( $url !== $request ) && ( strpos( $match, $url ) === 0 ) ) {
$request_match = $url . '/' . $request;
}
diff --git a/php/datasource/class-fieldmanager-datasource-term.php b/php/datasource/class-fieldmanager-datasource-term.php
index 7006937de..33e715c87 100644
--- a/php/datasource/class-fieldmanager-datasource-term.php
+++ b/php/datasource/class-fieldmanager-datasource-term.php
@@ -157,7 +157,7 @@ public function preload_alter_values( Fieldmanager_Field $field, $values ) {
if ( count( $terms ) > 0 ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 == $field->limit && empty( $field->multiple ) ) {
+ if ( 1 === $field->limit && empty( $field->multiple ) ) {
return $terms[0]->term_id;
} else {
$ret = array();
@@ -390,9 +390,9 @@ protected function build_hierarchical_term_data( $parent_terms, $tax_args, $dept
if ( ! empty( $pattern ) ) {
$tax_args['search'] = $pattern;
}
- $child_terms = get_terms( $this->get_taxonomies(), $tax_args );
+ $child_terms = get_terms( array_merge( $tax_args, array( 'taxonomy' => $this->get_taxonomies() ) ) );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 == $this->taxonomy_hierarchical_depth || $depth + 1 < $this->taxonomy_hierarchical_depth ) {
+ if ( 0 === $this->taxonomy_hierarchical_depth || $depth + 1 < $this->taxonomy_hierarchical_depth ) {
if ( ! empty( $child_terms ) ) {
$stack = $this->build_hierarchical_term_data( $child_terms, $this->taxonomy_args, $depth + 1, $stack );
}
@@ -447,8 +447,8 @@ private function get_term( $term_id ) {
return $term;
} else {
$terms = get_terms(
- $this->get_taxonomies(),
array(
+ 'taxonomy' => $this->get_taxonomies(),
'hide_empty' => false,
'include' => array( $term_id ),
'number' => 1,
@@ -492,5 +492,4 @@ public function get_edit_link( $value ) {
esc_html__( 'Edit', 'fieldmanager' )
);
}
-
}
diff --git a/php/datasource/class-fieldmanager-datasource-user.php b/php/datasource/class-fieldmanager-datasource-user.php
index 8a73040b0..ad4877266 100644
--- a/php/datasource/class-fieldmanager-datasource-user.php
+++ b/php/datasource/class-fieldmanager-datasource-user.php
@@ -96,29 +96,33 @@ public function __construct( $options = array() ) {
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
if ( ! in_array( $this->store_property, $this->allowed_store_properties ) ) {
throw new FM_Developer_Exception(
- sprintf(
- /* translators: 1: stored property, 2: allowed store properties */
- __( 'Store property %1$s is invalid. Must be one of %2$s.', 'fieldmanager' ),
- $this->store_property,
- implode( ', ', $this->allowed_store_properties )
+ esc_html(
+ sprintf(
+ /* translators: 1: stored property, 2: allowed store properties */
+ __( 'Store property %1$s is invalid. Must be one of %2$s.', 'fieldmanager' ),
+ $this->store_property,
+ implode( ', ', $this->allowed_store_properties )
+ )
)
);
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! empty( $this->reciprocal ) && 'ID' != $this->store_property ) {
- throw new FM_Developer_Exception( __( 'You cannot use reciprocal relationships with FM_Datasource_User if store_property is not set to ID.', 'fieldmanager' ) );
+ if ( ! empty( $this->reciprocal ) && 'ID' !== $this->store_property ) {
+ throw new FM_Developer_Exception( esc_html__( 'You cannot use reciprocal relationships with FM_Datasource_User if store_property is not set to ID.', 'fieldmanager' ) );
}
// Validate improper usage of display property.
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
if ( ! in_array( $this->display_property, $this->allowed_display_properties ) ) {
throw new FM_Developer_Exception(
- sprintf(
- /* translators: 1: display property, 2: allowed display properties */
- __( 'Display property %1$s is invalid. Must be one of %2$s.', 'fieldmanager' ),
- $this->display_property,
- implode( ', ', $this->allowed_display_properties )
+ esc_html(
+ sprintf(
+ /* translators: 1: display property, 2: allowed display properties */
+ __( 'Display property %1$s is invalid. Must be one of %2$s.', 'fieldmanager' ),
+ $this->display_property,
+ implode( ', ', $this->allowed_display_properties )
+ )
)
);
}
@@ -209,7 +213,7 @@ public function get_ajax_action() {
*/
public function presave_alter_values( Fieldmanager_Field $field, $values, $current_values ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'post' != $field->data_type || ! $this->reciprocal || 'ID' != $this->store_property ) {
+ if ( 'post' !== $field->data_type || ! $this->reciprocal || 'ID' !== $this->store_property ) {
return $values;
}
@@ -266,7 +270,7 @@ public function presave( Fieldmanager_Field $field, $value, $current_value ) {
wp_die( esc_html( sprintf( __( 'Tried to refer to user "%s" which current user cannot edit.', 'fieldmanager' ), $v ) ) );
}
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->reciprocal && 'ID' == $this->store_property ) {
+ if ( $this->reciprocal && 'ID' === $this->store_property ) {
call_user_func(
/**
* Filters function used to add user meta. This improves compatibility with
diff --git a/php/datasource/class-fieldmanager-datasource.php b/php/datasource/class-fieldmanager-datasource.php
index 9392fe0d0..75c8e3989 100644
--- a/php/datasource/class-fieldmanager-datasource.php
+++ b/php/datasource/class-fieldmanager-datasource.php
@@ -98,11 +98,10 @@ public function __construct( $options = array() ) {
}
if ( get_class( $this ) === __CLASS__ && empty( $options ) ) {
- $message = __( 'Invalid options for Datasource; must use the options parameter to supply an array.', 'fieldmanager' );
if ( Fieldmanager_Field::$debug ) {
- throw new FM_Developer_Exception( $message );
+ throw new FM_Developer_Exception( esc_html__( 'Invalid options for Datasource; must use the options parameter to supply an array.', 'fieldmanager' ) );
} else {
- wp_die( esc_html( $message ), esc_html__( 'Invalid Datasource Options', 'fieldmanager' ) );
+ wp_die( esc_html__( 'Invalid options for Datasource; must use the options parameter to supply an array.', 'fieldmanager' ), esc_html__( 'Invalid Datasource Options', 'fieldmanager' ) );
}
}
@@ -209,7 +208,7 @@ public function autocomplete_search() {
* @param mixed $current_values Current value.
* @return string $values Cleaned value.
*/
- public function presave_alter_values( Fieldmanager_Field $field, $values, $current_values ) {
+ public function presave_alter_values( Fieldmanager_Field $field, $values, $current_values ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $current_values is required by the interface and used by subclasses
// nothing here, but some child classes need this method.
return $values;
}
@@ -233,7 +232,7 @@ public function preload_alter_values( Fieldmanager_Field $field, $values ) {
* @param mixed $current_value Current value.
* @return string $values Cleaned value.
*/
- public function presave( Fieldmanager_Field $field, $value, $current_value ) {
+ public function presave( Fieldmanager_Field $field, $value, $current_value ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $current_value is required by the interface and used by subclasses
if ( is_array( $value ) ) {
return array_map( 'sanitize_text_field', $value );
}
@@ -246,7 +245,7 @@ public function presave( Fieldmanager_Field $field, $value, $current_value ) {
* @param mixed $value The current value.
* @return string HTML string.
*/
- public function get_view_link( $value ) {
+ public function get_view_link( $value ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- $value is required by the interface and used by subclasses
return '';
}
@@ -256,8 +255,7 @@ public function get_view_link( $value ) {
* @param int|string $value The current value.
* @return string HTML string.
*/
- public function get_edit_link( $value ) {
+ public function get_edit_link( $value ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- $value is required by the interface and used by subclasses
return '';
}
-
}
diff --git a/php/util/class-fieldmanager-util-assets.php b/php/util/class-fieldmanager-util-assets.php
index 27ec652f8..399befed6 100644
--- a/php/util/class-fieldmanager-util-assets.php
+++ b/php/util/class-fieldmanager-util-assets.php
@@ -213,7 +213,7 @@ public function add_script( $args ) {
// Set the default directory.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( '' == $args['plugin_dir'] ) {
+ if ( '' === $args['plugin_dir'] ) {
$args['plugin_dir'] = fieldmanager_get_baseurl(); // Allow overrides for child plugins.
}
$args['path'] = $args['plugin_dir'] . $args['path'];
@@ -273,7 +273,7 @@ public function add_style( $args ) {
// Set the default directory.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( '' == $args['plugin_dir'] ) {
+ if ( '' === $args['plugin_dir'] ) {
$args['plugin_dir'] = fieldmanager_get_baseurl(); // Allow overrides for child plugins.
}
$args['path'] = $args['plugin_dir'] . $args['path'];
diff --git a/php/util/class-fieldmanager-util-term-meta.php b/php/util/class-fieldmanager-util-term-meta.php
index a91e5ddd9..09939685d 100644
--- a/php/util/class-fieldmanager-util-term-meta.php
+++ b/php/util/class-fieldmanager-util-term-meta.php
@@ -293,7 +293,7 @@ public function add_term_meta_post( $term_id, $taxonomy ) {
// Check the result.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 != $result ) {
+ if ( 0 !== $result ) {
return $result;
} else {
return false;
@@ -328,7 +328,7 @@ public function collect_garbage( $term_id, $tt_id, $taxonomy ) {
public function split_shared_term( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
$post_id = $this->get_term_meta_post_id( $old_term_id, $taxonomy );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( false != $post_id ) {
+ if ( false !== $post_id ) {
wp_update_post(
array(
'ID' => $post_id,
@@ -422,4 +422,3 @@ function fm_update_term_meta( $term_id, $taxonomy, $meta_key, $meta_value, $meta
function fm_delete_term_meta( $term_id, $taxonomy, $meta_key, $meta_value = '' ) {
return Fieldmanager_Util_Term_Meta()->delete_term_meta( $term_id, $taxonomy, $meta_key, $meta_value );
}
-
diff --git a/php/util/class-fieldmanager-util-validation.php b/php/util/class-fieldmanager-util-validation.php
index 31a07adf2..26af7f44e 100644
--- a/php/util/class-fieldmanager-util-validation.php
+++ b/php/util/class-fieldmanager-util-validation.php
@@ -108,7 +108,7 @@ private function setup( $form_id, $context ) {
// Add the appropriate action hook to finalize and output validation JS.
// Also determine where the jQuery validation script needs to be added.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'page' == $context ) {
+ if ( 'page' === $context ) {
// Currently only the page context outputs to the frontend.
$action = 'wp_footer';
$admin = false;
@@ -168,11 +168,8 @@ public function add_field( &$fm ) {
// This is not a rule available in jQuery validation.
/* translators: %s: validation key */
$fm->_invalid_definition( sprintf( __( 'The validation rule "%s" does not exist.', 'fieldmanager' ), $validation_key ) );
- } else {
- // This rule is valid so check for any messages.
- if ( isset( $fm->validation_messages[ $validation_key ] ) ) {
- $messages[ $validation_key ] = $fm->validation_messages[ $validation_key ];
- }
+ } elseif ( isset( $fm->validation_messages[ $validation_key ] ) ) {
+ $messages[ $validation_key ] = $fm->validation_messages[ $validation_key ];
}
}
}
@@ -181,7 +178,7 @@ public function add_field( &$fm ) {
// This is necessary because it is the only way validation is supported on the term add form.
// Other validation methods won't work and will just fail gracefully.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'term' == $this->context && isset( $fm->validation_rules['required'] ) && $fm->validation_rules['required'] ) {
+ if ( 'term' === $this->context && isset( $fm->validation_rules['required'] ) && $fm->validation_rules['required'] ) {
$fm->required = true;
}
@@ -244,12 +241,12 @@ public function add_validation() {
// Add the Fieldmanager validation script and CSS.
// This is not done via the normal enqueue process since there is no way to know at that point if any fields will require validation.
// Doing this here avoids loading JS/CSS for validation if not in use.
- echo sprintf(
+ printf(
"
\n",
'stylesheet',
esc_url( fieldmanager_get_baseurl() )
);
- echo sprintf(
+ printf(
"<%s type='%s' src='%sjs/validation/fieldmanager-validation.js?ver=0.3'>\n",
'script',
'text/javascript',
@@ -257,7 +254,7 @@ public function add_validation() {
);
// Add the jQuery validation script.
- echo sprintf(
+ printf(
"<%s type='%s' src='%sjs/validation/jquery.validate.min.js'>\n",
'script',
'text/javascript',
@@ -265,7 +262,7 @@ public function add_validation() {
);
// Add the ignore, rules and messages to final validate method with form ID, wrap in script tags and output.
- echo sprintf(
+ printf(
"\t\n",
esc_attr( $this->form_id ),
esc_js( $ignore_js ),
diff --git a/phpcs.xml b/phpcs.xml
index 6bab965b5..0f654fd77 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -12,6 +12,26 @@
+
+
+
+
+
+
+
+
+
+
@@ -47,7 +67,13 @@
-
+
+
+
+
+
+
+
From 703deb7cfa13e90dd07a16e00860e5c6737b6615 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 16 Apr 2026 14:29:04 +0000
Subject: [PATCH 4/6] Fix double-escaping issues identified in code review
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/5aaa55b7-20ff-40ff-8235-425680472340
Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
---
fieldmanager.php | 2 +-
php/class-fieldmanager-group.php | 2 +-
php/context/class-fieldmanager-context-storable.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fieldmanager.php b/fieldmanager.php
index 9f8e286b8..2d6be18f2 100644
--- a/fieldmanager.php
+++ b/fieldmanager.php
@@ -554,7 +554,7 @@ function fm_register_submenu_page( $group_name, $parent_slug, $page_title, $menu
}
if ( isset( $submenus[ $group_name ] ) ) {
/* translators: %s: group name */
- throw new FM_Duplicate_Submenu_Name_Exception( esc_html( sprintf( esc_html__( '%s is already in use as a submenu name', 'fieldmanager' ), $group_name ) ) );
+ throw new FM_Duplicate_Submenu_Name_Exception( esc_html( sprintf( __( '%s is already in use as a submenu name', 'fieldmanager' ), $group_name ) ) );
}
if ( ! $menu_title ) {
diff --git a/php/class-fieldmanager-group.php b/php/class-fieldmanager-group.php
index 873fb4a64..09aaf201a 100644
--- a/php/class-fieldmanager-group.php
+++ b/php/class-fieldmanager-group.php
@@ -163,7 +163,7 @@ public function __construct( $label = '', $options = array() ) {
// if the array key is not an int, and the name attr is set, and they don't match, we got a problem.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
if ( $element->name && ! is_int( $name ) && $element->name !== $name ) {
- throw new FM_Developer_Exception( esc_html( esc_html__( 'Group child name conflict: ', 'fieldmanager' ) . $name . ' / ' . $element->name ) );
+ throw new FM_Developer_Exception( esc_html( __( 'Group child name conflict: ', 'fieldmanager' ) . $name . ' / ' . $element->name ) );
} elseif ( ! $element->name ) {
$element->name = $name;
}
diff --git a/php/context/class-fieldmanager-context-storable.php b/php/context/class-fieldmanager-context-storable.php
index 565632e37..6cf9eaa58 100644
--- a/php/context/class-fieldmanager-context-storable.php
+++ b/php/context/class-fieldmanager-context-storable.php
@@ -112,7 +112,7 @@ protected function save_field( $field, $data ) {
if ( isset( $this->save_keys[ $field->get_element_key() ] ) ) {
/* translators: %s: element key for the field */
- throw new FM_Developer_Exception( esc_html( sprintf( esc_html__( 'You have two fields in this group saving to the same key: %s', 'fieldmanager' ), $field->get_element_key() ) ) );
+ throw new FM_Developer_Exception( esc_html( sprintf( __( 'You have two fields in this group saving to the same key: %s', 'fieldmanager' ), $field->get_element_key() ) ) );
} else {
$this->save_keys[ $field->get_element_key() ] = true;
}
From 2ecc52049d49984b84f64a1b14a8a8aa19d2fed9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 16 Apr 2026 17:06:30 +0000
Subject: [PATCH 5/6] Revert unintended strict comparison in checkbox that
broke tests
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/c87f30a6-8bcb-4a36-a40c-24ab84070cd3
Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
---
php/class-fieldmanager-checkbox.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/php/class-fieldmanager-checkbox.php b/php/class-fieldmanager-checkbox.php
index 5fa9e0749..fa8b9a855 100644
--- a/php/class-fieldmanager-checkbox.php
+++ b/php/class-fieldmanager-checkbox.php
@@ -60,8 +60,8 @@ public function form_element( $value = null ) {
esc_attr( $this->get_form_name() ),
esc_attr( (string) $this->checked_value ),
$this->get_element_attributes(),
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- ( $value === $this->checked_value ) ? 'checked="checked"' : '',
+ // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- baseline
+ ( $value == $this->checked_value ) ? 'checked="checked"' : '',
esc_attr( $this->get_element_id() ),
$this->unchecked_value
);
@@ -75,8 +75,8 @@ public function form_element( $value = null ) {
* @return mixed Proper value.
*/
public function presave( $value = null, $current_value = array() ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $value === $this->checked_value || $value === $this->unchecked_value ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- baseline
+ if ( $value == $this->checked_value || $value === $this->unchecked_value ) {
return $value;
} elseif ( empty( $value ) ) {
return $this->unchecked_value;
From 74d1f6d73eb662bf24f739126ab8ed214684bc4e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 20 Apr 2026 15:46:48 +0000
Subject: [PATCH 6/6] Revert all phpcbf strict comparisons and suppress with
phpcs:ignore
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/1657c266-403f-465f-b426-b97991f2eb27
Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
---
php/class-fieldmanager-checkboxes.php | 4 +-
php/class-fieldmanager-field.php | 68 +++++++++----------
php/class-fieldmanager-group.php | 36 +++++-----
php/class-fieldmanager-media.php | 4 +-
php/class-fieldmanager-options.php | 12 ++--
php/class-fieldmanager-richtextarea.php | 4 +-
.../class-fieldmanager-context-post.php | 16 ++---
.../class-fieldmanager-context-quickedit.php | 28 ++++----
.../class-fieldmanager-context-submenu.php | 8 +--
.../class-fieldmanager-context-term.php | 4 +-
.../class-fieldmanager-datasource-post.php | 24 +++----
.../class-fieldmanager-datasource-term.php | 8 +--
.../class-fieldmanager-datasource-user.php | 12 ++--
php/util/class-fieldmanager-util-assets.php | 8 +--
.../class-fieldmanager-util-term-meta.php | 8 +--
.../class-fieldmanager-util-validation.php | 8 +--
16 files changed, 126 insertions(+), 126 deletions(-)
diff --git a/php/class-fieldmanager-checkboxes.php b/php/class-fieldmanager-checkboxes.php
index bd94c42c9..4fc7047a4 100644
--- a/php/class-fieldmanager-checkboxes.php
+++ b/php/class-fieldmanager-checkboxes.php
@@ -52,8 +52,8 @@ public function form_element( $value = array() ) {
* @return string $attribute on match, empty on failure.
*/
public function option_selected( $current_option, $options, $attribute ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
- if ( ( ( null !== $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) || ( 'checked' === $this->default_value && in_array( $this->default_value, $options ) ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
+ if ( ( ( null !== $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) || ( 'checked' == $this->default_value && in_array( $this->default_value, $options ) ) ) {
return $attribute;
} else {
return '';
diff --git a/php/class-fieldmanager-field.php b/php/class-fieldmanager-field.php
index 6357eed49..e7f15bd76 100644
--- a/php/class-fieldmanager-field.php
+++ b/php/class-fieldmanager-field.php
@@ -458,8 +458,8 @@ public function set_options( $label, $options ) {
}
// If this is a single field with a limit of 1, serialize_data has no impact.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! $this->serialize_data && ! $this->is_group() && 1 === $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ! $this->serialize_data && ! $this->is_group() && 1 == $this->limit ) {
$this->serialize_data = true;
}
@@ -483,8 +483,8 @@ public function set_options( $label, $options ) {
*/
public function element_markup( $values = array() ) {
$values = $this->preload_alter_values( $values );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit ) {
// count() generates a warning when passed non-countable values in PHP 7.2.
if ( is_scalar( $values ) ) {
$count_values = 1;
@@ -527,15 +527,15 @@ public function element_markup( $values = array() ) {
// Find the array position of the "counter" (e.g. in element[0], [0] is the counter, thus the position is 1).
$html_array_position = 0; // default is no counter; i.e. if $this->limit = 0.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit ) {
$html_array_position = 1; // base situation is formname[0], so the counter is in position 1.
if ( $this->parent ) {
$parent = $this->parent;
while ( $parent ) {
$html_array_position++; // one more for having a parent (e.g. parent[this][0]).
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $parent->limit ) { // and another for the parent having multiple (e.g. parent[0][this][0]).
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $parent->limit ) { // and another for the parent having multiple (e.g. parent[0][this][0]).
$html_array_position++;
}
$parent = $parent->parent; // parent's parent; root element has null parent which breaks while loop.
@@ -594,27 +594,27 @@ public function element_markup( $values = array() ) {
*/
$out = apply_filters( "fm_element_markup_start_{$this->name}", $out, $this, $values );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ( 0 === $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'top' === $this->add_more_position ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ( 0 == $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'top' == $this->add_more_position ) {
$out .= $this->add_another();
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit ) {
$out .= $this->single_element_markup( null, true );
}
for ( $i = 0; $i < $max; $i++ ) {
$this->seq = $i;
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 === $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 == $this->limit ) {
$value = $values;
} else {
$value = isset( $values[ $i ] ) ? $values[ $i ] : null;
}
$out .= $this->single_element_markup( $value );
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ( 0 === $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'bottom' === $this->add_more_position ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ( 0 == $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) && 'bottom' == $this->add_more_position ) {
$out .= $this->add_another();
}
@@ -715,8 +715,8 @@ public function single_element_markup( $value = null, $is_proto = false ) {
* the title from the tab label.
*/
if ( ! empty( $this->label ) && ! $this->is_tab && $this->one_label_per_item ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit ) {
$out .= $this->wrap_with_multi_tools( $label, array( 'fmjs-removable-label' ) );
} elseif ( ! $this->label_after_element ) {
$out .= $label;
@@ -735,8 +735,8 @@ public function single_element_markup( $value = null, $is_proto = false ) {
$form_element = $this->form_element( $value );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit && ( ! $this->one_label_per_item || empty( $this->label ) ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit && ( ! $this->one_label_per_item || empty( $this->label ) ) ) {
$out .= $this->wrap_with_multi_tools( $form_element );
} else {
$out .= $form_element;
@@ -790,8 +790,8 @@ public function wrap_with_multi_tools( $html, $classes = array() ) {
$out .= $html;
$out .= '
';
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 === $this->limit || $this->limit > $this->minimum_count ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 == $this->limit || $this->limit > $this->minimum_count ) {
$out .= $this->get_remove_handle();
}
@@ -809,14 +809,14 @@ public function get_form_name( $multiple = '' ) {
$tree = $this->get_form_tree();
$name = '';
foreach ( $tree as $level => $branch ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 === $level ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 == $level ) {
$name .= $branch->name;
} else {
$name .= '[' . $branch->name . ']';
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $branch->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $branch->limit ) {
$name .= '[' . $branch->get_seq() . ']';
}
}
@@ -877,8 +877,8 @@ public function get_element_key() {
* @return bool True if yes, false if no.
*/
public function is_repeatable() {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit ) {
return true;
} elseif ( $this->parent ) {
return $this->parent->is_repeatable();
@@ -905,8 +905,8 @@ public function is_group() {
* @return mixed Sanitized values.
*/
public function presave_all( $values, $current_values ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 === $this->limit && empty( $this->multiple ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 == $this->limit && empty( $this->multiple ) ) {
$values = $this->presave_alter_values( array( $values ), array( $current_values ) );
if ( ! empty( $values ) ) {
$value = $this->presave( $values[0], $current_values );
@@ -920,8 +920,8 @@ public function presave_all( $values, $current_values ) {
}
// If $this->limit != 1, and $values is not an array, that'd just be wrong, and possibly an attack, so...
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 !== $this->limit && ! is_array( $values ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 != $this->limit && ! is_array( $values ) ) {
// EXCEPT maybe this is a request to remove indices.
if ( ! empty( $this->index ) && null === $values && ! empty( $current_values ) && is_array( $current_values ) ) {
@@ -1017,8 +1017,8 @@ function ( $value ) {
* @param array $current_values The current values.
*/
protected function save_index( $values, $current_values ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'post' !== $this->data_type || empty( $this->data_id ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 'post' != $this->data_type || empty( $this->data_id ) ) {
return;
}
// Must delete current values specifically, then add new ones, to support a scenario where the
diff --git a/php/class-fieldmanager-group.php b/php/class-fieldmanager-group.php
index 09aaf201a..8f8005c43 100644
--- a/php/class-fieldmanager-group.php
+++ b/php/class-fieldmanager-group.php
@@ -147,8 +147,8 @@ public function __construct( $label = '', $options = array() ) {
parent::__construct( $label, $options );
// Repeatable groups cannot used unserialized data.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- $is_repeatable = ( 1 !== $this->limit );
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ $is_repeatable = ( 1 != $this->limit );
if ( ! $this->serialize_data && $is_repeatable ) {
throw new FM_Developer_Exception( esc_html__( 'You cannot use `"serialize_data" => false` with repeating groups', 'fieldmanager' ) );
}
@@ -161,8 +161,8 @@ public function __construct( $label = '', $options = array() ) {
// Convenient naming of child elements via their keys.
foreach ( $this->children as $name => $element ) {
// if the array key is not an int, and the name attr is set, and they don't match, we got a problem.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $element->name && ! is_int( $name ) && $element->name !== $name ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $element->name && ! is_int( $name ) && $element->name != $name ) {
throw new FM_Developer_Exception( esc_html( __( 'Group child name conflict: ', 'fieldmanager' ) . $name . ' / ' . $element->name ) );
} elseif ( ! $element->name ) {
$element->name = $name;
@@ -246,26 +246,26 @@ public function form_element( $value = null ) {
// Set default classes to display the first tab content and hide others.
$tab_classes = array( 'fm-tab' );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- $tab_classes[] = ( 0 === $this->child_count ) ? 'wp-tab-active' : 'hide-if-no-js';
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ $tab_classes[] = ( 0 == $this->child_count ) ? 'wp-tab-active' : 'hide-if-no-js';
// Generate output for the tab. Depends on whether or not there is a tab limit in place.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 === $this->tab_limit || $this->child_count < $this->tab_limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 == $this->tab_limit || $this->child_count < $this->tab_limit ) {
$tab_group .= sprintf(
'%s ',
esc_attr( implode( ' ', $tab_classes ) ),
esc_attr( $element->get_element_id() ),
$element->escape( 'label' )
);
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- } elseif ( 0 !== $this->tab_limit && $this->child_count >= $this->tab_limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ } elseif ( 0 != $this->tab_limit && $this->child_count >= $this->tab_limit ) {
$submenu_item_classes = array( 'fm-submenu-item' );
$submenu_item_link_class = '';
// Create the More tab when first hitting the tab limit.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->child_count === $this->tab_limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $this->child_count == $this->tab_limit ) {
// Create the tab.
$tab_group_submenu .= sprintf(
'';
}
if ( $this->tabbed ) {
@@ -397,8 +397,8 @@ public function presave( $values, $current_values = array() ) {
$child_value = empty( $values[ $element->name ] ) ? null : $values[ $element->name ];
$current_child_value = ! isset( $current_values[ $element->name ] ) ? array() : $current_values[ $element->name ];
$values[ $element->name ] = $element->presave_all( $values[ $element->name ], $current_child_value );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! $this->save_empty && 1 !== $this->limit ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ! $this->save_empty && 1 != $this->limit ) {
if ( is_array( $values[ $element->name ] ) ) {
if ( empty( $values[ $element->name ] ) ) {
unset( $values[ $element->name ] );
@@ -473,8 +473,8 @@ public function get_element_label( $classes = array() ) {
}
$remove = '';
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->one_label_per_item && ( 0 === $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $this->one_label_per_item && ( 0 == $this->limit || ( $this->limit > 1 && $this->limit > $this->minimum_count ) ) ) {
$remove = $this->get_remove_handle();
}
diff --git a/php/class-fieldmanager-media.php b/php/class-fieldmanager-media.php
index 057c5a1e3..a9d74424f 100644
--- a/php/class-fieldmanager-media.php
+++ b/php/class-fieldmanager-media.php
@@ -139,8 +139,8 @@ public function admin_print_scripts() {
* @return int The sanitized value.
*/
public function presave( $value, $current_value = array() ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 === $value || ! is_numeric( $value ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 == $value || ! is_numeric( $value ) ) {
return null;
}
return absint( $value );
diff --git a/php/class-fieldmanager-options.php b/php/class-fieldmanager-options.php
index b8ca1ac1e..f36aff819 100644
--- a/php/class-fieldmanager-options.php
+++ b/php/class-fieldmanager-options.php
@@ -154,12 +154,12 @@ public function form_data_elements( $value ) {
// If grouped display is desired, check where to add the start and end points
// Note we are assuming the data has come pre-sorted into groups.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->grouped && ( $current_group !== $data_element['group'] ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $this->grouped && ( $current_group != $data_element['group'] ) ) {
// Append the end for the previous group unless this is the first group.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( '' !== $current_group ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( '' != $current_group ) {
$form_data_elements_html .= $this->form_data_end_group();
}
@@ -210,8 +210,8 @@ public function form_data_element( $data_row, $value ) {
* @return string $attribute On match, empty On failure.
*/
public function option_selected( $current_option, $options, $attribute ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
- if ( ( null !== $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
+ if ( ( null != $options && ! empty( $options ) ) && in_array( $current_option, $options ) ) {
return $attribute;
}
diff --git a/php/class-fieldmanager-richtextarea.php b/php/class-fieldmanager-richtextarea.php
index ef1311d9a..36dadb783 100644
--- a/php/class-fieldmanager-richtextarea.php
+++ b/php/class-fieldmanager-richtextarea.php
@@ -155,8 +155,8 @@ public function form_element( $value = '' ) {
if ( ! isset( $settings['default_editor'] ) ) {
$settings['default_editor'] = 'tinymce';
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- } elseif ( 'cookie' === $settings['default_editor'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ } elseif ( 'cookie' == $settings['default_editor'] ) {
if ( $proto ) {
$settings['default_editor'] = 'tinymce';
} else {
diff --git a/php/context/class-fieldmanager-context-post.php b/php/context/class-fieldmanager-context-post.php
index 9a8237106..1ec31e32d 100644
--- a/php/context/class-fieldmanager-context-post.php
+++ b/php/context/class-fieldmanager-context-post.php
@@ -180,8 +180,8 @@ public function save_fields_for_post( $post_id ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- baseline
empty( $_POST['post_ID'] )
|| ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- || ( isset( $_POST['action'] ) && 'editpost' !== $_POST['action'] )
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Missing -- baseline
+ || ( isset( $_POST['action'] ) && 'editpost' != $_POST['action'] )
) {
return;
}
@@ -193,8 +193,8 @@ public function save_fields_for_post( $post_id ) {
}
// Prevent saving the same post twice; FM does not yet use revisions.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( get_post_type( $post_id ) === 'revision' ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( get_post_type( $post_id ) == 'revision' ) {
return;
}
@@ -205,8 +205,8 @@ public function save_fields_for_post( $post_id ) {
}
// Do not handle quickedit in this context.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( 'inline-save' === $_POST['action'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Missing -- baseline
+ if ( 'inline-save' == $_POST['action'] ) {
return;
}
@@ -218,8 +218,8 @@ public function save_fields_for_post( $post_id ) {
}
// Make sure the current user is authorized to save this post.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( isset( $_POST['post_type'] ) && 'post' === $_POST['post_type'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Missing -- baseline
+ if ( isset( $_POST['post_type'] ) && 'post' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
$this->fm->_unauthorized_access( __( 'User cannot edit this post', 'fieldmanager' ) );
return;
diff --git a/php/context/class-fieldmanager-context-quickedit.php b/php/context/class-fieldmanager-context-quickedit.php
index b3aeef473..1b46f3810 100644
--- a/php/context/class-fieldmanager-context-quickedit.php
+++ b/php/context/class-fieldmanager-context-quickedit.php
@@ -120,8 +120,8 @@ public function add_custom_columns( $columns ) {
* @param int $post_id The post ID.
*/
public function manage_custom_columns( $column_name, $post_id ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $column_name !== $this->fm->name ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $column_name != $this->fm->name ) {
return;
}
$data = get_post_meta( $post_id, $this->fm->name, true );
@@ -140,8 +140,8 @@ public function manage_custom_columns( $column_name, $post_id ) {
* @param array $values The current values.
*/
public function add_quickedit_box( $column_name, $post_type, $values = array() ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $column_name !== $this->fm->name ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $column_name != $this->fm->name ) {
return;
}
?>
@@ -173,8 +173,8 @@ public function render_ajax_form() {
return;
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Recommended -- baseline
- if ( 'fm_quickedit_render' !== $_GET['action'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Recommended -- baseline
+ if ( 'fm_quickedit_render' != $_GET['action'] ) {
return;
}
@@ -183,8 +183,8 @@ public function render_ajax_form() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- baseline
$post_id = intval( $_GET['post_id'] );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! $post_id || $column_name !== $this->fm->name ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ! $post_id || $column_name != $this->fm->name ) {
return;
}
@@ -210,16 +210,16 @@ public function save_fields_for_quickedit( $post_id ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- baseline
! isset( $_POST['post_type'] )
|| ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- || ( isset( $_POST['action'] ) && 'inline-save' !== $_POST['action'] )
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Missing -- baseline
+ || ( isset( $_POST['action'] ) && 'inline-save' != $_POST['action'] )
) {
return;
}
$use_this_post_type = false;
foreach ( $this->post_types as $type ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( $type === $_POST['post_type'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Missing -- baseline
+ if ( $type == $_POST['post_type'] ) {
$use_this_post_type = true;
break;
}
@@ -234,8 +234,8 @@ public function save_fields_for_quickedit( $post_id ) {
}
// Make sure the current user can save this post.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing -- baseline
- if ( 'post' === $_POST['post_type'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Missing -- baseline
+ if ( 'post' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
$this->fm->_unauthorized_access( __( 'User cannot edit this post', 'fieldmanager' ) );
return;
diff --git a/php/context/class-fieldmanager-context-submenu.php b/php/context/class-fieldmanager-context-submenu.php
index bb8c36f5e..661dc79af 100644
--- a/php/context/class-fieldmanager-context-submenu.php
+++ b/php/context/class-fieldmanager-context-submenu.php
@@ -111,8 +111,8 @@ public function render_submenu_page() {
?>
@@ -144,8 +144,8 @@ public function render_submenu_page() {
* Save a submenu page
*/
public function handle_submenu_save() {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Recommended -- baseline
- if ( empty( $_GET['page'] ) || $_GET['page'] !== $this->menu_slug ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons, WordPress.Security.NonceVerification.Recommended -- baseline
+ if ( empty( $_GET['page'] ) || $_GET['page'] != $this->menu_slug ) {
return;
}
diff --git a/php/context/class-fieldmanager-context-term.php b/php/context/class-fieldmanager-context-term.php
index 5e6ee90b8..ce19dc57e 100644
--- a/php/context/class-fieldmanager-context-term.php
+++ b/php/context/class-fieldmanager-context-term.php
@@ -223,8 +223,8 @@ public function add_term_fields( $taxonomy ) {
*/
public function edit_term_fields( $term, $taxonomy ) {
// Check if this term's parent matches the specified term if it is set.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 !== strlen( $this->parent ) && $this->parent !== $term->parent ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 !== strlen( $this->parent ) && $this->parent != $term->parent ) {
return;
}
diff --git a/php/datasource/class-fieldmanager-datasource-post.php b/php/datasource/class-fieldmanager-datasource-post.php
index e904e598e..a8be668fe 100644
--- a/php/datasource/class-fieldmanager-datasource-post.php
+++ b/php/datasource/class-fieldmanager-datasource-post.php
@@ -158,10 +158,10 @@ public function get_items( $fragment = null ) {
if ( $post_id ) {
$exact_post = get_post( $post_id );
if ( $exact_post && (
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- 'any' === $post_args['post_type'] ||
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- $post_args['post_type'] === $exact_post->post_type ||
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ 'any' == $post_args['post_type'] ||
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ $post_args['post_type'] == $exact_post->post_type ||
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- baseline
in_array( $exact_post->post_type, $post_args['post_type'] )
) ) {
@@ -242,8 +242,8 @@ public function title_like( $where, $wp_query ) {
* @param array $current_values Existing post values.
*/
public function presave_alter_values( Fieldmanager_Field $field, $values, $current_values ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'post' === $field->data_type && ! empty( $this->reciprocal ) && ! empty( $current_values ) && is_array( $current_values ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 'post' == $field->data_type && ! empty( $this->reciprocal ) && ! empty( $current_values ) && is_array( $current_values ) ) {
foreach ( $current_values as $reciprocal_post_id ) {
delete_post_meta( $reciprocal_post_id, $this->reciprocal, $field->data_id );
}
@@ -281,8 +281,8 @@ public function presave( Fieldmanager_Field $field, $value, $current_value ) {
}
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->save_to_post_parent && 1 === $field->limit && 'post' === $field->data_type ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $this->save_to_post_parent && 1 == $field->limit && 'post' == $field->data_type ) {
if ( ! wp_is_post_revision( $field->data_id ) ) {
Fieldmanager_Context_Post::safe_update_post(
array(
@@ -331,8 +331,8 @@ public function preload_alter_values( Fieldmanager_Field $field, $values ) {
if ( $this->only_save_to_post_parent ) {
$post_parent = wp_get_post_parent_id( $field->data_id );
if ( $post_parent ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- return ( 1 === $field->limit && empty( $field->multiple ) ) ? $post_parent : array( $post_parent );
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ return ( 1 == $field->limit && empty( $field->multiple ) ) ? $post_parent : array( $post_parent );
}
}
return $values;
@@ -445,8 +445,8 @@ function fm_url_to_post_id( $url ) {
foreach ( (array) $rewrite as $match => $query ) {
// If the requesting file is the anchor of the match, prepend it
// to the path info.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! empty( $url ) && ( $url !== $request ) && ( strpos( $match, $url ) === 0 ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
$request_match = $url . '/' . $request;
}
diff --git a/php/datasource/class-fieldmanager-datasource-term.php b/php/datasource/class-fieldmanager-datasource-term.php
index 33e715c87..a8dae279c 100644
--- a/php/datasource/class-fieldmanager-datasource-term.php
+++ b/php/datasource/class-fieldmanager-datasource-term.php
@@ -156,8 +156,8 @@ public function preload_alter_values( Fieldmanager_Field $field, $values ) {
}
if ( count( $terms ) > 0 ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 1 === $field->limit && empty( $field->multiple ) ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 1 == $field->limit && empty( $field->multiple ) ) {
return $terms[0]->term_id;
} else {
$ret = array();
@@ -391,8 +391,8 @@ protected function build_hierarchical_term_data( $parent_terms, $tax_args, $dept
$tax_args['search'] = $pattern;
}
$child_terms = get_terms( array_merge( $tax_args, array( 'taxonomy' => $this->get_taxonomies() ) ) );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 === $this->taxonomy_hierarchical_depth || $depth + 1 < $this->taxonomy_hierarchical_depth ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 == $this->taxonomy_hierarchical_depth || $depth + 1 < $this->taxonomy_hierarchical_depth ) {
if ( ! empty( $child_terms ) ) {
$stack = $this->build_hierarchical_term_data( $child_terms, $this->taxonomy_args, $depth + 1, $stack );
}
diff --git a/php/datasource/class-fieldmanager-datasource-user.php b/php/datasource/class-fieldmanager-datasource-user.php
index ad4877266..e1f9b2df1 100644
--- a/php/datasource/class-fieldmanager-datasource-user.php
+++ b/php/datasource/class-fieldmanager-datasource-user.php
@@ -107,8 +107,8 @@ public function __construct( $options = array() ) {
);
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( ! empty( $this->reciprocal ) && 'ID' !== $this->store_property ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( ! empty( $this->reciprocal ) && 'ID' != $this->store_property ) {
throw new FM_Developer_Exception( esc_html__( 'You cannot use reciprocal relationships with FM_Datasource_User if store_property is not set to ID.', 'fieldmanager' ) );
}
@@ -212,8 +212,8 @@ public function get_ajax_action() {
* @return string Sanitized values.
*/
public function presave_alter_values( Fieldmanager_Field $field, $values, $current_values ) {
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'post' !== $field->data_type || ! $this->reciprocal || 'ID' !== $this->store_property ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 'post' != $field->data_type || ! $this->reciprocal || 'ID' != $this->store_property ) {
return $values;
}
@@ -269,8 +269,8 @@ public function presave( Fieldmanager_Field $field, $value, $current_value ) {
/* translators: %s: user id */
wp_die( esc_html( sprintf( __( 'Tried to refer to user "%s" which current user cannot edit.', 'fieldmanager' ), $v ) ) );
}
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( $this->reciprocal && 'ID' === $this->store_property ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( $this->reciprocal && 'ID' == $this->store_property ) {
call_user_func(
/**
* Filters function used to add user meta. This improves compatibility with
diff --git a/php/util/class-fieldmanager-util-assets.php b/php/util/class-fieldmanager-util-assets.php
index 399befed6..36eecbcb8 100644
--- a/php/util/class-fieldmanager-util-assets.php
+++ b/php/util/class-fieldmanager-util-assets.php
@@ -212,8 +212,8 @@ public function add_script( $args ) {
}
// Set the default directory.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( '' === $args['plugin_dir'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( '' == $args['plugin_dir'] ) {
$args['plugin_dir'] = fieldmanager_get_baseurl(); // Allow overrides for child plugins.
}
$args['path'] = $args['plugin_dir'] . $args['path'];
@@ -272,8 +272,8 @@ public function add_style( $args ) {
}
// Set the default directory.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( '' === $args['plugin_dir'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( '' == $args['plugin_dir'] ) {
$args['plugin_dir'] = fieldmanager_get_baseurl(); // Allow overrides for child plugins.
}
$args['path'] = $args['plugin_dir'] . $args['path'];
diff --git a/php/util/class-fieldmanager-util-term-meta.php b/php/util/class-fieldmanager-util-term-meta.php
index 09939685d..bc2fa8d7e 100644
--- a/php/util/class-fieldmanager-util-term-meta.php
+++ b/php/util/class-fieldmanager-util-term-meta.php
@@ -292,8 +292,8 @@ public function add_term_meta_post( $term_id, $taxonomy ) {
);
// Check the result.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 0 !== $result ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 0 != $result ) {
return $result;
} else {
return false;
@@ -327,8 +327,8 @@ public function collect_garbage( $term_id, $tt_id, $taxonomy ) {
*/
public function split_shared_term( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
$post_id = $this->get_term_meta_post_id( $old_term_id, $taxonomy );
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( false !== $post_id ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( false != $post_id ) {
wp_update_post(
array(
'ID' => $post_id,
diff --git a/php/util/class-fieldmanager-util-validation.php b/php/util/class-fieldmanager-util-validation.php
index 26af7f44e..c2f8b7217 100644
--- a/php/util/class-fieldmanager-util-validation.php
+++ b/php/util/class-fieldmanager-util-validation.php
@@ -107,8 +107,8 @@ private function setup( $form_id, $context ) {
// Add the appropriate action hook to finalize and output validation JS.
// Also determine where the jQuery validation script needs to be added.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'page' === $context ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 'page' == $context ) {
// Currently only the page context outputs to the frontend.
$action = 'wp_footer';
$admin = false;
@@ -177,8 +177,8 @@ public function add_field( &$fm ) {
// If this is the term context and the field is required, modify the original element to have the required property.
// This is necessary because it is the only way validation is supported on the term add form.
// Other validation methods won't work and will just fail gracefully.
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- baseline
- if ( 'term' === $this->context && isset( $fm->validation_rules['required'] ) && $fm->validation_rules['required'] ) {
+ // phpcs:ignore Universal.Operators.StrictComparisons -- baseline
+ if ( 'term' == $this->context && isset( $fm->validation_rules['required'] ) && $fm->validation_rules['required'] ) {
$fm->required = true;
}