Created
November 30, 2018 14:36
-
-
Save gregoirenoyelle/df872875a633f21b5376254ac597b551 to your computer and use it in GitHub Desktop.
Ajouter des tailles de police personnalisées dans l'éditeur moderne de WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A placer dans le fichier functions.php de votre thème sans le <?php du début | |
//* Fonction qui se déclenche 'after_setup_theme' | |
function gn_ajouter_fonction_font_theme_support() { | |
/*** | |
* Remplacer les tailles des polices du texte | |
* ici pour 'grand' cela donnera les classes suivantes: | |
* '.has-grand-font-size'... | |
* | |
* Attention, si votre thème le nécessite, ajouter les fonctions | |
* add_theme_support dans un hook sur after_setup_theme | |
* Voir le lien pour plus d'information: | |
* @link https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support | |
*/ | |
add_theme_support( 'editor-font-sizes', array( | |
array( | |
'name' => __( 'Petit', 'genesis-sample' ), | |
'shortName' => __( 'S', 'genesis-sample' ), | |
'size' => 12, | |
'slug' => 'petit' | |
), | |
// Ajouter ici votre autres taille en partant de l'exemple sans 'after_setup_theme' | |
) ); | |
// Suppression des tailles de police sur mesure | |
add_theme_support('disable-custom-font-sizes'); | |
} | |
add_action( 'after_setup_theme', 'gn_ajouter_fonction_font_theme_support' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Taille du texte **/ | |
/* Petit */ | |
.entry-content p.has-petit-font-size { | |
font-size: 12px; | |
font-size: 1.2rem; | |
} | |
/* Normal */ | |
.entry-content p.has-normal-font-size { | |
font-size: 16px; | |
font-size: 1.6rem; | |
} | |
/* Grand */ | |
.entry-content p.has-grand-font-size { | |
font-size: 22px; | |
font-size: 2.2rem; | |
} | |
/* Très grand */ | |
.entry-content p.has-tres-grand-font-size { | |
font-size: 35px; | |
font-size: 3.5rem; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A placer dans le fichier functions.php de votre thème sans le <?php du début | |
/*** | |
* Remplacer les tailles des polices du texte | |
* ici pour 'grand' cela donnera les classes suivantes: | |
* '.has-grand-font-size'... | |
* | |
* Attention, si votre thème le nécessite, ajouter les fonctions | |
* add_theme_support dans un hook sur after_setup_theme | |
* Voir le lien pour plus d'information: | |
* @link https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support | |
*/ | |
add_theme_support( 'editor-font-sizes', array( | |
array( | |
'name' => __( 'Petit', 'genesis-sample' ), | |
'shortName' => __( 'S', 'genesis-sample' ), | |
'size' => 12, | |
'slug' => 'petit' | |
), | |
array( | |
'name' => __( 'Normal', 'genesis-sample' ), | |
'shortName' => __( 'M', 'genesis-sample' ), | |
'size' => 16, | |
'slug' => 'normal' | |
), | |
array( | |
'name' => __( 'Grand', 'genesis-sample' ), | |
'shortName' => __( 'L', 'genesis-sample' ), | |
'size' => 22, | |
'slug' => 'grand' | |
), | |
array( | |
'name' => __( 'Très grand', 'genesis-sample' ), | |
'shortName' => __( 'XL', 'genesis-sample' ), | |
'size' => 35, | |
'slug' => 'tres-grand' | |
) | |
) ); | |
// Suppression des tailles de police sur mesure | |
add_theme_support('disable-custom-font-sizes'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment