Tag Info

Hot answers tagged

26

To add our button to the TinyMCE editor we need to do several things: Add our button to the toolbar Register a TinyMCE plugin Create that TinyMCE plug-in which tells TinyMCE what to do when our button is clicked. Steps #1 and #2 In these steps we register our TinyMCE plug-in which will live inside a javascript file at 'path/to/shortcode.js' (see ...


16

If you look in class-wp-editor.php you'll find that the filter you are using is still there, however the settings are different. self::$first_init = array( 'theme' => 'modern', 'skin' => 'lightgray', 'language' => self::$mce_locale, 'formats' => "{ ...


13

The follow small plugin create a custom buttom inside line 1 of the WordPress TinyMCE Version 4, tested in WP Version 3.9-beta2. The plugin have var_dump include to understand the values. It also possible to add the button to other lines of the visual editor, only a other hook, like for line 2: mce_buttons_2. Result Plugin, php side - tinymce4-test.php ...


12

I recently got this working. You should search and replace metaname with your meta box name. The key to maintaining formatting was using wpautop(); when saving the data. add_action( 'add_meta_boxes', 'add_metaname_box'); add_action( 'save_post', 'metaname_save'); function add_metaname_box() { add_meta_box( 'metaname_id', __( 'metaname ...


11

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

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


11

You can not enhance the drop down list formatselect. But you can enhance with the hook tiny_mce_before_init the second drop down styleselect, there is hide in a default WordPress install. The documentation list all defaults and possibilities. inline – Name of the inline element to produce for example “span”. The current text selection will be wrapped in ...


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


9

It is almost code golf, but this is the smallest piece of code that I could up with that will create a button on the Visual editor to turn the current paragraph in a <h2> block. add_filter( 'tiny_mce_before_init', 'wpse18719_tiny_mce_before_init' ); function wpse18719_tiny_mce_before_init( $initArray ) { $initArray['setup'] = <<<JS ...


9

WordPress provides a mce_css filter, that can be used to add custom stylesheets to the Visual Editor. According to the Codex: The file can be a .php file, allowing dynamic generation of CSS rules for the content editor. Example Codex filter callback, modified for a Theme: function wpse120831_mce_css( $mce_css ) { if ( ! empty( $mce_css ) ) ...


8

If a function echos data, you can use php output buffering to capture the echoed output and return it instead // Turn on the output buffer ob_start(); // Echo the editor to the buffer wp_editor(); // Store the contents of the buffer in a variable $editor_contents = ob_get_clean(); // Return the content you want to the calling function return ...


8

Just wrote the function. It'll display the tinymce editor in every custom taxonomy description right now. Surely you can edit to show it for only some specific taxonomy. /** * Display advanced TinyMCE editor in taxonomy page */ function wpse_7156_enqueue_category() { global $pagenow, $current_screen; if( $pagenow == 'edit-tags.php' ) { ...


7

There is a button on the visual text editor built in to WordPress that will strip Microsoft Word formating. It is labeled "Paste From Word"


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

Check out this tutorial on Pro Blog Design: http://www.problogdesign.com/wordpress/user-friendly-short-codes-with-tinymce/


7

Well, Thanks to wp 3.3 now we have wp_editor() function to do that :)


7

Adding scripts after TinyMCE: You might check out the before_wp_tiny_mce and after_wp_tiny_mcehooks. If you take a look at the file /wp-includes/class-wp-editor.php you can see that the TinyMCE settings scripts are not all loaded through the usual enqueue methods, but some are displayed via: add_action( 'admin_print_footer_scripts', array( __CLASS__, ...


6

Solution 1 This works as javascript solution: Example: tinyMCE.activeEditor.dom.addStyle('p {color:red; font-size:28px;}'); just open your js console and paste it for a quick test. To target a specific editor one should use: tinyMCE.getInstanceById('##editorID##').dom.addStyle('p {color:red; font-size:28px;}'); This will inject the provided string ...


6

The answer suggested by GavinR is correct. You don't need to install the suggested plug-in, though. Just add this mini plugin and you're set: <?php defined( 'ABSPATH' ) OR exit; /* Plugin Name: TinyMCE break instead of paragraph */ function mytheme_tinymce_settings( $tinymce_init_settings ) { $tinymce_init_settings['forced_root_block'] = false; ...


6

The strings was new, not more for your requirements. This is the new content of the hook. array ( 'selector' => '#content', 'resize' => 'vertical', 'menubar' => false, 'wpautop' => true, 'indent' => false, 'toolbar1' => ...


6

One change is that: theme_advanced_buttons1 is going to be changed to: toolbar1 which allows you to update the buttons so my new function will look something like: function myformatTinyMCE( $in ) { $in['toolbar1'] = 'bold'; $in['toolbar2'] = 'formatselect'; return $in; } add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' ); Also it looks ...


6

There is a hook for that: 'mce_css'. It is called in _WP_Editors::editor_settings() and you get all loaded stylesheets comma separated as the first and only parameter. Now it is easy: Use the global variable $editor_styles (here are your theme’s and parent theme’s editor stylesheets stored already), add the time of the file’s last modification as a ...


6

There's too much to put the whole answer here so checkout this guide: http://wp.smashingmagazine.com/2012/05/01/wordpress-shortcodes-complete-guide/ You have to create a Javascript file that takes action from the button you register through WordPress that inserts the TinyMCE button into the editor.


6

Use the filter 'mce_external_languages'. From wp-includes/class-wp-editor.php: The following filter loads external language files for TinyMCE plugins. It takes an associative array 'plugin_name' => 'path', where path is the include path to the file. The language file should follow the same format as /tinymce/langs/wp-langs.php and ...


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.


6

This should be what you're looking for - put this code into your theme's functions.php file: add_filter( 'tiny_mce_before_init', 'yourprefix_tiny_mce_before_init' ); function yourprefix_tiny_mce_before_init( $init_array ) { // filter styles: $init_array['theme_advanced_styles'] = "your_style=your_class"; // filter formats: ...


6

Here is a nice and fairly new (a year old) tutorial i've read a few days ago http://www.garyc40.com/2010/03/how-to-make-shortcodes-user-friendly/ He as a great example and you cal also download the source files and get a better understanding.


5

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 be a bit dated, so in the event of ...


5

Use this class: http://www.deluxeblogtips.com/p/meta-box-script-for-wordpress.html and then call the metabox like this (don't forget to read the manual and view some examples): $meta_boxes[] = array( 'id' => 'textmetabox', 'title' => 'Your Meta Box Title', 'pages' => array('post', 'slider', 'whatever-your-cpt-is'), 'fields' => ...


5

Use add_editor_style e.g.: functions.php add_editor_style('custom-editor-style.css'); http://codex.wordpress.org/Function_Reference/add_editor_style



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