Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #637399

    Hello the team,

    I’d like to modify the avia social count widget in order to add a Facebook link in my child theme.
    I wrote in my functions.php :

    function avia_socialcount ()
    {
    	class avia_socialcount extends WP_Widget {
    
    		function __construct() {
    			//Constructor
    			$widget_ops = array('classname' => 'avia_socialcount', 'description' => __('A widget to display a link to your twitter, facebook profiles and rss feed', 'avia_framework') );
    			parent::__construct( 'avia_socialcount', THEMENAME.' RSS Link, Twitter et Facebook Account', $widget_ops );
    		}
    
    		function widget($args, $instance) {
    			// prints the widget
    
    			extract($args, EXTR_SKIP);
    			$twitter = empty($instance['twitter']) ? '' : $instance['twitter'];
    			$facebook = empty($instance['twitter']) ? '' : $instance['facebook'];
    			$rss 	 = empty($instance['rss'])     ? '' : $instance['rss'];
    			$rss = preg_replace('!https?:\/\/feeds.feedburner.com\/!','',$rss);
    
    			if(!empty($twitter) || !empty($rss) || !empty($facebook))
    			{
    				$addClass = "asc_multi_count";
    				if(!isset($twitter) || !isset($rss) || !isset($facebook)) $addClass = 'asc_single_count';
    
    				echo $before_widget;
    				$output = "";
    				if(!empty($twitter))
    				{
    					$link = 'http://twitter.com/'.$twitter.'/';
    					$before = apply_filters('avf_social_widget', "", 'twitter');
    					$output .= "<a href='$link' class='asc_twitter $addClass'>{$before}<strong class='asc_count'>".__('Follow','avia_framework')."</strong><span>".__('on Twitter','avia_framework')."</span></a>";
    					
    				}
    				
    				if(!empty($facebook))
    				{
    					$link2 = 'https://www.facebook.com/'.$facebook.'/';
    					$before = apply_filters('avf_social_widget', "", 'facebook');
    					$output .= "<a href='$link2' class='asc_facebook $addClass'>{$before}<strong class='asc_count'>".__('Follow','avia_framework')."</strong><span>".__('sur Facebook','avia_framework')."</span></a>";
    					
    				}
    
    				if($rss)
    				{
    					$output .= "<a href='$rss' class='asc_rss $addClass'>".apply_filters('avf_social_widget',"", 'rss')."<strong class='asc_count'>".__('Subscribe','avia_framework')."</strong><span>".__('to RSS Feed','avia_framework')."</span></a>";
    				}
    
    				echo $output;
    				echo $after_widget;
    			}
    		}
    
    		function update($new_instance, $old_instance) {
    			//save the widget
    			$instance = $old_instance;
    			foreach($new_instance as $key=>$value)
    			{
    				$instance[$key]	= strip_tags($new_instance[$key]);
    			}
    
    			return $instance;
    		}
    
    		function form($instance) {
    			//widgetform in backend
    
    			$instance = wp_parse_args( (array) $instance, array('rss' => avia_get_option('feedburner'), 'twitter', 'facebook' => avia_get_option('twitter') ) );
    			$twitter = empty($instance['twitter']) ? '' :  strip_tags($instance['twitter']);
    			$facebook = empty($instance['facebook']) ? '' :  strip_tags($instance['facebook']);
    			$rss 	 = empty($instance['rss'])     ? '' :  strip_tags($instance['rss']);
    	?>
    			<p>
    			<label for="<?php echo $this->get_field_id('twitter'); ?>"><?php _e('Twitter Username:', 'avia_framework'); ?>
    			<input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo esc_attr($twitter); ?>" /></label></p>
    			
    			<p>
    			<label for="<?php echo $this->get_field_id('facebook'); ?>"><?php _e('Facebook Username:', 'avia_framework'); ?>
    			<input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php echo esc_attr($facebook); ?>" /></label></p>
    
    			<p><label for="<?php echo $this->get_field_id('rss'); ?>"><?php _e('Enter your feed url:', 'avia_framework'); ?>
    			<input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php echo esc_attr($rss); ?>" /></label></p>
    
    		<?php
    		}
    	}
    }

    But nothing changes in my backend, the function of the parent theme is loaded instead of this one of my child theme.

    Please help.

    Best regards.

    #638031

    Hey hurraken,

    Try removing:

    function avia_socialcount ()
    {
    ..
    }

    Leave the class as it is.

    Best regards,
    Josue

    #638053

    Great it works !!

    Thank you Josue !

    #638174

    Hi,

    Glad to hear it works! Feel free to reach out to us again on the forum if you need assistance with anything else :)

    Best regards,
    Jordan

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.