Created
October 18, 2018 07:01
-
-
Save cedwardsmedia/b589740d47fb57c9113f30c917269a80 to your computer and use it in GitHub Desktop.
Modified Kirby CMS index.php passing rendered page through HTML Tidy via PHP HTML Tidy functions
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
<?php | |
define('DS', DIRECTORY_SEPARATOR); | |
// load kirby | |
require(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php'); | |
// check for a custom site.php | |
if(file_exists(__DIR__ . DS . 'site.php')) { | |
require(__DIR__ . DS . 'site.php'); | |
} else { | |
$kirby = kirby(); | |
} | |
$config = array( | |
'indent' => true, | |
'indent-spaces' => '5', | |
'quote-ampersand' => true, | |
'quote-marks' => true, | |
'indent-cdata' => true, | |
'enclose-text' => true, | |
'vertical-space' => true, | |
'sort-attributes' => 'alpha', | |
'wrap' => '80', | |
'output-html' => true, | |
'break-before-br' => true, | |
'markup' => true, | |
'write-back' => true, | |
'wrap-script-literals' => true, | |
'wrap-sections' => true, | |
'quiet' => true, | |
'error-file' => 'tidy.log'); | |
/* Pass the kirby rendering ($kirby->launch()) | |
through HTML Tidy before sending to client */ | |
$tidy = new tidy(); | |
$tidy->parseString($kirby->launch(), $config, 'utf8'); | |
$tidy->cleanRepair(); | |
echo tidy_get_output($tidy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment