/** * Register the marketpress specific customizer options. In our * case it is a simple color picker to set a specific * key color. * * @param object $wp_customize * @return void */ function helsinki_register_customizer_sections($wp_customize) { // add section for the color switch to set the key colors $enabled_key_color = apply_filters('helsinki_register_customizer_sections_key_color', TRUE); if ($enabled_key_color) { $wp_customize->add_section('colors', array('title' => __('Colors', 'helsinki'), 'priority' => 5)); $wp_customize->add_setting('key_color', array('default' => apply_filters('helsinki_customizer_default_key_color', '#0084cc'), 'transport' => 'refresh', 'sanitize_callback' => 'helsinki_sanitize_color')); $wp_customize->add_setting('footer_link_color', array('default' => apply_filters('helsinki_customizer_default_footer_link_color', '#d36037'), 'transport' => 'refresh', 'sanitize_callback' => 'helsinki_sanitize_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'key_color', array('label' => __('Key Color', 'helsinki'), 'description' => __('The key color is the main color of the website. Usually it is the color of the links, hovers and backgrounds.', 'helsinki'), 'section' => 'colors', 'settings' => 'key_color'))); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'footer_link_color', array('label' => __('Footer Link Color', 'helsinki'), 'description' => __('This color is for the links in the footer area of the website.', 'helsinki'), 'section' => 'colors', 'settings' => 'footer_link_color'))); } // add section for the custom logo $enabled_logo = apply_filters('helsinki_register_customizer_sections_logo', TRUE); if ($enabled_logo) { $wp_customize->add_section('helsinki_logo_section', array('title' => __('Logo', 'helsinki'), 'priority' => 6, 'description' => __('Upload a logo which usually replaces the default site name and description in the header', 'helsinki'))); $wp_customize->add_setting('helsinki_logo', array('default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'esc_url_raw')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'helsinki_logo', array('label' => __('Logo', 'helsinki'), 'section' => 'helsinki_logo_section', 'settings' => 'helsinki_logo'))); } // adding a new section to the customizer $enabled_social_icons = apply_filters('helsinki_register_customizer_sections_social_icons', TRUE); if ($enabled_social_icons) { $wp_customize->add_section('social_icons_section', array('title' => __('Social Media Icons', 'helsinki'), 'description' => __('In this Section you can enter your Social-Media-Channels to show them in your Theme. To do so, add the URL to your profiles in the inputs below.', 'helsinki'), 'priority' => 7)); $settings = helsinki_get_social_medias(); if (!is_array($settings) || count($settings) < 1) { return; } foreach ($settings as $id => $setting) { $option_key = 'social_icons_section' . '[' . $id . ']'; // adding a new setting to the database $wp_customize->add_setting($id, array('default' => '', 'sanitize_callback' => 'esc_url_raw')); $control_args = array('label' => $setting['label'], 'section' => 'social_icons_section', 'settings' => $id); $control = new WP_Customize_Control($wp_customize, $option_key, $control_args); $wp_customize->add_control($control); } } }
/** * Helper function to display the Social Icons from customizer * * @param array $args * @return string */ function helsinki_get_social_channel_icons(array $args = array()) { $default_args = array('before' => '<aside class="social-share" id="site-social-icons">', 'after' => '</aside>', 'link' => '<a href="%1$s" title="%2$s" class="social-share-link social-share-link-%3$s">%4$s</a>', 'link_before' => '', 'link_after' => ''); $rtn = apply_filters('pre_helsinki_customizer_get_social_channel_icons', FALSE, $args, $default_args); if ($rtn !== FALSE) { return $rtn; } $args = wp_parse_args($args, $default_args); $args = apply_filters('helsinki_customizer_get_social_channel_icons_args', $args); $markup = ''; $links = array(); $social_icons = helsinki_get_social_medias(); foreach ($social_icons as $theme_mod => $icon) { $link = get_theme_mod($theme_mod, ''); if ($link !== '') { $markup .= $args['link_before']; $markup .= sprintf($args['link'], esc_url($link), esc_attr($icon['label']), $theme_mod, $icon['icon']); $markup .= $args['link_after']; $links[$theme_mod] = $link; } } if ($markup !== '') { $markup = $args['before'] . $markup . $args['after']; } return apply_filters('helsinki_customizer_get_social_channel_icons', $markup, $social_icons, $links); }