| 1 |
<!DOCTYPE html> |
| 2 |
<html <?php language_attributes(); ?>> |
| 3 |
<head> |
| 4 |
<meta charset="<?php bloginfo('charset'); ?>" /> |
| 5 |
<?php |
| 6 |
// If this file is called directly, abort. |
| 7 |
if (!defined('ABSPATH')) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
wp_head(); |
| 11 |
?> |
| 12 |
|
| 13 |
</head> |
| 14 |
<?php |
| 15 |
// get the post ID |
| 16 |
$post_id = get_the_ID(); |
| 17 |
// get post meta data for css_links |
| 18 |
$css_links = get_post_meta($post_id, 'css_links', true); |
| 19 |
// get post meta data for inline_css |
| 20 |
$inline_css = get_post_meta($post_id, 'inline_css', true); |
| 21 |
// get post meta data for js_links |
| 22 |
$js_links = get_post_meta($post_id, 'js_links', true); |
| 23 |
// get post meta data for inline_js |
| 24 |
$inline_js = get_post_meta($post_id, 'inline_js', true); |
| 25 |
// check if the key css_links exist |
| 26 |
if($css_links!==''){ |
| 27 |
// Loop through all the css link |
| 28 |
$decoded_css_links = json_decode($css_links); |
| 29 |
if (is_array($decoded_css_links)) { |
| 30 |
foreach ($decoded_css_links as $css_link) { |
| 31 |
// SECURITY FIX: Validate and escape CSS URLs |
| 32 |
if (filter_var($css_link, FILTER_VALIDATE_URL) && (strpos($css_link, 'http') === 0)) { |
| 33 |
echo '<link href="' . esc_url($css_link) . '" rel="stylesheet"/>'; |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
// check if the key inline_css exist |
| 39 |
if($inline_css!==''){ |
| 40 |
// Loop through all the inline css and print it |
| 41 |
$decoded_inline_css = json_decode($inline_css); |
| 42 |
if (is_array($decoded_inline_css)) { |
| 43 |
foreach ($decoded_inline_css as $css) { |
| 44 |
// SECURITY FIX: Sanitize CSS to prevent XSS |
| 45 |
$sanitized_css = wp_strip_all_tags($css); |
| 46 |
echo '<style>' . esc_html($sanitized_css) . '</style>'; |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
// check if the key js_links exist |
| 51 |
$js_links_decoded = !empty($js_links) ? json_decode($js_links) : null; |
| 52 |
if(is_array($js_links_decoded)){ |
| 53 |
// Loop through all the js link and print it script tags |
| 54 |
$decoded_js_links = json_decode($js_links); |
| 55 |
if (is_array($decoded_js_links)) { |
| 56 |
foreach ($decoded_js_links as $js_link) { |
| 57 |
// SECURITY FIX: Validate and escape JS URLs |
| 58 |
if (filter_var($js_link, FILTER_VALIDATE_URL) && (strpos($js_link, 'http') === 0)) { |
| 59 |
echo '<script src="' . esc_url($js_link) . '"></script>'; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
?> |
| 65 |
|
| 66 |
<body class="text-gray-800 font-sans leading-normal gradient-bg postid-<?= esc_attr($post_id) ?>"> |
| 67 |
<?php |
| 68 |
// get content of the post |
| 69 |
$content = apply_filters('the_content', get_the_content()); |
| 70 |
echo $content; |
| 71 |
?> |
| 72 |
</body> |
| 73 |
<?php |
| 74 |
wp_footer(); |
| 75 |
// check if the key inline_js exist |
| 76 |
$inline_js_decoded = !empty($inline_js) ? json_decode($inline_js) : null; |
| 77 |
if(is_array($inline_js_decoded)){ |
| 78 |
// Loop through all the inline script and print the script tags after body |
| 79 |
$decoded_inline_js = json_decode($inline_js); |
| 80 |
if (is_array($decoded_inline_js)) { |
| 81 |
foreach ($decoded_inline_js as $js) { |
| 82 |
// SECURITY FIX: Completely block inline JS to prevent XSS |
| 83 |
// This feature is disabled for security reasons |
| 84 |
error_log('MetaSync Security: Inline JS blocked for security - content: ' . substr($js, 0, 100)); |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
?> |
| 90 |
|
| 91 |
</html> |