/** * Return formatted headers. * * @param bool $display * @param string $content * The post type being added to the page * * @return string */ function getHeader($display = true, $content = '') { // bail early if (false == $display) { return ''; } // override $header = apply_filters('mpdf_get_header', $content); //sanitize $header = \PressBooks\Sanitize\filter_title($header); return $header; }
/** * Return formatted headers. * * @param string $context * The post type being added to the page * * @param array $page * The "page" content */ function getHeader($display = true, $content = '') { // bail early if (false == $display) { return ''; } // default is to print nothing if (empty($content)) { $header = ''; } else { $header = $content; } // override $header = apply_filters('mpdf_get_header', $content); //sanitize $header = \PressBooks\Sanitize\filter_title($header); return $header; }
/** * @covers \PressBooks\Sanitize\filter_title */ public function test_filter_title() { // Acceptable Tags: <br />, <span> with class, <em>, and <strong>. $test = '<h1><em>Hello</em><br/><strong>World!</strong></h1>'; $test = \PressBooks\Sanitize\filter_title($test); $this->assertEquals('<em>Hello</em><br /><strong>World!</strong>', $test); $test = '<span class="pb" style="font-weight:bold;"><i><b>Foobar</b></i></span><p /><div>Foobaz</div>'; $test = \PressBooks\Sanitize\filter_title($test); $this->assertEquals('<span class="pb">Foobar</span>Foobaz', $test); }