mirror of
https://ghproxy.net/https://github.com/AlxMedia/textdash.git
synced 2025-08-26 17:00:31 +08:00
221 lines
12 KiB
PHP
221 lines
12 KiB
PHP
<?php
|
|
/* ------------------------------------------------------------------------- *
|
|
* Dynamic styles
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Convert hexadecimal to rgb
|
|
/* ------------------------------------ */
|
|
if ( ! function_exists( 'textdash_hex2rgb' ) ) {
|
|
|
|
function textdash_hex2rgb( $hex, $array=false ) {
|
|
$hex = str_replace("#", "", $hex);
|
|
|
|
if ( strlen($hex) == 3 ) {
|
|
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
|
|
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
|
|
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
|
|
} else {
|
|
$r = hexdec(substr($hex,0,2));
|
|
$g = hexdec(substr($hex,2,2));
|
|
$b = hexdec(substr($hex,4,2));
|
|
}
|
|
|
|
$rgb = array( $r, $g, $b );
|
|
if ( !$array ) { $rgb = implode(",", $rgb); }
|
|
return $rgb;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/* Google fonts
|
|
/* ------------------------------------ */
|
|
if ( ! function_exists( 'textdash_enqueue_google_fonts' ) ) {
|
|
|
|
function textdash_enqueue_google_fonts () {
|
|
if ( get_theme_mod('dynamic-styles', 'on') == 'on' ) {
|
|
if ( get_theme_mod( 'font' ) == 'titillium-web-ext' ) { wp_enqueue_style( 'titillium-web-ext', '//fonts.googleapis.com/css?family=Titillium+Web:400,400italic,300italic,300,600&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'droid-serif' ) { wp_enqueue_style( 'droid-serif', '//fonts.googleapis.com/css?family=Droid+Serif:400,400italic,700' ); }
|
|
if ( get_theme_mod( 'font' ) == 'source-sans-pro' ) { wp_enqueue_style( 'source-sans-pro', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,300italic,300,400italic,600&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'lato' ) { wp_enqueue_style( 'lato', '//fonts.googleapis.com/css?family=Lato:400,300,300italic,400italic,700' ); }
|
|
if ( get_theme_mod( 'font' ) == 'raleway' ) { wp_enqueue_style( 'raleway', '//fonts.googleapis.com/css?family=Raleway:400,300,600' ); }
|
|
if ( get_theme_mod( 'font' ) == 'ubuntu' ) { wp_enqueue_style( 'ubuntu', '//fonts.googleapis.com/css?family=Ubuntu:400,400italic,300italic,300,700&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'ubuntu-cyr' ) { wp_enqueue_style( 'ubuntu-cyr', '//fonts.googleapis.com/css?family=Ubuntu:400,400italic,300italic,300,700&subset=latin,cyrillic-ext' ); }
|
|
/*default*/ if ( ( get_theme_mod( 'font' ) == '' ) || ( get_theme_mod( 'font' ) == 'roboto' ) ) { wp_enqueue_style( 'roboto', '//fonts.googleapis.com/css?family=Roboto:400,300italic,300,400italic,700&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'roboto-cyr' ) { wp_enqueue_style( 'roboto-cyr', '//fonts.googleapis.com/css?family=Roboto:400,300italic,300,400italic,700&subset=latin,cyrillic-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'roboto-condensed' ) { wp_enqueue_style( 'roboto-condensed', '//fonts.googleapis.com/css?family=Roboto+Condensed:400,300italic,300,400italic,700&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'roboto-condensed-cyr' ) { wp_enqueue_style( 'roboto-condensed-cyr', '//fonts.googleapis.com/css?family=Roboto+Condensed:400,300italic,300,400italic,700&subset=latin,cyrillic-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'roboto-slab' ) { wp_enqueue_style( 'roboto-slab', '//fonts.googleapis.com/css?family=Roboto+Slab:400,300italic,300,400italic,700&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'roboto-slab-cyr' ) { wp_enqueue_style( 'roboto-slab-cyr', '//fonts.googleapis.com/css?family=Roboto+Slab:400,300italic,300,400italic,700&subset=latin,cyrillic-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'playfair-display' ) { wp_enqueue_style( 'playfair-display', '//fonts.googleapis.com/css?family=Playfair+Display:400,400italic,700&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'playfair-display-cyr' ) { wp_enqueue_style( 'playfair-display-cyr', '//fonts.googleapis.com/css?family=Playfair+Display:400,400italic,700&subset=latin,cyrillic' ); }
|
|
if ( get_theme_mod( 'font' ) == 'open-sans' ) { wp_enqueue_style( 'open-sans', '//fonts.googleapis.com/css?family=Open+Sans:400,400italic,300italic,300,600&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'open-sans-cyr' ) { wp_enqueue_style( 'open-sans-cyr', '//fonts.googleapis.com/css?family=Open+Sans:400,400italic,300italic,300,600&subset=latin,cyrillic-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'pt-serif' ) { wp_enqueue_style( 'pt-serif', '//fonts.googleapis.com/css?family=PT+Serif:400,700,400italic&subset=latin,latin-ext' ); }
|
|
if ( get_theme_mod( 'font' ) == 'pt-serif-cyr' ) { wp_enqueue_style( 'pt-serif-cyr', '//fonts.googleapis.com/css?family=PT+Serif:400,700,400italic&subset=latin,cyrillic-ext' ); }
|
|
}
|
|
}
|
|
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'textdash_enqueue_google_fonts' );
|
|
|
|
|
|
/* Dynamic css output
|
|
/* ------------------------------------ */
|
|
if ( ! function_exists( 'textdash_dynamic_css' ) ) {
|
|
|
|
function textdash_dynamic_css() {
|
|
if ( get_theme_mod('dynamic-styles', 'on') == 'on' ) {
|
|
|
|
// rgb values
|
|
$color_1 = get_theme_mod('color-1');
|
|
$color_1_rgb = textdash_hex2rgb($color_1);
|
|
|
|
// start output
|
|
$styles = '';
|
|
|
|
// google fonts
|
|
if ( get_theme_mod( 'font' ) == 'titillium-web-ext' ) { $styles .= 'body { font-family: "Titillium Web", Arial, sans-serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'droid-serif' ) { $styles .= 'body { font-family: "Droid Serif", serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'source-sans-pro' ) { $styles .= 'body { font-family: "Source Sans Pro", Arial, sans-serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'lato' ) { $styles .= 'body { font-family: "Lato", Arial, sans-serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'raleway' ) { $styles .= 'body { font-family: "Raleway", Arial, sans-serif; }'."\n"; }
|
|
if ( ( get_theme_mod( 'font' ) == 'ubuntu' ) || ( get_theme_mod( 'font' ) == 'ubuntu-cyr' ) ) { $styles .= 'body { font-family: "Ubuntu", Arial, sans-serif; }'."\n"; }
|
|
/*default*/ if ( ( get_theme_mod( 'font' ) == '' ) || ( get_theme_mod( 'font' ) == 'roboto' ) || ( get_theme_mod( 'font' ) == 'roboto-cyr' ) ) { $styles .= 'body { font-family: "Roboto", Arial, sans-serif; }'."\n"; }
|
|
if ( ( get_theme_mod( 'font' ) == 'roboto-condensed' ) || ( get_theme_mod( 'font' ) == 'roboto-condensed-cyr' ) ) { $styles .= 'body { font-family: "Roboto Condensed", Arial, sans-serif; }'."\n"; }
|
|
if ( ( get_theme_mod( 'font' ) == 'roboto-slab' ) || ( get_theme_mod( 'font' ) == 'roboto-slab-cyr' ) ) { $styles .= 'body { font-family: "Roboto Slab", Arial, sans-serif; }'."\n"; }
|
|
if ( ( get_theme_mod( 'font' ) == 'playfair-display' ) || ( get_theme_mod( 'font' ) == 'playfair-display-cyr' ) ) { $styles .= 'body { font-family: "Playfair Display", Arial, sans-serif; }'."\n"; }
|
|
if ( ( get_theme_mod( 'font' ) == 'open-sans' ) || ( get_theme_mod( 'font' ) == 'open-sans-cyr' ) ) { $styles .= 'body { font-family: "Open Sans", Arial, sans-serif; }'."\n"; }
|
|
if ( ( get_theme_mod( 'font' ) == 'pt-serif' ) || ( get_theme_mod( 'font' ) == 'pt-serif-cyr' ) ) { $styles .= 'body { font-family: "PT Serif", serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'arial' ) { $styles .= 'body { font-family: Arial, sans-serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'georgia' ) { $styles .= 'body { font-family: Georgia, serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'verdana' ) { $styles .= 'body { font-family: Verdana, sans-serif; }'."\n"; }
|
|
if ( get_theme_mod( 'font' ) == 'tahoma' ) { $styles .= 'body { font-family: Tahoma, sans-serif; }'."\n"; }
|
|
|
|
// container width
|
|
if ( get_theme_mod('container-width','1280') != '1280' ) {
|
|
if ( get_theme_mod( 'boxed' ) ) {
|
|
$styles .= '.boxed #wrapper { max-width: '.esc_attr( get_theme_mod('container-width') ).'px; }'."\n";
|
|
}
|
|
else {
|
|
$styles .= '.full-width #wrapper { max-width: '.esc_attr( get_theme_mod('container-width') ).'px; }'."\n";
|
|
}
|
|
}
|
|
// article width
|
|
if ( get_theme_mod('article-width','700') != '700' ) {
|
|
$styles .= '
|
|
body.single .entry > *:not(.alignfull),
|
|
body.single .entry-header,
|
|
body.single .entry-footer { max-width: '.esc_attr( get_theme_mod('article-width') ).'px; }
|
|
'."\n";
|
|
}
|
|
// primary color
|
|
if ( get_theme_mod('color-1','#027aff') != '#027aff' ) {
|
|
$styles .= '
|
|
.themeform label .required,
|
|
.entry a,
|
|
.site-title a,
|
|
.nav-menu:not(.mobile) a,
|
|
.nav-menu.mobile ul li a,
|
|
.type-list-date .type-list-date-day,
|
|
.type-list-title a,
|
|
.slick-featured-nav .slick-prev:before,
|
|
.slick-featured-nav .slick-next:before,
|
|
.featured-item .thumb-icon,
|
|
.post-comments,
|
|
.post-comments:hover,
|
|
.slick-highlights-nav .slick-prev:before,
|
|
.slick-highlights-nav .slick-next:before,
|
|
.highlights-date,
|
|
.highlights-title,
|
|
.highlights-item .thumb-icon,
|
|
.related-title a:hover,
|
|
.widget a:hover,
|
|
.alx-tabs-nav li a,
|
|
.alx-tab .tab-item-category a,
|
|
.alx-posts .post-item-category a,
|
|
.alx-tab li:hover .tab-item-title a,
|
|
.alx-tab li:hover .tab-item-comment a,
|
|
.alx-posts li:hover .post-item-title a,
|
|
.comment-tabs li.active a { color: '.esc_attr( get_theme_mod('color-1') ).'; }
|
|
|
|
.themeform input[type="button"],
|
|
.themeform input[type="reset"],
|
|
.themeform input[type="submit"],
|
|
.themeform button[type="button"],
|
|
.themeform button[type="reset"],
|
|
.themeform button[type="submit"],
|
|
.themeform input[type="button"]:hover,
|
|
.themeform input[type="reset"]:hover,
|
|
.themeform input[type="submit"]:hover,
|
|
.themeform button[type="button"]:hover,
|
|
.themeform button[type="reset"]:hover,
|
|
.themeform button[type="submit"]:hover,
|
|
.toggle-search,
|
|
.toggle-search.active,
|
|
.search-expand,
|
|
.menu-toggle-icon span,
|
|
.type-list-date .type-list-date-month,
|
|
.featured-item,
|
|
.highlights-item .post-comments,
|
|
.author-bio .bio-avatar:after,
|
|
.sidebar .post-nav li a:hover,
|
|
.widget_calendar caption,
|
|
.alx-tabs-nav li.active a { background-color: '.esc_attr( get_theme_mod('color-1') ).'; }
|
|
|
|
#profile { border-bottom: 5px solid '.esc_attr( get_theme_mod('color-1') ).'; }
|
|
|
|
.nav-menu.mobile button:focus,
|
|
.menu-toggle:focus { box-shadow: inset 0 0px 2px '.esc_attr( get_theme_mod('color-1') ).'; }
|
|
|
|
.nav-menu .svg-icon,
|
|
.nav-menu.mobile button.active .svg-icon { fill: '.esc_attr( get_theme_mod('color-1') ).'; }
|
|
|
|
.highlights-item .post-comments > span:before { border-color: transparent '.esc_attr( get_theme_mod('color-1') ).' transparent transparent; }
|
|
|
|
'."\n";
|
|
}
|
|
// secondary color
|
|
if ( get_theme_mod('color-2','#d9ebff') != '#d9ebff' ) {
|
|
$styles .= '
|
|
.nav-menu.mobile,
|
|
.type-list-date .type-list-date-day,
|
|
.type-list-inner .post-comments,
|
|
.slick-highlights-nav .slick-prev,
|
|
.slick-highlights-nav .slick-next,
|
|
.slick-highlights-nav .slick-prev:hover,
|
|
.slick-highlights-nav .slick-next:hover,
|
|
.slick-highlights-nav .slick-prev:focus,
|
|
.slick-highlights-nav .slick-next:focus,
|
|
.highlights-item,
|
|
.comment-tabs li.active a { background-color: '.esc_attr( get_theme_mod('color-2') ).'; }
|
|
|
|
.type-list-inner .post-comments > span:before { border-color: transparent '.esc_attr( get_theme_mod('color-2') ).' transparent transparent; }
|
|
'."\n";
|
|
}
|
|
// social sidebar color
|
|
if ( get_theme_mod('color-social-sidebar','#d9ebff') != '#d9ebff' ) {
|
|
$styles .= '
|
|
.s2 { background-color: '.esc_attr( get_theme_mod('color-social-sidebar') ).'; }
|
|
'."\n";
|
|
}
|
|
// body background color
|
|
if ( get_theme_mod('color-social-sidebar','#e0e6ea') != '#e0e6ea' ) {
|
|
$styles .= '
|
|
body { background-color: '.esc_attr( get_theme_mod('color-background') ).'; }
|
|
'."\n";
|
|
}
|
|
// header logo max-height
|
|
if ( get_theme_mod('logo-max-height','50') != '50' ) {
|
|
$styles .= '.site-title a img { max-height: '.esc_attr( get_theme_mod('logo-max-height') ).'px; }'."\n";
|
|
}
|
|
// header text color
|
|
if ( get_theme_mod( 'header_textcolor' ) != '' ) {
|
|
$styles .= '.site-title a, .site-description { color: #'.esc_attr( get_theme_mod( 'header_textcolor' ) ).'; }'."\n";
|
|
}
|
|
wp_add_inline_style( 'textdash-style', $styles );
|
|
}
|
|
}
|
|
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'textdash_dynamic_css' );
|