Make WordPress Core

Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#56307 closed defect (bug) (fixed)

Docs: Fix parameter type of `$feature` in `block_has_support()`

Reported by: soean's profile Soean Owned by: audrasjb's profile audrasjb
Milestone: 6.1 Priority: normal
Severity: normal Version: 5.8
Component: Editor Keywords: has-patch
Focuses: docs Cc:

Description

In the docs of block_has_support() the type of $feature is string. See on GitHub.

It should be an array, as you see in the tests and core.

For example block_has_support( $block_type, array( 'color', 'gradient' ) );.

Change History (8)

This ticket was mentioned in PR #3039 on WordPress/wordpress-develop by Soean.


21 months ago
#1

  • Keywords has-patch added

In the docs of block_has_support() the type of $feature is string, should be array.

Trac ticket: https://core.trac.wordpress.org/ticket/56307

#2 @audrasjb
21 months ago

  • Owner set to audrasjb
  • Status changed from new to accepted
  • Version set to 5.8

Good catch!

Introduced in #50761 (WP 5.8).

#3 @audrasjb
21 months ago

@Soean maybe replace
Path to the specific feature to check support for.
with:
Array of paths to specific features to check support for.

What do you think?

Last edited 21 months ago by audrasjb (previous) (diff)

#4 @Soean
21 months ago

Only one $feature is checked at a time, this $feature can be nested, like for example:

block.json

{
    "apiVersion": 2,
    ...
    "supports": {
        "spacing": {
            "margin": true,
            "padding": false
        }
        "align": false
    }
}

$feature:
array( 'spacing', 'margin' ) --> true

array( 'spacing', 'padding' ) --> false

Or be at the highest level, like:

array( 'align' ) --> false

So maybe? Array of path to a specific feature to check support for. ?

#5 @audrasjb
21 months ago

Ok I see. Then Path to a specific feature to check support for. looks good for me :)

#6 @audrasjb
21 months ago

  • Milestone changed from Awaiting Review to 6.1

#7 @audrasjb
21 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 53799:

Docs: Fix $feature parameter type in block_has_support().

In block_has_support() docblock, the $feature parameter is an array, not a string.

Props Soean, audrasjb.
Fixes #56307.
See #55646.

Note: See TracTickets for help on using tickets.