input_attrs['orderby'] ) && strtolower( $this->input_attrs['orderby'] ) === 'popular' ) {
$this->fontOrderBy = 'popular';
}
// Get the list of Google fonts
if ( isset( $this->input_attrs['font_count'] ) ) {
if ( 'all' != strtolower( $this->input_attrs['font_count'] ) ) {
$this->fontCount = ( abs( (int) $this->input_attrs['font_count'] ) > 0 ? abs( (int) $this->input_attrs['font_count'] ) : 'all' );
}
}
$this->fontList = $this->get_google_fonts( 'all' );
// Decode the default json font value
$this->fontValues = json_decode( $this->value( 'family' ) );
// Find the index of our default font within our list of Google fonts
$this->fontListIndex = $this->get_font_index( $this->fontList, $this->fontValues->font );
}
/**
* Enqueue our scripts and styles
*/
public function enqueue() {
wp_enqueue_script( 'botiga-select2', get_template_directory_uri() . '/vendor/select2/select2.full.min.js', array( 'jquery' ), '4.0.13', true );
wp_enqueue_style( 'botiga-select2', get_template_directory_uri() . '/vendor/select2/select2.min.css', array(), '4.0.13', 'all' );
}
/**
* Export our List of Google Fonts to JavaScript
*/
public function to_json() {
parent::to_json();
$this->json['botigafontslist'] = $this->fontList;
}
/**
* Render the control in the customizer
*/
public function render_content() {
$fontCounter = 0;
$isFontInList = false;
$fontListStr = '';
if( !empty($this->fontList) ) {
?>
label ) ) { ?>
label ); ?>
description ) ) { ?>
description ); ?>
link( 'family' ); ?> />
input_attrs['disableRegular'] == false ) : ?>
$value ) {
if( $value->family == $needle ) {
return $key;
}
}
return false;
}
/**
* Return the list of Google Fonts from our json file. Unless otherwise specfied, list will be limited to 30 fonts.
*/
public function get_google_fonts( $count = 30 ) {
$fontFile = get_template_directory_uri() . '/inc/customizer/controls/typography/google-fonts-alphabetical.json';
$request = wp_remote_get( $fontFile );
if( is_wp_error( $request ) ) {
return "";
}
$body = wp_remote_retrieve_body( $request );
$content = json_decode( $body );
return $content->items;
}
}