| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : upstairsbar.co.uk ( 982) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vinfinity.co.uk/wp-content/themes/dine/inc/ |
Upload File : |
<?php
/**
* this is deprecated since 3.3
* Register custom fonts.
*/
function dine_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = trim( get_theme_mod( 'font_subsets' ) );
$font_positions = array(
'heading' => array(
'face' => 'Oswald',
'weights' => '300,400,700',
),
'nav' => array(
'face' => 'Oswald',
'weights' => '400',
),
'body' => array(
'face' => 'Lato',
'weights' => '400,700',
),
'text_slider' => array(
'face' => 'Bahiana',
'weights' => '400',
),
);
foreach ( $font_positions as $position => $font_data ) {
$weight_std = $font_data[ 'weights' ];
$source = get_theme_mod( "{$position}_font_source", 'standard' );
if ( 'local' == $source ) continue;
$face = get_theme_mod( "{$position}_font", $font_data[ 'face' ] );
if ( ! $face ) continue;
$weights = trim( get_theme_mod( "{$position}_font_weights", $weight_std ) );
$weights = explode( ',', $weights ); $weights = array_map( 'absint', $weights );
if ( isset( $fonts[ $face ] ) ) {
$fonts[ $face ] = array_merge( $fonts[ $face ], $weights );
} else {
$fonts[ $face ] = $weights;
}
}
$font_strs = [];
foreach ( $fonts as $face => $weights ) {
$weights = array_unique( $weights );
$weights = join(',', $weights);
$font_strs[] = "$face:$weights";
}
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $font_strs ) ),
'subset' => urlencode( $subsets ),
), 'https://fonts.googleapis.com/css' );
return esc_url_raw( $fonts_url );
}
return $fonts_url;
}
// add_action( 'dine_css', 'dine_font_css', 0 );
/**
* font css
* @since 3.1
*/
function dine_font_css( $css ) {
$google_fonts = dine_google_fonts();
$normal_fonts = dine_normal_fonts();
$font_assigns = array();
$font_positions = array(
'body' => 'Open Sans',
'heading' => 'Oswald',
'nav' => 'Oswald',
'text_slider' => 'Bahiana'
);
$font_face_rules = '';
$local_fonts = [];
foreach ( $font_positions as $position => $std ) {
$type = get_theme_mod( "{$position}_font_source" );
if ( 'local' != $type ) $type = 'standard';
if ( 'standard' == $type ) {
$font = get_theme_mod( "{$position}_font", $std );
if ( ! $font ) continue;
if ( isset( $normal_fonts[ $font ] ) ) {
$font = '"' . $normal_fonts[ $font ][ 'face' ] . '",' . $normal_fonts[ $font ][ 'category' ] ;
} elseif ( isset( $google_fonts[ $font ] ) ) {
$cat = $google_fonts[ $font ][ 'category' ];
if ( 'handwriting' == $cat || 'display' == $cat ) {
$fallback = 'cursive';
} else {
$fallback = $cat;
}
$font = '"' . $font . '",' . $fallback;
}
} elseif ( 'local' == $type ) {
$woff = trim( get_theme_mod( "{$position}_font_upload_woff" ) );
$woff2 = trim( get_theme_mod( "{$position}_font_upload_woff2" ) );
$font = '';
if ( $woff2 && $woff ) {
$font = trim( get_theme_mod( "{$position}_font_name" ) );
if ( ! $font ) {
$pathinfo = pathinfo( $woff2 );
$font = sanitize_title_with_dashes ( $pathinfo[ 'filename' ] );
if ( ! $font ) {
$pathinfo = pathinfo( $woff );
$font = sanitize_title_with_dashes ( $pathinfo[ 'filename' ] );
}
}
if ( ! $font ) {
$font = 'dine ' . $position . ' font';
}
$fallback = get_theme_mod( "{$position}_font_fallback" );
if ( 'serif' != $fallback ) $fallback = 'sans-serif';
/* prevent duplication from loading font twice */
if ( ! in_array( $font, $local_fonts ) ) {
$font_face_rules .= "@font-face {font-family: {$font}; src: url({$woff2}) format('woff2'), url({$woff}) format('woff');}";
}
$font = $font . ", {$fallback}";
$local_fonts[] = $font;
}
}
$font_assigns[ $position ] = $font;
}
/**
* font face rule
*/
$css = $css . $font_face_rules;
/**
* fonts
*/
foreach ( $font_assigns as $position => $font ) {
if ( 'heading' == $position ) {
$selector = dine_heading_selector();
} elseif ( 'body' == $position ) {
$selector = dine_body_selector();
} elseif ( 'nav' == $position ) {
$selector = dine_nav_selector();
} elseif ( 'text_slider' == $position ) {
$selector = dine_text_slider_selector();
}
$css .= $selector . '{font-family:' . $font . ';}';
}
return $css;
}