-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsfc-activity-feed-widget.php
145 lines (126 loc) · 6.71 KB
/
sfc-activity-feed-widget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/*
Plugin Name: SFC - Activity Feed Widget
Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
Description: Create an Activity Feed for your sites sidebar.
Author: Otto
Version: 0.25
Author URI: http://ottodestruct.com
License: GPL2
Copyright 2009-2010 Samuel Wood (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2,
as published by the Free Software Foundation.
You may NOT assume that you can use any other version of the GPL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The license for this software can likely be found here:
http://www.gnu.org/licenses/gpl-2.0.html
*/
// checks for sfc on activation
function sfc_activity_feed_activation_check(){
if (function_exists('sfc_version')) {
if (version_compare(sfc_version(), '0.18', '>=')) {
return;
}
}
deactivate_plugins(basename(__FILE__)); // Deactivate ourself
wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
}
register_activation_hook(__FILE__, 'sfc_activity_feed_activation_check');
function get_sfc_activity_feed($args) {
$args = wp_parse_args($args, array(
'header'=>'true',
'site'=>'',
'bordercolor'=>'000000',
'width'=>'260',
'height'=>'400',
'font'=>'lucida+grande',
'colorscheme'=>'light'));
extract($args);
if (empty($site)) $site = get_bloginfo('url');
return "<p class='fb-activity-feed'><iframe src='http://www.facebook.com/plugins/activity.php?site={$site}&width={$width}&height={$height}&header={$header}&colorscheme={$colorscheme}&font={$font}&border_color={$bordercolor}' scrolling='no' frameborder='0' allowTransparency='true' style='border:none; overflow:hidden; width:{$width}px; height:{$height}px'></iframe></p>";
}
function sfc_activity_feed($args='') {
echo get_sfc_activity_feed($args);
}
function sfc_activity_feed_shortcode($atts) {
$args = shortcode_atts(array(
'header'=>'true',
'site'=>'',
'bordercolor'=>'000000',
'width'=>'260',
'height'=>'400',
'font'=>'lucida+grande',
'colorscheme'=>'light'), $atts);
return get_sfc_activity_feed($args);
}
add_shortcode('fb-activity', 'sfc_activity_feed_shortcode');
class SFC_Activity_Feed_Widget extends WP_Widget {
function SFC_Activity_Feed_Widget() {
$widget_ops = array('classname' => 'widget_sfc-activity-feed', 'description' => __('Facebook Activity Feed', 'sfc'));
$this->WP_Widget('sfc-activity', __('Facebook Activity Feed (SFC)', 'sfc'), $widget_ops);
}
function widget($args, $instance) {
extract( $args );
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if ( $title ) echo $before_title . $title . $after_title;
sfc_activity_feed($instance);
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'width'=>260, 'height'=>400, 'bordercolor'=>'000000', 'font'=>'lucida+grande', 'colorscheme'=>'light') );
$instance['title'] = strip_tags($new_instance['title']);
$instance['width'] = intval($new_instance['width']);
$instance['height'] = intval($new_instance['height']);
$instance['bordercolor'] = strip_tags($new_instance['bordercolor']);
$instance['colorscheme'] = strip_tags($new_instance['colorscheme']);
$instance['font'] = strip_tags($new_instance['font']);
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'width'=>260, 'height'=>400, 'bordercolor'=>'000000', 'font'=>'lucida+grande', 'colorscheme'=>'light' ) );
$title = strip_tags($instance['title']);
$width = intval($instance['width']);
$height = intval($instance['height']);
$bordercolor = strip_tags($instance['bordercolor']);
if (empty($bordercolor)) $bordercolor = '000000';
$colorscheme = strip_tags($instance['colorscheme']);
$font = strip_tags($instance['font']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
</label></p>
<p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width of the widget in pixels:', 'sfc'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo $width; ?>" />
</label></p>
<p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height of the widget in pixels:', 'sfc'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo $height; ?>" />
</label></p>
<p><label for="<?php echo $this->get_field_id('bordercolor'); ?>"><?php _e('Border color:', 'sfc'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('bordercolor'); ?>" name="<?php echo $this->get_field_name('bordercolor'); ?>" type="text" value="<?php echo $bordercolor; ?>" />
</label></p>
<p><label for="<?php echo $this->get_field_id('colorscheme'); ?>"><?php _e('Color scheme:', 'sfc'); ?>
<select name="<?php echo $this->get_field_name('colorscheme'); ?>" id="<?php echo $this->get_field_id('colorscheme'); ?>">
<option value="light" <?php selected('light', $colorscheme); ?>><?php _e('light', 'sfc'); ?></option>
<option value="dark" <?php selected('dark', $colorscheme); ?>><?php _e('dark', 'sfc'); ?></option>
</select>
</label></p>
<p><label for="<?php echo $this->get_field_id('font'); ?>"><?php _e('Font:', 'sfc'); ?>
<select name="<?php echo $this->get_field_name('font'); ?>" id="<?php echo $this->get_field_id('font'); ?>">
<option value="arial" <?php selected('arial', $font); ?>>arial</option>
<option value="lucide+grande" <?php selected('lucide+grande', $font); ?>>lucide grande</option>
<option value="segoe+ui" <?php selected('segoe+ui', $font); ?>>segoe ui</option>
<option value="tahoma" <?php selected('tahoma', $font); ?>>tahoma</option>
<option value="trebuchet+ms" <?php selected('trebuchet+ms', $font); ?>>trebuchet ms</option>
<option value="verdana" <?php selected('verdana', $font); ?>>verdana</option>
</select>
</label></p>
<?php
}
}
add_action('widgets_init', create_function('', 'return register_widget("SFC_Activity_Feed_Widget");'));