'; echo '' . esc_html( $this->label ) . ''; if ( !empty( $this->description ) ) { echo '' . $this->description . ''; } echo '
'; echo ''; } } } /*====== Toggle ======*/ if ( class_exists( 'WP_Customize_Control' ) ) { class Bianco_Customizer_Toggle_Control extends WP_Customize_Control { public $type = 'toggle'; public function render_content() { echo ''; } } } /*====== Radio Image ======*/ if ( class_exists( 'WP_Customize_Control' ) ) { class Bianco_Customize_Control_Radio_Image extends WP_Customize_Control { public $type = 'radio-image'; public function enqueue() { wp_enqueue_script( 'jquery-ui-button' ); } public function to_json() { parent::to_json(); foreach ( $this->choices as $value => $args ) { $this->choices[ $value ]['url'] = esc_url( sprintf( $args['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ) ); $this->json['choices'] = $this->choices; $this->json['link'] = $this->get_link(); $this->json['value'] = $this->value(); $this->json['id'] = $this->id; } } public function content_template() { ?> <# if ( ! data.choices ) { return; } #> <# if ( data.label ) { #> {{ data.label }} <# } #> <# if ( data.description ) { #> {{{ data.description }}} <# } #> fonts ) { if ( is_array( $this->fonts ) ) { $fonts = $this->fonts; } else { return; } } else { $fonts = $this->bianco_get_fonts(); if ( ! $fonts ) { return; } } if ( ! empty( $this->label ) ) { echo '' . esc_html( $this->label ) . ''; } if ( ! empty( $this->description ) ) { echo '' . esc_html( $this->description ) . ''; } echo ''; } private function bianco_get_fonts() { $api_key = $this->api_key; $cache_time = DAY_IN_SECONDS * $this->cache_time; if ( ! $api_key ) { return null; } if ( ! get_transient( 'bianco_google_fonts' ) ) { $cloud_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $api_key; $local_url = get_template_directory_uri() . '/assets/fonts/google-fonts/google-fonts.json?ver=' . BIANCO_THEME_VERSION; $cloud_data = wp_remote_get( $cloud_url, array( 'sslverify' => false ) ); $local_data = wp_remote_get( $local_url, array( 'sslverify' => false ) ); if ( ! is_wp_error( $cloud_data ) ) { $content = json_decode( $cloud_data['body'] ); if ( isset( $content->error ) ) { if ( ! is_wp_error( $local_data ) ) { $content = json_decode( $local_data['body'] ); } else { return null; } } } else { if ( ! is_wp_error( $local_data ) ) { $content = json_decode( $local_data['body'] ); } else { return null; } } set_transient( 'bianco_google_fonts', $content, $cache_time ); } if ( ! get_transient( 'bianco_popular_google_fonts' ) ) { $cloud_url = 'https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key=' . $api_key; $local_url = get_template_directory_uri() . '/assets/fonts/google-fonts/google-fonts-popular.json?ver=' . BIANCO_THEME_VERSION; $cloud_data = wp_remote_get( $cloud_url, array( 'sslverify' => false ) ); $local_data = wp_remote_get( $local_url, array( 'sslverify' => false ) ); if ( ! is_wp_error( $cloud_data ) ) { $content = json_decode( $cloud_data['body'] ); if ( isset( $content->error ) ) { if ( ! is_wp_error( $local_data ) ) { $content = json_decode( $local_data['body'] ); } else { return null; } } } else { if ( ! is_wp_error( $local_data ) ) { $content = json_decode( $local_data['body'] ); } else { return null; } } set_transient( 'bianco_popular_google_fonts', $content, $cache_time ); } if ( 'all' == $this->amount ) { $content = get_transient( 'bianco_google_fonts' ); return $content->items; } else { $content = get_transient( 'bianco_popular_google_fonts' ); return array_slice( $content->items, 0, $this->amount ); } } } } add_action( 'customize_register', 'bianco_register_customizer_control_google_fonts', 0 ); } /*====== Sidebar Dropdown ======*/ if ( class_exists( 'WP_Customize_Control' ) ) { class Bianco_Sidebar_Dropdown_Custom_Control extends WP_Customize_Control { public $type = 'sidebar_dropdown'; public function render_content() { echo '