SlideShare una empresa de Scribd logo
1 de 43
Editing the Visual Editor




                     Editing the Visual Editor
About Me: Jake Goldman
• President (& chief engineer!) @ 10up LLC, a
  WordPress development & strategy agency
• Author of over a dozen WordPress plug-ins
• Dozens of clients, from university like Bates
  College to WP.com VIP clients like TechCrunch
• Writer/expert reviewer @ Smashing Magazine
• @jakemgold

                                   Editing the Visual Editor
About You: Why You’re Here




                     Editing the Visual Editor
Hypothesis #1
 The styling of content in your editor should at
least somewhat match the styling of content on
                   your page.


                      !=

                                    Editing the Visual Editor
Hypothesis #2

Different kinds of content (post types) often
            have different styling.


                    !=


                                   Editing the Visual Editor
Hypothesis #3
WordPress does a pretty good job of knowing
how to clean up our authors’ messes, but we
       know our authors even better.




                                 Editing the Visual Editor
Hypothesis #4
Sometimes we need more ways to style content
          than we currently have.


                             How do I apply a
                          “specifications” style??




                                    Editing the Visual Editor
Hypothesis #5
Sometimes we need to put editor-like content
         in more than one place.




                                 Editing the Visual Editor
Hypothesis #6
“Shortcodes” alone are not intuitive solutions
for special features, and are not discoverable.
Does this guy
expect me to
 remember
   this?




                                    Editing the Visual Editor
Solution #1: Style Your Editor




                        Editing the Visual Editor
Solution #1: Style Your Editor

                                                          ( functions.php )

add_action( ‘after_theme_setup’, ‘eve_theme_setup’ );

function eve_theme_setup() {
     add_editor_style();
}




                                                  Editing the Visual Editor
Solution #1: Style Your Editor

                                                          ( functions.php )

add_action( ‘after_theme_setup’, ‘eve_theme_setup’ );

function eve_theme_setup() {
     add_editor_style();
}


    Hook is non-essential,
      but good form.


                                                  Editing the Visual Editor
Solution #1: Style Your Editor



html .mceContentBody { max-width:550px; }
body.mceContentBody {
    font-family: 'lucida grande',sans-serif; color: #555;
}
p,ul,ol,h4,h5,h6 {
    line-height:20px; margin: 0 0 20px 0; font-size:13px;
}
...



                                                   Editing the Visual Editor
Solution #1: Style Your Editor

  Tip: matching the editor body width to the
  content width on the front end makes a big
        difference in designing content!
html .mceContentBody { max-width:550px; }
body.mceContentBody {
    font-family: 'lucida grande',sans-serif; color: #555;
}
p,ul,ol,h4,h5,h6 {
    line-height:20px; margin: 0 0 20px 0; font-size:13px;
}
...



                                                   Editing the Visual Editor
Solution #2: Style Based on Post Type


                                                           ( functions.php )

add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' );

function eve_setup_other_stylesheets( $post_type ) {
    if ( $post_type == 'page' ) {
        remove_editor_styles();
        add_editor_style( 'editor-style-page.css' );
    }

     remove_action('do_meta_boxes','eve_setup_other_stylesheets‘);
}




                                                   Editing the Visual Editor
Solution #2: Style Based on Post Type


                                                           ( functions.php )

add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' );

function eve_setup_other_stylesheets( $post_type ) {
    if ( $post_type == 'page' ) {
        remove_editor_styles();
        add_editor_style( 'editor-style-page.css' );
    }
        Note #1: We don’t have
     remove_action('do_meta_boxes','eve_setup_other_stylesheets‘);
}      to use this hook. But it’s
           pretty convenient.

                                                   Editing the Visual Editor
Solution #2: Style Based on Post Type


                                                           ( functions.php )

add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' );

function eve_setup_other_stylesheets( $post_type ) {
    if ( $post_type == 'page' ) {
        remove_editor_styles();
        add_editor_style( 'editor-style-page.css' );
    }

     remove_action('do_meta_boxes','eve_setup_other_stylesheets‘);
}
Note #2: We don’t have to remove styles.
   We can add multiple editor styles.
                                                   Editing the Visual Editor
Solution #2: Style Based on Post Type


                                                           ( functions.php )

add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' );

function eve_setup_other_stylesheets( $post_type ) {
    if ( $post_type == 'page' ) {
        remove_editor_styles();
        add_editor_style( 'editor-style-page.css' );
    } Note #3: This concept
         applies to all our
     remove_action('do_meta_boxes','eve_setup_other_stylesheets‘);
}     TinyMCE / editor tips!


                                                   Editing the Visual Editor
Solution #3: Modify Allowed Post Tags



                 Save




                            Editing the Visual Editor
Solution #3: Modify Allowed Post Tags

                                                          ( functions.php )

add_action( 'init', 'eve_modify_allowed_post_tags' );

function eve_modify_allowed_post_tags() {
    global $allowedposttags;
    unset( $allowedposttags['blockquote'] );
}




                                                  Editing the Visual Editor
Solution #3: Modify Allowed Post Tags
                         Don’t forget!
                                                          ( functions.php )

         Users with   unfiltered_html         capabilities
add_action( 'init', 'eve_modify_allowed_post_tags' );
        (editors & admins) are not filtered by this. If
function eve_modify_allowed_post_tags() {
    global $allowedposttags; rid all users of this element,
      you really want to
    unset( $allowedposttags['blockquote'] );
}      you’ll need to remove that capability from the
               role or filter content elsewhere.


                                                  Editing the Visual Editor
Solution #4: Remove editor buttons




                          Editing the Visual Editor
Solution #4: Remove editor buttons

                                                          ( functions.php )

add_filter( 'mce_buttons', 'eve_mce_buttons' );

function eve_mce_buttons( $buttons ) {
    if ( $button_key = array_search( 'blockquote', $buttons ) )
        unset( $buttons[$button_key] );

    return $buttons;
}




                                                  Editing the Visual Editor
Solution #4b: Manage full screen
            buttons




      Introduced in WordPress 3.2


                                    Editing the Visual Editor
Solution #4b: Manage full screen
                 buttons
                                                          ( functions.php )

add_filter( 'wp_fullscreen_buttons', 'eve_fullscreen_buttons' );

function eve_fullscreen_buttons( $buttons ) {
    if ( isset( $buttons['blockquote'] ) )
        unset( $buttons['blockquote'] );

    return $buttons;
}




                                                  Editing the Visual Editor
Solution #5: Add a style drop down




                         Editing the Visual Editor
Solution #5: Add a style drop down

   Step 1: Add style dropdown control                       ( functions.php )

add_filter( 'mce_buttons_2', 'eve_mce_buttons_style_drop' );

function eve_mce_buttons_style_drop( $buttons ) {
    array_unshift( $buttons, 'styleselect' );
    return $buttons;
}




                                                    Editing the Visual Editor
Solution #5: Add a style drop down

Step 2: Specify style names and classes                   ( functions.php )

add_filter( 'tiny_mce_before_init', 'eve_add_mce_styles‘ );

function eve_add_mce_styles( $init ) {
    $init['theme_advanced_styles'] = 'Specifications=specs,Big
        Warning=warning,Special Feature=special';
    return $init;
}




                                                  Editing the Visual Editor
Solution #6: Add another editor



  Newly easy in
  WordPress 3.3!




                        Editing the Visual Editor
( functions.php )

add_action( 'do_meta_boxes', 'eve_setup_editor_meta_box' );

function eve_setup_editor_meta_box() {
   add_meta_box( 'eve_second_editor', 'Sidebar', 'eve_editor_meta_box',
      'page' );
}

function eve_editor_meta_box( $post ) {
   $content = get_post_meta( $post->ID, '_eve_second_html', true );
   wp_nonce_field( 'eve_nonce_action', '_eve_nonce_name' );
    wp_editor( $content, 'eve_second_html', array(
      'media_buttons' => false,
    ));
}

add_action( 'save_post', 'eve_save_second_editor' );

function eve_save_second_editor( $post_id ) {
   [ various checks for capability / nonce / etc ]
   $meta = empty( $_POST['eve_second_html'] ) ?
      delete_post_meta( $post_id, '_eve_second_html' ) :
      update_post_meta( $post_id, '_eve_second_html', wp_kses_post(
         $_POST['eve_second_html'] ) );
}


                                                          Editing the Visual Editor
Power of wp_editor()
'wpautop' => true, // use wpautop?
'media_buttons' => true, // show insert/upload button(s)
'textarea_name' => $editor_id, // set the textarea name to
  something different, square brackets [] can be used here
'textarea_rows' => get_option('default_post_edit_rows', 10), //
  rows="..."
'tabindex' => '',
'editor_css' => '', // intended for extra styles for both visual
  and HTML editors buttons, needs to include the <style> tags, can
  use "scoped".
'editor_class' => '', // add extra class(es) to the editor textarea
'teeny' => false, // output the minimal editor config used in Press
  This
'dfw' => false, // replace the default fullscreen with DFW (needs
  specific DOM elements and css)
'tinymce' => true, // load TinyMCE, can be used to pass settings
  directly to TinyMCE using an array()
'quicktags' => true // load Quicktags, can be used to pass settings
  directly to Quicktags using an array()

                                                     Editing the Visual Editor
                                           ( wp-includes/class-wp-editor.php )
Power of wp_editor()
'wpautop' => true, // use wpautop?
'media_buttons' => true, // show insert/upload button(s)
'textarea_name' => $editor_id, // set the textarea name to
  something different, square brackets [] can be used here
'textarea_rows' => get_option('default_post_edit_rows', 10), //
  rows="..."
'tabindex' => '',
'editor_css' => '', // intended for extra styles for both visual
  Whoa
  and HTML editors buttons, needs to include the <style> tags, can
  use "scoped".
'editor_class' => '', // add extra class(es) to the editor textarea
'teeny' => false, // output the minimal editor config used in Press
  This
'dfw' => false, // replace the default fullscreen with DFW (needs
  specific DOM elements and css)
'tinymce' => true, // load TinyMCE, can be used to pass settings
  directly to TinyMCE using an array()
'quicktags' => true // load Quicktags, can be used to pass settings
  directly to Quicktags using an array()

                                                     Editing the Visual Editor
                                           ( wp-includes/class-wp-editor.php )
Solution #7: A button for your
          shortcode



                   My button!




                          Editing the Visual Editor
Solution #7: A button for your
           shortcode

Step 1: Make your TinyMCE plug-in




                                    Editing the Visual Editor
(function() {
    tinymce.create('tinymce.plugins.eve_mail', {
        init : function(ed, url) {
            ed.addButton('eve_mail', {
                title : 'Add a protected email address',
                image : url+'/mail_icon.png',
                onclick : function() {
                    var selected_mail = ed.selection.getContent();
                    if ( selected_mail == '' ) selected_mail = 'enter email';
                    ed.execCommand( 'mceInsertContent', false,
                       '[mailto]'+selected_mail+'[/mailto]' );
                 }
            });
        },
        createControl : function(n, cm) {
            return null;
        },
        getInfo : function() {
            return {
                longname : "Safe Email Address Link",
                author : 'Jake Goldman (10up)',
                authorurl : 'http://www.get10up.com/',
                infourl : 'http://www.get10up.com/',
                version : "1.0"
            };
        }
    });
    tinymce.PluginManager.add('eve_mail', tinymce.plugins.eve_mail);
})();                                                      Editing the Visual Editor
(function() {
    tinymce.create('tinymce.plugins.eve_mail', {
        init : function(ed, url) {
            ed.addButton('eve_mail', {
                title : 'Add a protected email address',
                image : url+'/mail_icon.png',
                onclick : function() {
                    var selected_mail = ed.selection.getContent();
                    if ( selected_mail == '' ) selected_mail = 'enter email';
                    ed.execCommand( 'mceInsertContent', false,
                       '[mailto]'+selected_mail+'[/mailto]' );
          Learn more about making TinyMCE plug-ins /
                 }
            });
        },                 buttons:
        createControl : function(n, cm) {
            return null;
        },
     http://tinymce.moxiecode.com/tryit/listbox_splitbutton.php
        getInfo : function() {
            return {
                longname : "Safe Email Address Link",
      http://www.ilovecolors.com.ar/tinymce-plugin-wordpress/
                author : 'Jake Goldman (10up)',
                authorurl : 'http://www.get10up.com/',
                infourl : 'http://www.get10up.com/',
                version : "1.0"
            };
        }
    });
    tinymce.PluginManager.add('eve_mail', tinymce.plugins.eve_mail);
})();                                                      Editing the Visual Editor
Solution #7: A button for your
                 shortcode

Step 2: Register your plug-in with TinyMCE                ( functions.php )

add_filter('mce_external_plugins','eve_add_mail_shortcode_plugin');

function eve_add_mail_shortcode_plugin( $plugin_array ) {
    $plugin_array['eve_mail'] = get_stylesheet_directory_uri() .
        '/editor_buttons/editor_plugin.js';
    return $plugin_array;
}




                                                  Editing the Visual Editor
Solution #7: A button for your
                 shortcode

   Step 3: Add your button to the editor                  ( functions.php )

add_filter( 'mce_buttons', 'even_add_mail_shortcode_button');

function even_add_mail_shortcode_button( $buttons ) {
    array_push( $buttons, "|", "eve_mail" );
    return $buttons;
}




                                                  Editing the Visual Editor
Solution #7: A button for your
          shortcode




                        Editing the Visual Editor
Power Tip: Style the fullscreen editor




                            Editing the Visual Editor
Power Tip: Style the fullscreen editor
                                                          ( functions.php )

add_action( 'admin_print_styles-post-new.php',
    'eve_fullscreen_styles' );
add_action('admin_print_styles-post.php','eve_fullscreen_styles');

function eve_fullscreen_styles() { ?>
<style type="text/css">
.fullscreen-active #wp-fullscreen-title { font-family: Georgia;
    font-size: 40px; }
</style>
<?php }




                                                  Editing the Visual Editor
Bonus Tip: Default Content

   Remember: can be post type specific!                   ( functions.php )

add_filter( 'default_content', ‘eve_editor_content' );

function my_editor_content( $content ) {
    $content = “<h2>Subtitle</h2>nnStart writing!";
    return $content;
}




                                                  Editing the Visual Editor
Editing the Visual Editor
          by Jake Goldman
            @jakemgold

  slides & code will be available at
            get10up.com




                                  Editing the Visual Editor

Más contenido relacionado

La actualidad más candente

Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
Best Practices for Magento Debugging
Best Practices for Magento Debugging Best Practices for Magento Debugging
Best Practices for Magento Debugging varien
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHendy Irawan
 
How to Develop a Basic Magento Extension Tutorial
How to Develop a Basic Magento Extension TutorialHow to Develop a Basic Magento Extension Tutorial
How to Develop a Basic Magento Extension TutorialHendy Irawan
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extensionHendy Irawan
 
Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mike Schinkel
 
Developing For The WordPress Customizer
Developing For The WordPress CustomizerDeveloping For The WordPress Customizer
Developing For The WordPress CustomizerAnthony Hortin
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentNuvole
 
Why NextCMS: Layout Editor
Why NextCMS: Layout EditorWhy NextCMS: Layout Editor
Why NextCMS: Layout EditorPhuoc Nguyen Huu
 
Angular js filters and directives
Angular js filters and directivesAngular js filters and directives
Angular js filters and directivesDarryl Sherman
 
TDC 2015 - Metaprogramação na prática
TDC 2015 - Metaprogramação na práticaTDC 2015 - Metaprogramação na prática
TDC 2015 - Metaprogramação na práticaGuilherme Carreiro
 
Developing for the WordPress Customizer
Developing for the WordPress CustomizerDeveloping for the WordPress Customizer
Developing for the WordPress CustomizerAnthony Hortin
 
Working with WooCommerce Custom Fields
Working with WooCommerce Custom FieldsWorking with WooCommerce Custom Fields
Working with WooCommerce Custom FieldsAnthony Hortin
 
sfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin BundlesfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin Bundleth0masr
 

La actualidad más candente (19)

Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Best Practices for Magento Debugging
Best Practices for Magento Debugging Best Practices for Magento Debugging
Best Practices for Magento Debugging
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 
How to Develop a Basic Magento Extension Tutorial
How to Develop a Basic Magento Extension TutorialHow to Develop a Basic Magento Extension Tutorial
How to Develop a Basic Magento Extension Tutorial
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extension
 
Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012
 
Drupal Form Api
Drupal Form ApiDrupal Form Api
Drupal Form Api
 
Quality code by design
Quality code by designQuality code by design
Quality code by design
 
Developing For The WordPress Customizer
Developing For The WordPress CustomizerDeveloping For The WordPress Customizer
Developing For The WordPress Customizer
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
 
Why NextCMS: Layout Editor
Why NextCMS: Layout EditorWhy NextCMS: Layout Editor
Why NextCMS: Layout Editor
 
Angular js filters and directives
Angular js filters and directivesAngular js filters and directives
Angular js filters and directives
 
Presentation
PresentationPresentation
Presentation
 
TDC 2015 - Metaprogramação na prática
TDC 2015 - Metaprogramação na práticaTDC 2015 - Metaprogramação na prática
TDC 2015 - Metaprogramação na prática
 
Developing for the WordPress Customizer
Developing for the WordPress CustomizerDeveloping for the WordPress Customizer
Developing for the WordPress Customizer
 
Working with WooCommerce Custom Fields
Working with WooCommerce Custom FieldsWorking with WooCommerce Custom Fields
Working with WooCommerce Custom Fields
 
sfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin BundlesfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin Bundle
 
Codigo taller-plugins
Codigo taller-pluginsCodigo taller-plugins
Codigo taller-plugins
 

Similar a Editing the Visual Editor (WordPress)

Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experienceBeth Soderberg
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1Yoav Farhi
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeRakesh Kushwaha
 
Plug in development
Plug in developmentPlug in development
Plug in developmentLucky Ali
 
Top Wordpress dashboard hacks
Top Wordpress dashboard hacks Top Wordpress dashboard hacks
Top Wordpress dashboard hacks Pankaj Subedi
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
 
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013Jonny Allbut
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2giwoolee
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Damien Carbery
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
Custom Post Types in WP3
Custom Post Types in WP3Custom Post Types in WP3
Custom Post Types in WP3gregghenry
 
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016Peter Martin
 
Image manipulation in WordPress 3.5
Image manipulation in WordPress 3.5Image manipulation in WordPress 3.5
Image manipulation in WordPress 3.5Marko Heijnen
 
WordPress Theme Workshop: Misc
WordPress Theme Workshop: MiscWordPress Theme Workshop: Misc
WordPress Theme Workshop: MiscDavid Bisset
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Ivan Chepurnyi
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Vishwash Gaur
 
WordPress Theme Workshop: Theme Setup
WordPress Theme Workshop: Theme SetupWordPress Theme Workshop: Theme Setup
WordPress Theme Workshop: Theme SetupDavid Bisset
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
WordPress Theme Workshop: Sidebars
WordPress Theme Workshop: SidebarsWordPress Theme Workshop: Sidebars
WordPress Theme Workshop: SidebarsDavid Bisset
 

Similar a Editing the Visual Editor (WordPress) (20)

Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experience
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
Plug in development
Plug in developmentPlug in development
Plug in development
 
Top Wordpress dashboard hacks
Top Wordpress dashboard hacks Top Wordpress dashboard hacks
Top Wordpress dashboard hacks
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Custom Post Types in WP3
Custom Post Types in WP3Custom Post Types in WP3
Custom Post Types in WP3
 
WordCamp Praga 2015
WordCamp Praga 2015WordCamp Praga 2015
WordCamp Praga 2015
 
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
 
Image manipulation in WordPress 3.5
Image manipulation in WordPress 3.5Image manipulation in WordPress 3.5
Image manipulation in WordPress 3.5
 
WordPress Theme Workshop: Misc
WordPress Theme Workshop: MiscWordPress Theme Workshop: Misc
WordPress Theme Workshop: Misc
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
 
WordPress Theme Workshop: Theme Setup
WordPress Theme Workshop: Theme SetupWordPress Theme Workshop: Theme Setup
WordPress Theme Workshop: Theme Setup
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
WordPress Theme Workshop: Sidebars
WordPress Theme Workshop: SidebarsWordPress Theme Workshop: Sidebars
WordPress Theme Workshop: Sidebars
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Editing the Visual Editor (WordPress)

  • 1. Editing the Visual Editor Editing the Visual Editor
  • 2. About Me: Jake Goldman • President (& chief engineer!) @ 10up LLC, a WordPress development & strategy agency • Author of over a dozen WordPress plug-ins • Dozens of clients, from university like Bates College to WP.com VIP clients like TechCrunch • Writer/expert reviewer @ Smashing Magazine • @jakemgold Editing the Visual Editor
  • 3. About You: Why You’re Here Editing the Visual Editor
  • 4. Hypothesis #1 The styling of content in your editor should at least somewhat match the styling of content on your page. != Editing the Visual Editor
  • 5. Hypothesis #2 Different kinds of content (post types) often have different styling. != Editing the Visual Editor
  • 6. Hypothesis #3 WordPress does a pretty good job of knowing how to clean up our authors’ messes, but we know our authors even better. Editing the Visual Editor
  • 7. Hypothesis #4 Sometimes we need more ways to style content than we currently have. How do I apply a “specifications” style?? Editing the Visual Editor
  • 8. Hypothesis #5 Sometimes we need to put editor-like content in more than one place. Editing the Visual Editor
  • 9. Hypothesis #6 “Shortcodes” alone are not intuitive solutions for special features, and are not discoverable. Does this guy expect me to remember this? Editing the Visual Editor
  • 10. Solution #1: Style Your Editor Editing the Visual Editor
  • 11. Solution #1: Style Your Editor ( functions.php ) add_action( ‘after_theme_setup’, ‘eve_theme_setup’ ); function eve_theme_setup() { add_editor_style(); } Editing the Visual Editor
  • 12. Solution #1: Style Your Editor ( functions.php ) add_action( ‘after_theme_setup’, ‘eve_theme_setup’ ); function eve_theme_setup() { add_editor_style(); } Hook is non-essential, but good form. Editing the Visual Editor
  • 13. Solution #1: Style Your Editor html .mceContentBody { max-width:550px; } body.mceContentBody { font-family: 'lucida grande',sans-serif; color: #555; } p,ul,ol,h4,h5,h6 { line-height:20px; margin: 0 0 20px 0; font-size:13px; } ... Editing the Visual Editor
  • 14. Solution #1: Style Your Editor Tip: matching the editor body width to the content width on the front end makes a big difference in designing content! html .mceContentBody { max-width:550px; } body.mceContentBody { font-family: 'lucida grande',sans-serif; color: #555; } p,ul,ol,h4,h5,h6 { line-height:20px; margin: 0 0 20px 0; font-size:13px; } ... Editing the Visual Editor
  • 15. Solution #2: Style Based on Post Type ( functions.php ) add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' ); function eve_setup_other_stylesheets( $post_type ) { if ( $post_type == 'page' ) { remove_editor_styles(); add_editor_style( 'editor-style-page.css' ); } remove_action('do_meta_boxes','eve_setup_other_stylesheets‘); } Editing the Visual Editor
  • 16. Solution #2: Style Based on Post Type ( functions.php ) add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' ); function eve_setup_other_stylesheets( $post_type ) { if ( $post_type == 'page' ) { remove_editor_styles(); add_editor_style( 'editor-style-page.css' ); } Note #1: We don’t have remove_action('do_meta_boxes','eve_setup_other_stylesheets‘); } to use this hook. But it’s pretty convenient. Editing the Visual Editor
  • 17. Solution #2: Style Based on Post Type ( functions.php ) add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' ); function eve_setup_other_stylesheets( $post_type ) { if ( $post_type == 'page' ) { remove_editor_styles(); add_editor_style( 'editor-style-page.css' ); } remove_action('do_meta_boxes','eve_setup_other_stylesheets‘); } Note #2: We don’t have to remove styles. We can add multiple editor styles. Editing the Visual Editor
  • 18. Solution #2: Style Based on Post Type ( functions.php ) add_action( 'do_meta_boxes', 'eve_setup_other_stylesheets' ); function eve_setup_other_stylesheets( $post_type ) { if ( $post_type == 'page' ) { remove_editor_styles(); add_editor_style( 'editor-style-page.css' ); } Note #3: This concept applies to all our remove_action('do_meta_boxes','eve_setup_other_stylesheets‘); } TinyMCE / editor tips! Editing the Visual Editor
  • 19. Solution #3: Modify Allowed Post Tags Save Editing the Visual Editor
  • 20. Solution #3: Modify Allowed Post Tags ( functions.php ) add_action( 'init', 'eve_modify_allowed_post_tags' ); function eve_modify_allowed_post_tags() { global $allowedposttags; unset( $allowedposttags['blockquote'] ); } Editing the Visual Editor
  • 21. Solution #3: Modify Allowed Post Tags Don’t forget! ( functions.php ) Users with unfiltered_html capabilities add_action( 'init', 'eve_modify_allowed_post_tags' ); (editors & admins) are not filtered by this. If function eve_modify_allowed_post_tags() { global $allowedposttags; rid all users of this element, you really want to unset( $allowedposttags['blockquote'] ); } you’ll need to remove that capability from the role or filter content elsewhere. Editing the Visual Editor
  • 22. Solution #4: Remove editor buttons Editing the Visual Editor
  • 23. Solution #4: Remove editor buttons ( functions.php ) add_filter( 'mce_buttons', 'eve_mce_buttons' ); function eve_mce_buttons( $buttons ) { if ( $button_key = array_search( 'blockquote', $buttons ) ) unset( $buttons[$button_key] ); return $buttons; } Editing the Visual Editor
  • 24. Solution #4b: Manage full screen buttons Introduced in WordPress 3.2 Editing the Visual Editor
  • 25. Solution #4b: Manage full screen buttons ( functions.php ) add_filter( 'wp_fullscreen_buttons', 'eve_fullscreen_buttons' ); function eve_fullscreen_buttons( $buttons ) { if ( isset( $buttons['blockquote'] ) ) unset( $buttons['blockquote'] ); return $buttons; } Editing the Visual Editor
  • 26. Solution #5: Add a style drop down Editing the Visual Editor
  • 27. Solution #5: Add a style drop down Step 1: Add style dropdown control ( functions.php ) add_filter( 'mce_buttons_2', 'eve_mce_buttons_style_drop' ); function eve_mce_buttons_style_drop( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } Editing the Visual Editor
  • 28. Solution #5: Add a style drop down Step 2: Specify style names and classes ( functions.php ) add_filter( 'tiny_mce_before_init', 'eve_add_mce_styles‘ ); function eve_add_mce_styles( $init ) { $init['theme_advanced_styles'] = 'Specifications=specs,Big Warning=warning,Special Feature=special'; return $init; } Editing the Visual Editor
  • 29. Solution #6: Add another editor Newly easy in WordPress 3.3! Editing the Visual Editor
  • 30. ( functions.php ) add_action( 'do_meta_boxes', 'eve_setup_editor_meta_box' ); function eve_setup_editor_meta_box() { add_meta_box( 'eve_second_editor', 'Sidebar', 'eve_editor_meta_box', 'page' ); } function eve_editor_meta_box( $post ) { $content = get_post_meta( $post->ID, '_eve_second_html', true ); wp_nonce_field( 'eve_nonce_action', '_eve_nonce_name' ); wp_editor( $content, 'eve_second_html', array( 'media_buttons' => false, )); } add_action( 'save_post', 'eve_save_second_editor' ); function eve_save_second_editor( $post_id ) { [ various checks for capability / nonce / etc ] $meta = empty( $_POST['eve_second_html'] ) ? delete_post_meta( $post_id, '_eve_second_html' ) : update_post_meta( $post_id, '_eve_second_html', wp_kses_post( $_POST['eve_second_html'] ) ); } Editing the Visual Editor
  • 31. Power of wp_editor() 'wpautop' => true, // use wpautop? 'media_buttons' => true, // show insert/upload button(s) 'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here 'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..." 'tabindex' => '', 'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped". 'editor_class' => '', // add extra class(es) to the editor textarea 'teeny' => false, // output the minimal editor config used in Press This 'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css) 'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() 'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array() Editing the Visual Editor ( wp-includes/class-wp-editor.php )
  • 32. Power of wp_editor() 'wpautop' => true, // use wpautop? 'media_buttons' => true, // show insert/upload button(s) 'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here 'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..." 'tabindex' => '', 'editor_css' => '', // intended for extra styles for both visual Whoa and HTML editors buttons, needs to include the <style> tags, can use "scoped". 'editor_class' => '', // add extra class(es) to the editor textarea 'teeny' => false, // output the minimal editor config used in Press This 'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css) 'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() 'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array() Editing the Visual Editor ( wp-includes/class-wp-editor.php )
  • 33. Solution #7: A button for your shortcode My button! Editing the Visual Editor
  • 34. Solution #7: A button for your shortcode Step 1: Make your TinyMCE plug-in Editing the Visual Editor
  • 35. (function() { tinymce.create('tinymce.plugins.eve_mail', { init : function(ed, url) { ed.addButton('eve_mail', { title : 'Add a protected email address', image : url+'/mail_icon.png', onclick : function() { var selected_mail = ed.selection.getContent(); if ( selected_mail == '' ) selected_mail = 'enter email'; ed.execCommand( 'mceInsertContent', false, '[mailto]'+selected_mail+'[/mailto]' ); } }); }, createControl : function(n, cm) { return null; }, getInfo : function() { return { longname : "Safe Email Address Link", author : 'Jake Goldman (10up)', authorurl : 'http://www.get10up.com/', infourl : 'http://www.get10up.com/', version : "1.0" }; } }); tinymce.PluginManager.add('eve_mail', tinymce.plugins.eve_mail); })(); Editing the Visual Editor
  • 36. (function() { tinymce.create('tinymce.plugins.eve_mail', { init : function(ed, url) { ed.addButton('eve_mail', { title : 'Add a protected email address', image : url+'/mail_icon.png', onclick : function() { var selected_mail = ed.selection.getContent(); if ( selected_mail == '' ) selected_mail = 'enter email'; ed.execCommand( 'mceInsertContent', false, '[mailto]'+selected_mail+'[/mailto]' ); Learn more about making TinyMCE plug-ins / } }); }, buttons: createControl : function(n, cm) { return null; }, http://tinymce.moxiecode.com/tryit/listbox_splitbutton.php getInfo : function() { return { longname : "Safe Email Address Link", http://www.ilovecolors.com.ar/tinymce-plugin-wordpress/ author : 'Jake Goldman (10up)', authorurl : 'http://www.get10up.com/', infourl : 'http://www.get10up.com/', version : "1.0" }; } }); tinymce.PluginManager.add('eve_mail', tinymce.plugins.eve_mail); })(); Editing the Visual Editor
  • 37. Solution #7: A button for your shortcode Step 2: Register your plug-in with TinyMCE ( functions.php ) add_filter('mce_external_plugins','eve_add_mail_shortcode_plugin'); function eve_add_mail_shortcode_plugin( $plugin_array ) { $plugin_array['eve_mail'] = get_stylesheet_directory_uri() . '/editor_buttons/editor_plugin.js'; return $plugin_array; } Editing the Visual Editor
  • 38. Solution #7: A button for your shortcode Step 3: Add your button to the editor ( functions.php ) add_filter( 'mce_buttons', 'even_add_mail_shortcode_button'); function even_add_mail_shortcode_button( $buttons ) { array_push( $buttons, "|", "eve_mail" ); return $buttons; } Editing the Visual Editor
  • 39. Solution #7: A button for your shortcode Editing the Visual Editor
  • 40. Power Tip: Style the fullscreen editor Editing the Visual Editor
  • 41. Power Tip: Style the fullscreen editor ( functions.php ) add_action( 'admin_print_styles-post-new.php', 'eve_fullscreen_styles' ); add_action('admin_print_styles-post.php','eve_fullscreen_styles'); function eve_fullscreen_styles() { ?> <style type="text/css"> .fullscreen-active #wp-fullscreen-title { font-family: Georgia; font-size: 40px; } </style> <?php } Editing the Visual Editor
  • 42. Bonus Tip: Default Content Remember: can be post type specific! ( functions.php ) add_filter( 'default_content', ‘eve_editor_content' ); function my_editor_content( $content ) { $content = “<h2>Subtitle</h2>nnStart writing!"; return $content; } Editing the Visual Editor
  • 43. Editing the Visual Editor by Jake Goldman @jakemgold slides & code will be available at get10up.com Editing the Visual Editor