style_loader_tag

FILTER wp-includes\class-wp-styles.php (ligne 245) github
Filters the HTML link tag of an enqueued style.
traduction française
Filtre la balise de lien HTML d'un style mis en file d'attente.

Paramètres

Entrée :
$tag, $handle, $href, $media
Sortie :
@param string $tag    The link tag for the enqueued style.
@param string $handle The style's registered handle.
@param string $href   The stylesheet's source URL.
@param string $media  The stylesheet's media attribute.

Utilisation

Modifier les attributs des balises style

Filtre pour ajouter des attributs aux styles.

frontend
add_filter('style_loader_tag', 'add_style_attributes', 10, 4);
function add_style_attributes($tag, $handle, $href, $media) {
    if ($handle === 'print-style') {
        $tag = str_replace('media="all"', 'media="print"', $tag);
    }
    return $tag;
}

Actualités

Chargement des actualités...