Я успешно получил значение для семейства шрифтов Google. Но я все еще не понимаю, как получить вариант шрифта Google, когда выбрано семейство шрифтов Google (настройщик wordpress)?
Поскольку я хочу ввести значение, которое я уже получил для варианта шрифта, в массив $ examples_choices = array ();
Это мой код:
$url = get_template_directory_uri() . '/assets/fonts/webfonts.json';
$response = wp_remote_get( get_template_directory_uri() . '/assets/fonts/webfonts.json', array( 'sslverify' => true ) );
$response = wp_remote_retrieve_body( wp_remote_get($url, array('sslverify' => false )));
if( is_wp_error( $response ) ) {
echo 'Something went wrong!';
} else {
$json_a = json_decode($response, true);
$font_items = $json_a['items'];
$family_choices = array();
$variants_choices = array();
foreach ($font_items as $font_value => $font_item) {
$family_choices[$font_item['family']] = $font_item['family'];
}
$family_args = array(
'label' => 'Font Family',
'section' => 'typography_section',
'settings' => 'font_family_setting',
'panel' => 'display_option',
'type' => 'select',
'choices' => $family_choices
);
$variant_args = array(
'label' => 'Font Variant',
'section' => 'typography_section',
'settings' => 'font_variant_setting',
'panel' => 'display_option',
'type' => 'select',
'choices' => $variants_choices
);
}
и это маленькие веб-шрифты json file
{
"kind": "webfonts#webfontList",
"items": [
{
"kind": "webfonts#webfont",
"family": "ABeeZee",
"category": "sans-serif",
"variants": [
"regular",
"italic"
],
"subsets": [
"latin"
],
"version": "v12",
"lastModified": "2019-01-15",
"files": {
"regular": "http://fonts.gstatic.com/s/abeezee/v12/esDR31xSG-6AGleN6tKukbcHCpE.ttf",
"italic": "http://fonts.gstatic.com/s/abeezee/v12/esDT31xSG-6AGleN2tCklZUCGpG-GQ.ttf"
}
}
}