Created
October 17, 2018 13:46
-
-
Save sareiodata/0457992ed986da8fcd4bd933ff90908e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('trp_before_translate_content', 'trpc_fix_html_attributes_without_spaces'); | |
function trpc_fix_html_attributes_without_spaces($output){ | |
$size = strlen($output); | |
$pos = 0; | |
$pos_c = 0; | |
while ($pos_c < $size){ | |
$len = strcspn($output, '<' , $pos); | |
$pos += $len; | |
$len_c = strcspn($output, '>' , $pos); | |
$pos_c += $len_c; | |
$even_detection_apostrophe = 0; | |
$even_detection_quote = 0; | |
for ($i = $pos; $i < $pos_c; $i++){ | |
$char = $output[$i]; //next | |
if ($char == '"' ){ | |
$even_detection_quote ++; | |
if ( $even_detection_quote % 2 == 0){ | |
$output = substr_replace( $output, ' ', $i+1, 0 ); | |
} | |
} | |
if ($char == "'" ){ | |
$even_detection_apostrophe ++; | |
if ( $even_detection_apostrophe % 2 == 0){ | |
$output = substr_replace( $output, ' ', $i+1, 0 ); | |
} | |
} | |
} | |
$pos_c ++; | |
$pos = $pos_c; | |
} | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment