WP_Scripts::add_data( string $handle, string $key, mixed $value ): bool
This overrides the add_data method from WP_Dependencies, to support normalizing of $args.
Parameters
-
$handle
string Required -
Name of the item. Should be unique.
-
$key
string Required -
The data key.
-
$value
mixed Required -
The data value.
Return
bool True on success, false on failure.
Source
File: wp-includes/class-wp-scripts.php
.
View all references
public function add_data( $handle, $key, $value ) {
if ( ! isset( $this->registered[ $handle ] ) ) {
return false;
}
if ( 'strategy' === $key ) {
if ( ! empty( $value ) && ! $this->is_delayed_strategy( $value ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: $strategy, 2: $handle */
__( 'Invalid strategy `%1$s` defined for `%2$s` during script registration.' ),
$value,
$handle
),
'6.3.0'
);
return false;
} elseif ( ! $this->registered[ $handle ]->src && $this->is_delayed_strategy( $value ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: $strategy, 2: $handle */
__( 'Cannot supply a strategy `%1$s` for script `%2$s` because it is an alias (it lacks a `src` value).' ),
$value,
$handle
),
'6.3.0'
);
return false;
}
}
return parent::add_data( $handle, $key, $value );
}
Changelog
Version | Description |
---|---|
6.3.0 | Introduced. |