WP External Links


/ Published in: PHP
Save to your folder(s)

Configure settings for all external links on your site.

Features:
* Open external links in new window or tab
* Add "nofollow"
* Set link title
* Set link icon
* Set classes (for your own styling)
* Set no-icon class
* SEO friendly


Copy this code and paste it in your HTML
  1. <?php defined( 'ABSPATH' ) OR die( 'No direct access.' );
  2. /*
  3. Plugin Name: WP External Links
  4. Plugin URI: http://www.freelancephp.net/wp-external-links-plugin
  5. Description: Open external links in a new window/tab, add "external" / "nofollow" to rel-attribute, set icon, XHTML strict, SEO friendly...
  6. Author: Victor Villaverde Laan
  7. Version: 1.41
  8. Author URI: http://www.freelancephp.net
  9. License: Dual licensed under the MIT and GPL licenses
  10. */
  11.  
  12. // plugin version
  13. define( 'WP_EXTERNAL_LINKS_VERSION', '1.41' );
  14.  
  15. // plugin key (used as translation domain, option_group, page_slug etc)
  16. define( 'WP_EXTERNAL_LINKS_KEY', 'wp_external_links' );
  17.  
  18. // plugin file
  19. define( 'WP_EXTERNAL_LINKS_FILE', __FILE__ );
  20.  
  21.  
  22. // check plugin compatibility
  23. if ( isset( $wp_version ) AND version_compare( preg_replace( '/-.*$/', '', $wp_version ), '3.0', '>=' )
  24. AND version_compare( phpversion(), '5.2', '>=' ) ) {
  25.  
  26. // include classes
  27. require_once( 'includes/wp-plugin-dev-classes/class-wp-meta-box-page.php' );
  28. require_once( 'includes/wp-plugin-dev-classes/class-wp-option-forms.php' );
  29. require_once( 'includes/class-admin-external-links.php' );
  30. require_once( 'includes/class-wp-external-links.php' );
  31.  
  32. // create WP_External_Links instance
  33. $WP_External_Links = new WP_External_Links();
  34.  
  35. } else {
  36.  
  37. // set error message
  38. function wp_external_links_error_notice() {
  39. echo '<div class="error">'
  40. . __( '<p>Warning - <strong>WP External Links Plugin</strong> requires PHP 5.2+ and WP 3.0+.'
  41. . '<br/>Please upgrade your configuration or use an older version of this plugin. '
  42. . 'Disable the plugin to remove this message.</p>', WP_EXTERNAL_LINKS_KEY )
  43. . '</div>';
  44. }
  45. add_action( 'admin_notices', 'wp_external_links_error_notice' );
  46.  
  47. }
  48.  
  49. /* ommit PHP closing tag, to prevent unwanted whitespace at the end of the parts generated by the included files */

URL: http://www.freelancephp.net/wp-external-links-plugin/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.