PluginProbe
Autoptimize / 3.1.4
Autoptimize v3.1.4
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
← All changes | classes/autoptimizeHTML.php +28 -1 2.4.13.1.4 View file →
@@ -16,8 +16,22 @@
16 16 */
17 17 private $keepcomments = false;
18 18
19 19 /**
20 + * Whether inline CSS/ JS is minified.
21 + *
22 + * @var bool
23 + */
24 + private $minify_inline = false;
25 +
26 + /**
27 + * Whether to force xhtml compatibility.
28 + *
29 + * @var bool
30 + */
31 + private $forcexhtml = false;
32 +
33 + /**
20 34 * Things to exclude from being minifed.
21 35 *
22 36 * @var array
23 37 */
@@ -34,8 +48,11 @@
34 48
35 49 // Filter to force xhtml.
36 50 $this->forcexhtml = (bool) apply_filters( 'autoptimize_filter_html_forcexhtml', false );
37 51
52 + // minify inline JS/ CSS.
53 + $this->minify_inline = (bool) apply_filters( 'autoptimize_html_minify_inline_js_css', $options['minify_inline'] );
54 +
38 55 // Filterable strings to be excluded from HTML minification.
39 56 $exclude = apply_filters( 'autoptimize_filter_html_exclude', '' );
40 57 if ( '' !== $exclude ) {
41 58 $exclude_arr = array_filter( array_map( 'trim', explode( ',', $exclude ) ) );
@@ -74,9 +91,19 @@
74 91 if ( $this->forcexhtml ) {
75 92 $options['xhtml'] = true;
76 93 }
77 94
78 - $tmp_content = Minify_HTML::minify( $this->content, $options );
95 + // Optionally minify inline JS & CSS.
96 + if ( $this->minify_inline ) {
97 + if ( false != autoptimizeOptionWrapper::get_option( 'autoptimize_js' ) && false != autoptimizeConfig::get_post_meta_ao_settings( 'ao_post_js_optimize' ) && true !== apply_filters( 'autoptimize_filter_js_noptimize', false, $this->content ) && false === strpos( $this->content, 'text/template' ) ) {
98 + $options['jsMinifier'] = 'JSMin::minify';
99 + }
100 + if ( false != autoptimizeOptionWrapper::get_option( 'autoptimize_css' ) && false != autoptimizeConfig::get_post_meta_ao_settings( 'ao_post_css_optimize' ) && true !== apply_filters( 'autoptimize_filter_css_noptimize', false, $this->content ) ) {
101 + $options['cssMinifier'] = 'autoptimizeCSSmin::minify';
102 + }
103 + }
104 +
105 + $tmp_content = AO_Minify_HTML::minify( $this->content, $options );
79 106 if ( ! empty( $tmp_content ) ) {
80 107 $this->content = $tmp_content;
81 108 unset( $tmp_content );
82 109 }