/** * Define the sections and settings for the General panel * * @since 1.3.0. * * @param array $sections The master array of Customizer sections * @return array The augmented master array */ function ttfmake_customizer_define_typography_sections($sections) { $panel = 'ttfmake_typography'; $typography_sections = array(); /** * Typekit */ if (!ttfmake_is_plus()) { $typography_sections['font-typekit'] = array('panel' => $panel, 'title' => __('Typekit', 'make'), 'description' => __('Looking to add premium fonts from Typekit to your website?', 'make'), 'options' => array('font-typekit-update-text' => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'type' => 'text', 'description' => sprintf('<a href="%1$s" target="_blank">%2$s</a>', esc_url(ttfmake_get_plus_link('typekit')), sprintf(__('Upgrade to %1$s', 'make'), 'Make Plus')))))); } /** * Google Web Fonts */ $typography_sections['font-google'] = array('panel' => $panel, 'title' => __('Google Web Fonts', 'make'), 'options' => array('font-subset' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_subset'), 'control' => array('label' => __('Character Subset', 'make'), 'type' => 'select', 'choices' => ttfmake_get_google_font_subsets())), 'font-subset-text' => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'type' => 'text', 'description' => __('Not all fonts provide each of these subsets.', 'make'))))); /** * Site Title & Tagline */ $typography_sections['font-site-title-tagline'] = array('panel' => $panel, 'title' => __('Site Title & Tagline', 'make'), 'options' => array('font-family-site-title' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Site Title Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-site-title' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Site Title Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-site-tagline' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Site Tagline Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-site-tagline' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Site Tagline Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')))); /** * Main Navigation */ $typography_sections['font-main-menu'] = array('panel' => $panel, 'title' => __('Main Menu', 'make'), 'options' => array('font-family-nav' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Menu Item Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-nav' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Menu Item Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-subnav' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Sub-Menu Item Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-subnav' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Sub-Menu Item Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-subnav-option-heading' => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'type' => 'heading', 'label' => __('Sub-Menu Item Options', 'make'))), 'font-subnav-mobile' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Use Menu Item styles in mobile view', 'make'), 'type' => 'checkbox')))); /** * Widgets */ $typography_sections['font-widget'] = array('panel' => $panel, 'title' => __('Widgets', 'make'), 'options' => array('font-family-widget' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Widget Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-widget' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Widget Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')))); /** * Headers & Body */ $typography_sections['font'] = array('panel' => $panel, 'title' => __('Headers & Body', 'make'), 'options' => array('font-family-h1' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('H1 Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-h1' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('H1 Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-h2' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('H2 Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-h2' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('H2 Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-h3' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('H3 Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-h3' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('H3 Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-h4' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('H4 Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-h4' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('H4 Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-h5' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('H5 Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-h5' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('H5 Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-h6' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('H6 Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-h6' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('H6 Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')), 'font-family-body' => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Body Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-size-body' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Body Font Size (in px)', 'make'), 'type' => ttfmake_customizer_supports_panels() ? 'number' : 'text')))); // Filter the definitions $typography_sections = apply_filters('make_customizer_typography_sections', $typography_sections); // Merge with master array return array_merge($sections, $typography_sections); }
/** * Generate an array of Customizer option definitions for a particular HTML element. * * @since 1.5.0. * * @param string $element * @param string $label * @param string $description * @return array */ function ttfmake_customizer_typography_group_definitions($element, $label, $description = '') { $definitions = array('typography-group-' . $element => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'label' => $label, 'description' => $description, 'type' => 'group-title')), 'font-family-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_font_choice'), 'control' => array('label' => __('Font Family', 'make'), 'type' => 'select', 'choices' => ttfmake_font_choices_placeholder())), 'font-style-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_choice'), 'control' => array('control_type' => 'TTFMAKE_Customize_Radio_Control', 'label' => __('Font Style', 'make'), 'type' => 'radio', 'mode' => 'buttonset', 'choices' => ttfmake_get_choices('font-style-' . $element))), 'font-weight-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_choice'), 'control' => array('control_type' => 'TTFMAKE_Customize_Radio_Control', 'label' => __('Font Weight', 'make'), 'type' => 'radio', 'mode' => 'buttonset', 'choices' => ttfmake_get_choices('font-weight-' . $element))), 'font-size-' . $element => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('control_type' => 'TTFMAKE_Customize_Range_Control', 'label' => __('Font Size (px)', 'make'), 'type' => 'range', 'input_attrs' => array('min' => 6, 'max' => 100, 'step' => 1))), 'text-transform-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_choice'), 'control' => array('control_type' => 'TTFMAKE_Customize_Radio_Control', 'label' => __('Text Transform', 'make'), 'type' => 'radio', 'mode' => 'buttonset', 'choices' => ttfmake_get_choices('text-transform-' . $element))), 'line-height-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_float'), 'control' => array('control_type' => 'TTFMAKE_Customize_Range_Control', 'label' => __('Line Height (em)', 'make'), 'type' => 'range', 'input_attrs' => array('min' => 0, 'max' => 5, 'step' => 0.1))), 'letter-spacing-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_float'), 'control' => array('control_type' => 'TTFMAKE_Customize_Range_Control', 'label' => __('Letter Spacing (px)', 'make'), 'type' => 'range', 'input_attrs' => array('min' => 0, 'max' => 10, 'step' => 0.5))), 'word-spacing-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_float'), 'control' => array('control_type' => 'TTFMAKE_Customize_Range_Control', 'label' => __('Word Spacing (px)', 'make'), 'type' => 'range', 'input_attrs' => array('min' => 0, 'max' => 20, 'step' => 1))), 'link-underline-' . $element => array('setting' => array('sanitize_callback' => 'ttfmake_sanitize_choice'), 'control' => array('control_type' => 'TTFMAKE_Customize_Radio_Control', 'label' => __('Link Underline', 'make'), 'type' => 'radio', 'mode' => 'buttonset', 'choices' => ttfmake_get_choices('link-underline-' . $element)))); /** * Filter the Customizer's font control definitions. * * @since 1.5.0. * * @param array $definitions Array of Customizer options and their setting and control definitions. * @param string $element The HTML element that the font properties will apply to. */ return apply_filters('make_customizer_typography_group_definitions', $definitions, $element); }