$tag_atts ) { foreach ( $tag_atts as $tag_att ) { $regexp = $this->get_pattern( $tag_name, $tag_att ); $content = preg_replace_callback( "/$regexp/siU", function ( $found ) use ( $link, $new_link, $tag_att ) { $old_link = untrailingslashit( trim( $found[2], '\'"' ) ); if ( $this->link_processor->links_match( $link, $old_link ) ) { // Replace only the attribute value, not the tag content or other attributes. return preg_replace( "#({$tag_att}=[\"|\'])" . $old_link . '/?(["|\'])#i', '\1' . $new_link . '\2', $found[0], 1 ); } return $found[0]; }, $content ); } } return $content; } }