Skip to content

Instantly share code, notes, and snippets.

@tristanlins
Created April 24, 2014 09:27
Show Gist options
  • Save tristanlins/11248038 to your computer and use it in GitHub Desktop.
Save tristanlins/11248038 to your computer and use it in GitHub Desktop.
<?php
class Hooks
{
public function outputFrontendTemplate($buffer)
{
$buffer = preg_replace_callback(
'~class="([^"]+)"~',
function ($matches) {
$classes = explode(' ', $matches[1]);
$classes = array_filter($classes);
$index = array_search('invisible', $classes);
if ($index !== false) {
$classes[$index] = 'sr-only';
}
return sprintf('class="%s"', implode(' ', $classes));
},
$buffer
);
return $buffer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment