Completed
Push — add/pwa ( d2805e...9c2880 )
by
unknown
08:14
created

Jetpack_Perf_Optimize_HTML::end_buffer_html()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Slow but somewhat effective HTML compression.
5
 * TODO: only use if caching is detected - this probably doesn't make sense without it
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
6
 */
7
class Jetpack_Perf_Optimize_HTML {
8
	private static $__instance = null;
9
10
	/**
11
	 * Singleton implementation
12
	 *
13
	 * @return object
14
	 */
15
	public static function instance() {
16
		if ( ! is_a( self::$__instance, 'Jetpack_Perf_Optimize_HTML' ) ) {
17
			self::$__instance = new Jetpack_Perf_Optimize_HTML();
18
		}
19
20
		return self::$__instance;
21
	}
22
23
	private function __construct() {
24
		add_action( 'template_redirect', array( $this, 'begin_buffer_html' ) );
25
	}
26
27
	function begin_buffer_html() {
28
		ob_start( array( $this, 'end_buffer_html' ) );
29
	}
30
31
	function end_buffer_html( $content ) {
32
		require_once dirname( __FILE__ ) . '/external/HTML.php';
33
		return Minify_HTML::minify( $content );
34
	}
35
}