2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// HEX TO RGB
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! function_exists( 'fictioneer_hex_to_rgb' ) ) {
|
|
|
|
/**
|
|
|
|
* Convert hex colors to RGB
|
|
|
|
*
|
|
|
|
* @license MIT
|
|
|
|
* @author Simon Waldherr https://github.com/SimonWaldherr
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.7.0
|
2023-01-21 01:31:34 +01:00
|
|
|
* @link https://github.com/SimonWaldherr/ColorConverter.php
|
|
|
|
*
|
2023-08-20 01:04:49 +02:00
|
|
|
* @param string $input The to be converted hex (six digits).
|
|
|
|
*
|
|
|
|
* @return array RGB values as array.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_hex_to_rgb( $input ) {
|
|
|
|
if ( substr( trim( $input ), 0, 1 ) === '#' ) {
|
|
|
|
$input = substr( $input, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( strlen( $input ) < 2) || ( strlen( $input ) > 6 ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = str_split( $input );
|
|
|
|
|
|
|
|
if ( strlen( $input ) === 2 ) {
|
|
|
|
$r = intval( $values[0] . $values[1], 16 );
|
|
|
|
$g = $r;
|
|
|
|
$b = $r;
|
|
|
|
} else if ( strlen( $input ) === 3 ) {
|
|
|
|
$r = intval( $values[0], 16 );
|
|
|
|
$g = intval( $values[1], 16 );
|
|
|
|
$b = intval( $values[2], 16 );
|
|
|
|
} else if ( strlen( $input ) === 6 ) {
|
|
|
|
$r = intval( $values[0] . $values[1], 16 );
|
|
|
|
$g = intval( $values[2] . $values[3], 16 );
|
|
|
|
$b = intval( $values[4] . $values[5], 16 );
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return array( $r, $g, $b );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// RGB TO HSL
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! function_exists( 'fictioneer_rgb_to_hsl' ) ) {
|
|
|
|
/**
|
|
|
|
* Convert RGB colors to HSL
|
|
|
|
*
|
|
|
|
* @license MIT
|
|
|
|
* @author Simon Waldherr https://github.com/SimonWaldherr
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.7.0
|
2023-01-21 01:31:34 +01:00
|
|
|
* @link https://github.com/SimonWaldherr/ColorConverter.php
|
|
|
|
*
|
2023-08-20 01:04:49 +02:00
|
|
|
* @param array $input The to be converted RGB.
|
|
|
|
* @param int $precision Rounding precision. Default 0.
|
|
|
|
*
|
|
|
|
* @return array HSL values as array.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_rgb_to_hsl( $input, $precision = 0 ) {
|
|
|
|
$r = max( min( intval( $input[0], 10 ) / 255, 1 ), 0 );
|
|
|
|
$g = max( min( intval( $input[1], 10 ) / 255, 1 ), 0 );
|
|
|
|
$b = max( min( intval( $input[2], 10 ) / 255, 1 ), 0 );
|
|
|
|
$max = max( $r, $g, $b );
|
|
|
|
$min = min( $r, $g, $b );
|
|
|
|
$l = ( $max + $min ) / 2;
|
|
|
|
|
|
|
|
if ( $max !== $min ) {
|
|
|
|
$d = $max - $min;
|
|
|
|
$s = $l > 0.5 ? $d / ( 2 - $max - $min ) : $d / ( $max + $min );
|
|
|
|
if ( $max === $r ) {
|
|
|
|
$h = ( $g - $b ) / $d + ( $g < $b ? 6 : 0 );
|
|
|
|
} else if ( $max === $g ) {
|
|
|
|
$h = ( $b - $r ) / $d + 2;
|
|
|
|
} else {
|
|
|
|
$h = ( $r - $g ) / $d + 4;
|
|
|
|
}
|
|
|
|
$h = $h / 6;
|
|
|
|
} else {
|
|
|
|
$h = $s = 0;
|
|
|
|
}
|
|
|
|
return [round( $h * 360, $precision ), round( $s * 100, $precision ), round( $l * 100, $precision )];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// GENERATE CSS CLAMP
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! function_exists( 'fictioneer_get_css_clamp' ) ) {
|
|
|
|
/**
|
2023-08-20 01:04:49 +02:00
|
|
|
* Generate a high-precision CSS clamp
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.7.0
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2023-08-20 01:04:49 +02:00
|
|
|
* @param int $min The minimum value.
|
|
|
|
* @param int $max The maximum value.
|
|
|
|
* @param int $wmin The minimum viewport value.
|
|
|
|
* @param int $wmax The maximum viewport value.
|
|
|
|
* @param string $unit The relative clamp unit. Default 'vw'.
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
|
|
|
* @return string The calculated clamp.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_get_css_clamp( $min, $max, $wmin, $wmax, $unit = 'vw' ) {
|
|
|
|
$vw = ( $min - $max ) / ( ( $wmin / 100 ) - ( $wmax / 100 ) );
|
|
|
|
$offset = $min - $vw * ( $wmin / 100 );
|
|
|
|
|
|
|
|
return "clamp({$min}px, {$vw}{$unit} + ({$offset}px), {$max}px)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// GENERATE CSS CUSTOM PROPERTY HSL CODE
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! function_exists( 'fictioneer_hsl_code' ) ) {
|
|
|
|
/**
|
|
|
|
* Convert a hex color to a Fictioneer HSL code.
|
|
|
|
*
|
|
|
|
* Example: #fcfcfd =>
|
|
|
|
* hsl(calc(240deg + var(--hue-rotate)) calc(20% * var(--saturation)) clamp(49.5%, 99% * var(--darken), 99.5%))
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.7.0
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2023-08-20 01:04:49 +02:00
|
|
|
* @param string $hex The color as hex.
|
|
|
|
* @param string $output Switch output style. Default 'default'.
|
|
|
|
*
|
2023-01-21 01:31:34 +01:00
|
|
|
* @return string The converted color.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_hsl_code( $hex, $output = 'default' ) {
|
|
|
|
$hsl_array = fictioneer_rgb_to_hsl( fictioneer_hex_to_rgb( $hex ), 2 );
|
|
|
|
|
2023-08-28 10:43:04 +02:00
|
|
|
if ( $output == 'values' ) {
|
|
|
|
return "$hsl_array[0] $hsl_array[1] $hsl_array[2]";
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
$deg = 'calc(' . $hsl_array[0] . 'deg + var(--hue-rotate))';
|
|
|
|
$saturation = 'calc(' . $hsl_array[1] . '% * var(--saturation))';
|
|
|
|
$min = max( 0, $hsl_array[2] * 0.5 );
|
|
|
|
$max = $hsl_array[2] + (100 - $hsl_array[2]) / 2;
|
|
|
|
$lightness = 'clamp('. $min . '%, ' . $hsl_array[2] . '% * var(--darken), ' . $max . '%)';
|
|
|
|
|
2023-08-28 10:43:04 +02:00
|
|
|
if ( $output == 'free' ) {
|
|
|
|
return "$deg $saturation $lightness";
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
return "hsl($deg $saturation $lightness)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// GENERATE CSS CUSTOM PROPERTY HSL FONT CODE
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! function_exists( 'fictioneer_hsl_font_code' ) ) {
|
|
|
|
/**
|
|
|
|
* Convert a hex color to a Fictioneer HSL font code.
|
|
|
|
*
|
|
|
|
* This is a reduced variant of the regular HSL font code.
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.7.0
|
2023-01-21 01:31:34 +01:00
|
|
|
* @see fictioneer_hsl_code( $hex, $output )
|
|
|
|
*
|
2023-08-20 01:04:49 +02:00
|
|
|
* @param string $hex The color as hex.
|
|
|
|
*
|
2023-01-21 01:31:34 +01:00
|
|
|
* @return string The converted color.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_hsl_font_code( $hex ) {
|
|
|
|
$hsl_array = fictioneer_rgb_to_hsl( fictioneer_hex_to_rgb( $hex ), 2 );
|
|
|
|
|
|
|
|
$deg = 'calc(' . $hsl_array[0] . 'deg + var(--hue-rotate))';
|
2024-02-25 17:33:12 +01:00
|
|
|
$saturation = 'max(calc(' . $hsl_array[1] . '% * (var(--font-saturation) + var(--saturation) - 1)), 0%)';
|
2024-02-25 17:55:19 +01:00
|
|
|
$lightness = 'clamp(0%, calc(' . $hsl_array[2] . '% * var(--font-lightness, 1)), 100%)';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
return "hsl($deg $saturation $lightness)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
2024-02-15 21:07:02 +01:00
|
|
|
// VALIDATE GOOGLE FONTS LINK
|
2023-01-21 01:31:34 +01:00
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
/**
|
2024-02-15 21:07:02 +01:00
|
|
|
* Validates Google Fonts link
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2024-02-15 21:07:02 +01:00
|
|
|
* @since 5.10.0
|
|
|
|
*
|
|
|
|
* @param string $link The Google Fonts link.
|
|
|
|
*
|
|
|
|
* @return boolean Whether the link is valid or not.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
function fictioneer_validate_google_fonts_link( $link ) {
|
|
|
|
return preg_match( '/^https:\/\/fonts\.googleapis\.com\/css2/', $link ) === 1;
|
|
|
|
}
|
2024-02-07 22:56:39 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// =============================================================================
|
|
|
|
// EXTRACT FONT DATA FROM GOOGLE FONTS LINK
|
|
|
|
// =============================================================================
|
2024-02-15 17:54:04 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
/**
|
|
|
|
* Returns fonts data from a Google Fonts link
|
|
|
|
*
|
|
|
|
* @since 5.10.0
|
|
|
|
*
|
|
|
|
* @param string $link The Google Fonts link.
|
|
|
|
*
|
|
|
|
* @return array|false|null The font data if successful, false if malformed,
|
|
|
|
* null if not a valid Google Fonts link.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_extract_font_from_google_link( $link ) {
|
|
|
|
// Validate
|
|
|
|
if ( ! fictioneer_validate_google_fonts_link( $link ) ) {
|
|
|
|
// Not Google Fonts link
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup
|
|
|
|
$font = array(
|
|
|
|
'google_link' => $link,
|
|
|
|
'skip' => true,
|
|
|
|
'chapter' => true,
|
|
|
|
'version' => '',
|
|
|
|
'key' => '',
|
|
|
|
'name' => '',
|
|
|
|
'family' => '',
|
|
|
|
'type' => '',
|
|
|
|
'styles' => ['normal'],
|
|
|
|
'weights' => [],
|
|
|
|
'charsets' => [],
|
|
|
|
'formats' => [],
|
|
|
|
'about' => __( 'This font is loaded via the Google Fonts CDN, see source for additional information.', 'fictioneer' ),
|
|
|
|
'note' => '',
|
|
|
|
'sources' => array(
|
|
|
|
'googleFontsCss' => array(
|
|
|
|
'name' => 'Google Fonts CSS File',
|
|
|
|
'url' => $link
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Name?
|
|
|
|
preg_match( '/family=([^:]+)/', $link, $name_matches );
|
|
|
|
|
|
|
|
if ( ! empty( $name_matches ) ) {
|
|
|
|
$font['name'] = str_replace( '+', ' ', $name_matches[1] );
|
|
|
|
$font['family'] = $font['name'];
|
|
|
|
$font['key'] = sanitize_title( $font['name'] );
|
|
|
|
} else {
|
|
|
|
// Link malformed
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Italic? Weights?
|
|
|
|
preg_match( '/ital,wght@([0-9,;]+)/', $link, $ital_weight_matches );
|
|
|
|
|
|
|
|
if ( ! empty( $ital_weight_matches ) ) {
|
|
|
|
$specifications = explode( ';', $ital_weight_matches[1] );
|
|
|
|
$weights = [];
|
|
|
|
$is_italic = false;
|
2024-02-07 22:56:39 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
foreach ( $specifications as $spec ) {
|
|
|
|
list( $ital, $weight ) = explode( ',', $spec );
|
|
|
|
|
|
|
|
if ( $ital == '1' ) {
|
|
|
|
$is_italic = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$weights[ $weight ] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $is_italic ) {
|
|
|
|
$font['styles'][] = 'italic';
|
|
|
|
}
|
|
|
|
|
|
|
|
$font['weights'] = array_keys( $weights );
|
2024-02-07 22:56:39 +01:00
|
|
|
}
|
2024-02-15 21:07:02 +01:00
|
|
|
|
|
|
|
// Done
|
|
|
|
return $font;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
2024-02-15 21:07:02 +01:00
|
|
|
// GET FONT DATA
|
2023-01-21 01:31:34 +01:00
|
|
|
// =============================================================================
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
/**
|
|
|
|
* Returns fonts included by the theme
|
|
|
|
*
|
2024-06-13 11:44:36 +02:00
|
|
|
* Note: If a font.json contains a { "remove": true } node, the font will not
|
|
|
|
* be added to the result array and therefore removed from the site.
|
|
|
|
*
|
2024-02-15 21:07:02 +01:00
|
|
|
* @since 5.10.0
|
|
|
|
*
|
2024-06-13 11:44:36 +02:00
|
|
|
* @return array Array of font data. Keys: skip, chapter, version, key, name,
|
|
|
|
* family, type, styles, weights, charsets, formats, about, note,
|
|
|
|
* sources, css_path, css_file, and in_child_theme.
|
2024-02-15 21:07:02 +01:00
|
|
|
*/
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
function fictioneer_get_font_data() {
|
|
|
|
// Setup
|
|
|
|
$parent_font_dir = get_template_directory() . '/fonts';
|
|
|
|
$child_font_dir = get_stylesheet_directory() . '/fonts';
|
|
|
|
$parent_fonts = [];
|
|
|
|
$child_fonts = [];
|
|
|
|
$google_fonts = [];
|
|
|
|
|
|
|
|
// Helper function
|
|
|
|
$extract_font_data = function( $font_dir, &$fonts, $theme = 'parent' ) {
|
|
|
|
if ( is_dir( $font_dir ) ) {
|
|
|
|
$font_folders = array_diff( scandir( $font_dir ), ['..', '.'] );
|
|
|
|
|
|
|
|
foreach ( $font_folders as $folder ) {
|
|
|
|
$full_path = "{$font_dir}/{$folder}";
|
|
|
|
$json_file = "$full_path/font.json";
|
|
|
|
$css_file = "$full_path/font.css";
|
|
|
|
|
|
|
|
if ( is_dir( $full_path ) && file_exists( $json_file ) && file_exists( $css_file ) ) {
|
|
|
|
$folder_name = basename( $folder );
|
|
|
|
$data = @json_decode( file_get_contents( $json_file ), true );
|
|
|
|
|
|
|
|
if ( $data && json_last_error() === JSON_ERROR_NONE ) {
|
|
|
|
if ( ! ( $data['remove'] ?? 0 ) ) {
|
|
|
|
$data['css_path'] = "/fonts/{$folder_name}/font.css";
|
|
|
|
$data['css_file'] = $css_file;
|
|
|
|
$data['in_child_theme'] = $theme === 'child';
|
|
|
|
|
|
|
|
$fonts[ $data['key'] ] = $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
return $fonts;
|
2023-08-26 06:06:30 +02:00
|
|
|
}
|
2024-02-15 21:07:02 +01:00
|
|
|
};
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// Parent theme
|
|
|
|
$extract_font_data( $parent_font_dir, $parent_fonts );
|
|
|
|
|
|
|
|
// Child theme (if any)
|
|
|
|
if ( $parent_font_dir !== $child_font_dir ) {
|
|
|
|
$extract_font_data( $child_font_dir, $child_fonts, 'child' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Google Fonts links (if any)
|
|
|
|
$google_fonts_links = get_option( 'fictioneer_google_fonts_links' );
|
|
|
|
|
|
|
|
if ( $google_fonts_links ) {
|
|
|
|
$google_fonts_links = explode( "\n", $google_fonts_links );
|
|
|
|
|
|
|
|
foreach ( $google_fonts_links as $link ) {
|
|
|
|
$font = fictioneer_extract_font_from_google_link( $link );
|
|
|
|
|
|
|
|
if ( $font ) {
|
|
|
|
$google_fonts[] = $font;
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// Merge finds
|
|
|
|
$fonts = array_merge( $parent_fonts, $child_fonts, $google_fonts );
|
|
|
|
|
|
|
|
// Apply filters
|
|
|
|
$fonts = apply_filters( 'fictioneer_filter_font_data', $fonts );
|
|
|
|
|
|
|
|
// Return complete font list
|
|
|
|
return $fonts;
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// BUILD BUNDLED FONT CSS FILE
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build bundled font stylesheet
|
|
|
|
*
|
|
|
|
* @since 5.10.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_build_bundled_fonts() {
|
|
|
|
// Setup
|
2024-03-09 03:54:10 +01:00
|
|
|
$base_fonts = WP_CONTENT_DIR . '/themes/fictioneer/css/fonts-base.css';
|
2024-02-15 21:07:02 +01:00
|
|
|
$fonts = fictioneer_get_font_data();
|
|
|
|
$disabled_fonts = get_option( 'fictioneer_disabled_fonts', [] );
|
|
|
|
$disabled_fonts = is_array( $disabled_fonts ) ? $disabled_fonts : [];
|
|
|
|
$combined_font_css = '';
|
|
|
|
$font_stack = [];
|
|
|
|
|
|
|
|
// Apply filters
|
|
|
|
$fonts = apply_filters( 'fictioneer_filter_pre_build_bundled_fonts', $fonts );
|
|
|
|
|
|
|
|
// Build
|
2024-03-09 03:54:10 +01:00
|
|
|
if ( file_exists( $base_fonts ) ) {
|
|
|
|
$css = file_get_contents( $base_fonts );
|
|
|
|
$css = str_replace( '../fonts/', get_template_directory_uri() . '/fonts/', $css );
|
|
|
|
|
|
|
|
$combined_font_css .= $css;
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
foreach ( $fonts as $key => $font ) {
|
|
|
|
if ( in_array( $key, $disabled_fonts ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $font['chapter'] ?? 0 ) {
|
|
|
|
$font_stack[ $font['key'] ] = array(
|
|
|
|
'css' => fictioneer_font_family_value( $font['family'] ?? '' ),
|
|
|
|
'name' => $font['name'] ?? '',
|
|
|
|
'alt' => $font['alt'] ?? ''
|
|
|
|
);
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
if ( ! ( $font['skip'] ?? 0 ) && ! ( $font['google_link'] ?? 0 ) ) {
|
|
|
|
$css = file_get_contents( $font['css_file'] );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
if ( $font['in_child_theme'] ?? 0 ) {
|
|
|
|
$css = str_replace( '../fonts/', get_stylesheet_directory_uri() . '/fonts/', $css );
|
2024-03-05 11:29:02 +01:00
|
|
|
} else {
|
|
|
|
$css = str_replace( '../fonts/', get_template_directory_uri() . '/fonts/', $css );
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$combined_font_css .= $css;
|
2023-08-26 06:06:30 +02:00
|
|
|
}
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update options
|
|
|
|
update_option( 'fictioneer_chapter_fonts', $font_stack, true );
|
|
|
|
update_option( 'fictioneer_bundled_fonts_timestamp', time(), true );
|
|
|
|
|
|
|
|
// Save
|
2024-09-08 18:41:28 +02:00
|
|
|
file_put_contents(
|
|
|
|
fictioneer_get_theme_cache_dir( 'build_bundled_fonts' ) . '/bundled-fonts.css',
|
|
|
|
$combined_font_css
|
|
|
|
);
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
2023-08-26 06:06:30 +02:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// =============================================================================
|
|
|
|
// GET CUSTOM FONT CSS
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper that returns a font family value
|
|
|
|
*
|
|
|
|
* @since 5.10.0
|
|
|
|
*
|
|
|
|
* @param string $option Name of the theme mod.
|
|
|
|
* @param string $font_default Fallback font.
|
|
|
|
* @param string $mod_default Default for get_theme_mod().
|
|
|
|
*
|
|
|
|
* @return string Ready to use font family value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_get_custom_font( $option, $font_default, $mod_default ) {
|
|
|
|
$selection = get_theme_mod( $option, $mod_default );
|
|
|
|
$family = $font_default;
|
|
|
|
|
|
|
|
switch ( $selection ) {
|
|
|
|
case 'system':
|
|
|
|
$family = 'var(--ff-system)';
|
|
|
|
break;
|
|
|
|
case 'default':
|
|
|
|
$family = $font_default;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$family = "'{$selection}', {$font_default}";
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
2024-02-15 21:07:02 +01:00
|
|
|
|
|
|
|
return $family;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
2024-02-15 21:07:02 +01:00
|
|
|
// BUILD BUNDLED CUSTOMIZE CSS FILE
|
2023-01-21 01:31:34 +01:00
|
|
|
// =============================================================================
|
|
|
|
|
2024-02-20 14:00:54 +01:00
|
|
|
/**
|
|
|
|
* Returns the CSS loaded from a snippet file
|
|
|
|
*
|
|
|
|
* @since 5.11.1
|
|
|
|
*
|
2024-02-21 09:38:02 +01:00
|
|
|
* @param string $snippet Name of the snippet file without file ending.
|
2024-02-20 14:00:54 +01:00
|
|
|
* @param string|null $filter Optional. Part of the generated filter, defaulting
|
|
|
|
* to the snippet name (lower case, underscores).
|
|
|
|
*
|
|
|
|
* @return string The CSS string from the file.
|
|
|
|
*/
|
|
|
|
|
2024-02-21 09:38:02 +01:00
|
|
|
function fictioneer_get_customizer_css_snippet( $snippet, $filter = null ) {
|
2024-02-20 14:00:54 +01:00
|
|
|
// Setup
|
|
|
|
$snippets_file_path = WP_CONTENT_DIR . '/themes/fictioneer/css/customize/';
|
|
|
|
$filter = $filter ? $filter : strtolower( str_replace( '-', '_', $snippet ) );
|
|
|
|
$css = file_get_contents( $snippets_file_path . $snippet . '.css' );
|
|
|
|
|
|
|
|
// Get file contents
|
|
|
|
if ( $css !== false ) {
|
|
|
|
return apply_filters( "fictioneer_filter_css_snippet_{$filter}", $css );
|
|
|
|
} else {
|
|
|
|
error_log( 'File not found: ' . $snippets_file_path . $snippet . '.css' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Graceful error
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2024-02-28 16:31:56 +01:00
|
|
|
/**
|
|
|
|
* Helper to get theme color mod with default fallback
|
|
|
|
*
|
|
|
|
* @since 5.12.0
|
2024-08-01 19:58:41 +02:00
|
|
|
* @since 5.21.2 - Refactored with theme colors helper function.
|
2024-02-28 16:31:56 +01:00
|
|
|
*
|
|
|
|
* @param string $mod The requested theme color.
|
|
|
|
* @param string|null $default Optional. Default color code.
|
|
|
|
*
|
2024-03-01 02:42:46 +01:00
|
|
|
* @return string The requested color code or '#ff6347' (tomato) if not found.
|
2024-02-28 16:31:56 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_get_theme_color( $mod, $default = null ) {
|
2024-08-01 19:58:41 +02:00
|
|
|
$fictioneer_colors = fictioneer_get_theme_colors_array();
|
2024-03-01 02:42:46 +01:00
|
|
|
$default = $default ?? $fictioneer_colors[ $mod ]['hex'] ?? '#ff6347'; // Tomato
|
2024-02-28 16:31:56 +01:00
|
|
|
|
|
|
|
return get_theme_mod( $mod, $default );
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
/**
|
|
|
|
* Builds customization stylesheet
|
|
|
|
*
|
|
|
|
* @since 5.11.0
|
|
|
|
*
|
2024-03-03 11:28:37 +01:00
|
|
|
* @param string|null $context Optional. In which context the stylesheet created,
|
2024-02-15 21:07:02 +01:00
|
|
|
* for example 'preview' for the Customizer.
|
|
|
|
*/
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-03-03 11:28:37 +01:00
|
|
|
function fictioneer_build_customize_css( $context = null ) {
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Setup -----------------------------------------------------------------
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-08-28 19:18:18 +02:00
|
|
|
$file_path = fictioneer_get_theme_cache_dir( 'build_customize_css' ) . '/customize.css';
|
2024-09-20 22:46:34 +02:00
|
|
|
$site_width = (int) get_theme_mod( 'site_width', FICTIONEER_DEFAULT_SITE_WIDTH );
|
2024-02-15 21:38:12 +01:00
|
|
|
$header_image_style = get_theme_mod( 'header_image_style', 'default' );
|
|
|
|
$header_style = get_theme_mod( 'header_style', 'default' );
|
2024-02-15 22:02:07 +01:00
|
|
|
$content_list_style = get_theme_mod( 'content_list_style', 'default' );
|
2024-02-15 21:38:12 +01:00
|
|
|
$page_style = get_theme_mod( 'page_style', 'default' );
|
2024-02-20 11:04:45 +01:00
|
|
|
$card_style = get_theme_mod( 'card_style', 'default' );
|
2024-03-04 02:27:07 +01:00
|
|
|
$card_frame = get_theme_mod( 'card_frame', 'default' );
|
2024-02-20 10:55:26 +01:00
|
|
|
$footer_style = get_theme_mod( 'footer_style', 'default' );
|
2024-08-04 23:48:09 +02:00
|
|
|
$sidebar_style = get_theme_mod( 'sidebar_style', 'none' );
|
2024-02-15 21:07:02 +01:00
|
|
|
$css = '';
|
|
|
|
|
2024-03-03 11:28:37 +01:00
|
|
|
if ( $context === 'preview' ) {
|
2024-08-28 19:18:18 +02:00
|
|
|
$file_path = fictioneer_get_theme_cache_dir( 'preview' ) . '/customize-preview.css';
|
2024-03-07 11:46:33 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:38:12 +01:00
|
|
|
// --- Assets ----------------------------------------------------------------
|
|
|
|
|
|
|
|
if (
|
2024-02-16 15:59:22 +01:00
|
|
|
$header_image_style === 'polygon-battered' ||
|
|
|
|
in_array( $page_style, ['polygon-battered', 'polygon-mask-image-battered-ringbook'] )
|
2024-02-15 21:38:12 +01:00
|
|
|
) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'polygon-battered' );
|
2024-02-15 21:38:12 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 22:02:07 +01:00
|
|
|
// --- Header image style ----------------------------------------------------
|
|
|
|
|
2024-02-16 15:59:22 +01:00
|
|
|
if ( $header_image_style === 'polygon-battered' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-image-style-battered' );
|
2024-02-15 22:02:07 +01:00
|
|
|
}
|
|
|
|
|
2024-02-17 00:10:41 +01:00
|
|
|
if ( $header_image_style === 'polygon-chamfered' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-image-style-chamfered' );
|
2024-02-17 00:10:41 +01:00
|
|
|
}
|
|
|
|
|
2024-02-16 23:12:05 +01:00
|
|
|
if ( $header_image_style === 'mask-grunge-frame-a-large' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-image-style-grunge-frame-a-large' );
|
2024-02-16 23:12:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $header_image_style === 'mask-grunge-frame-a-small' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-image-style-grunge-frame-a-small' );
|
2024-02-16 23:12:05 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Fading header image ---------------------------------------------------
|
|
|
|
|
|
|
|
$header_image_fading_start = fictioneer_sanitize_integer( get_theme_mod( 'header_image_fading_start', 0 ), 0, 0, 99 );
|
|
|
|
$header_image_fading_breakpoint = (int) get_theme_mod( 'header_image_fading_breakpoint', 0 );
|
|
|
|
|
|
|
|
if ( $header_image_fading_start > 0 ) {
|
|
|
|
if ( $header_image_fading_breakpoint > 320 ) {
|
|
|
|
$css .= "@media only screen and (min-width: {$header_image_fading_breakpoint}px) {
|
|
|
|
:root {
|
|
|
|
--header-fading-mask-image: " . fictioneer_get_fading_gradient( 100, $header_image_fading_start, 100, 'var(--header-fading-mask-image-rotation, 180deg)' ) . ";
|
|
|
|
}
|
|
|
|
}";
|
|
|
|
} else {
|
|
|
|
$css .= ":root {
|
|
|
|
--header-fading-mask-image: " . fictioneer_get_fading_gradient( 100, $header_image_fading_start, 100, 'var(--header-fading-mask-image-rotation, 180deg)' ) . ";
|
|
|
|
}";
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
2024-02-21 02:40:30 +01:00
|
|
|
|
|
|
|
$css .= '@media only screen and (min-width: 1024px) {
|
2024-08-28 14:40:16 +02:00
|
|
|
.inset-header-image .header-background._style-default._fading-bottom._shadow .header-background__wrapper {
|
2024-02-21 02:40:30 +01:00
|
|
|
margin-left: 4px;
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
}';
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 22:02:07 +01:00
|
|
|
// --- Inset header image ----------------------------------------------------
|
|
|
|
|
|
|
|
if ( get_theme_mod( 'inset_header_image' ) ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'inset-header-image' );
|
2024-02-15 22:02:07 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Base layout -----------------------------------------------------------
|
|
|
|
|
|
|
|
$hue_offset_dark = (int) get_theme_mod( 'hue_offset', 0 );
|
|
|
|
$saturation_offset_dark = (int) get_theme_mod( 'saturation_offset', 0 );
|
|
|
|
$lightness_offset_dark = (int) get_theme_mod( 'lightness_offset', 0 );
|
2024-02-25 17:33:12 +01:00
|
|
|
$font_saturation_offset_dark = (int) get_theme_mod( 'font_saturation_offset', 0 );
|
2024-02-25 23:15:55 +01:00
|
|
|
$font_lightness_offset_dark = (int) get_theme_mod( 'font_lightness_offset', 0 );
|
2024-02-15 21:07:02 +01:00
|
|
|
$hue_offset_light = (int) get_theme_mod( 'hue_offset_light', 0 );
|
|
|
|
$saturation_offset_light = (int) get_theme_mod( 'saturation_offset_light', 0 );
|
|
|
|
$lightness_offset_light = (int) get_theme_mod( 'lightness_offset_light', 0 );
|
2024-02-25 17:33:12 +01:00
|
|
|
$font_saturation_offset_light = (int) get_theme_mod( 'font_saturation_offset_light', 0 );
|
2024-02-25 23:15:55 +01:00
|
|
|
$font_lightness_offset_light = (int) get_theme_mod( 'font_lightness_offset_light', 0 );
|
2024-09-20 22:46:34 +02:00
|
|
|
$site_width = (int) get_theme_mod( 'site_width', FICTIONEER_DEFAULT_SITE_WIDTH );
|
2024-04-12 20:24:47 +02:00
|
|
|
$main_offset = (int) get_theme_mod( 'main_offset', 0 );
|
2024-08-04 23:48:09 +02:00
|
|
|
$sidebar_width = (int) get_theme_mod( 'sidebar_width', 256 );
|
|
|
|
$sidebar_gap = (int) get_theme_mod( 'sidebar_gap', 48 );
|
2024-09-30 00:07:52 +02:00
|
|
|
$logo_min_height = (int) get_theme_mod( 'logo_min_height', 210 );
|
|
|
|
$logo_max_height = (int) get_theme_mod( 'logo_height', 210 );
|
2024-02-15 21:07:02 +01:00
|
|
|
$title_min = (int) get_theme_mod( 'site_title_font_size_min', 32 );
|
|
|
|
$title_max = (int) get_theme_mod( 'site_title_font_size_max', 60 );
|
|
|
|
$tagline_min = (int) get_theme_mod( 'site_tagline_font_size_min', 13 );
|
|
|
|
$tagline_max = (int) get_theme_mod( 'site_tagline_font_size_max', 18 );
|
|
|
|
$header_image_min = (int) get_theme_mod( 'header_image_height_min', 210 );
|
|
|
|
$header_image_max = (int) get_theme_mod( 'header_image_height_max', 480 );
|
2024-11-07 02:44:50 +01:00
|
|
|
$header_bg_color_light = fictioneer_get_theme_color( 'header_color_light', '' );
|
|
|
|
$header_bg_color_dark = fictioneer_get_theme_color( 'header_color_dark', '' );
|
2024-02-15 21:07:02 +01:00
|
|
|
$header_min = (int) get_theme_mod( 'header_height_min', 190 );
|
|
|
|
$header_max = (int) get_theme_mod( 'header_height_max', 380 );
|
2024-08-08 12:28:02 +02:00
|
|
|
$story_cover_width_offset = (int) get_theme_mod( 'story_cover_width_offset', 0 );
|
2024-08-09 20:04:04 +02:00
|
|
|
$story_cover_box_shadow = get_theme_mod( 'story_cover_shadow', 'var(--box-shadow-xl)' );
|
2024-02-15 21:07:02 +01:00
|
|
|
$card_grid_column_min = (int) get_theme_mod( 'card_grid_column_min', 308 );
|
|
|
|
$card_cover_width_mod = get_theme_mod( 'card_cover_width_mod', 1 );
|
2024-02-21 17:18:05 +01:00
|
|
|
$card_grid_column_gap_mod = get_theme_mod( 'card_grid_column_gap_mod', 1 );
|
|
|
|
$card_grid_row_gap_mod = get_theme_mod( 'card_grid_row_gap_mod', 1 );
|
2024-05-30 13:56:07 +02:00
|
|
|
$card_font_size_min_mod = get_theme_mod( 'card_font_size_min_mod', 0 );
|
|
|
|
$card_font_size_grow_mod = get_theme_mod( 'card_font_size_grow_mod', 0 );
|
|
|
|
$card_font_size_max_mod = get_theme_mod( 'card_font_size_max_mod', 0 );
|
2024-03-02 03:21:31 +01:00
|
|
|
$card_box_shadow = get_theme_mod( 'card_shadow', 'var(--box-shadow-m)' );
|
2024-02-15 21:07:02 +01:00
|
|
|
$font_primary = fictioneer_get_custom_font( 'primary_font_family_value', 'var(--ff-system)', 'Open Sans' );
|
|
|
|
$font_secondary = fictioneer_get_custom_font( 'secondary_font_family_value', 'var(--ff-base)', 'Lato' );
|
|
|
|
$font_heading = fictioneer_get_custom_font( 'heading_font_family_value', 'var(--ff-base)', 'Open Sans' );
|
|
|
|
$font_site_title = fictioneer_get_custom_font( 'site_title_font_family_value', 'var(--ff-heading)', 'default' );
|
|
|
|
$font_nav_item = fictioneer_get_custom_font( 'nav_item_font_family_value', 'var(--ff-base)', 'default' );
|
|
|
|
$font_story_title = fictioneer_get_custom_font( 'story_title_font_family_value', 'var(--ff-heading)', 'default' );
|
|
|
|
$font_chapter_title = fictioneer_get_custom_font( 'chapter_title_font_family_value', 'var(--ff-heading)', 'default' );
|
|
|
|
$font_chapter_list_title = fictioneer_get_custom_font( 'chapter_list_title_font_family_value', 'var(--ff-base)', 'default' );
|
|
|
|
$font_card_title = fictioneer_get_custom_font( 'card_title_font_family_value', 'var(--ff-heading)', 'default' );
|
|
|
|
$font_card_body = fictioneer_get_custom_font( 'card_body_font_family_value', 'var(--ff-note)', 'default' );
|
|
|
|
$font_card_list_link = fictioneer_get_custom_font( 'card_list_link_font_family_value', 'var(--ff-note)', 'default' );
|
|
|
|
|
2024-03-02 19:28:30 +01:00
|
|
|
$dark_shade = fictioneer_hex_to_rgb( get_theme_mod( 'dark_shade', '000000' ) );
|
|
|
|
$dark_shade = is_array( $dark_shade ) ? $dark_shade : [0, 0, 0];
|
|
|
|
|
2024-09-30 00:07:52 +02:00
|
|
|
if ( $logo_min_height < $logo_max_height ) {
|
|
|
|
$logo_height = fictioneer_get_css_clamp( $logo_min_height, $logo_max_height, 320, $site_width );
|
|
|
|
} else {
|
|
|
|
$logo_height = $logo_max_height . 'px';
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
$css .= ":root {
|
2024-05-30 13:55:04 +02:00
|
|
|
--site-width: {$site_width}px;
|
|
|
|
--main-offset: {$main_offset}px;
|
2024-08-04 23:48:09 +02:00
|
|
|
--sidebar-width: {$sidebar_width}px;
|
|
|
|
--sidebar-gap: {$sidebar_gap}px;
|
2024-05-30 13:55:04 +02:00
|
|
|
--hue-offset: {$hue_offset_dark}deg;
|
2024-02-15 21:07:02 +01:00
|
|
|
--saturation-offset: " . $saturation_offset_dark / 100 . ";
|
|
|
|
--lightness-offset: " . $lightness_offset_dark / 100 . ";
|
2024-02-25 17:33:12 +01:00
|
|
|
--font-saturation-offset: " . $font_saturation_offset_dark / 100 . ";
|
2024-02-25 23:15:55 +01:00
|
|
|
--font-lightness-offset: " . $font_lightness_offset_dark / 100 . ";
|
2024-02-22 19:41:03 +01:00
|
|
|
--header-image-height: " . fictioneer_get_css_clamp( $header_image_min, $header_image_max, 320, $site_width ) . ";
|
2024-08-12 02:42:45 +02:00
|
|
|
--header-height: calc(" . fictioneer_get_css_clamp( $header_min, $header_max, 320, $site_width ) . " - var(--page-inset-top, 0px));
|
2024-09-30 00:07:52 +02:00
|
|
|
--header-logo-height: {$logo_height};
|
|
|
|
--header-logo-min-height: {$logo_min_height};
|
|
|
|
--header-logo-max-height: {$logo_max_height};
|
2024-02-15 21:07:02 +01:00
|
|
|
--site-title-font-size: " . fictioneer_get_css_clamp( $title_min, $title_max, 320, $site_width ) . ";
|
|
|
|
--site-title-tagline-font-size: " . fictioneer_get_css_clamp( $tagline_min, $tagline_max, 320, $site_width ) . ";
|
2024-05-30 13:55:04 +02:00
|
|
|
--grid-columns-min: {$card_grid_column_min}px;
|
|
|
|
--grid-columns-row-gap-multiplier: {$card_grid_row_gap_mod};
|
|
|
|
--grid-columns-col-gap-multiplier: {$card_grid_column_gap_mod};
|
2024-05-30 13:56:07 +02:00
|
|
|
--card-font-size-min-mod: {$card_font_size_min_mod}px;
|
|
|
|
--card-font-size-grow-mod: {$card_font_size_grow_mod}px;
|
|
|
|
--card-font-size-max-mod: {$card_font_size_max_mod}px;
|
2024-02-15 21:07:02 +01:00
|
|
|
--ff-base: {$font_primary};
|
|
|
|
--ff-note: {$font_secondary};
|
|
|
|
--ff-heading: {$font_heading};
|
|
|
|
--ff-site-title: {$font_site_title};
|
|
|
|
--ff-story-title: {$font_story_title};
|
|
|
|
--ff-chapter-title: {$font_chapter_title};
|
|
|
|
--ff-chapter-list-title: {$font_chapter_list_title};
|
|
|
|
--ff-card-title: {$font_card_title};
|
|
|
|
--ff-card-body: {$font_card_body};
|
|
|
|
--ff-card-list-link: {$font_card_list_link};
|
|
|
|
--ff-nav-item: {$font_nav_item};
|
|
|
|
--card-cover-width-mod: {$card_cover_width_mod};
|
2024-03-02 03:21:31 +01:00
|
|
|
--card-box-shadow: {$card_box_shadow};
|
|
|
|
--card-drop-shadow: " . str_replace( 'box-', 'drop-', $card_box_shadow ) . ";
|
2024-08-09 20:04:04 +02:00
|
|
|
--story-cover-box-shadow: {$story_cover_box_shadow};
|
2024-08-09 23:49:21 +02:00
|
|
|
--recommendation-cover-box-shadow: {$story_cover_box_shadow};
|
2024-08-08 12:28:02 +02:00
|
|
|
--floating-cover-image-width: " . fictioneer_get_css_clamp( 56, 200 + $story_cover_width_offset, 320, 768 ) . ";
|
|
|
|
--in-content-cover-image-width: " . fictioneer_get_css_clamp( 100, 200 + $story_cover_width_offset, 375, 768 ) . ";
|
2024-02-15 21:07:02 +01:00
|
|
|
}";
|
|
|
|
|
2024-04-01 16:53:51 +02:00
|
|
|
if ( $card_box_shadow === 'none' ) {
|
|
|
|
$css .= ".card{box-shadow:none!important;}";
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// Only light mode
|
|
|
|
$css .= ":root[data-mode=light] {
|
2024-05-30 13:55:04 +02:00
|
|
|
--hue-offset: {$hue_offset_light}deg;
|
2024-02-15 21:07:02 +01:00
|
|
|
--saturation-offset: " . $saturation_offset_light / 100 . ";
|
|
|
|
--lightness-offset: " . $lightness_offset_light / 100 . ";
|
2024-02-25 17:33:12 +01:00
|
|
|
--font-saturation-offset: " . $font_saturation_offset_light / 100 . ";
|
2024-02-25 23:15:55 +01:00
|
|
|
--font-lightness-offset: " . $font_lightness_offset_light / 100 . ";
|
2024-02-15 21:07:02 +01:00
|
|
|
}";
|
|
|
|
|
|
|
|
// --- Custom layout ---------------------------------------------------------
|
|
|
|
|
2024-08-04 23:48:09 +02:00
|
|
|
if ( $sidebar_style !== 'none' ) {
|
|
|
|
$css .= ":root, :root[data-theme=base] {
|
|
|
|
--layout-spacing-horizontal: " . fictioneer_get_css_clamp( 20, 48, 480, $site_width ) . ";
|
|
|
|
--layout-spacing-horizontal-small: " . fictioneer_get_css_clamp( 10, 20, 320, 400 ) . ";
|
|
|
|
}";
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
if ( get_theme_mod( 'use_custom_layout', false ) ) {
|
|
|
|
$vertical_min = (int) get_theme_mod( 'vertical_spacing_min', 24 );
|
|
|
|
$vertical_max = (int) get_theme_mod( 'vertical_spacing_max', 48 );
|
|
|
|
$horizontal_min = (int) get_theme_mod( 'horizontal_spacing_min', 20 );
|
|
|
|
$horizontal_max = (int) get_theme_mod( 'horizontal_spacing_max', 80 );
|
|
|
|
$horizontal_small_min = (int) get_theme_mod( 'horizontal_spacing_small_min', 10 );
|
|
|
|
$horizontal_small_max = (int) get_theme_mod( 'horizontal_spacing_small_max', 20 );
|
|
|
|
$large_border_radius = (int) get_theme_mod( 'large_border_radius', 4 );
|
|
|
|
$small_border_radius = (int) get_theme_mod( 'small_border_radius', 2 );
|
2024-08-18 16:56:51 +02:00
|
|
|
$nested_border_radius_multiplier = max( 0, get_theme_mod( 'nested_border_radius_multiplier', 1 ) );
|
2024-08-21 22:53:24 +02:00
|
|
|
$content_list_gap = (int) get_theme_mod( 'content_list_gap', 4 );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
$css .= ":root, :root[data-theme=base] {
|
|
|
|
--layout-spacing-vertical: " . fictioneer_get_css_clamp( $vertical_min, $vertical_max, 480, $site_width ) . ";
|
|
|
|
--layout-spacing-horizontal: " . fictioneer_get_css_clamp( $horizontal_min, $horizontal_max, 480, $site_width, '%' ) . ";
|
|
|
|
--layout-spacing-horizontal-small: " . fictioneer_get_css_clamp( $horizontal_small_min, $horizontal_small_max, 320, 400, '%' ) . ";
|
2024-03-04 22:26:17 +01:00
|
|
|
--layout-border-radius-large: {$large_border_radius}px;
|
|
|
|
--layout-border-radius-small: {$small_border_radius}px;
|
2024-08-18 16:56:51 +02:00
|
|
|
--layout-nested-border-radius-multiplier: {$nested_border_radius_multiplier};
|
2024-08-21 22:53:24 +02:00
|
|
|
--chapter-list-gap: {$content_list_gap}px;
|
|
|
|
--content-list-gap: {$content_list_gap}px;
|
2024-02-15 21:07:02 +01:00
|
|
|
}";
|
2024-08-04 23:48:09 +02:00
|
|
|
|
|
|
|
if ( $sidebar_style !== 'none' ) {
|
|
|
|
$css .= ".has-sidebar {
|
|
|
|
--layout-spacing-horizontal: " . fictioneer_get_css_clamp( $horizontal_min, $horizontal_max, 480, $site_width ) . ";
|
|
|
|
--layout-spacing-horizontal-small: " . fictioneer_get_css_clamp( $horizontal_small_min, $horizontal_small_max, 320, 400 ) . ";
|
|
|
|
}";
|
|
|
|
}
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- Dark mode font weight adjustment --------------------------------------
|
|
|
|
|
|
|
|
if ( get_theme_mod( 'dark_mode_font_weight', 'adjusted' ) === 'normal' ) {
|
|
|
|
$css .= ":root[data-font-weight=default]:is(html) {
|
|
|
|
--font-smoothing-webkit: subpixel-antialiased;
|
|
|
|
--font-smoothing-moz: auto;
|
|
|
|
--font-weight-normal: 400;
|
|
|
|
--font-weight-semi-strong: 600;
|
|
|
|
--font-weight-strong: 600;
|
|
|
|
--font-weight-medium: 500;
|
|
|
|
--font-weight-heading: 700;
|
|
|
|
--font-weight-badge: 600;
|
|
|
|
--font-weight-post-meta: 400;
|
2024-02-23 19:16:36 +01:00
|
|
|
--font-weight-read-ribbon: 700;
|
|
|
|
--font-weight-card-label: 600;
|
2024-02-15 21:07:02 +01:00
|
|
|
--font-weight-navigation: 400;
|
|
|
|
--font-letter-spacing-base: 0em;
|
|
|
|
}";
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- Dark mode colors ------------------------------------------------------
|
|
|
|
|
|
|
|
$css .= ":root {
|
2024-03-03 00:17:28 +01:00
|
|
|
--site-title-heading-color: " . fictioneer_hsl_font_code( fictioneer_get_theme_color( 'dark_header_title_color' ) ) . ";
|
|
|
|
--site-title-tagline-color: " . fictioneer_hsl_font_code( fictioneer_get_theme_color( 'dark_header_tagline_color' ) ) . ";
|
2024-02-15 21:07:02 +01:00
|
|
|
}";
|
|
|
|
|
2024-11-07 02:44:50 +01:00
|
|
|
if ( $header_bg_color_dark ) {
|
|
|
|
$css .= ":root {
|
|
|
|
--header-background-color: " . fictioneer_hsl_code( $header_bg_color_dark ) . ";
|
|
|
|
}";
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
if ( get_theme_mod( 'use_custom_dark_mode', false ) ) {
|
2024-02-28 16:31:56 +01:00
|
|
|
$css .= ":root, :root[data-theme=base] {"
|
|
|
|
.
|
|
|
|
implode( '', array_map( function( $prop ) {
|
|
|
|
return "--bg-{$prop}-free: " . fictioneer_hsl_code( fictioneer_get_theme_color( "dark_bg_{$prop}" ), 'free' ) . ';';
|
|
|
|
}, ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'] ) )
|
|
|
|
.
|
|
|
|
"
|
2024-03-04 15:43:51 +01:00
|
|
|
--card-frame-border-color: " . fictioneer_hsl_code( fictioneer_get_theme_color( 'dark_card_frame' ) ) . ";
|
2024-03-02 19:28:30 +01:00
|
|
|
--dark-shade-rgb:" . implode( ' ', $dark_shade ) . ";
|
2024-02-28 16:31:56 +01:00
|
|
|
--primary-400: " . fictioneer_get_theme_color( 'dark_primary_400' ) . ";
|
|
|
|
--primary-500: " . fictioneer_get_theme_color( 'dark_primary_500' ) . ";
|
|
|
|
--primary-600: " . fictioneer_get_theme_color( 'dark_primary_600' ) . ";
|
|
|
|
--red-400: " . fictioneer_get_theme_color( 'dark_red_400' ) . ";
|
|
|
|
--red-500: " . fictioneer_get_theme_color( 'dark_red_500' ) . ";
|
|
|
|
--red-600: " . fictioneer_get_theme_color( 'dark_red_600' ) . ";
|
|
|
|
--green-400: " . fictioneer_get_theme_color( 'dark_green_400' ) . ";
|
|
|
|
--green-500: " . fictioneer_get_theme_color( 'dark_green_500' ) . ";
|
|
|
|
--green-600: " . fictioneer_get_theme_color( 'dark_green_600' ) . ";
|
|
|
|
--theme-color-base: " . fictioneer_hsl_code( fictioneer_get_theme_color( 'dark_theme_color_base' ), 'values' ) . ";
|
|
|
|
--navigation-background: " . fictioneer_hsl_code( fictioneer_get_theme_color( 'dark_navigation_background_sticky' ) ) . ";
|
|
|
|
--bookmark-color-alpha: " . fictioneer_get_theme_color( 'dark_bookmark_color_alpha' ) . ";
|
|
|
|
--bookmark-color-beta: " . fictioneer_get_theme_color( 'dark_bookmark_color_beta' ) . ";
|
|
|
|
--bookmark-color-gamma: " . fictioneer_get_theme_color( 'dark_bookmark_color_gamma' ) . ";
|
|
|
|
--bookmark-color-delta: " . fictioneer_get_theme_color( 'dark_bookmark_color_delta' ) . ";
|
|
|
|
--bookmark-line: " . fictioneer_get_theme_color( 'dark_bookmark_line_color' ) . ";
|
|
|
|
--ins-background: " . fictioneer_get_theme_color( 'dark_ins_background' ) . ";
|
|
|
|
--del-background: " . fictioneer_get_theme_color( 'dark_del_background' ) . ";"
|
|
|
|
.
|
|
|
|
implode( '', array_map( function( $prop ) {
|
|
|
|
return "--badge-{$prop}-background: " . fictioneer_get_theme_color( "dark_badge_{$prop}_background" ) . ';';
|
|
|
|
}, ['generic', 'moderator', 'admin', 'author', 'supporter', 'override'] ) )
|
|
|
|
.
|
|
|
|
"}
|
|
|
|
:root, :root[data-theme=base], :root .chapter-formatting, :root[data-theme=base] .chapter-formatting {"
|
|
|
|
.
|
|
|
|
implode( '', array_map( function( $prop ) {
|
|
|
|
return "--fg-{$prop}: " . fictioneer_hsl_font_code( fictioneer_get_theme_color( "dark_fg_{$prop}" ) ) . ';';
|
|
|
|
}, ['100', '200', '300', '400', '500', '600', '700', '800', '900', '950', 'tinted', 'inverted'] ) )
|
|
|
|
.
|
|
|
|
"}";
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Light mode colors -----------------------------------------------------
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-03-03 00:17:28 +01:00
|
|
|
$css .= ":root[data-mode=light] {
|
|
|
|
--site-title-heading-color: " . fictioneer_hsl_font_code( fictioneer_get_theme_color( 'light_header_title_color' ) ) . ";
|
|
|
|
--site-title-tagline-color: " . fictioneer_hsl_font_code( fictioneer_get_theme_color( 'light_header_tagline_color' ) ) . ";
|
|
|
|
}";
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-11-07 02:44:50 +01:00
|
|
|
if ( $header_bg_color_light ) {
|
|
|
|
$css .= ":root[data-mode=light] {
|
|
|
|
--header-background-color: " . fictioneer_hsl_code( $header_bg_color_light ) . ";
|
|
|
|
}";
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
if ( get_theme_mod( 'use_custom_light_mode', false ) ) {
|
2024-03-01 02:42:46 +01:00
|
|
|
$css .= ":root[data-mode=light] {"
|
|
|
|
.
|
|
|
|
implode( '', array_map( function( $prop ) {
|
|
|
|
return "--bg-{$prop}-free: " . fictioneer_hsl_code( fictioneer_get_theme_color( "light_bg_{$prop}" ), 'free' ) . ';';
|
|
|
|
}, ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'] ) )
|
|
|
|
.
|
|
|
|
"
|
2024-03-04 15:43:51 +01:00
|
|
|
--card-frame-border-color: " . fictioneer_hsl_code( fictioneer_get_theme_color( 'light_card_frame' ) ) . ";
|
2024-03-01 02:42:46 +01:00
|
|
|
--primary-400: " . fictioneer_get_theme_color( 'light_primary_400' ) . ";
|
|
|
|
--primary-500: " . fictioneer_get_theme_color( 'light_primary_500' ) . ";
|
|
|
|
--primary-600: " . fictioneer_get_theme_color( 'light_primary_600' ) . ";
|
|
|
|
--red-400: " . fictioneer_get_theme_color( 'light_red_400' ) . ";
|
|
|
|
--red-500: " . fictioneer_get_theme_color( 'light_red_500' ) . ";
|
|
|
|
--red-600: " . fictioneer_get_theme_color( 'light_red_600' ) . ";
|
|
|
|
--green-400: " . fictioneer_get_theme_color( 'light_green_400' ) . ";
|
|
|
|
--green-500: " . fictioneer_get_theme_color( 'light_green_500' ) . ";
|
|
|
|
--green-600: " . fictioneer_get_theme_color( 'light_green_600' ) . ";
|
|
|
|
--theme-color-base: " . fictioneer_hsl_code( fictioneer_get_theme_color( 'light_theme_color_base' ), 'values' ) . ";
|
|
|
|
--navigation-background: " . fictioneer_hsl_code( fictioneer_get_theme_color( 'light_navigation_background_sticky' ) ) . ";
|
|
|
|
--bookmark-color-alpha: " . fictioneer_get_theme_color( 'light_bookmark_color_alpha' ) . ";
|
|
|
|
--bookmark-color-beta: " . fictioneer_get_theme_color( 'light_bookmark_color_beta' ) . ";
|
|
|
|
--bookmark-color-gamma: " . fictioneer_get_theme_color( 'light_bookmark_color_gamma' ) . ";
|
|
|
|
--bookmark-color-delta: " . fictioneer_get_theme_color( 'light_bookmark_color_delta' ) . ";
|
|
|
|
--bookmark-line: " . fictioneer_get_theme_color( 'light_bookmark_line_color' ) . ";
|
|
|
|
--ins-background: " . fictioneer_get_theme_color( 'light_ins_background' ) . ";
|
|
|
|
--del-background: " . fictioneer_get_theme_color( 'light_del_background' ) . ";"
|
|
|
|
.
|
|
|
|
implode( '', array_map( function( $prop ) {
|
|
|
|
return "--badge-{$prop}-background: " . fictioneer_get_theme_color( "light_badge_{$prop}_background" ) . ';';
|
|
|
|
}, ['generic', 'moderator', 'admin', 'author', 'supporter', 'override'] ) )
|
|
|
|
.
|
|
|
|
"}
|
|
|
|
:root[data-mode=light], :root[data-mode=light] .chapter-formatting {"
|
|
|
|
.
|
|
|
|
implode( '', array_map( function( $prop ) {
|
|
|
|
return "--fg-{$prop}: " . fictioneer_hsl_font_code( fictioneer_get_theme_color( "light_fg_{$prop}" ) ) . ';';
|
|
|
|
}, ['100', '200', '300', '400', '500', '600', '700', '800', '900', '950', 'tinted', 'inverted'] ) )
|
|
|
|
.
|
|
|
|
"}";
|
2024-02-15 21:07:02 +01:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-19 22:59:06 +01:00
|
|
|
// --- Header styles ---------------------------------------------------------
|
|
|
|
|
|
|
|
if ( in_array( $header_style, ['top', 'split'] ) ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-style-top-split' );
|
2024-02-19 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
2024-04-12 19:44:12 +02:00
|
|
|
if ( $header_style === 'wide' ) {
|
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-style-wide' );
|
|
|
|
}
|
|
|
|
|
2024-06-27 13:37:17 +02:00
|
|
|
if ( $header_style === 'text_center' ) {
|
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-style-text-center' );
|
|
|
|
}
|
|
|
|
|
2024-06-28 12:32:27 +02:00
|
|
|
if ( $header_style === 'post_content' ) {
|
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'header-style-post-content' );
|
|
|
|
}
|
|
|
|
|
2024-02-15 21:38:12 +01:00
|
|
|
// --- Page styles -----------------------------------------------------------
|
|
|
|
|
2024-02-16 15:59:22 +01:00
|
|
|
if ( $page_style === 'polygon-mask-image-battered-ringbook' || $page_style === 'polygon-battered' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-battered' );
|
2024-02-15 21:38:12 +01:00
|
|
|
}
|
|
|
|
|
2024-02-16 15:59:22 +01:00
|
|
|
if ( $page_style === 'polygon-mask-image-battered-ringbook' || $page_style === 'mask-image-ringbook' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-ringbook' );
|
2024-02-15 21:38:12 +01:00
|
|
|
}
|
|
|
|
|
2024-02-16 15:59:22 +01:00
|
|
|
if ( $page_style === 'polygon-chamfered' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-chamfered' );
|
2024-02-15 21:38:12 +01:00
|
|
|
}
|
|
|
|
|
2024-02-16 15:59:22 +01:00
|
|
|
if ( $page_style === 'polygon-interface-a' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-interface-a' );
|
2024-02-15 21:38:12 +01:00
|
|
|
}
|
|
|
|
|
2024-02-16 16:17:32 +01:00
|
|
|
if ( $page_style === 'mask-image-wave-a' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-wave-a' );
|
2024-02-16 16:17:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $page_style === 'mask-image-layered-steps-a' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-layered-steps-a' );
|
2024-02-16 16:17:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $page_style === 'mask-image-layered-peaks-a' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-layered-peaks-a' );
|
2024-02-16 16:17:32 +01:00
|
|
|
}
|
|
|
|
|
2024-02-16 23:33:58 +01:00
|
|
|
if ( $page_style === 'mask-image-grunge-a' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'page-style-grunge-a' );
|
2024-02-16 23:33:58 +01:00
|
|
|
}
|
|
|
|
|
2024-05-28 14:45:31 +02:00
|
|
|
if ( $page_style === 'none' ) {
|
|
|
|
$css .= '.main__background { display:none !important; }';
|
|
|
|
}
|
|
|
|
|
2024-02-15 22:02:07 +01:00
|
|
|
// --- Page shadow -----------------------------------------------------------
|
|
|
|
|
2024-02-18 15:45:01 +01:00
|
|
|
if ( ! get_theme_mod( 'page_shadow', true ) ) {
|
2024-02-15 22:02:07 +01:00
|
|
|
$css .= ':root.no-page-shadow {
|
2024-02-24 03:39:00 +01:00
|
|
|
--minimal-page-box-shadow: none;
|
2024-02-22 19:41:03 +01:00
|
|
|
--page-box-shadow: none;
|
|
|
|
--page-drop-shadow: none;
|
2024-02-15 22:02:07 +01:00
|
|
|
}';
|
|
|
|
}
|
|
|
|
|
2024-02-20 11:04:45 +01:00
|
|
|
// --- Card styles -----------------------------------------------------------
|
|
|
|
|
|
|
|
if ( in_array( $card_style, ['unfolded', 'combined'] ) ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'card-style-unfolded-combined' );
|
2024-02-20 11:04:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $card_style === 'combined' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'card-style-combined' );
|
2024-02-20 11:04:45 +01:00
|
|
|
}
|
|
|
|
|
2024-03-04 02:27:07 +01:00
|
|
|
// --- Card frames -----------------------------------------------------------
|
|
|
|
|
2024-03-04 15:43:51 +01:00
|
|
|
if ( $card_frame !== 'default' ) {
|
2024-03-04 20:25:05 +01:00
|
|
|
$css .= ':root:not(.minimal) .card{filter:var(--card-drop-shadow);}';
|
2024-03-04 15:43:51 +01:00
|
|
|
}
|
|
|
|
|
2024-03-04 02:27:07 +01:00
|
|
|
if ( in_array( $card_frame, ['stacked_right', 'stacked_left', 'stacked_random'] ) ) {
|
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'card-frame-stacked' );
|
|
|
|
|
|
|
|
if ( $card_frame === 'stacked_left' ) {
|
|
|
|
$css .= '.card{--this-rotation-mod:-1;}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-04 02:48:06 +01:00
|
|
|
if ( $card_frame === 'border_2px' ) {
|
2024-03-04 20:25:05 +01:00
|
|
|
$css .= ':root:not(.minimal) .card{--card-style-border-width: 2px;box-shadow: 0 0 0 var(--card-frame-border-thickness, 2px) var(--card-frame-border-color);}';
|
2024-03-04 02:48:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $card_frame === 'border_3px' ) {
|
2024-03-04 20:25:05 +01:00
|
|
|
$css .= ':root:not(.minimal) .card{--card-style-border-width: 3px;box-shadow: 0 0 0 var(--card-frame-border-thickness, 3px) var(--card-frame-border-color);}';
|
2024-03-04 02:48:06 +01:00
|
|
|
}
|
|
|
|
|
2024-03-05 01:32:46 +01:00
|
|
|
if ( $card_frame === 'chamfered' ) {
|
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'card-frame-chamfered' );
|
|
|
|
}
|
|
|
|
|
2024-06-11 13:36:19 +02:00
|
|
|
if ( $card_frame === 'battered' ) {
|
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'card-frame-battered' );
|
|
|
|
}
|
|
|
|
|
2024-02-15 22:02:07 +01:00
|
|
|
// --- Content list style ----------------------------------------------------
|
|
|
|
|
|
|
|
if ( $content_list_style === 'full' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'content-list-style-full' );
|
2024-02-15 22:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $content_list_style === 'free' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'content-list-style-free' );
|
2024-02-15 22:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $content_list_style === 'lines' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'content-list-style-lines' );
|
2024-02-15 22:02:07 +01:00
|
|
|
}
|
|
|
|
|
2024-02-20 10:55:26 +01:00
|
|
|
// --- Footer style ----------------------------------------------------------
|
|
|
|
|
|
|
|
if ( $footer_style === 'isolated' ) {
|
2024-02-21 09:38:02 +01:00
|
|
|
$css .= fictioneer_get_customizer_css_snippet( 'footer-style-isolated' );
|
2024-02-20 10:55:26 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Filters ---------------------------------------------------------------
|
2024-02-09 12:20:16 +01:00
|
|
|
|
2024-02-16 15:14:58 +01:00
|
|
|
$css = apply_filters( 'fictioneer_filter_pre_build_customize_css', $css );
|
2024-02-09 12:20:16 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Minify ----------------------------------------------------------------
|
|
|
|
|
|
|
|
$css = fictioneer_minify_css( $css );
|
|
|
|
|
|
|
|
// --- Update options --------------------------------------------------------
|
|
|
|
|
2024-03-03 11:28:37 +01:00
|
|
|
if ( $context !== 'preview' ) {
|
2024-02-15 21:07:02 +01:00
|
|
|
update_option( 'fictioneer_customize_css_timestamp', time(), true );
|
2024-02-09 12:20:16 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// --- Save ------------------------------------------------------------------
|
|
|
|
|
|
|
|
file_put_contents( $file_path, $css );
|
2024-02-09 12:20:16 +01:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// =============================================================================
|
|
|
|
// GENERATE LINEAR GRADIENT CSS WITH APPROXIMATED CUBIC-BEZIER
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! function_exists( 'fictioneer_get_fading_gradient' ) ) {
|
2023-01-21 01:31:34 +01:00
|
|
|
/**
|
2024-02-15 21:07:02 +01:00
|
|
|
* Returns an eased fading linear-gradient CSS
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2024-02-15 21:07:02 +01:00
|
|
|
* This is an approximated cubic-bezier transition based on a pattern.
|
|
|
|
*
|
|
|
|
* @param float $start_opacity The starting opacity of the gradient in percentage.
|
|
|
|
* @param int $start The starting point of the gradient in percentage.
|
|
|
|
* @param int $end The ending point of the gradient in percentage.
|
|
|
|
* @param int $direction The direction of the gradient with unit (e.g. '180deg').
|
|
|
|
* @param string $hsl The HSL string used as color. Default '0 0% 0%'.
|
|
|
|
*
|
|
|
|
* @return string The linear-gradient CSS.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
function fictioneer_get_fading_gradient( $start_opacity, $start, $end, $direction, $hsl = '0 0% 0%' ) {
|
2023-01-21 01:31:34 +01:00
|
|
|
// Setup
|
2024-02-15 21:07:02 +01:00
|
|
|
$alpha_values = [0.987, 0.951, 0.896, 0.825, 0.741, 0.648, 0.55, 0.45, 0.352, 0.259, 0.175, 0.104, 0.049, 0.013, 0];
|
|
|
|
$num_stops = count( $alpha_values );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// Calculate positions
|
|
|
|
$positions = array_map(
|
|
|
|
function( $index ) use ( $start, $end, $num_stops ) {
|
|
|
|
return $start + ( ( $end - $start ) / ( $num_stops - 1 ) * $index );
|
|
|
|
},
|
|
|
|
array_keys( $alpha_values )
|
|
|
|
);
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-01-04 05:05:56 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// Open...
|
|
|
|
$gradient = "linear-gradient({$direction}, ";
|
2024-02-13 12:32:38 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// ... add color stops...
|
|
|
|
foreach ( $alpha_values as $index => $alpha ) {
|
|
|
|
$position = round( $positions[ $index ], 2 );
|
|
|
|
$adjusted_alpha = round( $alpha * $start_opacity, 3 );
|
|
|
|
$gradient .= "hsl({$hsl} / {$adjusted_alpha}%) {$position}%";
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
if ( $index < $num_stops - 1 ) {
|
|
|
|
$gradient .= ', ';
|
|
|
|
}
|
2023-08-26 06:06:30 +02:00
|
|
|
}
|
|
|
|
|
2024-02-15 21:07:02 +01:00
|
|
|
// ... close
|
|
|
|
$gradient .= ');';
|
|
|
|
|
|
|
|
// Return
|
|
|
|
return $gradient;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
}
|