| 1 |
<?php |
| 2 |
|
| 3 |
if( ! function_exists( 'themify_get_google_font_lists' ) ) : |
| 4 |
|
| 5 |
/** |
| 6 |
* Get google font lists |
| 7 |
* @return array |
| 8 |
*/ |
| 9 |
function themify_get_google_font_lists() { |
| 10 |
return (defined( 'THEMIFY_GOOGLE_FONTS' ) && THEMIFY_GOOGLE_FONTS != true)?array():include( themify_get_google_fonts_file() ); |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Return file to use depending if user selected Recommended or Full list in theme settings. |
| 15 |
* |
| 16 |
* @since 2.1.7 |
| 17 |
* |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
function themify_get_google_fonts_file() { |
| 21 |
static $url=null; |
| 22 |
if($url===null){ |
| 23 |
$url = 'google-fonts'; |
| 24 |
if(!apply_filters( 'themify_google_fonts_full_list', ('full' === themify_get( 'setting-webfonts_list',false,true )) ) ){ |
| 25 |
$url.='-recommended'; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Filters the file loaded. |
| 30 |
* Useful for recovery in case user loaded Full List and their server can't manage it. |
| 31 |
* @param string $fonts |
| 32 |
*/ |
| 33 |
$url= apply_filters( 'themify_google_fonts_file',dirname( __FILE__ ).'/'. $url.'.php' ); |
| 34 |
} |
| 35 |
return $url; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Returns a list of Google Web Fonts |
| 40 |
* @return array |
| 41 |
* @since 1.5.6 |
| 42 |
*/ |
| 43 |
function themify_get_google_web_fonts_list() { |
| 44 |
$google_fonts_list = array( |
| 45 |
array( 'value' => '', 'name' => '' ), |
| 46 |
array( |
| 47 |
'value' => '', |
| 48 |
'name' => '--- ' . __( 'Google Fonts', 'themify' ) . ' ---' |
| 49 |
) |
| 50 |
); |
| 51 |
$fonts = themify_get_google_font_lists(); |
| 52 |
foreach ( $fonts as $k=>$f ) { |
| 53 |
$google_fonts_list[] = array( |
| 54 |
'value' => $k, |
| 55 |
'name' => $k, |
| 56 |
'variant' => is_array( $f ) ? $f[1] : array() |
| 57 |
); |
| 58 |
} |
| 59 |
|
| 60 |
return apply_filters( 'themify_get_google_web_fonts_list', $google_fonts_list ); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Returns a list of web safe fonts |
| 65 |
* @param bool $only_names Whether to return only the array keys or the values as well |
| 66 |
* @return mixed|void |
| 67 |
* @since 1.0.0 |
| 68 |
*/ |
| 69 |
function themify_get_web_safe_font_list( $only_names = false ) { |
| 70 |
$web_safe_font_names = array( |
| 71 |
"Arial, Helvetica, sans-serif", |
| 72 |
"Verdana, Geneva, sans-serif", |
| 73 |
"Georgia, 'Times New Roman', Times, serif", |
| 74 |
"'Times New Roman', Times, serif", |
| 75 |
"Tahoma, Geneva, sans-serif", |
| 76 |
"'Trebuchet MS', Arial, Helvetica, sans-serif", |
| 77 |
"Palatino, 'Palatino Linotype', 'Book Antiqua', serif", |
| 78 |
"'Lucida Sans Unicode', 'Lucida Grande', sans-serif" |
| 79 |
); |
| 80 |
|
| 81 |
if( ! $only_names ) { |
| 82 |
$web_safe_fonts = array( |
| 83 |
array( 'value' => 'default', 'name' => '', 'selected' => true ), |
| 84 |
array( 'value' => '', 'name' => '--- '.__( 'Web Safe Fonts', 'themify' ) . ' ---' ) |
| 85 |
); |
| 86 |
|
| 87 |
foreach( $web_safe_font_names as $font ) { |
| 88 |
$web_safe_fonts[] = array( |
| 89 |
'value' => $font, |
| 90 |
'name' => $font |
| 91 |
); |
| 92 |
} |
| 93 |
} else { |
| 94 |
$web_safe_fonts = $web_safe_font_names; |
| 95 |
} |
| 96 |
|
| 97 |
return apply_filters( 'themify_get_web_safe_font_list', $web_safe_fonts ); |
| 98 |
} |
| 99 |
|
| 100 |
endif; |