Tag Info

Hot answers tagged

16

Ok apparently WordPress keeps track of what kind of editor (visual or html) is active as a class which is added to the content wrapper so here is a solution that will get you the latest content in the editor function get_tinymce_content(){ if (jQuery("#wp-content-wrap").hasClass("tmce-active")){ return tinyMCE.activeEditor.getContent(); ...


11

You pretty much had it, according to the description. Here's what you might be looking for for instances 2 and 3 (for instance 1 you can leave the settings empty to get the default set of buttons): Instance 2: wp_editor( $distribution, 'distribution', array( 'media_buttons' => false, 'textarea_rows' => 8, 'tabindex' ...


11

Just set 'quicktags' parameter of the settings array to false. wp_editor('', 'some-id', array('quicktags' => false) );


10

tinyMCE textarea is initially unseen by the used serialize function: $.post(ajaxurl, $('#addtag').serialize(), function(r){ .... you will need to call tinyMCE.triggerSave() to make it 'visible' a simple script with: jQuery('#submit').mousedown( function() { tinyMCE.triggerSave(); }); should do the trick. This in an external file, enqueued ...


9

There is at least 1 issue with using wp_editor in a meta box, as discussed in ticket #19173(Good read on the subject of wp_editor and meta boxes). TinyMCE gets all messed up if you move the meta box that contains it (specifically, if TinyMCE's location in the DOM is changed). You can, however, use the Quicktags version (non tinyMCE). Another alternative is ...


8

WordPress is running addslashes on POST input. The value you get from the data base looks probably like: <img title=\"\" … … and the editor tries to enforce valid markup from that. So … call the editor with … wp_editor( stripslashes( $content ), strtolower($value['id']), $settings );


7

only overwrite the send_to_editor function when your link or button is click but store the old function to restore it so try this on a click event: //store old send to editor function window.restore_send_to_editor = window.send_to_editor; //overwrite send to editor function window.send_to_editor = function(html) { var imgurl = ...


7

you can set the params via array on the wp_editor() function; an exmaple $settings = array( 'tinymce' => array( 'setup' => 'function (ed) { tinymce.documentBaseURL = "' . get_admin_url() . '"; }', ), 'quicktags' => TRUE, 'editor_class' => 'frontend-article-editor', 'textarea_rows' => ...


7

Try this: replace 'theme_advanced_disable' => 'fullscreen' with 'toolbar1'=> 'bold,italic,underline,bullist,numlist,link,unlink,forecolor,undo,redo' Also, remove 'teeny' => true,


6

You can filter the TinyMCE body classes to add or change as needed. It's a string that's pre-populated with some things like post type, so the easiest thing to do is append your additional classes (with a preceding space). <?php function wpse_128380_tinymce_body_class( $mce ) { // you could do things here to detect whatever you need // and use ...


6

esc_html() and esc_textarea() are, appropriate to their names, escaping functions and really meant for display rather than sanitizing or validating. I would use wp_kses() or wp_kses_post() (which is just wp_kses() with the global $allowedposttags) to sanitize input from a wp_editor() field before saving.


5

To get the quicktags to show up, you need to re instantiate them within your ajax oncomplete handler. quicktags({id : 'editorcontentid'}); My ajax success handler looks like this; success: function(data, textStatus, XMLHttpRequest){ //append editor to dom $('#container').append($(data).html()); //init quicktags ...


5

You need to add a name attribute to your editors. The name attribute needs to be set to the value of of your option, so like this: function us_partners_cb() { $us_partners_desc = get_option( 'us_partners_desc' ); echo wp_editor( $us_partners_desc, 'uspartnersdesc', array('textarea_name' => 'us_partners_desc') ); }


5

To restrict users to just one post, don’t let them create new posts. Just add one wp_editor() instance to their profile. Hook into 'show_user_profile' and 'edit_user_profile' to show the editor. Hook into 'personal_options_update' and 'edit_user_profile_update' to save the content to a user meta or a hidden custom post type. Now they don’t have to ...


5

Short answer: Because there is a hidden widget where the TinyMCE appears first. Long answer (sorry, a very long answer): Go to the Codex and copy the example widget Foo_Widget to make sure we are talking about the same code. Now open your IDE (not an editor) and write a short testing widget as plugin. Starting with a minimal plugin header... <?php /* ...


5

The main problem are the missing scripts. The scripts enqueued in _WP_Editors::enqueue_scripts() are never printed. The same is true for _WP_Editors::editor_js(). So you have to do that in your AJAX callback handler. I have written a demo plugin and put it on GitHub: T5 AJAX Editor. There is one class named Ajax_Editor. Its method render() prints the ...


5

Make sure you've registered the stylesheet for the editor: add_editor_style( 'http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css' ); This should be in your functions.php https://codex.wordpress.org/Editor_Style


4

Actually you can include the editor-style.css (or any other stylesheet), just pass a "content_css" value to tinymce that points to a css file: wp_editor( $content, 'editablecontent', array( 'tinymce' => array( 'content_css' => get_stylesheet_directory_uri() . '/editor-styles.css' ) ); So the original ...


4

Add Dashicon All buttons inside the TinyMCE have a class, also your custom button. Include (use wp_enqueue_style() a stylesheet with styling with Dashicons, like the follow example. .myicon:before { content: '\2605'; display: inline-block; -webkit-font-smoothing: antialiased; font: normal 16px/1 'dashicons'; vertical-align: top; } On ...


4

The editor is hard-coded into the form. It isn't inserted by add_meta_box. There is a hook called edit_form_after_title which you should be able to use though. Proof of concept: // use the action to create a place for your meta box function add_before_editor($post) { global $post; do_meta_boxes('post', 'pre_editor', $post); } ...


4

Use the_content() not echo get_the_content();. As you can see in wp-includes/default-filters.php wpautop is added for the filter 'the_content' which is called in the_content().


4

In your edited_terms function you need to save the value and in your add_tag_form_fields you need replace your test with the saved data. something like: class Test{ function __construct() { //do_action('add_tag_form_fields', $taxonomy); add_action('add_tag_form_fields', array($this, 'add_tag_form_fields')); ...


4

It's a bug http://core.trac.wordpress.org/ticket/21197 Using the shortcut pulls up the TinyMCE fullscreen editor rather than the custom wordpress fullscreen editor. Update 13. July 2012: Fixed in Changeset 21266.


4

The TinyMCE has an Filter for all allowed tags. You can change the tags, there are set in standard for your options and the editor fitler the tags. Its not necassary, that you filter after save. Example for enhanced tags: function fb_change_mce_options( $initArray ) { // Comma separated string od extendes tags // Command separated string of ...


4

While @s_ha_dum’s solution works fine on a custom plugin page, it will fail if you use TinyMCE on a post editor page after the first editor instance has been called, because it would either affect all editors or at least the editors later on the same page. TinyMCE parses custom styles into its settings during the first run only. How to remove the custom ...


4

It turns out that TinyMCE has it's own autop setting, so if you kill it before the sort and then put it back you should be good to go! Check out the autop setting handling in this snippet: <script> (function($) { // by default, wpautop will be true var wpautop = true; // this function wraps subsequent additions of TinyMCE ...


3

Here is my solution: add_filter('the_editor_content', "firmasite_tinymce_style"); function firmasite_tinymce_style($content) { add_editor_style('assets/css/custom.css'); // This is for front-end tinymce customization if ( ! is_admin() ) { global $editor_styles; $editor_styles = (array) $editor_styles; $stylesheet = ...


3

your post here helped me figure a solution. Along with the mceInit property, I also had to retrieve the qtInit that wp_editor generates as well. The following is the relevant code within my class. Basically I have wp_editor run so that the javascript is generated. I use hooks to retrieve the javascript, so that I can echo it out in the ajax response. // ...


3

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 ...


3

I was looking for a solution to place custom metabox above the default editor and i've found the solution to my old question (how to customize the default editor with the wp_editor)! The solution was to unset the default editor first. Then create another metabox to to place the content then use wp_editor to create new its new instance, simple isn't it? ...



Only top voted, non community-wiki answers of a minimum length are eligible