Purpose

Modify query placeholders programmatically after placeholders are replaced in a query string. This filter allows external logic to dynamically adjust query parameters.

Usage

add_filter("wr_query_replace_placeholder", array( $this, "my_query_replace_placeholder" ), 10, 1 );

Parameters

  • $parameter (array): An associative array containing placeholders and their respective values.

Use Case

This functionality is useful when:

  • You need to dynamically update query placeholders before executing the query.
  • External factors or custom logic determine the value of certain query parameters.

Implementation Example

The following example replaces the value of the placeholder my_placeholder with “new value”:

add_filter("wr_query_replace_placeholder", array( $this, "my_query_replace_placeholder" ), 10, 1 );
 
public function my_query_replace_placeholder($parameter) {  
 
	if(isset($parameter["my_placeholder"])) {    
		$parameter["my_placeholder"] = "new value";
	}	
	return $parameter;
}

The code transforms the query:

SELECT id, description FROM wp_wr_service WHERE identifier like '%##my_placeholder##';

Into the following query:

SELECT id, description FROM wp_wr_service WHERE identifier like '%new value';