hook_custom_css(); } public function css_tablet() { $this->hook_custom_css(); } public function css_mobile() { $this->hook_custom_css(); } private function hook_custom_css() { if (!self::$css_hooked) { self::$css_hooked = true; add_action('wp_head', [$this, 'renderCustomCSS'], 100); } } public function renderCustomCSS() { if (is_admin()) { return; } $all_css = Helper::get_option('css_all'); $tablet_css = Helper::get_option('css_tablet'); $mobile_css = Helper::get_option('css_mobile'); $output = ''; if (!empty($all_css)) { $output .= wp_strip_all_tags($all_css) . "\n"; } if (!empty($tablet_css)) { $output .= '@media (max-width: 1024px) {' . wp_strip_all_tags($tablet_css) . "}\n"; } if (!empty($mobile_css)) { $output .= '@media (max-width: 767px) {' . wp_strip_all_tags($mobile_css) . "}\n"; } $output = trim($output); if (!empty($output)) { echo '' . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } }