1

I am trying to add another section to the twenty seventeen customizer theme. I have a functions.php in a child theme of the Twenty Seventeen wordpress theme. However, it does not seem to add it. Am I missing something?

Code:

// Social media list
function twentyseventeen_child_social_array() {

    $social_sites = array(
        'twitter'       => 'twentyseventeen-child_twitter_profile',
        'facebook'      => 'twentyseventeen-child_facebook_profile',
        'google-plus'   => 'twentyseventeen-child_googleplus_profile',
        'pinterest'     => 'twentyseventeen-child_pinterest_profile',
        'linkedin'      => 'twentyseventeen-child_linkedin_profile',
        'youtube'       => 'twentyseventeen-child_youtube_profile',
        'vimeo'         => 'twentyseventeen-child_vimeo_profile',
        'tumblr'        => 'twentyseventeen-child_tumblr_profile',
        'instagram'     => 'twentyseventeen-child_instagram_profile',
        'flickr'        => 'twentyseventeen-child_flickr_profile',
        'dribbble'      => 'twentyseventeen-child_dribbble_profile',
        'rss'           => 'twentyseventeen-child_rss_profile',
        'reddit'        => 'twentyseventeen-child_reddit_profile',
        'soundcloud'    => 'twentyseventeen-child_soundcloud_profile',
        'spotify'       => 'twentyseventeen-child_spotify_profile',
        'vine'          => 'twentyseventeen-child_vine_profile',
        'yahoo'         => 'twentyseventeen-child_yahoo_profile',
        'behance'       => 'twentyseventeen-child_behance_profile',
        'codepen'       => 'twentyseventeen-child_codepen_profile',
        'delicious'     => 'twentyseventeen-child_delicious_profile',
        'stumbleupon'   => 'twentyseventeen-child_stumbleupon_profile',
        'deviantart'    => 'twentyseventeen-child_deviantart_profile',
        'digg'          => 'twentyseventeen-child_digg_profile',
        'github'        => 'twentyseventeen-child_github_profile',
        'hacker-news'   => 'twentyseventeen-child_hacker-news_profile',
        'steam'         => 'twentyseventeen-child_steam_profile',
        'vk'            => 'twentyseventeen-child_vk_profile',
        'weibo'         => 'twentyseventeen-child_weibo_profile',
        'tencent-weibo' => 'twentyseventeen-child_tencent_weibo_profile',
        '500px'         => 'twentyseventeen-child_500px_profile',
        'foursquare'    => 'twentyseventeen-child_foursquare_profile',
        'slack'         => 'twentyseventeen-child_slack_profile',
        'slideshare'    => 'twentyseventeen-child_slideshare_profile',
        'qq'            => 'twentyseventeen-child_qq_profile',
        'whatsapp'      => 'twentyseventeen-child_whatsapp_profile',
        'skype'         => 'twentyseventeen-child_skype_profile',
        'wechat'        => 'twentyseventeen-child_wechat_profile',
        'xing'          => 'twentyseventeen-child_xing_profile',
        'paypal'        => 'twentyseventeen-child_paypal_profile',
    );

    return apply_filters( 'twentyseventeen_child_social_array_filter', $social_sites );
}

function add_customizer_sections( $wp_customize ) {

    $social_sites = twentyseventeen_child_social_array();

    // set a priority used to order the social sites
    $priority = 5;

    // section
    $wp_customize->add_section( 'twentyseventeen_child_social_meida_icons', array(
        'title'       => __( 'Social Media Icons', 'twentyseventeen-child' ),
        'priority'    => 25,
        'description' => __( 'Add the URL for each of your social profiles.', 'twentyseventeen-child' )
    ) );

    // create a setting and control for each social site
    foreach ( $social_sites as $social_site => $value ) {

        $label = ucfirst( $social_site );

        if ( $social_site == 'google-plus' ) {
            $label = 'Google Plus';
        } elseif ( $social_site == 'rss' ) {
            $label = 'RSS';
        } elseif ( $social_site == 'soundcloud' ) {
            $label = 'SoundCloud';
        } elseif ( $social_site == 'slideshare' ) {
            $label = 'SlideShare';
        } elseif ( $social_site == 'codepen' ) {
            $label = 'CodePen';
        } elseif ( $social_site == 'stumbleupon' ) {
            $label = 'StumbleUpon';
        } elseif ( $social_site == 'deviantart' ) {
            $label = 'DeviantArt';
        } elseif ( $social_site == 'hacker-news' ) {
            $label = 'Hacker News';
        } elseif ( $social_site == 'whatsapp' ) {
            $label = 'WhatsApp';
        } elseif ( $social_site == 'qq' ) {
            $label = 'QQ';
        } elseif ( $social_site == 'vk' ) {
            $label = 'VK';
        } elseif ( $social_site == 'wechat' ) {
                $label = 'WeChat';
        } elseif ( $social_site == 'tencent-weibo' ) {
            $label = 'Tencent Weibo';
        } elseif ( $social_site == 'paypal' ) {
            $label = 'PayPal';
        }

        // setting
        $wp_customize->add_setting( $social_site, array(
            'sanitize_callback' => 'esc_url_raw'
        ) );
        // control
        $wp_customize->add_control( $social_site, array(
            'type'     => 'url',
            'label'    => $label,
            'section'  => 'twentyseventeen_child_social_media_icons',
            'priority' => $priority
        ) );
        // increment the priority for next site
        $priority = $priority + 5;
    }
}
add_action( 'customize_register', 'add_customizer_sections' );

// Function to be used to output social meida Icons
function social_icons_output() {

    $social_sites = twentyseventeen_child_social_array();

    foreach ( $social_sites as $social_site => $profile ) {

        if ( strlen( get_theme_mod( $social_site ) ) > 0 ) {
            $active_sites[ $social_site ] = $social_site;
        }
    }

    if ( ! empty( $active_sites ) ) {

        echo '<ul class="list-unstyled text-center mb-0">';
        foreach ( $active_sites as $key => $active_site ) {
            $class = 'fab fa-' . $active_site; ?>
            <li class="list-unstyled-item">
                <a class="<?php echo esc_attr( $active_site ); ?>" target="_blank" href="<?php echo esc_url( get_theme_mod( $key ) ); ?>">
                    <i class="<?php echo esc_attr( $class ); ?>" title="<?php echo esc_attr( $active_site ); ?>"></i>
                </a>
            </li>
        <?php }
        echo "</ul>";
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.