public function render_content() { $family_val = ''; $variant_val = ''; $subsets_val = array(); $variant_options = array(); $subsets_options = array(); $google_fonts = Youxi_Google_Font::fetch(); $value = Youxi_Google_Font::parse_str($this->value()); if (isset($value['family'])) { $family_val = $value['family']; $variant_options = Youxi_Google_Font::get_variants($family_val); $subsets_options = Youxi_Google_Font::get_subsets($family_val); if (isset($value['variant'])) { $variant_val = $value['variant']; } if (isset($value['subsets']) && is_array($value['subsets'])) { $subsets_val = $value['subsets']; } } ?> <label> <?php if (!empty($this->label)) { ?> <span class="customize-control-title"><?php echo esc_html($this->label); ?> </span> <?php } if (!empty($this->description)) { ?> <span class="description customize-control-description"><?php echo $this->description; ?> </span> <?php } ?> <input type="hidden" class="youxi-google-font-value" <?php $this->link(); ?> > <select class="youxi-google-font-control youxi-google-font-family" style="width: 100%"> <option value=""<?php selected('', $family_val); ?> ><?php esc_html_e('Inherit', 'youxi'); ?> </option> <?php foreach ($google_fonts as $font) { $font_family = preg_replace('/\\s+/', '+', $font['family']); ?> <option value="<?php echo esc_attr($font_family); ?> "<?php selected($font_family, $family_val); ?> ><?php echo esc_html($font['family']); ?> </option> <?php } ?> </select> <select class="youxi-google-font-control youxi-google-font-variant" style="width: 100%;<?php if (!$family_val) { echo ' display: none;'; } ?> "<?php disabled('', $family_val); ?> > <option value=""><?php esc_html_e('Select a Font Variant', 'youxi'); ?> </option> <?php foreach ($variant_options as $font_variant) { ?> <option value="<?php echo esc_attr($font_variant); ?> "<?php selected($variant_val, $font_variant); ?> ><?php echo esc_html($font_variant); ?> </option> <?php } ?> </select> <div class="youxi-google-font-control youxi-google-font-subsets"> <?php foreach ($subsets_options as $subset) { ?> <label> <input type="checkbox" value="<?php echo esc_attr($subset); ?> "<?php checked(true, in_array($subset, $subsets_val)); ?> > <?php echo esc_html($subset); ?> <br> </label> <?php } ?> </div> </label> <?php }
public function render_content($value) { $family_val = ''; $variant_val = 'regular'; $subsets_val = array(); $variant_options = array(); $subsets_options = array(); $google_fonts = Youxi_Google_Font::fetch(); $value = Youxi_Google_Font::parse_str($value); if (isset($value['family'])) { $family_val = $value['family']; $variant_options = Youxi_Google_Font::get_variants($family_val); $subsets_options = Youxi_Google_Font::get_subsets($family_val); if (isset($value['variant'])) { $variant_val = $value['variant']; } if (isset($value['subsets']) && is_array($value['subsets'])) { $subsets_val = $value['subsets']; } } ?> <div class="youxi-webfont-form-control youxi-webfont-provider-family"> <label class="customize-control-title"><?php esc_html_e('Family', 'youxi'); ?> </label> <select> <option class="placeholder" selected disabled value=""><?php esc_html_e('Select a Font Family', 'youxi'); ?> </option> <?php foreach ($google_fonts as $font) { $font_family = preg_replace('/\\s+/', '+', $font['family']); ?> <option value="<?php echo esc_attr($font_family); ?> "<?php selected($font_family, $family_val); ?> ><?php echo esc_html($font['family']); ?> </option> <?php } ?> </select> </div> <div class="youxi-webfont-form-control youxi-webfont-provider-variation"<?php if (!$family_val) { echo ' style="display: none;"'; } ?> > <label class="customize-control-title"><?php esc_html_e('Variant', 'youxi'); ?> </label> <select> <?php foreach ($variant_options as $font_variant) { ?> <option value="<?php echo esc_attr($font_variant); ?> "<?php selected($font_variant, $variant_val); ?> ><?php echo esc_html($font_variant); ?> </option> <?php } ?> </select> </div> <div class="youxi-webfont-form-control youxi-webfont-provider-subsets"<?php if (!$family_val) { echo ' style="display: none;"'; } ?> > <label class="customize-control-title"><?php esc_html_e('Subsets', 'youxi'); ?> </label> <div class="checkboxes"> <?php foreach ($subsets_options as $subset) { ?> <label> <input type="checkbox" value="<?php echo esc_attr($subset); ?> "<?php checked(true, in_array($subset, $subsets_val)); ?> > <?php echo esc_html($subset); ?> <br> </label> <?php } ?> </div> </div> <?php }