apply_filters( “script_module_data_{$module_id}”, array $data )

In this article

Filters data associated with a given Script Module.

Description

Script Modules may require data that is required for initialization or is essential to have immediately available on page load. These are suitable use cases for this data.

The dynamic portion of the hook name, $module_id, refers to the Script Module ID that the data is associated with.

This is best suited to pass essential data that must be available to the module for initialization or immediately on page load. It does not replace the REST API or fetching data from the client.

Parameters

$dataarray
The data associated with the Script Module.

Source

$data = apply_filters( "script_module_data_{$module_id}", array() );

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.