WordPress.org

Ready to get started?Download WordPress

Forums

Insert/edit link Class feature (8 posts)

  1. Clicknathan
    Member
    Posted 5 years ago #

    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?

  2. Andrew Ozz
    WordPress Dev
    Posted 5 years ago #

    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.

  3. theinterned
    Member
    Posted 5 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

  4. TomBurr
    Member
    Posted 4 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

  5. TwoThirdsWater
    Member
    Posted 4 years ago #

    I have exactly the same situation.

    Can anybody help please?

  6. Jandal
    Member
    Posted 4 years ago #

    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,
    =-)

  7. Divadrummer
    Member
    Posted 4 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.

  8. kchevalier
    Member
    Posted 4 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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.