esc_html__( 'Inherit', 'alagu' ), '100' => esc_html__( 'Thin 100', 'alagu' ), '200' => esc_html__( 'Extra-Light 200', 'alagu' ), '300' => esc_html__( 'Light 300', 'alagu' ), '400' => esc_html__( 'Normal 400', 'alagu' ), '500' => esc_html__( 'Medium 500', 'alagu' ), '600' => esc_html__( 'Semi-Bold 600', 'alagu' ), '700' => esc_html__( 'Bold 700', 'alagu' ), '800' => esc_html__( 'Extra-Bold 800', 'alagu' ), '900' => esc_html__( 'Ultra-Bold 900', 'alagu' ), ); wp_localize_script( 'alagu-typography-control', 'dtTypoObject', $typo_localize ); } /** * Get a specific property of an array without needing to check if that property exists. * * Provide a default value if you want to return a specific value if the property is not set. * * @param array $array Array from which the property's value should be retrieved. * @param string $prop Name of the property to be retrieved. * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null. * * @return null|string|mixed The value */ public function fonts_util( $array, $prop, $default = null ) { if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) { return $default; } if ( isset( $array[ $prop ] ) ) { $value = $array[ $prop ]; } else { $value = ''; } return empty( $value ) && null !== $default ? $default : $value; } /** * Get the data to export to the client via JSON. * */ public function to_json() { parent::to_json(); $this->json['default'] = $this->setting->default; if ( isset( $this->default ) ) { $this->json['default'] = $this->default; } $val = maybe_unserialize( $this->value() ); if ( ! is_array( $val ) ) { $val = array(); } $choices = maybe_unserialize( $this->choices ); if ( ! is_array( $choices ) || empty( $choices ) ) { $this->choices = array( 'font_family' => esc_html__( 'Font Family', 'alagu'), 'font_weight' => esc_html__( 'Font Weight', 'alagu'), 'text_transform' => esc_html__( 'Text Transform', 'alagu'), 'text_align' => esc_html__( 'Text Align', 'alagu'), 'text_decoration' => esc_html__( 'Text Decoration', 'alagu'), 'font_style' => esc_html__( 'Font Style', 'alagu'), 'font_size' => esc_html__( 'Font Size', 'alagu'), 'line_height' => esc_html__( 'Line Height', 'alagu'), 'letter_spacing' => esc_html__( 'Letter Spacing', 'alagu'), ); } $this->json['value'] = $val; $this->json['id'] = $this->id; $this->json['label'] = esc_html( $this->label ); $this->json['choices'] = $this->choices; $this->json['link'] = $this->get_link(); $system_fonts = array(); foreach ( ALAGU_Font_Families::get_system_fonts() as $name => $value ) { $fallback = $value['fallback']; $weights = implode(",", $value['weights'] ); $system_fonts[ $name ] = array( 'fallback' => $name .', '. $fallback, 'weights' => $weights, ); } $this->json['system_fonts'] = $system_fonts; $custom_fonts = array(); if( is_array(ALAGU_Font_Families::get_custom_fonts()) && !empty(ALAGU_Font_Families::get_custom_fonts()) ) { foreach ( ALAGU_Font_Families::get_custom_fonts() as $name => $value ) { $fallback = $value['fallback']; $custom_fonts[ $name ] = array( 'fallback' => $name .', '. $fallback ); } $this->json['custom_fonts'] = $custom_fonts; } $google_fonts = array(); if( is_array(ALAGU_Font_Families::get_google_fonts()) && !empty(ALAGU_Font_Families::get_google_fonts()) ) { foreach ( ALAGU_Font_Families::get_google_fonts() as $name => $single_font ) { # google-fonts-1.json $category = $this->fonts_util( $single_font, '0' ); $variants = $this->fonts_util( $single_font, '1' ); $weights = implode(",", $variants ); $google_fonts[ $name ] = array( 'fallback' => "'".$name ."', ". $category, 'weights' => $weights, ); } $this->json['google_fonts'] = $google_fonts; } } /** * Renders the control wrapper and calls $this->render_content() for the internals. */ protected function render() { $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id ); $class = 'customize-control has-responsive-switchers customize-control-' . $this->type; $d_controller = $d_condition = $d_value = ''; $dependency = $this->dependency; if( !empty( $dependency ) ) { $d_controller = "data-controller='" . esc_attr( $dependency[0] )."'"; $d_condition = "data-condition='" . esc_attr( $dependency[1] )."'"; $d_value = "data-value='". esc_attr( $dependency[2] )."'"; } printf( '