WP_Interactivity_API::get_context
Returns the latest value on the context stack with the passed namespace.
When the namespace is omitted, it uses the current namespace on the namespace stack during a process_directives call.
Method of the class: WP_Interactivity_API{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WP_Interactivity_API = new WP_Interactivity_API(); $WP_Interactivity_API->get_context( ?string $store_namespace ): array;
- ?string $store_namespace
- .
Default:null
Changelog
| Since 6.6.0 | Introduced. |
WP_Interactivity_API::get_context() WP Interactivity API::get context code WP 6.9.1
public function get_context( ?string $store_namespace = null ): array {
if ( null === $this->context_stack ) {
_doing_it_wrong(
__METHOD__,
__( 'The context can only be read during directive processing.' ),
'6.6.0'
);
return array();
}
if ( ! $store_namespace ) {
if ( null !== $store_namespace ) {
_doing_it_wrong(
__METHOD__,
__( 'The namespace should be a non-empty string.' ),
'6.6.0'
);
return array();
}
$store_namespace = end( $this->namespace_stack );
}
$context = end( $this->context_stack );
return ( $store_namespace && $context && isset( $context[ $store_namespace ] ) )
? $context[ $store_namespace ]
: array();
}