| 1 |
<?php |
| 2 |
// If this file is called directly, abort before emitting any document output. |
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
?> |
| 7 |
<!DOCTYPE html> |
| 8 |
<html <?php language_attributes(); ?>> |
| 9 |
<head> |
| 10 |
<meta charset="<?php bloginfo('charset'); ?>" /> |
| 11 |
<?php |
| 12 |
wp_head(); |
| 13 |
?> |
| 14 |
|
| 15 |
</head> |
| 16 |
<?php |
| 17 |
$post_id = get_the_ID(); |
| 18 |
$css_links = get_post_meta($post_id, 'css_links', true); |
| 19 |
$inline_css = get_post_meta($post_id, 'inline_css', true); |
| 20 |
$js_links = get_post_meta($post_id, 'js_links', true); |
| 21 |
|
| 22 |
$decode_meta_list = static function ($value) { |
| 23 |
if (is_array($value)) { |
| 24 |
return $value; |
| 25 |
} |
| 26 |
if (!is_string($value) || '' === $value) { |
| 27 |
return array(); |
| 28 |
} |
| 29 |
|
| 30 |
$decoded = json_decode($value, true); |
| 31 |
return is_array($decoded) ? $decoded : array(); |
| 32 |
}; |
| 33 |
|
| 34 |
foreach ($decode_meta_list($css_links) as $css_link) { |
| 35 |
if (is_string($css_link) && filter_var($css_link, FILTER_VALIDATE_URL) && 0 === strpos($css_link, 'http')) { |
| 36 |
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet -- Dynamic per-post CSS URLs from the user's page settings (css_links meta) must print in <head> of this bare custom-page template; enqueueing after wp_head() would relocate them to the footer. |
| 37 |
echo '<link href="' . esc_url($css_link) . '" rel="stylesheet"/>'; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
foreach ($decode_meta_list($inline_css) as $css) { |
| 42 |
if (is_string($css)) { |
| 43 |
// SECURITY FIX: Sanitize CSS to prevent XSS. |
| 44 |
$sanitized_css = wp_strip_all_tags($css); |
| 45 |
echo '<style>' . esc_html($sanitized_css) . '</style>'; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
foreach ($decode_meta_list($js_links) as $js_link) { |
| 50 |
if (is_string($js_link) && filter_var($js_link, FILTER_VALIDATE_URL) && 0 === strpos($js_link, 'http')) { |
| 51 |
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript -- Dynamic per-post JS URLs from the user's page settings (js_links meta) must print in <head> of this bare custom-page template; enqueueing after wp_head() would relocate them to the footer. |
| 52 |
echo '<script src="' . esc_url($js_link) . '"></script>'; |
| 53 |
} |
| 54 |
} |
| 55 |
?> |
| 56 |
|
| 57 |
<body class="text-gray-800 font-sans leading-normal gradient-bg postid-<?php echo esc_attr($post_id); ?>"> |
| 58 |
<?php |
| 59 |
$content = apply_filters('the_content', get_the_content()); |
| 60 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- the_content() passthrough in a blank page template; escaping would corrupt the document |
| 61 |
echo $content; |
| 62 |
?> |
| 63 |
</body> |
| 64 |
<?php |
| 65 |
wp_footer(); |
| 66 |
?> |
| 67 |
|
| 68 |
</html> |
| 69 |
|