Purpose
Modify the queried data for a specific template object programmatically, enabling dynamic adjustments based on specific conditions.
Usage
add_filter( "wr_template_object_modify_data", array( $this, "my_template_object_modify_data" ), 10, 2 );
Parameters
$data (array)
: The current data associated with the template object.$options (TemplateObjectDTO)
: The template object options, including identifiers and additional settings.
Use Case
This functionality is useful when:
- You need to adjust the data retrieved for a template object dynamically (e.g., applying calculations or transformations).
- The data requires customization based on the template’s identifier or other parameters.
Implementation Example
add_filter( "wr_template_object_modify_data", array( $this, "my_template_object_modify_data" ), 10, 2 );
public function my_template_object_modify_data( $data, TemplateObjectDTO $options) {
$options = $settings->options;
if ( $options->option_exists( "identifier" ) ) {
if ( $options->find( "value", "my_identifier" ) !== null ) {
$data["value"] = $data["value"]*1.1;
}
}
return $data;
}