Custom Facebook Feed - Version 2.12.1

Version Description

  • Fix: Fixed an issue with post date timezones due to changes in the WordPress 5.3 update
  • Fix: Fixed a rare issue where a JavaScript error would occur in the WordPress admin if a Facebook account was manually connected and the Page ID used was the full URL
  • Fix: Fixed a JavaScript error in the admin when using older web browsers
  • Tweak: Improved the manual account connection process
  • Tweak: Some minor UI tweaks to match the new WordPress 5.3 UI style
Download this release

Release Info

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

Code changes from version 1.12.1 to 2.12.1

README.txt CHANGED
@@ -256,6 +256,7 @@ The most common reason for this is that an add-on or extension you have installe
256
257
== Changelog ==
258
= 2.12.1 =
259
* Fix: Fixed a rare issue where a JavaScript error would occur in the WordPress admin if a Facebook account was manually connected and the Page ID used was the full URL
260
* Fix: Fixed a JavaScript error in the admin when using older web browsers
261
* Tweak: Improved the manual account connection process
256
257
== Changelog ==
258
= 2.12.1 =
259
+ * Fix: Fixed an issue with post date timezones due to changes in the WordPress 5.3 update
260
* Fix: Fixed a rare issue where a JavaScript error would occur in the WordPress admin if a Facebook account was manually connected and the Page ID used was the full URL
261
* Fix: Fixed a JavaScript error in the admin when using older web browsers
262
* Tweak: Improved the manual account connection process
custom-facebook-feed-admin.php CHANGED
@@ -423,7 +423,7 @@ function cff_settings_page() {
423
<label for="cff_manual_account_id"><span class="cff_page"><?php _e('Page'); ?></span><span class="cff_group"><?php _e('Group'); ?></span> <?php _e('ID'); ?></label>
424
<input name="cff_manual_account_id" id="cff_manual_account_id" type="text" value="" placeholder="Eg: 1234567890123 or smashballoon" />
425
<a class="cff-tooltip-link" href="JavaScript:void(0);"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
426
- <p class="cff-tooltip cff-more-info"><?php _e('The ID of the Facebook'); ?> <span class="cff_page"><?php _e('Page'); ?></span><span class="cff_group"><?php _e('Group'); ?></span> <?php _e('you want to add.'); ?> &nbsp;<a href='https://smashballoon.com/custom-facebook-feed/id/'><?php _e("How do I find my Page ID?"); ?></a></p>
427
</div>
428
429
<div>
423
<label for="cff_manual_account_id"><span class="cff_page"><?php _e('Page'); ?></span><span class="cff_group"><?php _e('Group'); ?></span> <?php _e('ID'); ?></label>
424
<input name="cff_manual_account_id" id="cff_manual_account_id" type="text" value="" placeholder="Eg: 1234567890123 or smashballoon" />
425
<a class="cff-tooltip-link" href="JavaScript:void(0);"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
426
+ <p class="cff-tooltip cff-more-info"><?php _e('The ID of the Facebook'); ?> <span class="cff_page"><?php _e('Page'); ?></span><span class="cff_group"><?php _e('Group'); ?></span> <?php _e('you want to add.'); ?> &nbsp;<a href='https://smashballoon.com/custom-facebook-feed/id/' target='_blank'><?php _e("How do I find my Page ID?"); ?></a></p>
427
</div>
428
429
<div>
custom-facebook-feed.php CHANGED
@@ -530,10 +530,9 @@ function display_cff($atts) {
530
531
$cff_date_before = isset($options[ 'cff_date_before' ]) ? $options[ 'cff_date_before' ] : '';
532
$cff_date_after = isset($options[ 'cff_date_after' ]) ? $options[ 'cff_date_after' ] : '';
533
- //Set user's timezone based on setting
534
$cff_timezone = $atts['timezone'];
535
- $cff_orig_timezone = date_default_timezone_get();
536
- date_default_timezone_set($cff_timezone);
537
538
//Posted ago strings
539
$cff_date_translate_strings = array(
@@ -1261,7 +1260,7 @@ function display_cff($atts) {
1261
isset($news->created_time) ? $post_time = $news->created_time : $post_time = '';
1262
if( isset($news->backdated_time) ) $post_time = $news->backdated_time; //If the post is backdated then use that as the date instead
1263
1264
- $cff_date = '<p class="cff-date" '.$cff_date_styles.'>'. $cff_date_before . ' ' . cff_getdate(strtotime($post_time), $cff_date_formatting, $cff_date_custom, $cff_date_translate_strings) . ' ' . $cff_date_after;
1265
if($cff_date_position == 'below' || (!$cff_show_author && $cff_date_position == 'author') ) $cff_date .= '<span class="cff-date-dot">&nbsp;&middot;&nbsp;&nbsp;</span>';
1266
$cff_date .= '</p>';
1267
@@ -2044,8 +2043,6 @@ function display_cff($atts) {
2044
$p++;
2045
}
2046
2047
- //Reset the timezone
2048
- date_default_timezone_set( $cff_orig_timezone );
2049
//Add the Like Box inside
2050
if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
2051
/* Credit link */
@@ -2165,46 +2162,59 @@ function cff_wrap_span_callback($matches) {
2165
return "<span class='cff-break-word'>$url_short</span>";
2166
}
2167
2168
- //2013-04-28T21:06:56+0000
2169
//Time stamp function - used for posts
2170
- function cff_getdate($original, $date_format, $custom_date, $cff_date_translate_strings) {
2171
switch ($date_format) {
2172
2173
case '2':
2174
- $print = date_i18n('F jS, g:i a', $original);
2175
break;
2176
case '3':
2177
- $print = date_i18n('F jS', $original);
2178
break;
2179
case '4':
2180
- $print = date_i18n('D F jS', $original);
2181
break;
2182
case '5':
2183
- $print = date_i18n('l F jS', $original);
2184
break;
2185
case '6':
2186
- $print = date_i18n('D M jS, Y', $original);
2187
break;
2188
case '7':
2189
- $print = date_i18n('l F jS, Y', $original);
2190
break;
2191
case '8':
2192
- $print = date_i18n('l F jS, Y - g:i a', $original);
2193
break;
2194
case '9':
2195
- $print = date_i18n("l M jS, 'y", $original);
2196
break;
2197
case '10':
2198
- $print = date_i18n('m.d.y', $original);
2199
break;
2200
case '11':
2201
- $print = date_i18n('m/d/y', $original);
2202
break;
2203
case '12':
2204
- $print = date_i18n('d.m.y', $original);
2205
break;
2206
case '13':
2207
- $print = date_i18n('d/m/y', $original);
2208
break;
2209
default:
2210
@@ -2254,7 +2264,7 @@ function cff_getdate($original, $date_format, $custom_date, $cff_date_translate_
2254
2255
}
2256
if ( !empty($custom_date) ){
2257
- $print = date_i18n($custom_date, $original);
2258
}
2259
2260
return $print;
530
531
$cff_date_before = isset($options[ 'cff_date_before' ]) ? $options[ 'cff_date_before' ] : '';
532
$cff_date_after = isset($options[ 'cff_date_after' ]) ? $options[ 'cff_date_after' ] : '';
533
+
534
+ //Timezone. The post date is adjusted by the timezone offset in the cff_getdate function.
535
$cff_timezone = $atts['timezone'];
536
537
//Posted ago strings
538
$cff_date_translate_strings = array(
1260
isset($news->created_time) ? $post_time = $news->created_time : $post_time = '';
1261
if( isset($news->backdated_time) ) $post_time = $news->backdated_time; //If the post is backdated then use that as the date instead
1262
1263
+ $cff_date = '<p class="cff-date" '.$cff_date_styles.'>'. $cff_date_before . ' ' . cff_getdate(strtotime($post_time), $cff_date_formatting, $cff_date_custom, $cff_date_translate_strings, $cff_timezone) . ' ' . $cff_date_after;
1264
if($cff_date_position == 'below' || (!$cff_show_author && $cff_date_position == 'author') ) $cff_date .= '<span class="cff-date-dot">&nbsp;&middot;&nbsp;&nbsp;</span>';
1265
$cff_date .= '</p>';
1266
2043
$p++;
2044
}
2045
2046
//Add the Like Box inside
2047
if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
2048
/* Credit link */
2162
return "<span class='cff-break-word'>$url_short</span>";
2163
}
2164
2165
+ //Use the timezone to offset the date as all post dates are in UTC +0000
2166
+ function cff_set_timezone($original, $cff_timezone){
2167
+ $cff_date_time = new DateTime(date('m/d g:i a'), new DateTimeZone('UTC'));
2168
+ $cff_date_time->setTimeZone(new DateTimeZone($cff_timezone));
2169
+ $cff_date_time_offset = $cff_date_time->getOffset();
2170
+
2171
+ $original = $original + $cff_date_time_offset;
2172
+
2173
+ return $original;
2174
+ }
2175
//Time stamp function - used for posts
2176
+ function cff_getdate($original, $date_format, $custom_date, $cff_date_translate_strings, $cff_timezone) {
2177
+
2178
+ //Offset the date by the timezone
2179
+ $new_time = cff_set_timezone($original, $cff_timezone);
2180
+
2181
switch ($date_format) {
2182
2183
case '2':
2184
+ $print = date_i18n('F jS, g:i a', $new_time);
2185
break;
2186
case '3':
2187
+ $print = date_i18n('F jS', $new_time);
2188
break;
2189
case '4':
2190
+ $print = date_i18n('D F jS', $new_time);
2191
break;
2192
case '5':
2193
+ $print = date_i18n('l F jS', $new_time);
2194
break;
2195
case '6':
2196
+ $print = date_i18n('D M jS, Y', $new_time);
2197
break;
2198
case '7':
2199
+ $print = date_i18n('l F jS, Y', $new_time);
2200
break;
2201
case '8':
2202
+ $print = date_i18n('l F jS, Y - g:i a', $new_time);
2203
break;
2204
case '9':
2205
+ $print = date_i18n("l M jS, 'y", $new_time);
2206
break;
2207
case '10':
2208
+ $print = date_i18n('m.d.y', $new_time);
2209
break;
2210
case '11':
2211
+ $print = date_i18n('m/d/y', $new_time);
2212
break;
2213
case '12':
2214
+ $print = date_i18n('d.m.y', $new_time);
2215
break;
2216
case '13':
2217
+ $print = date_i18n('d/m/y', $new_time);
2218
break;
2219
default:
2220
2264
2265
}
2266
if ( !empty($custom_date) ){
2267
+ $print = date_i18n($custom_date, $new_time);
2268
}
2269
2270
return $print;
js/cff-admin-scripts.js CHANGED
@@ -634,10 +634,17 @@ jQuery(document).ready(function($) {
634
635
if( cff_current_page_id_arr.length > 1 ){
636
for (var i = 0; i < cff_current_page_id_arr.length; i++) {
637
- cffLabelAsPrimary( $('#cff_connected_account_' + cffStripURLParts(cff_current_page_id_arr[i].trim()) ), true );
638
}
639
} else {
640
- cffLabelAsPrimary( $('#cff_connected_account_' + cffStripURLParts(cff_current_page_id) ), true );
641
}
642
643
//Show the modal by default, but hide if the "cffnomodal" class is added to prevent it showing after saving settings
634
635
if( cff_current_page_id_arr.length > 1 ){
636
for (var i = 0; i < cff_current_page_id_arr.length; i++) {
637
+ cffLabelAsPrimary( $('#cff_connected_account_' + cffValidateID( cff_current_page_id_arr[i] ) ), true );
638
}
639
} else {
640
+ cffLabelAsPrimary( $('#cff_connected_account_' + cffValidateID( cff_current_page_id ) ), true );
641
+ }
642
+ //Make sure ID is a valid string
643
+ function cffValidateID(id){
644
+ //Remove slashes from end
645
+ id = cffStripURLParts( id.replace(/\/#x2F;, "").trim() );
646
+ //Only return if it contains numbers/letters
647
+ if( id.match("^[A-Za-z0-9]+quot;) ) return id;
648
}
649
650
//Show the modal by default, but hide if the "cffnomodal" class is added to prevent it showing after saving settings