set_font_defaults( $args, $id ); } /** * Sets the typography defaults */ public function set_font_defaults( $args, $id ) { $arr = array(); if ( ! empty( $args['font_defaults'] ) ) { $arr[ $id ] = $args['font_defaults']; } $this->font_defaults = $arr; } /** * Enqueues selectize js * * @since 1.0.0 * @access public * @return void */ public function enqueue() { wp_enqueue_script( 'jquery-ui' ); wp_enqueue_script( 'jquery-ui-slider' ); wp_enqueue_style( 'selectize', get_template_directory_uri() . '//include/library/epsilon-framework/assets/vendors/selectize/selectize.css' ); wp_enqueue_script( 'selectize', get_template_directory_uri() . '//include/library/epsilon-framework/assets/vendors/selectize/selectize.min.js', array( 'jquery' ), '1.0.0', true ); } /** * Grabs the value from the json and creates a k/v array * * @since 1.0.0 * * @param $values * * @return array */ public function get_values( $values ) { $defaults = array( 'font-family' => 'Select font', 'font-weight' => '', 'font-style' => '', 'letter-spacing' => '0', 'font-size' => '16', 'line-height' => '18', ); $arr = array(); foreach ( $this->choices as $choice ) { if ( array_key_exists( $choice, $defaults ) ) { $arr[ $choice ] = $defaults[ $choice ]; } } if ( empty( $values ) ) { return $arr; } $json = get_theme_mod( $values, '' ); if ( '' === $json ) { return $arr; } $json = str_replace( '"', '"', $json ); $json = (array) json_decode( $json ); $options = (array) $json['json']; /** * Changed these options (font-style and weight) in toggles */ if ( ! empty( $options['font-style'] ) ) { $options['font-style'] = 'on'; } if ( ! empty( $options['font-weight'] ) ) { $options['font-weight'] = 'on'; } $return = array_merge( $arr, $options ); foreach ( $return as $k => $v ) { $return[ $k ] = esc_attr( $v ); } return $return; } /** * Access the GFonts Json and parse its content. * * @since 1.0.0 * @access public * @return array|mixed|object */ public function google_fonts() { global $wp_filesystem; if ( empty( $wp_filesystem ) ) { require_once( ABSPATH . '/wp-admin/includes/file.php' ); WP_Filesystem(); } $path = dirname( dirname( __FILE__ ) ) . '/assets/data/gfonts.json'; $gfonts = $wp_filesystem->get_contents( $path ); return json_decode( $gfonts ); } /** * @return string */ public function set_selectors() { return implode( ',', $this->selectors ); } /** * Displays the control content. * * @since 1.0.0 * @access public * @return void */ public function render_content() { ?> get_values( $this->id ); $fonts = $this->google_fonts(); ?>
choices ) ) : ?>
>
>
choices ) || in_array( 'line-height', $this->choices ) || in_array( 'letter-spacing', $this->choices ) ) : ?>
choices ) ) : ?>
choices ) ) : ?>
choices ) ) : ?>