Quantcast
Channel: XTemos » All Posts
Viewing all articles
Browse latest Browse all 38972

Reply To: Additional social fields in administration panel in child theme

$
0
0

Hi,

I was able to make it work on Notredam theme. On the functions.php of my child theme I added the following code.
This code will help you add Yelp text box on the Social Panel Settings and a link on the footer and not on the share social buttons of the single product page, since Yelp is just a social profile and there’s nothing to share in Yelp.

Add this code on your functions.php

/** 
* ------------------------------------------------------------------------------------------------
* Add Yelp field to Social icons settings 
* ------------------------------------------------------------------------------------------------
*/
    Redux::setSection( "xz_options", array(
        'title' => 'Social',
        'id' => 'social',
        'icon' => 'el-icon-group',
        'fields' => array (
            array (
                'id'       => 'yelp_link',
                'type'     => 'text',
                'title'    => __('Yelp link', 'notredam'), 
                'default' => '#'
            ),
        ),
    ) );
    

/**
* ------------------------------------------------------------------------------------------------
* Share and follow buttons shortcode
* ------------------------------------------------------------------------------------------------
*/

if( ! function_exists( 'xz_shortcode_social' )) {
	function xz_shortcode_social($atts) {
		extract(shortcode_atts( array(
			'type' => 'follow',
			'align' => 'center',
			'tooltip' => 'no',
			'style' => 'default', // circle colored 
			'size' => 'default', // circle colored 
			'el_class' => '',
		), $atts ));

		$target = "_blank";

		$thumb_id = get_post_thumbnail_id();
		$thumb_url = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);

		ob_start();
		?>
		
			<ul class="social-icons text-<?php echo esc_attr( $align ); ?> icons-design-<?php echo esc_attr( $style ); ?> icons-size-<?php echo esc_attr( $size ); ?> social-<?php echo esc_attr( $type ); ?> <?php echo esc_attr( $el_class ); ?>">
				<?php if ( $type == 'share' || xz_get_opt( 'fb_link' ) != ''): ?>
					<li class="social-facebook"><a href="<?php echo ($type == 'follow') ? xz_get_opt( 'fb_link' ) : 'https://www.facebook.com/sharer/sharer.php?u=' . get_the_permalink(); ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-facebook"></i><?php _e('Facebook', 'notredam') ?></a></li>
				<?php endif ?>

				<?php if ( $type == 'share' || xz_get_opt( 'twitter_link' ) != ''): ?>
					<li class="social-twitter"><a href="<?php echo ($type == 'follow') ? xz_get_opt( 'twitter_link' ) : 'http://twitter.com/share?url=' . get_the_permalink(); ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-twitter"></i><?php _e('Twitter', 'notredam') ?></a></li>
				<?php endif ?>

				<?php if ( $type == 'share' || xz_get_opt( 'google_link' ) != ''): ?>
					<li class="social-google"><a href="<?php echo ($type == 'follow') ? xz_get_opt( 'google_link' ) : 'http://plus.google.com/share?url=' . get_the_permalink(); ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-google-plus"></i><?php _e('Google', 'notredam') ?></a></li>
				<?php endif ?>

				<?php if ( $type == 'share' || xz_get_opt( 'social_email' ) != ''): ?>
					<li class="social-email"><a href="mailto:<?php echo ($type == 'follow') ? xz_get_opt( 'social_email' ) : xz_get_opt( 'social_email' ) . '?subject=' . __('Check this ', 'notredam') . get_the_permalink(); ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-envelope"></i><?php _e('Email', 'notredam') ?></a></li>
				<?php endif ?>

				<?php if ( $type == 'follow' && xz_get_opt( 'isntagram_link' ) != ''): ?>
					<li class="social-instagram"><a href="<?php echo ($type == 'follow') ? xz_get_opt( 'isntagram_link' ) : '' . get_the_permalink(); ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-instagram"></i><?php _e('Instagram', 'notredam') ?></a></li>
				<?php endif ?>

				<?php if ( $type == 'share' || xz_get_opt( 'pinterest_link' ) != ''): ?>
					<li class="social-pinterest"><a href="<?php echo ($type == 'follow') ? xz_get_opt( 'pinterest_link' ) : 'http://pinterest.com/pin/create/button/?url=' . get_the_permalink() . '&media=' . $thumb_url[0]; ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-pinterest"></i><?php _e('Pinterest', 'notredam') ?></a></li>
				<?php endif ?>
				
				<?php if ( $type == 'follow' && xz_get_opt( 'yelp_link' ) != ''): ?>
					<li class="social-email"><a href="<?php echo ($type == 'follow') ? xz_get_opt( 'yelp_link' ) : '' . get_the_permalink() . '&media=' . $thumb_url[0]; ?>" target="<?php echo esc_attr( $target ); ?>" class="<?php if( $tooltip == "yes" ) echo 'xz-tooltip'; ?>"><i class="fa fa-yelp"></i><?php _e('Yelp', 'notredam') ?></a></li>
				<?php endif ?>
			</ul>
	
		<?php
		$output = ob_get_contents();
		ob_end_clean();

		return $output; 
	}

	add_shortcode( 'social_buttons', 'xz_shortcode_social' );
}

After you add this code on your functions.php remember to add your shortcode on your footer [social_buttons type="follow"]


Viewing all articles
Browse latest Browse all 38972

Trending Articles