Tag Info

Hot answers tagged

10

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(); ...


10

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


10

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


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

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

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


6

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 );


6

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


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

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


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

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

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

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

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


3

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


3

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


3

That can be achieved with the hooks edit_form_after_title and edit_form_after_editor and proceed like a meta box. I noticed a "glitch", though, if you swap Visual/Html in the custom wp_editors and then publish/refresh the page, their state will be the same as the main editor (the post content). Adjust the post type, page in this example. add_action( ...


3

I believe you want remove_editor_styles. Looks like it removes the theme support for editor styles. remove_editor_styles(); If you run that on your plugin's backend page before the editor boots, it should solve the problem. There might be a parameter you can pass to the editor functions, or a hook, but removing the editor style support for the effected ...


3

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


3

WordPress stores this option as user meta ({$wpdb->prefix}user-settings). You can use get_user_setting('editor', 'tinymce') to get it's value (editor is setting name, and tinymce is default value).


3

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

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


3

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); } ...



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