<?php  
/* 
Plugin Name: Custom Styles 
Description: Add custom styles in your posts and pages content using TinyMCE WYSIWYG editor. The plugin adds a Styles dropdown menu in the visual post editor. 
Based on TinyMCE Kit plug-in for WordPress 
 
http://plugins.svn.wordpress.org/tinymce-advanced/branches/tinymce-kit/tinymce-kit.php 

*/

/** 
 * Apply styles to the visual editor 
 */    
add_filter('mce_css', 'dan_editor_style');  
function dan_editor_style($url) {  
  
    if ( !empty($url) )  
        $url .= ',';  
  
    // Retrieves the plugin directory URL  
    // Change the path here if using different directories  
    $url .= '/_custom/editor-styles.css';  
  
    return $url;  
}  
  
/** 
 * Add "Styles" drop-down 
 */   
add_filter( 'mce_buttons_2', 'dan_editor_buttons' );  
  
function dan_editor_buttons( $buttons ) {  
    array_unshift( $buttons, 'styleselect' );  
    return $buttons;  
}  
  
/** 
 * Add styles/classes to the "Styles" drop-down 
 */   
add_filter( 'tiny_mce_before_init', 'dan_before_init' );  
  
function dan_before_init( $settings ) {  
  
    $style_formats = array(  
        array(  
            'title' => 'Quote',  
            'selector' => '*',  // * = wildcard for all selectors
            'classes' => 'quote'  
            )/*,  
        array(  
            'title' => 'Testimonial',  
            'selector' => 'p',  
            'classes' => 'testimonial',  
        ),  
        array(  
            'title' => 'Warning Box',  
            'block' => 'div',  
            'classes' => 'warning box',  
            'wrapper' => true  
        ),  
        array(  
            'title' => 'Red Uppercase Text',  
            'inline' => 'span',  
            'styles' => array(  
                'color' => '#ff0000',  
                'fontWeight' => 'bold',  
                'textTransform' => 'uppercase'  
            )  
        )  */
    );  
  
    $settings['style_formats'] = json_encode( $style_formats );  
  
    //print_r( $settings );
  
    return $settings;  
  
}  
  
/* Learn TinyMCE style format options at http://www.tinymce.com/wiki.php/Configuration:formats */  
  
/* 
 * Add custom stylesheet to the website front-end with hook 'wp_enqueue_scripts' 
 */  
add_action('wp_enqueue_scripts', 'dan_editor_enqueue');  
  
/* 
 * Enqueue stylesheet, if it exists. 
 */  
function dan_editor_enqueue() {  
  $StyleUrl = '/_custom/editor-styles.css'; // Customstyle.css is relative to the current file  
  wp_enqueue_style( 'myCustomStyles', $StyleUrl );  
} 

?>