Skip to content

Commit

Permalink
Fix ampersand conversion in links
Browse files Browse the repository at this point in the history
  • Loading branch information
mihdan committed May 3, 2023
1 parent 6fe128a commit 9b8d3bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions mihdan-no-external-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Mihdan: No External Links
* Plugin URI: https://wordpress.org/plugins/mihdan-no-external-links/
* Description: Convert external links into internal links, site wide or post/page specific. Add NoFollow, Click logging, and more...
* Version: 5.0.6
* Version: 5.0.7
* Author: Mikhail Kobzarev
* Author URI: https://www.kobzarev.com/
* License: GPL-2.0+
Expand All @@ -28,7 +28,7 @@
}

const MIHDAN_NO_EXTERNAL_LINKS_DIR = __DIR__;
const MIHDAN_NO_EXTERNAL_LINKS_VERSION = '5.0.6';
const MIHDAN_NO_EXTERNAL_LINKS_VERSION = '5.0.7';
const MIHDAN_NO_EXTERNAL_LINKS_SLUG = 'mihdan-no-external-links';

define( 'MIHDAN_NO_EXTERNAL_LINKS_BASENAME', plugin_basename( __FILE__ ) );
Expand Down
2 changes: 1 addition & 1 deletion public/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function mask_link( $matches ): string {

preg_match( '/class="([^"]+)"/si', $attributes, $maybe_classes );

if ( $maybe_classes[1] ) {
if ( ! empty( $maybe_classes[1] ) ) {
$classes .= ' ' . $maybe_classes[1];
}

Expand Down
34 changes: 14 additions & 20 deletions public/js/seo-hide.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,20 @@
}
);

function basePropertyOf( object ) {
return function ( key ) {
return object == null ? undefined : object[ key ];
};
}

var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
reHasEscapedHtml = RegExp( reEscapedHtml.source ),
htmlUnescapes = {
'&': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&#39;': "'"
},
unescapeHtmlChar = basePropertyOf( htmlUnescapes );

/**
* Decode HTML entities.
*
* Example:
* - &#038; -> &
* - &amp; -> &
*
* @param text String for decoding.
* @returns {string}
*/
function decodeHTMLEntities( text ) {
return ( text && reHasEscapedHtml.test( text ) )
? text.replace( reEscapedHtml, unescapeHtmlChar )
: text;
const textArea = document.createElement( 'textarea' );
textArea.innerHTML = text;

return textArea.value;
}
} )( window, document );
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: mihdan, kaggdesign
Tags: seo, seo-hide, link, links, publisher, post, posts, comments
Requires at least: 5.7.4
Tested up to: 6.2
Stable tag: 5.0.6
Stable tag: 5.0.7
Requires PHP: 7.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -63,7 +63,11 @@ Mihdan: No External Links **does not** make any changes to your database, it jus

== Changelog ==

= 5.0.6 (03.05.2023) =
= 5.0.7 (03.05.2023) =
* Fixed ampersand conversion in links
* Fixed PHP notices

= 5.0.6 (02.05.2023) =
* Resolve #[20](https://github.com/mihdan/mihdan-no-external-links/issues/20)
* Resolve #[25](https://github.com/mihdan/mihdan-no-external-links/issues/25)
* Resolve #[30](https://github.com/mihdan/mihdan-no-external-links/issues/30)
Expand Down

0 comments on commit 9b8d3bd

Please sign in to comment.