Purpose

Set data for a template programmatically, bypassing the need for data stored in the database.

Usage

add_filter( "wr_template_object_set_data", array( $this, "my_template_object_set_data" ), 10, 3 );

Parameters

  • $data
  • $options
  • $selector

Use Case

This functionality is useful when:

  • The required data does not exist in the database (e.g., data from external files).
  • You need to generate or compute data dynamically using custom algorithms.

Implementation Example

add_filter( "wr_template_object_set_data", array( $this, "my_template_object_set_data" ), 10, 3 );
 
public function my_template_object_set_data( $data, $options = array(), $selector = array() ) {
	if ( !empty($options["identifier"] && $options["identifier"] === "my_template_object_identifier" ) ) {
		return array("placeholder" => 1)
	}
	return $data;
}