PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
plugins
/
admin-site-enhancements
/
classes
<?php namespace ASENHA\Classes; /** * Class for Open All External Links in New Tab module * * @since 6.9.5 */ class Open_External_Links_In_New_Tab { /** * Parse links in content to add target="_blank" rel="noopener noreferrer nofollow" attributes * * @since 4.9.0 */ public function add_target_and_rel_atts_to_content_links( $content ) { if ( ! empty( $content ) ) { // regex pattern for "a href" $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>"; if ( preg_match_all( "/$regexp/siU", $content, $matches, PREG_SET_ORDER ) ) { // $matches might contain parts of $content that has links (a href) preg_match_all( "/$regexp/siU", $content, $matches, PREG_SET_ORDER ); if ( is_array( $matches ) ) { $i = 0; foreach ( $matches as $match ) { $original_tag = $match[0]; // e.g. <a title="Link Title" href="http://www.example.com/sit-quaerat"> $tag = $match[0]; // Same value as $original_tag but for further processing $url = $match[2]; // e.g. http://www.example.com/sit-quaerat if ( false !== strpos( $url, get_site_url() ) ) { // Internal link. Do nothing. } elseif ( false === strpos( $url, 'http' ) ) { // Relative link to internal URL. Do nothing. } else { // External link. Let's do something. // Regex pattern for target="_blank|parent|self|top" $pattern = '/target\s*=\s*"\s*_(blank|parent|self|top)\s*"/'; // If there's no 'target="_blank|parent|self|top"' in $tag, add target="blank" if ( 0 === preg_match( $pattern, $tag ) ) { // Replace closing > with ' target="_blank">' $tag = substr_replace( $tag, ' target="_blank">', -1 ); } // If there's no 'rel' attribute in $tag, add rel="noopener noreferrer nofollow" $pattern = '/rel\s*=\s*\"[a-zA-Z0-9_\s]*\"/'; if ( 0 === preg_match( $pattern, $tag ) ) { // Replace closing > with ' rel="noopener noreferrer nofollow">' $tag = substr_replace( $tag, ' rel="noopener noreferrer nofollow">', -1 ); } else { // replace rel="noopener" with rel="noopener noreferrer nofollow" if ( false !== strpos( $tag, 'noopener' ) && false === strpos( $tag, 'noreferrer' ) && false === strpos( $tag, 'nofollow' ) ) { $tag = str_replace( 'noopener', 'noopener noreferrer nofollow', $tag ); } } // Replace original a href tag with one containing target and rel attributes above $content = str_replace( $original_tag, $tag, $content ); } $i++; } } } } return $content; } }
[-] class-hide-admin-bar.php
[edit]
[-] class-svg-upload.php
[edit]
[-] class-disable-gutenberg.php
[edit]
[-] class-cleanup-admin-bar.php
[edit]
[-] class-disable-rest-api.php
[edit]
[-] class-multiple-user-roles.php
[edit]
[-] class-disable-updates.php
[edit]
[-] class-image-upload-control.php
[edit]
[-] class-hide-admin-notices.php
[edit]
[-] class-content-duplication.php
[edit]
[-] class-insert-head-body-footer-code.php
[edit]
[-] class-media-replacement.php
[edit]
[-] class-password-protection.php
[edit]
[-] class-heartbeat-control.php
[edit]
[-] class-email-address-obfuscator.php
[edit]
[-] class-settings-sanitization.php
[edit]
[-] class-wp-config-transformer.php
[edit]
[-] class-content-order.php
[edit]
[-] class-custom-css.php
[edit]
[-] class-enhance-list-tables.php
[edit]
[-] class-login-logout-menu.php
[edit]
[-] class-search-engines-visibility.php
[edit]
[-] class-limit-login-attempts.php
[edit]
[-] class-disable-xml-rpc.php
[edit]
[-] class-common-methods.php
[edit]
[-] class-email-delivery.php
[edit]
[-] class-obfuscate-author-slugs.php
[edit]
[-] class-external-permalinks.php
[edit]
[-] class-wider-admin-menu.php
[edit]
[-] class-display-system-summary.php
[edit]
[-] class-admin-menu-organizer.php
[edit]
[-] class-redirect-fourofour.php
[edit]
[-] class-manage-robots-txt.php
[edit]
[-] class-site-identity-on-login-page.php
[edit]
[-] class-avif-upload.php
[edit]
[-] class-disable-comments.php
[edit]
[-] class-manage-ads-appads-txt.php
[edit]
[-] class-various-admin-ui-enhancements.php
[edit]
[-] class-admin-menu-svg-icon-mask.php
[edit]
[-] class-deactivation.php
[edit]
[-] class-activation.php
[edit]
[-] class-view-admin-as-role.php
[edit]
[-] class-maintenance-mode.php
[edit]
[-] class-custom-body-class.php
[edit]
[-] class-disable-dashboard-widgets.php
[edit]
[-] class-login-id-type.php
[edit]
[-] class-image-sizes-panel.php
[edit]
[-] class-redirect-after-login.php
[edit]
[-] class-settings-sections-fields.php
[edit]
[-] class-auto-publish-posts-with-missed-schedule.php
[edit]
[-] class-revisions-control.php
[edit]
[+]
..
[-] class-registration-date-column.php
[edit]
[-] class-disable-embeds.php
[edit]
[-] class-show-custom-taxonomy-filters.php
[edit]
[-] class-custom-nav-menu-items-in-new-tab.php
[edit]
[-] class-disable-feeds.php
[edit]
[-] class-captcha-protection.php
[edit]
[-] class-custom-admin-footer-text.php
[edit]
[-] class-change-login-url.php
[edit]
[-] class-last-login-column.php
[edit]
[-] class-settings-fields-render.php
[edit]
[-] class-disable-smaller-components.php
[edit]
[-] class-disable-author-archives.php
[edit]
[-] class-redirect-after-logout.php
[edit]
[-] class-open-external-links-in-new-tab.php
[edit]