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() . '/assets/vendor/select2/select2.full.min.js', array( 'jquery' ), '4.0.13', true ); wp_enqueue_style( 'botiga-select2', get_template_directory_uri() . '/assets/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) && $this->fontList !== 'error' ) { ?> label ) ) { ?> label ); ?> description ) ) { ?> description ); ?>
link( 'family' ); ?> />
input_attrs['disableRegular'] == false ) : ?>
fontList == 'error' ) { $error_message = sprintf( /* translators: 1: How to use adobe fonts docs link */ __( '

Something went wrong and the Google Fonts couldn\'t be loaded. Please contact our support here to get help.', 'botiga' ), 'https://athemes.com/support/' ); if( defined( 'BOTIGA_AWL_ACTIVE' ) ) { $error_message = __( '

Something went wrong and the Google Fonts couldn\'t be loaded.', 'botiga' ); } echo wp_kses_post( $error_message ); } } /** * Find the index of the saved font in our multidimensional array of Google Fonts */ public function get_font_index( $haystack, $needle ) { if( 'error' === $haystack ) { return false; } foreach( $haystack as $key => $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 ) { require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound $fontFile = get_parent_theme_file_path( '/inc/customizer/controls/typography/google-fonts-alphabetical.json' ); $file_system = new WP_Filesystem_Direct( false ); $content = json_decode( $file_system->get_contents( $fontFile ) ); return $content->items; } }