June 30, 20108 Comments

It’s just a simple fanbox widget as wordpress plugin, nothing to explain. But I made my own version ?

Features

  • iframe method
  • auto detect ie(internet explorer), because sometimes it’s make problem for ie and option to use as iframe only for ie !
  • jquery based document ready facebook load ! Not clear ? see bellow

One thing to note that I used a way to load the facebook js script after loading jquery as normally in wordpress site front end we use jquery and many plugin uses this… so we can take that jquery is using default. So I loaded the fb js using wp_enqueue function and then called the fb init function after the document is loaded using jquery dom ready function :P … It’s just an experiment about slow loading of facebook fanbox widget in wordpress :D

Download

  Facebook Fanbox wordpress widget (2.9 KiB, 66 hits)


If you just download with no comment and no recommendation to others, then I am planning to hate you :P
Man at least share in social network and give me traffic so that I can have more money from ads :(

Good morning. It’s just morning after working whole night and I am feeling too hungry :)

Code Example

	function widget( $args, $instance ) {
		extract( $args );
                 global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
		/* Our variables from the widget settings. */
		$title          = apply_filters('widget_title', $instance['title'] );
		$profileid      = $instance['profileid']; //name or profile id , not both
		$apikey         = isset( $instance['apikey'])? $instance['apikey'] : '';
                $stream         = isset( $instance['stream'] ) ? $instance['stream'] : 0;
                $connections    = isset( $instance['connections'] )? (($instance['connections'] > 100)? 100: intval($instance['connections'])): 10; //Specifying 0 hides the list of fans in the Fan Box. You cannot display more than 100 fans. (Default value is 10 connections.)
                $width          = isset( $instance['width'] )? (($instance['width'] < 200)? 200: intval($instance['width'])): 300; // at least 200 pixels wide at minimum. (Default value is 300 pixels.)
                $height         = isset( $instance['height'] )? $instance['height']: 554;
                $css            = isset( $instance['css']) ? $instace['css']:'';
                $logobar        = isset( $instance['logobar'] ) ? $instance['logobar'] : 1;
                $iframe         = isset( $instance['iframe'])? $instance['iframe'] : 0;
                $locale         = isset( $instance['locale'])? $instance['locale']: 'en_US';
                $iframeie       = isset( $instance['iframeie'] ) ? $instance['iframeie'] : 1; // use iframe for ie , auto detect
                $usejquery     = isset( $instance['usejquery'] ) ? $instance['usejquery'] : 1;
		/* Before widget (defined by themes). */
                //var_dump($iframe);
		echo $before_widget;
		/* Display the widget title if one was input (before and after defined by themes). */
		if ( $title )
                {
                    echo $before_title . $title . $after_title;
                }
                if(($is_IE && $iframeie) || $iframe || $apikey == '')
                {
                    //echo 'yes';
                    echo '<iframe scrolling="no" frameborder="0" src="http://www.facebook.com/connect/connect.php?id='.$profileid.'&amp;stream='.$stream.'&amp;connections='.$connections.'&amp;logobar='.$logo.'&amp;css='.$css.'?'.mktime().'" style="border: none; width: '.$width.'px; height:'.$height.'px;">&nbsp;</iframe>';
                }
                else
                {
                    if($usejquery)
                    {
                        wp_enqueue_script('fbjs', 'http://static.ak.connect.facebook.com/connect.php/en_US', array('jquery'), null);
                        echo '<fb:fan profile_id="'.$profileid.'" width="'.$width.'" connections="'.$connections.'" stream="'.$stream.'" header="'.$logobar.'"></fb:fan>';
                        echo '<script type="text/javascript">jQuery(document).ready(function() {
                                FB.init("'.$apikey.'");
                                });</script>';
                    }
                    else
                    {
                            echo '<script type="text/javascript" src="http://static.ak.connect.facebook.com/connect.php/en_US"></script>';
                            echo '<script type="text/javascript"> FB.init("'.$apikey.'"); </script>';
                    }
                }
		/* After widget (defined by themes). */
		echo $after_widget;
	}
December 25, 2009Leave a Comment

Post and Page Excerpt Widgets is a nice plugin to show post/page excerpt as as widget in sidebar position. You can download it from wp code from here. One I thing I noticed about this plugin is it has a common bug that I faced many times while using query_posts. When I use this query_posts it’s break some conditional loop like is_home(), is_category() etc but there is another function get_posts in wordpress that does the same thing but don’t have similar problem. Once I discussed about this problem in one of my old posts. Please check that posts for better sense from here is_home-is_single-is_category-is-not-working-in-wp!.

Let me focus to this writing again :D
As Post and Page Excerpt Widgets is using the query_posts function for custom query it make’s problem for conditional tags. Let me show u solution and it’s like my that posts.
In you theme functions.php add a new function if not exists yet

…continue reading Fix wp plugin “Post and Page Excerpt Widgets” not to break conditional tag

  • Go to top
    Go to top
feedback