wp_sprintf

Filters a fragment from the pattern passed to wp_sprintf().

Description

apply_filters( 'wp_sprintf', (string) $fragment, (string) $arg ); 

If the fragment is unchanged, then sprintf() will be run on the fragment.

Parameters (2)

0. $fragment (string)
A fragment from the pattern.
1. $arg (string)
The argument.

Usage

To run the hook, copy the example below.
  1. $fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); 
  2.  
  3. if ( !empty( $fragment ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_sprintf callback 
  2. function filter_wp_sprintf( $fragment, $arg ) { 
  3. // make filter magic happen here... 
  4. return $fragment
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_sprintf', 'filter_wp_sprintf', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_sprintf', 'filter_wp_sprintf', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/formatting.php  
  1. $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );