Skip to content

Allow box_values() to accept string input#2761

Merged
selul merged 2 commits intodevelopmentfrom
copilot/update-box-values-string-input
Mar 19, 2026
Merged

Allow box_values() to accept string input#2761
selul merged 2 commits intodevelopmentfrom
copilot/update-box-values-string-input

Conversation

Copy link

Copilot AI commented Mar 19, 2026

CSS_Utility::box_values() passed its $box argument directly to array_map(), causing a fatal error when a string (e.g. a raw CSS value like '10px') was provided instead of an array.

Changes

  • inc/css/class-css-utility.php — Added an early return in box_values() when $box is not an array; updated @param type to array|string.
  • tests/test-css.php — Added test_box_values_string_input() covering string pass-through cases.
public static function box_values( $box, $box_default = array() ) {
    if ( ! is_array( $box ) ) {
        return $box; // string values returned as-is
    }
    // existing array logic...
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Allow box_values() to use a string input without requiring an array</issue_title>
<issue_description>## 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.</issue_description>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: selul <3330746+selul@users.noreply.github.com>
Copilot AI changed the title [WIP] Update box_values to accept string input without array Allow box_values() to accept string input Mar 19, 2026
Copilot AI requested a review from selul March 19, 2026 14:54
@selul selul marked this pull request as ready for review March 19, 2026 14:55
@pirate-bot
Copy link
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 271.64 KB 271.64 KB 0 B (0.00%)
Blocks 1.54 MB 1.54 MB 0 B (0.00%)
CSS 100.76 KB 100.76 KB 0 B (0.00%)
Dashboard 198.36 KB 198.36 KB 0 B (0.00%)
Onboarding 160.8 KB 160.8 KB 0 B (0.00%)
Export Import 97.73 KB 97.73 KB 0 B (0.00%)
Pro 407.08 KB 407.08 KB 0 B (0.00%)

@selul selul merged commit fcec296 into development Mar 19, 2026
22 checks passed
@selul selul deleted the copilot/update-box-values-string-input branch March 19, 2026 15:00
@pirate-bot
Copy link
Contributor

Plugin build for 4a32002 is ready 🛎️!

@pirate-bot
Copy link
Contributor

E2E Tests

Playwright Test Status:

Performance Results serverResponse: {"q25":413.7,"q50":416.6,"q75":422.7,"cnt":10}, firstPaint: {"q25":415.4,"q50":516.3,"q75":534.4,"cnt":10}, domContentLoaded: {"q25":1541.7,"q50":1551,"q75":1566.6,"cnt":10}, loaded: {"q25":1542.1,"q50":1551.35,"q75":1566.9,"cnt":10}, firstContentfulPaint: {"q25":3221.2,"q50":3240.75,"q75":3254,"cnt":10}, firstBlock: {"q25":6590.9,"q50":6637.9,"q75":6792.9,"cnt":10}, type: {"q25":13.01,"q50":13.36,"q75":13.55,"cnt":10}, typeWithoutInspector: {"q25":11.53,"q50":12.01,"q75":12.66,"cnt":10}, typeWithTopToolbar: {"q25":15.77,"q50":16.24,"q75":16.66,"cnt":10}, typeContainer: {"q25":7.25,"q50":8.01,"q75":8.49,"cnt":10}, focus: {"q25":50.47,"q50":53.24,"q75":54.61,"cnt":10}, inserterOpen: {"q25":15.78,"q50":17.18,"q75":19.9,"cnt":10}, inserterSearch: {"q25":5.4,"q50":5.52,"q75":5.58,"cnt":10}, inserterHover: {"q25":2.31,"q50":2.45,"q75":2.68,"cnt":20}, loadPatterns: {"q25":1054.09,"q50":1075.71,"q75":1128.99,"cnt":10}, listViewOpen: {"q25":80.34,"q50":85.47,"q75":96.96,"cnt":10}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants