Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * AVIA COMBO WIDGET
- *
- * Widget that retrieves, stores and displays the number of twitter and rss followers
- *
- * @package AviaFramework
- * @todo replace the widget system with a dynamic one, based on config files for easier widget creation
- */
- if (!class_exists('avia_fb_likebox'))
- {
- class avia_fb_likebox extends WP_Widget {
- function __construct() {
- //Constructor
- $widget_ops = array('classname' => 'avia_fb_likebox', 'description' => 'A widget that displays a facebook Likebox to a facebook page of your choice' );
- parent::__construct( 'avia_fb_likebox', THEMENAME.' Facebook Likebox', $widget_ops );
- }
- function widget($args, $instance)
- {
- // prints the widget
- $this->fbsdk();
- extract($args, EXTR_SKIP);
- if(empty($instance['url'])) return;
- $url = $instance['url'];
- $height = $instance['height'];
- $border = $instance['border'];
- $profiles = 3000; // since the height determines the number of images loaded
- $faces = "true";
- $extraClass = "";
- $style = "";
- if(strpos($height, "%") === false && strpos($height, "px") === false) $height = $height."px";
- if(strpos($height, "%") !== false)
- {
- $extraClass = "av_facebook_widget_wrap_positioner";
- }
- echo $before_widget;
- echo "<div class='av_facebook_widget_wrap {$extraClass} av_facebook_widget_wrap_border_{$border}'>";
- echo '<div class="fb-page" data-href="'.$url.'" data-width="100%" data-height="'.$instance['height'].'" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="'.$instance['fb-images'].'" data-show-posts="'.$instance['fb-posts'].'"><div class="fb-xfbml-parse-ignore"></div></div>';
- echo "</div>";
- echo $after_widget;
- }
- function update($new_instance, $old_instance)
- {
- $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('url' => 'https://www.facebook.com/kriesi.at', 'height' => '258px', 'border' => 'yes', 'fb-posts' => 'yes', 'fb-image' => 'yes') );
- $html = new avia_htmlhelper();
- $elementCat = array("name" => "",
- "desc" => "",
- "id" => $this->get_field_name('border'),
- "type" => "select",
- "std" => strip_tags($instance['border']),
- "class" => "",
- "no_first" => true,
- "subtype" => array('Yes, display border'=>'yes', 'No, do not display border'=>'no'));
- $fbpost = array("name" => "",
- "desc" => "",
- "id" => $this->get_field_name('fb-posts'),
- "type" => "select",
- "std" => strip_tags($instance['fb-posts']),
- "class" => "",
- "no_first" => true,
- "subtype" => array('Yes, display the posts'=>'yes', 'No, do not display the posts'=>'no'));
- $fbimage = array("name" => "",
- "desc" => "",
- "id" => $this->get_field_name('fb-image'),
- "type" => "select",
- "std" => strip_tags($instance['fb-image']),
- "class" => "",
- "no_first" => true,
- "subtype" => array('Yes, display images'=>'true', 'No, do not display images'=>'false'));
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('url'); ?>">Enter the url to the Page. Please note that it needs to be a link to a <strong>facebook fanpage</strong>. Personal profiles are not allowed!
- <input class="widefat" id="<?php echo $this->get_field_id('url'); ?>" name="<?php echo $this->get_field_name('url'); ?>" type="text" value="<?php echo esc_attr($instance['url']); ?>" /></label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('height'); ?>">Enter the widget height in pixel or % <br/><small>(100% would create a widget of equal height and width)</small>
- <input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr($instance['height']); ?>" /></label>
- </p>
- <p><label for="<?php echo $this->get_field_id('border'); ?>">Display Border around the widget?
- <?php echo $html->select($elementCat); ?>
- </label></p>
- <p><label for="<?php echo $this->get_field_id('fb-posts'); ?>">Display Posts?
- <?php echo $html->select($fbpost); ?>
- </label></p>
- <p><label for="<?php echo $this->get_field_id('fb-images'); ?>">Display Facebook Images?
- <?php echo $html->select($fbimage); ?>
- </label></p>
- <?php
- }
- function fbsdk() { ?>
- <div id="fb-root"></div>
- <script>(function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));</script>
- <?php
- add_action('wp_footer', 'sdk', 50);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement