Last active
          August 29, 2015 14:18 
        
      - 
      
- 
        Save thierrypigot/d1c17e170b22f05337dc to your computer and use it in GitHub Desktop. 
    Custom TinyMCE style in list
  
        
  
    
      This file contains hidden or 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 | |
| // Ajout du menu de selection STYLES | |
| // http://codex.wordpress.org/TinyMCE_Custom_Styles | |
| function tp_mce_buttons_2( $buttons ) { | |
| array_splice( $buttons, 1, 0, 'styleselect' ); | |
| return $buttons; | |
| } | |
| // Register our callback to the appropriate filter | |
| add_filter('mce_buttons_2', 'tp_mce_buttons_2'); | |
| function tp_customformatTinyMCE($settings) | |
| { | |
| // Add block format elements you want to show in dropdown | |
| $settings['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5; Heading 6=h6'; | |
| $new_styles = array ( | |
| array( | |
| 'title' => __("Boutons (balises A)","tonnamespacepourtraduction"), | |
| 'items' => array( | |
| // Style "bouton" | |
| array( | |
| 'title' => __('Bouton bleu'), | |
| 'selector' => 'a', | |
| 'classes' => 'bouton_bleu' | |
| ), | |
| array( | |
| 'title' => __('Bouton bleu (gros)'), | |
| 'selector' => 'a', | |
| 'classes' => 'big_bouton_bleu' | |
| ), | |
| ), | |
| ), | |
| array( | |
| 'title' => __("Divers","tonnamespacepourtraduction"), | |
| 'items' => array( | |
| array( | |
| 'title' => __('Souligné centré'), | |
| 'selector' => 'p,h1,h2,h3,h4,h5,h6', | |
| 'classes' => 'souligne_center' | |
| ), | |
| array( | |
| 'title' => __('Image sans bordure'), | |
| 'selector' => 'img', | |
| 'classes' => 'no_border' | |
| ), | |
| ), | |
| ), | |
| ); | |
| $settings['style_formats_merge'] = true; | |
| // on remplace les styles existants par les nôtres | |
| $settings['style_formats'] = json_encode($new_styles); | |
| return $settings; | |
| } | |
| // Modify Tiny_MCE init | |
| add_filter('tiny_mce_before_init', 'tp_customformatTinyMCE' ,1); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment