Custom Facebook Feed - Version 1.4.0

Version Description

  • Major Update!
  • New: Loads of new customization options for your feed
  • New: Define feed width, height, padding and background color
  • New: Change the font-size, font-weight and color of the post text, description, date, links and event details
  • New: Choose whether to show or hide certain parts of the posts
  • New: Select whether the Like box is shown at the top of bottom of the feed
  • New: Choose Like box background color
Download this release

Release Info

Developer smashballoon
Plugin Icon 128x128 Custom Facebook Feed
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.7 to 1.4.0

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: smashballoon
3
Tags: facebook, custom, customizable, feed, seo, search engine, responsive, mobile, shortcode, social, status
4
Requires at least: 3.0
5
Tested up to: 3.5.1
6
- Stable tag: 1.3.7
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
@@ -13,26 +13,27 @@ The Custom Facebook Feed allows you to display a customizable Facebook feed of a
13
14
Display a **customizable**, **responsive** and **search engine crawlable** version of your Facebook feed on your WordPress site.
15
16
- Other Facebook plugins use iframes to show your feed which don't allow you to customize how they look, aren't responsive and are not crawlable by search engines. The Custom Facebook Feed inherits your theme's style to display a feed which is responsive, crawlable and seamlessly matches the look and feel of your site.
17
18
- * **Completely Customizable** - by default inherits your theme's styles
19
* **Feed content is crawlable by search engines adding SEO value to your site** - other Facebook plugins embed the feed using iframes which are not crawlable
20
- * **Completely responsive and mobile optimized** - works on any screen size
21
- * Use the shortcode to display the feed in a page, post or widget anywhere on your site
22
- * Limit the number of posts to be shown in your feed
23
* Set a maximum length for both the post title and body text
24
- * Use the shortcode to display feeds from multiple Facebook pages anywhere on your site
25
26
- To display photos, videos and the number of likes, shares and comments for each post then [upgrade to the PRO version](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO"). Try out the [PRO demo](http://smashballoon.com/custom-facebook-feed/demo "Custom Facebook Feed Demo").
27
28
== Installation ==
29
30
1. Install the Custom Facebook Feed either via the WordPress plugin directory, or by uploading the files to your web server (in the `/wp-content/plugins/` directory).
31
2. Activate the plugin through the 'Plugins' menu in WordPress.
32
- 3. Navigate to the plugin settings page to configure your feed.
33
4. Use the shortcode `[custom-facebook-feed]` in your page, post or widget to display your feed.
34
5. You can display multiple feeds of different Facebook pages by specifying a Page ID directly in the shortcode: `[custom-facebook-feed id=SarahsBakery show=5]`.
35
- 6. You can limit the length of the title and body text by using `titlelength=100` and `bodylength=150` (for example) in the shortcode. `[custom-facebook-feed titlelength=100 bodylength=150]`.
36
37
== Frequently Asked Questions ==
38
@@ -54,7 +55,7 @@ An Access Token is required by Facebook in order to access their feeds. Don't w
54
55
= Can I show photos and videos in my feed? =
56
57
- This plugin only allows you to display text updates from your feed. To display photos and videos in your feed you need to upgrade to the PRO version of the plugin. Try out a demo of the PRO version on the [Custom Facebook Feed website](http://smashballoon.com/custom-facebook-feed/demo "Custom Facebook Feed Demo"), and find out more about the PRO version [here](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO").
58
59
= Can I show the comments associated with each post? =
60
@@ -66,14 +67,24 @@ It sure is. Unlike other Facebook plugins which use iframes to embed your feed i
66
67
== Screenshots ==
68
69
- 1. Feed displayed in a page or post. By default the feed inherits your theme's default styles and is completely responsive.
70
- 2. Feed displayed in a side widget.
71
3. Configuring the plugin
72
- 4. Adding the shortcode to your page or post. The shortcode parameters are optional and can be used to override the default settings you set on the plugin settings page
73
- 5. Adding the shortcode to a widget
74
75
== Changelog ==
76
77
= 1.3.6 =
78
* Minor modifications
79
3
Tags: facebook, custom, customizable, feed, seo, search engine, responsive, mobile, shortcode, social, status
4
Requires at least: 3.0
5
Tested up to: 3.5.1
6
+ Stable tag: 1.4.0
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
13
14
Display a **customizable**, **responsive** and **search engine crawlable** version of your Facebook feed on your WordPress site.
15
16
+ The Custom Facebook Feed allows you to display a completely customizable, responsive, and search engine crawlable version of your Facebook page on your own website. No more ugly iframes! Customize your feed to seamlessly match the look and feel of your site.
17
18
+ * **Completely Customizable** - By default the feed will adopt the style of your website, but can be completely customized to look however you like!
19
* **Feed content is crawlable by search engines adding SEO value to your site** - other Facebook plugins embed the feed using iframes which are not crawlable
20
+ * **Completely responsive and mobile optimized** - layout looks great on any screen size and in any container width
21
+ * Control the width, height, padding and background color of your feed
22
+ * Customize the size, weight and color of text
23
+ * Select which parts of each post to display or hide
24
+ * Select the number of posts to display
25
* Set a maximum length for both the post title and body text
26
+ * Use the shortcode to display the feed in a page, post or widget anywhere on your site
27
28
+ To display photos, videos, the number of likes, shares and comments for each post, and for multiple layout options then [upgrade to the PRO version](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO"). Try out the [PRO demo](http://smashballoon.com/custom-facebook-feed/demo "Custom Facebook Feed Demo").
29
30
== Installation ==
31
32
1. Install the Custom Facebook Feed either via the WordPress plugin directory, or by uploading the files to your web server (in the `/wp-content/plugins/` directory).
33
2. Activate the plugin through the 'Plugins' menu in WordPress.
34
+ 3. Navigate to the 'Facebook Feed' settings page to configure your feed.
35
4. Use the shortcode `[custom-facebook-feed]` in your page, post or widget to display your feed.
36
5. You can display multiple feeds of different Facebook pages by specifying a Page ID directly in the shortcode: `[custom-facebook-feed id=SarahsBakery show=5]`.
37
38
== Frequently Asked Questions ==
39
55
56
= Can I show photos and videos in my feed? =
57
58
+ This plugin only allows you to display textual updates from your feed. To display photos and videos in your feed you need to upgrade to the PRO version of the plugin. Try out a demo of the PRO version on the [Custom Facebook Feed website](http://smashballoon.com/custom-facebook-feed/demo "Custom Facebook Feed Demo"), and find out more about the PRO version [here](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO").
59
60
= Can I show the comments associated with each post? =
61
67
68
== Screenshots ==
69
70
+ 1. By default the feed inherits your theme's default styles and is completely responsive.
71
+ 2. Completely customize the way your feed looks to perfectly match your site.
72
3. Configuring the plugin
73
+ 4. Use the styling options to customize your feed
74
+ 5. It's super easy to display your feed in any page or post
75
+ 6. Add the shortcode to a widget
76
77
== Changelog ==
78
79
+ = 1.4.0 =
80
+ * Major Update!
81
+ * New: Loads of new customization options for your feed
82
+ * New: Define feed width, height, padding and background color
83
+ * New: Change the font-size, font-weight and color of the post text, description, date, links and event details
84
+ * New: Choose whether to show or hide certain parts of the posts
85
+ * New: Select whether the Like box is shown at the top of bottom of the feed
86
+ * New: Choose Like box background color
87
+
88
= 1.3.6 =
89
* Minor modifications
90
css/{style.css → cff-style.css} RENAMED
@@ -1,52 +1,40 @@
1
-
2
/**************/
3
/*** LAYOUT ***/
4
/**************/
5
-
6
/* Feed container */
7
#cff {
8
float: left;
9
width: 100%;
10
margin: 0 auto;
11
- padding: 0;
12
}
13
-
14
/* Individual post item */
15
#cff .cff-item{
16
float: left;
17
width: 100%;
18
clear: both;
19
- padding: 20px 0;
20
border-bottom: 1px solid #ddd;
21
}
22
#cff .cff-item:first-child{
23
padding-top: 0;
24
}
25
-
26
-
27
/******************/
28
/*** TYPOGRAPHY ***/
29
/******************/
30
-
31
/* Links */
32
#cff a {
33
- color:#666;
34
text-decoration:underline;
35
}
36
- #cff a:active, #cff a:hover {
37
- color: #000;
38
- }
39
-
40
/* Post titles and body text */
41
- #cff h4, #cff h3, #cff p{
42
float: left;
43
width: 100%;
44
padding: 0;
45
margin: 5px 0;
46
line-height: 1.4;
47
- }
48
-
49
- #cff h4, #cff h3{
50
white-space: pre;
51
white-space: pre-wrap;
52
white-space: pre-line;
@@ -56,14 +44,25 @@
56
white-space: -hp-pre-wrap;
57
word-wrap: break-word;
58
}
59
-
60
/* Date */
61
#cff .cff-date{
62
float: left;
63
width: 100%;
64
font-size: 11px;
65
}
66
-
67
/* Event */
68
#cff .details{
69
float: left;
@@ -78,40 +77,30 @@
78
#cff .details p{
79
font-size: 14px;
80
}
81
-
82
-
83
/*****************/
84
/*** POST META ***/
85
/*****************/
86
-
87
/* Meta container */
88
- #cff .cff-meta{
89
float: left;
90
width: 100%;
91
- list-style-type: none;
92
- padding: 5px 0;
93
- margin: 0;
94
}
95
-
96
/* View on Facebook / View Link text */
97
#cff .cff-viewpost{
98
- float: left;
99
- clear: both;
100
font-size: 11px;
101
}
102
-
103
-
104
- /************/
105
- /*** MISC ***/
106
- /************/
107
-
108
/* Like box */
109
#cff .cff-likebox{
110
float: left;
111
width: 100%;
112
- margin: 10px 0 0 -10px;
113
}
114
-
115
/* Clear fix */
116
.clear:after {
117
clear: both;
@@ -122,7 +111,17 @@
122
}
123
.clear {
124
display: inline-block;
125
- }
126
- .clear {
127
display: block;
128
}
1
/**************/
2
/*** LAYOUT ***/
3
/**************/
4
/* Feed container */
5
#cff {
6
float: left;
7
width: 100%;
8
margin: 0 auto;
9
+ -webkit-box-sizing: border-box;
10
+ -moz-box-sizing: border-box;
11
+ box-sizing: border-box;
12
}
13
/* Individual post item */
14
#cff .cff-item{
15
float: left;
16
width: 100%;
17
clear: both;
18
+ padding: 20px 0 15px 0;
19
border-bottom: 1px solid #ddd;
20
}
21
#cff .cff-item:first-child{
22
padding-top: 0;
23
}
24
/******************/
25
/*** TYPOGRAPHY ***/
26
/******************/
27
/* Links */
28
#cff a {
29
text-decoration:underline;
30
}
31
/* Post titles and body text */
32
+ #cff h3, #cff h4, #cff h5, #cff h6, #cff p{
33
float: left;
34
width: 100%;
35
padding: 0;
36
margin: 5px 0;
37
line-height: 1.4;
38
white-space: pre;
39
white-space: pre-wrap;
40
white-space: pre-line;
44
white-space: -hp-pre-wrap;
45
word-wrap: break-word;
46
}
47
/* Date */
48
#cff .cff-date{
49
float: left;
50
width: 100%;
51
font-size: 11px;
52
}
53
+ /* Link */
54
+ /*Link text*/
55
+ #cff .text-link{
56
+ float: left;
57
+ clear: none;
58
+ width: 72%;
59
+ margin-left: 3%;
60
+ padding: 5px 0 10px 0;
61
+ }
62
+ #cff .text-link.no-image{
63
+ width: 100%;
64
+ margin-left: 0;
65
+ }
66
/* Event */
67
#cff .details{
68
float: left;
77
#cff .details p{
78
font-size: 14px;
79
}
80
/*****************/
81
/*** POST META ***/
82
/*****************/
83
/* Meta container */
84
+ #cff .meta-wrap{
85
float: left;
86
width: 100%;
87
}
88
/* View on Facebook / View Link text */
89
#cff .cff-viewpost{
90
+ float: right;
91
+ clear: none;
92
+ padding-top: 12px;
93
font-size: 11px;
94
}
95
/* Like box */
96
+ #cff .cff-likebox iframe{
97
+ margin: 0;
98
+ }
99
#cff .cff-likebox{
100
float: left;
101
width: 100%;
102
+ margin-left: -10px;
103
}
104
/* Clear fix */
105
.clear:after {
106
clear: both;
111
}
112
.clear {
113
display: inline-block;
114
display: block;
115
+ }
116
+
117
+ /*********************/
118
+ /*** STYLE OPTIONS ***/
119
+ /*********************/
120
+ #cff.fixed-height{
121
+ overflow: hidden;
122
+ overflow-y: auto;
123
+ padding: 5px 10px;
124
+ -webkit-box-sizing: border-box;
125
+ -moz-box-sizing: border-box;
126
+ box-sizing: border-box;
127
}
custom-facebook-feed-admin.php CHANGED
@@ -1,26 +1,56 @@
1
<?php
2
function cff_menu() {
3
- add_menu_page('Settings', 'Custom Facebook Feed', 'manage_options', 'cff-top', 'cff_settings_page');
4
}
5
add_action('admin_menu', 'cff_menu');
6
7
//Create Settings page
8
function cff_settings_page() {
9
-
10
//Declare variables for fields
11
$hidden_field_name = 'cff_submit_hidden';
12
$access_token = 'cff_access_token';
13
$page_id = 'cff_page_id';
14
$num_show = 'cff_num_show';
15
- $cff_title_length = 'cff_title_length';
16
- $cff_body_length = 'cff_body_length';
17
18
// Read in existing option value from database
19
$access_token_val = get_option( $access_token );
20
$page_id_val = get_option( $page_id );
21
$num_show_val = get_option( $num_show );
22
- $cff_title_length_val = get_option( $cff_title_length );
23
- $cff_body_length_val = get_option( $cff_body_length );
24
25
// See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
26
if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
@@ -28,144 +58,675 @@ function cff_settings_page() {
28
$access_token_val = $_POST[ $access_token ];
29
$page_id_val = $_POST[ $page_id ];
30
$num_show_val = $_POST[ $num_show ];
31
- $cff_title_length_val = $_POST[ $cff_title_length ];
32
- $cff_body_length_val = $_POST[ $cff_body_length ];
33
-
34
// Save the posted value in the database
35
update_option( $access_token, $access_token_val );
36
update_option( $page_id, $page_id_val );
37
update_option( $num_show, $num_show_val );
38
- update_option( $cff_title_length, $cff_title_length_val );
39
- update_option( $cff_body_length, $cff_body_length_val );
40
-
41
// Put an settings updated message on the screen
42
?>
43
<div class="updated"><p><strong><?php _e('Settings saved.', 'custom-facebook-feed' ); ?></strong></p></div>
44
-
45
<?php } ?>
46
47
<div class="wrap">
48
-
49
- <h2><?php _e('Custom Facebook Feed'); ?></h2>
50
-
51
<form name="form1" method="post" action="">
52
-
53
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
54
-
55
-
56
- <h3><?php _e('Feed Settings'); ?></h3>
57
-
58
-
59
<table class="form-table">
60
-
61
<tbody>
62
-
63
<tr valign="top">
64
-
65
<th scope="row"><?php _e('Access Token'); ?></th>
66
-
67
<td>
68
-
69
<input name="cff_access_token" type="text" value="<?php esc_attr_e( $access_token_val ); ?>" size="60" />
70
-
71
<a href="http://smashballoon.com/custom-facebook-feed/access-token/" target="_blank">How to get an Access Token</a>
72
-
73
</td>
74
-
75
</tr>
76
-
77
<tr valign="top">
78
-
79
<th scope="row"><?php _e('Page ID'); ?></th>
80
-
81
<td>
82
-
83
<input name="cff_page_id" type="text" value="<?php esc_attr_e( $page_id_val ); ?>" size="60" />
84
-
85
<a href="http://smashballoon.com/custom-facebook-feed/faq/" target="_blank">What's my Page ID?</a>
86
-
87
</td>
88
-
89
</tr>
90
-
91
<tr valign="top">
92
-
93
<th scope="row"><?php _e('Number of posts to display'); ?></th>
94
-
95
<td>
96
-
97
<input name="cff_num_show" type="text" value="<?php esc_attr_e( $num_show_val ); ?>" size="4" />
98
-
99
</td>
100
-
101
</tr>
102
-
103
</tbody>
104
-
105
</table>
106
107
- <br />
108
- <h3><?php _e('Post Formatting'); ?></h3>
109
110
111
- <table class="form-table">
112
113
- <tbody>
114
115
- <tr valign="top">
116
117
- <th scope="row"><?php _e('Maximum Post Text Length'); ?></th>
118
119
<td>
120
121
- <input name="cff_title_length" type="text" value="<?php esc_attr_e( $cff_title_length_val ); ?>" size="4" /> <span>Characters.</span> <i style="color: #666; font-size: 11px; margin-left: 5px;">(Leave empty to set no maximum length)</i>
122
123
</td>
124
-
125
</tr>
126
127
<tr valign="top">
128
-
129
- <th scope="row"><?php _e('Maximum Link/Event Description Length'); ?></th>
130
-
131
<td>
132
133
- <input name="cff_body_length" type="text" value="<?php esc_attr_e( $cff_body_length_val ); ?>" size="4" /> <span>Characters.</span> <i style="color: #666; font-size: 11px; margin-left: 5px;">(Leave empty to set no maximum length)</i>
134
135
</td>
136
-
137
</tr>
138
-
139
</tbody>
140
-
141
</table>
142
143
- <p style="margin: 25px 0 40px 0;">
144
- <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
145
- &nbsp;&nbsp;<a href="http://smashballoon.com/custom-facebook-feed/troubleshooting" target="_blank"><b>HELP!</b> My feed is not showing up</a>
146
- </p>
147
148
</form>
149
150
<hr />
151
-
152
- <h4>Displaying your Feed</h4>
153
-
154
- <p>Copy and paste this shortcode directly into the page, post or widget where you'd like the feed to show up:</p>
155
-
156
- <input type="text" value="[custom-facebook-feed]" size="23" />
157
-
158
- <p>You can override the settings above directly in the shortcode like so:</p>
159
-
160
- <p>[custom-facebook-feed <b>id=Your_Page_ID show=3 titlelength=100 bodylength=150</b>]</p>
161
<br />
162
<p>Please note that the free version of the plugin only displays text updates. For <b>photos, videos, comments and more</b> please upgrade to the <a href="http://smashballoon.com/custom-facebook-feed/wordpress-plugin/" target="_blank">Pro version</a> of the plugin.</p>
163
164
- <br /><br /><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Plugin Support</a> - Smash Balloon is committed to making this plugin better. Please let us know if you have had any issues when using this plugin so that we can continue to make it better!
165
-
166
- <br /><br /><br />
167
<a href="http://smashballoon.com/custom-facebook-feed/demo" target="_blank"><img src="<?php echo plugins_url( 'img/pro.jpg' , __FILE__ ) ?>" /></a>
168
169
<?php
170
- } //End Settings_Page
171
?>
1
<?php
2
function cff_menu() {
3
+ add_menu_page(
4
+ '',
5
+ 'Facebook Feed',
6
+ 'manage_options',
7
+ 'cff-top',
8
+ 'cff_settings_page'
9
+ );
10
+ add_submenu_page(
11
+ 'cff-top',
12
+ 'Settings',
13
+ 'Settings',
14
+ 'manage_options',
15
+ 'cff-top',
16
+ 'cff_settings_page'
17
+ );
18
}
19
add_action('admin_menu', 'cff_menu');
20
+ //Add styling page
21
+ function cff_styling_menu() {
22
+ add_submenu_page(
23
+ 'cff-top',
24
+ 'Layout & Style',
25
+ 'Layout & Style',
26
+ 'manage_options',
27
+ 'cff-style',
28
+ 'cff_style_page'
29
+ );
30
+ }
31
+ add_action('admin_menu', 'cff_styling_menu');
32
+
33
+
34
+ function cff_register_option() {
35
+ // creates our settings in the options table
36
+ register_setting('cff_license', 'cff_license_key', 'cff_sanitize_license' );
37
+ }
38
+ add_action('admin_init', 'cff_register_option');
39
+
40
+
41
42
//Create Settings page
43
function cff_settings_page() {
44
//Declare variables for fields
45
$hidden_field_name = 'cff_submit_hidden';
46
$access_token = 'cff_access_token';
47
$page_id = 'cff_page_id';
48
$num_show = 'cff_num_show';
49
50
// Read in existing option value from database
51
$access_token_val = get_option( $access_token );
52
$page_id_val = get_option( $page_id );
53
$num_show_val = get_option( $num_show );
54
55
// See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
56
if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
58
$access_token_val = $_POST[ $access_token ];
59
$page_id_val = $_POST[ $page_id ];
60
$num_show_val = $_POST[ $num_show ];
61
// Save the posted value in the database
62
update_option( $access_token, $access_token_val );
63
update_option( $page_id, $page_id_val );
64
update_option( $num_show, $num_show_val );
65
// Put an settings updated message on the screen
66
?>
67
<div class="updated"><p><strong><?php _e('Settings saved.', 'custom-facebook-feed' ); ?></strong></p></div>
68
<?php } ?>
69
+
70
71
<div class="wrap">
72
+ <h2><?php _e('Custom Facebook Feed Settings'); ?></h2>
73
<form name="form1" method="post" action="">
74
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
75
+ <h3><?php _e('Configuration'); ?></h3>
76
<table class="form-table">
77
<tbody>
78
<tr valign="top">
79
<th scope="row"><?php _e('Access Token'); ?></th>
80
<td>
81
<input name="cff_access_token" type="text" value="<?php esc_attr_e( $access_token_val ); ?>" size="60" />
82
<a href="http://smashballoon.com/custom-facebook-feed/access-token/" target="_blank">How to get an Access Token</a>
83
</td>
84
</tr>
85
<tr valign="top">
86
<th scope="row"><?php _e('Page ID'); ?></th>
87
<td>
88
<input name="cff_page_id" type="text" value="<?php esc_attr_e( $page_id_val ); ?>" size="60" />
89
<a href="http://smashballoon.com/custom-facebook-feed/faq/" target="_blank">What's my Page ID?</a>
90
</td>
91
</tr>
92
<tr valign="top">
93
<th scope="row"><?php _e('Number of posts to display'); ?></th>
94
<td>
95
<input name="cff_num_show" type="text" value="<?php esc_attr_e( $num_show_val ); ?>" size="4" />
96
</td>
97
</tr>
98
</tbody>
99
</table>
100
+ <?php submit_button(); ?>
101
+ </form>
102
+ <hr />
103
+ <h4>Displaying your Feed</h4>
104
+ <p>Copy and paste this shortcode directly into the page, post or widget where you'd like the feed to show up:</p>
105
+ <input type="text" value="[custom-facebook-feed]" size="23" />
106
+ <p>You can override the settings above directly in the shortcode like so:</p>
107
+ <p>[custom-facebook-feed <b>id=Your_Page_ID show=3 titlelength=100 bodylength=150</b>]</p>
108
+ <br />
109
+ <hr />
110
+ <br />
111
+ <p>Please note that the free version of the plugin only displays text updates. For <b>photos, videos, comments and more</b> please upgrade to the <a href="http://smashballoon.com/custom-facebook-feed/wordpress-plugin/" target="_blank">Pro version</a> of the plugin.</p>
112
113
+ <p><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Plugin Support</a> - Smash Balloon is committed to making this plugin better. Please let us know if you have had any issues when using this plugin so that we can continue to make it better!</p>
114
+ <br /><br /><br /><br />
115
+ <a href="http://smashballoon.com/custom-facebook-feed/demo" target="_blank"><img src="<?php echo plugins_url( 'img/pro.jpg' , __FILE__ ) ?>" /></a>
116
117
118
+ <?php
119
+ } //End Settings_Page
120
+ //Create Style page
121
+ function cff_style_page() {
122
123
+ //Declare variables for fields
124
+ $style_hidden_field_name = 'cff_style_submit_hidden';
125
+ $defaults = array(
126
+ //Include
127
+ 'cff_show_text' => true,
128
+ 'cff_show_desc' => true,
129
+ 'cff_show_date' => true,
130
+ 'cff_show_event_title' => true,
131
+ 'cff_show_event_details' => true,
132
+ 'cff_show_link' => true,
133
+ 'cff_show_like_box' => true,
134
+ //Typography
135
+ 'cff_title_format' => 'p',
136
+ 'cff_title_size' => 'inherit',
137
+ 'cff_title_weight' => 'inherit',
138
+ 'cff_title_color' => '',
139
+ 'cff_body_size' => 'inherit',
140
+ 'cff_body_weight' => 'inherit',
141
+ 'cff_body_color' => '',
142
+ 'cff_event_title_format' => 'p',
143
+ 'cff_event_title_size' => 'inherit',
144
+ 'cff_event_title_weight' => 'inherit',
145
+ 'cff_event_title_color' => '',
146
+ 'cff_event_details_size' => 'inherit',
147
+ 'cff_event_details_weight' => 'inherit',
148
+ 'cff_event_details_color' => '',
149
+ 'cff_date_size' => 'inherit',
150
+ 'cff_date_weight' => 'inherit',
151
+ 'cff_date_color' => '',
152
+ 'cff_link_size' => 'inherit',
153
+ 'cff_link_weight' => 'inherit',
154
+ 'cff_link_color' => '',
155
+ //Misc
156
+ 'cff_feed_width' => '',
157
+ 'cff_feed_height' => '',
158
+ 'cff_feed_padding' => '',
159
+ 'cff_like_box_position' => 'bottom',
160
+ 'cff_bg_color' => '',
161
+ 'cff_likebox_bg_color' => ''
162
+ );
163
+
164
+ //Save layout options in an array
165
+ add_option( 'cff_style_settings', $options );
166
+ $options = get_option('cff_style_settings');
167
+ $options = wp_parse_args(get_option('cff_style_settings'), $defaults);
168
+ //Set the page variables
169
+
170
+ //Include
171
+ $cff_show_text = $options[ 'cff_show_text' ];
172
+ $cff_show_desc = $options[ 'cff_show_desc' ];
173
+ $cff_show_date = $options[ 'cff_show_date' ];
174
+ $cff_show_event_title = $options[ 'cff_show_event_title' ];
175
+ $cff_show_event_details = $options[ 'cff_show_event_details' ];
176
+ $cff_show_link = $options[ 'cff_show_link' ];
177
+ $cff_show_like_box = $options[ 'cff_show_like_box' ];
178
+ //Typography
179
+ $cff_title_format = $options[ 'cff_title_format' ];
180
+ $cff_title_size = $options[ 'cff_title_size' ];
181
+ $cff_title_weight = $options[ 'cff_title_weight' ];
182
+ $cff_title_color = $options[ 'cff_title_color' ];
183
+ $cff_body_size = $options[ 'cff_body_size' ];
184
+ $cff_body_weight = $options[ 'cff_body_weight' ];
185
+ $cff_body_color = $options[ 'cff_body_color' ];
186
+ $cff_event_title_format = $options[ 'cff_event_title_format' ];
187
+ $cff_event_title_size = $options[ 'cff_event_title_size' ];
188
+ $cff_event_title_weight = $options[ 'cff_event_title_weight' ];
189
+ $cff_event_title_color = $options[ 'cff_event_title_color' ];
190
+ $cff_event_details_size = $options[ 'cff_event_details_size' ];
191
+ $cff_event_details_weight = $options[ 'cff_event_details_weight' ];
192
+ $cff_event_details_color = $options[ 'cff_event_details_color' ];
193
+ $cff_date_size = $options[ 'cff_date_size' ];
194
+ $cff_date_weight = $options[ 'cff_date_weight' ];
195
+ $cff_date_color = $options[ 'cff_date_color' ];
196
+ $cff_link_size = $options[ 'cff_link_size' ];
197
+ $cff_link_weight = $options[ 'cff_link_weight' ];
198
+ $cff_link_color = $options[ 'cff_link_color' ];
199
+ //Misc
200
+ $cff_feed_width = $options[ 'cff_feed_width' ];
201
+ $cff_feed_height = $options[ 'cff_feed_height' ];
202
+ $cff_feed_padding = $options[ 'cff_feed_padding' ];
203
+ $cff_like_box_position = $options[ 'cff_like_box_position' ];
204
+ $cff_open_links = $options[ 'cff_open_links' ];
205
+ $cff_bg_color = $options[ 'cff_bg_color' ];
206
+ $cff_likebox_bg_color = $options[ 'cff_likebox_bg_color' ];
207
+
208
+ // Texts lengths
209
+ $cff_title_length = 'cff_title_length';
210
+ $cff_body_length = 'cff_body_length';
211
212
+ // Read in existing option value from database
213
+ $cff_title_length_val = get_option( $cff_title_length );
214
+ $cff_body_length_val = get_option( $cff_body_length );
215
216
+ // See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
217
+ if( isset($_POST[ $style_hidden_field_name ]) && $_POST[ $style_hidden_field_name ] == 'Y' ) {
218
+
219
+ // Read their posted value
220
+ $cff_title_length_val = $_POST[ $cff_title_length ];
221
+ $cff_body_length_val = $_POST[ $cff_body_length ];
222
+ // Save the posted value in the database
223
+ update_option( $cff_title_length, $cff_title_length_val );
224
+ update_option( $cff_body_length, $cff_body_length_val );
225
+
226
+ //Update the page variable
227
+ //Include
228
+ $cff_show_text = $_POST[ 'cff_show_text' ];
229
+ $cff_show_desc = $_POST[ 'cff_show_desc' ];
230
+ $cff_show_date = $_POST[ 'cff_show_date' ];
231
+ $cff_show_event_title = $_POST[ 'cff_show_event_title' ];
232
+ $cff_show_event_details = $_POST[ 'cff_show_event_details' ];
233
+ $cff_show_link = $_POST[ 'cff_show_link' ];
234
+ $cff_show_like_box = $_POST[ 'cff_show_like_box' ];
235
+ //Typography
236
+ $cff_title_format = $_POST[ 'cff_title_format' ];
237
+ $cff_title_size = $_POST[ 'cff_title_size' ];
238
+ $cff_title_weight = $_POST[ 'cff_title_weight' ];
239
+ $cff_title_color = $_POST[ 'cff_title_color' ];
240
+ $cff_body_size = $_POST[ 'cff_body_size' ];
241
+ $cff_body_weight = $_POST[ 'cff_body_weight' ];
242
+ $cff_body_color = $_POST[ 'cff_body_color' ];
243
+ $cff_event_title_format = $_POST[ 'cff_event_title_format' ];
244
+ $cff_event_title_size = $_POST[ 'cff_event_title_size' ];
245
+ $cff_event_title_weight = $_POST[ 'cff_event_title_weight' ];
246
+ $cff_event_title_color = $_POST[ 'cff_event_title_color' ];
247
+ $cff_event_details_size = $_POST[ 'cff_event_details_size' ];
248
+ $cff_event_details_weight = $_POST[ 'cff_event_details_weight' ];
249
+ $cff_event_details_color = $_POST[ 'cff_event_details_color' ];
250
+ $cff_date_size = $_POST[ 'cff_date_size' ];
251
+ $cff_date_weight = $_POST[ 'cff_date_weight' ];
252
+ $cff_date_color = $_POST[ 'cff_date_color' ];
253
+ $cff_link_size = $_POST[ 'cff_link_size' ];
254
+ $cff_link_weight = $_POST[ 'cff_link_weight' ];
255
+ $cff_link_color = $_POST[ 'cff_link_color' ];
256
+ //Misc
257
+ $cff_feed_width = $_POST[ 'cff_feed_width' ];
258
+ $cff_feed_height = $_POST[ 'cff_feed_height' ];
259
+ $cff_feed_padding = $_POST[ 'cff_feed_padding' ];
260
+ $cff_like_box_position = $_POST[ 'cff_like_box_position' ];
261
+ $cff_open_links = $_POST[ 'cff_open_links' ];
262
+ $cff_bg_color = $_POST[ 'cff_bg_color' ];
263
+ $cff_likebox_bg_color = $_POST[ 'cff_likebox_bg_color' ];
264
+
265
+ //Update the options in the array in the database
266
+ //Include
267
+ $options[ 'cff_show_text' ] = $cff_show_text;
268
+ $options[ 'cff_show_desc' ] = $cff_show_desc;
269
+ $options[ 'cff_show_date' ] = $cff_show_date;
270
+ $options[ 'cff_show_event_title' ] = $cff_show_event_title;
271
+ $options[ 'cff_show_event_details' ] = $cff_show_event_details;
272
+ $options[ 'cff_show_link' ] = $cff_show_link;
273
+ $options[ 'cff_show_like_box' ] = $cff_show_like_box;
274
+ //Typography
275
+ $options[ 'cff_title_format' ] = $cff_title_format;
276
+ $options[ 'cff_title_size' ] = $cff_title_size;
277
+ $options[ 'cff_title_weight' ] = $cff_title_weight;
278
+ $options[ 'cff_title_color' ] = $cff_title_color;
279
+ $options[ 'cff_body_size' ] = $cff_body_size;
280
+ $options[ 'cff_body_weight' ] = $cff_body_weight;
281
+ $options[ 'cff_body_color' ] = $cff_body_color;
282
+ $options[ 'cff_event_title_format' ] = $cff_event_title_format;
283
+ $options[ 'cff_event_title_size' ] = $cff_event_title_size;
284
+ $options[ 'cff_event_title_weight' ] = $cff_event_title_weight;
285
+ $options[ 'cff_event_title_color' ] = $cff_event_title_color;
286
+ $options[ 'cff_event_details_size' ] = $cff_event_details_size;
287
+ $options[ 'cff_event_details_weight' ] = $cff_event_details_weight;
288
+ $options[ 'cff_event_details_color' ] = $cff_event_details_color;
289
+ $options[ 'cff_date_size' ] = $cff_date_size;
290
+ $options[ 'cff_date_weight' ] = $cff_date_weight;
291
+ $options[ 'cff_date_color' ] = $cff_date_color;
292
+ $options[ 'cff_link_size' ] = $cff_link_size;
293
+ $options[ 'cff_link_weight' ] = $cff_link_weight;
294
+ $options[ 'cff_link_color' ] = $cff_link_color;
295
+ //Misc
296
+ $options[ 'cff_feed_width' ] = $cff_feed_width;
297
+ $options[ 'cff_feed_height' ] = $cff_feed_height;
298
+ $options[ 'cff_feed_padding' ] = $cff_feed_padding;
299
+ $options[ 'cff_like_box_position' ] = $cff_like_box_position;
300
+ $options[ 'cff_open_links' ] = $cff_open_links;
301
+ $options[ 'cff_bg_color' ] = $cff_bg_color;
302
+ $options[ 'cff_likebox_bg_color' ] = $cff_likebox_bg_color;
303
+
304
+ //Update the array
305
+ update_option( 'cff_style_settings', $options );
306
+ // Put an settings updated message on the screen
307
+ ?>
308
+ <div class="updated"><p><strong><?php _e('Settings saved.', 'custom-facebook-feed' ); ?></strong></p></div>
309
+ <?php } ?>
310
+
311
312
+ <div class="wrap">
313
+ <h2><?php _e('Custom Facebook Feed - Layout and Style'); ?></h2>
314
+ <form name="form1" method="post" action="">
315
+ <input type="hidden" name="<?php echo $style_hidden_field_name; ?>" value="Y">
316
+ <br />
317
+ <hr />
318
+ <table class="form-table">
319
+ <tbody>
320
+ <h3><?php _e('General'); ?></h3>
321
+ <tr valign="top">
322
+ <th scope="row"><?php _e('Feed Width'); ?></th>
323
+ <td>
324
+ <input name="cff_feed_width" type="text" value="<?php esc_attr_e( $cff_feed_width ); ?>" size="6" />
325
+ <span>Eg. 500px, 50%, 10em. <i style="color: #666; font-size: 11px; margin-left: 5px;">Default is 100%</i></span>
326
+ </td>
327
+ </tr>
328
+ <tr valign="top">
329
+ <th scope="row"><?php _e('Feed Height'); ?></th>
330
<td>
331
+ <input name="cff_feed_height" type="text" value="<?php esc_attr_e( $cff_feed_height ); ?>" size="6" />
332
+ <span>Eg. 500px, 50em. <i style="color: #666; font-size: 11px; margin-left: 5px;">Leave empty to set no maximum height. If the feed exceeds this height then a scroll bar will be used.</i></span>
333
+ </td>
334
+ </tr>
335
+ <th scope="row"><?php _e('Feed Padding'); ?></th>
336
+ <td>
337
+ <input name="cff_feed_padding" type="text" value="<?php esc_attr_e( $cff_feed_padding ); ?>" size="6" />
338
+ <span>Eg. 20px, 5%. <i style="color: #666; font-size: 11px; margin-left: 5px;">This is the amount of padding/spacing that goes around the feed. This is particularly useful if you intend to set a background color on the feed.</i></span>
339
+ </td>
340
+ </tr>
341
+ <tr valign="top">
342
+ <th scope="row"><?php _e('Feed Background Color'); ?></th>
343
+ <td>
344
+ <label for="cff_bg_color">#</label>
345
+ <input name="cff_bg_color" type="text" value="<?php esc_attr_e( $cff_bg_color ); ?>" size="10" />
346
+ <span>Eg. ED9A00 <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a></span>
347
+ </td>
348
+ </tr>
349
+ </tbody>
350
+ </table>
351
+ <?php submit_button(); ?>
352
+ <hr />
353
+ <h3><?php _e('Post Layout'); ?></h3>
354
+ <table class="form-table">
355
+ <tbody>
356
+ <tr>
357
+ <td><p>Choose a post layout:</p></td>
358
359
+ <td>
360
+ <select name="cff_preset_layout" disabled>
361
+ <option>Thumbnail</option>
362
+ <option>Half-width</option>
363
+ <option>Full-width</option>
364
+ </select>
365
366
+ <i style="color: #666; font-size: 11px; margin-left: 5px;"><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Upgrade to Pro</a></i>
367
</td>
368
</tr>
369
370
<tr valign="top">
371
+ <th scope="row"><?php _e('Include the following in posts (when applicable):'); ?></th>
372
<td>
373
+ <div>
374
+ <input name="cff_show_text" type="checkbox" id="cff_show_text" <?php if($cff_show_text == true) echo "checked"; ?> />
375
+ <label for="cff_show_text">Post text</label>
376
+ </div>
377
+ <div>
378
+ <input type="checkbox" name="cff_show_desc" id="cff_show_desc" <?php if($cff_show_desc == true) echo 'checked="checked"' ?> />
379
+ <label for="cff_show_desc">Video/link description</label>
380
+ </div>
381
+ <div>
382
+ <input type="checkbox" name="cff_show_date" id="cff_show_date" <?php if($cff_show_date == true) echo 'checked="checked"' ?> />
383
+ <label for="cff_show_date">Date</label>
384
+ </div>
385
+ <div>
386
+ <input type="checkbox" disabled />
387
+ <label style="color: #999;">Photos/videos</label><i style="color: #666; font-size: 11px; margin-left: 5px;"><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Upgrade to Pro</a></i>
388
+ </div>
389
+
390
+ <div>
391
+ <input type="checkbox" name="cff_show_event_title" id="cff_show_event_title" <?php if($cff_show_event_title == true) echo 'checked="checked"' ?> />
392
+ <label for="cff_show_event_title">Event title</label>
393
+ </div>
394
+ <div>
395
+ <input type="checkbox" name="cff_show_event_details" id="cff_show_event_details" <?php if($cff_show_event_details == true) echo 'checked="checked"' ?> />
396
+ <label for="cff_show_event_details">Event details</label>
397
+ </div>
398
+ <div>
399
+ <input type="checkbox" disabled />
400
+ <label style="color: #999;">Like/shares/comments</label><i style="color: #666; font-size: 11px; margin-left: 5px;"><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Upgrade to Pro</a></i>
401
+ </div>
402
+ <div>
403
+ <input type="checkbox" name="cff_show_link" id="cff_show_link" <?php if($cff_show_link == true) echo 'checked="checked"' ?> />
404
+ <label for="cff_show_link">View on Facebook/View Link</label>
405
+ </div>
406
+ </td>
407
+ </tr>
408
+ </tbody>
409
+ </table>
410
+ <?php submit_button(); ?>
411
+ <hr />
412
413
414
+ <h3><?php _e('Typography'); ?></h3>
415
+ <table class="form-table">
416
+ <tbody>
417
+ <tr valign="top">
418
+ <th scope="row"><?php _e('Post Text'); ?></th>
419
+
420
+ <!-- <p>What does inherit mean?</p> -->
421
+ <td>
422
+ <label for="cff_title_format">Format</label>
423
+ <select name="cff_title_format">
424
+ <option value="p" <?php if($cff_title_format == "p") echo 'selected="selected"' ?> >Paragraph</option>
425
+ <option value="h3" <?php if($cff_title_format == "h3") echo 'selected="selected"' ?> >Heading 3</option>
426
+ <option value="h4" <?php if($cff_title_format == "h4") echo 'selected="selected"' ?> >Heading 4</option>
427
+ <option value="h5" <?php if($cff_title_format == "h5") echo 'selected="selected"' ?> >Heading 5</option>
428
+ <option value="h6" <?php if($cff_title_format == "h6") echo 'selected="selected"' ?> >Heading 6</option>
429
+ </select>
430
+ &nbsp;&nbsp;
431
+ <label for="cff_title_size">Font Size</label>
432
+ <select name="cff_title_size">
433
+ <option value="inherit" <?php if($cff_title_size == "inherit") echo 'selected="selected"' ?> >Inherit</option>
434
+ <option value="10" <?php if($cff_title_size == "10") echo 'selected="selected"' ?> >10px</option>
435
+ <option value="11" <?php if($cff_title_size == "11") echo 'selected="selected"' ?> >11px</option>
436
+ <option value="12" <?php if($cff_title_size == "12") echo 'selected="selected"' ?> >12px</option>
437
+ <option value="14" <?php if($cff_title_size == "14") echo 'selected="selected"' ?> >14px</option>
438
+ <option value="16" <?php if($cff_title_size == "16") echo 'selected="selected"' ?> >16px</option>
439
+ <option value="18" <?php if($cff_title_size == "18") echo 'selected="selected"' ?> >18px</option>
440
+ <option value="20" <?php if($cff_title_size == "20") echo 'selected="selected"' ?> >20px</option>
441
+ <option value="24" <?php if($cff_title_size == "24") echo 'selected="selected"' ?> >24px</option>
442
+ <option value="28" <?php if($cff_title_size == "28") echo 'selected="selected"' ?> >28px</option>
443
+ <option value="32" <?php if($cff_title_size == "32") echo 'selected="selected"' ?> >32px</option>
444
+ <option value="36" <?php if($cff_title_size == "36") echo 'selected="selected"' ?> >36px</option>
445
+ <option value="42" <?php if($cff_title_size == "42") echo 'selected="selected"' ?> >42px</option>
446
+ <option value="48" <?php if($cff_title_size == "48") echo 'selected="selected"' ?> >48px</option>
447
+ <option value="60" <?php if($cff_title_size == "54") echo 'selected="selected"' ?> >54px</option>
448
+ <option value="60" <?php if($cff_title_size == "60") echo 'selected="selected"' ?> >60px</option>
449
+ </select>
450
+ &nbsp;&nbsp;
451
+ <label for="cff_title_weight">Font Weight</label>
452
+ <select name="cff_title_weight">
453
+ <option value="inherit" <?php if($cff_title_weight == "inherit") echo 'selected="selected"' ?> >Inherit</option>
454
+ <option value="normal" <?php if($cff_title_weight == "normal") echo 'selected="selected"' ?> >Normal</option>
455
+ <option value="bold" <?php if($cff_title_weight == "bold") echo 'selected="selected"' ?> >Bold</option>
456
+ </select>
457
+ &nbsp;&nbsp;
458
+ <label for="cff_title_color">Font Color&nbsp;&nbsp;#</label>
459
+ <input name="cff_title_color" type="text" value="<?php esc_attr_e( $cff_title_color ); ?>" size="10" />
460
+ <span>Eg. ED9A00 <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a></span>
461
</td>
462
</tr>
463
+ <tr valign="top">
464
+ <th scope="row"><?php _e('Link Description'); ?></th>
465
+
466
+ <td>
467
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
468
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
469
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
470
+ <label for="cff_body_size">Font Size</label>
471
+ <select name="cff_body_size">
472
+ <option value="inherit" <?php if($cff_body_size == "inherit") echo 'selected="selected"' ?> >Inherit</option>
473
+ <option value="10" <?php if($cff_body_size == "10") echo 'selected="selected"' ?> >10px</option>
474
+ <option value="11" <?php if($cff_body_size == "11") echo 'selected="selected"' ?> >11px</option>
475
+ <option value="12" <?php if($cff_body_size == "12") echo 'selected="selected"' ?> >12px</option>
476
+ <option value="14" <?php if($cff_body_size == "14") echo 'selected="selected"' ?> >14px</option>
477
+ <option value="16" <?php if($cff_body_size == "16") echo 'selected="selected"' ?> >16px</option>
478
+ <option value="18" <?php if($cff_body_size == "18") echo 'selected="selected"' ?> >18px</option>
479
+ <option value="20" <?php if($cff_body_size == "20") echo 'selected="selected"' ?> >20px</option>
480
+ <option value="24" <?php if($cff_body_size == "24") echo 'selected="selected"' ?> >24px</option>
481
+ <option value="28" <?php if($cff_body_size == "28") echo 'selected="selected"' ?> >28px</option>
482
+ <option value="32" <?php if($cff_body_size == "32") echo 'selected="selected"' ?> >32px</option>
483
+ <option value="36" <?php if($cff_body_size == "36") echo 'selected="selected"' ?> >36px</option>
484
+ <option value="42" <?php if($cff_body_size == "42") echo 'selected="selected"' ?> >42px</option>
485
+ <option value="48" <?php if($cff_body_size == "48") echo 'selected="selected"' ?> >48px</option>
486
+ <option value="60" <?php if($cff_body_size == "54") echo 'selected="selected"' ?> >54px</option>
487
+ <option value="60" <?php if($cff_body_size == "60") echo 'selected="selected"' ?> >60px</option>
488
+ </select>
489
+ &nbsp;&nbsp;
490
+ <label for="cff_body_weight">Font Weight</label>
491
+ <select name="cff_body_weight">
492
+ <option value="inherit" <?php if($cff_body_weight == "inherit") echo 'selected="selected"' ?> >Inherit</option>
493
+ <option value="normal" <?php if($cff_body_weight == "normal") echo 'selected="selected"' ?> >Normal</option>
494
+ <option value="bold" <?php if($cff_body_weight == "bold") echo 'selected="selected"' ?> >Bold</option>
495
+ </select>
496
+ &nbsp;&nbsp;
497
+ <label for="cff_body_color">Font Color&nbsp;&nbsp;#</label>
498
+ <input name="cff_body_color" type="text" value="<?php esc_attr_e( $cff_body_color ); ?>" size="10" />
499
+ <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>
500
+ </td>
501
+ </tr>
502
+ <tr valign="top">
503
+ <th scope="row"><?php _e('Event Title'); ?></th>
504
+
505
+ <td>
506
+ <label for="cff_event_title_format">Format</label>
507
+ <select name="cff_event_title_format">
508
+ <option value="p" <?php if($cff_event_title_format == "p") echo 'selected="selected"' ?> >Paragraph</option>
509
+ <option value="h3" <?php if($cff_event_title_format == "h3") echo 'selected="selected"' ?> >Heading 3</option>
510
+ <option value="h4" <?php if($cff_event_title_format == "h4") echo 'selected="selected"' ?> >Heading 4</option>
511
+ <option value="h5" <?php if($cff_event_title_format == "h5") echo 'selected="selected"' ?> >Heading 5</option>
512
+ <option value="h6" <?php if($cff_event_title_format == "h6") echo 'selected="selected"' ?> >Heading 6</option>
513
+ </select>
514
+ &nbsp;&nbsp;
515
+ <label for="cff_event_title_size">Font Size</label>
516
+ <select name="cff_event_title_size">
517
+ <option value="inherit" <?php if($cff_event_title_size == "inherit") echo 'selected="selected"' ?> >Inherit</option>
518
+ <option value="10" <?php if($cff_event_title_size == "10") echo 'selected="selected"' ?> >10px</option>
519
+ <option value="11" <?php if($cff_event_title_size == "11") echo 'selected="selected"' ?> >11px</option>
520
+ <option value="12" <?php if($cff_event_title_size == "12") echo 'selected="selected"' ?> >12px</option>
521
+ <option value="14" <?php if($cff_event_title_size == "14") echo 'selected="selected"' ?> >14px</option>
522
+ <option value="16" <?php if($cff_event_title_size == "16") echo 'selected="selected"' ?> >16px</option>
523
+ <option value="18" <?php if($cff_event_title_size == "18") echo 'selected="selected"' ?> >18px</option>
524
+ <option value="20" <?php if($cff_event_title_size == "20") echo 'selected="selected"' ?> >20px</option>
525
+ <option value="24" <?php if($cff_event_title_size == "24") echo 'selected="selected"' ?> >24px</option>
526
+ <option value="28" <?php if($cff_event_title_size == "28") echo 'selected="selected"' ?> >28px</option>
527
+ <option value="32" <?php if($cff_event_title_size == "32") echo 'selected="selected"' ?> >32px</option>
528
+ <option value="36" <?php if($cff_event_title_size == "36") echo 'selected="selected"' ?> >36px</option>
529
+ <option value="42" <?php if($cff_event_title_size == "42") echo 'selected="selected"' ?> >42px</option>
530
+ <option value="48" <?php if($cff_event_title_size == "48") echo 'selected="selected"' ?> >48px</option>
531
+ <option value="60" <?php if($cff_event_title_size == "54") echo 'selected="selected"' ?> >54px</option>
532
+ <option value="60" <?php if($cff_event_title_size == "60") echo 'selected="selected"' ?> >60px</option>
533
+ </select>
534
+ &nbsp;&nbsp;
535
+ <label for="cff_event_title_weight">Font Weight</label>
536
+ <select name="cff_event_title_weight">
537
+ <option value="inherit" <?php if($cff_event_title_weight == "inherit") echo 'selected="selected"' ?> >Inherit</option>
538
+ <option value="normal" <?php if($cff_event_title_weight == "normal") echo 'selected="selected"' ?> >Normal</option>
539
+ <option value="bold" <?php if($cff_event_title_weight == "bold") echo 'selected="selected"' ?> >Bold</option>
540
+ </select>
541
+ &nbsp;&nbsp;
542
+ <label for="cff_event_title_color">Font Color&nbsp;&nbsp;#</label>
543
+ <input name="cff_event_title_color" type="text" value="<?php esc_attr_e( $cff_event_title_color ); ?>" size="10" />
544
+ <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>
545
+ </td>
546
+ </tr>
547
+ <tr valign="top">
548
+ <th scope="row"><?php _e('Event Details'); ?></th>
549
+
550
+ <td>
551
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
552
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
553
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
554
+ <label for="cff_event_details_size">Font Size</label>
555
+ <select name="cff_event_details_size">
556
+ <option value="inherit" <?php if($cff_event_details_size == "inherit") echo 'selected="selected"' ?> >Inherit</option>
557
+ <option value="10" <?php if($cff_event_details_size == "10") echo 'selected="selected"' ?> >10px</option>
558
+ <option value="11" <?php if($cff_event_details_size == "11") echo 'selected="selected"' ?> >11px</option>
559
+ <option value="12" <?php if($cff_event_details_size == "12") echo 'selected="selected"' ?> >12px</option>
560
+ <option value="14" <?php if($cff_event_details_size == "14") echo 'selected="selected"' ?> >14px</option>
561
+ <option value="16" <?php if($cff_event_details_size == "16") echo 'selected="selected"' ?> >16px</option>
562
+ <option value="18" <?php if($cff_event_details_size == "18") echo 'selected="selected"' ?> >18px</option>
563
+ <option value="20" <?php if($cff_event_details_size == "20") echo 'selected="selected"' ?> >20px</option>
564
+ <option value="24" <?php if($cff_event_details_size == "24") echo 'selected="selected"' ?> >24px</option>
565
+ <option value="28" <?php if($cff_event_details_size == "28") echo 'selected="selected"' ?> >28px</option>
566
+ <option value="32" <?php if($cff_event_details_size == "32") echo 'selected="selected"' ?> >32px</option>
567
+ <option value="36" <?php if($cff_event_details_size == "36") echo 'selected="selected"' ?> >36px</option>
568
+ <option value="42" <?php if($cff_event_details_size == "42") echo 'selected="selected"' ?> >42px</option>
569
+ <option value="48" <?php if($cff_event_details_size == "48") echo 'selected="selected"' ?> >48px</option>
570
+ <option value="60" <?php if($cff_event_details_size == "54") echo 'selected="selected"' ?> >54px</option>
571
+ <option value="60" <?php if($cff_event_details_size == "60") echo 'selected="selected"' ?> >60px</option>
572
+ </select>
573
+ &nbsp;&nbsp;
574
+ <label for="cff_event_details_weight">Font Weight</label>
575
+ <select name="cff_event_details_weight">
576
+ <option value="inherit" <?php if($cff_event_details_weight == "inherit") echo 'selected="selected"' ?> >Inherit</option>
577
+ <option value="normal" <?php if($cff_event_details_weight == "normal") echo 'selected="selected"' ?> >Normal</option>
578
+ <option value="bold" <?php if($cff_event_details_weight == "bold") echo 'selected="selected"' ?> >Bold</option>
579
+ </select>
580
+ &nbsp;&nbsp;
581
+ <label for="cff_event_details_color">Font Color&nbsp;&nbsp;#</label>
582
+ <input name="cff_event_details_color" type="text" value="<?php esc_attr_e( $cff_event_details_color ); ?>" size="10" />
583
+ <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>
584
+ </td>
585
+ </tr>
586
+ <tr valign="top">
587
+ <th scope="row"><?php _e('Date'); ?></th>
588
+
589
+ <td>
590
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
591
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
592
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
593
+ <label for="cff_date_size">Font Size</label>
594
+ <select name="cff_date_size">
595
+ <option value="inherit" <?php if($cff_date_size == "inherit") echo 'selected="selected"' ?> >Inherit</option>
596
+ <option value="10" <?php if($cff_date_size == "10") echo 'selected="selected"' ?> >10px</option>
597
+ <option value="11" <?php if($cff_date_size == "11") echo 'selected="selected"' ?> >11px</option>
598
+ <option value="12" <?php if($cff_date_size == "12") echo 'selected="selected"' ?> >12px</option>
599
+ <option value="14" <?php if($cff_date_size == "14") echo 'selected="selected"' ?> >14px</option>
600
+ <option value="16" <?php if($cff_date_size == "16") echo 'selected="selected"' ?> >16px</option>
601
+ <option value="18" <?php if($cff_date_size == "18") echo 'selected="selected"' ?> >18px</option>
602
+ <option value="20" <?php if($cff_date_size == "20") echo 'selected="selected"' ?> >20px</option>
603
+ <option value="24" <?php if($cff_date_size == "24") echo 'selected="selected"' ?> >24px</option>
604
+ <option value="28" <?php if($cff_date_size == "28") echo 'selected="selected"' ?> >28px</option>
605
+ <option value="32" <?php if($cff_date_size == "32") echo 'selected="selected"' ?> >32px</option>
606
+ <option value="36" <?php if($cff_date_size == "36") echo 'selected="selected"' ?> >36px</option>
607
+ <option value="42" <?php if($cff_date_size == "42") echo 'selected="selected"' ?> >42px</option>
608
+ <option value="48" <?php if($cff_date_size == "48") echo 'selected="selected"' ?> >48px</option>
609
+ <option value="60" <?php if($cff_date_size == "54") echo 'selected="selected"' ?> >54px</option>
610
+ <option value="60" <?php if($cff_date_size == "60") echo 'selected="selected"' ?> >60px</option>
611
+ </select>
612
+ &nbsp;&nbsp;
613
+ <label for="cff_date_weight">Font Weight</label>
614
+ <select name="cff_date_weight">
615
+ <option value="inherit" <?php if($cff_date_weight == "inherit") echo 'selected="selected"' ?> >Inherit</option>
616
+ <option value="normal" <?php if($cff_date_weight == "normal") echo 'selected="selected"' ?> >Normal</option>
617
+ <option value="bold" <?php if($cff_date_weight == "bold") echo 'selected="selected"' ?> >Bold</option>
618
+ </select>
619
+ &nbsp;&nbsp;
620
+ <label for="cff_date_color">Font Color&nbsp;&nbsp;#</label>
621
+ <input name="cff_date_color" type="text" value="<?php esc_attr_e( $cff_date_color ); ?>" size="10" />
622
+ <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>
623
+ </td>
624
+ </tr>
625
+ <tr valign="top">
626
+ <th scope="row"><?php _e('Link to Facebook'); ?></th>
627
+
628
+ <!-- <p>What does inherit mean?</p> -->
629
+
630
+ <td>
631
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
632
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
633
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
634
+ <label for="cff_link_size">Font Size</label>
635
+ <select name="cff_link_size">
636
+ <option value="inherit" <?php if($cff_link_size == "inherit") echo 'selected="selected"' ?> >Inherit</option>
637
+ <option value="10" <?php if($cff_link_size == "10") echo 'selected="selected"' ?> >10px</option>
638
+ <option value="11" <?php if($cff_link_size == "11") echo 'selected="selected"' ?> >11px</option>
639
+ <option value="12" <?php if($cff_link_size == "12") echo 'selected="selected"' ?> >12px</option>
640
+ <option value="14" <?php if($cff_link_size == "14") echo 'selected="selected"' ?> >14px</option>
641
+ <option value="16" <?php if($cff_link_size == "16") echo 'selected="selected"' ?> >16px</option>
642
+ <option value="18" <?php if($cff_link_size == "18") echo 'selected="selected"' ?> >18px</option>
643
+ <option value="20" <?php if($cff_link_size == "20") echo 'selected="selected"' ?> >20px</option>
644
+ <option value="24" <?php if($cff_link_size == "24") echo 'selected="selected"' ?> >24px</option>
645
+ <option value="28" <?php if($cff_link_size == "28") echo 'selected="selected"' ?> >28px</option>
646
+ <option value="32" <?php if($cff_link_size == "32") echo 'selected="selected"' ?> >32px</option>
647
+ <option value="36" <?php if($cff_link_size == "36") echo 'selected="selected"' ?> >36px</option>
648
+ <option value="42" <?php if($cff_link_size == "42") echo 'selected="selected"' ?> >42px</option>
649
+ <option value="48" <?php if($cff_link_size == "48") echo 'selected="selected"' ?> >48px</option>
650
+ <option value="60" <?php if($cff_link_size == "54") echo 'selected="selected"' ?> >54px</option>
651
+ <option value="60" <?php if($cff_link_size == "60") echo 'selected="selected"' ?> >60px</option>
652
+ </select>
653
+ &nbsp;&nbsp;
654
+ <label for="cff_link_weight">Font Weight</label>
655
+ <select name="cff_link_weight">
656
+ <option value="inherit" <?php if($cff_link_weight == "inherit") echo 'selected="selected"' ?> >Inherit</option>
657
+ <option value="normal" <?php if($cff_link_weight == "normal") echo 'selected="selected"' ?> >Normal</option>
658
+ <option value="bold" <?php if($cff_link_weight == "bold") echo 'selected="selected"' ?> >Bold</option>
659
+ </select>
660
+ &nbsp;&nbsp;
661
+ <label for="cff_link_color">Font Color&nbsp;&nbsp;#</label>
662
+ <input name="cff_link_color" type="text" value="<?php esc_attr_e( $cff_link_color ); ?>" size="10" />
663
+ <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>
664
+ </td>
665
+ </tr>
666
+ <tr><i style="color: #666; font-size: 11px; margin-left: 5px;">'Inherit' means that the text will inherit the styles from your theme.</i></tr>
667
</tbody>
668
</table>
669
+ <br />
670
+ <hr />
671
+
672
673
+ <h3><?php _e('Likes, Shares and Comments'); ?></h3>
674
+ <p style="color: #666; font-size: 11px; font-style: italic; margin-left: 5px;"><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Upgrade to Pro</a></p>
675
676
+ <br />
677
+ <hr />
678
+ <h3><?php _e('Misc'); ?></h3>
679
+ <table class="form-table">
680
+ <tbody>
681
+ <tr valign="top">
682
+ <th scope="row"><?php _e('Maximum Post Text Length'); ?></th>
683
+ <td>
684
+ <input name="cff_title_length" type="text" value="<?php esc_attr_e( $cff_title_length_val ); ?>" size="4" /> <span>Characters.</span> <i style="color: #666; font-size: 11px; margin-left: 5px;">(Leave empty to set no maximum length)</i>
685
+ </td>
686
+ </tr>
687
+ <tr valign="top">
688
+ <th scope="row"><?php _e('Maximum Link/Event Description Length'); ?></th>
689
+ <td>
690
+ <input name="cff_body_length" type="text" value="<?php esc_attr_e( $cff_body_length_val ); ?>" size="4" /> <span>Characters.</span> <i style="color: #666; font-size: 11px; margin-left: 5px;">(Leave empty to set no maximum length)</i>
691
+ </td>
692
+ </tr>
693
+ <tr valign="top">
694
+ <th scope="row"><?php _e('Show the Like Box'); ?></th>
695
+ <td>
696
+ <input type="checkbox" name="cff_show_like_box" id="cff_show_like_box" <?php if($cff_show_like_box == true) echo 'checked="checked"' ?> />
697
+ </td>
698
+ </tr>
699
+ <tr valign="top">
700
+ <th scope="row"><?php _e('Like Box Position'); ?></th>
701
+ <td>
702
+ <select name="cff_like_box_position">
703
+ <option value="bottom" <?php if($cff_like_box_position == "bottom") echo 'selected="selected"' ?> >Bottom</option>
704
+ <option value="top" <?php if($cff_like_box_position == "top") echo 'selected="selected"' ?> >Top</option>
705
+ </select>
706
+ </td>
707
+ </tr>
708
+ <tr valign="top">
709
+ <th scope="row"><?php _e('Like Box Background Color'); ?></th>
710
+ <td>
711
+ <label for="cff_likebox_bg_color">#</label>
712
+ <input name="cff_likebox_bg_color" type="text" value="<?php esc_attr_e( $cff_likebox_bg_color ); ?>" size="10" />
713
+ <a href="http://www.colorpicker.com/" target="_blank">Color Picker</a>
714
+ </td>
715
+ </tr>
716
+ </tbody>
717
+ </table>
718
+ <?php submit_button(); ?>
719
</form>
720
721
<hr />
722
<br />
723
<p>Please note that the free version of the plugin only displays text updates. For <b>photos, videos, comments and more</b> please upgrade to the <a href="http://smashballoon.com/custom-facebook-feed/wordpress-plugin/" target="_blank">Pro version</a> of the plugin.</p>
724
725
+ <p><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Plugin Support</a> - Smash Balloon is committed to making this plugin better. Please let us know if you have had any issues when using this plugin so that we can continue to make it better!</p>
726
+ <br /><br /><br /><br />
727
<a href="http://smashballoon.com/custom-facebook-feed/demo" target="_blank"><img src="<?php echo plugins_url( 'img/pro.jpg' , __FILE__ ) ?>" /></a>
728
729
+
730
<?php
731
+ } //End Style_Page
732
?>
custom-facebook-feed.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Custom Facebook Feed
4
Plugin URI: http://smashballoon.com/custom-facebook-feed
5
Description: Add a completely customizable Facebook feed to your WordPress site
6
- Version: 1.3.7
7
Author: Smash Balloon
8
Author URI: http://smashballoon.com/
9
License: GPLv2 or later
@@ -11,17 +11,14 @@ License: GPLv2 or later
11
12
/*
13
Copyright 2013 Smash Balloon (email : hey@smashballoon.com)
14
-
15
This program is free software; you can redistribute it and/or modify
16
it under the terms of the GNU General Public License as published by
17
the Free Software Foundation; either version 2 of the License, or
18
(at your option) any later version.
19
-
20
This program is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
GNU General Public License for more details.
24
-
25
You should have received a copy of the GNU General Public License
26
along with this program; if not, write to the Free Software
27
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -33,14 +30,137 @@ include dirname( __FILE__ ) .'/custom-facebook-feed-admin.php';
33
// Add shortcodes
34
add_shortcode('custom-facebook-feed', 'display_cff');
35
function display_cff($atts) {
36
//Pass in shortcode attrbutes
37
$atts = shortcode_atts(
38
- array(
39
- 'id' => get_option('cff_page_id'),
40
- 'show' => get_option('cff_num_show'),
41
- 'titlelength' => get_option('cff_title_length'),
42
- 'bodylength' => get_option('cff_body_length')
43
- ), $atts);
44
45
//Assign the Access Token and Page ID variables
46
$access_token = get_option('cff_access_token');
@@ -49,193 +169,249 @@ function display_cff($atts) {
49
//Get show posts attribute. If not set then default to 10.
50
$show_posts = $atts['show'];
51
if ( $show_posts == 0 || $show_posts == undefined ) $show_posts = 10;
52
-
53
//Check whether the Access Token is present and valid
54
if ($access_token == '') {
55
- echo 'Please enter a valid Access Token. You can do this in the plugin settings (Settings > Custom Facebook Feed).<br /><br />';
56
return false;
57
}
58
-
59
//Check whether a Page ID has been defined
60
if ($page_id == '') {
61
- echo "Please enter the Page ID of the Facebook feed you'd like to display. You can do this in either the plugin settings (Settings > Custom Facebook Feed) or in the shortcode itself. For example [custom_facebook_feed id=<b>YOUR_PAGE_ID</b>].<br /><br />";
62
return false;
63
}
64
-
65
66
-
67
- //Get JSON object of feed data
68
- function fetchUrl($url){
69
- //Can we use cURL?
70
- if(is_callable('curl_init')){
71
- $ch = curl_init();
72
- curl_setopt($ch, CURLOPT_URL, $url);
73
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
74
- curl_setopt($ch, CURLOPT_TIMEOUT, 20);
75
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
76
-
77
- $feedData = curl_exec($ch);
78
- curl_close($ch);
79
-
80
- //If not then use file_get_contents
81
- } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
82
- $feedData = @file_get_contents($url);
83
-
84
- //Or else use the WP HTTP API
85
- } else {
86
- if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
87
- $request = new WP_Http;
88
- $result = $request->request($url);
89
- $feedData = $result['body'];
90
-
91
- }
92
-
93
- return $feedData;
94
- }
95
-
96
//Get the contents of the Facebook page
97
$json_object = fetchUrl('https://graph.facebook.com/' . $page_id . '/posts?access_token=' . $access_token);
98
-
99
-
100
-
101
//Interpret data with JSON
102
$FBdata = json_decode($json_object);
103
104
//Create HTML
105
- $content = '<div id="cff">';
106
//Limit var
107
$i = 0;
108
- foreach ($FBdata->data as $news ) {
109
-
110
//Explode News and Page ID's into 2 values
111
$PostID = explode("_", $news->id);
112
-
113
//Check whether it's a status (author comment or like)
114
if ( ( $news->type == 'status' && !empty($news->message) ) || $news->type !== 'status' ) {
115
//If it isn't then create the post
116
-
117
//Only create posts for the amount of posts specified
118
if ( $i == $show_posts ) break;
119
$i++;
120
121
- //Start the container
122
- $content .= '<div class="cff-item">';
123
124
- //Text/title/description/date
125
- //Get text limits
126
- $title_limit = $atts['titlelength'];
127
- $body_limit = $atts['bodylength'];
128
129
- if (!empty($news->story)) {
130
- $story_text = $news->story;
131
- if (isset($title_limit) && $title_limit !== '') {
132
- if (strlen($story_text) > $title_limit) $story_text = substr($story_text, 0, $title_limit) . '...';
133
}
134
- $content .= '<h4>' . cff_make_clickable($story_text) . '</h4>';
135
- }
136
- if (!empty($news->message)) {
137
- $message_text = $news->message;
138
- if (isset($title_limit) && $title_limit !== '') {
139
- if (strlen($message_text) > $title_limit) $message_text = substr($message_text, 0, $title_limit) . '...';
140
}
141
- $content .= '<h4>' . cff_make_clickable($message_text) . '</h4>';
142
- }
143
if (!empty($news->description)) {
144
$description_text = $news->description;
145
- if (isset($body_limit) && $body_limit !== '') {
146
if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
147
}
148
- $content .= '<p>' . cff_make_clickable($description_text) . '</p>';
149
}
150
151
-
152
- //Posted on
153
- $content .= '<p class="cff-date">Posted '. cff_timeSince(strtotime($news->created_time)) . ' ago</p>';
154
-
155
-
156
- //Check whether it's a shared link
157
if ($news->type == 'link') {
158
159
- $story = $news->story;
160
-
161
- //Check whether it's an event
162
- $created_event = 'created an event.';
163
- $shared_event = 'shared an event.';
164
-
165
- $created_event = stripos($story, $created_event);
166
- $shared_event = stripos($story, $shared_event);
167
-
168
- if ( $created_event || $shared_event ){
169
- //Get the event object
170
- $eventID = $PostID[1];
171
- if ( $shared_event ) {
172
- //Get the event id from the event URL. eg: http://www.facebook.com/events/123451234512345/
173
- $event_url = parse_url($news->link);
174
- $url_parts = explode('/', $event_url['path']);
175
- //Get the id from the parts
176
- $eventID = $url_parts[count($url_parts)-2];
177
- }
178
- //Get the contents of the event
179
- $event_json = fetchUrl('https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token);
180
-
181
- //Interpret data with JSON
182
- $event_object = json_decode($event_json);
183
-
184
- //Display the event details
185
- $content .= '<div class="details">';
186
- if (!empty($event_object->name)) $content .= '<h5>' . $event_object->name . '</h5>';
187
- if (!empty($event_object->location)) $content .= '<p>Where: ' . $event_object->location . '</p>';
188
- if (!empty($event_object->start_time)) $content .= '<p>When: ' . date("F j, Y, g:i a", strtotime($event_object->start_time)) . '</p>';
189
- if (!empty($event_object->description)){
190
- $description = $event_object->description;
191
- if (isset($body_limit) && $body_limit !== '') {
192
- if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
193
}
194
- $content .= '<p>' . cff_make_clickable($description) . '</p>';
195
}
196
-
197
- $content .= '</div><!-- end .details -->';
198
}
199
-
200
}
201
202
- //Show link
203
if (!empty($news->link)) {
204
$link = $news->link;
205
-
206
//Check whether it links to facebook or somewhere else
207
$facebook_str = 'facebook.com';
208
-
209
if(stripos($link, $facebook_str) !== false) {
210
$link_text = 'View on Facebook';
211
} else {
212
$link_text = 'View Link';
213
}
214
- $content .= '<a class="cff-viewpost" href="' . $link . '" title="' . $link_text . '">' . $link_text . '</a>';
215
}
216
217
218
- //End item
219
- $content .= '</div> <!-- end .cff-item -->';
220
221
- } //End status check
222
223
- } //End the loop
224
225
226
//Add the Like Box
227
- $content .= '<div class="cff-likebox"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/' . $page_id . '" width="200" show_faces="false" stream="false" header="true"></fb:like-box></div>';
228
$content .= '</div><div class="clear"></div> <!-- end .Custom Facebook Feed -->';
229
230
//Return our feed HTML to display
231
return $content;
232
233
}
234
235
236
237
//Make links in text clickable
238
function cff_make_url_clickable($matches) {
239
$ret = '';
240
$url = $matches[2];
241
@@ -246,9 +422,10 @@ function cff_make_url_clickable($matches) {
246
$ret = substr($url, -1);
247
$url = substr($url, 0, strlen($url)-1);
248
}
249
- return $matches[1] . "<a href=\"$url\" rel=\"nofollow\" target='_blank'>$url</a>" . $ret;
250
}
251
function cff_make_web_ftp_clickable($matches) {
252
$ret = '';
253
$dest = $matches[2];
254
$dest = 'http://' . $dest;
@@ -260,7 +437,7 @@ function cff_make_web_ftp_clickable($matches) {
260
$ret = substr($dest, -1);
261
$dest = substr($dest, 0, strlen($dest)-1);
262
}
263
- return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\" target='_blank'>$dest</a>" . $ret;
264
}
265
function cff_make_email_clickable($matches) {
266
$email = $matches[2] . '@' . $matches[3];
@@ -281,9 +458,7 @@ function cff_make_clickable($ret) {
281
282
283
//Time stamp function
284
-
285
function cff_timeSince($original) {
286
-
287
// Array of time period
288
$chunks = array(
289
array(60 * 60 * 24 * 365 , 'year'),
@@ -293,29 +468,30 @@ function cff_timeSince($original) {
293
array(60 * 60 , 'hour'),
294
array(60 , 'minute'),
295
);
296
-
297
// Current time
298
$today = time();
299
$since = $today - $original;
300
-
301
// $j saves performing the count function each time around the loop
302
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
303
$seconds = $chunks[$i][0];
304
$name = $chunks[$i][1];
305
-
306
// finding the biggest chunk (if the chunk fits, break)
307
if (($count = floor($since / $seconds)) != 0) {
308
break;
309
}
310
}
311
-
312
$print = ($count == 1) ? '1 '.$name : "$count {$name}s";
313
-
314
if ($i + 1 < $j) {
315
// now getting the second item
316
$seconds2 = $chunks[$i + 1][0];
317
$name2 = $chunks[$i + 1][1];
318
-
319
// add second item if it's greater than 0
320
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
321
$print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
@@ -325,34 +501,34 @@ function cff_timeSince($original) {
325
}
326
327
328
-
329
//Enqueue stylesheet
330
add_action( 'wp_enqueue_scripts', 'cff_add_my_stylesheet' );
331
function cff_add_my_stylesheet() {
332
// Respects SSL, Style.css is relative to the current file
333
- wp_register_style( 'cff', plugins_url('css/style.css', __FILE__) );
334
wp_enqueue_style( 'cff' );
335
}
336
337
//Allows shortcodes in sidebar of theme
338
- add_filter('widget_text', 'do_shortcode');
339
340
//Uninstall
341
function cff_uninstall()
342
{
343
if ( ! current_user_can( 'activate_plugins' ) )
344
return;
345
-
346
delete_option( 'cff_access_token' );
347
delete_option( 'cff_page_id' );
348
delete_option( 'cff_num_show' );
349
delete_option( 'cff_title_length' );
350
delete_option( 'cff_body_length' );
351
}
352
register_uninstall_hook( __FILE__, 'cff_uninstall' );
353
354
355
//Comment out the line below to view errors
356
error_reporting(0);
357
-
358
?>
3
Plugin Name: Custom Facebook Feed
4
Plugin URI: http://smashballoon.com/custom-facebook-feed
5
Description: Add a completely customizable Facebook feed to your WordPress site
6
+ Version: 1.4.0
7
Author: Smash Balloon
8
Author URI: http://smashballoon.com/
9
License: GPLv2 or later
11
12
/*
13
Copyright 2013 Smash Balloon (email : hey@smashballoon.com)
14
This program is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License as published by
16
the Free Software Foundation; either version 2 of the License, or
17
(at your option) any later version.
18
This program is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
// Add shortcodes
31
add_shortcode('custom-facebook-feed', 'display_cff');
32
function display_cff($atts) {
33
+
34
+ //Style options
35
+ $options = get_option('cff_style_settings');
36
+
37
+
38
+ /********** GENERAL **********/
39
+
40
+ $cff_feed_width = $options[ 'cff_feed_width' ];
41
+ $cff_feed_height = $options[ 'cff_feed_height' ];
42
+ $cff_feed_padding = $options[ 'cff_feed_padding' ];
43
+ $cff_bg_color = $options[ 'cff_bg_color' ];
44
+
45
+ //Compile feed styles
46
+ $cff_feed_styles = 'style="';
47
+ if ( !empty($cff_feed_width) ) $cff_feed_styles .= 'width:' . $cff_feed_width . '; ';
48
+ if ( !empty($cff_feed_height) ) $cff_feed_styles .= 'height:' . $cff_feed_height . '; ';
49
+ if ( !empty($cff_feed_padding) ) $cff_feed_styles .= 'padding:' . $cff_feed_padding . '; ';
50
+ if ( !empty($cff_bg_color) ) $cff_feed_styles .= 'background-color:#' . $cff_bg_color . '; ';
51
+ $cff_feed_styles .= '"';
52
+
53
+ //Like box
54
+ $cff_like_box_position = $options[ 'cff_like_box_position' ];
55
+
56
+ //Open links in new window?
57
+ $cff_open_links = $options[ 'cff_open_links' ];
58
+ $target = 'target="_blank"';
59
+ if ($cff_open_links) $target = 'target="_blank"';
60
+
61
+
62
+ /********** LAYOUT **********/
63
+
64
+ //Include
65
+ $cff_show_text = $options[ 'cff_show_text' ];
66
+ $cff_show_desc = $options[ 'cff_show_desc' ];
67
+ $cff_show_date = $options[ 'cff_show_date' ];
68
+ $cff_show_event_title = $options[ 'cff_show_event_title' ];
69
+ $cff_show_event_details = $options[ 'cff_show_event_details' ];
70
+ $cff_show_link = $options[ 'cff_show_link' ];
71
+ $cff_show_like_box = $options[ 'cff_show_like_box' ];
72
+
73
+
74
+ /********** TYPOGRAPHY **********/
75
+
76
+ //Title
77
+ $cff_title_format = $options[ 'cff_title_format' ];
78
+ if (empty($cff_title_format)) $cff_title_format = 'p';
79
+ $cff_title_size = $options[ 'cff_title_size' ];
80
+ $cff_title_weight = $options[ 'cff_title_weight' ];
81
+ $cff_title_color = $options[ 'cff_title_color' ];
82
+ $cff_title_styles = 'style="';
83
+ if ( !empty($cff_title_size) && $cff_title_size != 'inherit' ) $cff_title_styles .= 'font-size:' . $cff_title_size . 'px; ';
84
+ if ( !empty($cff_title_weight) && $cff_title_weight != 'inherit' ) $cff_title_styles .= 'font-weight:' . $cff_title_weight . '; ';
85
+ if ( !empty($cff_title_color) ) $cff_title_styles .= 'color:#' . $cff_title_color . ';';
86
+ $cff_title_styles .= '"';
87
+
88
+ //Description
89
+ $cff_body_size = $options[ 'cff_body_size' ];
90
+ $cff_body_weight = $options[ 'cff_body_weight' ];
91
+ $cff_body_color = $options[ 'cff_body_color' ];
92
+ $cff_body_styles = 'style="';
93
+ if ( !empty($cff_body_size) && $cff_body_size != 'inherit' ) $cff_body_styles .= 'font-size:' . $cff_body_size . 'px; ';
94
+ if ( !empty($cff_body_weight) && $cff_body_weight != 'inherit' ) $cff_body_styles .= 'font-weight:' . $cff_body_weight . '; ';
95
+ if ( !empty($cff_body_color) ) $cff_body_styles .= 'color:#' . $cff_body_color . ';';
96
+ $cff_body_styles .= '"';
97
+
98
+ //Event Title
99
+ $cff_event_title_format = $options[ 'cff_event_title_format' ];
100
+ if (empty($cff_event_title_format)) $cff_event_title_format = 'p';
101
+ $cff_event_title_size = $options[ 'cff_event_title_size' ];
102
+ $cff_event_title_weight = $options[ 'cff_event_title_weight' ];
103
+ $cff_event_title_color = $options[ 'cff_event_title_color' ];
104
+ $cff_event_title_styles = 'style="';
105
+ if ( !empty($cff_event_title_size) && $cff_event_title_size != 'inherit' ) $cff_event_title_styles .= 'font-size:' . $cff_event_title_size . 'px; ';
106
+ if ( !empty($cff_event_title_weight) && $cff_event_title_weight != 'inherit' ) $cff_event_title_styles .= 'font-weight:' . $cff_event_title_weight . '; ';
107
+ if ( !empty($cff_event_title_color) ) $cff_event_title_styles .= 'color:#' . $cff_event_title_color . ';';
108
+ $cff_event_title_styles .= '"';
109
+
110
+ //Event Details
111
+ $cff_event_details_size = $options[ 'cff_event_details_size' ];
112
+ $cff_event_details_weight = $options[ 'cff_event_details_weight' ];
113
+ $cff_event_details_color = $options[ 'cff_event_details_color' ];
114
+ $cff_event_details_styles = 'style="';
115
+ if ( !empty($cff_event_details_size) && $cff_event_details_size != 'inherit' ) $cff_event_details_styles .= 'font-size:' . $cff_event_details_size . 'px; ';
116
+ if ( !empty($cff_event_details_weight) && $cff_event_details_weight != 'inherit' ) $cff_event_details_styles .= 'font-weight:' . $cff_event_details_weight . '; ';
117
+ if ( !empty($cff_event_details_color) ) $cff_event_details_styles .= 'color:#' . $cff_event_details_color . ';';
118
+ $cff_event_details_styles .= '"';
119
+
120
+ //Date
121
+ $cff_date_size = $options[ 'cff_date_size' ];
122
+ $cff_date_weight = $options[ 'cff_date_weight' ];
123
+ $cff_date_color = $options[ 'cff_date_color' ];
124
+ $cff_date_styles = 'style="';
125
+ if ( !empty($cff_date_size) && $cff_date_size != 'inherit' ) $cff_date_styles .= 'font-size:' . $cff_date_size . 'px; ';
126
+ if ( !empty($cff_date_weight) && $cff_date_weight != 'inherit' ) $cff_date_styles .= 'font-weight:' . $cff_date_weight . '; ';
127
+ if ( !empty($cff_date_color) ) $cff_date_styles .= 'color:#' . $cff_date_color . ';';
128
+ $cff_date_styles .= '"';
129
+
130
+ //Link to Facebook
131
+ $cff_link_size = $options[ 'cff_link_size' ];
132
+ $cff_link_weight = $options[ 'cff_link_weight' ];
133
+ $cff_link_color = $options[ 'cff_link_color' ];
134
+ $cff_link_styles = 'style="';
135
+ if ( !empty($cff_link_size) && $cff_link_size != 'inherit' ) $cff_link_styles .= 'font-size:' . $cff_link_size . 'px; ';
136
+ if ( !empty($cff_link_weight) && $cff_link_weight != 'inherit' ) $cff_link_styles .= 'font-weight:' . $cff_link_weight . '; ';
137
+ if ( !empty($cff_link_color) ) $cff_link_styles .= 'color:#' . $cff_link_color . ';';
138
+ $cff_link_styles .= '"';
139
+
140
+
141
+ /********** MISC **********/
142
+
143
+ //Like Box styles
144
+ $cff_likebox_bg_color = $options[ 'cff_likebox_bg_color' ];
145
+ $cff_likebox_styles = 'style="';
146
+ if ( !empty($cff_likebox_bg_color) ) $cff_likebox_styles .= 'background-color:#' . $cff_likebox_bg_color . '; margin-left: 0; ';
147
+ $cff_likebox_styles .= '"';
148
+
149
+
150
+
151
+
152
//Pass in shortcode attrbutes
153
$atts = shortcode_atts(
154
+ array(
155
+ 'id' => get_option('cff_page_id'),
156
+ 'show' => get_option('cff_num_show'),
157
+ 'titlelength' => get_option('cff_title_length'),
158
+ 'bodylength' => get_option('cff_body_length')
159
+ ), $atts);
160
+
161
+ //Text limits
162
+ $title_limit = $atts['titlelength'];
163
+ $body_limit = $atts['bodylength'];
164
165
//Assign the Access Token and Page ID variables
166
$access_token = get_option('cff_access_token');
169
//Get show posts attribute. If not set then default to 10.
170
$show_posts = $atts['show'];
171
if ( $show_posts == 0 || $show_posts == undefined ) $show_posts = 10;
172
//Check whether the Access Token is present and valid
173
if ($access_token == '') {
174
+ echo 'Please enter a valid Access Token. You can do this in the Custom Facebook Feed plugin settings.<br /><br />';
175
return false;
176
}
177
//Check whether a Page ID has been defined
178
if ($page_id == '') {
179
+ echo "Please enter the Page ID of the Facebook feed you'd like to display. You can do this in either the Custom Facebook Feed plugin settings or in the shortcode itself. For example [custom_facebook_feed id=<b>YOUR_PAGE_ID</b>].<br /><br />";
180
return false;
181
}
182
183
//Get the contents of the Facebook page
184
$json_object = fetchUrl('https://graph.facebook.com/' . $page_id . '/posts?access_token=' . $access_token);
185
//Interpret data with JSON
186
$FBdata = json_decode($json_object);
187
+ //Set like box variable
188
+ $like_box = '<div class="cff-likebox" ' . $cff_likebox_styles . '><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/' . $page_id . '" width="300" show_faces="false" stream="false" header="true"></fb:like-box></div>';
189
+
190
+
191
192
+ //***START FEED***
193
//Create HTML
194
+ $content = '<div id="cff" class="';
195
+ if ( !empty($cff_feed_height) ) $content .= 'fixed-height ';
196
+ $content .= '"' . $cff_feed_styles . '>';
197
+
198
+
199
+ //Add like box to top of feed
200
+ if ($cff_like_box_position == 'top' && $cff_show_like_box) $content .= $like_box;
201
//Limit var
202
$i = 0;
203
+
204
+ foreach ($FBdata->data as $news )
205
+ {
206
//Explode News and Page ID's into 2 values
207
$PostID = explode("_", $news->id);
208
//Check whether it's a status (author comment or like)
209
if ( ( $news->type == 'status' && !empty($news->message) ) || $news->type !== 'status' ) {
210
//If it isn't then create the post
211
//Only create posts for the amount of posts specified
212
if ( $i == $show_posts ) break;
213
$i++;
214
215
216
+ //********************************//
217
+ //***COMPILE SECTION VARIABLES***//
218
+ //********************************//
219
220
+ //POST TEXT
221
+ $cff_post_text = '<' . $cff_title_format . ' ' . $cff_title_styles . '">';
222
+ if (!empty($news->story)) {
223
+ $story_text = $news->story;
224
+ if (!empty($title_limit)) {
225
+ if (strlen($story_text) > $title_limit) $story_text = substr($story_text, 0, $title_limit) . '...';
226
+ }
227
+ $cff_post_text .= cff_make_clickable($story_text) . ' ';
228
}
229
+ if (!empty($news->message)) {
230
+ $message_text = $news->message;
231
+ if (!empty($title_limit)) {
232
+ if (strlen($message_text) > $title_limit) $message_text = substr($message_text, 0, $title_limit) . '...';
233
+ }
234
+ $cff_post_text .= cff_make_clickable($message_text) . ' ';
235
}
236
+ if (!empty($news->name) && empty($news->story)) {
237
+ $name_text = $news->name;
238
+ if (!empty($title_limit)) {
239
+ if (strlen($name_text) > $title_limit) $name_text = substr($name_text, 0, $title_limit) . '...';
240
+ }
241
+ $cff_post_text .= cff_make_clickable($name_text);
242
+ }
243
+ $cff_post_text .= '</' . $cff_title_format . '>';
244
+
245
+ //DESCRIPTION
246
+ $cff_description = '';
247
if (!empty($news->description)) {
248
$description_text = $news->description;
249
+ if (!empty($body_limit)) {
250
if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
251
}
252
+ $cff_description .= '<p '.$cff_body_styles.'>' . cff_make_clickable($description_text) . '</p>';
253
}
254
255
+ //LINK
256
+ $cff_shared_link = '';
257
+ //Display shared link
258
if ($news->type == 'link') {
259
+ //Display link name and description
260
+ if (!empty($news->description)) {
261
+ $cff_shared_link .= '<p class="text-link no-image"><a href="'.$news->link.'" '.$target.'>'. '<b>' . $news->name . '</b></a></p>';
262
+ }
263
+ }
264
265
+ //DATE
266
+ $cff_date = '<p class="cff-date" '.$cff_date_styles.'>Posted '. cff_timeSince(strtotime($news->created_time)) . ' ago</p>';
267
+
268
+ //EVENT
269
+ $cff_event = '';
270
+ if ($cff_show_event_title || $cff_show_event_details) {
271
+ //Check for media
272
+ if ($news->type == 'link') {
273
+ $story = $news->story;
274
+ //Check whether it's an event
275
+ $created_event = 'created an event.';
276
+ $shared_event = 'shared an event.';
277
+ $created_event = stripos($story, $created_event);
278
+ $shared_event = stripos($story, $shared_event);
279
+ if ( $created_event || $shared_event ){
280
+ //Get the event object
281
+ $eventID = $PostID[1];
282
+ if ( $shared_event ) {
283
+ //Get the event id from the event URL. eg: http://www.facebook.com/events/123451234512345/
284
+ $event_url = parse_url($news->link);
285
+ $url_parts = explode('/', $event_url['path']);
286
+ //Get the id from the parts
287
+ $eventID = $url_parts[count($url_parts)-2];
288
+ }
289
+ //Get the contents of the event using the WP HTTP API
290
+ $event_json = fetchUrl('https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token);
291
+ //Interpret data with JSON
292
+ $event_object = json_decode($event_json);
293
+
294
+ //EVENT
295
+ //Display the event details
296
+ $cff_event = '<div class="details">';
297
+ //Show event title
298
+ if ($cff_show_event_title && !empty($event_object->name)) $cff_event .= '<' . $cff_event_title_format . ' ' . $cff_event_title_styles . '>' . $event_object->name . '</' . $cff_event_title_format . '>';
299
+ //Show event details
300
+ if ($cff_show_event_details){
301
+ if (!empty($event_object->location)) $cff_event .= '<p ' . $cff_event_details_styles . '>Where: ' . $event_object->location . '</p>';
302
+ if (!empty($event_object->start_time)) $cff_event .= '<p ' . $cff_event_details_styles . '>When: ' . date("F j, Y, g:i a", strtotime($event_object->start_time)) . '</p>';
303
+ if (!empty($event_object->description)){
304
+ $description = $event_object->description;
305
+ if (!empty($body_limit)) {
306
+ if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
307
+ }
308
+ $cff_event .= '<p ' . $cff_event_details_styles . '>' . cff_make_clickable($description) . '</p>';
309
+ }
310
}
311
+ $cff_event .= '</div><!-- end .details -->';
312
}
313
}
314
}
315
316
+
317
+ //LINK
318
+ //Display the link to the Facebook post or external link
319
+ $cff_link = '';
320
if (!empty($news->link)) {
321
$link = $news->link;
322
//Check whether it links to facebook or somewhere else
323
$facebook_str = 'facebook.com';
324
if(stripos($link, $facebook_str) !== false) {
325
$link_text = 'View on Facebook';
326
} else {
327
$link_text = 'View Link';
328
}
329
+ $cff_link = '<div class="meta-wrap"><a class="cff-viewpost" href="' . $link . '" title="' . $link_text . '" ' . $target . ' ' . $cff_link_styles . '>' . $link_text . '</a></div><!-- end .meta-wrap -->';
330
}
331
332
333
334
+ //**************************//
335
+ //***CREATE THE POST HTML***//
336
+ //**************************//
337
+
338
+ //Start the container
339
+ $content .= '<div class="cff-item ';
340
+ if ($news->type == 'link') $content .= 'link-item';
341
+ $content .= '">';
342
+
343
+
344
+
345
+ //POST TEXT
346
+ if($cff_show_text) $content .= $cff_post_text;
347
348
+ //DESCRIPTION
349
+ if($cff_show_desc) $content .= $cff_description;
350
351
+ //LINK
352
+ if($cff_show_desc) $content .= $cff_shared_link;
353
+
354
+ //EVENT
355
+ if($cff_show_event_title || $cff_show_event_details) $content .= $cff_event;
356
+
357
+ //DATE
358
+ if($cff_show_date) $content .= $cff_date;
359
+
360
+ //LINK
361
+ if($cff_show_link) $content .= $cff_link;
362
+
363
+
364
+ //End the post item
365
+ $content .= '</div><div class="clear"></div> <!-- end .cff-item -->';
366
+
367
+
368
+
369
+
370
+ } // End status check
371
+
372
+ } // End the loop
373
374
//Add the Like Box
375
+ if ($cff_like_box_position == 'bottom' && $cff_show_like_box) $content .= $like_box;
376
+
377
+ //End the feed
378
$content .= '</div><div class="clear"></div> <!-- end .Custom Facebook Feed -->';
379
380
//Return our feed HTML to display
381
return $content;
382
+ }
383
384
+ //Get JSON object of feed data
385
+ function fetchUrl($url){
386
+ //Can we use cURL?
387
+ if(is_callable('curl_init')){
388
+ $ch = curl_init();
389
+ curl_setopt($ch, CURLOPT_URL, $url);
390
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
391
+ curl_setopt($ch, CURLOPT_TIMEOUT, 20);
392
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
393
+ $feedData = curl_exec($ch);
394
+ curl_close($ch);
395
+ //If not then use file_get_contents
396
+ } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
397
+ $feedData = @file_get_contents($url);
398
+ //Or else use the WP HTTP API
399
+ } else {
400
+ if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
401
+ $request = new WP_Http;
402
+ $result = $request->request($url);
403
+ $feedData = $result['body'];
404
+ }
405
+
406
+ return $feedData;
407
}
408
409
410
+ //***FUNCTIONS***
411
412
//Make links in text clickable
413
function cff_make_url_clickable($matches) {
414
+ $target = 'target="_blank"';
415
$ret = '';
416
$url = $matches[2];
417
422
$ret = substr($url, -1);
423
$url = substr($url, 0, strlen($url)-1);
424
}
425
+ return $matches[1] . "<a href=\"$url\" rel=\"nofollow\" ".$target.">$url</a>" . $ret;
426
}
427
function cff_make_web_ftp_clickable($matches) {
428
+ $target = 'target="_blank"';
429
$ret = '';
430
$dest = $matches[2];
431
$dest = 'http://' . $dest;
437
$ret = substr($dest, -1);
438
$dest = substr($dest, 0, strlen($dest)-1);
439
}
440
+ return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\" ".$target.">$dest</a>" . $ret;
441
}
442
function cff_make_email_clickable($matches) {
443
$email = $matches[2] . '@' . $matches[3];
458
459
460
//Time stamp function
461
function cff_timeSince($original) {
462
// Array of time period
463
$chunks = array(
464
array(60 * 60 * 24 * 365 , 'year'),
468
array(60 * 60 , 'hour'),
469
array(60 , 'minute'),
470
);
471
+
472
// Current time
473
$today = time();
474
$since = $today - $original;
475
+
476
// $j saves performing the count function each time around the loop
477
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
478
+
479
$seconds = $chunks[$i][0];
480
$name = $chunks[$i][1];
481
+
482
// finding the biggest chunk (if the chunk fits, break)
483
if (($count = floor($since / $seconds)) != 0) {
484
break;
485
}
486
}
487
+
488
$print = ($count == 1) ? '1 '.$name : "$count {$name}s";
489
+
490
if ($i + 1 < $j) {
491
// now getting the second item
492
$seconds2 = $chunks[$i + 1][0];
493
$name2 = $chunks[$i + 1][1];
494
+
495
// add second item if it's greater than 0
496
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
497
$print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
501
}
502
503
504
//Enqueue stylesheet
505
add_action( 'wp_enqueue_scripts', 'cff_add_my_stylesheet' );
506
function cff_add_my_stylesheet() {
507
// Respects SSL, Style.css is relative to the current file
508
+ wp_register_style( 'cff', plugins_url('css/cff-style.css', __FILE__) );
509
wp_enqueue_style( 'cff' );
510
}
511
512
+
513
//Allows shortcodes in sidebar of theme
514
+ add_filter('widget_text', 'do_shortcode');
515
+
516
517
//Uninstall
518
function cff_uninstall()
519
{
520
if ( ! current_user_can( 'activate_plugins' ) )
521
return;
522
delete_option( 'cff_access_token' );
523
delete_option( 'cff_page_id' );
524
delete_option( 'cff_num_show' );
525
delete_option( 'cff_title_length' );
526
delete_option( 'cff_body_length' );
527
+ delete_option('cff_style_settings');
528
}
529
register_uninstall_hook( __FILE__, 'cff_uninstall' );
530
531
532
//Comment out the line below to view errors
533
error_reporting(0);
534
?>