Skip to content

Allow box_values() to use a string input without requiring an array #2760

@selul

Description

@selul

Problem

In the box_values method, when $box is a string, the current implementation expects $box to always be an array. This creates unnecessary type constraints and can break scenarios where a string is valid input.

Suggested Fix

Update box_values to use the following logic:

if ( ! is_array( $box ) ) {
    return $box;
}

This way, when $box is a string, it will simply be returned, making the function more robust.

Code Reference

public static function box_values( $box, $box_default = array() ) {
    if ( ! is_array( $box ) ) {
        return $box;
    }
    // existing logic here
}

Expected Behavior

  • If $box is a string, return the string as is.
  • If $box is an array, continue with the current array logic.

Benefit

This change improves compatibility and prevents errors when a string is given as input.

Metadata

Metadata

Assignees

Labels

releasedIndicate that an issue has been resolved and released in a particular version of the product.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions