[wp-trac] [WordPress Trac] #56707: `register_block_type`'s `editor_script` handle fails if it is an array.
WordPress Trac
noreply at wordpress.org
Tue Oct 18 13:00:31 UTC 2022
#56707: `register_block_type`'s `editor_script` handle fails if it is an array.
-------------------------------------------------+-------------------------
Reporter: nendeb55 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1
Component: Editor | Version: trunk
Severity: normal | Resolution:
Keywords: needs-testing has-testing-info dev- | Focuses:
feedback |
-------------------------------------------------+-------------------------
Comment (by nendeb55):
@costdev Thank you for the improvement.
I hope this is the kind of code you're looking for to organize it.
{{{#!php
<?php
public function __set( $name, $value ) {
if ( ! in_array( $name, $this->deprecated_properties ) ) {
$this->{$name} = $value;
return;
}
$new_name = $name . '_handles';
if ( is_array( $value ) ) {
$filtered = array_filter( $value, 'is_string' );
if ( count( $filtered ) !== count( $value ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: The '$value' argument.
*/
__( 'The %s argument must be a string or a
string array.' ),
'<code>$value</code>'
),
'6.1.0',
);
}
$this->{$new_name} = $filtered;
return;
}
if ( ! is_string( $value ) ) {
return;
}
$this->{$new_name}[0] = $value;
}
}}}
Tested. It worked correctly.
Will this be reflected in WordPress 6.1?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56707#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list