Add Button to TinyMCE Custom Menu

That looks like it is an error due to TinyMCE (editorremov I believe) not being loaded yet. Either hook to the admin_footer action instead of admin_head (interestingly you have declared the in_footer option as true and it is still not working) or declare the editorremov dependency when enqueuing your script: wp_enqueue_script( ‘features’, plugin_dir_url( __FILE__ ) … Read more

Allow author to upload image via Media button without plugin

in the basic configuration the user role contributor and subscriber do not have the capability upload_files. The user role author has this capability. The capability upload_files gives the user the panels “Media” and “Media > Add New”. If you want another role to grant this capability, you can use the function add_cap(). Since such changes … Read more

How to modify VisualComposer’s TinyMCE editor only for a specific shortcode

There are a number of problems: The tiny_mce_before_init filter does not affect the TinyMCE editor that VC instantiates for parameters with name == ‘content’ and type == ‘content_html’. VC gets the TinyMCE HTML markup in a separate AJAX request. The editor’s instantiation does not benefit from the tinyMCEPreInit inline JavaScript array that the filter affects. … Read more

TinyMCE custom button retrieve value from custom field

Rather than finding the custom field value when the user hits the button, change the [custom field value] to a shortcode name (perhaps “[mkay_subscription_button_value]”?) and then create a shortcode that can replace the value of that key with the post’s custom meta. Something like this: function 246286_display_custom_field( $atts ) { $data = get_post_meta( get_the_ID(), ‘mkay_custom_field’, … Read more

Custom styles in Tiny MCE with an external CSS file

The path to the CSS file tinymce.min.css was incorrect. The solution was to change: $url .= trailingslashit( plugin_dir_url(get_stylesheet_directory_uri()) ) . ‘/tinymce.min.css’; to: $StyleUrl = get_stylesheet_directory_uri().’/style-sheets/tinymce.min.css’; I also had to change: $StyleUrl = plugin_dir_url(get_stylesheet_directory_uri()).’tinymce.min.css’; to: $StyleUrl = get_stylesheet_directory_uri().’/style-sheets/tinymce.min.css’; Now all I had to do was to remove the styles array so the complete code is: // … Read more