loadHTML($buffer, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$dom->loadHTML($buffer);
// Remove Empty Headings
if ( $adarelief_emptyheadings ) {
$domwasneeded = true;
for ($ir = 1; $ir <= 6; $ir++) {
$headings = $dom->getElementsByTagName('h'.$ir);
for ($i = $headings->length; --$i >= 0; ) {
$heading = $headings->item($i);
if (str_ireplace(array(' ',' ','-','_'), '', trim(htmlentities(wp_strip_all_tags($heading->nodeValue)))) == "") {
$img = $heading->getElementsByTagName('img')->item(0);
if (!isset($img) || $img->getAttribute('alt') == "") {
adarelief_DOMRemove($heading);
}
}
}
}
}
// END Empty Headings
// Fix Missing Form Labels --DOM--
if ( $adarelief_addlabels ) {
$domwasneeded = true;
// EMPTY LABELS
$labels = $dom->getElementsByTagName('label');
for ($i = $labels->length; --$i >= 0; ) {
$label = $labels->item($i);
if ( $label->nodeValue == '') $label->parentNode->removeChild($label);
}
// END EMPTY LABELS
}
// PRO Fix Missing Form Labels --DOM--
// PRO END MISSING FORM LABELS
// Fix target Blank --DOM--
if ( $adarelief_remtargetblank ) {
$domwasneeded = true;
$alllinks = $dom->getElementsByTagName('a');
foreach ($alllinks as $theadalink) {
if ( strtolower($theadalink->getAttribute('target')) == strtolower("_blank")) {
$theadalinkaria = $theadalink->getAttribute('aria-label');
if (strpos(strtolower($theadalinkaria), 'new window') === false) {
$theadalinkaria .= ' (Opens in New Window)';
$theadalink->setAttribute('aria-label', $theadalinkaria);
}
}
}
} // End Target Blank
// Add Lang --DOM--
if ( $adarelief_lang ) {
$adarelief_langcode = get_option( 'adarelief_langcode');
if($adarelief_langcode != "") {
$domwasneeded = true;
$html = $dom->getElementsByTagName('html');
foreach ($html as $htmlcode) {
if ($htmlcode->getAttribute('lang') == "" and $htmlcode->getAttribute('xml:lang') == "")
$htmlcode->setAttribute('lang', $adarelief_langcode);
}
}
} // END Lang
if ($domwasneeded) {
$buffer = $dom->saveHTML();
}
// DO SOME REVOLUTION SLIDER FIXES
if ($adarelief_revsliddup) {
$buffer = str_replace( 'Oops...', 'Oops...', $buffer );
$buffer = str_replace( 'jQuery(sliderID).show().html(err);
}
}', 'jQuery(sliderID).show().html(err);
}
}', $buffer );
}
return $buffer;
}
function adarelief_change_justified_text($content){
$content = preg_replace( '/(text-)?align:\s?justify/i', 'text-align: '.'left', $content );
return $content;
}
function adarelief_make_alttags ( $buffer ) {
$adarelief_imgdec = get_option('adarelief_imgdec');
// Get The Page Title
preg_match('/
(.*?)\<\/title>/i',$buffer, $artitletouse);
// Get All Images
preg_match_all('/
/i',$buffer, $matches);
$adanr = 0;
foreach($matches[0] as $data ) {
$adanr++; // This is used to Fix the Closeing Images Alt Texts
// No Alt
if (!strpos( $data, 'alt=' )) {
// The image has title?
if (strpos( $data, 'title="' ) ) {
preg_match('/title="(.*?)"/i',$data, $arimgtitle);
$datanew = $data;
$imgwithalt = '
]+>(.*?)<\/a>/i',$buffer, $matches);
foreach($matches[0] as $data ) {
preg_match('/]+>(.*?)<\/a>/i',$data, $matches1);
// HighEnd Theme Compatibility
if ( $adarelief_highend ) {
$buffer = str_replace( '', 'Facebook', $buffer );
$buffer = str_replace( '', '', $buffer );
$buffer = str_replace( '', 'Mobile Menu Close', $buffer );
$buffer = str_replace( '', 'Close Fancy Search', $buffer );
$buffer = str_replace( '', 'Facebook', $buffer );
$buffer = str_replace( '', '', $buffer );
$buffer = str_replace( '', 'Feed', $buffer );
$buffer = str_replace( '', 'Foursquare', $buffer );
$buffer = str_replace( '', 'Instagram', $buffer );
$buffer = str_replace( '', 'Linkedin', $buffer );
$buffer = str_replace( '', 'Pinterest', $buffer );
$buffer = str_replace( '', 'Yelp', $buffer );
$buffer = str_replace( '', 'Vimeo', $buffer );
$buffer = str_replace( '', 'TripAdvisor', $buffer );
$buffer = str_replace( '', 'Youtube', $buffer );
} // END Highend Compatibility
// Combatibility with Call&Book Mobile Bar Plugin
if (strpos( $matches1[0], '' ) ) {
$datanew = $data;
$datanew = str_replace( '', 'Send Email', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
// Kallyas Compatibility
if (strpos( $matches1[1], 'glyphicon glyphicon-menu-left' ) ) {
if ( $adarelief_kallyas ) {
$datanew = $data;
$datanew = str_replace( 'class="glyphicon glyphicon-menu-left">', 'class="glyphicon glyphicon-menu-left">Slider Go Left', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
}
if (strpos( $matches1[1], 'glyphicon glyphicon-menu-right' ) ) {
if ( $adarelief_kallyas ) {
$datanew = $data;
$datanew = str_replace( 'class="glyphicon glyphicon-menu-right">', 'class="glyphicon glyphicon-menu-right">Slider Go Right', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
}
// End Kallyas Compatibility
// Has something inside?
// Do all the rest
if (!strpos( $matches1[1], 'aria-label' ) ) { // We Don't Do anything if Aria Label is present
// TO ADD EXTRACTION TEXTS FROM ARIA or TITLE
$datanew = $data;
$datanew = str_replace( '>', '>Link ', $datanew );
//$datanew = str_replace( '>', ' aria-label="This is a link">', $datanew );
//$datanew = str_replace( 'href=', 'aria-label="This is a link" href=', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
if (!strpos( $matches1[0], 'aria-label' ) ) { // We Don't Do anything if Aria Label is present
// TO ADD EXTRACTION TEXTS FROM ARIA or TITLE
$datanew = $data;
//$datanew = str_replace( '>', '>Link ', $datanew );
$datanew = str_replace( '>', '>Link ', $datanew );
//$datanew = str_replace( '>', ' aria-label="This is a link">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
/*
if ((!strpos( $matches1[0], 'aria-label' ) ) AND ($matches1[1] != '')) {
preg_match('/]+>(.*?)<\/span>/i',$data, $matches2);
if ($matches2[1] == '' ) {
$datanew = $data;
$datanew = str_replace( 'href=', 'aria-label="This is a link" href=', $datanew );
//$datanew = str_replace( '', '', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
}
*/
// HighEnd Theme Compatibility
if ( $adarelief_highend ) {
if (strpos( $matches1[0], '' ) ) {
$datanew = $data;
$datanew = str_replace( '', '', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
}
if ( $matches1[1] == '' ) {
// Avada Compatibility
if ( $adarelief_avada ) {
if (strpos( $data, 'tfs-scroll-down-indicator' ) ) {
$datanew = $data;
$datanew = str_replace( '>', '>Scroll Down', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
if (strpos( $data, 'fusion-page-load-link">' ) ) {
$datanew = $data;
$datanew = str_replace( 'fusion-page-load-link">', 'fusion-page-load-link">Page Load Link', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
}
// Kallyas Compatibility
else if ( $adarelief_kallyas ) {
if (strpos( $data, 'zn-res-trigger zn-header-icon' ) ) {
$datanew = $data;
$datanew = str_replace( '', '', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
}
// LETS ADD SOME SOCIAL PRE-DEFAULTS
if ((strpos( $data, 'facebook' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="Facebook">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'twitter' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="Twitter">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'foursquare' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="foursquare">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'google' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="google">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'instagram' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="instagram">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'linkedin' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="linkedin">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'pinterest' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="pinterest">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'youtube' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="youtube">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'vimeo' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="vimeo">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
else if ((strpos( $data, 'yelp' ) ) AND (!strpos( $data, 'aria-label' ) ) ) {
$datanew = $data;
$datanew = str_replace( '>', ' aria-label="yelp">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
}
// Do all the rest
else if (!strpos( $data, 'aria-label' ) ) { // We Don't Do anything if Aria Label is present
// TO ADD EXTRACTION TEXTS FROM ARIA or TITLE
$datanew = $data;
// $datanew = str_replace( '>', '>Link ', $datanew );
$datanew = str_replace( '>', ' aria-label="This is a link">', $datanew );
$buffer = str_replace( $data, $datanew, $buffer );
// Other Empty links to come
}
}
}
// Code For Google Recaptcha Empty Label
// $buffer = str_replace( 'CAPTCHA', 'CAPTCHA', $buffer );
return $buffer;
}
// PRO START SEARCH - REPLACE FUNCTION
// PRO END SEARCH - REPLACE FUNCTION
// PRO BROKEN ARIA MENU
// END BROKEN ARIA MENU
function adarelief_make_emptyheadings ( $buffer ) {
preg_match_all('|<\/h([1-6])>|i',$buffer, $matches);
foreach($matches as $data ) {
//if (( $data[2] == '' ) || ( $data[2] == null )){
// Let's Remove the Empty Headings
$buffer = str_replace( $data, '', $buffer );
// }
}
return $buffer;
}
function adarelief_rem_noscript ( $buffer ) {
preg_match_all('/