filtrdynamicznyod 3.6.0
shortcode_atts_{$shortcode}
Args 4Plik wp-includes/shortcodes.php
Opis
Filtruje domyślne atrybuty konkretnego shortcode’a — np. shortcode_atts_gallery.
Przykład użycia
add_filter( 'shortcode_atts_{$shortcode}', ... )php
add_filter( 'shortcode_atts_gallery', 'wpdocs_gallery_atts' );
function wpdocs_gallery_atts( $out ) {
$out['columns'] = 3;
return $out;
}
add_filter( 'shortcode_atts_gallery', 'wpdocs_gallery_atts' );
function wpdocs_gallery_atts( $out ) {
$out['columns'] = 3;
return $out;
}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.
Parametry
| Parametr | Typ | Opis |
|---|---|---|
$out | array | The output array of shortcode attributes. |
$pairs | array | The supported attributes and their defaults. |
$atts | array | The user defined shortcode attributes. |
$shortcode | string | The shortcode name. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'shortcode_atts_{$shortcode}', 'twoja_funkcja', 10, 4 );
function twoja_funkcja($param_1, $param_2, $param_3, $param_4) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'shortcode_atts_{$shortcode}', 'twoja_funkcja', 10, 4 );
function twoja_funkcja($param_1, $param_2, $param_3, $param_4) {
// Twój kod
}