display = [ 'font-family' => [], 'font-subsets' => [], 'font-weight' => [], 'font-style' => [], 'text-transform' => [], 'letter-spacing' => [], 'text-decoration' => [], 'font-size' => [], 'color' => '', 'line-height' => [], ]; parent::__construct( $manager, $id, $args ); } /** * Enqueue control related scripts/styles. * * @access public */ public function enqueue() { parent::enqueue(); wp_localize_script( $this->type . '-js', 'blogsy_typography_vars', [ 'fonts' => \Blogsy\Helper::fonts()->get_fonts(), 'default' => \Blogsy\Helper::fonts()->get_default_system_font(), ] ); // Script debug. $blogsy_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; /** * Enqueue select2 stylesheet. */ wp_enqueue_style( 'blogsy-select2-style', BLOGSY_THEME_URI . '/admin/dashboard/assets/css/select2' . $blogsy_suffix . '.css', false, BLOGSY_THEME_VERSION, 'all' ); /** * Enqueue select2 script. */ wp_enqueue_script( 'blogsy-select2-js', BLOGSY_THEME_URI . '/admin/dashboard/assets/js/libs/select2' . $blogsy_suffix . '.js', [ 'jquery' ], BLOGSY_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'] = [ 'advanced' => esc_html__( 'Advanced', 'blogsy' ), 'font-family' => esc_html__( 'Font Family', 'blogsy' ), 'font-subsets' => esc_html__( 'Languages', 'blogsy' ), 'font-weight' => esc_html__( 'Weight', 'blogsy' ), 'font-size' => esc_html__( 'Size', 'blogsy' ), 'font-style' => esc_html__( 'Style', 'blogsy' ), 'text-transform' => esc_html__( 'Transform', 'blogsy' ), 'text-decoration' => esc_html__( 'Decoration', 'blogsy' ), 'line-height' => esc_html__( 'Line Height', 'blogsy' ), 'letter-spacing' => esc_html__( 'Letter Spacing', 'blogsy' ), 'inherit' => esc_html__( 'Inherit', 'blogsy' ), 'default' => esc_html__( 'Default System Font', 'blogsy' ), 'color' => esc_html__( 'Color', 'blogsy' ), 'weights' => [ 'inherit' => esc_html__( 'Inherit', 'blogsy' ), '100' => esc_html__( 'Thin 100', 'blogsy' ), '100italic' => esc_html__( 'Thin 100 Italic', 'blogsy' ), '200' => esc_html__( 'Extra-Thin 200', 'blogsy' ), '200italic' => esc_html__( 'Extra-Thin 200 Italic', 'blogsy' ), '300' => esc_html__( 'Light 300', 'blogsy' ), '300italic' => esc_html__( 'Light 300 Italic', 'blogsy' ), '400' => esc_html__( 'Normal 400', 'blogsy' ), '400italic' => esc_html__( 'Normal 400 Italic', 'blogsy' ), '500' => esc_html__( 'Medium 500', 'blogsy' ), '500italic' => esc_html__( 'Medium 500 Italic', 'blogsy' ), '600' => esc_html__( 'Semi-Bold 600', 'blogsy' ), '600italic' => esc_html__( 'Semi-Bold 600 Italic', 'blogsy' ), '700' => esc_html__( 'Bold 700', 'blogsy' ), '700italic' => esc_html__( 'Bold 700 Italic', 'blogsy' ), '800' => esc_html__( 'Extra-Bold 800', 'blogsy' ), '800italic' => esc_html__( 'Extra-Bold 800 Italic', 'blogsy' ), '900' => esc_html__( 'Black 900', 'blogsy' ), '900italic' => esc_html__( 'Black 900 Italic', 'blogsy' ), ], 'subsets' => \Blogsy\Helper::fonts()->get_google_font_subsets(), 'transforms' => [ 'inherit' => esc_html__( 'Inherit', 'blogsy' ), 'uppercase' => esc_html__( 'Uppercase', 'blogsy' ), 'lowercase' => esc_html__( 'Lowercase', 'blogsy' ), 'capitalize' => esc_html__( 'Capitalize', 'blogsy' ), 'none' => esc_html__( 'None', 'blogsy' ), ], 'decorations' => [ 'inherit' => esc_html__( 'Inherit', 'blogsy' ), 'underline' => esc_html__( 'Underline', 'blogsy' ), 'overline' => esc_html__( 'Overline', 'blogsy' ), 'line-through' => esc_html__( 'Line Through', 'blogsy' ), 'none' => esc_html__( 'None', 'blogsy' ), ], 'styles' => [ 'inherit' => esc_html__( 'Inherit', 'blogsy' ), 'normal' => esc_html__( 'Normal', 'blogsy' ), 'italic' => esc_html__( 'Italic', 'blogsy' ), 'oblique' => esc_html__( 'Oblique', 'blogsy' ), ], ]; $default_units = [ 'font-size' => [ [ 'id' => 'px', 'name' => 'px', 'min' => 8, 'max' => 85, 'step' => 1, ], [ 'id' => 'em', 'name' => 'em', 'min' => 0.5, 'max' => 6.5, 'step' => 0.01, ], [ 'id' => 'rem', 'name' => 'rem', 'min' => 0.5, 'max' => 6.5, 'step' => 0.01, ], ], 'letter-spacing' => [ [ 'id' => 'px', 'name' => 'px', 'min' => -10, 'max' => 10, 'step' => 1, ], [ 'id' => 'em', 'name' => 'em', 'min' => -0.5, 'max' => 1, 'step' => 0.01, ], ], 'line-height' => [ [ 'id' => '', 'name' => '', 'min' => 1, 'max' => 10, 'step' => 0.1, ], ], ]; $this->json['units'] = []; foreach ( [ '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'] = [ 'desktop' => [ 'title' => esc_html__( 'Desktop', 'blogsy' ), 'icon' => 'dashicons dashicons-desktop', ], 'tablet' => [ 'title' => esc_html__( 'Tablet', 'blogsy' ), 'icon' => 'dashicons dashicons-tablet', ], 'mobile' => [ 'title' => esc_html__( 'Mobile', 'blogsy' ), '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() { ?>