PluginProbe
WP EXtra – One Click Optimize / 8.0
WP EXtra – One Click Optimize v8.0
8.7.1 8.6.8 8.7.0 trunk 5.9 8.0 8.5.0 8.5.4 8.5.5 8.6.0 8.6.1 8.6.2 8.6.3 8.6.5
wp-extra / src / Modules / WPEX_Code.php

WPEX_Code.php in WP EXtra – One Click Optimize 8.0, at src/Modules/WPEX_Code.php

61 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPEXtra\Modules;
4
5 use WPEXtra\Core\ClassEXtra;
6
7 class WPEX_Code {
8
9 public function __construct() {
10 if(wp_extra_get_option('code_header')) {
11 add_action('wp_head', [$this, 'insertHeaderCode']);
12 }
13 if(function_exists('wp_body_open') && version_compare(get_bloginfo('version'), '5.2' , '>=') && wp_extra_get_option('code_body')) {
14 add_action('wp_body_open', [$this, 'insertBodyCode']);
15 }
16 if(wp_extra_get_option('code_footer')) {
17 add_action('wp_footer', [$this, 'insertFooterCode']);
18 }
19 if(wp_extra_get_option('css_all') || wp_extra_get_option('css_tablet') || wp_extra_get_option('css_mobile')) {
20 add_action('wp_footer', [$this, 'insertCustomCSS'], 100 );
21 }
22 }
23
24 public function insertHeaderCode() {
25 echo wp_unslash(wp_extra_get_option('code_header')); // @codingStandardsIgnoreLine.
26 }
27
28 public function insertBodyCode() {
29 echo wp_unslash(wp_extra_get_option('code_body')); // @codingStandardsIgnoreLine.
30 }
31
32 public function insertFooterCode() {
33 echo wp_unslash(wp_extra_get_option('code_footer')); // @codingStandardsIgnoreLine.
34 }
35
36 public function insertCustomCSS() {
37 ob_start();
38 ?>
39 <style id="extra-css" type="text/css">
40 <?php
41 if(wp_extra_get_option('css_all')) {
42 echo wp_strip_all_tags(wp_extra_get_option('css_all')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
43 }
44 if(wp_extra_get_option('css_tablet')) {
45 echo '@media (max-width: 849px){';
46 echo wp_strip_all_tags(wp_extra_get_option('css_tablet')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
47 echo '}';
48 }
49 if(wp_extra_get_option('css_mobile')) {
50 echo '@media (max-width: 549px){';
51 echo wp_strip_all_tags(wp_extra_get_option('css_mobile')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
52 echo '}';
53 } ?>
54 </style>
55 <?php
56 $css = ob_get_clean();
57 $minify = ClassEXtra::instance();
58 echo $minify->minify_css($css);
59 }
60 }
61