Skip to content

Commit

Permalink
Properly use the filter for interactivity data
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed May 16, 2024
1 parent 4695f39 commit a1d2c2a
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,21 @@ public function config( string $store_namespace, array $config = array() ): arra
}

/**
* Prints the serialized client-side interactivity data.
* Adds interactivity data to filtered data to be passed to the client.
*
* Encodes the config and initial state into JSON and prints them inside a
* script tag of type "application/json". Once in the browser, the state will
* be parsed and used to hydrate the client-side interactivity stores and the
* configuration will be available using a `getConfig` utility.
* Once in the browser, the state will be parsed and used to hydrate the client-side
* interactivity stores and the configuration will be available using a `getConfig` utility.
*
* @since 6.5.0
*
* @param array $interactivity_data Interactivity data.
* @return array $interactivity_data Interactivity data with store data added (if it exists).
*/
public function print_client_interactivity_data() {
public function print_client_interactivity_data( $interactivity_data ) {
if ( empty( $this->state_data ) && empty( $this->config_data ) ) {
return;
return $interactivity_data;
}

$interactivity_data = array();

$config = array();
foreach ( $this->config_data as $key => $value ) {
if ( ! empty( $value ) ) {
Expand Down

0 comments on commit a1d2c2a

Please sign in to comment.