| @@ -1,14 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | -if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
| 2 | +if (!defined('ABSPATH')) { exit; // Exit if accessed directly | |
| 3 | +} | |
| 3 | 4 | /** |
| 4 | 5 | * @var string $title |
| 5 | 6 | * @var string $description |
| 6 | 7 | * @var string $url |
| 8 | + * @var string $og_title | |
| 7 | 9 | * @var string $featured_image |
| 10 | + * @var string $theme_color | |
| 8 | 11 | * @var string $landing_route |
| 9 | 12 | * @var bool $isHeadless |
| 10 | 13 | */ |
| 14 | +$fluentCommunityOgTitle = $og_title ?? ''; | |
| 15 | +$fluentCommunityThemeColor = $theme_color ?? ''; | |
| 11 | 16 | ?> |
| 12 | 17 | <!DOCTYPE html> |
| 13 | 18 | <html <?php language_attributes(); ?><?php echo !empty($html_class) ? ' class="' . esc_attr($html_class) . '"' : ''; ?>> |
| 14 | 19 | <head> |
| @@ -17,14 +22,19 @@ | ||
| 17 | 22 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=2.0,user-scalable=yes,viewport-fit=cover"/> |
| 18 | 23 | <meta name="mobile-web-app-capable" content="yes"> |
| 19 | 24 | <?php if (!$isHeadless) : wp_head(); else: ?> |
| 20 | 25 | <meta name="description" content="<?php echo esc_attr($description); ?>"> |
| 21 | - <link rel="icon" type="image/x-icon" href="<?php echo esc_url(get_site_icon_url()); ?>"/> | |
| 22 | - <link rel="apple-touch-icon" href="<?php echo esc_url(get_site_icon_url()); ?>"/> | |
| 26 | + <?php $fluentCommunitySiteIcon = get_site_icon_url(); ?> | |
| 27 | + <?php if ($fluentCommunitySiteIcon): ?> | |
| 28 | + <link rel="icon" type="image/x-icon" href="<?php echo esc_url($fluentCommunitySiteIcon); ?>"/> | |
| 29 | + <?php if (apply_filters('fluent_community/render_default_touch_icon', true)): ?> | |
| 30 | + <link rel="apple-touch-icon" href="<?php echo esc_url($fluentCommunitySiteIcon); ?>"/> | |
| 31 | + <?php endif; ?> | |
| 32 | + <?php endif; ?> | |
| 23 | 33 | <meta property="og:type" content="website"> |
| 24 | 34 | <meta property="og:url" content="<?php echo esc_url($url); ?>"> |
| 25 | 35 | <meta property="og:site_name" content="<?php bloginfo('name'); ?>"> |
| 26 | - <meta property="og:title" content="<?php echo esc_attr($og_title); ?>"> | |
| 36 | + <meta property="og:title" content="<?php echo esc_attr($fluentCommunityOgTitle); ?>"> | |
| 27 | 37 | <meta property="og:description" content="<?php echo esc_attr($description); ?>"> |
| 28 | 38 | <?php if ($featured_image): ?> |
| 29 | 39 | <meta property="og:image" content="<?php echo esc_url($featured_image); ?>"> |
| 30 | 40 | <meta name="twitter:image" content="<?php echo esc_url($featured_image); ?>"> |
| @@ -29,9 +39,9 @@ | ||
| 29 | 39 | <meta property="og:image" content="<?php echo esc_url($featured_image); ?>"> |
| 30 | 40 | <meta name="twitter:image" content="<?php echo esc_url($featured_image); ?>"> |
| 31 | 41 | <?php endif; ?> |
| 32 | 42 | <meta name="twitter:card" content="summary"> |
| 33 | - <meta name="theme-color" content="<?php echo esc_attr($theme_color); ?>"> | |
| 43 | + <meta name="theme-color" content="<?php echo esc_attr($fluentCommunityThemeColor); ?>"> | |
| 34 | 44 | <?php do_action('fluent_community/portal_head_meta', $landing_route); ?> |
| 35 | 45 | |
| 36 | 46 | <?php if(!empty($canonical_url)): ?> |
| 37 | 47 | <link rel="canonical" href="<?php echo esc_url($canonical_url); ?>"> |
| @@ -36,26 +46,16 @@ | ||
| 36 | 46 | <?php if(!empty($canonical_url)): ?> |
| 37 | 47 | <link rel="canonical" href="<?php echo esc_url($canonical_url); ?>"> |
| 38 | 48 | <?php endif; ?> |
| 39 | 49 | |
| 40 | - <?php if(!empty($json_ld)): ?><script type="application/ld+json"><?php echo json_encode($json_ld); ?></script> | |
| 50 | + <?php if(!empty($json_ld)): ?><script type="application/ld+json"><?php echo wp_json_encode($json_ld, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?></script> | |
| 41 | 51 | <?php endif; ?> |
| 42 | 52 | <?php endif; ?> |
| 43 | 53 | |
| 44 | 54 | |
| 45 | - <script type="text/javascript"> | |
| 46 | - (function() { | |
| 47 | - const colorPref = localStorage.getItem('fcom_global_storage'); | |
| 48 | - if(colorPref) { | |
| 49 | - const colorPrefObj = JSON.parse(colorPref); | |
| 50 | - if(colorPrefObj && colorPrefObj.colorScheme === 'dark') { | |
| 51 | - document.documentElement.classList.add('dark'); | |
| 52 | - // set data-color-mode attribute for better css handling | |
| 53 | - document.documentElement.setAttribute('data-color-mode', 'dark'); | |
| 54 | - } | |
| 55 | - } | |
| 56 | - })(); | |
| 57 | - </script> | |
| 55 | + <?php if (\FluentCommunity\App\Services\Helper::hasColorScheme()): ?> | |
| 56 | + <?php \FluentCommunity\App\Services\Helper::renderColorSchemePrePaintScript(); ?> | |
| 57 | + <?php endif; ?> | |
| 58 | 58 | |
| 59 | 59 | <?php if (\FluentCommunity\App\Services\Helper::isRtl()): ?> |
| 60 | 60 | <style> |
| 61 | 61 | body { |