3

does anybody know how to change functionality of button in wordpress content textarea of tinymce? There is a "u" button (underline) which makes text

<span style="text-decoration-line: underline;">text underlined</span>

what I need is change functionality of this button to put in content:

<u>text underlined</u>

I know that i need to change the tinymce init but where can i find it? What do i have to write there? I need this in my wordpress blog, so please help me :)

polest
  • 51
  • 9
  • I answered a similar question not long ago [here](http://stackoverflow.com/questions/32561161/wordpress-change-functionality-of-tinymce-button-u-underline/32563429#32563429) – PalinDrome555 Oct 09 '15 at 15:19
  • yeah but where can i find the init? Never saw the init – polest Oct 11 '15 at 19:10

1 Answers1

1

You can create your own shortcode to accomplish this. Add the following to functions.php and you may use [u] and [/u] around whatever should get <u>-tags.

function underline_shortcode( $atts, $content = null ) {
    return '<u>' . $content . '</u>';
}
add_shortcode( 'u', 'underline_shortcode' );

Another solution, add this to wysiwyg.php after tinyMCE.init {...

inline_styles: false,
formats: {
    underline: { inline: 'u', exact : true }
}

This should force the present button to serve you with the good old tags. Although this is not recommended since u-tags are deprecated. (Source: Underline format problem)

Community
  • 1
  • 1
danjah
  • 1,226
  • 1
  • 12
  • 27
  • Thanks, i will try that but isnt there a simply way to change the tinymce editors underline button? Or to create a new button in the editor? – polest Oct 08 '15 at 13:36
  • Yes, that is possible. For a detailed explanation, look here: http://wordpress.stackexchange.com/questions/72394/how-to-add-a-shortcode-button-to-the-tinymce-editor – danjah Oct 08 '15 at 13:37
  • I know that there is a easier way with the tinymce init but i dont know how to do it. By the way: your solution do not work :/ – polest Oct 08 '15 at 13:46