refactor(theme): remove dynamic styling systems and migrate to static CSS architecture
This commit introduces a major internal refactor of the theme, replacing all dynamic styling mechanisms with a fully static, CSS-based system. The previous implementation relied on WordPress Customizer settings, PHP-based style generation, and inline CSS injection for fonts, colors, and header behavior. These systems have been completely removed and replaced with a deterministic architecture using CSS variables and dedicated stylesheets. Key changes: - Removed dynamic font system (Google/local/inline CSS) - Removed dynamic color system and Customizer controls - Removed legacy compatibility layer (legacy-aliases.php) - Removed custom header support and related UI (header image, text color) - Eliminated inline <style> injection in wp_head - Introduced static typography system via fonts.css - Introduced static color system via colors.css - Refactored style.css to rely entirely on CSS variables - Cleaned up conflicting font declarations and redundant rules - Simplified theme structure and reduced PHP overhead - Aligned translation template with theme slug (zeitfresser.pot) Result: - Improved frontend performance and caching behavior - Reduced PHP execution and complexity - Fully deterministic rendering without runtime style mutations - Cleaner, more maintainable codebase No visual changes intended.
This commit is contained in:
@@ -15,9 +15,6 @@ require dirname( __FILE__ ) . '/includes/sanitize.php';
|
||||
require dirname( __FILE__ ) . '/includes/register-controls.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/site-identity/site-identity.php';
|
||||
require dirname( __FILE__ ) . '/colors/colors.php';
|
||||
require dirname( __FILE__ ) . '/font-family/font-family.php';
|
||||
require dirname( __FILE__ ) . '/font-customization/font-customization.php';
|
||||
require dirname( __FILE__ ) . '/general/general.php';
|
||||
require dirname( __FILE__ ) . '/post-detail/post-detail.php';
|
||||
require dirname( __FILE__ ) . '/footer-copyright/footer-copyright.php';
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_sticky_menu_background_color' );
|
||||
function zeitfresser_sticky_menu_background_color() {
|
||||
|
||||
$bg_color = get_theme_mod( 'background_color', get_theme_support( 'custom-background', 'default-color' ) );
|
||||
|
||||
$dynamic_css = "body,.site-header{background:#$bg_color;}";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_dark_color' );
|
||||
|
||||
function zeitfresser_dark_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'dark_color', array(
|
||||
'default' => zeitfresser_get_default_dark_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'dark_color', array(
|
||||
'label' => esc_html__( 'Misc Colors', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'dark_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_dark_color_enqueue_scripts' );
|
||||
function zeitfresser_dark_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-dark-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-dark/customizer-color-dark.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('dark_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--dark-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_grey_color' );
|
||||
|
||||
function zeitfresser_grey_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'grey_color', array(
|
||||
'default' => zeitfresser_get_default_grey_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'grey_color', array(
|
||||
'label' => esc_html__( 'Soft Text Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'grey_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_grey_color_enqueue_scripts' );
|
||||
function zeitfresser_grey_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-grey-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-grey/customizer-color-grey.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('grey_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--grey-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_light_color' );
|
||||
|
||||
function zeitfresser_light_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'light_color', array(
|
||||
'default' => zeitfresser_get_default_light_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'light_color', array(
|
||||
'label' => esc_html__( 'Header Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'light_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_light_color_enqueue_scripts' );
|
||||
function zeitfresser_light_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-light-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-light/customizer-color-light.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('light_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--light-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_primary_color' );
|
||||
function zeitfresser_primary_color( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'primary_color', array(
|
||||
'default' => zeitfresser_get_default_primary_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_color', array(
|
||||
'label' => esc_html__( 'Menu / Title / Button Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'primary_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_primary_color_enqueue_scripts' );
|
||||
function zeitfresser_primary_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-primary-color-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-primary/customizer-color-primary.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('primary_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--primary-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_secondary_color' );
|
||||
|
||||
function zeitfresser_secondary_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'secondary_color', array(
|
||||
'default' => zeitfresser_get_default_secondary_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondary_color', array(
|
||||
'label' => esc_html__( 'Highlight Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'secondary_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_secondary_color_enqueue_scripts' );
|
||||
function zeitfresser_secondary_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-secondary-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-secondary/customizer-color-secondary.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('secondary_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--secondary-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_site_title_color' );
|
||||
function zeitfresser_site_title_color( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'site_title_color_option', array(
|
||||
'default' => zeitfresser_get_default_site_title_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_title_color_option', array(
|
||||
'label' => esc_html__( 'Site Identity Color', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'settings' => 'site_title_color_option',
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_site_title_color_enqueue_scripts' );
|
||||
function zeitfresser_site_title_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-site-title-color-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-site-title/customizer-color-site-title.js', array(), '', true );
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize( 'site_title_color_option', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-title a' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
add_action( 'after_setup_theme', function () {
|
||||
add_theme_support( 'custom-header', array( 'header-text' => false ) );
|
||||
} );
|
||||
|
||||
add_action('customize_register', 'zeitfresser_color_section');
|
||||
function zeitfresser_color_section($wp_customize)
|
||||
{
|
||||
$wp_customize->get_section('colors')->title = esc_html__( "Color Options", 'zeitfresser' );
|
||||
$wp_customize->get_section('colors')->priority = 21;
|
||||
}
|
||||
|
||||
/* Add Default Colors for Customizer Settings */
|
||||
require dirname( __FILE__ ) . '/default-colors.php';
|
||||
|
||||
if( db_fs()->is__premium_only() ) {
|
||||
|
||||
require dirname( __FILE__ ) . '/color-site-title/color-site-title.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-primary/color-primary.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-secondary/color-secondary.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-light/color-light.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-grey/color-grey.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-dark/color-dark.php';
|
||||
}
|
||||
|
||||
require dirname( __FILE__ ) . '/color-background/color-background.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/dynamic-colors.php';
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/* Default Site Title Color */
|
||||
function zeitfresser_get_default_site_title_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Primary Color */
|
||||
function zeitfresser_get_default_primary_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Secondary Color */
|
||||
function zeitfresser_get_default_secondary_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Light Color */
|
||||
function zeitfresser_get_default_light_color() {
|
||||
return "#1e1f29";
|
||||
}
|
||||
|
||||
/* Default Grey Color */
|
||||
function zeitfresser_get_default_grey_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Dark Color */
|
||||
function zeitfresser_get_default_dark_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Background Color */
|
||||
function zeitfresser_get_default_background_color() {
|
||||
return "1e1f29";
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_site_title_color_dynamic_css' );
|
||||
function zeitfresser_site_title_color_dynamic_css() {
|
||||
|
||||
$site_title_color = esc_attr( get_theme_mod( 'site_title_color_option', zeitfresser_get_default_site_title_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --site-title-color: $site_title_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_secondary_color_dynamic_css' );
|
||||
function zeitfresser_secondary_color_dynamic_css() {
|
||||
|
||||
$secondary_color = esc_attr( get_theme_mod( 'secondary_color', zeitfresser_get_default_secondary_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --secondary-color: $secondary_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_primary_color_dynamic_css' );
|
||||
function zeitfresser_primary_color_dynamic_css() {
|
||||
|
||||
$primary_color = esc_attr( get_theme_mod( 'primary_color', zeitfresser_get_default_primary_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --primary-color: $primary_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_light_color_dynamic_css' );
|
||||
function zeitfresser_light_color_dynamic_css() {
|
||||
|
||||
$light_color = esc_attr( get_theme_mod( 'light_color', zeitfresser_get_default_light_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --light-color: $light_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_grey_color_dynamic_css' );
|
||||
function zeitfresser_grey_color_dynamic_css() {
|
||||
|
||||
$grey_color = esc_attr( get_theme_mod( 'grey_color', zeitfresser_get_default_grey_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --grey-color: $grey_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_dark_color_dynamic_css' );
|
||||
function zeitfresser_dark_color_dynamic_css() {
|
||||
|
||||
$dark_color = esc_attr( get_theme_mod( 'dark_color', zeitfresser_get_default_dark_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --dark-color: $dark_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/* Default Font Size */
|
||||
function zeitfresser_get_default_font_size() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_logo_size() {
|
||||
return 60;
|
||||
}
|
||||
|
||||
|
||||
function zeitfresser_get_default_site_identity_font_size() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
|
||||
function zeitfresser_get_default_font_weight() {
|
||||
return "400";
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_line_height() {
|
||||
return "1.6";
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_register_font_customization_section' );
|
||||
function zeitfresser_register_font_customization_section( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_section( 'daisy_blog_font_customization_section', array(
|
||||
'title' => esc_html__( 'Font Options', 'zeitfresser' ),
|
||||
'priority' => 20
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Add Default Font Customization for Customizer Settings */
|
||||
require dirname( __FILE__ ) . '/default-font-customization.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/logo-size/logo-size.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/site-identity-font-size/site-identity-font-size.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/font-size/font-size.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/font-weight/font-weight.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/line-height/line-height.php';
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('font_size',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$( 'body,html' ).css( 'font-size', to+'px' );
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_font_size' );
|
||||
function zeitfresser_font_size( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'font_size', array(
|
||||
'default' => zeitfresser_get_default_font_size(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'font_size', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'font_size',
|
||||
'label' => esc_html__( 'Body Font Size', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'input_attrs' => array(
|
||||
'min' => 1,
|
||||
'max' => 30
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_font_size_enqueue_scripts' );
|
||||
function zeitfresser_font_size_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-font-size-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/font-size/customizer-font-size.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_font_size_dynamic_css' );
|
||||
function zeitfresser_font_size_dynamic_css() {
|
||||
|
||||
$font_size = esc_attr( get_theme_mod( 'font_size', zeitfresser_get_default_font_size() ) );
|
||||
$font_size .= 'px';
|
||||
|
||||
$dynamic_css = "html,body{font-size:{$font_size};}";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('font_weight',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--font-weight', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_font_weight' );
|
||||
function zeitfresser_font_weight( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'font_weight', array(
|
||||
'default' => zeitfresser_get_default_font_weight(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'font_weight', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'font_weight',
|
||||
'label' => esc_html__( 'Body Font Weight', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'input_attrs' => array(
|
||||
'min' => 100,
|
||||
'max' => 900,
|
||||
'step' => 100
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_font_weight_enqueue_scripts' );
|
||||
function zeitfresser_font_weight_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-font-weight-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/font-weight/customizer-font-weight.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_font_weight_dynamic_css' );
|
||||
function zeitfresser_font_weight_dynamic_css() {
|
||||
|
||||
$font_weight = esc_attr( get_theme_mod( 'font_weight', zeitfresser_get_default_font_weight() ) );
|
||||
|
||||
$dynamic_css = ":root { --font-weight: $font_weight; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('line_height',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--line-height', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_line_height' );
|
||||
function zeitfresser_line_height( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'line_height', array(
|
||||
'default' => zeitfresser_get_default_line_height(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_float'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'line_height', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'line_height',
|
||||
'label' => esc_html__( 'Line Height', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'input_attrs' => array(
|
||||
'min' => 1,
|
||||
'max' => 5,
|
||||
'step' => 0.1
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_line_height_enqueue_scripts' );
|
||||
function zeitfresser_line_height_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-line-height-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/line-height/customizer-line-height.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_line_height_dynamic_css' );
|
||||
function zeitfresser_line_height_dynamic_css() {
|
||||
|
||||
$line_height = esc_attr( get_theme_mod( 'line_height', zeitfresser_get_default_line_height() ) );
|
||||
|
||||
$dynamic_css = ":root { --line-height: $line_height; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('logo_size',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--logo-size', to+'px');
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_logo_size' );
|
||||
function zeitfresser_logo_size( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'logo_size', array(
|
||||
'default' => zeitfresser_get_default_logo_size(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'logo_size', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'logo_size',
|
||||
'priority' => 8,
|
||||
'label' => esc_html__( 'Logo Size', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'input_attrs' => array(
|
||||
'min' => 10,
|
||||
'max' => 100
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_logo_size_enqueue_scripts' );
|
||||
function zeitfresser_logo_size_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-logo-size-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/logo-size/customizer-logo-size.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_logo_size_dynamic_css' );
|
||||
function zeitfresser_logo_size_dynamic_css() {
|
||||
|
||||
$logo_size = esc_attr( get_theme_mod( 'logo_size', zeitfresser_get_default_logo_size() ) );
|
||||
$logo_size .= 'px';
|
||||
|
||||
$dynamic_css = ":root { --logo-size: $logo_size; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('site_identity_font_size',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--site-identity-font-size', to+'px');
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_site_identity_font_size' );
|
||||
function zeitfresser_site_identity_font_size( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'site_identity_font_size', array(
|
||||
'default' => zeitfresser_get_default_site_identity_font_size(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'site_identity_font_size', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'site_identity_font_size',
|
||||
'label' => esc_html__( 'Site Identity Size', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'input_attrs' => array(
|
||||
'min' => 10,
|
||||
'max' => 40
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_site_identity_font_size_enqueue_scripts' );
|
||||
function zeitfresser_site_identity_font_size_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-site-identity-font-size-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/site-identity-font-size/customizer-site-identity-font-size.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_site_identity_font_size_dynamic_css' );
|
||||
function zeitfresser_site_identity_font_size_dynamic_css() {
|
||||
|
||||
$site_identity_font_size = esc_attr( get_theme_mod( 'site_identity_font_size', zeitfresser_get_default_site_identity_font_size() ) );
|
||||
$site_identity_font_size .= 'px';
|
||||
|
||||
$dynamic_css = ":root { --site-identity-font-size: $site_identity_font_size; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Default Font Family */
|
||||
function zeitfresser_get_default_site_identity_font_family() {
|
||||
return esc_html__( "Oswald", 'zeitfresser' );
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_main_font_family() {
|
||||
return esc_html__( "Oswald", 'zeitfresser' );
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_secondary_font_family() {
|
||||
return esc_html__( "Roboto", 'zeitfresser' );
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Add Google Fonts */
|
||||
require dirname( __FILE__ ) . '/google-fonts.php';
|
||||
|
||||
/* Add Default Font Family for Customizer Settings */
|
||||
require dirname( __FILE__ ) . '/default-font-family.php';
|
||||
|
||||
include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/helper-functions.php' );
|
||||
include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/class-webfonts-local.php' );
|
||||
include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/class-fonts-google-local.php' );
|
||||
|
||||
|
||||
|
||||
require dirname( __FILE__ ) . '/site-identity/site-identity-font-family.php';
|
||||
require dirname( __FILE__ ) . '/main/main-font-family.php';
|
||||
require dirname( __FILE__ ) . '/secondary/secondary-font-family.php';
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_google_fonts_scripts', 5 );
|
||||
function zeitfresser_google_fonts_scripts() {
|
||||
$local_css = zeitfresser_get_local_webfonts_css();
|
||||
|
||||
wp_register_style( 'zeitfresser-webfonts', false, array(), ZEITFRESSER_VERSION );
|
||||
wp_enqueue_style( 'zeitfresser-webfonts' );
|
||||
|
||||
if ( ! empty( $local_css ) ) {
|
||||
wp_add_inline_style( 'zeitfresser-webfonts', $local_css );
|
||||
return;
|
||||
}
|
||||
|
||||
$args = zeitfresser_used_google_fonts();
|
||||
$fonts_url = zeitfresser_fonts_url( $args );
|
||||
|
||||
if ( empty( $fonts_url ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'google-fonts', $fonts_url, array(), null );
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,457 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles downloading a font from the google-fonts API locally.
|
||||
* Solves privacy concerns with Google's CDN
|
||||
* and their sometimes less-than-transparent policies.
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
// Do not allow directly accessing this file.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit( 'Direct script access denied.' );
|
||||
}
|
||||
|
||||
final class Daisy_Blog_Google_Local {
|
||||
|
||||
/**
|
||||
* The name of the font-family
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $family;
|
||||
|
||||
/**
|
||||
* The system path where font-files are stored.
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $folder_path;
|
||||
|
||||
/**
|
||||
* The URL where files for this font can be found.
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $folder_url;
|
||||
|
||||
/**
|
||||
* An array of instances for this object.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $instances = array();
|
||||
|
||||
/**
|
||||
* Create an instance of this object for a specific font-family.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $family The font-family name.
|
||||
* @return Daisy_Blog_Google_Local
|
||||
*/
|
||||
public static function init( $family ) {
|
||||
$key = sanitize_key( $family );
|
||||
if ( ! isset( self::$instances[ $key ] ) ) {
|
||||
self::$instances[ $key ] = new self( $family );
|
||||
}
|
||||
return self::$instances[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access private
|
||||
* @param string $family The font-family name.
|
||||
*/
|
||||
private function __construct( $family ) {
|
||||
$this->family = $family;
|
||||
$key = sanitize_key( $this->family );
|
||||
$this->folder_path = $this->get_root_path() . "/$key";
|
||||
$this->folder_url = $this->get_root_url() . "/$key";
|
||||
$this->files = $this->get_font_family();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the @font-face CSS.
|
||||
*
|
||||
* @access public
|
||||
* @param array $variants The variants we want to get.
|
||||
* @return string
|
||||
*/
|
||||
public function get_css( $variants = array() ) {
|
||||
if ( ! $this->files ) {
|
||||
return;
|
||||
}
|
||||
$key = md5( wp_json_encode( $this->files ) );
|
||||
$cached = get_transient( $key );
|
||||
if ( $cached ) {
|
||||
return $cached;
|
||||
}
|
||||
$css = '';
|
||||
|
||||
// If $variants is empty then use all variants available.
|
||||
if ( empty( $variants ) ) {
|
||||
$variants = array_keys( $this->files );
|
||||
}
|
||||
|
||||
// Download files.
|
||||
$this->download_font_family( $variants );
|
||||
|
||||
// Create the @font-face CSS.
|
||||
foreach ( $variants as $variant ) {
|
||||
$css .= $this->get_variant_fontface_css( $variant );
|
||||
}
|
||||
set_transient( $key, $css, WEEK_IN_SECONDS );
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download font-family files.
|
||||
*
|
||||
* @access public
|
||||
* @param array $variants An array of variants to download. Leave empty to download all.
|
||||
* @return void
|
||||
*/
|
||||
public function download_font_family( $variants = array() ) {
|
||||
if ( empty( $variants ) ) {
|
||||
$variants = array_keys( $this->files );
|
||||
}
|
||||
foreach ( $this->files as $variant => $file ) {
|
||||
if ( in_array( $variant, $variants ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
$this->download_font_file( $file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a font-file and saves it locally.
|
||||
*
|
||||
* @access private
|
||||
* @param string $url The URL of the file we want to get.
|
||||
* @return bool
|
||||
*/
|
||||
private function download_font_file( $url ) {
|
||||
$path = $this->folder_path . '/' . $this->get_filename_from_url( $url );
|
||||
|
||||
// If the folder doesn't exist, create it.
|
||||
if ( ! file_exists( $this->folder_path ) ) {
|
||||
wp_mkdir_p( $this->folder_path );
|
||||
}
|
||||
// If the file exists no reason to do anything.
|
||||
if ( file_exists( $path ) ) {
|
||||
return true;
|
||||
}else{
|
||||
$contents = $this->get_remote_url_contents( $url );
|
||||
// Write file.
|
||||
$filesystem = $this->get_filesystem();
|
||||
return $filesystem->put_contents( $path, $contents, FS_CHMOD_FILE );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remote URL contents.
|
||||
*
|
||||
* @access private
|
||||
* @param string $url The URL we want to get.
|
||||
* @return string The contents of the remote URL.
|
||||
*/
|
||||
public function get_remote_url_contents( $url ) {
|
||||
$response = wp_remote_get( $url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return array();
|
||||
}
|
||||
$html = wp_remote_retrieve_body( $response );
|
||||
if ( is_wp_error( $html ) ) {
|
||||
return;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filename by breaking-down the URL parts.
|
||||
*
|
||||
* @access private
|
||||
* @param string $url The URL.
|
||||
* @return string The filename.
|
||||
*/
|
||||
private function get_filename_from_url( $url ) {
|
||||
$url_parts = explode( '/', $url );
|
||||
$parts_count = count( $url_parts );
|
||||
if ( 1 < $parts_count ) {
|
||||
return $url_parts[ count( $url_parts ) - 1 ];
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the @font-face CSS for a specific variant.
|
||||
*
|
||||
* @access public
|
||||
* @param string $variant The variant.
|
||||
* @return string
|
||||
*/
|
||||
public function get_variant_fontface_css( $variant ) {
|
||||
$font_face = "@font-face{font-family:'{$this->family}';";
|
||||
|
||||
// Get the font-style.
|
||||
$font_style = ( false !== strpos( $variant, 'italic' ) ) ? 'italic' : 'normal';
|
||||
$font_face .= "font-style:{$font_style};";
|
||||
|
||||
// Get the font-weight.
|
||||
$font_weight = '400';
|
||||
$font_weight = str_replace( 'italic', '', $variant );
|
||||
$font_weight = ( ! $font_weight || 'regular' === $font_weight ) ? '400' : $font_weight;
|
||||
$font_face .= "font-weight:{$font_weight};";
|
||||
|
||||
// Get the font-names.
|
||||
$font_name_0 = $this->get_local_font_name( $variant, false );
|
||||
$font_name_1 = $this->get_local_font_name( $variant, true );
|
||||
$font_face .= "src:local('{$font_name_0}'),";
|
||||
if ( $font_name_0 !== $font_name_1 ) {
|
||||
$font_face .= "local('{$font_name_1}'),";
|
||||
}
|
||||
|
||||
// Get the font-url.
|
||||
$font_url = $this->get_variant_local_url( $variant );
|
||||
$paths = $this->get_font_files_paths();
|
||||
if ( ! file_exists( $paths[ $variant ] ) ) {
|
||||
$font_url = $this->files[ $variant ];
|
||||
}
|
||||
|
||||
// Get the font-format.
|
||||
$font_format = ( strpos( $font_url, '.woff2' ) ) ? 'woff2' : 'truetype';
|
||||
$font_format = ( strpos( $font_url, '.woff' ) && ! strpos( $font_url, '.woff2' ) ) ? 'woff' : $font_format;
|
||||
$font_face .= "url({$font_url}) format('{$font_format}');}";
|
||||
|
||||
return $font_face;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the font-family.
|
||||
* This is used by @font-face in case the user already has the font downloaded locally.
|
||||
*
|
||||
* @access public
|
||||
* @param string $variant The variant.
|
||||
* @param bool $compact Whether we want the compact formatting or not.
|
||||
* @return string
|
||||
*/
|
||||
public function get_local_font_name( $variant, $compact = false ) {
|
||||
$variant_names = array(
|
||||
'100' => 'Thin',
|
||||
'100i' => 'Thin Italic',
|
||||
'100italic' => 'Thin Italic',
|
||||
'200' => 'Extra-Light',
|
||||
'200i' => 'Extra-Light Italic',
|
||||
'200italic' => 'Extra-Light Italic',
|
||||
'300' => 'Light',
|
||||
'300i' => 'Light Italic',
|
||||
'300italic' => 'Light Italic',
|
||||
'400' => 'Regular',
|
||||
'regular' => 'Regular',
|
||||
'400i' => 'Regular Italic',
|
||||
'italic' => 'Italic',
|
||||
'400italic' => 'Regular Italic',
|
||||
'500' => 'Medium',
|
||||
'500i' => 'Medium Italic',
|
||||
'500italic' => 'Medium Italic',
|
||||
'600' => 'Semi-Bold',
|
||||
'600i' => 'Semi-Bold Italic',
|
||||
'600italic' => 'Semi-Bold Italic',
|
||||
'700' => 'Bold',
|
||||
'700i' => 'Bold Italic',
|
||||
'700italic' => 'Bold Italic',
|
||||
'800' => 'Extra-Bold',
|
||||
'800i' => 'Extra-Bold Italic',
|
||||
'800italic' => 'Extra-Bold Italic',
|
||||
'900' => 'Black',
|
||||
'900i' => 'Black Italic',
|
||||
'900italic' => 'Black Italic',
|
||||
);
|
||||
|
||||
$variant = (string) $variant;
|
||||
if ( $compact ) {
|
||||
if ( isset( $variant_names[ $variant ] ) ) {
|
||||
return str_replace( array( ' ', '-' ), '', $this->family ) . '-' . str_replace( array( ' ', '-' ), '', $variant_names[ $variant ] );
|
||||
}
|
||||
return str_replace( array( ' ', '-' ), '', $this->family );
|
||||
}
|
||||
|
||||
if ( isset( $variant_names[ $variant ] ) ) {
|
||||
return $this->family . ' ' . $variant_names[ $variant ];
|
||||
}
|
||||
return $this->family;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local URL for a variant.
|
||||
*
|
||||
* @access public
|
||||
* @param string $variant The variant.
|
||||
* @return string The URL.
|
||||
*/
|
||||
public function get_variant_local_url( $variant ) {
|
||||
$local_urls = $this->get_font_files_urls_local();
|
||||
|
||||
if ( empty( $local_urls ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Return the specific variant if we can find it.
|
||||
if ( isset( $local_urls[ $variant ] ) ) {
|
||||
return $local_urls[ $variant ];
|
||||
}
|
||||
|
||||
// Return regular if the one we want could not be found.
|
||||
if ( isset( $local_urls['regular'] ) ) {
|
||||
return $local_urls['regular'];
|
||||
}
|
||||
|
||||
// Return the first available if all else failed.
|
||||
$vals = array_values( $local_urls );
|
||||
return $vals[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of local file URLs.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_files_urls_local() {
|
||||
$urls = array();
|
||||
$files = $this->get_font_files();
|
||||
foreach ( $files as $key => $file ) {
|
||||
$urls[ $key ] = $this->folder_url . '/' . $file;
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of local file paths.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_files_paths() {
|
||||
$paths = array();
|
||||
$files = $this->get_font_files();
|
||||
foreach ( $files as $key => $file ) {
|
||||
$paths[ $key ] = $this->folder_path . '/' . $file;
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of font-files.
|
||||
* Only contains the filenames.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_files() {
|
||||
$files = array();
|
||||
foreach ( $this->files as $key => $url ) {
|
||||
$files[ $key ] = $this->get_filename_from_url( $url );
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root fonts folder path.
|
||||
* Other paths are built based on this.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get_root_path() {
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$upload_dir = wp_upload_dir();
|
||||
$path = untrailingslashit( wp_normalize_path( $upload_dir['basedir'] ) ) . '/webfonts';
|
||||
|
||||
// If the folder doesn't exist, create it.
|
||||
if ( ! file_exists( $path ) ) {
|
||||
wp_mkdir_p( $path );
|
||||
}
|
||||
|
||||
// Return the path.
|
||||
return apply_filters( 'daisy_blog_googlefonts_root_path', $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root folder url.
|
||||
* Other urls are built based on this.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get_root_url() {
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$upload_dir = wp_upload_dir();
|
||||
|
||||
// The URL.
|
||||
$url = trailingslashit( $upload_dir['baseurl'] );
|
||||
|
||||
// Take care of domain mapping.
|
||||
// When using domain mapping we have to make sure that the URL to the file
|
||||
// does not include the original domain but instead the mapped domain.
|
||||
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
|
||||
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
|
||||
$mapped_domain = domain_mapping_siteurl( false );
|
||||
$original_domain = get_original_url( 'siteurl' );
|
||||
$url = str_replace( $original_domain, $mapped_domain, $url );
|
||||
}
|
||||
}
|
||||
$url = str_replace( array( 'https://', 'http://' ), '//', $url );
|
||||
return apply_filters( 'daisy_blog_googlefonts_root_url', untrailingslashit( esc_url_raw( $url ) ) . '/webfonts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a font-family from the array of google-fonts.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_family() {
|
||||
// Get the fonts array.
|
||||
$fonts = $this->get_fonts();
|
||||
if ( isset( $fonts[ $this->family ] ) ) {
|
||||
return $fonts[ $this->family ];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font defined in the google-fonts API.
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function get_fonts() {
|
||||
zeitfresser_get_google_fonts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the WP_Filesystem object.
|
||||
*
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function get_filesystem(){
|
||||
// The WordPress filesystem.
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
|
||||
WP_Filesystem();
|
||||
}
|
||||
return $wp_filesystem;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles adding to the footer the @font-face CSS for locally-hosted google-fonts.
|
||||
* Solves privacy concerns with Google's CDN and their sometimes less-than-transparent policies.
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Manages the way Google Fonts are enqueued.
|
||||
*/
|
||||
final class Daisy_Blog_Webfonts_Local{
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected $googlefonts;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function __construct( $googlefonts ) {
|
||||
$this->googlefonts = $googlefonts;
|
||||
|
||||
add_action( 'wp_footer', array( $this, 'add_styles' ) );
|
||||
add_action( 'admin_footer', array( $this, 'add_styles' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Webfont Loader for Google Fonts.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function add_styles() {
|
||||
|
||||
$hosted_fonts = $this->googlefonts;
|
||||
|
||||
// Early exit if we don't need to add any fonts.
|
||||
if ( empty( $hosted_fonts ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we only do this once per font-family.
|
||||
$hosted_fonts = array_unique( $hosted_fonts );
|
||||
|
||||
// Start CSS.
|
||||
$css = '';
|
||||
foreach( $hosted_fonts as $family ){
|
||||
// Add the @font-face CSS for this font-family.
|
||||
$css .= Daisy_Blog_Google_Local::init( $family )->get_css();
|
||||
}
|
||||
|
||||
// If we've got CSS, add to the footer.
|
||||
if ( $css ) {
|
||||
echo '<style id="daisy-blog-local-webfonts">' . $css . '</style>'; // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,334 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Function to check if it's a google font
|
||||
*/
|
||||
function zeitfresser_is_google_font( $font ){
|
||||
$return = false;
|
||||
$websafe_fonts = zeitfresser_get_websafe_font();
|
||||
if( $font ){
|
||||
if( array_key_exists( $font, $websafe_fonts ) ){
|
||||
//Web Safe Font
|
||||
$return = false;
|
||||
}else{
|
||||
//Google Font
|
||||
$return = true;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_get_websafe_font' ) ) {
|
||||
|
||||
/**
|
||||
* Function listing WebSafe Fonts and its attributes
|
||||
*/
|
||||
function zeitfresser_get_websafe_font(){
|
||||
$standard_fonts = array(
|
||||
'georgia-serif' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Georgia, serif',
|
||||
),
|
||||
'palatino-serif' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Palatino Linotype", "Book Antiqua", Palatino, serif',
|
||||
),
|
||||
'times-serif' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Times New Roman", Times, serif',
|
||||
),
|
||||
'arial-helvetica' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Arial, Helvetica, sans-serif',
|
||||
),
|
||||
'arial-gadget' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Arial Black", Gadget, sans-serif',
|
||||
),
|
||||
'comic-cursive' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Comic Sans MS", cursive, sans-serif',
|
||||
),
|
||||
'impact-charcoal' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Impact, Charcoal, sans-serif',
|
||||
),
|
||||
'lucida' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif',
|
||||
),
|
||||
'tahoma-geneva' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Tahoma, Geneva, sans-serif',
|
||||
),
|
||||
'trebuchet-helvetica' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Trebuchet MS", Helvetica, sans-serif',
|
||||
),
|
||||
'verdana-geneva' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Verdana, Geneva, sans-serif',
|
||||
),
|
||||
'courier' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Courier New", Courier, monospace',
|
||||
),
|
||||
'lucida-monaco' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Lucida Console", Monaco, monospace',
|
||||
)
|
||||
);
|
||||
|
||||
return apply_filters( 'daisy_blog_standard_fonts', $standard_fonts );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function zeitfresser_used_google_fonts() {
|
||||
$main_font_family = zeitfresser_get_mod( 'main_font_family', zeitfresser_get_default_main_font_family() );
|
||||
$secondary_font_family = zeitfresser_get_mod( 'secondary_font_family', zeitfresser_get_default_secondary_font_family() );
|
||||
$site_identity_font_family = esc_attr( zeitfresser_get_mod( 'site_identity_font_family', zeitfresser_get_default_site_identity_font_family() ) );
|
||||
|
||||
$args['main_font_family'] = $main_font_family;
|
||||
$args['secondary_font_family'] = $secondary_font_family;
|
||||
$args['site_identity_font_family'] = $site_identity_font_family;
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_action( 'wp_loaded', 'zeitfresser_google_font_local' );
|
||||
if( ! function_exists( 'zeitfresser_google_font_local' ) ) {
|
||||
/**
|
||||
* Function that load Google Fonts used in our theme from customer locally.
|
||||
* Solves privacy concerns with Google's CDN and their sometimes less-than-transparent policies.
|
||||
*/
|
||||
function zeitfresser_google_font_local() {
|
||||
|
||||
$args = array();
|
||||
$fonts = zeitfresser_used_google_fonts();
|
||||
|
||||
foreach( $fonts as $font ) {
|
||||
|
||||
$is_google_font = zeitfresser_is_google_font( $font );
|
||||
|
||||
if( $is_google_font ) {
|
||||
array_push( $args, $font );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new Daisy_Blog_Webfonts_Local( $args );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_font_weight_variants' ) ) {
|
||||
/**
|
||||
* Return the font variants used by the theme as an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_font_weight_variants() {
|
||||
$weights = explode( ';', zeitfresser_font_weight_query() );
|
||||
$weights = array_map( 'trim', $weights );
|
||||
$weights = array_filter( $weights );
|
||||
|
||||
if ( ! in_array( '400', $weights, true ) ) {
|
||||
$weights[] = '400';
|
||||
}
|
||||
|
||||
$weights = array_values( array_unique( $weights ) );
|
||||
sort( $weights );
|
||||
|
||||
return $weights;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_get_local_webfonts_css' ) ) {
|
||||
/**
|
||||
* Build local @font-face CSS for currently selected Google fonts.
|
||||
*
|
||||
* Falls back to remote font file URLs per variant if a local file is not
|
||||
* available yet, so typography does not break during warmup.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function zeitfresser_get_local_webfonts_css() {
|
||||
$fonts = array_values( array_unique( array_filter( zeitfresser_used_google_fonts() ) ) );
|
||||
$variants = zeitfresser_font_weight_variants();
|
||||
$css = '';
|
||||
|
||||
foreach ( $fonts as $font ) {
|
||||
if ( ! zeitfresser_is_google_font( $font ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$css .= Daisy_Blog_Google_Local::init( $font )->get_css( $variants );
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_get_local_webfont_urls' ) ) {
|
||||
/**
|
||||
* Extract local font asset URLs from a generated @font-face stylesheet.
|
||||
*
|
||||
* @param string $css Local webfont CSS.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_get_local_webfont_urls( $css ) {
|
||||
if ( empty( $css ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
preg_match_all( '#url\(([^)]+)\)#', $css, $matches );
|
||||
|
||||
if ( empty( $matches[1] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$urls = array();
|
||||
|
||||
foreach ( $matches[1] as $url ) {
|
||||
$url = trim( $url, "\"'" );
|
||||
|
||||
if ( false !== strpos( $url, content_url() ) ) {
|
||||
$urls[] = esc_url_raw( $url );
|
||||
}
|
||||
}
|
||||
|
||||
return array_values( array_unique( array_filter( $urls ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_font_weight_query' ) ) {
|
||||
/**
|
||||
* Return the compact weight list used by the Zeitfresser theme.
|
||||
*/
|
||||
function zeitfresser_font_weight_query() {
|
||||
$weights = array( '400', '500', '700' );
|
||||
$body_weight = (string) zeitfresser_get_mod( 'font_weight', zeitfresser_get_default_font_weight() );
|
||||
|
||||
if ( preg_match( '/^\d{3}$/', $body_weight ) ) {
|
||||
$weights[] = $body_weight;
|
||||
}
|
||||
|
||||
$weights = array_values( array_unique( array_filter( $weights ) ) );
|
||||
sort( $weights );
|
||||
|
||||
return implode( ';', $weights );
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists( 'zeitfresser_fonts_url' ) ) {
|
||||
/**
|
||||
* Returns a Google Fonts CSS2 URL for the selected theme fonts.
|
||||
*/
|
||||
function zeitfresser_fonts_url( $fonts = array() ) {
|
||||
$font_families = array();
|
||||
$weights = zeitfresser_font_weight_query();
|
||||
|
||||
foreach ( $fonts as $font ) {
|
||||
if ( ! zeitfresser_is_google_font( $font ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$family_name = trim( (string) $font );
|
||||
|
||||
if ( '' === $family_name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$font_families[] = 'family=' . str_replace( ' ', '+', $family_name ) . ':wght@' . $weights;
|
||||
}
|
||||
|
||||
$font_families = array_values( array_unique( $font_families ) );
|
||||
|
||||
if ( empty( $font_families ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return esc_url( 'https://fonts.googleapis.com/css2?' . implode( '&', $font_families ) . '&display=swap' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_check_varient' ) ) {
|
||||
/**
|
||||
* Checks for matched varients in google fonts for typography fields
|
||||
*/
|
||||
function zeitfresser_check_varient( $font_family = 'serif', $font_variants = 'regular', $body = false ){
|
||||
$variant = '';
|
||||
$var = array();
|
||||
$google_fonts = zeitfresser_get_google_fonts(); //Google Fonts
|
||||
$websafe_fonts = zeitfresser_get_websafe_font(); //Standard Web Safe Fonts
|
||||
|
||||
if( array_key_exists( $font_family, $google_fonts ) ){
|
||||
$variants = $google_fonts[ $font_family ][ 'variants' ];
|
||||
if( in_array( $font_variants, $variants ) ){
|
||||
if( $body ){ //LOAD ALL VARIANTS FOR BODY FONT
|
||||
foreach( $variants as $v ){
|
||||
$var[] = $v;
|
||||
}
|
||||
$variant = implode( ',', $var );
|
||||
}else{
|
||||
$variant = $font_variants;
|
||||
}
|
||||
}else{
|
||||
$variant = 'regular';
|
||||
}
|
||||
}else{ //Standard Web Safe Fonts
|
||||
if( array_key_exists( $font_family, $websafe_fonts ) ){
|
||||
$variants = $websafe_fonts[ $font_family ][ 'variants' ];
|
||||
if( in_array( $font_variants, $variants ) ){
|
||||
if( $body ){ //LOAD ALL VARIANTS FOR BODY FONT
|
||||
foreach( $variants as $v ){
|
||||
$var[] = $v;
|
||||
}
|
||||
$variant = implode( ',', $var );
|
||||
}else{
|
||||
$variant = $font_variants;
|
||||
}
|
||||
}else{
|
||||
$variant = 'regular';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $variant;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_get_google_fonts' ) ) {
|
||||
/**
|
||||
* Get Google Fonts
|
||||
*/
|
||||
function zeitfresser_get_google_fonts(){
|
||||
$webfonts_json = @file_get_contents( get_template_directory_uri() . '/inc/blocks/font-family/inc/google-webfonts.json', true );
|
||||
$fonts = json_decode( $webfonts_json, true );
|
||||
|
||||
$google_fonts = array();
|
||||
|
||||
if ( is_array( $fonts ) ) {
|
||||
foreach ( $fonts['items'] as $font ) {
|
||||
$google_fonts[ $font['family'] ] = array(
|
||||
'variants' => $font['variants'],
|
||||
);
|
||||
}
|
||||
}
|
||||
return $google_fonts;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('main_font_family',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$("head").append("<link href='https://fonts.googleapis.com/css?family=" + to + ":200,300,400,500,600,700,800,900|' rel='stylesheet' type='text/css'>");
|
||||
document.body.style.setProperty('--primary-font', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_main_font_family' );
|
||||
function zeitfresser_main_font_family( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'main_font_family', array(
|
||||
'default' => zeitfresser_get_default_main_font_family(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_google_fonts'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'main_font_family', array(
|
||||
'settings' => 'main_font_family',
|
||||
'label' => esc_html__( 'Primary Font', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'type' => 'select',
|
||||
'choices' => zeitfresser_google_fonts( zeitfresser_free_pro() ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_main_font_family_enqueue_scripts' );
|
||||
function zeitfresser_main_font_family_enqueue_scripts() {
|
||||
|
||||
$main_font_family = esc_attr( get_theme_mod( 'main_font_family', zeitfresser_get_default_main_font_family() ) );
|
||||
|
||||
wp_enqueue_script( 'graphthemes-main-font-family-customizer', get_template_directory_uri() . '/inc/blocks/font-family/main/customizer-main-font-family.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_main_font_family_dynamic_css' );
|
||||
function zeitfresser_main_font_family_dynamic_css() {
|
||||
|
||||
$main_font_family = esc_attr( get_theme_mod( 'main_font_family', zeitfresser_get_default_main_font_family() ) );
|
||||
|
||||
$dynamic_css = ":root { --primary-font: $main_font_family; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('secondary_font_family',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$("head").append("<link href='https://fonts.googleapis.com/css?family=" + to + ":200,300,400,500,600,700,800,900|' rel='stylesheet' type='text/css'>");
|
||||
document.body.style.setProperty('--secondary-font', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_secondary_font_family' );
|
||||
function zeitfresser_secondary_font_family( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'secondary_font_family', array(
|
||||
'default' => zeitfresser_get_default_secondary_font_family(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_google_fonts'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'secondary_font_family', array(
|
||||
'settings' => 'secondary_font_family',
|
||||
'label' => esc_html__( 'Secondary Font', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'type' => 'select',
|
||||
'choices' => zeitfresser_google_fonts( zeitfresser_free_pro() ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_secondary_font_family_enqueue_scripts' );
|
||||
function zeitfresser_secondary_font_family_enqueue_scripts() {
|
||||
|
||||
$secondary_font_family = esc_attr( get_theme_mod( 'secondary_font_family', zeitfresser_get_default_secondary_font_family() ) );
|
||||
|
||||
|
||||
wp_enqueue_script( 'graphthemes-secondary-font-family-customizer', get_template_directory_uri() . '/inc/blocks/font-family/secondary/customizer-secondary-font-family.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_secondary_font_family_dynamic_css' );
|
||||
function zeitfresser_secondary_font_family_dynamic_css() {
|
||||
|
||||
$secondary_font_family = esc_attr( get_theme_mod( 'secondary_font_family', zeitfresser_get_default_secondary_font_family() ) );
|
||||
|
||||
|
||||
$dynamic_css = ":root { --secondary-font: $secondary_font_family; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('site_identity_font_family',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$("head").append("<link rel='stylesheet' href='https://fonts.googleapis.com/css?family="+to+":200,300,400,500,600,700,800,900|' rel='stylesheet' type='text/css'>");
|
||||
document.body.style.setProperty('--site-identity-font-family', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_site_identity_font_family' );
|
||||
function zeitfresser_site_identity_font_family( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'site_identity_font_family', array(
|
||||
'default' => zeitfresser_get_default_site_identity_font_family(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_google_fonts'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'site_identity_font_family', array(
|
||||
'settings' => 'site_identity_font_family',
|
||||
'label' => esc_html__( 'Site Title/Tagline Font', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'type' => 'select',
|
||||
'choices' => zeitfresser_google_fonts( zeitfresser_free_pro() ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_site_identity_font_family_enqueue_scripts' );
|
||||
function zeitfresser_site_identity_font_family_enqueue_scripts() {
|
||||
|
||||
$site_identity_font_family = esc_attr( get_theme_mod( 'site_identity_font_family', zeitfresser_get_default_site_identity_font_family() ) );
|
||||
|
||||
|
||||
wp_enqueue_script( 'graphthemes-site-identity-font-family-customizer', get_template_directory_uri() . '/inc/blocks/font-family/site-identity/customizer-site-identity-font-family.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_site_identity_font_family_dynamic_css' );
|
||||
function zeitfresser_site_identity_font_family_dynamic_css() {
|
||||
|
||||
$site_identity_font_family = esc_attr( get_theme_mod( 'site_identity_font_family', zeitfresser_get_default_site_identity_font_family() ) );
|
||||
|
||||
$dynamic_css = ":root { --site-identity-font-family: $site_identity_font_family; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
Reference in New Issue
Block a user