<?php
/* ------------------------------------------------------------------------- *
 *  Dynamic styles
/* ------------------------------------------------------------------------- */
/*  Convert hexadecimal to rgb
/* ------------------------------------ */
if (!function_exists('notomag_hex2rgb')) {
    function notomag_hex2rgb($colour, $opacity = 1)
    {
        if ($colour[0] == '#') {
            $colour = substr($colour, 1);
        }
        if (strlen($colour) == 6) {
            list($r, $g, $b) = array($colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5]);
        } elseif (strlen($colour) == 3) {
            list($r, $g, $b) = array($colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2]);
        } else {
            return false;
        }
        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);
        return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $opacity . ')';
    }
}
if (!function_exists('notomag_get_inline_css')) :
    /**
     * Outputs theme custom CSS.
     *
     * @since 1.0.0
     */
    function notomag_get_inline_css()
    {
        $defaults = notomag_get_all_customizer_default_values();
        $background_color = get_theme_mod('background_color');

        $notomag_site_logo_height = notomag_get_option('notomag_site_logo_height');

        ob_start();
        ?>
        <?php if (!empty($background_color) && $background_color != 'ffffff') :
        ?>
        :root {
        --wpi--base-bg-color: #<?php echo esc_attr($background_color); ?>;
        }
    <?php endif; ?>

        <?php if ($notomag_site_logo_height !== $defaults['notomag_site_logo_height']) : ?>
        .site-logo img {
        height:<?php echo absint($notomag_site_logo_height); ?>px;
        }
    <?php endif; ?>
        <?php
        return ob_get_clean();
    }
endif;
