Version Description
- For jQuery uses live() function so also opens dynamicly created links in given target
- Fixed bug of changing
<abbr>
tag - Small cosmetical adjustments
Download this release
Release Info
Developer | freelancephp |
Plugin | WP External Links (nofollow new tab seo) |
Version | 0.32 |
Comparing to | |
See all releases |
Code changes from version 0.31 to 0.32
- images/icon-email-encoder-bundle.png +0 -0
- js/external-links.js +41 -36
- readme.txt +28 -7
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- wp-external-links.php +106 -68
images/icon-email-encoder-bundle.png
ADDED
Binary file
|
js/external-links.js
CHANGED
@@ -2,61 +2,66 @@
|
|
2 |
(function( w, $ ){
|
3 |
|
4 |
var addEvt = function ( el, evt, fn ) {
|
5 |
-
if (
|
6 |
-
// jQuery method
|
7 |
-
$( el ).bind( evt, fn );
|
8 |
-
} else if ( el.attachEvent ) {
|
9 |
// IE method
|
10 |
el.attachEvent( 'on'+ evt, fn );
|
11 |
} else if ( el.addEventListener ) {
|
12 |
// Standard JS method
|
13 |
el.addEventListener( evt, fn, false );
|
14 |
}
|
15 |
-
},
|
16 |
-
init = function () {
|
17 |
-
if ( typeof wpExtLinks != 'undefined' )
|
18 |
-
setExtLinks( wpExtLinks );
|
19 |
};
|
20 |
|
21 |
-
function
|
22 |
-
var
|
|
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
( href.substr( 0, 7 ) == 'http://'
|
34 |
-
|| href.substr( 0, 8 ) == 'https://'
|
35 |
-
|| href.substr( 0, 6 ) == 'ftp://' ) ) ) ) {
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
n.focus();
|
43 |
-
|
44 |
-
// prevent default
|
45 |
-
e.returnValue = false;
|
46 |
-
if ( e.preventDefault )
|
47 |
-
e.preventDefault();
|
48 |
-
}
|
49 |
-
}( a ));
|
50 |
}
|
51 |
}
|
52 |
}
|
53 |
|
54 |
if ( $ ) {
|
55 |
// jQuery DOMready method
|
56 |
-
$(
|
|
|
|
|
|
|
|
|
57 |
} else {
|
58 |
// use onload when jQuery not available
|
59 |
-
addEvt( w, 'load',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
})( window, typeof jQuery == 'undefined' ? null : jQuery );
|
2 |
(function( w, $ ){
|
3 |
|
4 |
var addEvt = function ( el, evt, fn ) {
|
5 |
+
if ( el.attachEvent ) {
|
|
|
|
|
|
|
6 |
// IE method
|
7 |
el.attachEvent( 'on'+ evt, fn );
|
8 |
} else if ( el.addEventListener ) {
|
9 |
// Standard JS method
|
10 |
el.addEventListener( evt, fn, false );
|
11 |
}
|
|
|
|
|
|
|
|
|
12 |
};
|
13 |
|
14 |
+
function openExtLink( a, opts, e ) {
|
15 |
+
var options = opts ? opts : wpExtLinks,
|
16 |
+
href = a.href ? a.href.toLowerCase() : '',
|
17 |
+
rel = a.rel ? a.rel.toLowerCase() : '',
|
18 |
+
n;
|
19 |
|
20 |
+
if ( a.href && ( options.excludeClass.length == 0 || a.className.indexOf( options.excludeClass ) )
|
21 |
+
&& ( rel.indexOf( 'external' ) > -1
|
22 |
+
|| ( ( href.indexOf( options.baseUrl ) === -1 ) &&
|
23 |
+
( href.substr( 0, 7 ) == 'http://'
|
24 |
+
|| href.substr( 0, 8 ) == 'https://'
|
25 |
+
|| href.substr( 0, 6 ) == 'ftp://' ) ) ) ) {
|
26 |
|
27 |
+
// open link in a new window
|
28 |
+
n = w.open( a.href, options.target );
|
29 |
+
n.focus();
|
|
|
|
|
|
|
30 |
|
31 |
+
// prevent default event action
|
32 |
+
if ( e ) {
|
33 |
+
e.returnValue = false;
|
34 |
+
if ( e.preventDefault )
|
35 |
+
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
}
|
38 |
}
|
39 |
|
40 |
if ( $ ) {
|
41 |
// jQuery DOMready method
|
42 |
+
$(function(){
|
43 |
+
$( 'a' ).live( 'click', function( e ){
|
44 |
+
openExtLink( this, null, e );
|
45 |
+
});
|
46 |
+
});
|
47 |
} else {
|
48 |
// use onload when jQuery not available
|
49 |
+
addEvt( w, 'load', function () {
|
50 |
+
var links = w.document.getElementsByTagName( 'a' ),
|
51 |
+
a;
|
52 |
+
|
53 |
+
// check each <a> element
|
54 |
+
for ( var i = 0; i < links.length; i++ ) {
|
55 |
+
a = links[ i ];
|
56 |
+
|
57 |
+
// click event for opening in a new window
|
58 |
+
addEvt( a, 'click', function( a ){
|
59 |
+
return function ( e ) {
|
60 |
+
openExtLink( a, null, e );
|
61 |
+
}
|
62 |
+
}( a ));
|
63 |
+
}
|
64 |
+
});
|
65 |
}
|
66 |
|
67 |
})( window, typeof jQuery == 'undefined' ? null : jQuery );
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: freelancephp
|
|
3 |
Tags: links, external, new window, icon, target, _blank, _new, _top, _none, rel, nofollow, javascript, xhtml strict
|
4 |
Requires at least: 2.7.0
|
5 |
Tested up to: 3.1.0
|
6 |
-
Stable tag: 0.
|
7 |
|
8 |
Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
|
9 |
|
@@ -29,15 +29,37 @@ Supports PHP4.3+ and up to latest WP version.
|
|
29 |
|
30 |
== Frequently Asked Questions ==
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
[Do you have a question? Please ask me](http://www.freelancephp.net/contact/)
|
33 |
|
34 |
== Screenshots ==
|
35 |
|
36 |
-
1. Admin Settings Page
|
37 |
1. Link Icon on the Site
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
== Changelog ==
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
= 0.31 =
|
42 |
* Small cosmetical adjustments
|
43 |
|
@@ -71,8 +93,7 @@ Supports PHP4.3+ and up to latest WP version.
|
|
71 |
|
72 |
== Upgrade Notice ==
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
* Title icon on Admin Options Page was made by [FatCow Web Hosting](http://www.fatcow.com/) taken form [iconfinder](http://findicons.com/icon/164579/link_go?id=427009)
|
3 |
Tags: links, external, new window, icon, target, _blank, _new, _top, _none, rel, nofollow, javascript, xhtml strict
|
4 |
Requires at least: 2.7.0
|
5 |
Tested up to: 3.1.0
|
6 |
+
Stable tag: 0.32
|
7 |
|
8 |
Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
|
9 |
|
29 |
|
30 |
== Frequently Asked Questions ==
|
31 |
|
32 |
+
= I have a problem when defining links with JavaScript. What to do? =
|
33 |
+
When having problems defining links in JavaScript like:
|
34 |
+
`document.write( "<a href=\"http:://google.com\">Google</a>" );`
|
35 |
+
|
36 |
+
You could use single quotes for defining the string and therefore remove the double quotes, like:
|
37 |
+
`document.write( '<a href="http:://google.com">Google</a>' );`
|
38 |
+
|
39 |
+
Or you could prevent the plugin filtering the link by escaping the last slash (`</a>`) like:
|
40 |
+
`document.write( '<a href="http:://google.com">Google<\/a>' );`
|
41 |
+
|
42 |
+
In the last case when using the JavaScript method and jQuery the link would still be opened in the target given on the options page.
|
43 |
+
|
44 |
[Do you have a question? Please ask me](http://www.freelancephp.net/contact/)
|
45 |
|
46 |
== Screenshots ==
|
47 |
|
|
|
48 |
1. Link Icon on the Site
|
49 |
+
1. Admin Settings Page
|
50 |
+
|
51 |
+
== Other notes ==
|
52 |
+
|
53 |
+
= Credits =
|
54 |
+
* Title icon on Admin Options Page was made by [FatCow Web Hosting](http://www.fatcow.com/) taken form [iconfinder](http://findicons.com/icon/164579/link_go?id=427009)
|
55 |
|
56 |
== Changelog ==
|
57 |
|
58 |
+
= 0.32 =
|
59 |
+
* For jQuery uses live() function so also opens dynamicly created links in given target
|
60 |
+
* Fixed bug of changing `<abbr>` tag
|
61 |
+
* Small cosmetical adjustments
|
62 |
+
|
63 |
= 0.31 =
|
64 |
* Small cosmetical adjustments
|
65 |
|
93 |
|
94 |
== Upgrade Notice ==
|
95 |
|
96 |
+
= 0.32 =
|
97 |
+
* For jQuery uses live() function so also opens dynamicly created links in given target
|
98 |
+
* Fixed bug of changing `<abbr>` tag
|
99 |
+
* Small cosmetical adjustments
|
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
wp-external-links.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP External Links
|
|
4 |
Plugin URI: http://www.freelancephp.net/wp-external-links-plugin
|
5 |
Description: Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
|
6 |
Author: Victor Villaverde Laan
|
7 |
-
Version: 0.
|
8 |
Author URI: http://www.freelancephp.net
|
9 |
License: Dual licensed under the MIT and GPL licenses
|
10 |
*/
|
@@ -19,7 +19,7 @@ class WP_External_Links {
|
|
19 |
* Current version
|
20 |
* @var string
|
21 |
*/
|
22 |
-
var $version = '0.
|
23 |
|
24 |
/**
|
25 |
* Used as prefix for options entry and could be used as text domain (for translations)
|
@@ -69,50 +69,14 @@ class WP_External_Links {
|
|
69 |
// load text domain for translations
|
70 |
load_plugin_textdomain( $this->domain, dirname( __FILE__ ) . '/lang/', basename( dirname(__FILE__) ) . '/lang/' );
|
71 |
|
72 |
-
// add actions
|
73 |
-
add_action( 'init', array( $this, 'init' ) );
|
74 |
-
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
75 |
-
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
76 |
-
|
77 |
-
// add filters
|
78 |
-
if ( $this->options[ 'filter_whole_page' ] ) {
|
79 |
-
add_action( 'wp', array( $this, 'wp' ), 1 );
|
80 |
-
} else {
|
81 |
-
// set filter priority
|
82 |
-
$priority = 1000000000;
|
83 |
-
|
84 |
-
// content
|
85 |
-
if ( $this->options[ 'filter_posts' ] ) {
|
86 |
-
add_filter( 'the_title', array( $this, 'filter_content' ), $priority );
|
87 |
-
add_filter( 'the_content', array( $this, 'filter_content' ), $priority );
|
88 |
-
add_filter( 'the_excerpt', array( $this, 'filter_content' ), $priority );
|
89 |
-
add_filter( 'get_the_excerpt', array( $this, 'filter_content' ), $priority );
|
90 |
-
}
|
91 |
-
|
92 |
-
// comments
|
93 |
-
if ( $this->options[ 'filter_comments' ] ) {
|
94 |
-
add_filter( 'comment_text', array( $this, 'filter_content' ), $priority );
|
95 |
-
add_filter( 'comment_excerpt', array( $this, 'filter_content' ), $priority );
|
96 |
-
add_filter( 'comment_url', array( $this, 'filter_content' ), $priority );
|
97 |
-
add_filter( 'get_comment_author_url', array( $this, 'filter_content' ), $priority );
|
98 |
-
add_filter( 'get_comment_author_link', array( $this, 'filter_content' ), $priority );
|
99 |
-
add_filter( 'get_comment_author_url_link', array( $this, 'filter_content' ), $priority );
|
100 |
-
}
|
101 |
-
|
102 |
-
// widgets ( only text widgets )
|
103 |
-
if ( $this->options[ 'filter_widgets' ] ) {
|
104 |
-
add_filter( 'widget_title', array( $this, 'filter_content' ), $priority );
|
105 |
-
add_filter( 'widget_text', array( $this, 'filter_content' ), $priority );
|
106 |
-
|
107 |
-
// Only if Widget Logic plugin is installed
|
108 |
-
// @todo Doesn't work and cannot find another way to filter all widget contents
|
109 |
-
//add_filter( 'widget_content', array( $this, 'filter_content' ), $priority );
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
// set uninstall hook
|
114 |
if ( function_exists( 'register_deactivation_hook' ) )
|
115 |
register_deactivation_hook( __FILE__, array( $this, 'deactivation' ));
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
|
118 |
/**
|
@@ -120,7 +84,51 @@ class WP_External_Links {
|
|
120 |
*/
|
121 |
function wp() {
|
122 |
if ( ! is_admin() && ! is_feed() ) {
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
}
|
126 |
|
@@ -135,24 +143,6 @@ class WP_External_Links {
|
|
135 |
}
|
136 |
}
|
137 |
|
138 |
-
/**
|
139 |
-
* Callback init
|
140 |
-
*/
|
141 |
-
function init() {
|
142 |
-
if ( ! is_admin() ) {
|
143 |
-
// add wp_head for setting js vars and css style
|
144 |
-
add_action( 'wp_head', array( $this, 'wp_head' ) );
|
145 |
-
|
146 |
-
// add stylesheet
|
147 |
-
wp_enqueue_style( 'wp-external-links', plugins_url( 'css/external-links.css', __FILE__ ), FALSE, $this->version );
|
148 |
-
|
149 |
-
// set js file
|
150 |
-
if ( $this->options[ 'use_js' ] ) {
|
151 |
-
wp_enqueue_script( 'wp-external-links', plugins_url( 'js/external-links.js', __FILE__ ), array( 'jquery' ), $this->version );
|
152 |
-
}
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
/**
|
157 |
* Callback wp_head
|
158 |
*/
|
@@ -170,34 +160,52 @@ var wpExtLinks = { baseUrl: '<?php echo get_bloginfo( 'url' ) ?>',target: '<?php
|
|
170 |
endif;
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
/**
|
174 |
* Filter content
|
175 |
* @param string $content
|
176 |
* @return string
|
177 |
*/
|
178 |
function filter_content( $content ) {
|
179 |
-
|
180 |
-
|
|
|
181 |
$content = preg_replace_callback( $a_pattern, array( $this, 'parse_link' ), $content );
|
182 |
|
183 |
// remove style when no icon classes are found
|
184 |
if ( strpos( $content, 'ext-icon-' ) === FALSE ) {
|
185 |
// remove style with id wp-external-links-css
|
186 |
-
$content = preg_replace( '/<link(.*?)wp-external-links-css(.*?)\/>[\s+]*/i',''
|
187 |
}
|
188 |
|
189 |
return $content;
|
190 |
}
|
191 |
|
192 |
|
193 |
-
|
194 |
/**
|
195 |
* Make a clean <a> code
|
196 |
* @param array $match Result of a preg call in filter_content()
|
197 |
* @return string Clean <a> code
|
198 |
*/
|
199 |
function parse_link( $match ) {
|
200 |
-
$attrs =
|
|
|
|
|
201 |
|
202 |
$href_tolower = strtolower( $attrs[ 'href' ] );
|
203 |
$rel_tolower = ( isset( $attrs[ 'rel' ] ) ) ? strtolower( $attrs[ 'rel' ] ) : '';
|
@@ -297,6 +305,17 @@ jQuery(function( $ ){
|
|
297 |
}
|
298 |
})
|
299 |
.change();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
})
|
301 |
</script>
|
302 |
<div class="wrap">
|
@@ -446,9 +465,28 @@ jQuery(function( $ ){
|
|
446 |
<h4><img src="<?php echo plugins_url( 'images/icon-wp-mailto-links.png', __FILE__ ) ?>" width="16" height="16" /> WP Mailto Links</h4>
|
447 |
<p><?php _e( 'Manage mailto links on your site and protect emails from spambots, set mail icon and more.', $this->domain ) ?></p>
|
448 |
<ul>
|
449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
<li><a href="http://wordpress.org/extend/plugins/wp-mailto-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-mailto-links-plugin/" target="_blank">FreelancePHP.net</a></li>
|
451 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
</div>
|
453 |
</div>
|
454 |
</div>
|
4 |
Plugin URI: http://www.freelancephp.net/wp-external-links-plugin
|
5 |
Description: Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
|
6 |
Author: Victor Villaverde Laan
|
7 |
+
Version: 0.32
|
8 |
Author URI: http://www.freelancephp.net
|
9 |
License: Dual licensed under the MIT and GPL licenses
|
10 |
*/
|
19 |
* Current version
|
20 |
* @var string
|
21 |
*/
|
22 |
+
var $version = '0.32';
|
23 |
|
24 |
/**
|
25 |
* Used as prefix for options entry and could be used as text domain (for translations)
|
69 |
// load text domain for translations
|
70 |
load_plugin_textdomain( $this->domain, dirname( __FILE__ ) . '/lang/', basename( dirname(__FILE__) ) . '/lang/' );
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
// set uninstall hook
|
73 |
if ( function_exists( 'register_deactivation_hook' ) )
|
74 |
register_deactivation_hook( __FILE__, array( $this, 'deactivation' ));
|
75 |
+
|
76 |
+
// add actions
|
77 |
+
add_action( 'wp', array( $this, 'wp' ) );
|
78 |
+
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
79 |
+
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
80 |
}
|
81 |
|
82 |
/**
|
84 |
*/
|
85 |
function wp() {
|
86 |
if ( ! is_admin() && ! is_feed() ) {
|
87 |
+
// add wp_head for setting js vars and css style
|
88 |
+
add_action( 'wp_head', array( $this, 'wp_head' ) );
|
89 |
+
|
90 |
+
// add stylesheet
|
91 |
+
wp_enqueue_style( 'wp-external-links', plugins_url( 'css/external-links.css', __FILE__ ), FALSE, $this->version );
|
92 |
+
|
93 |
+
// set js file
|
94 |
+
if ( $this->options[ 'use_js' ] ) {
|
95 |
+
wp_enqueue_script( 'wp-external-links', plugins_url( 'js/external-links.js', __FILE__ ), array( 'jquery' ), $this->version );
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( $this->options[ 'filter_whole_page' ] ) {
|
99 |
+
ob_start( array( $this, 'filter_page' ) );
|
100 |
+
} else {
|
101 |
+
// set filter priority
|
102 |
+
$priority = 1000000000;
|
103 |
+
|
104 |
+
// content
|
105 |
+
if ( $this->options[ 'filter_posts' ] ) {
|
106 |
+
add_filter( 'the_title', array( $this, 'filter_content' ), $priority );
|
107 |
+
add_filter( 'the_content', array( $this, 'filter_content' ), $priority );
|
108 |
+
add_filter( 'the_excerpt', array( $this, 'filter_content' ), $priority );
|
109 |
+
add_filter( 'get_the_excerpt', array( $this, 'filter_content' ), $priority );
|
110 |
+
}
|
111 |
+
|
112 |
+
// comments
|
113 |
+
if ( $this->options[ 'filter_comments' ] ) {
|
114 |
+
add_filter( 'comment_text', array( $this, 'filter_content' ), $priority );
|
115 |
+
add_filter( 'comment_excerpt', array( $this, 'filter_content' ), $priority );
|
116 |
+
add_filter( 'comment_url', array( $this, 'filter_content' ), $priority );
|
117 |
+
add_filter( 'get_comment_author_url', array( $this, 'filter_content' ), $priority );
|
118 |
+
add_filter( 'get_comment_author_link', array( $this, 'filter_content' ), $priority );
|
119 |
+
add_filter( 'get_comment_author_url_link', array( $this, 'filter_content' ), $priority );
|
120 |
+
}
|
121 |
+
|
122 |
+
// widgets ( only text widgets )
|
123 |
+
if ( $this->options[ 'filter_widgets' ] ) {
|
124 |
+
add_filter( 'widget_title', array( $this, 'filter_content' ), $priority );
|
125 |
+
add_filter( 'widget_text', array( $this, 'filter_content' ), $priority );
|
126 |
+
|
127 |
+
// Only if Widget Logic plugin is installed
|
128 |
+
// @todo Doesn't work and cannot find another way to filter all widget contents
|
129 |
+
//add_filter( 'widget_content', array( $this, 'filter_content' ), $priority );
|
130 |
+
}
|
131 |
+
}
|
132 |
}
|
133 |
}
|
134 |
|
143 |
}
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
/**
|
147 |
* Callback wp_head
|
148 |
*/
|
160 |
endif;
|
161 |
}
|
162 |
|
163 |
+
/**
|
164 |
+
* Filter complete html page
|
165 |
+
* @param array $match
|
166 |
+
* @return string
|
167 |
+
*/
|
168 |
+
function filter_page( $content ) {
|
169 |
+
$body_pattern = '/<body(.*?)>(.*?)<\/body[\s+]*>/is';
|
170 |
+
|
171 |
+
// only replace links in <body> part
|
172 |
+
return preg_replace_callback( $body_pattern, array( $this, '_callback_page_filter' ), $content );
|
173 |
+
}
|
174 |
+
|
175 |
+
function _callback_page_filter( $match ) {
|
176 |
+
return $this->filter_content( $match[ 0 ] );
|
177 |
+
}
|
178 |
+
|
179 |
/**
|
180 |
* Filter content
|
181 |
* @param string $content
|
182 |
* @return string
|
183 |
*/
|
184 |
function filter_content( $content ) {
|
185 |
+
$a_pattern = '/<a[^A-Za-z](.*?)>(.*?)<\/a[\s+]*>/is';
|
186 |
+
|
187 |
+
// replace links in body
|
188 |
$content = preg_replace_callback( $a_pattern, array( $this, 'parse_link' ), $content );
|
189 |
|
190 |
// remove style when no icon classes are found
|
191 |
if ( strpos( $content, 'ext-icon-' ) === FALSE ) {
|
192 |
// remove style with id wp-external-links-css
|
193 |
+
$content = preg_replace( '/<link(.*?)wp-external-links-css(.*?)\/>[\s+]*/i', '', $content );
|
194 |
}
|
195 |
|
196 |
return $content;
|
197 |
}
|
198 |
|
199 |
|
|
|
200 |
/**
|
201 |
* Make a clean <a> code
|
202 |
* @param array $match Result of a preg call in filter_content()
|
203 |
* @return string Clean <a> code
|
204 |
*/
|
205 |
function parse_link( $match ) {
|
206 |
+
$attrs = $match[ 1 ];
|
207 |
+
$attrs = stripslashes( $attrs );
|
208 |
+
$attrs = shortcode_parse_atts( $attrs );
|
209 |
|
210 |
$href_tolower = strtolower( $attrs[ 'href' ] );
|
211 |
$rel_tolower = ( isset( $attrs[ 'rel' ] ) ) ? strtolower( $attrs[ 'rel' ] ) : '';
|
305 |
}
|
306 |
})
|
307 |
.change();
|
308 |
+
|
309 |
+
// slide postbox
|
310 |
+
$( '.postbox' ).find( '.handlediv, .hndle' ).click(function(){
|
311 |
+
var $inside = $( this ).parent().find( '.inside' );
|
312 |
+
|
313 |
+
if ( $inside.css( 'display' ) == 'block' ) {
|
314 |
+
$inside.css({ display:'block' }).slideUp();
|
315 |
+
} else {
|
316 |
+
$inside.css({ display:'none' }).slideDown();
|
317 |
+
}
|
318 |
+
});
|
319 |
})
|
320 |
</script>
|
321 |
<div class="wrap">
|
465 |
<h4><img src="<?php echo plugins_url( 'images/icon-wp-mailto-links.png', __FILE__ ) ?>" width="16" height="16" /> WP Mailto Links</h4>
|
466 |
<p><?php _e( 'Manage mailto links on your site and protect emails from spambots, set mail icon and more.', $this->domain ) ?></p>
|
467 |
<ul>
|
468 |
+
<?php if ( is_plugin_active( 'wp-mailto-links/wp-mailto-links.php' ) ): ?>
|
469 |
+
<li><?php _e( 'This plugin is already activated.', $this->domain ) ?> <a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php _e( 'Settings' ) ?></a></li>
|
470 |
+
<?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php' ) ): ?>
|
471 |
+
<li><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e( 'Activate this plugin.', $this->domain ) ?></a></li>
|
472 |
+
<?php else: ?>
|
473 |
+
<li><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+Mailto+Links+freelancephp&plugin-search-input=Search+Plugins"><?php _e( 'Get this plugin now', $this->domain ) ?></a></li>
|
474 |
+
<?php endif; ?>
|
475 |
<li><a href="http://wordpress.org/extend/plugins/wp-mailto-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-mailto-links-plugin/" target="_blank">FreelancePHP.net</a></li>
|
476 |
</ul>
|
477 |
+
|
478 |
+
<h4><img src="<?php echo plugins_url( 'images/icon-email-encoder-bundle.png', __FILE__ ) ?>" width="16" height="16" /> Email Encoder Bundle</h4>
|
479 |
+
<p><?php _e( 'Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.', $this->domain ) ?></p>
|
480 |
+
<ul>
|
481 |
+
<?php if ( is_plugin_active( 'email-encoder-bundle/email-encoder-bundle.php' ) ): ?>
|
482 |
+
<li><?php _e( 'This plugin is already activated.', $this->domain ) ?> <a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/options-general.php?page=email-encoder-bundle/email-encoder-bundle.php"><?php _e( 'Settings' ) ?></a></li>
|
483 |
+
<?php elseif( file_exists( WP_PLUGIN_DIR . '/email-encoder-bundle/email-encoder-bundle.php' ) ): ?>
|
484 |
+
<li><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugins.php?plugin_status=inactive"><?php _e( 'Activate this plugin.', $this->domain ) ?></a></li>
|
485 |
+
<?php else: ?>
|
486 |
+
<li><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugin-install.php?tab=search&type=term&s=Email+Encoder+Bundle+freelancephp&plugin-search-input=Search+Plugins"><?php _e( 'Get this plugin now', $this->domain ) ?></a></li>
|
487 |
+
<?php endif; ?>
|
488 |
+
<li><a href="http://wordpress.org/extend/plugins/email-encoder-bundle/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/" target="_blank">FreelancePHP.net</a></li>
|
489 |
+
</ul>
|
490 |
</div>
|
491 |
</div>
|
492 |
</div>
|