display = array( 'font-family' => array(), 'font-subsets' => array(), 'font-weight' => array(), 'font-style' => array(), 'text-transform' => array(), 'letter-spacing' => array(), 'text-decoration' => array(), 'font-size' => array(), 'line-height' => array(), ); parent::__construct( $manager, $id, $args ); } /** * Enqueue control related scripts/styles. * * @access public */ public function enqueue() { parent::enqueue(); wp_localize_script( $this->type . '-js', 'bloghash_typography_vars', array( 'fonts' => bloghash()->fonts->get_fonts(), 'default' => bloghash()->fonts->get_default_system_font(), ) ); // Script debug. $bloghash_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; /** * Enqueue select2 stylesheet. */ wp_enqueue_style( 'bloghash-select2-style', BLOGHASH_THEME_URI . '/inc/admin/assets/css/select2' . $bloghash_suffix . '.css', false, BLOGHASH_THEME_VERSION, 'all' ); /** * Enqueue select2 script. */ wp_enqueue_script( 'bloghash-select2-js', BLOGHASH_THEME_URI . '/inc/admin/assets/js/libs/select2' . $bloghash_suffix . '.js', array( 'jquery' ), BLOGHASH_THEME_VERSION, true ); } /** * Refresh the parameters passed to the JavaScript via JSON. * * @see WP_Customize_Control::to_json() */ public function to_json() { parent::to_json(); $this->json['display'] = $this->display; $this->json['l10n'] = array( 'advanced' => esc_html__( 'Advanced', 'bloghash' ), 'font-family' => esc_html__( 'Font Family', 'bloghash' ), 'font-subsets' => esc_html__( 'Languages', 'bloghash' ), 'font-weight' => esc_html__( 'Weight', 'bloghash' ), 'font-size' => esc_html__( 'Size', 'bloghash' ), 'font-style' => esc_html__( 'Style', 'bloghash' ), 'text-transform' => esc_html__( 'Transform', 'bloghash' ), 'text-decoration' => esc_html__( 'Decoration', 'bloghash' ), 'line-height' => esc_html__( 'Line Height', 'bloghash' ), 'letter-spacing' => esc_html__( 'Letter Spacing', 'bloghash' ), 'inherit' => esc_html__( 'Inherit', 'bloghash' ), 'default' => esc_html__( 'Default System Font', 'bloghash' ), 'weights' => array( 'inherit' => esc_html__( 'Inherit', 'bloghash' ), '100' => esc_html__( 'Thin 100', 'bloghash' ), '100italic' => esc_html__( 'Thin 100 Italic', 'bloghash' ), '200' => esc_html__( 'Extra-Thin 200', 'bloghash' ), '200italic' => esc_html__( 'Extra-Thin 200 Italic', 'bloghash' ), '300' => esc_html__( 'Light 300', 'bloghash' ), '300italic' => esc_html__( 'Light 300 Italic', 'bloghash' ), '400' => esc_html__( 'Normal 400', 'bloghash' ), '400italic' => esc_html__( 'Normal 400 Italic', 'bloghash' ), '500' => esc_html__( 'Medium 500', 'bloghash' ), '500italic' => esc_html__( 'Medium 500 Italic', 'bloghash' ), '600' => esc_html__( 'Semi-Bold 600', 'bloghash' ), '600italic' => esc_html__( 'Semi-Bold 600 Italic', 'bloghash' ), '700' => esc_html__( 'Bold 700', 'bloghash' ), '700italic' => esc_html__( 'Bold 700 Italic', 'bloghash' ), '800' => esc_html__( 'Extra-Bold 800', 'bloghash' ), '800italic' => esc_html__( 'Extra-Bold 800 Italic', 'bloghash' ), '900' => esc_html__( 'Black 900', 'bloghash' ), '900italic' => esc_html__( 'Black 900 Italic', 'bloghash' ), ), 'subsets' => bloghash()->fonts->get_google_font_subsets(), 'transforms' => array( 'inherit' => esc_html__( 'Inherit', 'bloghash' ), 'uppercase' => esc_html__( 'Uppercase', 'bloghash' ), 'lowercase' => esc_html__( 'Lowercase', 'bloghash' ), 'capitalize' => esc_html__( 'Capitalize', 'bloghash' ), 'none' => esc_html__( 'None', 'bloghash' ), ), 'decorations' => array( 'inherit' => esc_html__( 'Inherit', 'bloghash' ), 'underline' => esc_html__( 'Underline', 'bloghash' ), 'overline' => esc_html__( 'Overline', 'bloghash' ), 'line-through' => esc_html__( 'Line Through', 'bloghash' ), 'none' => esc_html__( 'None', 'bloghash' ), ), 'styles' => array( 'inherit' => esc_html__( 'Inherit', 'bloghash' ), 'normal' => esc_html__( 'Normal', 'bloghash' ), 'italic' => esc_html__( 'Italic', 'bloghash' ), 'oblique' => esc_html__( 'Oblique', 'bloghash' ), ), ); $default_units = array( 'font-size' => array( array( 'id' => 'px', 'name' => 'px', 'min' => 8, 'max' => 65, 'step' => 1, ), array( 'id' => 'em', 'name' => 'em', 'min' => 0.5, 'max' => 6.5, 'step' => 0.01, ), array( 'id' => 'rem', 'name' => 'rem', 'min' => 0.5, 'max' => 6.5, 'step' => 0.01, ), ), 'letter-spacing' => array( array( 'id' => 'px', 'name' => 'px', 'min' => -10, 'max' => 10, 'step' => 1, ), ), 'line-height' => array( array( 'id' => '', 'name' => '', 'min' => 1, 'max' => 10, 'step' => 0.1, ), ), ); $this->json['units'] = array(); foreach ( array( 'font-size', 'letter-spacing', 'line-height' ) as $key ) { if ( isset( $this->display[ $key ] ) && isset( $this->display[ $key ]['unit'] ) ) { $this->json['units'][ $key ] = $this->display[ $key ]['unit']; } } $this->json['units'] = wp_parse_args( $this->json['units'], $default_units ); $this->json['responsive'] = array( 'desktop' => array( 'title' => esc_html__( 'Desktop', 'bloghash' ), 'icon' => 'dashicons dashicons-desktop', ), 'tablet' => array( 'title' => esc_html__( 'Tablet', 'bloghash' ), 'icon' => 'dashicons dashicons-tablet', ), 'mobile' => array( 'title' => esc_html__( 'Mobile', 'bloghash' ), 'icon' => 'dashicons dashicons-smartphone', ), ); } /** * An Underscore (JS) template for this control's content (but not its container). * * Class variables for this control class are available in the `data` JS object; * export custom variables by overriding {@see WP_Customize_Control::to_json()}. * * @see WP_Customize_Control::print_template() */ protected function content_template() { ?>