WP_Ability::__construct
Constructor.
Do not use this constructor directly. Instead, use the wp_register_ability()
Method of the class: WP_Ability{}
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
null. Nothing (null).
Usage
$WP_Ability = new WP_Ability(); $WP_Ability->__construct( $name, $args );
- $name(string) (required)
- The name of the ability, with its namespace.
- $args(array) (required)
- .
Notes
Changelog
| Since 6.9.0 | Introduced. |
WP_Ability::__construct() WP Ability:: construct code WP 6.9.1
public function __construct( string $name, array $args ) {
$this->name = $name;
$properties = $this->prepare_properties( $args );
foreach ( $properties as $property_name => $property_value ) {
if ( ! property_exists( $this, $property_name ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: Property name. */
__( 'Property "%1$s" is not a valid property for ability "%2$s". Please check the %3$s class for allowed properties.' ),
'<code>' . esc_html( $property_name ) . '</code>',
'<code>' . esc_html( $this->name ) . '</code>',
'<code>' . __CLASS__ . '</code>'
),
'6.9.0'
);
continue;
}
$this->$property_name = $property_value;
}
}