Exemplo n.º 1
0
 /**
  * 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 &amp; 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 &amp; 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);
 }
Exemplo n.º 2
0
 /**
  * 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();
     /**
      * Global
      */
     $typography_sections['font'] = array('panel' => $panel, 'title' => __('Global', 'make'), 'options' => array_merge(ttfmake_customizer_typography_group_definitions('body', __('Default', 'make')), array('body-link-group' => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'label' => __('Links', 'make'), 'type' => 'group-title')), 'font-weight-body-link' => 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-body-link'))))));
     /**
      * Text Headers
      */
     $typography_sections['font-headers'] = array('panel' => $panel, 'title' => __('Text Headers', 'make'), 'options' => array_merge(ttfmake_customizer_typography_group_definitions('h1', __('H1', 'make')), ttfmake_customizer_typography_group_definitions('h2', __('H2', 'make')), ttfmake_customizer_typography_group_definitions('h3', __('H3', 'make')), ttfmake_customizer_typography_group_definitions('h4', __('H4', 'make')), ttfmake_customizer_typography_group_definitions('h5', __('H5', 'make')), ttfmake_customizer_typography_group_definitions('h6', __('H6', 'make'))));
     /**
      * Site Title & Tagline
      */
     $typography_sections['font-site-title-tagline'] = array('panel' => $panel, 'title' => __('Site Title &amp; Tagline', 'make'), 'options' => array_merge(ttfmake_customizer_typography_group_definitions('site-title', __('Site Title', 'make')), ttfmake_customizer_typography_group_definitions('site-tagline', __('Tagline', 'make'))));
     /**
      * Main Navigation
      */
     $typography_sections['font-main-menu'] = array('panel' => $panel, 'title' => __('Main Menu', 'make'), 'options' => array_merge(ttfmake_customizer_typography_group_definitions('nav', __('Menu Items', 'make')), ttfmake_customizer_typography_group_definitions('subnav', __('Sub-Menu Items', 'make')), array('font-nav-mobile-option-heading' => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'type' => 'heading', 'label' => __('Mobile', 'make'))), 'font-subnav-mobile' => array('setting' => array('sanitize_callback' => 'absint'), 'control' => array('label' => __('Use Menu Item styles in mobile view', 'make'), 'type' => 'checkbox')), 'font-nav-current-item-option-heading' => array('control' => array('control_type' => 'TTFMAKE_Customize_Misc_Control', 'type' => 'group-title', 'label' => __('Current Item', 'make'))), 'font-weight-nav-current-item' => 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-nav-current-item'))))));
     /**
      * Header Bar
      */
     $typography_sections['font-header-bar'] = array('panel' => $panel, 'title' => __('Header Bar', 'make'), 'options' => ttfmake_customizer_typography_group_definitions('header-bar-text', __('Header Bar Text', 'make'), __('Includes Header Text, Header Bar Menu items, and the search field.', 'make')));
     /**
      * Sidebars
      */
     $typography_sections['font-sidebar'] = array('panel' => $panel, 'title' => __('Sidebars', 'make'), 'options' => array_merge(ttfmake_customizer_typography_group_definitions('widget-title', __('Widget Title', 'make')), ttfmake_customizer_typography_group_definitions('widget', __('Widget Body', 'make'))));
     /**
      * Footer
      */
     $typography_sections['font-footer'] = array('panel' => $panel, 'title' => __('Footer', 'make'), 'options' => array_merge(ttfmake_customizer_typography_group_definitions('footer-widget-title', __('Widget Title', 'make')), ttfmake_customizer_typography_group_definitions('footer-widget', __('Widget Body', 'make')), ttfmake_customizer_typography_group_definitions('footer-text', __('Footer Text', 'make'))));
     /**
      * Google Font Subsets
      */
     $typography_sections['font-google'] = array('panel' => $panel, 'title' => __('Google Font Subsets', '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' => sprintf(__('Not all fonts provide each of these subsets. Please visit the %s to see which subsets are available for each font.', 'make'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', esc_url('https://www.google.com/fonts'), __('Google Fonts website', 'make')))))));
     /**
      * 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'))))));
     }
     /**
      * Filter the definitions for the controls in the Typography panel of the Customizer.
      *
      * @since 1.3.0.
      *
      * @param array    $typography_sections    The array of definitions.
      */
     $typography_sections = apply_filters('make_customizer_typography_sections', $typography_sections);
     // Merge with master array
     return array_merge($sections, $typography_sections);
 }
Exemplo n.º 3
0
 /**
  * Sanitize the Character Subset choice.
  *
  * @since  1.0.0
  *
  * @param  string    $value    The value to sanitize.
  * @return array               The sanitized value.
  */
 function ttfmake_sanitize_font_subset($value)
 {
     if (!array_key_exists($value, ttfmake_get_google_font_subsets())) {
         $value = ttfmake_get_default('font-subset');
     }
     /**
      * Filter the sanitized subset choice.
      *
      * @since 1.2.3.
      *
      * @param string    $value    The chosen subset value.
      */
     return apply_filters('make_sanitize_font_subset', $value);
 }
Exemplo n.º 4
0
 /**
  * Configure settings and controls for the Fonts section.
  *
  * @since  1.0.0.
  *
  * @param  object    $wp_customize    The global customizer object.
  * @param  string    $section         The section name.
  * @return void
  */
 function ttfmake_customizer_font($wp_customize, $section)
 {
     $priority = new TTFMAKE_Prioritizer();
     $control_prefix = 'ttfmake_';
     $setting_prefix = str_replace($control_prefix, '', $section);
     // Google font info
     $setting_id = $setting_prefix . '-google-font-info';
     $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => sprintf(__('The list of Google fonts is long! You can %s before making your choices.', 'make'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', esc_url('http://www.google.com/fonts/'), __('preview', 'make'))), 'priority' => $priority->add())));
     // Site title font
     $setting_id = $setting_prefix . '-site-title';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_font_choice'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Site Title', 'make'), 'type' => 'select', 'choices' => ttfmake_all_font_choices(), 'priority' => $priority->add()));
     // Header font
     $setting_id = $setting_prefix . '-header';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_font_choice'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Headers', 'make'), 'type' => 'select', 'choices' => ttfmake_all_font_choices(), 'priority' => $priority->add()));
     // Body font
     $setting_id = $setting_prefix . '-body';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_font_choice'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Body', 'make'), 'type' => 'select', 'choices' => ttfmake_all_font_choices(), 'priority' => $priority->add()));
     if (false === ttfmake_is_plus()) {
         // Typekit information
         $setting_id = $setting_prefix . '-typekit-font-heading';
         $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'heading', 'label' => __('Typekit', 'make'), 'priority' => 450)));
         $setting_id = $setting_prefix . '-typekit-font-info';
         $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => sprintf(__('Looking to add premium fonts from Typekit to your website? %s.', 'make'), 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'))), 'priority' => 460)));
     }
     // Font family line
     $setting_id = $setting_prefix . '-family-line';
     $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'line', 'priority' => $priority->add())));
     // Site title font size
     $setting_id = $setting_prefix . '-site-title-size';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Site Title Font Size (in px)', 'make'), 'type' => 'text', 'priority' => $priority->add()));
     // Site title font size
     $setting_id = $setting_prefix . '-site-tagline-size';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Site Tagline Font Size (in px)', 'make'), 'type' => 'text', 'priority' => $priority->add()));
     // Navigation font size
     $setting_id = $setting_prefix . '-nav-size';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Navigation Font Size (in px)', 'make'), 'type' => 'text', 'priority' => $priority->add()));
     // Header font size
     $setting_id = $setting_prefix . '-header-size';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Header Font Size (in px)', 'make'), 'type' => 'text', 'priority' => $priority->add()));
     // Widget font size
     $setting_id = $setting_prefix . '-widget-size';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Widget Font Size (in px)', 'make'), 'type' => 'text', 'priority' => $priority->add()));
     // Body font size
     $setting_id = $setting_prefix . '-body-size';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Body Font Size (in px)', 'make'), 'type' => 'text', 'priority' => $priority->add()));
     // Font size line
     $setting_id = $setting_prefix . '-size-line';
     $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'line', 'priority' => $priority->add())));
     // Character Subset
     $setting_id = $setting_prefix . '-subset';
     $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_font_subset'));
     $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Character Subset', 'make'), 'type' => 'select', 'choices' => ttfmake_get_google_font_subsets(), 'priority' => $priority->add()));
     // Character subset info
     $setting_id = $setting_prefix . '-subset-info';
     $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => __('Not all fonts provide each of these subsets.', 'make'), 'priority' => $priority->add())));
 }