Custom Facebook Feed - Version 2.10

Version Description

  • New: Facebook Groups are making their long-awaited return to the plugin! Just click the 'Log in and get my Access Token' button on the plugin's Settings page and select 'Facebook Group'. Follow the prompts to connect your Group and display your feed.
  • Fix: Fixed an issue where a lists of groups or pages wouldn't be displayed when retrieving an Access Token due to a server configuration issue
  • Fix: Photo icons weren't showing for album posts
  • Tweak: Now uses the visitor_posts endpoint to display visitor post feeds
Download this release

Release Info

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

Code changes from version 2.9.1 to 2.10

README.txt CHANGED
@@ -1,23 +1,22 @@
1
- === Custom Facebook Feed ===
2
Contributors: smashballoon
3
- Tags: Facebook, Facebook feed, Facebook posts, Facebook wall, Facebook page
4
Requires at least: 3.0
5
Tested up to: 5.2
6
- Stable tag: 2.9.1
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
10
- The Custom Facebook Feed allows you to display completely customizable Facebook feeds of any public Facebook page on your website
11
12
== Description ==
13
14
- Display **completely customizable**, **responsive** and **search engine crawlable** Facebook feeds on your website. Display **multiple feeds** from **any public Facebook page**, and completely match the look and feel of the site with tons of customization options!
15
16
- *"The perfect plugin with amazing support! What else do you want? Get it!"* - [JoeJeffries](http://wordpress.org/support/topic/you-dont-already-have-this)
17
18
- *"I honestly cannot recommend this plugin enough. The plugin itself is gorgeous and super customizable, and if you run into trouble...support will get you out of it. Five Stars across the board."* - [pamsavoybarnett](http://wordpress.org/support/topic/love-this-plugin-w-awesome-support?replies=2)
19
-
20
- *"The positive reviews here say it all. John and SmashBalloon are delivering top-notch products and service -- something us website developers value greatly. If I could give them 10 Stars across the board I wouldn't hesitate. Cheers!"* - [AME Network](http://wordpress.org/support/topic/excellent-plugin-superior-support?replies=1)
21
22
= Features =
23
@@ -264,6 +263,11 @@ You no longer need your own Access Token to use the Custom Facebook Feed Plugin,
264
9. It's super easy to display your Facebook feed in any page or post
265
266
== Changelog ==
267
268
= 2.9.1 =
269
* New: Added support for v3.3 of the Facebook API.
1
+ === Smash Balloon Social Post Feed ===
2
Contributors: smashballoon
3
+ Tags: Facebook, Facebook feed, Facebook posts, Facebook wall, Facebook page, facebook likebox, facebook feed, facebook plugin
4
Requires at least: 3.0
5
+ Requires PHP: 5.2
6
Tested up to: 5.2
7
+ Stable tag: 2.10
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
11
+ Formerly "Custom Facebook Feed". Display completely customizable Facebook feeds of any public Facebook page on your website.
12
13
== Description ==
14
15
+ Display Facebook posts on your website. **Completely customizable**, **responsive** and **search engine crawlable**. Display **multiple Facebook feeds** from **any public Facebook page**, and completely match the look and feel of the site with tons of customization options!
16
17
+ *"The perfect Facebook plugin with amazing support! What else do you want? Get it!"* - [JoeJeffries](http://wordpress.org/support/topic/you-dont-already-have-this?facebook)
18
19
+ *"I honestly cannot recommend this plugin enough. The plugin itself is gorgeous and super customizable, and if you run into trouble...support will get you out of it. Five Stars across the board."* - [pamsavoybarnett](http://wordpress.org/support/topic/love-this-plugin-w-awesome-support?facebook)
20
21
= Features =
22
263
9. It's super easy to display your Facebook feed in any page or post
264
265
== Changelog ==
266
+ = 2.10 =
267
+ * New: Facebook Groups are making their long-awaited return to the plugin! Just click the 'Log in and get my Access Token' button on the plugin's Settings page and select 'Facebook Group'. Follow the prompts to connect your Group and display your feed.
268
+ * Fix: Fixed an issue where a lists of groups or pages wouldn't be displayed when retrieving an Access Token due to a server configuration issue
269
+ * Fix: Photo icons weren't showing for album posts
270
+ * Tweak: Now uses the `visitor_posts` endpoint to display visitor post feeds
271
272
= 2.9.1 =
273
* New: Added support for v3.3 of the Facebook API.
css/cff-admin-style.css CHANGED
@@ -988,7 +988,6 @@
988
font-size: 14px;
989
line-height: 1.6;
990
}
991
-
992
/* Tokens modal */
993
#cff-admin #cff_fb_login_modal.cff_modal_tokens{
994
display: block;
@@ -1024,7 +1023,8 @@
1024
}
1025
#cff-admin #cff-insert-token,
1026
#cff-admin .cff-insert-reviews-token,
1027
- #cff-admin .cff-insert-both-tokens{
1028
margin-top: 25px;
1029
float: left;
1030
clear: both;
@@ -1133,6 +1133,90 @@
1133
left: 7px;
1134
}
1135
1136
/* Admin footer share icons */
1137
#cff-admin #cff-admin-share-links{
1138
opacity: 0;
988
font-size: 14px;
989
line-height: 1.6;
990
}
991
/* Tokens modal */
992
#cff-admin #cff_fb_login_modal.cff_modal_tokens{
993
display: block;
1023
}
1024
#cff-admin #cff-insert-token,
1025
#cff-admin .cff-insert-reviews-token,
1026
+ #cff-admin .cff-insert-both-tokens,
1027
+ #cff-admin #cff-close-modal-primary-button{
1028
margin-top: 25px;
1029
float: left;
1030
clear: both;
1133
left: 7px;
1134
}
1135
1136
+ /* Groups option */
1137
+ #cff-admin .cff-login-options{
1138
+ width: 100%;
1139
+ padding: 20px 0 0 0;
1140
+ margin: 20px 0;
1141
+ box-sizing: border-box;
1142
+ border-top: 1px solid #eee;
1143
+ }
1144
+ #cff-admin .cff-login-options label{
1145
+ display: block;
1146
+ margin-bottom: 5px;
1147
+ font-weight: bold;
1148
+ }
1149
+ #cff-admin #cff_group_app{
1150
+ display: none;
1151
+ }
1152
+ /* Highlight admin groups in list */
1153
+ #cff-admin .cff-group-admin{
1154
+ position: relative;
1155
+ background: #eee;
1156
+ }
1157
+ #cff-admin .cff-group-admin-icon{
1158
+ position: absolute;
1159
+ top: 5px;
1160
+ right: 5px;
1161
+ padding: 5px 8px;
1162
+ background: rgba(255,255,255,0.5);
1163
+ border-radius: 5px;
1164
+ text-transform: uppercase;
1165
+ font-size: 11px;
1166
+ }
1167
+ #cff-admin .cff-group-admin-icon .fa{
1168
+ margin-right: 2px;
1169
+ font-size: 12px;
1170
+ }
1171
+ #cff-admin .cff-group-admin .cff-page-info-name {
1172
+ max-width: 85%;
1173
+ }
1174
+ #cff_token_expiration_note{
1175
+ display: none;
1176
+ width: 250px;
1177
+ padding: 5px 10px;
1178
+ float: right;
1179
+ font-size: 12px;
1180
+ margin-top: 11px;
1181
+ line-height: 1.3;
1182
+ border-radius: 5px;
1183
+ }
1184
+ #cff-group-member-directions{
1185
+ display: none;
1186
+ }
1187
+ /* App installation directions */
1188
+ #cff-group-installation{
1189
+ display: none;
1190
+ width: 100%;
1191
+ clear: both;
1192
+ text-align: left;
1193
+ }
1194
+ #cff-group-installation li{
1195
+ font-size: 14px;
1196
+ margin: 0 0 10px 0;
1197
+ line-height: 1.5;
1198
+ }
1199
+ #cff-group-installation li{
1200
+ position: relative;
1201
+ }
1202
+ #cff-group-app-tooltip{
1203
+ cursor: pointer;
1204
+ }
1205
+ #cff-group-app-screenshot{
1206
+ display: none;
1207
+ position: absolute;
1208
+ bottom: 42px;
1209
+ left: 0;
1210
+ margin-left: -85px;
1211
+ z-index: 10;
1212
+ border: 1px solid rgba(0,0,0,0.3);
1213
+ box-shadow: 0 0 0 5000px rgba(0,0,0,0.2);
1214
+ border-radius: 5px;
1215
+ }
1216
+ #cff-group-installation .button-secondary{
1217
+ margin: 25px 0 0 10px;
1218
+ }
1219
+
1220
/* Admin footer share icons */
1221
#cff-admin #cff-admin-share-links{
1222
opacity: 0;
custom-facebook-feed-admin.php CHANGED
@@ -138,19 +138,32 @@ function cff_settings_page() {
138
139
<p>Log into your Facebook account using the button below and approve the plugin to connect your account.</p>
140
141
- <p><a href="javascript:void(0);" id="cff_admin_cancel_btn" class="cff-admin-cancel-btn">Cancel</a>
142
143
- <?php
144
- $admin_url_state = admin_url('admin.php?page=cff-top');
145
- //If the admin_url isn't returned correctly then use a fallback
146
- if( $admin_url_state == '/wp-admin/admin.php?page=cff-top' || $admin_url_state == '/wp-admin/admin.php?page=cff-top&tab=configuration' ){
147
- $admin_url_state = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
148
- }
149
- ?>
150
151
- <a href="https://api.smashballoon.com/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a></p>
152
153
- <p style="font-size: 11px; margin-top: 25px;"><b>Please note:</b> this does not give us permission to manage your Facebook pages, it simply allows the plugin to see a list of the pages you manage and retrieve an Access Token.</p>
154
155
</div>
156
</div>
@@ -164,45 +177,162 @@ function cff_settings_page() {
164
if( $_GET['final_response'] == 'true' ){
165
166
$access_token = $_GET['access_token'];
167
- $url = 'https://graph.facebook.com/me/accounts?limit=500&access_token='.$access_token;
168
- $pages_data = @file_get_contents($url);
169
- $pages_data_arr = json_decode($pages_data);
170
-
171
- if( empty($pages_data_arr->data) ){
172
- //If they don't manage any pages then just use the user token instead
173
- ?>
174
- <script type='text/javascript'>
175
- jQuery(document).ready(function($) {
176
- $('#cff_access_token').val('<?php echo $access_token ?>').addClass('cff-success');
177
- //Check the own access token setting so it reveals token field
178
- if( $('#cff_show_access_token:checked').length < 1 ){
179
- $("#cff_show_access_token").trigger("change").prop( "checked", true );
180
- }
181
- });
182
- </script>
183
184
- <?php
185
} else {
186
//Show the pages they manage
187
echo '<div id="cff_fb_login_modal" class="cff_modal_tokens cffnomodal">';
188
echo '<div class="cff_modal_box">';
189
echo '<div class="cff-managed-pages">';
190
191
- echo '<p style="margin-top: 0;"><i class="fa fa-check-circle" aria-hidden="true" style="font-size: 15px; margin: 0 8px 0 2px;"></i>Select a Facebook page below to get an Access Token.</p>';
192
- echo '<p class="cff-tokens-note">Note: This Access Token will allow you to display posts from <b style="font-weight: 900;">any</b> public Facebook page, not just the one selected.</p>';
193
194
- echo '<div class="cff-pages-wrap">';
195
- foreach ( $pages_data_arr->data as $page => $page_data ) {
196
- echo '<div class="cff-managed-page ';
197
- if( $page_data->id == $page_id_val ) echo 'cff-page-selected';
198
- echo '" data-token="'.$page_data->access_token.'" data-page-id="'.$page_data->id.'">';
199
- echo '<p><img class="cff-page-avatar" border="0" height="50" width="50" src="https://graph.facebook.com/'.$page_data->id.'/picture"><b class="cff-page-info-name">'.$page_data->name.'</b><span class="cff-page-info">(Page ID: '.$page_data->id.')</span></p>';
200
echo '</div>';
201
- }
202
- echo '</div>';
203
204
- $cff_use_token_text = 'Use token for this page';
205
- echo '<a href="JavaScript:void(0);" id="cff-insert-token" class="button button-primary" disabled="disabled">'.$cff_use_token_text.'</a>';
206
207
echo '</div>';
208
echo '<a href="JavaScript:void(0);" class="cff-modal-close"><i class="fa fa-times"></i></a>';
@@ -210,7 +340,7 @@ function cff_settings_page() {
210
echo '</div>';
211
212
echo '<a href="JavaScript:void(0);" class="cff_admin_btn" id="cff_fb_show_tokens"><i class="fa fa-th-list" aria-hidden="true" style="font-size: 14px; margin-right: 8px;"></i>';
213
- _e( "Show Available Pages", "custom-facebook-feed" );
214
echo '</a>';
215
216
}
@@ -222,8 +352,8 @@ function cff_settings_page() {
222
<table class="form-table">
223
<tbody>
224
<tr valign="top">
225
- <th scope="row"><label><?php _e('Facebook Page ID<br /><i style="font-weight: normal; font-size: 12px;">ID of your Facebook Page</i>', 'custom-facebook-feed'); ?></label><code class="cff_shortcode"> id
226
- Eg: id="YOUR_PAGE_ID"</code></th>
227
<td>
228
<input name="cff_page_id" id="cff_page_id" type="text" value="<?php esc_attr_e( $page_id_val, 'custom-facebook-feed' ); ?>" size="45" />
229
&nbsp;<a class="cff-tooltip-link" href="JavaScript:void(0);"><?php _e('What\'s my Page ID?', 'custom-facebook-feed'); ?></a>
@@ -239,8 +369,7 @@ function cff_settings_page() {
239
URL Format 3: <code>https://www.facebook.com/pages/your_page_name/<span class="cff-highlight">1234567890</span></code>
240
'); ?>
241
</li>
242
- <li><?php _e('<b>Facebook Group</b><br />Due to <a href="https://smashballoon.com/facebook-api-changes-april-4-2018/" target="_blank">recent changes</a> to the Facebook API it is unfortunately no longer possible to display a feed from a Facebook Group.'); ?></li>
243
- <li><?php _e('To test that your ID is correct, you can copy and paste it into our <a href="http://smashballoondemo.com/" target="_blank">Pro demo</a>.'); ?></li>
244
</ul>
245
</div>
246
</td>
@@ -264,6 +393,21 @@ function cff_settings_page() {
264
<tbody>
265
<h3><?php _e('Settings', 'custom-facebook-feed'); ?></h3>
266
267
<tr valign="top">
268
<th scope="row"><label><?php _e('Show posts on my page by:', 'custom-facebook-feed'); ?></label><code class="cff_shortcode"> showpostsby
269
Eg: showpostsby=others</code></th>
@@ -273,9 +417,6 @@ function cff_settings_page() {
273
<option value="others" <?php if($cff_show_others_val == 'others' || $cff_show_others_val == 'on') echo 'selected="selected"' ?> ><?php _e('Page owner + other people', 'custom-facebook-feed'); ?></option>
274
<option value="onlyothers" <?php if($cff_show_others_val == 'onlyothers') echo 'selected="selected"' ?> ><?php _e('Only other people', 'custom-facebook-feed'); ?></option>
275
</select>
276
-
277
- <p id="cff-others-only" style="font-size: 12px;"><b>Note:</b> Only displaying posts by other people works by retrieving your posts from Facebook and then filtering out the posts by the page owner. If this option doesn't display many posts then you can retrieve more by setting the post limit option (below) to a higher number (a number 15-20 greater than the number of posts you want to display).</p>
278
-
279
</td>
280
</tr>
281
@@ -590,10 +731,8 @@ function cff_settings_page() {
590
<?php
591
$cff_use_own_token = get_option( 'cff_show_access_token' );
592
$access_token = get_option( $access_token );
593
- if ( $access_token == '' || empty($access_token) || ( !isset($cff_use_own_token) || empty($cff_use_own_token) ) ) $access_token = '297576260660946|iCDRJNnG9EAJplgB-vkMR2q2ob0';
594
?>
595
- <?php $posts_json = cff_fetchUrl("https://graph.facebook.com/".get_option( trim($page_id) )."/feed?access_token=". trim($access_token) ."&limit=1"); ?>
596
-
597
598
<textarea readonly="readonly" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)." style="width: 70%; height: 500px; white-space: pre; font-family: Menlo,Monaco,monospace;">
599
## SITE/SERVER INFO: ##
@@ -3972,5 +4111,7 @@ $notice_status = get_option( $option, false );
3972
if ( get_transient( $transient ) !== 'waiting' && $notice_status !== 'dismissed' ) {
3973
add_action( 'admin_notices', 'cff_rating_notice_html' );
3974
}
3975
3976
?>
138
139
<p>Log into your Facebook account using the button below and approve the plugin to connect your account.</p>
140
141
142
+ <div class="cff-login-options">
143
+ <label for="cff_login_type">Would you like to display a Facebook Page or Group?</label>
144
+ <select id="cff_login_type">
145
+ <option value="page">Facebook Page</option>
146
+ <option value="group">Facebook Group</option>
147
+ </select>
148
+
149
+ <p>
150
+ <a href="javascript:void(0);" id="cff_admin_cancel_btn" class="cff-admin-cancel-btn">Cancel</a>
151
152
+ <?php
153
+ $admin_url_state = admin_url('admin.php?page=cff-top');
154
+ //If the admin_url isn't returned correctly then use a fallback
155
+ if( $admin_url_state == '/wp-admin/admin.php?page=cff-top' || $admin_url_state == '/wp-admin/admin.php?page=cff-top&tab=configuration' ){
156
+ $admin_url_state = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
157
+ }
158
+ ?>
159
+ <a href="https://api.smashballoon.com/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_page_app"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a>
160
161
+ <a href="https://api.smashballoon.com/facebook-group-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_group_app"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a>
162
+
163
+ </p>
164
+ </div>
165
+
166
+ <p style="font-size: 11px; margin-top: 25px;"><b>Please note:</b> this does not give us permission to manage your Facebook pages or groups, it simply allows the plugin to see a list that you manage and retrieve an Access Token.</p>
167
168
</div>
169
</div>
177
if( $_GET['final_response'] == 'true' ){
178
179
$access_token = $_GET['access_token'];
180
+ $cff_is_groups = false;
181
+ $pages_data_arr = '';
182
+ $groups_data_arr = '';
183
+
184
+ if( isset($_GET['group']) ){
185
+ //Get Groups
186
187
+ $cff_is_groups = true;
188
+ $groups_data_arr = '';
189
+
190
+ //Extend the user token by making a call to /me/accounts. User must be an admin of a page for this to work as won't work if the response is empty.
191
+ $url = 'https://graph.facebook.com/me/accounts?limit=500&access_token='.$access_token;
192
+
193
+ $accounts_data = cff_fetchUrl($url);
194
+ $accounts_data_arr = json_decode($accounts_data);
195
+ $cff_token_expiration = 'never';
196
+ if( empty($accounts_data_arr->data) ){
197
+ $cff_token_expiration = '60 days';
198
+ }
199
+
200
+ //Get User ID
201
+ $user_url = 'https://graph.facebook.com/me?fields=id&access_token='.$access_token;
202
+ $user_id_data = cff_fetchUrl($user_url);
203
+
204
+ if( !empty($user_id_data) ){
205
+ $user_id_data_arr = json_decode($user_id_data);
206
+ $user_id = $user_id_data_arr->id;
207
+
208
+ //Get groups they're admin of
209
+ $groups_admin_url = 'https://graph.facebook.com/'.$user_id.'/groups?admin_only=true&fields=name,id,picture&access_token='.$access_token;
210
+ $groups_admin_data = cff_fetchUrl($groups_admin_url);
211
+ $groups_admin_data_arr = json_decode($groups_admin_data);
212
+
213
+ //Get member groups
214
+ $groups_url = 'https://graph.facebook.com/'.$user_id.'/groups?admin_only=false&fields=name,id,picture&access_token='.$access_token;
215
+ $groups_data = cff_fetchUrl($groups_url);
216
+ $groups_data_arr = json_decode($groups_data);
217
+
218
+ // $pages_data_arr = $groups_data_arr;
219
+ }
220
} else {
221
+ //Get Pages
222
+
223
+ $url = 'https://graph.facebook.com/me/accounts?limit=500&access_token='.$access_token;
224
+ $pages_data = cff_fetchUrl($url);
225
+ $pages_data_arr = json_decode($pages_data);
226
+
227
+ if( empty($pages_data_arr->data) ){
228
+ //If they don't manage any pages then just use the user token instead
229
+ ?>
230
+ <script type='text/javascript'>
231
+ jQuery(document).ready(function($) {
232
+ $('#cff_access_token').val('<?php echo $access_token ?>').addClass('cff-success');
233
+ //Check the own access token setting so it reveals token field
234
+ if( $('#cff_show_access_token:checked').length < 1 ){
235
+ $("#cff_show_access_token").trigger("change").prop( "checked", true );
236
+ }
237
+ });
238
+ </script>
239
+ <?php
240
+ }
241
+
242
+ }
243
+
244
+
245
+ if( !empty($pages_data_arr->data) || $cff_is_groups ){
246
//Show the pages they manage
247
echo '<div id="cff_fb_login_modal" class="cff_modal_tokens cffnomodal">';
248
echo '<div class="cff_modal_box">';
249
echo '<div class="cff-managed-pages">';
250
251
+ if( $cff_is_groups ){
252
+ //GROUPS
253
+
254
+ if( empty($groups_data_arr->data) && empty($groups_admin_data_arr->data) ){
255
+ echo '<h3>No Groups Returned</h3>';
256
+ echo "<p>Facebook has not returned any groups for your user. It is only possible to display a feed from a group which you are either an admin or a member. Please note, if you are not an admin of the group then it is required that an admin add our app in the group settings in order to display a feed.</p><p>Please either create or join a Facebook group and then follow the directions when connecting your account on this page.</p>";
257
+ echo '<a href="JavaScript:void(0);" class="button button-primary" id="cff-close-modal-primary-button">Close</a>';
258
+ } else {
259
+
260
+ echo '<div class="cff-groups-list">';
261
+ echo '<p style="margin-top: 0;"><i class="fa fa-check-circle" aria-hidden="true" style="font-size: 15px; margin: 0 8px 0 2px;"></i>Select a Facebook group below to get an Access Token.</p>';
262
+
263
+ echo '<div class="cff-pages-wrap">';
264
+ //Admin groups
265
+ foreach ( $groups_admin_data_arr->data as $page => $group_data ) {
266
+ echo '<div class="cff-managed-page cff-group-admin';
267
+ if( $group_data->id == $page_id_val ) echo ' cff-page-selected';
268
+ echo '" data-token="'.$access_token.'" data-page-id="'.$group_data->id.'" id="cff_'.$group_data->id.'">';
269
+ echo '<p>';
270
+ if( isset( $group_data->picture->data->url ) ) echo '<img class="cff-page-avatar" border="0" height="50" width="50" src="'.$group_data->picture->data->url.'">';
271
+ echo '<b class="cff-page-info-name">'.$group_data->name.'</b><span class="cff-page-info">(Group ID: '.$group_data->id.')</span></p>';
272
+ echo '<div class="cff-group-admin-icon"><i class="fa fa-user" aria-hidden="true"></i> Admin</div>';
273
+ echo '</div>';
274
+ }
275
+ //Member groups
276
+ foreach ( $groups_data_arr->data as $page => $group_data ) {
277
+ echo '<div class="cff-managed-page';
278
+ if( $group_data->id == $page_id_val ) echo ' cff-page-selected';
279
+ echo '" data-token="'.$access_token.'" data-page-id="'.$group_data->id.'" id="cff_'.$group_data->id.'">';
280
+ echo '<p>';
281
+ if( isset( $group_data->picture->data->url ) ) echo '<img class="cff-page-avatar" border="0" height="50" width="50" src="'.$group_data->picture->data->url.'">';
282
+ echo '<b class="cff-page-info-name">'.$group_data->name.'</b><span class="cff-page-info">(Group ID: '.$group_data->id.')</span></p>';
283
+ echo '</div>';
284
+ }
285
+ echo '</div>';
286
+ echo '<a href="JavaScript:void(0);" class="button button-primary cff-group-btn" id="cff-insert-token" disabled="disabled">Use token for this Group</a>';
287
+ if( $cff_token_expiration == "60 days" ) echo '<div id="cff_token_expiration_note" class="cff-error"><b>Important:</b> This token will expire in 60 days.<br /><a href="https://smashballoon.com/extending-a-group-access-token-so-it-never-expires/" target="_blank">Extend token so it never expires</a></div>';
288
+ echo '</div>';
289
+
290
+ echo '<div id="cff-group-installation">';
291
+ echo '<h3>Important</h3>';
292
+
293
+ echo '<div id="cff-group-admin-directions">';
294
+ echo '<p>To display a feed from your group you need to add our app in your Facebook group settings:</p>';
295
+ echo '<ul>';
296
+ echo '<li><b>1)</b> Go to your group settings page by clicking <a id="cff-group-edit" href="https://www.facebook.com/groups/" target="_blank">here<i class="fa fa-external-link" aria-hidden="true" style="font-size: 13px; position: relative; top: 2px; margin-left: 5px;"></i></a></li>';
297
+ echo '<li><b>2)</b> In the "Apps" section click "Add Apps".</li>';
298
+ echo '<li><b>3)</b> Search for "Smash Balloon" and select our app (<a id="cff-group-app-tooltip">screenshot</a>).<img id="cff-group-app-screenshot" src="'. plugins_url( "img/group-app.png" , __FILE__ ) .'" alt="Thumbnail Layout" /></li>';
299
+ echo '<li><b>4</b>) Click "Add".</li>';
300
+ echo '</ul>';
301
+
302
+ echo '<p style="margin-bottom: 10px;">You can now use the plugin to display a feed from your group.</p>';
303
+ echo '</div>';
304
+
305
+ echo '<div id="cff-group-member-directions">';
306
+ echo '<p>To display a feed from this group an admin needs to first add our app in the group settings. Please ask an admin to follow the directions <a href="https://smashballoon.com/adding-our-app-to-a-facebook-group/" target="_blank">here</a> to add our app.</p>';
307
+ echo '<p>Once this is done you will then be able to display a feed from this group.</p>';
308
+ echo '</div>';
309
+
310
+ echo '<a href="JavaScript:void(0);" class="button button-primary" id="cff-close-modal-primary-button">Done</a>';
311
+ echo '<a href="https://smashballoon.com/display-facebook-group-feed/" target="_blank" class="button button-secondary"><i class="fa fa-life-ring"></i> Help</a>';
312
+ echo '</div>';
313
+
314
+ }
315
+
316
+ } else {
317
+ //PAGES
318
319
+ echo '<p style="margin-top: 0;"><i class="fa fa-check-circle" aria-hidden="true" style="font-size: 15px; margin: 0 8px 0 2px;"></i>Select a Facebook page below to get an Access Token.</p>';
320
+ echo '<p class="cff-tokens-note">Note: This Access Token will allow you to display posts from <b style="font-weight: 900;">any</b> public Facebook page, not just the one selected.</p>';
321
+
322
+ echo '<div class="cff-pages-wrap">';
323
+ foreach ( $pages_data_arr->data as $page => $page_data ) {
324
+ echo '<div class="cff-managed-page ';
325
+ if( $page_data->id == $page_id_val ) echo 'cff-page-selected';
326
+ echo '" data-token="'.$page_data->access_token.'" data-page-id="'.$page_data->id.'">';
327
+ echo '<p><img class="cff-page-avatar" border="0" height="50" width="50" src="https://graph.facebook.com/'.$page_data->id.'/picture"><b class="cff-page-info-name">'.$page_data->name.'</b><span class="cff-page-info">(Page ID: '.$page_data->id.')</span></p>';
328
+ echo '</div>';
329
+ }
330
echo '</div>';
331
332
+ $cff_use_token_text = 'Use token for this page';
333
+ echo '<a href="JavaScript:void(0);" id="cff-insert-token" class="button button-primary" disabled="disabled">'.$cff_use_token_text.'</a>';
334
+
335
+ }
336
337
echo '</div>';
338
echo '<a href="JavaScript:void(0);" class="cff-modal-close"><i class="fa fa-times"></i></a>';
340
echo '</div>';
341
342
echo '<a href="JavaScript:void(0);" class="cff_admin_btn" id="cff_fb_show_tokens"><i class="fa fa-th-list" aria-hidden="true" style="font-size: 14px; margin-right: 8px;"></i>';
343
+ $cff_is_groups ? _e( "Show Available Groups", "custom-facebook-feed" ) : _e( "Show Available Pages", "custom-facebook-feed" );
344
echo '</a>';
345
346
}
352
<table class="form-table">
353
<tbody>
354
<tr valign="top">
355
+ <th scope="row"><label><?php _e('Facebook Page ID<br /><i style="font-weight: normal; font-size: 12px;">ID of your Facebook Page or Group</i>', 'custom-facebook-feed'); ?></label><code class="cff_shortcode"> id
356
+ Eg: id="YOUR_PAGE_OR_GROUP_ID"</code></th>
357
<td>
358
<input name="cff_page_id" id="cff_page_id" type="text" value="<?php esc_attr_e( $page_id_val, 'custom-facebook-feed' ); ?>" size="45" />
359
&nbsp;<a class="cff-tooltip-link" href="JavaScript:void(0);"><?php _e('What\'s my Page ID?', 'custom-facebook-feed'); ?></a>
369
URL Format 3: <code>https://www.facebook.com/pages/your_page_name/<span class="cff-highlight">1234567890</span></code>
370
'); ?>
371
</li>
372
+ <li><?php _e('<b>Facebook Group</b><br />You can find the ID of your Facebook <b>Group</b> from the URL, like so: <code>https://www.facebook.com/groups/<span class="cff-highlight">1234567890</span></code>'); ?></li>
373
</ul>
374
</div>
375
</td>
393
<tbody>
394
<h3><?php _e('Settings', 'custom-facebook-feed'); ?></h3>
395
396
+ <tr valign="top" class="cff-page-type">
397
+ <th scope="row"><label><?php _e('Is it a page or group?'); ?></label><code class="cff_shortcode"> pagetype
398
+ Eg: pagetype=group</code></th>
399
+ <td>
400
+ <select name="cff_page_type" id="cff_page_type" style="width: 100px;">
401
+ <option value="page" <?php if($cff_page_type_val == "page") echo 'selected="selected"' ?> ><?php _e('Page'); ?></option>
402
+ <option value="group" <?php if($cff_page_type_val == "group") echo 'selected="selected"' ?> ><?php _e('Group'); ?></option>
403
+ <option value="profile" <?php if($cff_page_type_val == "profile") echo 'selected="selected"' ?> ><?php _e('Profile'); ?></option>
404
+ </select>
405
+ <div class="cff-notice cff-profile-error cff-page-type">
406
+ <?php _e("<p>Due to Facebook's privacy policy you're not able to display posts from a personal profile, only from a public Facebook Page.</p><p>If you're using a profile to represent a business, organization, product, public figure or the like, then Facebook recommends <a href='http://www.facebook.com/help/175644189234902/' target='_blank'>converting your profile to a page</a>. There are many advantages to using pages over profiles, and once you've converted then the plugin will be able to successfully retrieve and display all of your posts.</p>", 'custom-facebook-feed'); ?>
407
+ </div>
408
+ </td>
409
+ </tr>
410
+
411
<tr valign="top">
412
<th scope="row"><label><?php _e('Show posts on my page by:', 'custom-facebook-feed'); ?></label><code class="cff_shortcode"> showpostsby
413
Eg: showpostsby=others</code></th>
417
<option value="others" <?php if($cff_show_others_val == 'others' || $cff_show_others_val == 'on') echo 'selected="selected"' ?> ><?php _e('Page owner + other people', 'custom-facebook-feed'); ?></option>
418
<option value="onlyothers" <?php if($cff_show_others_val == 'onlyothers') echo 'selected="selected"' ?> ><?php _e('Only other people', 'custom-facebook-feed'); ?></option>
419
</select>
420
</td>
421
</tr>
422
731
<?php
732
$cff_use_own_token = get_option( 'cff_show_access_token' );
733
$access_token = get_option( $access_token );
734
+ $posts_json = cff_fetchUrl("https://graph.facebook.com/".get_option( trim($page_id) )."/feed?access_token=". trim($access_token) ."&limit=1");
735
?>
736
737
<textarea readonly="readonly" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)." style="width: 70%; height: 500px; white-space: pre; font-family: Menlo,Monaco,monospace;">
738
## SITE/SERVER INFO: ##
4111
if ( get_transient( $transient ) !== 'waiting' && $notice_status !== 'dismissed' ) {
4112
add_action( 'admin_notices', 'cff_rating_notice_html' );
4113
}
4114
+ //Uncomment below to show notice
4115
+ // add_action( 'admin_notices', 'cff_rating_notice_html' );
4116
4117
?>
custom-facebook-feed.php CHANGED
@@ -1,9 +1,9 @@
1
<?php
2
/*
3
Plugin Name: Custom Facebook Feed
4
- Plugin URI: http://smashballoon.com/custom-facebook-feed
5
Description: Add completely customizable Facebook feeds to your WordPress site
6
- Version: 2.9.1
7
Author: Smash Balloon
8
Author URI: http://smashballoon.com/
9
License: GPLv2 or later
@@ -24,7 +24,7 @@ along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
*/
26
27
- define('CFFVER', '2.9.1');
28
29
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
30
//Include admin
@@ -696,9 +696,6 @@ function display_cff($atts) {
696
//If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field
697
get_option('cff_show_access_token') ? $cff_show_access_token = true : $cff_show_access_token = false;
698
699
- //If there's no Access Token then use a default
700
- if ($access_token == '' || !$cff_show_access_token) $access_token = '198080700214649|natEgdD5R82UoiLXL5UsUK82-O8';
701
-
702
//Check whether a Page ID has been defined
703
if ($page_id == '') {
704
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=YOUR_PAGE_ID_HERE].<br /><br />";
@@ -739,13 +736,11 @@ function display_cff($atts) {
739
740
//Show posts ONLY by others
741
if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) {
742
- $graph_query = 'feed';
743
$cff_show_only_others = true;
744
}
745
-
746
}
747
748
-
749
$cff_post_limit = $atts['limit'];
750
751
//If the limit isn't set then set it to be 7 more than the number of posts defined
@@ -886,7 +881,7 @@ function display_cff($atts) {
886
//ALL POSTS
887
if (!$cff_events_only){
888
889
- $cff_posts_json_url = 'https://graph.facebook.com/v3.3/' . $page_id . '/' . $graph_query . '?fields=id,from{picture,id,name,link},message,message_tags,story,story_tags,status_type,created_time,backdated_time,call_to_action,attachments{title,description,media_type,unshimmed_url,target{id},media{source}}&access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
890
891
if( $cff_show_access_token && strlen($access_token) > 130 ){
892
//If using a Page Access Token then set caching time to be minimum of 5 minutes
@@ -944,29 +939,20 @@ function display_cff($atts) {
944
$cff_content .= '<div class="cff-error-msg"><p>Unable to display Facebook posts.<br/><a href="javascript:void(0);" id="cff-show-error" onclick="cffShowError()">Show error</a>';
945
$cff_content .= '<script type="text/javascript">function cffShowError() { document.getElementById("cff-error-reason").style.display = "block"; document.getElementById("cff-show-error").style.display = "none"; }</script>';
946
$cff_content .= '</p><div id="cff-error-reason">';
947
948
- if( $cff_page_type == 'group' ){
949
-
950
- $cff_content .= 'Due to recent changes in the Facebook API it is unfortunately no longer possible to display posts from Facebook Groups. Please see <a href="https://smashballoon.com/facebook-api-changes-april-4-2018/" target="_blank">this page</a> for more information.';
951
-
952
- } else {
953
-
954
- if( isset($FBdata->error->message) ) $cff_content .= 'Error: ' . $FBdata->error->message;
955
- if( isset($FBdata->error->type) ) $cff_content .= '<br />Type: ' . $FBdata->error->type;
956
- if( isset($FBdata->error->code) ) $cff_content .= '<br />Code: ' . $FBdata->error->code;
957
- if( isset($FBdata->error->error_subcode) ) $cff_content .= '<br />Subcode: ' . $FBdata->error->error_subcode;
958
-
959
- if( isset($FBdata->error_msg) ) $cff_content .= 'Error: ' . $FBdata->error_msg;
960
- if( isset($FBdata->error_code) ) $cff_content .= '<br />Code: ' . $FBdata->error_code;
961
-
962
- if($FBdata == null) $cff_content .= 'Error: Server configuration issue';
963
-
964
- if( empty($FBdata->error) && empty($FBdata->error_msg) && $FBdata !== null ) $cff_content .= 'Error: No posts available for this Facebook ID';
965
966
- $cff_content .= '<br />Please refer to our <a href="https://smashballoon.com/custom-facebook-feed/docs/errors/" target="_blank">Error Message Reference</a>.';
967
968
- }
969
-
970
971
$cff_content .= '</div></div>'; //End .cff-error-msg and #cff-error-reason
972
//Only display errors to admins
@@ -1056,14 +1042,6 @@ function display_cff($atts) {
1056
break;
1057
}
1058
1059
- //ONLY show posts by others
1060
- if ( $cff_show_only_others ) {
1061
- //If the post author's ID is the same as the page ID then don't show the post
1062
- if( isset($news->from) ){
1063
- if ( $numeric_page_id == $news->from->id ) $cff_show_post = false;
1064
- }
1065
- }
1066
-
1067
//Is it a duplicate post?
1068
if (!isset($prev_post_message)) $prev_post_message = '';
1069
if (!isset($prev_post_link)) $prev_post_link = '';
@@ -1127,44 +1105,10 @@ function display_cff($atts) {
1127
1128
//Is it an album?
1129
$cff_album = false;
1130
- $num_photos = 0;
1131
-
1132
if( isset($news->status_type) ){
1133
if( $news->status_type == 'added_photos' ){
1134
- //Check 'story' to see whether it contains a number
1135
- (isset($news->story)) ? $str = $news->story : $str = '';
1136
-
1137
- //Only matches number with a space after them
1138
- preg_match('!\d+ !', $str, $matches);
1139
-
1140
-
1141
- (isset($matches[0])) ? $num_photos = $matches[0] : $num_photos = 0;
1142
-
1143
- //If the story contains a number...
1144
- if ( $num_photos > 1 ) {
1145
-
1146
- //... and the link is to an album then it most likely has photo attachments
1147
- $albumLinkArr1 = explode('photos/a.', $link);
1148
- if( isset($albumLinkArr1[1]) ) $albumLinkArr2 = explode('.', $albumLinkArr1[1]);
1149
-
1150
- //If it has an album link then set the post type to be album
1151
- if( isset($albumLinkArr1[1]) ){
1152
-
1153
- $cff_album = true;
1154
-
1155
- //Change the Post ID to be to the post about adding photos to the album
1156
- $cff_post_id = $PostID[0] . '_' . $albumLinkArr2[0];
1157
-
1158
- //Link to the album instead of the photo
1159
- $album_link = str_replace('photo.php?','media/set/?',$link);
1160
- $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
1161
-
1162
- //If the album link is a new format then link it to the post
1163
- $album_link_check = 'media/set/?';
1164
- if( stripos($album_link, $album_link_check) !== true ) $album_link = $link;
1165
-
1166
- }
1167
-
1168
}
1169
}
1170
}
@@ -1879,9 +1823,9 @@ function display_cff($atts) {
1879
1880
$cff_media_link = '';
1881
1882
- if( $cff_show_media_link && ($cff_post_type == 'photo' || $cff_post_type == 'video') ){
1883
$cff_media_link .= '<p class="cff-media-link"><a href="'.$link.'" '.$target.' style="color: #'.$cff_posttext_link_color.';"><span style="padding-right: 5px;" class="fa fas fa-';
1884
- if($cff_post_type == 'photo') $cff_media_link .= 'picture-o fa-image" aria-hidden="true"></span>'. $cff_translate_photo_text;
1885
// if($cff_post_type == 'video') $cff_media_link .= 'file-video-o';
1886
if($cff_post_type == 'video') $cff_media_link .= 'video-camera fa-video" aria-hidden="true"></span>'. $cff_translate_video_text;
1887
$cff_media_link .= '</a></p>';
1
<?php
2
/*
3
Plugin Name: Custom Facebook Feed
4
+ Plugin URI: https://smashballoon.com/custom-facebook-feed
5
Description: Add completely customizable Facebook feeds to your WordPress site
6
+ Version: 2.10
7
Author: Smash Balloon
8
Author URI: http://smashballoon.com/
9
License: GPLv2 or later
24
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
*/
26
27
+ define('CFFVER', '2.10');
28
29
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
30
//Include admin
696
//If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field
697
get_option('cff_show_access_token') ? $cff_show_access_token = true : $cff_show_access_token = false;
698
699
//Check whether a Page ID has been defined
700
if ($page_id == '') {
701
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=YOUR_PAGE_ID_HERE].<br /><br />";
736
737
//Show posts ONLY by others
738
if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) {
739
+ $graph_query = 'visitor_posts';
740
$cff_show_only_others = true;
741
}
742
}
743
744
$cff_post_limit = $atts['limit'];
745
746
//If the limit isn't set then set it to be 7 more than the number of posts defined
881
//ALL POSTS
882
if (!$cff_events_only){
883
884
+ $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $page_id . '/' . $graph_query . '?fields=id,from{picture,id,name,link},message,message_tags,story,story_tags,status_type,created_time,backdated_time,call_to_action,attachments{title,description,media_type,unshimmed_url,target{id},media{source}}&access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
885
886
if( $cff_show_access_token && strlen($access_token) > 130 ){
887
//If using a Page Access Token then set caching time to be minimum of 5 minutes
939
$cff_content .= '<div class="cff-error-msg"><p>Unable to display Facebook posts.<br/><a href="javascript:void(0);" id="cff-show-error" onclick="cffShowError()">Show error</a>';
940
$cff_content .= '<script type="text/javascript">function cffShowError() { document.getElementById("cff-error-reason").style.display = "block"; document.getElementById("cff-show-error").style.display = "none"; }</script>';
941
$cff_content .= '</p><div id="cff-error-reason">';
942
+
943
+ if( isset($FBdata->error->message) ) $cff_content .= 'Error: ' . $FBdata->error->message;
944
+ if( isset($FBdata->error->type) ) $cff_content .= '<br />Type: ' . $FBdata->error->type;
945
+ if( isset($FBdata->error->code) ) $cff_content .= '<br />Code: ' . $FBdata->error->code;
946
+ if( isset($FBdata->error->error_subcode) ) $cff_content .= '<br />Subcode: ' . $FBdata->error->error_subcode;
947
948
+ if( isset($FBdata->error_msg) ) $cff_content .= 'Error: ' . $FBdata->error_msg;
949
+ if( isset($FBdata->error_code) ) $cff_content .= '<br />Code: ' . $FBdata->error_code;
950
+
951
+ if($FBdata == null) $cff_content .= 'Error: Server configuration issue';
952
953
+ if( empty($FBdata->error) && empty($FBdata->error_msg) && $FBdata !== null ) $cff_content .= 'Error: No posts available for this Facebook ID';
954
955
+ $cff_content .= '<br />Please refer to our <a href="https://smashballoon.com/custom-facebook-feed/docs/errors/" target="_blank">Error Message Reference</a>.';
956
957
$cff_content .= '</div></div>'; //End .cff-error-msg and #cff-error-reason
958
//Only display errors to admins
1042
break;
1043
}
1044
1045
//Is it a duplicate post?
1046
if (!isset($prev_post_message)) $prev_post_message = '';
1047
if (!isset($prev_post_link)) $prev_post_link = '';
1105
1106
//Is it an album?
1107
$cff_album = false;
1108
if( isset($news->status_type) ){
1109
if( $news->status_type == 'added_photos' ){
1110
+ if( isset($news->attachments) ){
1111
+ if( $news->attachments->data[0]->media_type == 'album' ) $cff_album = true;
1112
}
1113
}
1114
}
1823
1824
$cff_media_link = '';
1825
1826
+ if( $cff_show_media_link && ($cff_post_type == 'photo' || $cff_post_type == 'video' || $cff_album) ){
1827
$cff_media_link .= '<p class="cff-media-link"><a href="'.$link.'" '.$target.' style="color: #'.$cff_posttext_link_color.';"><span style="padding-right: 5px;" class="fa fas fa-';
1828
+ if($cff_post_type == 'photo' || $cff_album) $cff_media_link .= 'picture-o fa-image" aria-hidden="true"></span>'. $cff_translate_photo_text;
1829
// if($cff_post_type == 'video') $cff_media_link .= 'file-video-o';
1830
if($cff_post_type == 'video') $cff_media_link .= 'video-camera fa-video" aria-hidden="true"></span>'. $cff_translate_video_text;
1831
$cff_media_link .= '</a></p>';
img/group-app.png ADDED
Binary file
js/cff-admin-scripts.js CHANGED
@@ -91,21 +91,7 @@ jQuery(document).ready(function($) {
91
//Show the JSON
92
jQuery('#cff-api-test-result textarea').css('display', 'block');
93
});
94
-
95
-
96
- //If 'Others only' is selected then show a note
97
- var $cffOthersOnly = jQuery('#cff-others-only');
98
-
99
- if ( jQuery("#cff_show_others option:selected").val() == 'onlyothers' ) $cffOthersOnly.show();
100
101
- jQuery("#cff_show_others").change(function() {
102
- if ( jQuery("#cff_show_others option:selected").val() == 'onlyothers' ) {
103
- $cffOthersOnly.show();
104
- } else {
105
- $cffOthersOnly.hide();
106
- }
107
- });
108
-
109
110
//If '__ days ago' date is selected then show 'Translate this'
111
var $cffTranslateDate = jQuery('#cff-translate-date');
@@ -216,17 +202,20 @@ jQuery(document).ready(function($) {
216
$('#cff_admin_cancel_btn').on('click', function(){
217
$('#cff_fb_login_modal').hide();
218
});
219
- $('.cff-modal-close').on('click', function(){
220
$('.cff_modal_tokens').hide();
221
});
222
$('#cff_fb_show_tokens').on('click', function(){
223
- $('.cff_modal_tokens').show();
224
});
225
226
//Select a page for token
227
$('.cff-managed-page').on('click', function(){
228
$('#cff-insert-token, .cff-insert-reviews-token, .cff-insert-both-tokens').removeAttr('disabled');
229
230
$(this).siblings().removeClass('cff-page-selected');
231
$(this).addClass('cff-page-selected');
232
});
@@ -235,7 +224,30 @@ jQuery(document).ready(function($) {
235
$('#cff-insert-token').on('click', function(){
236
$('#cff_access_token').val( $('.cff-page-selected').attr('data-token') ).addClass('cff-success');
237
if( $('#cff_page_id').val().trim() == '' ) $('#cff_page_id').val( $('.cff-page-selected').attr('data-page-id') );
238
- $('.cff_modal_tokens').hide();
239
240
location.hash = "cffnomodal";
241
});
@@ -245,6 +257,17 @@ jQuery(document).ready(function($) {
245
$('.cff_modal_tokens').removeClass('cffnomodal');
246
}
247
248
//Load the admin share widgets
249
$('#cff-admin-show-share-links').on('click', function(){
250
$(this).fadeOut();
@@ -255,4 +278,16 @@ jQuery(document).ready(function($) {
255
}, 500);
256
});
257
258
});
91
//Show the JSON
92
jQuery('#cff-api-test-result textarea').css('display', 'block');
93
});
94
95
96
//If '__ days ago' date is selected then show 'Translate this'
97
var $cffTranslateDate = jQuery('#cff-translate-date');
202
$('#cff_admin_cancel_btn').on('click', function(){
203
$('#cff_fb_login_modal').hide();
204
});
205
+ $('.cff-modal-close, #cff-close-modal-primary-button').on('click', function(){
206
$('.cff_modal_tokens').hide();
207
});
208
$('#cff_fb_show_tokens').on('click', function(){
209
+ $('.cff_modal_tokens, .cff-groups-list').show();
210
+ $('#cff-group-installation').hide();
211
});
212
213
//Select a page for token
214
$('.cff-managed-page').on('click', function(){
215
$('#cff-insert-token, .cff-insert-reviews-token, .cff-insert-both-tokens').removeAttr('disabled');
216
217
+ $('#cff_token_expiration_note').show();
218
+
219
$(this).siblings().removeClass('cff-page-selected');
220
$(this).addClass('cff-page-selected');
221
});
224
$('#cff-insert-token').on('click', function(){
225
$('#cff_access_token').val( $('.cff-page-selected').attr('data-token') ).addClass('cff-success');
226
if( $('#cff_page_id').val().trim() == '' ) $('#cff_page_id').val( $('.cff-page-selected').attr('data-page-id') );
227
+
228
+ if( $(this).hasClass('cff-group-btn') ){
229
+ $('.cff-groups-list').hide();
230
+ $('#cff-group-installation').show();
231
+
232
+ //Show directions for either group admin or member
233
+ if( $('.cff-page-selected').hasClass('cff-group-admin') ){
234
+ $('#cff-group-admin-directions').show();
235
+ $('#cff-group-member-directions').hide();
236
+ } else {
237
+ $('#cff-group-admin-directions').hide();
238
+ $('#cff-group-member-directions').show();
239
+ }
240
+
241
+ //Change page type to be group
242
+ $('#cff_page_type').val('group');
243
+ $('.cff-page-options').hide();
244
+
245
+ //Dynamically create group edit link
246
+ var cffGroupEditLink = 'https://facebook.com/groups/'+$('.cff-page-selected').attr('data-page-id')+'/edit';
247
+ $('#cff-group-installation #cff-group-edit').attr('href', cffGroupEditLink);
248
+ } else {
249
+ $('.cff_modal_tokens').hide();
250
+ }
251
252
location.hash = "cffnomodal";
253
});
257
$('.cff_modal_tokens').removeClass('cffnomodal');
258
}
259
260
+ //Switch Page/Group app button in modal
261
+ jQuery("#cff_login_type").change(function() {
262
+ if ( jQuery("#cff_login_type option:selected").val() == 'group' ) {
263
+ jQuery('#cff_page_app').hide();
264
+ jQuery('#cff_group_app').css('display', 'inline-block');
265
+ } else {
266
+ jQuery('#cff_page_app').css('display', 'inline-block');
267
+ jQuery('#cff_group_app').hide();
268
+ }
269
+ });
270
+
271
//Load the admin share widgets
272
$('#cff-admin-show-share-links').on('click', function(){
273
$(this).fadeOut();
278
}, 500);
279
});
280
281
+ //Group app setup screenshot
282
+ jQuery('#cff-group-app-tooltip').hover(function(){
283
+ jQuery('#cff-group-app-screenshot').fadeIn(100);
284
+ }, function(){
285
+ jQuery('#cff-group-app-screenshot').fadeOut(100);
286
+ });
287
+
288
+ //Remove any duplicate groups
289
+ jQuery('.cff-group-admin').each(function(){
290
+ jQuery('.cff-groups-list #' + jQuery(this).attr('id') ).eq(1).hide();
291
+ });
292
+
293
});