Advertisements

add_filter

Definition:
function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {}

Hooks a function or method to a specific filter action.
Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Plugins can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

Parameters

  • string $tag: The name of the filter to hook the $function_to_add to.
  • callback $function_to_add: The name of the function to be called when the filter is applied.
  • int $priority: optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
  • int $accepted_args: optional. The number of arguments the function accept (default 1).

Return values

returns:true

Source code

function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {

	global $wp_filter, $merged_filters;



	$idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);

	$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);

	unset( $merged_filters[ $tag ] );

	return true;

}

347

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: