How to make WordPress and TinyMCE accept tags wrapping block-level elements as allowed in HTML5?

[*] A few years down the track, but hopefully someone else will find this solution useful… Although my issues trying to get this sort of thing to work in WordPress were slightly different, hopefully this solution will work for you too. Firstly, the issue with tags not being allowed to contain multiple block level elements … Read more

TinyMCE – Show Advanced Options (2nd Row) By Default

If you inspect the value of $in you should get something like: Array ( [mode] => exact [width] => 100% [theme] => advanced [skin] => wp_theme [language] => en [theme_advanced_toolbar_location] => top [theme_advanced_toolbar_align] => left [theme_advanced_statusbar_location] => bottom [theme_advanced_resizing] => 1 [theme_advanced_resize_horizontal] => [dialog_type] => modal [formats] => { alignleft : [ {selector : ‘p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li’, … Read more

Using post ID in custom tinyMCE button

You would need to place a globally namespaced javascript variable in your php code where you enqueue the script to be loaded for the editor pages. So, this code will enqueue a script function to be added to the “edit post/page” screens: add_action(‘admin_head’,’my_add_styles_admin’); function my_add_styles_admin() { global $current_screen; $type = $current_screen->post_type; if (is_admin() && $type … Read more

Adding TinyMCE custom buttons when using teeny_mce_before_init

I believe that you have already registered your shortcode. Now what we need to do is to initiate the Button. Once the shortcode is registered [ph_min] let’s check if user can use rich editing: function add_highlight_button() { if ( ! current_user_can(‘edit_posts’) && ! current_user_can(‘edit_pages’) ) return; if ( get_user_option(‘rich_editing’) == ‘true’) { add_filter(‘mce_external_plugins’, ‘add_tcustom_tinymce_plugin’); add_filter(‘mce_buttons’, … Read more

How to add a custom button to the tinyMCE toolbar?

Your problem i believe are the lines that follow the enqueues and print scripts, you’re mixing Javascript with PHP.. Javascript goes inside the HTML section of a PHP file or inside an echo statement. This page of the codex gives an example for adding a button to TinyMCE inside WordPress. However that codex entry might … Read more

Registering custom TinyMCE buttons, for admin area, to work with custom instances of wp_editor

I copied your code into my functions.php, and added a simple admin panel (‘Foo’) to display the editor. Then I created a new directory inside my current theme for the editor button, and put the editor button JS into the relevant file: /wp-content/themes/[my-theme-dir]/tinymce_buttons/pH/editor_plugin.js. Result: when I went to Dashboard > Foo (the panel I’d created), … Read more

data-accordion removed in Visual Editor

Here is an example of How to Update kses and TinyMCE to allow select data-* attributes in WordPress. Reference add_action( ‘after_setup_theme’, ‘x_kses_allow_data_attributes_on_links’ ); function x_kses_allow_data_attributes_on_links() { global $allowedposttags; $tags = array( ‘a’ ); $new_attributes = array( ‘data-foo’ => array(), ‘data-bar’ => array(), ); foreach ( $tags as $tag ) { if ( isset( $allowedposttags[ $tag … Read more