shortcode_atts_<shortcode>

Filters a shortcode's default attributes.

Description

apply_filters( 'shortcode_atts_<shortcode>', (array) $out, (array) $pairs, (array) $atts, (string) $shortcode ); 

If the third parameter of the shortcode_atts() function is present then this filter is available. The third parameter, $shortcode, is the name of the shortcode.

Parameters (4)

0. $out (array)
The output array of shortcode attributes.
1. $pairs (array)
The supported attributes and their defaults.
2. $atts (array)
The user defined shortcode attributes.
3. $shortcode (string)
The shortcode name.

Usage

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

Defined (1)

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

/wp-includes/shortcodes.php  
  1. $out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode );