Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The default WordPress insert/edit link inspector window has options for URL, Target, Title and Class. I would like to add a checkbox labeled "Make link nofollow" that, when checked, adds rel="nofollow" to the link.

It would also need to know if the link already has nofollow and default to checked in the case of a link edit.

Is there an existing filter or action to hook into this dialog to add the required bits?

share|improve this question
    
unfortunately there are no hooks in those sections. this is something many of us want... –  onetrickpony Jan 20 '11 at 22:35
    
@OTP: Perhaps with 3.1's new link inspector, can we hook now? –  Scott B Mar 12 '11 at 20:10
add comment

1 Answer

up vote 1 down vote accepted

You could add the advlink plugin in to tinyMCE. I don't think I can attach the code, so to do it you'll need to download a copy of tinyMCE:

http://tinymce.moxiecode.com/download/download.php

Then copy over the advlink directory (from the plugins folder) to your Wordpress plugins folder, and open up the link.htm file.

In there edit the 4 script tags at the top from:

    <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/mctabs.js"></script>
<script type="text/javascript" src="../../utils/form_utils.js"></script>
<script type="text/javascript" src="../../utils/validate.js"></script>

to:

    <script type="text/javascript" src="../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../../wp-includes/js/tinymce/utils/mctabs.js"></script>
<script type="text/javascript" src="../../../wp-includes/js/tinymce/utils/form_utils.js"></script>
<script type="text/javascript" src="../../../wp-includes/js/tinymce/utils/validate.js"></script>

Lastly add this filter function to your theme's functions.php file:

function tiny_mce_advlink($plugins) {
   $newPlugins=array('advlink' => WP_PLUGIN_URL.'/advlink/editor_plugin.js' );
   return $plugins+$newPlugins;
}
add_filter('mce_external_plugins', 'tiny_mce_advlink');

Then you should have a more advanced dialog when you click on a link. In the Advanced tab you'll notice a drop down that says 'Relationship page to target' and you can select the 'No Follow' option.

You can of course use this tinyMCE plugin as the basis to write your own if you wanted.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.