Purpose

Dynamically modify the file path for a PDF template. This filter allows you to programmatically specify a custom template path based on specific conditions.

Usage

add_filter( "wr_pdf_template_template_path", array( $this, "custom_template_path" ), 10, 4 );

Parameters

  • $template_path (string): The default file path for the PDF template.
  • $payload (array): The data associated with the template.
  • $options (array): Additional options, such as identifiers or context.

Use Case

This functionality is useful when:

  • You need to override the default PDF template path for specific scenarios.
  • External plugins or custom logic determine the appropriate template file based on options or payload data.

Implementation Example

The following example sets a custom PDF template path for templates with a specific identifier:

add_filter( "wr_pdf_template_template_path", array( $this, "custom_template_path" ), 10, 4 );
 
public function custom_template_path( $template_path, $payload, $options ) {
	if($options["identifier"] == "identifier") {
		return "custom/path/template.pdf"
	}
	return $template_path;
}