Does anyone know how you can control the various classes that are available under the Insert/edit link Class dropdown in Visual mode when editing a post / page?
I understand that I can create CSS to control these. What I'm asking is how can I control the list here? Is it possible or is this just a quirk or future feature thing?
You will need to add the list of Name to show=classname to the TinyMCE config using the filter tiny_mce_before_init. More info.
theinterned
Member
Posted 2 years ago #
I was having this problem for a long time, azaozz's response helped me figure out what to do:
I couldn't figure out how to add another css file to tinymce using the filter so I did a little digging and found that there is a file in public/wp-includes/js/tinymce/ called wordpress.css. I added the classes I wanted to this css file and they now show up in the post / page editor.
I don't know how well this method will hold up to an upgrade (I have a feeling it wont), but I couldn't find any information on the net about how to use the tiny_mce_before_init filter.
Ned
TomBurr
Member
Posted 2 years ago #
Hi,
I am really struggling to figure this out. I don't really want to edit a core file that might be changed in an update. Asaozz (or anyone else!), thank you for your comment above, but please could you spell out in a little more detail how to add a custom class name to the class dropdown on the Insert/Edit link dialog.
Many thanks!
Tom
TwoThirdsWater
Member
Posted 2 years ago #
I have exactly the same situation.
Can anybody help please?
G'day,
I just found this plugin
http://www.n7studios.co.uk/2010/03/07/wordpress-insert-link-class-plugin/
It adds class names to the editor, then all you have to do is add the class to your theme CSS.
Working like a charm for me.
HTH,
=-)
Divadrummer
Member
Posted 2 years ago #
The plugin above doesn't seem to be working right now (it looks pretty new), but depending on what you want to do, I found another nice plugin that might work for you.
http://wordpress.org/extend/plugins/link-indication/
Which allows you to automatically assign custom CSS classes for links based on file extension or domain.
I couldn't find the TinyMCE file listed above, nor any other file that referenced the built-in classes.
kchevalier
Member
Posted 2 years ago #
Create a stylesheet in your theme directory called 'tinymce.css' (for example). Add your desired link classes in there, like so:
a.myClass {}
Then, in your functions.php add the following:
function addTinyMCELinkClasses( $wp ) {
$wp .= ',' . get_bloginfo('stylesheet_directory') . '/tinymce.css';
return $wp;
}
if ( function_exists( 'add_filter' ) ) {
add_filter( 'mce_css', 'addTinyMCELinkClasses' );
}
Hope that helps.