<?php
/**
* Theme Customizer Fonts
*
* @package Customizer_Library
* @author The Theme Foundry
*/
if ( ! function_exists( 'customizer_library_get_font_choices' ) ) :
/**
* Packages the font choices into value/label pairs for use with the customizer.
*
* @since 1.0.0.
*
* @return array The fonts in value/label pairs.
*/
function customizer_library_get_all_fonts() {
$heading1 = array( 1 => array( 'label' => sprintf( '--- %s ---', __( 'Standard Fonts', 'optimizer' ) ) ) );
$standard_fonts = customizer_library_get_standard_fonts();
$heading2 = array( 2 => array( 'label' => sprintf( '--- %s ---', __( 'Google Fonts', 'optimizer' ) ) ) );
$google_fonts = customizer_library_get_google_fonts();
/**
* Allow for developers to modify the full list of fonts.
*
* @since 1.3.0.
*
* @param array $fonts The list of all fonts.
*/
return apply_filters( 'customizer_library_all_fonts', array_merge( $heading1, $standard_fonts, $heading2, $google_fonts ) );
}
endif;
if ( ! function_exists( 'customizer_library_get_font_choices' ) ) :
/**
* Packages the font choices into value/label pairs for use with the customizer.
*
* @since 1.0.0.
*
* @return array The fonts in value/label pairs.
*/
function customizer_library_get_font_choices() {
$fonts = customizer_library_get_all_fonts();
$choices = array();
// Repackage the fonts into value/label pairs
foreach ( $fonts as $key => $font ) {
$choices[ $key ] = $font['label'];
}
return $choices;
}
endif;
if ( ! function_exists( 'customizer_library_get_google_font_uri' ) ) :
/**
* Build the HTTP request URL for Google Fonts.
*
* @since 1.0.0.
*
* @return string The URL for including Google Fonts.
*/
function customizer_library_get_google_font_uri( $fonts ) {
// De-dupe the fonts
$fonts = array_unique( $fonts );
$allowed_fonts = customizer_library_get_google_fonts();
$family = array();
// Validate each font and convert to URL format
foreach ( $fonts as $font ) {
$font = trim( $font );
// Verify that the font exists
if ( array_key_exists( $font, $allowed_fonts ) ) {
// Build the family name and variant string (e.g., "Open+Sans:regular,italic,700")
$family[] = urlencode( $font . ':' . join( ',', customizer_library_choose_google_font_variants( $font, $allowed_fonts[ $font ]['variants'] ) ) );
}
}
// Convert from array to string
if ( empty( $family ) ) {
return '';
} else {
$request = '//fonts.googleapis.com/css?display=swap&family=' . implode( '%7C', $family );
}
// Load the font subset
$subset = '';
if ( 'all' === $subset ) {
$subsets_available = customizer_library_get_google_font_subsets();
// Remove the all set
unset( $subsets_available['all'] );
// Build the array
$subsets = array_keys( $subsets_available );
} else {
$subsets = array(
'latin',
$subset,
);
}
// Append the subset string
if ( ! empty( $subsets ) ) {
$request .= urlencode( '&subset=' . join( ',', $subsets ) );
}
return esc_url( $request );
}
endif;
if ( ! function_exists( 'customizer_library_get_google_font_subsets' ) ) :
/**
* Retrieve the list of available Google font subsets.
*
* @since 1.0.0.
*
* @return array The available subsets.
*/
function customizer_library_get_google_font_subsets() {
return array(
'all' => __( 'All', 'optimizer' ),
'cyrillic' => __( 'Cyrillic', 'optimizer' ),
'cyrillic-ext' => __( 'Cyrillic Extended', 'optimizer' ),
'devanagari' => __( 'Devanagari', 'optimizer' ),
'greek' => __( 'Greek', 'optimizer' ),
'greek-ext' => __( 'Greek Extended', 'optimizer' ),
'khmer' => __( 'Khmer', 'optimizer' ),
'latin' => __( 'Latin', 'optimizer' ),
'latin-ext' => __( 'Latin Extended', 'optimizer' ),
'vietnamese' => __( 'Vietnamese', 'optimizer' ),
);
}
endif;
if ( ! function_exists( 'customizer_library_choose_google_font_variants' ) ) :
/**
* Given a font, chose the variants to load for the theme.
*
* Attempts to load regular, italic, and 700. If regular is not found, the first variant in the family is chosen. italic
* and 700 are only loaded if found. No fallbacks are loaded for those fonts.
*
* @since 1.0.0.
*
* @param string $font The font to load variants for.
* @param array $variants The variants for the font.
* @return array The chosen variants.
*/
function customizer_library_choose_google_font_variants( $font, $variants = array() ) {
$chosen_variants = array();
if ( empty( $variants ) ) {
$fonts = customizer_library_get_google_fonts();
if ( array_key_exists( $font, $fonts ) ) {
$variants = $fonts[ $font ]['variants'];
}
}
// If a "regular" variant is not found, get the first variant
if ( ! in_array( 'regular', $variants ) ) {
$chosen_variants[] = $variants[0];
} else {
$chosen_variants[] = 'regular';
}
// Only add "italic" if it exists
if ( in_array( 'italic', $variants ) ) {
$chosen_variants[] = 'italic';
}
if ( in_array( '300', $variants ) ) {
$chosen_variants[] = '300';
}
// Only add "700" if it exists
if ( in_array( '600', $variants ) ) {
$chosen_variants[] = '600';
}
// Only add "700" if it exists
if ( in_array( '700', $variants ) ) {
$chosen_variants[] = '700';
}
if ( in_array( '800', $variants ) ) {
$chosen_variants[] = '800';
}
return apply_filters( 'customizer_library_font_variants', array_unique( $chosen_variants ), $font, $variants );
}
endif;
if ( ! function_exists( 'customizer_library_get_standard_fonts' ) ) :
/**
* Return an array of standard websafe fonts.
*
* @since 1.0.0.
*
* @return array Standard websafe fonts.
*/
function customizer_library_get_standard_fonts() {
//CUSTOM FONT
global $optimizer;
$fontname ='';$customfont ='';
if($optimizer['custom_font_ttf'] && $optimizer['custom_font_eot'] && $optimizer['custom_font_woff']){
$fonturl = $optimizer['custom_font_ttf'];
$fontname = substr($fonturl, strrpos($fonturl, "/") + 1);
$fontname = str_replace('.ttf','', $fontname);
$customfont = array(
'label' => $fontname.' ['.__('Custom','optimizer').']',
'stack' => ''.$fontname.''
);
}else{
$customfont = array(
'label' => '',
'stack' => 'Georgia,Times,"Times New Roman",serif'
);
}
return array(
$fontname => $customfont,
'serif' => array(
'label' => _x( 'Serif', 'font style', 'optimizer' ),
'stack' => 'Georgia,Times,"Times New Roman",serif'
),
'sans-serif' => array(
'label' => _x( 'Sans Serif', 'font style', 'optimizer' ),
'stack' => '"Helvetica Neue",Helvetica,Arial,sans-serif'
),
'monospace' => array(
'label' => _x( 'Monospaced', 'font style', 'optimizer' ),
'stack' => 'Monaco,"Lucida Sans Typewriter","Lucida Typewriter","Courier New",Courier,monospace'
)
);
}
endif;
if ( ! function_exists( 'customizer_library_get_font_stack' ) ) :
/**
* Validate the font choice and get a font stack for it.
*
* @since 1.0.0.
*
* @param string $font The 1st font in the stack.
* @return string The full font stack.
*/
function customizer_library_get_font_stack( $font ) {
$all_fonts = customizer_library_get_all_fonts();
// Sanitize font choice
$font = customizer_library_sanitize_font_choice( $font );
$sans = '"Helvetica Neue",sans-serif';
$serif = 'Georgia, serif';
// Use stack if one is identified
if ( isset( $all_fonts[ $font ]['stack'] ) && ! empty( $all_fonts[ $font ]['stack'] ) ) {
$stack = $all_fonts[ $font ]['stack'];
} else {
$stack = '"' . $font . '",' . $sans;
}
return $stack;
}
endif;
if ( ! function_exists( 'customizer_library_sanitize_font_choice' ) ) :
/**
* Sanitize a font choice.
*
* @since 1.
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress主题】2022年最新版完整功能demo+插件v0.8.0.zip
共372个文件
php:130个
png:68个
jpg:30个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 87 浏览量
2022-04-04
04:07:07
上传
评论
收藏 3.19MB ZIP 举报
温馨提示
"【WordPress主题】2022年最新版完整功能demo+插件v0.8.0 Optimizer PRO - Optimizer WordPress Theme 优化器Pro - 优化器WordPress主题" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress主题】2022年最新版完整功能demo+插件v0.8.0.zip (372个子文件)
style.css 154KB
style_core.css 135KB
customizer.css 86KB
woo.css 50KB
shortcodes.css 37KB
font-awesome.css 31KB
live.css 28KB
backend.css 26KB
animate.min.css 20KB
admin.css 17KB
portfolio.css 14KB
colpick.css 8KB
meta.css 2KB
rtl.css 924B
customize-partial-refresh-widgets-preview.css 237B
editor-style.css 69B
fontawesome-webfont.eot 162KB
ajax-loader.gif 2KB
newloader.gif 2KB
slide.jpg 246KB
welcome_textbg.jpg 232KB
preset20.jpg 30KB
preset26.jpg 27KB
preset17.jpg 26KB
preset10.jpg 26KB
preset8.jpg 25KB
preset16.jpg 24KB
preset12.jpg 23KB
preset2.jpg 21KB
preset22.jpg 21KB
preset15.jpg 21KB
preset5.jpg 21KB
preset6.jpg 20KB
preset23.jpg 20KB
preset11.jpg 20KB
preset24.jpg 20KB
preset9.jpg 20KB
preset19.jpg 19KB
preset3.jpg 19KB
preset7.jpg 18KB
preset13.jpg 18KB
preset1.jpg 17KB
preset25.jpg 17KB
preset18.jpg 16KB
preset4.jpg 16KB
preset21.jpg 15KB
preset14.jpg 15KB
preset27.jpg 12KB
biowidget_pp.jpg 9KB
shortcodes_js.js 265KB
other.js 103KB
widget_presets.js 73KB
live.js 60KB
customizer.js 60KB
widgets.js 55KB
gallery.js 39KB
core.js 30KB
optimizer.js 26KB
masonry.js 24KB
magnific-popup.js 23KB
inlineditor.js 21KB
jquery.sly.min.js 18KB
customize-partial-refresh-widgets-preview.js 14KB
colpick.js 13KB
pagination.js 11KB
accordion.js 8KB
map-styles.js 8KB
portfolio.js 7KB
widgetize_ajax.js 4KB
customize-partial-refresh-widgets-pane.js 3KB
customize-partial-refresh-base.js 2KB
admin.js 1KB
twentythirteen.js 315B
demo5-options.json 16KB
demo24-options.json 2KB
demo12-options.json 2KB
demo22-options.json 2KB
demo11-options.json 2KB
demo1-options.json 2KB
demo2-options.json 2KB
demo4-options.json 2KB
demo20-options.json 1KB
demo9-options.json 1KB
demo25-options.json 1KB
demo18-options.json 1KB
demo7-options.json 1KB
demo27-options.json 1KB
demo26-options.json 1KB
demo13-options.json 1KB
demo17-options.json 1KB
demo23-options.json 1KB
demo21-options.json 1KB
demo14-options.json 1KB
demo15-options.json 1KB
demo16-options.json 977B
demo3-options.json 719B
demo19-options.json 686B
demo10-options.json 607B
demo6-options.json 473B
demo8-options.json 319B
共 372 条
- 1
- 2
- 3
- 4
资源评论
Lee达森
- 粉丝: 963
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功