18

Here's a way to test the core patch #33300.6 by Andew Ozz, through a test plugin in WP 4.5.2, to try out the text pattern filter. Demo Here's a strikethrough example using ~ $init['wpsetextpattern_inline_patterns'] = '{ strong: { start: "*", end: "*", format: "bold" }, strong2: { start: "**", end: "**", format: "bold" ...


8

I had the exact same problem and found the solution to this. The problem is that the anchor plugin for TinyMCE is not being included as part of the default Wordpress install. So while Wordpress says to include: $buttons[] = 'anchor'; …that's not going to work because the TinyMCE plugin for anchors isn't there. If you go to TinyMCE's website, you can ...


5

You can register TinyMCE plugins using mce_external_plugins filter: add_filter('mce_external_plugins', 'my_tinymce_plugins'); function my_tinymce_plugins() { $plugins_array = array( 'my-tinymce-plugin-name' => 'tinymce-plugin-url-of-js-file' ); return $plugins_array; } You can add that code to ...


4

You asked the question a long ago but I was looking for something similar and found a solution. Enqueue an admin side script on post edit screens(where we have tinyMCE). Then use the code below: (function($) { 'use strict'; $(document).ready(function() { $(document).on( 'click', '#mce-modal-block', function() { tinyMCE....


3

To achieve the dropdown styles we have to use the filter hook tiny_mce_before_init. This filter grants developers access to the TinyMCE settings array. The following example adds custom style options to an existing Style dropdown. add_filter( 'tiny_mce_before_init', 'my_mce_before_init' ); function my_mce_before_init( $settings ) { $style_formats = ...


3

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


2

wp_editor() outputs the textarea(html codes), so, maybe you dont need to use that in functions.php, but use inside the page's source. (where that textarea is generated, for example like this: <div class="blabla> <form action="" method="POST"> <?php wp_editor( 'Hi,its content' , 'desired_id_of_textarea', $settings = array('textarea_name'=&...


2

I'm not sure if this question is still relevant or not (so I'm posting for future reference for people), but there is a way to define a css file for the TinyMCE editor in your plugin by using the mce_css filter. For a quick example, I'll take an excerpt from the WordPress documentation: function plugin_mce_css( $mce_css ) { if ( ! empty( $mce_css ) ) ...


2

I found a simpler solution, maybe someone can use it: var post_id = jQuery('#post_ID').val();


2

@frabiacca: I'm not sure if you meant the toolbar menu, like Circle B showed or the height of the writing place. If it's the latter you can : do it easily by gragging the bottom right corner or the textarea or clicking on the fullscreen button of the editor :D do it programmatically codex.wordpress.org/TinyMCE function wptiny($initArray){ $initArray[...


2

Hope You can use fallowing // Sets class attribute on all paragraphs in the active editor tinymce.activeEditor.dom.setAttrib(tinymce.activeEditor.dom.select('p'), 'class', 'myclass'); // Sets class attribute on a specific element in the current page tinymce.dom.setAttrib('mydiv', 'class', 'myclass'); or You can add Id by jquery like this $('div').find('...


2

They have actually fixed it so you can just add the shortcode within the paragraph content and it works. As simple as ...However, when [expand tag="span" title="this trigger" targtag="span"]hidden content[/expand] is clicked… That would be the contents of a paragraph block with inline shortcode. See this for more information.


2

addMenuItem() adds to tinymce's toolbar, which isn't used by WP by default, and uses context to add to the particular (sub)menu. You're adding a MenuButton, and you can access the button through the editor's buttons array, keyed by the button name: add_action( 'admin_print_footer_scripts', function () { ?> <script type="text/javascript"> ...


1

Just add this code to functions.php of your theme and then "View" --> "Show blocks" will always be enabled immediately when the page loads if( !function_exists('custom_settings_tinymce') ){ function custom_settings_tinymce($init) { $init['visualblocks_default_state'] = true; return $init; } add_filter('tiny_mce_before_init', '...


1

automatically turns pasted image URLs into embedded images Yes, but only for URLs ending with .gif, .jpg, .jpeg and .png. And that conversion is one of the "smart paste" features in TinyMCE — another one is when you select a text and paste an absolute URL (that begins with http or https), the text is automatically converted to a hyperlink (clickable ...


1

I just found out you can do it this way too, where you can keep using the original array and not have to use additional filters: Instead of the array keys being named theme_advanced_buttons*, they are now named toolbar*, so for example: $in['toolbar1'] = 'formatselect, bold, italic, underline, bullist, numlist, blockquote, link, image, alignleft, ...


1

I think theme_advanced_buttons1, theme_advanced_buttons2 etc were part of the TinyMCE advanced theme which is no longer available in TinyMCE 4. WordPress 4.9.7 is using TinyMCE version 4.7.11. The two rows of controls are now referred to with: mce_buttons mce_buttons_2 Here is a good example, taken from https://www.kevinleary.net/customizing-tinymce-...


1

I found the solution with help from Jacob Peattie and the article from https://make.wordpress.org/core/2017/05/23/addition-of-tinymce-to-the-text-widget/ Here's a quick walkthrough on what i did: I made a new js file container the code of my original button, but modified it to the event listener of the widget tinymce jQuery( document ).on( 'tinymce-editor-...


1

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


1

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


1

Try type: 'listbox', values: [{text: 'small'}, {text: 'normal'}, {text: 'large'}] For details: https://github.com/tinymce/tinymce/blob/master/js/tinymce/plugins/link/plugin.js I met the same problem when I want to use select2 in the dialog. All plugins are using listbox. My guess is they always use listbox instead of selectbox. And the handler for ...


1

After few days I got it to work. Gotta check those core files, now I know how. Anyways, here is the working code: function my_tiny_mce_tweaks( $first_init ) { $first_init['formats'] = '{' . 'alignleft: [' . '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . '{selector: "img,table,dl.wp-caption", ...


1

Well, yes, you can do that: //replace live edited content to display html editor.on('BeforeSetcontent', function(event){ event.content = tinymce_to_html( event.content ); }); //Transform your html content to raw content editor.on('GetContent', function(event){ event.content = html_to_tinymce( event.content ); }); Let's explain that: Under the ...


1

I have decided that the best solution is to just disable the visual editor, from Users -> Your Profile -> Disable visual editor when writing.


1

There are multiple options: Use a real table: <table><tr><td> and so on. Use pre-formatted text: <pre>text</pre> Switch to the HTML editor and enter HTML entities or numerical references for preserved white-space: &#160;


1

I figured it out. The window which was opened had to call the tinyMCEPopup.close() in its own scope. Which also meant I had to include the tiny_mce_popup.js script as well.


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