0

I've been learning how to created theme customizer feature to a theme. I have been learning how to make social media icons to show up in the footer.

I have included the files that have to be included in the function.php. But in front-end of theme customizer, my setting does not show up and getting an error message.

I'm learning from just want to see if would work see: https://www.competethemes.com/blog/social-icons-wordpress-menu-theme-customizer/#comment-20708

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'rixcy_scripts' not found or invalid function name in /Users/brandonpowell/sites/valet/alter-theme/web/wp/wp-includes/class-wp-hook.php on line 298

Footer.php

<?php
?>

<!-- #content -->
<div class="footer">
    <div class="main-content">
        <div class="width-6">
                <img src="img/AlterEgo-Branding-text-color.png">
        </div>

        <div class="width-6">

        </div>
    </div>
</div>

<div class="social">
        <div class="main-content">
                <?php require get_template_directory() . '/inc/outputicons.php'; ?>
        </div>
</div>


<?php wp_footer(); ?>

</body>
</html>

socialcustomizersection.php

  <?php
        function my_add_customizer_sections( $wp_customize ) {

            $social_sites = ct_atlers_social_array();

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

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

            // 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 == 'twitter' ) {
                    $label = 'Twitter';
                } elseif ( $social_site == 'facebook' ) {
                    $label = 'Facebook';
                } elseif ( $social_site == 'Github' ) {
                    $label = 'github';
                } elseif ( $social_site == 'linkedin' ) {
                    $label = 'Linkedin';
                } elseif ( $social_site == 'youtube' ) {
                    $label = 'Youtube';
                } elseif ( $social_site == 'instagram' ) {
                    $label = 'Instagram';
                } elseif ( $social_site == 'instagram' ) {
                    $label = 'Instagram';
                } elseif ( $social_site == 'dribbble' ) {
                    $label = 'dribbble';
                } elseif ( $social_site == 'behance' ) {
                    $label = 'behance';
                } elseif ( $social_site == 'behance' ) {
                    $label = 'behance';
                } elseif ( $social_site == 'email-form' ) {
                    $label = 'Contact Form';
                }
                // 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'  => 'ct_tribes_social_media_icons',
                    'priority' => $priority
                ) );
                // increment the priority for next site
                $priority = $priority + 5;
            }
        }
        add_action( 'customize_register', 'my_add_customizer_sections' );

outputicons.php

<?php

function my_social_icons_output() {

    $social_sites = ct_atlers_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="social-media-icons">';
        foreach ( $active_sites as $key => $active_site ) {
            $class = 'fa fa-' . $active_site; ?>
            <li>
                <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>";
    }
}

socialarray.php

<?php
function ct_atlers_social_array() {

    $social_sites = array(
        'twitter'       => 'alter_twitter_profile',
        'facebook'      => 'alter_facebook_profile',
        'google-plus'   => 'alter_googleplus_profile',
        'linkedin'      => 'alter_linkedin_profile',
        'youtube'       => 'alter_youtube_profile',
        'instagram'     => 'alter_instagram_profile',
        'dribbble'      => 'alter_dribbble_profile',
        'behance'       => 'alter_behance_profile',
        'github'        => 'alter_github_profile',
        'email_form'        => 'alter_email_profile',
    );

    return apply_filters( 'ct_alter_social_array_filter', $social_sites );
}
0

The section you created 'Social Media Icons' doesn't show because is empty it doesn't have any control, this is because you didn't set the correct ID in the control arguments, it should be like this in socialcustomizersection.php:

// control
$wp_customize->add_control( $social_site, array(
    'type'     => 'url',
    'label'    => $label,
    'section'  => 'ct_alter_social_array_filter', //it should be the ID you Set for the section
    'priority' => $priority
) );

also in footer.php you are loading outputicons.php and that only contains a function, you need to call the function, put this after the require_once on the footer.php or at the end of outputicons.php:

my_social_icons_output();

the section will show, i added 2 here for testing the output:

enter image description here and they work:

enter image description here

  • This the right way to called a function I may ask. <?php require_once my_social_icons_output(); ?> – Brandon Powell Feb 22 '17 at 3:15
  • require_once its used for loading files, you can just <?php my_social_icons_output(); ?> given that you are loading the file with the function in functions.php – David Lee Feb 22 '17 at 3:22

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.