Hi guys,
Would you please tell where and in which file to edit the PT widget so that when one clicks on its icon it opens Twitter in a BLANK window instead of the same? I couldn't find it. Thanks a lot,
Nomar
Hi guys,
Would you please tell where and in which file to edit the PT widget so that when one clicks on its icon it opens Twitter in a BLANK window instead of the same? I couldn't find it. Thanks a lot,
Nomar
Hello,
Open your framework > php folder then look for class-framework-widgets.php. Search for twitter or this line.
if ( !empty( $title ) ) { echo $before_title . "<a href='http://twitter.com/$username/' title='$title'>".$title ."</a>". $after_title; };
replace it with
if ( !empty( $title ) ) { echo $before_title . "<a href='http://twitter.com/$username/' title='$title' target='_blank'>".$title ."</a>". $after_title; };
Regards,
Ismael
Hi Ismael,
Thanks for your reply. Unfortunately, I couldn't find that line of code in that file.
I don't know whether this file belongs to a different version of the theme, The code for Twitter (AVIA SOCIALCOUNT) is located on line 523, and extends until line 665. I'll try to copy it here so you can tell me what to change or where to add the code you provided (don't know if this form will hold it entirely).
BTW: sorry, but didn't know how to place code between 'backticks':
class avia_socialcount extends WP_Widget {
function avia_socialcount() {
//Constructor
$widget_ops = array('classname' => 'avia_socialcount', 'description' => 'A widget to display your twitter and rss followers' );
$this->WP_Widget( 'avia_socialcount', THEMENAME.' Twitter and RSS count', $widget_ops );
}
function widget($args, $instance) {
// prints the widget
extract($args, EXTR_SKIP);
$twitter = empty($instance['twitter']) ? '' : apply_filters('widget_title', $instance['twitter']);
$rss = empty($instance['rss']) ? '' : apply_filters('widget_title', $instance['rss']);
$rss = preg_replace('!https?:\/\/feeds.feedburner.com\/!','',$rss);
$follower = $this->count_followers($twitter, $rss, $widget_id);
if(!empty($follower) && is_array($follower))
{
$addClass = "asc_multi_count";
if(!isset($follower['twitter']) || !isset($follower['rss'])) $addClass = 'asc_single_count';
echo $before_widget;
if(isset($follower['twitter']))
{
$link = 'http://twitter.com/'.$twitter.'/';
echo "<strong class='asc_count'>".$follower['twitter']."<span>".__('Follower','avia_framework')."</span> target='_blank'";
}
if(isset($follower['rss']))
{
$link = 'http://feeds.feedburner.com/'.$rss;
echo "<strong class='asc_count'>".$follower['rss']."<span>".__('Subscribers','avia_framework')."</span> target='_blank'";
}
echo $after_widget;
}
}
function count_followers($twitter, $rss, $widget_id)
{
$follower = array();
$optionkey = strtolower(THEMENAME.'fc_id'.$widget_id);
$cache = get_transient($optionkey);
if($cache)
{
$follower = get_option($optionkey);
}
else
{
if($twitter != "")
{
$twittercount = wp_remote_get( 'http://api.twitter.com/1/statuses/user_timeline.xml?screen_name='.$twitter );
if (!is_wp_error($twittercount))
{
$xml = simplexml_load_string($twittercount['body']);
if( empty( $xml->error ) && isset($xml->status->user->followers_count))
{
$follower['twitter'] = (int) $xml->status->user->followers_count;
}
}
}
if($rss != "")
{
$requesturl = "http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/".$rss.'&dates=' . date('Y-m-d', strtotime('-2 days', time()));
$feedcount = wp_remote_get($requesturl);
if (!is_wp_error($feedcount))
{
$xml = simplexml_load_string($feedcount['body']);
if(is_object($xml->feed->entry))
{
$follower['rss'] = (int) $xml->feed->entry->attributes()->circulation;
}
}
}
$fallback = get_option($optionkey);
if(!isset($follower['rss']) && isset($fallback['rss'])) $follower['rss'] = $fallback['rss'];
if(!isset($follower['twitter']) && isset($fallback['twitter'])) $follower['twitter'] = $fallback['twitter'];
set_transient($optionkey, 1, 60*60*12);
update_option($optionkey, $follower);
}
return $follower;
}
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]);
}
delete_transient(strtolower(THEMENAME.'fc_id'.$this->id_base."-".$this->number));
return $instance;
}
function form($instance) {
//widgetform in backend
$instance = wp_parse_args( (array) $instance, array('rss' => avia_get_option('feedburner'), 'twitter' => avia_get_option('twitter') ) );
$twitter = empty($instance['twitter']) ? '' : strip_tags($instance['twitter']);
$rss = empty($instance['rss']) ? '' : strip_tags($instance['rss']);
?>
<p>
<label for="<?php echo $this->get_field_id('twitter'); ?>">Twitter Username:
<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('rss'); ?>">Enter your feedburner url:
<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
}
}
Thanks a lot for your help. Take care,
Nomar
Oh, before I forget,
I would highly appreciate if you also told be where to do the same (target='_blank') for the "social icons" in the header and "footer".
Note: It would be great if this setting was added to the CMS in a similar fashion to the way you did for the section "Links".
Thanks again,
Nomar
Hi Nomar,
The code Ismael referred to above is on line 45 in the class-framework-widgets.php file. Here's the complete function so you can find it easier:
function widget($args, $instance) {
// prints the widget
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
$count = empty($instance['count']) ? '' : apply_filters('widget_title', $instance['count']);
$username = empty($instance['username']) ? '' : apply_filters('widget_title', $instance['username']);
$exclude_replies = empty($instance['exclude_replies']) ? '' : apply_filters('widget_title', $instance['exclude_replies']);
$time = empty($instance['time']) ? 'no' : apply_filters('widget_title', $instance['time']);
$display_image = empty($instance['display_image']) ? 'no' : apply_filters('widget_title', $instance['display_image']);
if ( !empty( $title ) ) { echo $before_title . "<a href='http://twitter.com/$username/' title='$title'>".$title ."</a>". $after_title; };
$messages = tweetbox_get_tweet($count, $username, $widget_id, $time, $exclude_replies, $display_image);
echo $messages;
echo $after_widget;
}
As far as "target="_blank", you'll need to place that snippet of code in footer.php. Here's the code you're looking for:
<ul class="social_bookmarks">
<?php
//contact icon
$contact_page_id = avia_get_option('email_page');
if (function_exists('icl_object_id')) $contact_page_id = icl_object_id($contact_page_id, 'page', true); //wpml prepared
if($contact_page_id) echo "<li class='mail'><a href='".get_permalink($contact_page_id)."'>".__('Send us Mail', 'avia_framework')."</a></li>";
if($dribbble = avia_get_option('dribbble')) echo "<li class='dribbble'><a href='http://dribbble.com/".$dribbble."'>".__('Follow us on dribbble', 'avia_framework')."</a></li>";
if($twitter = avia_get_option('twitter')) echo "<li class='twitter'><a href='http://twitter.com/".$twitter."'>".__('Follow us on Twitter', 'avia_framework')."</a></li>";
if($facebook = avia_get_option('facebook')) echo "<li class='facebook'><a href='".$facebook."'>".__('Join our Facebook Group', 'avia_framework')."</a></li>";
?>
<li class='rss'><a href="<?php avia_option('feedburner',get_bloginfo('rss2_url')); ?>"><?php _e('Subscribe to our RSS Feed', 'avia_framework')?></a></li>
</ul>
You'll want to place target=_blank before the HREF in each of the links above.
Hope this helps!
Regards,
Mya
Hi Mya,
Hope you are doing great.
Thanks for explaining where the code "should" be. However, as I said in my first reply to Ismael, it appears that we are working on different versions of the "class-framework-widgets.php" file. If you take a look at the code I pasted above, you'll see what I mean.
I tried the first piece of code you provided, for the widget, but it didn't work (I guess there must be something else in the rest of the code). In the footer' socket, I had already managed to make social links to work my way (sort of)... ;o)
Is there a way you could send me the "class-framework-widgets.php" file you are currently using? Perhaps I could solve the problem using it instead of the one I have...
Also, if you don't mind me asking, where would I do the same for the social icons in the header, if I were using them?
Thanks a bunch. Take care,
Nomar
Hi Nomar,
The versions shouldn't matter. Make sure you are looping in the propulsion theme folder in framework>php>class-framework-widgets.php. I just checked the files for propulsion 1.2.1 and its the same location in both.
For the social links, it needs to be in the proper format for being inside the php tags.. Here is the twitter link:
if($twitter = avia_get_option('twitter')) echo "<li class='twitter'><a href='http://twitter.com/".$twitter."' target='_blank'>".__('Follow us on Twitter', 'avia_framework')."</a></li>";
So the whole block would be:
if($dribbble = avia_get_option('dribbble')) echo "<li class='dribbble'><a href='http://dribbble.com/".$dribbble."' target='_blank'>".__('Follow us on dribbble', 'avia_framework')."</a></li>";
if($twitter = avia_get_option('twitter')) echo "<li class='twitter'><a href='http://twitter.com/".$twitter."' target='_blank'>".__('Follow us on Twitter', 'avia_framework')."</a></li>";
if($facebook = avia_get_option('facebook')) echo "<li class='facebook'><a href='".$facebook."' target='_blank'>".__('Join our Facebook Group', 'avia_framework')."</a></li>";
For the header, you would do the same thing except in the functions.php right around line 198. You can search for:
echo '<ul class="social_bookmarks">';
to find the exact spot.
Regards,
Devin
Hey Devin,
Hope you are doing great.
I double checked to make sure I was using the right file, and yes, I am.
I replaced the section of the code with the one you sent, but it didn't work either. I don't know what I'm missing....
BTW, I noticed that your code is different to the one that was originally in the file:
if ( !empty( $title ) ) { echo $before_title . "<a href='http://twitter.com/$username/' title='$title' target='_blank'>".$title ."</a>". $after_title; };
However, I also tried the code in the functions.php, and it works fine for both the social icons in the header and footer, except for the RSS; I haven't been able to find in which file I can add the target='_blank' to open the RSS in a new tab...
Thanks for your help in these two things. Have a great weekend,
Nomar
Hi Nomar,
The RSS line is just under the others. Replace it with:
echo ' <li class="rss"><a href="'.avia_get_option('feedburner',get_bloginfo('rss2_url')).'" target="_blank">RSS</a></li>';
Your main issue however I'm not sure what else to do. You can try re-downloading the theme files from your downloads in theme forest and replace your file with the framework>php>class-framework-widgets.php file in the newest version and try following Ismael's original changes again.
Regards,
Devin
You must log in to post.