Version Description
- Tweak: The Facebook app used to connect groups has changed. If you are using a Facebook group feed, then please reconnect your group accounts using the new app when convenient to prevent any future issues. When reconnecting, follow the included directions on how to add the new app to your group settings.
- Tweak: All Facebook data is now encrypted in your WordPress database.
- Tweak: Access Tokens are no longer able to be viewed on the settings page.
- Fix: Manually connecting an account while on the "Settings" page would not work.
- Fix: Fixed a PHP error when a string was used for the cache time setting.
Download this release
Release Info
Developer | smashballoon |
Plugin | Custom Facebook Feed |
Version | 4.1 |
Comparing to | |
See all releases |
Code changes from version 4.0.5 to 4.1
- README.txt +13 -1
- admin/admin-functions.php +11 -0
- admin/assets/css/settings.css +10 -2
- admin/assets/img/group-app.png +0 -0
- admin/assets/js/oembeds.js +2 -3
- admin/assets/js/settings.js +38 -1
- admin/builder/assets/css/global.css +1 -1
- admin/builder/assets/js/add-source.js +1 -2
- admin/builder/templates/form-data-examples.html +1 -4
- admin/builder/templates/sections/popup/add-source-popup.php +6 -2
- admin/views/settings/tab/advanced.php +14 -0
- admin/views/settings/tab/general.php +9 -7
- custom-facebook-feed.php +4 -3
- inc/Admin/CFF_Global_Settings.php +24 -0
- inc/Admin/CFF_Notifications.php +21 -1
- inc/Admin/CFF_Support.php +3 -1
- inc/Admin/CFF_oEmbeds.php +6 -1
- inc/Builder/CFF_Db.php +35 -5
- inc/Builder/CFF_Feed_Builder.php +10 -5
- inc/Builder/CFF_Feed_Saver.php +16 -10
- inc/Builder/CFF_Feed_Saver_Manager.php +1 -0
- inc/Builder/CFF_Source.php +66 -8
- inc/Builder/Controls/CFF_Customview_Control.php +0 -5
- inc/CFF_Cache.php +65 -13
- inc/CFF_Error_Reporter.php +6 -0
- inc/CFF_FB_Settings.php +3 -0
- inc/CFF_Group_Posts.php +12 -6
- inc/CFF_Oembed.php +12 -1
- inc/CFF_Shortcode.php +18 -7
- inc/CFF_Utils.php +6 -0
- inc/Custom_Facebook_Feed.php +31 -0
- inc/SB_Facebook_Data_Encryption.php +189 -0
- inc/SB_Facebook_Data_Manager.php +539 -0
README.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: Facebook, Facebook feed, Facebook posts, Facebook group, Facebook page
|
|
4 |
Â
Requires at least: 4.1
|
5 |
Â
Requires PHP: 5.6
|
6 |
Â
Tested up to: 5.8
|
7 |
-
Stable tag: 4.
|
8 |
Â
License: GPLv2 or later
|
9 |
Â
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Â
|
@@ -262,6 +262,13 @@ The most common reason for this is that an add-on or extension you have installe
|
|
262 |
Â
9. It's super easy to display your Facebook feed in any page or post
|
263 |
Â
|
264 |
Â
== Changelog ==
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
265 |
Â
= 4.0.5 =
|
266 |
Â
* Fix: Fixed an issue that was causing the "All Feeds" page to be inaccessible to some users.
|
267 |
Â
|
@@ -270,6 +277,11 @@ The most common reason for this is that an add-on or extension you have installe
|
|
270 |
Â
* Fix: If a feed name contained an apostrophe then additional slashes were being added each time settings were saved.
|
271 |
Â
* Tweak: An alert bubble is added to the Facebook Feed menu item when there are new notifications available.
|
272 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
273 |
Â
= 4.0.3 =
|
274 |
Â
* Fix: Added additional plugin hardening.
|
275 |
Â
|
4 |
Â
Requires at least: 4.1
|
5 |
Â
Requires PHP: 5.6
|
6 |
Â
Tested up to: 5.8
|
7 |
+
Stable tag: 4.1
|
8 |
Â
License: GPLv2 or later
|
9 |
Â
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Â
|
262 |
Â
9. It's super easy to display your Facebook feed in any page or post
|
263 |
Â
|
264 |
Â
== Changelog ==
|
265 |
+
= 4.1 =
|
266 |
+
* Tweak: The Facebook app used to connect groups has changed. If you are using a Facebook group feed, then please reconnect your group accounts using the new app when convenient to prevent any future issues. When reconnecting, follow the included directions on how to add the new app to your group settings.
|
267 |
+
* Tweak: All Facebook data is now encrypted in your WordPress database.
|
268 |
+
* Tweak: Access Tokens are no longer able to be viewed on the settings page.
|
269 |
+
* Fix: Manually connecting an account while on the "Settings" page would not work.
|
270 |
+
* Fix: Fixed a PHP error when a string was used for the cache time setting.
|
271 |
+
|
272 |
Â
= 4.0.5 =
|
273 |
Â
* Fix: Fixed an issue that was causing the "All Feeds" page to be inaccessible to some users.
|
274 |
Â
|
277 |
Â
* Fix: If a feed name contained an apostrophe then additional slashes were being added each time settings were saved.
|
278 |
Â
* Tweak: An alert bubble is added to the Facebook Feed menu item when there are new notifications available.
|
279 |
Â
|
280 |
+
= 4.0.4 =
|
281 |
+
* Fix: The call-to-action in the Like Box widget would not display properly at certain window widths in some browsers.
|
282 |
+
* Fix: If a feed name contained an apostrophe then additional slashes were being added each time settings were saved.
|
283 |
+
* Tweak: An alert bubble is added to the Facebook Feed menu item when there are new notifications available.
|
284 |
+
|
285 |
Â
= 4.0.3 =
|
286 |
Â
* Fix: Added additional plugin hardening.
|
287 |
Â
|
admin/admin-functions.php
CHANGED
@@ -3,6 +3,7 @@ use CustomFacebookFeed\CFF_Utils;
|
|
3 |
Â
use CustomFacebookFeed\CFF_Oembed;
|
4 |
Â
use CustomFacebookFeed\CFF_GDPR_Integrations;
|
5 |
Â
use CustomFacebookFeed\CFF_Feed_Locator;
|
Â
|
|
6 |
Â
|
7 |
Â
add_action('group_post_scheduler_cron', 'cff_group_cache_function');
|
8 |
Â
function cff_group_cache_function(){
|
@@ -5595,3 +5596,13 @@ function cff_check_custom_css() {
|
|
5595 |
Â
cff_transfer_css( $custom_css );
|
5596 |
Â
}
|
5597 |
Â
add_action( 'init', 'cff_check_custom_css' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
3 |
Â
use CustomFacebookFeed\CFF_Oembed;
|
4 |
Â
use CustomFacebookFeed\CFF_GDPR_Integrations;
|
5 |
Â
use CustomFacebookFeed\CFF_Feed_Locator;
|
6 |
+
use CustomFacebookFeed\SB_Facebook_Data_Manager;
|
7 |
Â
|
8 |
Â
add_action('group_post_scheduler_cron', 'cff_group_cache_function');
|
9 |
Â
function cff_group_cache_function(){
|
5596 |
Â
cff_transfer_css( $custom_css );
|
5597 |
Â
}
|
5598 |
Â
add_action( 'init', 'cff_check_custom_css' );
|
5599 |
+
|
5600 |
+
function cff_doing_openssl() {
|
5601 |
+
return extension_loaded( 'openssl' );
|
5602 |
+
}
|
5603 |
+
function cff_delete_all_platform_data(){
|
5604 |
+
$manager = new SB_Facebook_Data_Manager();
|
5605 |
+
$manager->delete_caches();
|
5606 |
+
\cff_main()->cff_error_reporter->add_action_log( 'Deleted all platform data.' );
|
5607 |
+
\cff_main()->cff_error_reporter->reset_api_errors();
|
5608 |
+
}
|
admin/assets/css/settings.css
CHANGED
@@ -1010,13 +1010,21 @@
|
|
1010 |
Â
}
|
1011 |
Â
|
1012 |
Â
.sb-tab-box.sb-caching-box .cff-caching-btn .loading path,
|
1013 |
-
.sb-tab-box.sb-optimize-box .optimize-image-btn .loading path
|
Â
|
|
1014 |
Â
fill: rgb(23 22 22 / 95%)
|
1015 |
Â
}
|
1016 |
Â
.sb-tab-box.sb-caching-box .cff-caching-btn .success svg,
|
1017 |
-
.sb-tab-box.sb-optimize-box .optimize-image-btn .success svg
|
Â
|
|
1018 |
Â
stroke: rgb(23 22 22 / 95%)
|
1019 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1020 |
Â
.sb-tab-box.sb-caching-box .cff-caching-btn:disabled path,
|
1021 |
Â
.sb-tab-box.sb-caching-box .optimize-image-btn:disabled path {
|
1022 |
Â
fill: #8C8F9A;
|
1010 |
Â
}
|
1011 |
Â
|
1012 |
Â
.sb-tab-box.sb-caching-box .cff-caching-btn .loading path,
|
1013 |
+
.sb-tab-box.sb-optimize-box .optimize-image-btn .loading path,
|
1014 |
+
.sb-tab-box.sb-dpa-clear-box-style .loading path {
|
1015 |
Â
fill: rgb(23 22 22 / 95%)
|
1016 |
Â
}
|
1017 |
Â
.sb-tab-box.sb-caching-box .cff-caching-btn .success svg,
|
1018 |
+
.sb-tab-box.sb-optimize-box .optimize-image-btn .success svg,
|
1019 |
+
.sb-tab-box.sb-dpa-clear-box-style .success svg {
|
1020 |
Â
stroke: rgb(23 22 22 / 95%)
|
1021 |
Â
}
|
1022 |
+
|
1023 |
+
.sb-tab-content .sb-tab-box.sb-dpa-clear-box-style .cff-tab-form-field .cff-btn {
|
1024 |
+
transform: none;
|
1025 |
+
margin-bottom: 15px;
|
1026 |
+
}
|
1027 |
+
|
1028 |
Â
.sb-tab-box.sb-caching-box .cff-caching-btn:disabled path,
|
1029 |
Â
.sb-tab-box.sb-caching-box .optimize-image-btn:disabled path {
|
1030 |
Â
fill: #8C8F9A;
|
admin/assets/img/group-app.png
CHANGED
Binary file
|
admin/assets/js/oembeds.js
CHANGED
@@ -67,7 +67,6 @@ var cffoEmbeds = new Vue({
|
|
67 |
Â
})
|
68 |
Â
.then(response => response.json())
|
69 |
Â
.then(data => {
|
70 |
-
console.log(data);
|
71 |
Â
if( data.success == false ) {
|
72 |
Â
this.installerStatus = 'error'
|
73 |
Â
}
|
@@ -160,7 +159,7 @@ var cffoEmbeds = new Vue({
|
|
160 |
Â
|
161 |
Â
/**
|
162 |
Â
* Toggle Sticky Widget view
|
163 |
-
*
|
164 |
Â
* @since 4.0
|
165 |
Â
*/
|
166 |
Â
toggleStickyWidget: function() {
|
@@ -175,4 +174,4 @@ var cffoEmbeds = new Vue({
|
|
175 |
Â
this.instagramInstallBtnText = this.modal.activate;
|
176 |
Â
}
|
177 |
Â
}
|
178 |
-
})
|
67 |
Â
})
|
68 |
Â
.then(response => response.json())
|
69 |
Â
.then(data => {
|
Â
|
|
70 |
Â
if( data.success == false ) {
|
71 |
Â
this.installerStatus = 'error'
|
72 |
Â
}
|
159 |
Â
|
160 |
Â
/**
|
161 |
Â
* Toggle Sticky Widget view
|
162 |
+
*
|
163 |
Â
* @since 4.0
|
164 |
Â
*/
|
165 |
Â
toggleStickyWidget: function() {
|
174 |
Â
this.instagramInstallBtnText = this.modal.activate;
|
175 |
Â
}
|
176 |
Â
}
|
177 |
+
})
|
admin/assets/js/settings.js
CHANGED
@@ -66,6 +66,7 @@ var settings_data = {
|
|
66 |
Â
uploadStatus: null,
|
67 |
Â
clearCacheStatus: null,
|
68 |
Â
optimizeCacheStatus: null,
|
Â
|
|
69 |
Â
pressedBtnName: null,
|
70 |
Â
loading: false,
|
71 |
Â
hasError: cff_settings.hasError,
|
@@ -610,6 +611,40 @@ var cffSettings = new Vue({
|
|
610 |
Â
}.bind(this), 3000);
|
611 |
Â
});
|
612 |
Â
},
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
613 |
Â
saveChangesIcon: function() {
|
614 |
Â
if ( this.btnStatus == 'loading' ) {
|
615 |
Â
return this.loaderSVG;
|
@@ -753,7 +788,9 @@ var cffSettings = new Vue({
|
|
753 |
Â
ajaxPost : function(data, callback){
|
754 |
Â
var self = this;
|
755 |
Â
data['nonce'] = self.nonce;
|
756 |
-
|
Â
|
|
Â
|
|
757 |
Â
},
|
758 |
Â
|
759 |
Â
/**
|
66 |
Â
uploadStatus: null,
|
67 |
Â
clearCacheStatus: null,
|
68 |
Â
optimizeCacheStatus: null,
|
69 |
+
dpaResetStatus: null,
|
70 |
Â
pressedBtnName: null,
|
71 |
Â
loading: false,
|
72 |
Â
hasError: cff_settings.hasError,
|
611 |
Â
}.bind(this), 3000);
|
612 |
Â
});
|
613 |
Â
},
|
614 |
+
dpaReset: function() {
|
615 |
+
this.dpaResetStatus = 'loading';
|
616 |
+
let data = new FormData();
|
617 |
+
data.append( 'action', 'cff_dpa_reset' );
|
618 |
+
data.append( 'nonce', this.nonce );
|
619 |
+
fetch(this.ajaxHandler, {
|
620 |
+
method: "POST",
|
621 |
+
credentials: 'same-origin',
|
622 |
+
body: data
|
623 |
+
})
|
624 |
+
.then(response => response.json())
|
625 |
+
.then(data => {
|
626 |
+
if ( data.success == false ) {
|
627 |
+
this.dpaResetStatus = 'error';
|
628 |
+
return;
|
629 |
+
}
|
630 |
+
this.dpaResetStatus = 'success';
|
631 |
+
setTimeout(function() {
|
632 |
+
this.dpaResetStatus = null;
|
633 |
+
}.bind(this), 3000);
|
634 |
+
});
|
635 |
+
},
|
636 |
+
dpaResetStatusIcon: function() {
|
637 |
+
if ( this.dpaResetStatus === null ) {
|
638 |
+
return;
|
639 |
+
}
|
640 |
+
if ( this.dpaResetStatus == 'loading' ) {
|
641 |
+
return this.loaderSVG;
|
642 |
+
} else if ( this.dpaResetStatus == 'success' ) {
|
643 |
+
return this.checkmarkSVG;
|
644 |
+
} else if ( this.dpaResetStatus == 'error' ) {
|
645 |
+
return `<i class="fa fa-times-circle"></i>`;
|
646 |
+
}
|
647 |
+
},
|
648 |
Â
saveChangesIcon: function() {
|
649 |
Â
if ( this.btnStatus == 'loading' ) {
|
650 |
Â
return this.loaderSVG;
|
788 |
Â
ajaxPost : function(data, callback){
|
789 |
Â
var self = this;
|
790 |
Â
data['nonce'] = self.nonce;
|
791 |
+
data['settings_page'] = true;
|
792 |
+
|
793 |
+
self.$http.post(self.ajaxHandler,data).then(callback);
|
794 |
Â
},
|
795 |
Â
|
796 |
Â
/**
|
admin/builder/assets/css/global.css
CHANGED
@@ -2072,7 +2072,7 @@
|
|
2072 |
Â
.cff-group-app-screenshot{
|
2073 |
Â
display: none;
|
2074 |
Â
position: absolute;
|
2075 |
-
bottom:
|
2076 |
Â
left: 50%;
|
2077 |
Â
margin-left: -325px;
|
2078 |
Â
z-index: 10;
|
2072 |
Â
.cff-group-app-screenshot{
|
2073 |
Â
display: none;
|
2074 |
Â
position: absolute;
|
2075 |
+
bottom: 75px;
|
2076 |
Â
left: 50%;
|
2077 |
Â
margin-left: -325px;
|
2078 |
Â
z-index: 10;
|
admin/builder/assets/js/add-source.js
CHANGED
@@ -67,7 +67,7 @@ Vue.component('sb-add-source-component', {
|
|
67 |
Â
'action' : 'cff_source_builder_update',
|
68 |
Â
'type' : self.addNewSource.typeSelected,
|
69 |
Â
'id' : self.addNewSource.manualSourceID,
|
70 |
-
'access_token' : self.addNewSource.manualSourceToken
|
71 |
Â
};
|
72 |
Â
if(isEventSource){
|
73 |
Â
manualSourceData.privilege = 'events';
|
@@ -234,7 +234,6 @@ Vue.component('sb-add-source-component', {
|
|
234 |
Â
}
|
235 |
Â
var finalUrl = fbConnectURL + "{'{url=" + appendURL + "}'}";
|
236 |
Â
window.location = finalUrl;
|
237 |
-
|
238 |
Â
},
|
239 |
Â
|
240 |
Â
/**
|
67 |
Â
'action' : 'cff_source_builder_update',
|
68 |
Â
'type' : self.addNewSource.typeSelected,
|
69 |
Â
'id' : self.addNewSource.manualSourceID,
|
70 |
+
'access_token' : self.addNewSource.manualSourceToken,
|
71 |
Â
};
|
72 |
Â
if(isEventSource){
|
73 |
Â
manualSourceData.privilege = 'events';
|
234 |
Â
}
|
235 |
Â
var finalUrl = fbConnectURL + "{'{url=" + appendURL + "}'}";
|
236 |
Â
window.location = finalUrl;
|
Â
|
|
237 |
Â
},
|
238 |
Â
|
239 |
Â
/**
|
admin/builder/templates/form-data-examples.html
CHANGED
@@ -130,7 +130,6 @@ Tool to help understand how sending and retrieving feed related info from the da
|
|
130 |
Â
event.preventDefault();
|
131 |
Â
|
132 |
Â
var thisData = $(this).serializeArray();
|
133 |
-
console.log(thisData)
|
134 |
Â
$.ajax({
|
135 |
Â
url: cff_builder.ajax_handler,
|
136 |
Â
type: 'post',
|
@@ -138,12 +137,10 @@ Tool to help understand how sending and retrieving feed related info from the da
|
|
138 |
Â
success: function (data) {
|
139 |
Â
if (data.indexOf('{') === 0) {
|
140 |
Â
data = JSON.parse(data);
|
141 |
-
console.log(data);
|
142 |
-
|
143 |
Â
}
|
144 |
Â
|
145 |
Â
}
|
146 |
Â
});
|
147 |
Â
});
|
148 |
Â
});
|
149 |
-
</script>
|
130 |
Â
event.preventDefault();
|
131 |
Â
|
132 |
Â
var thisData = $(this).serializeArray();
|
Â
|
|
133 |
Â
$.ajax({
|
134 |
Â
url: cff_builder.ajax_handler,
|
135 |
Â
type: 'post',
|
137 |
Â
success: function (data) {
|
138 |
Â
if (data.indexOf('{') === 0) {
|
139 |
Â
data = JSON.parse(data);
|
Â
|
|
Â
|
|
140 |
Â
}
|
141 |
Â
|
142 |
Â
}
|
143 |
Â
});
|
144 |
Â
});
|
145 |
Â
});
|
146 |
+
</script>
|
admin/builder/templates/sections/popup/add-source-popup.php
CHANGED
@@ -35,8 +35,11 @@
|
|
35 |
Â
<span class="sb-small sb-lighter" v-html="source.account_type"></span>
|
36 |
Â
</div>
|
37 |
Â
<div v-if="source.error !== ''" class="sb-source-error-wrap">
|
38 |
-
<span v-html="genericText.invalid"></span><a href="#" @click.prevent.default="$parent.activateView('sourcePopupType', '
|
39 |
Â
</div>
|
Â
|
|
Â
|
|
Â
|
|
40 |
Â
</div>
|
41 |
Â
</div>
|
42 |
Â
</div>
|
@@ -318,6 +321,7 @@
|
|
318 |
Â
<p class="sb-step-text sb-small-p"><span v-html="addAppStep"></span><span v-if="index === 0"><a id="cff-group-admin-link" :href="'https://www.facebook.com/groups/'+selectedSourcesToConnect[0]+'/apps/store'" target="_blank" rel="noopener noreferrer" v-html="$parent.genericText.clickingHere"></a></span></p>
|
319 |
Â
</div>
|
320 |
Â
</div>
|
Â
|
|
321 |
Â
</div>
|
322 |
Â
|
323 |
Â
<div v-if="typeof window.cffSelected !== 'undefined' && window.cffSelected.indexOf(false) > -1 " class="sb-directions-wrap">
|
@@ -339,4 +343,4 @@
|
|
339 |
Â
</div>
|
340 |
Â
</div>
|
341 |
Â
</div>
|
342 |
-
</script>
|
35 |
Â
<span class="sb-small sb-lighter" v-html="source.account_type"></span>
|
36 |
Â
</div>
|
37 |
Â
<div v-if="source.error !== ''" class="sb-source-error-wrap">
|
38 |
+
<span v-html="genericText.invalid"></span><a href="#" @click.prevent.default="$parent.activateView('sourcePopupType', 'creationRedirect')" v-html="genericText.reconnect"></a>
|
39 |
Â
</div>
|
40 |
+
<div v-if="source.error === '' && typeof( source.needs_update ) !== 'undefined' && source.needs_update" class="sb-source-error-wrap">
|
41 |
+
<span v-html="genericText.updateRequired"></span><a href="#" @click.prevent.default="$parent.activateView('sourcePopupType','creationRedirect')" v-html="genericText.reconnect"></a>
|
42 |
+
</div>
|
43 |
Â
</div>
|
44 |
Â
</div>
|
45 |
Â
</div>
|
321 |
Â
<p class="sb-step-text sb-small-p"><span v-html="addAppStep"></span><span v-if="index === 0"><a id="cff-group-admin-link" :href="'https://www.facebook.com/groups/'+selectedSourcesToConnect[0]+'/apps/store'" target="_blank" rel="noopener noreferrer" v-html="$parent.genericText.clickingHere"></a></span></p>
|
322 |
Â
</div>
|
323 |
Â
</div>
|
324 |
+
<p style="margin-top: 25px;"><span style="color: red; font-weight: bold;">Important:</span> {{selectSourceScreen.modal.reconnectingAppDir}}</p>
|
325 |
Â
</div>
|
326 |
Â
|
327 |
Â
<div v-if="typeof window.cffSelected !== 'undefined' && window.cffSelected.indexOf(false) > -1 " class="sb-directions-wrap">
|
343 |
Â
</div>
|
344 |
Â
</div>
|
345 |
Â
</div>
|
346 |
+
</script>
|
admin/views/settings/tab/advanced.php
CHANGED
@@ -157,5 +157,19 @@
|
|
157 |
Â
</div>
|
158 |
Â
</div>
|
159 |
Â
</div>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
160 |
Â
</div>
|
161 |
Â
<!-- todo: this is just demo content and will be replaced once I work on this -->
|
157 |
Â
</div>
|
158 |
Â
</div>
|
159 |
Â
</div>
|
160 |
+
<div class="sb-tab-box sb-optimize-box sb-dpa-clear-box-style clearfix">
|
161 |
+
<div class="tab-label">
|
162 |
+
<h3>{{advancedTab.dpaClear.title}}</h3>
|
163 |
+
</div>
|
164 |
+
<div class="cff-tab-form-field">
|
165 |
+
<button type="button" class="cff-btn" @click="dpaReset()">
|
166 |
+
<span v-html="dpaResetStatusIcon()" :class="dpaResetStatus" v-if="dpaResetStatus !== null"></span>
|
167 |
+
{{advancedTab.dpaClear.clear}}
|
168 |
+
</button>
|
169 |
+
<span class="help-text">
|
170 |
+
{{advancedTab.dpaClear.helpText}}
|
171 |
+
</span>
|
172 |
+
</div>
|
173 |
+
</div>
|
174 |
Â
</div>
|
175 |
Â
<!-- todo: this is just demo content and will be replaced once I work on this -->
|
admin/views/settings/tab/general.php
CHANGED
@@ -272,8 +272,15 @@
|
|
272 |
Â
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
273 |
Â
<path d="M6.50008 0.666664C3.28008 0.666664 0.666748 3.28 0.666748 6.5C0.666748 9.72 3.28008 12.3333 6.50008 12.3333C9.72008 12.3333 12.3334 9.72 12.3334 6.5C12.3334 3.28 9.72008 0.666664 6.50008 0.666664ZM7.08342 9.41667H5.91675V8.25H7.08342V9.41667ZM7.08342 7.08333H5.91675V3.58333H7.08342V7.08333Z" fill="#D72C2C"/>
|
274 |
Â
</svg>
|
275 |
-
<span v-html="genericText.errorSource"></span><a href="#" @click.prevent.default="activateView('sourcePopup')" v-html="genericText.reconnect"></a>
|
276 |
Â
</div>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
277 |
Â
</div>
|
278 |
Â
</div>
|
279 |
Â
<div class="sb-srcs-item-actions">
|
@@ -288,11 +295,6 @@
|
|
288 |
Â
<span>{{source.account_id}}</span>
|
289 |
Â
<div class="cff-fb-srcs-info-icon" v-html="svgIcons['copy2']" @click.prevent.default="copyToClipBoard(source.account_id)"></div>
|
290 |
Â
</div>
|
291 |
-
<div class="cff-fb-srcs-info-item">
|
292 |
-
<strong>{{genericText.token}}</strong>
|
293 |
-
<span>{{source.access_token}}</span>
|
294 |
-
<div class="cff-fb-srcs-info-icon" v-html="svgIcons['copy2']" @click.prevent.default="copyToClipBoard(source.access_token)"></div>
|
295 |
-
</div>
|
296 |
Â
</div>
|
297 |
Â
</div>
|
298 |
Â
|
@@ -366,4 +368,4 @@
|
|
366 |
Â
</div>
|
367 |
Â
</div>
|
368 |
Â
</div>
|
369 |
-
</div>
|
272 |
Â
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
273 |
Â
<path d="M6.50008 0.666664C3.28008 0.666664 0.666748 3.28 0.666748 6.5C0.666748 9.72 3.28008 12.3333 6.50008 12.3333C9.72008 12.3333 12.3334 9.72 12.3334 6.5C12.3334 3.28 9.72008 0.666664 6.50008 0.666664ZM7.08342 9.41667H5.91675V8.25H7.08342V9.41667ZM7.08342 7.08333H5.91675V3.58333H7.08342V7.08333Z" fill="#D72C2C"/>
|
274 |
Â
</svg>
|
275 |
+
<span v-html="genericText.errorSource"></span><a href="#" @click.prevent.default="activateView('sourcePopup','creationRedirect')" v-html="genericText.reconnect"></a>
|
276 |
Â
</div>
|
277 |
+
<div v-if="source.error === '' && typeof( source.needs_update ) !== 'undefined' && source.needs_update" class="sb-source-error-wrap">
|
278 |
+
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
279 |
+
<path d="M6.50008 0.666664C3.28008 0.666664 0.666748 3.28 0.666748 6.5C0.666748 9.72 3.28008 12.3333 6.50008 12.3333C9.72008 12.3333 12.3334 9.72 12.3334 6.5C12.3334 3.28 9.72008 0.666664 6.50008 0.666664ZM7.08342 9.41667H5.91675V8.25H7.08342V9.41667ZM7.08342 7.08333H5.91675V3.58333H7.08342V7.08333Z" fill="#D72C2C"/>
|
280 |
+
</svg>
|
281 |
+
|
282 |
+
<span v-html="genericText.updateRequired"></span><a href="#" @click.prevent.default="activateView('sourcePopup','creationRedirect')" v-html="genericText.reconnect"></a>
|
283 |
+
</div>
|
284 |
Â
</div>
|
285 |
Â
</div>
|
286 |
Â
<div class="sb-srcs-item-actions">
|
295 |
Â
<span>{{source.account_id}}</span>
|
296 |
Â
<div class="cff-fb-srcs-info-icon" v-html="svgIcons['copy2']" @click.prevent.default="copyToClipBoard(source.account_id)"></div>
|
297 |
Â
</div>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
298 |
Â
</div>
|
299 |
Â
</div>
|
300 |
Â
|
368 |
Â
</div>
|
369 |
Â
</div>
|
370 |
Â
</div>
|
371 |
+
</div>
|
custom-facebook-feed.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Â
Plugin Name: Smash Balloon 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: 4.
|
7 |
Â
Author: Smash Balloon
|
8 |
Â
Author URI: http://smashballoon.com/
|
9 |
Â
License: GPLv2 or later
|
@@ -25,15 +25,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25 |
Â
*/
|
26 |
Â
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
27 |
Â
|
28 |
-
define('CFFVER', '4.
|
29 |
Â
define( 'WPW_SL_STORE_URL', 'https://smashballoon.com/' );
|
30 |
Â
define( 'WPW_SL_ITEM_NAME', 'Custom Facebook Feed WordPress Plugin Personal' ); //*!*Update Plugin Name at top of file*!*
|
31 |
Â
|
32 |
Â
// Db version.
|
33 |
Â
if ( ! defined( 'CFF_DBVERSION' ) ) {
|
34 |
-
define( 'CFF_DBVERSION', '2.
|
35 |
Â
}
|
36 |
Â
|
Â
|
|
37 |
Â
// Plugin Folder Path.
|
38 |
Â
if ( ! defined( 'CFF_PLUGIN_DIR' ) ) {
|
39 |
Â
define( 'CFF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
3 |
Â
Plugin Name: Smash Balloon 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: 4.1
|
7 |
Â
Author: Smash Balloon
|
8 |
Â
Author URI: http://smashballoon.com/
|
9 |
Â
License: GPLv2 or later
|
25 |
Â
*/
|
26 |
Â
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
27 |
Â
|
28 |
+
define('CFFVER', '4.1');
|
29 |
Â
define( 'WPW_SL_STORE_URL', 'https://smashballoon.com/' );
|
30 |
Â
define( 'WPW_SL_ITEM_NAME', 'Custom Facebook Feed WordPress Plugin Personal' ); //*!*Update Plugin Name at top of file*!*
|
31 |
Â
|
32 |
Â
// Db version.
|
33 |
Â
if ( ! defined( 'CFF_DBVERSION' ) ) {
|
34 |
+
define( 'CFF_DBVERSION', '2.4' );
|
35 |
Â
}
|
36 |
Â
|
37 |
+
|
38 |
Â
// Plugin Folder Path.
|
39 |
Â
if ( ! defined( 'CFF_PLUGIN_DIR' ) ) {
|
40 |
Â
define( 'CFF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
inc/Admin/CFF_Global_Settings.php
CHANGED
@@ -72,6 +72,7 @@ class CFF_Global_Settings {
|
|
72 |
Â
add_action( 'wp_ajax_cff_export_settings_json', [$this, 'cff_export_settings_json'] );
|
73 |
Â
add_action( 'wp_ajax_cff_clear_cache', [$this, 'cff_clear_cache'] );
|
74 |
Â
add_action( 'wp_ajax_cff_clear_image_resize_cache', [$this, 'cff_clear_image_resize_cache'] );
|
Â
|
|
75 |
Â
|
76 |
Â
CFF_Upgrader::hooks();
|
77 |
Â
}
|
@@ -1165,6 +1166,11 @@ class CFF_Global_Settings {
|
|
1165 |
Â
),
|
1166 |
Â
)
|
1167 |
Â
),
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1168 |
Â
),
|
1169 |
Â
'dialogBoxPopupScreen' => array(
|
1170 |
Â
'deleteSource' => array(
|
@@ -1669,4 +1675,22 @@ class CFF_Global_Settings {
|
|
1669 |
Â
return CFF_View::render( 'settings.index' );
|
1670 |
Â
}
|
1671 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1672 |
Â
}
|
72 |
Â
add_action( 'wp_ajax_cff_export_settings_json', [$this, 'cff_export_settings_json'] );
|
73 |
Â
add_action( 'wp_ajax_cff_clear_cache', [$this, 'cff_clear_cache'] );
|
74 |
Â
add_action( 'wp_ajax_cff_clear_image_resize_cache', [$this, 'cff_clear_image_resize_cache'] );
|
75 |
+
add_action( 'wp_ajax_cff_dpa_reset', [$this, 'cff_dpa_reset'] );
|
76 |
Â
|
77 |
Â
CFF_Upgrader::hooks();
|
78 |
Â
}
|
1166 |
Â
),
|
1167 |
Â
)
|
1168 |
Â
),
|
1169 |
+
'dpaClear' => array(
|
1170 |
+
'title' => __( 'Manage Data', 'custom-facebook-feed' ),
|
1171 |
+
'helpText' => __( 'Warning: Clicking this button will permanently delete all Facebook data, including all connected accounts, cached posts, and stored images.', 'custom-facebook-feed' ),
|
1172 |
+
'clear' => __( 'Delete all Platform Data', 'custom-facebook-feed' ),
|
1173 |
+
),
|
1174 |
Â
),
|
1175 |
Â
'dialogBoxPopupScreen' => array(
|
1176 |
Â
'deleteSource' => array(
|
1675 |
Â
return CFF_View::render( 'settings.index' );
|
1676 |
Â
}
|
1677 |
Â
|
1678 |
+
/**
|
1679 |
+
* CFF Clear Everything
|
1680 |
+
*
|
1681 |
+
* @since 4.1
|
1682 |
+
*/
|
1683 |
+
public function cff_dpa_reset() {
|
1684 |
+
//Security Checks
|
1685 |
+
check_ajax_referer( 'cff_admin_nonce', 'nonce' );
|
1686 |
+
|
1687 |
+
$cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
|
1688 |
+
$cap = apply_filters( 'cff_settings_pages_capability', $cap );
|
1689 |
+
if ( ! current_user_can( $cap ) ) {
|
1690 |
+
wp_send_json_error(); // This auto-dies.
|
1691 |
+
}
|
1692 |
+
|
1693 |
+
cff_delete_all_platform_data();
|
1694 |
+
new CFF_Response( true, [] );
|
1695 |
+
}
|
1696 |
Â
}
|
inc/Admin/CFF_Notifications.php
CHANGED
@@ -21,7 +21,7 @@ class CFF_Notifications {
|
|
21 |
Â
*
|
22 |
Â
* @var string
|
23 |
Â
*/
|
24 |
-
const SOURCE_URL = '
|
25 |
Â
|
26 |
Â
/**
|
27 |
Â
* @var string
|
@@ -252,6 +252,16 @@ class CFF_Notifications {
|
|
252 |
Â
continue;
|
253 |
Â
}
|
254 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
255 |
Â
// The message and license should never be empty, if they are, ignore.
|
256 |
Â
if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
|
257 |
Â
continue;
|
@@ -319,6 +329,16 @@ class CFF_Notifications {
|
|
319 |
Â
if ( ! empty( $notification['minver'] ) && version_compare( $notification['minver'], CFFVER ) >= 0 ) {
|
320 |
Â
unset( $notifications[ $key ] );
|
321 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
322 |
Â
}
|
323 |
Â
|
324 |
Â
return $notifications;
|
21 |
Â
*
|
22 |
Â
* @var string
|
23 |
Â
*/
|
24 |
+
const SOURCE_URL = 'https://plugin.smashballoon.com/notifications.json';
|
25 |
Â
|
26 |
Â
/**
|
27 |
Â
* @var string
|
252 |
Â
continue;
|
253 |
Â
}
|
254 |
Â
|
255 |
+
// Ignore if a specific cff_status is empty or false
|
256 |
+
if ( ! empty( $notification['statuscheck'] ) ) {
|
257 |
+
$status_key = sanitize_key( $notification['statuscheck'] );
|
258 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
259 |
+
|
260 |
+
if ( empty( $cff_statuses_option[ $status_key ] ) ) {
|
261 |
+
continue;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
Â
// The message and license should never be empty, if they are, ignore.
|
266 |
Â
if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
|
267 |
Â
continue;
|
329 |
Â
if ( ! empty( $notification['minver'] ) && version_compare( $notification['minver'], CFFVER ) >= 0 ) {
|
330 |
Â
unset( $notifications[ $key ] );
|
331 |
Â
}
|
332 |
+
|
333 |
+
// Ignore if a specific cff_status is empty or false
|
334 |
+
if ( ! empty( $notification['statuscheck'] ) ) {
|
335 |
+
$status_key = sanitize_key( $notification['statuscheck'] );
|
336 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
337 |
+
|
338 |
+
if ( empty( $cff_statuses_option[ $status_key ] ) ) {
|
339 |
+
unset( $notifications[ $key ] );
|
340 |
+
}
|
341 |
+
}
|
342 |
Â
}
|
343 |
Â
|
344 |
Â
return $notifications;
|
inc/Admin/CFF_Support.php
CHANGED
@@ -12,6 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
12 |
Â
use CustomFacebookFeed\CFF_View;
|
13 |
Â
use CustomFacebookFeed\CFF_Utils;
|
14 |
Â
use CustomFacebookFeed\CFF_Response;
|
Â
|
|
15 |
Â
use CustomFacebookFeed\Builder\CFF_Db;
|
16 |
Â
use CustomFacebookFeed\CFF_Feed_Locator;
|
17 |
Â
use CustomFacebookFeed\Builder\CFF_Feed_Builder;
|
@@ -442,6 +443,7 @@ class CFF_Support {
|
|
442 |
Â
|
443 |
Â
$feeds_list = CFF_Feed_Builder::get_feed_list();
|
444 |
Â
$source_list = CFF_Feed_Builder::get_source_list();
|
Â
|
|
445 |
Â
$i = 0;
|
446 |
Â
foreach( $feeds_list as $feed ) {
|
447 |
Â
if ( $i >= 25 ) {
|
@@ -458,7 +460,7 @@ class CFF_Support {
|
|
458 |
Â
$output .= $source['username'];
|
459 |
Â
$output .= ' (' . $source_id . ')';
|
460 |
Â
$output .= "</br>";
|
461 |
-
$output .= $source['access_token'];
|
462 |
Â
}
|
463 |
Â
}
|
464 |
Â
}
|
12 |
Â
use CustomFacebookFeed\CFF_View;
|
13 |
Â
use CustomFacebookFeed\CFF_Utils;
|
14 |
Â
use CustomFacebookFeed\CFF_Response;
|
15 |
+
use CustomFacebookFeed\SB_Facebook_Data_Manager;
|
16 |
Â
use CustomFacebookFeed\Builder\CFF_Db;
|
17 |
Â
use CustomFacebookFeed\CFF_Feed_Locator;
|
18 |
Â
use CustomFacebookFeed\Builder\CFF_Feed_Builder;
|
443 |
Â
|
444 |
Â
$feeds_list = CFF_Feed_Builder::get_feed_list();
|
445 |
Â
$source_list = CFF_Feed_Builder::get_source_list();
|
446 |
+
$manager = new SB_Facebook_Data_Manager();
|
447 |
Â
$i = 0;
|
448 |
Â
foreach( $feeds_list as $feed ) {
|
449 |
Â
if ( $i >= 25 ) {
|
460 |
Â
$output .= $source['username'];
|
461 |
Â
$output .= ' (' . $source_id . ')';
|
462 |
Â
$output .= "</br>";
|
463 |
+
$output .= $manager->remote_encrypt( $source['access_token'] );
|
464 |
Â
}
|
465 |
Â
}
|
466 |
Â
}
|
inc/Admin/CFF_oEmbeds.php
CHANGED
@@ -220,6 +220,11 @@ class CFF_oEmbeds {
|
|
220 |
Â
$oembed_token_settings = $newly_retrieved_oembed_connection_data;
|
221 |
Â
$return['newOembedData'] = $newly_retrieved_oembed_connection_data;
|
222 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
223 |
Â
update_option( 'cff_oembed_token', $newly_retrieved_oembed_connection_data );
|
224 |
Â
update_option( 'sbi_oembed_token', $newly_retrieved_oembed_connection_data );
|
225 |
Â
} elseif ( ! empty( $newly_retrieved_oembed_connection_data ) ) {
|
@@ -408,4 +413,4 @@ class CFF_oEmbeds {
|
|
408 |
Â
public function oembeds_manager(){
|
409 |
Â
return CFF_View::render( 'oembeds.index' );
|
410 |
Â
}
|
411 |
-
}
|
220 |
Â
$oembed_token_settings = $newly_retrieved_oembed_connection_data;
|
221 |
Â
$return['newOembedData'] = $newly_retrieved_oembed_connection_data;
|
222 |
Â
|
223 |
+
$encryption = new \CustomFacebookFeed\SB_Facebook_Data_Encryption();
|
224 |
+
if ( isset( $newly_retrieved_oembed_connection_data['access_token'] ) && ! $encryption->decrypt( $newly_retrieved_oembed_connection_data['access_token'] ) ) {
|
225 |
+
$newly_retrieved_oembed_connection_data['access_token'] = $encryption->encrypt( $newly_retrieved_oembed_connection_data['access_token'] );
|
226 |
+
}
|
227 |
+
|
228 |
Â
update_option( 'cff_oembed_token', $newly_retrieved_oembed_connection_data );
|
229 |
Â
update_option( 'sbi_oembed_token', $newly_retrieved_oembed_connection_data );
|
230 |
Â
} elseif ( ! empty( $newly_retrieved_oembed_connection_data ) ) {
|
413 |
Â
public function oembeds_manager(){
|
414 |
Â
return CFF_View::render( 'oembeds.index' );
|
415 |
Â
}
|
416 |
+
}
|
inc/Builder/CFF_Db.php
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
Â
*/
|
7 |
Â
|
8 |
Â
namespace CustomFacebookFeed\Builder;
|
Â
|
|
9 |
Â
|
10 |
Â
class CFF_Db {
|
11 |
Â
|
@@ -80,6 +81,15 @@ class CFF_Db {
|
|
80 |
Â
return $wpdb->get_results( $sql, ARRAY_A );
|
81 |
Â
}
|
82 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
83 |
Â
if ( ! isset( $args['id'] ) ) {
|
84 |
Â
return false;
|
85 |
Â
}
|
@@ -129,6 +139,7 @@ class CFF_Db {
|
|
129 |
Â
public static function source_update( $to_update, $where_data ) {
|
130 |
Â
global $wpdb;
|
131 |
Â
$sources_table_name = $wpdb->prefix . 'cff_sources';
|
Â
|
|
132 |
Â
|
133 |
Â
$data = array();
|
134 |
Â
$where = array();
|
@@ -147,7 +158,7 @@ class CFF_Db {
|
|
147 |
Â
$where_format[] = '%s';
|
148 |
Â
}
|
149 |
Â
if ( isset( $to_update['access_token'] ) ) {
|
150 |
-
$data['access_token'] = $to_update['access_token'];
|
151 |
Â
$format[] = '%s';
|
152 |
Â
}
|
153 |
Â
if ( isset( $to_update['username'] ) ) {
|
@@ -155,7 +166,7 @@ class CFF_Db {
|
|
155 |
Â
$format[] = '%s';
|
156 |
Â
}
|
157 |
Â
if ( isset( $to_update['info'] ) ) {
|
158 |
-
$data['info'] = $to_update['info'];
|
159 |
Â
$format[] = '%s';
|
160 |
Â
}
|
161 |
Â
if ( isset( $to_update['error'] ) ) {
|
@@ -214,6 +225,7 @@ class CFF_Db {
|
|
214 |
Â
public static function source_insert( $to_insert ) {
|
215 |
Â
global $wpdb;
|
216 |
Â
$sources_table_name = $wpdb->prefix . 'cff_sources';
|
Â
|
|
217 |
Â
|
218 |
Â
$data = array();
|
219 |
Â
$format = array();
|
@@ -233,7 +245,7 @@ class CFF_Db {
|
|
233 |
Â
$format[] = '%s';
|
234 |
Â
}
|
235 |
Â
if ( isset( $to_insert['access_token'] ) ) {
|
236 |
-
$data['access_token'] = $to_insert['access_token'];
|
237 |
Â
$format[] = '%s';
|
238 |
Â
}
|
239 |
Â
if ( isset( $to_insert['username'] ) ) {
|
@@ -241,7 +253,7 @@ class CFF_Db {
|
|
241 |
Â
$format[] = '%s';
|
242 |
Â
}
|
243 |
Â
if ( isset( $to_insert['info'] ) ) {
|
244 |
-
$data['info'] = $to_insert['info'];
|
245 |
Â
$format[] = '%s';
|
246 |
Â
}
|
247 |
Â
if ( isset( $to_insert['error'] ) ) {
|
@@ -900,6 +912,24 @@ class CFF_Db {
|
|
900 |
Â
}
|
901 |
Â
}
|
902 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
903 |
Â
public static function reset_tables() {
|
904 |
Â
global $wpdb;
|
905 |
Â
$feeds_table_name = $wpdb->prefix . 'cff_feeds';
|
@@ -947,4 +977,4 @@ class CFF_Db {
|
|
947 |
Â
|
948 |
Â
update_option( 'cff_statuses', $cff_statuses_option );
|
949 |
Â
}
|
950 |
-
}
|
6 |
Â
*/
|
7 |
Â
|
8 |
Â
namespace CustomFacebookFeed\Builder;
|
9 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
10 |
Â
|
11 |
Â
class CFF_Db {
|
12 |
Â
|
81 |
Â
return $wpdb->get_results( $sql, ARRAY_A );
|
82 |
Â
}
|
83 |
Â
|
84 |
+
if ( isset( $args['type'] ) && ! isset( $args['id'] ) ) {
|
85 |
+
$sql = $wpdb->prepare( "
|
86 |
+
SELECT * FROM $sources_table_name
|
87 |
+
WHERE account_type = %s;
|
88 |
+
", $args['type'] );
|
89 |
+
|
90 |
+
return $wpdb->get_results( $sql, ARRAY_A );
|
91 |
+
}
|
92 |
+
|
93 |
Â
if ( ! isset( $args['id'] ) ) {
|
94 |
Â
return false;
|
95 |
Â
}
|
139 |
Â
public static function source_update( $to_update, $where_data ) {
|
140 |
Â
global $wpdb;
|
141 |
Â
$sources_table_name = $wpdb->prefix . 'cff_sources';
|
142 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
143 |
Â
|
144 |
Â
$data = array();
|
145 |
Â
$where = array();
|
158 |
Â
$where_format[] = '%s';
|
159 |
Â
}
|
160 |
Â
if ( isset( $to_update['access_token'] ) ) {
|
161 |
+
$data['access_token'] = $encryption->maybe_encrypt( $to_update['access_token'] );
|
162 |
Â
$format[] = '%s';
|
163 |
Â
}
|
164 |
Â
if ( isset( $to_update['username'] ) ) {
|
166 |
Â
$format[] = '%s';
|
167 |
Â
}
|
168 |
Â
if ( isset( $to_update['info'] ) ) {
|
169 |
+
$data['info'] = $encryption->maybe_encrypt( $to_update['info'] );
|
170 |
Â
$format[] = '%s';
|
171 |
Â
}
|
172 |
Â
if ( isset( $to_update['error'] ) ) {
|
225 |
Â
public static function source_insert( $to_insert ) {
|
226 |
Â
global $wpdb;
|
227 |
Â
$sources_table_name = $wpdb->prefix . 'cff_sources';
|
228 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
229 |
Â
|
230 |
Â
$data = array();
|
231 |
Â
$format = array();
|
245 |
Â
$format[] = '%s';
|
246 |
Â
}
|
247 |
Â
if ( isset( $to_insert['access_token'] ) ) {
|
248 |
+
$data['access_token'] = $encryption->maybe_encrypt( $to_insert['access_token'] );
|
249 |
Â
$format[] = '%s';
|
250 |
Â
}
|
251 |
Â
if ( isset( $to_insert['username'] ) ) {
|
253 |
Â
$format[] = '%s';
|
254 |
Â
}
|
255 |
Â
if ( isset( $to_insert['info'] ) ) {
|
256 |
+
$data['info'] = $encryption->maybe_encrypt( $to_insert['info'] );
|
257 |
Â
$format[] = '%s';
|
258 |
Â
}
|
259 |
Â
if ( isset( $to_insert['error'] ) ) {
|
912 |
Â
}
|
913 |
Â
}
|
914 |
Â
|
915 |
+
public static function clear_cff_feed_caches() {
|
916 |
+
global $wpdb;
|
917 |
+
$feed_caches_table_name = $wpdb->prefix . 'cff_feed_caches';
|
918 |
+
|
919 |
+
if ( $wpdb->get_var( "show tables like '$feed_caches_table_name'" ) === $feed_caches_table_name ) {
|
920 |
+
$wpdb->query( "DELETE FROM $feed_caches_table_name" );
|
921 |
+
}
|
922 |
+
}
|
923 |
+
|
924 |
+
public static function clear_cff_sources() {
|
925 |
+
global $wpdb;
|
926 |
+
$sources_table_name = $wpdb->prefix . 'cff_sources';
|
927 |
+
|
928 |
+
if ( $wpdb->get_var( "show tables like '$sources_table_name'" ) === $sources_table_name ) {
|
929 |
+
$wpdb->query( "DELETE FROM $sources_table_name" );
|
930 |
+
}
|
931 |
+
}
|
932 |
+
|
933 |
Â
public static function reset_tables() {
|
934 |
Â
global $wpdb;
|
935 |
Â
$feeds_table_name = $wpdb->prefix . 'cff_feeds';
|
977 |
Â
|
978 |
Â
update_option( 'cff_statuses', $cff_statuses_option );
|
979 |
Â
}
|
980 |
+
}
|
inc/Builder/CFF_Feed_Builder.php
CHANGED
@@ -8,7 +8,7 @@ namespace CustomFacebookFeed\Builder;
|
|
8 |
Â
use CustomFacebookFeed\Builder\Tabs\CFF_Styling_Tab;
|
9 |
Â
use CustomFacebookFeed\CFF_Utils;
|
10 |
Â
use CustomFacebookFeed\CFF_Response;
|
11 |
-
use CustomFacebookFeed\
|
12 |
Â
use function DI\value;
|
13 |
Â
|
14 |
Â
class CFF_Feed_Builder {
|
@@ -985,6 +985,7 @@ class CFF_Feed_Builder {
|
|
985 |
Â
'errorNotice' => __( 'There was an error when trying to connect to Facebook.', 'custom-facebook-feed' ),
|
986 |
Â
'errorDirections' => '<a href="https://smashballoon.com/custom-facebook-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on How to Resolve This Issue', 'custom-facebook-feed' ) . '</a>',
|
987 |
Â
'errorSource' => __( 'Source Invalid', 'custom-facebook-feed' ),
|
Â
|
|
988 |
Â
'invalid' => __( 'Invalid', 'custom-facebook-feed' ),
|
989 |
Â
'reconnect' => __( 'Reconnect', 'custom-facebook-feed' ),
|
990 |
Â
'feed' => __( 'feed', 'custom-facebook-feed' ),
|
@@ -1116,12 +1117,13 @@ class CFF_Feed_Builder {
|
|
1116 |
Â
'accessToken' => __( 'Facebook Access Token', 'custom-facebook-feed' ),
|
1117 |
Â
'enterToken' => __( 'Enter Token', 'custom-facebook-feed' ),
|
1118 |
Â
'addApp' => __( 'Add Facebook App to your group', 'custom-facebook-feed' ),
|
1119 |
-
'addAppDetails' => __( 'To get posts from your group, Facebook requires the "Smash Balloon
|
1120 |
Â
'addAppSteps' => [
|
1121 |
Â
__( 'Go to your group settings page by ', 'custom-facebook-feed' ),
|
1122 |
-
sprintf( __( 'Search for "Smash Balloon" and select our app %s(see screenshot)%s', 'custom-facebook-feed' ), '<a href="JavaScript:void(0);" id="cff-group-app-tooltip">', '<img class="cff-group-app-screenshot sb-tr-1" src="' . trailingslashit( CFF_PLUGIN_URL ) . 'admin/assets/img/group-app.png" alt="Thumbnail Layout"></a>'),
|
1123 |
Â
__( 'Click "Add" and you are done.', 'custom-facebook-feed' )
|
1124 |
Â
],
|
Â
|
|
1125 |
Â
'appMemberInstructions' => sprintf( __( 'To display a feed form this group, Facebook requires the admin to add the Smash Balloon app in the group settings. Please ask an admin to follow the %sdirections here%s to add the app.', 'custom-facebook-feed' ), '<a href="https://smashballoon.com/doc/display-facebook-group-feed/" target="_blank" rel="noopener noreferrer">', '</a>' ) . '<br><br>' . __( 'Once this is done, you will be able to display a feed from this group.', 'custom-facebook-feed' ),
|
1126 |
Â
'notAdmin' => __( 'For groups you are not an administrator of', 'custom-facebook-feed' ),
|
1127 |
Â
'disclaimer' => sprintf( __( 'Please note: There are Facebook limitations to displaying group content which may prevent older posts from being displayed. Please %ssee here%s for more information.', 'custom-facebook-feed' ), '<a href="https://smashballoon.com/doc/facebook-api-change-limits-groups-to-90-days/" target="_blank" rel="noopener noreferrer">', '</a>' ),
|
@@ -1506,6 +1508,7 @@ class CFF_Feed_Builder {
|
|
1506 |
Â
public static function get_source_list( $page = 1 ) {
|
1507 |
Â
$args['page'] = $page;
|
1508 |
Â
$source_data = CFF_Db::source_query( $args );
|
Â
|
|
1509 |
Â
|
1510 |
Â
$legacy_data = \CustomFacebookFeed\CFF_FB_Settings::get_legacy_settings( array() );
|
1511 |
Â
|
@@ -1513,11 +1516,13 @@ class CFF_Feed_Builder {
|
|
1513 |
Â
|
1514 |
Â
$return = array();
|
1515 |
Â
foreach ( $source_data as $source ) {
|
1516 |
-
$info = ! empty( $source['info'] ) ? json_decode( $source['info'] ) : array();
|
1517 |
Â
$avatar = \CustomFacebookFeed\CFF_Parse::get_avatar( $info );
|
1518 |
Â
|
1519 |
Â
$source['avatar_url'] = $avatar;
|
1520 |
Â
|
Â
|
|
Â
|
|
1521 |
Â
if ( $source['account_id'] === $legacy_id ) {
|
1522 |
Â
$source['used_in'] = $source['used_in'] + 1;
|
1523 |
Â
if ( ! isset( $source['instances'] ) ) {
|
@@ -2578,4 +2583,4 @@ class CFF_Feed_Builder {
|
|
2578 |
Â
include_once CFF_BUILDER_DIR . 'templates/builder.php';
|
2579 |
Â
}
|
2580 |
Â
|
2581 |
-
}
|
8 |
Â
use CustomFacebookFeed\Builder\Tabs\CFF_Styling_Tab;
|
9 |
Â
use CustomFacebookFeed\CFF_Utils;
|
10 |
Â
use CustomFacebookFeed\CFF_Response;
|
11 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
12 |
Â
use function DI\value;
|
13 |
Â
|
14 |
Â
class CFF_Feed_Builder {
|
985 |
Â
'errorNotice' => __( 'There was an error when trying to connect to Facebook.', 'custom-facebook-feed' ),
|
986 |
Â
'errorDirections' => '<a href="https://smashballoon.com/custom-facebook-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on How to Resolve This Issue', 'custom-facebook-feed' ) . '</a>',
|
987 |
Â
'errorSource' => __( 'Source Invalid', 'custom-facebook-feed' ),
|
988 |
+
'updateRequired' => __( 'Update Required', 'custom-facebook-feed' ),
|
989 |
Â
'invalid' => __( 'Invalid', 'custom-facebook-feed' ),
|
990 |
Â
'reconnect' => __( 'Reconnect', 'custom-facebook-feed' ),
|
991 |
Â
'feed' => __( 'feed', 'custom-facebook-feed' ),
|
1117 |
Â
'accessToken' => __( 'Facebook Access Token', 'custom-facebook-feed' ),
|
1118 |
Â
'enterToken' => __( 'Enter Token', 'custom-facebook-feed' ),
|
1119 |
Â
'addApp' => __( 'Add Facebook App to your group', 'custom-facebook-feed' ),
|
1120 |
+
'addAppDetails' => __( 'To get posts from your group, Facebook requires the "Smash Balloon Wordpress" app to be added in your group settings. Just follow the directions here:', 'custom-facebook-feed' ),
|
1121 |
Â
'addAppSteps' => [
|
1122 |
Â
__( 'Go to your group settings page by ', 'custom-facebook-feed' ),
|
1123 |
+
sprintf( __( 'Search for "Smash Balloon WordPress" and select our app %s(see screenshot)%s', 'custom-facebook-feed' ), '<a href="JavaScript:void(0);" id="cff-group-app-tooltip">', '<img class="cff-group-app-screenshot sb-tr-1" src="' . trailingslashit( CFF_PLUGIN_URL ) . 'admin/assets/img/group-app.png" alt="Thumbnail Layout"></a>'),
|
1124 |
Â
__( 'Click "Add" and you are done.', 'custom-facebook-feed' )
|
1125 |
Â
],
|
1126 |
+
'reconnectingAppDir' => __( 'If you are reconnecting an existing Group then make sure to follow the directions above to add this new app to your Group settings. The previous app will no longer work. This is required in order for new posts to be retrieved.', 'custom-facebook-feed' ),
|
1127 |
Â
'appMemberInstructions' => sprintf( __( 'To display a feed form this group, Facebook requires the admin to add the Smash Balloon app in the group settings. Please ask an admin to follow the %sdirections here%s to add the app.', 'custom-facebook-feed' ), '<a href="https://smashballoon.com/doc/display-facebook-group-feed/" target="_blank" rel="noopener noreferrer">', '</a>' ) . '<br><br>' . __( 'Once this is done, you will be able to display a feed from this group.', 'custom-facebook-feed' ),
|
1128 |
Â
'notAdmin' => __( 'For groups you are not an administrator of', 'custom-facebook-feed' ),
|
1129 |
Â
'disclaimer' => sprintf( __( 'Please note: There are Facebook limitations to displaying group content which may prevent older posts from being displayed. Please %ssee here%s for more information.', 'custom-facebook-feed' ), '<a href="https://smashballoon.com/doc/facebook-api-change-limits-groups-to-90-days/" target="_blank" rel="noopener noreferrer">', '</a>' ),
|
1508 |
Â
public static function get_source_list( $page = 1 ) {
|
1509 |
Â
$args['page'] = $page;
|
1510 |
Â
$source_data = CFF_Db::source_query( $args );
|
1511 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
1512 |
Â
|
1513 |
Â
$legacy_data = \CustomFacebookFeed\CFF_FB_Settings::get_legacy_settings( array() );
|
1514 |
Â
|
1516 |
Â
|
1517 |
Â
$return = array();
|
1518 |
Â
foreach ( $source_data as $source ) {
|
1519 |
+
$info = ! empty( $source['info'] ) ? json_decode($encryption->decrypt( $source['info'] ) ) : array();
|
1520 |
Â
$avatar = \CustomFacebookFeed\CFF_Parse::get_avatar( $info );
|
1521 |
Â
|
1522 |
Â
$source['avatar_url'] = $avatar;
|
1523 |
Â
|
1524 |
+
$source['needs_update'] = CFF_Source::needs_update( $source, $info );
|
1525 |
+
|
1526 |
Â
if ( $source['account_id'] === $legacy_id ) {
|
1527 |
Â
$source['used_in'] = $source['used_in'] + 1;
|
1528 |
Â
if ( ! isset( $source['instances'] ) ) {
|
2583 |
Â
include_once CFF_BUILDER_DIR . 'templates/builder.php';
|
2584 |
Â
}
|
2585 |
Â
|
2586 |
+
}
|
inc/Builder/CFF_Feed_Saver.php
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
Â
namespace CustomFacebookFeed\Builder;
|
9 |
Â
|
10 |
Â
use CustomFacebookFeed\CFF_FB_Settings;
|
Â
|
|
11 |
Â
|
12 |
Â
class CFF_Feed_Saver {
|
13 |
Â
|
@@ -219,6 +220,7 @@ class CFF_Feed_Saver {
|
|
219 |
Â
* @since 4.0
|
220 |
Â
*/
|
221 |
Â
public function update() {
|
Â
|
|
222 |
Â
if ( ! isset( $this->sanitized_and_sorted_data ) ) {
|
223 |
Â
return false;
|
224 |
Â
}
|
@@ -231,6 +233,8 @@ class CFF_Feed_Saver {
|
|
231 |
Â
|
232 |
Â
if ( $this->is_legacy ) {
|
233 |
Â
$to_save_json = \CustomFacebookFeed\CFF_Utils::cff_json_encode( $settings_array );
|
Â
|
|
Â
|
|
234 |
Â
return update_option( 'cff_legacy_feed_settings', $to_save_json );
|
235 |
Â
}
|
236 |
Â
|
@@ -282,10 +286,10 @@ class CFF_Feed_Saver {
|
|
282 |
Â
*
|
283 |
Â
* @since 4.0
|
284 |
Â
*/
|
285 |
-
public function get_feed_settings() {
|
Â
|
|
286 |
Â
if ( $this->is_legacy ) {
|
287 |
-
$return =
|
288 |
-
|
289 |
Â
$this->feed_db_data = array(
|
290 |
Â
'id' => 'legacy',
|
291 |
Â
'feed_name' => __( 'Legacy Feeds', 'custom-facebook-feed' ),
|
@@ -351,9 +355,9 @@ class CFF_Feed_Saver {
|
|
351 |
Â
'account_id' => stripslashes( $source['account_id'] ),
|
352 |
Â
'account_type' => stripslashes( $source['account_type'] ),
|
353 |
Â
'privilege' => stripslashes( $source['privilege'] ),
|
354 |
-
'access_token' => stripslashes( $source['access_token'] ),
|
355 |
Â
'username' => stripslashes( $source['username'] ),
|
356 |
-
'info' => stripslashes( $source['info'] ),
|
357 |
Â
'error' => stripslashes( $source['error'] ),
|
358 |
Â
'expires' => stripslashes( $source['expires'] ),
|
359 |
Â
'avatar_url' => stripslashes( $source['avatar_url'] ),
|
@@ -381,9 +385,9 @@ class CFF_Feed_Saver {
|
|
381 |
Â
'account_id' => stripslashes( $source_query[0]['account_id'] ),
|
382 |
Â
'account_type' => stripslashes( $source_query[0]['account_type'] ),
|
383 |
Â
'privilege' => stripslashes( $source_query[0]['privilege'] ),
|
384 |
-
'access_token' => stripslashes( $source_query[0]['access_token'] ),
|
385 |
Â
'username' => stripslashes( $source_query[0]['username'] ),
|
386 |
-
'info' => stripslashes( $source_query[0]['info'] ),
|
387 |
Â
'expires' => stripslashes( $source_query[0]['expires'] ),
|
388 |
Â
);
|
389 |
Â
|
@@ -422,6 +426,7 @@ class CFF_Feed_Saver {
|
|
422 |
Â
|
423 |
Â
$args = array( 'id' => $sources );
|
424 |
Â
$source_query = CFF_Db::source_query( $args );
|
Â
|
|
425 |
Â
|
426 |
Â
$return['sources'] = array();
|
427 |
Â
if ( ! empty( $source_query ) ) {
|
@@ -430,9 +435,9 @@ class CFF_Feed_Saver {
|
|
430 |
Â
'record_id' => stripslashes( $source['id'] ),
|
431 |
Â
'account_id' => stripslashes( $source['account_id'] ),
|
432 |
Â
'account_type' => stripslashes( $source['account_type'] ),
|
433 |
-
'access_token' => stripslashes( $source['access_token'] ),
|
434 |
Â
'username' => stripslashes( $source['username'] ),
|
435 |
-
'info' => stripslashes( $source['info'] ),
|
436 |
Â
'expires' => stripslashes( $source['expires'] ),
|
437 |
Â
);
|
438 |
Â
}
|
@@ -798,8 +803,9 @@ class CFF_Feed_Saver {
|
|
798 |
Â
|
799 |
Â
public static function set_legacy_feed_settings() {
|
800 |
Â
$to_save = CFF_Post_Set::legacy_to_builder_convert();
|
801 |
-
|
802 |
Â
$to_save_json = \CustomFacebookFeed\CFF_Utils::cff_json_encode( $to_save );
|
Â
|
|
803 |
Â
|
804 |
Â
update_option( 'cff_legacy_feed_settings', $to_save_json );
|
805 |
Â
}
|
8 |
Â
namespace CustomFacebookFeed\Builder;
|
9 |
Â
|
10 |
Â
use CustomFacebookFeed\CFF_FB_Settings;
|
11 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
12 |
Â
|
13 |
Â
class CFF_Feed_Saver {
|
14 |
Â
|
220 |
Â
* @since 4.0
|
221 |
Â
*/
|
222 |
Â
public function update() {
|
223 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
224 |
Â
if ( ! isset( $this->sanitized_and_sorted_data ) ) {
|
225 |
Â
return false;
|
226 |
Â
}
|
233 |
Â
|
234 |
Â
if ( $this->is_legacy ) {
|
235 |
Â
$to_save_json = \CustomFacebookFeed\CFF_Utils::cff_json_encode( $settings_array );
|
236 |
+
$to_save_json = $encryption->maybe_encrypt( $to_save_json );
|
237 |
+
|
238 |
Â
return update_option( 'cff_legacy_feed_settings', $to_save_json );
|
239 |
Â
}
|
240 |
Â
|
286 |
Â
*
|
287 |
Â
* @since 4.0
|
288 |
Â
*/
|
289 |
+
public function get_feed_settings( $is_export = false ) {
|
290 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
291 |
Â
if ( $this->is_legacy ) {
|
292 |
+
$return = CFF_FB_Settings::get_legacy_settings( array() ) ;
|
Â
|
|
293 |
Â
$this->feed_db_data = array(
|
294 |
Â
'id' => 'legacy',
|
295 |
Â
'feed_name' => __( 'Legacy Feeds', 'custom-facebook-feed' ),
|
355 |
Â
'account_id' => stripslashes( $source['account_id'] ),
|
356 |
Â
'account_type' => stripslashes( $source['account_type'] ),
|
357 |
Â
'privilege' => stripslashes( $source['privilege'] ),
|
358 |
+
'access_token' => $is_export === true ? stripslashes( $source['access_token'] ) : stripslashes( $encryption->decrypt( $source['access_token'] ) ),
|
359 |
Â
'username' => stripslashes( $source['username'] ),
|
360 |
+
'info' => stripslashes( $encryption->decrypt( $source['info'] ) ),
|
361 |
Â
'error' => stripslashes( $source['error'] ),
|
362 |
Â
'expires' => stripslashes( $source['expires'] ),
|
363 |
Â
'avatar_url' => stripslashes( $source['avatar_url'] ),
|
385 |
Â
'account_id' => stripslashes( $source_query[0]['account_id'] ),
|
386 |
Â
'account_type' => stripslashes( $source_query[0]['account_type'] ),
|
387 |
Â
'privilege' => stripslashes( $source_query[0]['privilege'] ),
|
388 |
+
'access_token' => stripslashes( $encryption->decrypt( $source_query[0]['access_token'] ) ),
|
389 |
Â
'username' => stripslashes( $source_query[0]['username'] ),
|
390 |
+
'info' => stripslashes( $encryption->decrypt( $source_query[0]['info'] ) ),
|
391 |
Â
'expires' => stripslashes( $source_query[0]['expires'] ),
|
392 |
Â
);
|
393 |
Â
|
426 |
Â
|
427 |
Â
$args = array( 'id' => $sources );
|
428 |
Â
$source_query = CFF_Db::source_query( $args );
|
429 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
430 |
Â
|
431 |
Â
$return['sources'] = array();
|
432 |
Â
if ( ! empty( $source_query ) ) {
|
435 |
Â
'record_id' => stripslashes( $source['id'] ),
|
436 |
Â
'account_id' => stripslashes( $source['account_id'] ),
|
437 |
Â
'account_type' => stripslashes( $source['account_type'] ),
|
438 |
+
'access_token' => stripslashes( $encryption->decrypt( $source['access_token'] ) ),
|
439 |
Â
'username' => stripslashes( $source['username'] ),
|
440 |
+
'info' => stripslashes( $encryption->decrypt( $source['info'] ) ),
|
441 |
Â
'expires' => stripslashes( $source['expires'] ),
|
442 |
Â
);
|
443 |
Â
}
|
803 |
Â
|
804 |
Â
public static function set_legacy_feed_settings() {
|
805 |
Â
$to_save = CFF_Post_Set::legacy_to_builder_convert();
|
806 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
807 |
Â
$to_save_json = \CustomFacebookFeed\CFF_Utils::cff_json_encode( $to_save );
|
808 |
+
$to_save_json = $encryption->maybe_encrypt( $to_save_json );
|
809 |
Â
|
810 |
Â
update_option( 'cff_legacy_feed_settings', $to_save_json );
|
811 |
Â
}
|
inc/Builder/CFF_Feed_Saver_Manager.php
CHANGED
@@ -89,6 +89,7 @@ class CFF_Feed_Saver_Manager {
|
|
89 |
Â
$settings_data['playlist'] = CFF_Source::extract_id( $settings_data['playlist'], 'playlist' );
|
90 |
Â
}
|
91 |
Â
|
Â
|
|
92 |
Â
$feed_saver = new CFF_Feed_Saver( $feed_id );
|
93 |
Â
$feed_saver->set_feed_name( $feed_name );
|
94 |
Â
$feed_saver->set_data( $settings_data );
|
89 |
Â
$settings_data['playlist'] = CFF_Source::extract_id( $settings_data['playlist'], 'playlist' );
|
90 |
Â
}
|
91 |
Â
|
92 |
+
unset($settings_data['accesstoken']);
|
93 |
Â
$feed_saver = new CFF_Feed_Saver( $feed_id );
|
94 |
Â
$feed_saver->set_feed_name( $feed_name );
|
95 |
Â
$feed_saver->set_data( $settings_data );
|
inc/Builder/CFF_Source.php
CHANGED
@@ -33,7 +33,11 @@ class CFF_Source {
|
|
33 |
Â
* @since 4.0
|
34 |
Â
*/
|
35 |
Â
public static function builder_update() {
|
36 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
37 |
Â
|
38 |
Â
$cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
|
39 |
Â
$cap = apply_filters( 'cff_settings_pages_capability', $cap );
|
@@ -108,7 +112,8 @@ class CFF_Source {
|
|
108 |
Â
|
109 |
Â
// don't update or insert the access token if there is an API error
|
110 |
Â
if ( ! isset( $header_details->error ) && ! isset( $header_details->cached_error ) ) {
|
111 |
-
$source_data['error']
|
Â
|
|
112 |
Â
CFF_Source::update_or_insert( $source_data );
|
113 |
Â
}
|
114 |
Â
|
@@ -150,7 +155,8 @@ class CFF_Source {
|
|
150 |
Â
$source_data['info'] = $header_details;
|
151 |
Â
// don't update or insert the access token if there is an API error
|
152 |
Â
if ( ! isset( $header_details->error ) ) {
|
153 |
-
$source_data['error']
|
Â
|
|
154 |
Â
CFF_Source::update_or_insert( $source_data );
|
155 |
Â
}
|
156 |
Â
endforeach;
|
@@ -377,8 +383,8 @@ class CFF_Source {
|
|
377 |
Â
#$urls['group'] = 'https://api.smashballoon.com/v2/facebook-group-login.php?state=' . $admin_url_state;
|
378 |
Â
|
379 |
Â
$sb_admin_email = get_option('admin_email');
|
380 |
-
$urls['page'] = 'https://connect.smashballoon.com/auth/fb/?wordpress_user=' . $sb_admin_email . '&state=';
|
381 |
-
$urls['group'] = 'https://connect.smashballoon.com/auth/fb/?wordpress_user=' . $sb_admin_email . '&state=';
|
382 |
Â
$urls['stateURL'] = $admin_url_state;
|
383 |
Â
|
384 |
Â
return $urls;
|
@@ -586,6 +592,8 @@ class CFF_Source {
|
|
586 |
Â
}
|
587 |
Â
CFF_Source::insert( $source_data );
|
588 |
Â
}
|
Â
|
|
Â
|
|
589 |
Â
}
|
590 |
Â
|
591 |
Â
/**
|
@@ -642,11 +650,62 @@ class CFF_Source {
|
|
642 |
Â
if ( isset( $source_data['name'] ) ) {
|
643 |
Â
$source_data['username'] = $source_data['name'];
|
644 |
Â
}
|
645 |
-
$data
|
646 |
Â
|
647 |
Â
return CFF_Db::source_update( $data, $where );
|
648 |
Â
}
|
649 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
650 |
Â
/**
|
651 |
Â
* Attempts to find the album or playlist ID from
|
652 |
Â
* a Facebook URL
|
@@ -690,7 +749,6 @@ class CFF_Source {
|
|
690 |
Â
$id = explode( '.', $id_pieces )[1];
|
691 |
Â
} else {
|
692 |
Â
$id = $matches[0];
|
693 |
-
error_log(json_encode($matches));
|
694 |
Â
}
|
695 |
Â
}
|
696 |
Â
|
@@ -997,4 +1055,4 @@ class CFF_Source {
|
|
997 |
Â
);
|
998 |
Â
return \CustomFacebookFeed\Builder\CFF_Source::update_or_insert( $source_data );
|
999 |
Â
}
|
1000 |
-
}
|
33 |
Â
* @since 4.0
|
34 |
Â
*/
|
35 |
Â
public static function builder_update() {
|
36 |
+
$action = 'cff-admin';
|
37 |
+
if ( ! empty( $_POST['settings_page'] ) ) {
|
38 |
+
$action = 'cff_admin_nonce';
|
39 |
+
}
|
40 |
+
check_ajax_referer( $action , 'nonce');
|
41 |
Â
|
42 |
Â
$cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
|
43 |
Â
$cap = apply_filters( 'cff_settings_pages_capability', $cap );
|
112 |
Â
|
113 |
Â
// don't update or insert the access token if there is an API error
|
114 |
Â
if ( ! isset( $header_details->error ) && ! isset( $header_details->cached_error ) ) {
|
115 |
+
$source_data['error'] = '';
|
116 |
+
$source_data['info']->connected_version = CFFVER;
|
117 |
Â
CFF_Source::update_or_insert( $source_data );
|
118 |
Â
}
|
119 |
Â
|
155 |
Â
$source_data['info'] = $header_details;
|
156 |
Â
// don't update or insert the access token if there is an API error
|
157 |
Â
if ( ! isset( $header_details->error ) ) {
|
158 |
+
$source_data['error'] = '';
|
159 |
+
$source_data['info']->connected_version = CFFVER;
|
160 |
Â
CFF_Source::update_or_insert( $source_data );
|
161 |
Â
}
|
162 |
Â
endforeach;
|
383 |
Â
#$urls['group'] = 'https://api.smashballoon.com/v2/facebook-group-login.php?state=' . $admin_url_state;
|
384 |
Â
|
385 |
Â
$sb_admin_email = get_option('admin_email');
|
386 |
+
$urls['page'] = 'https://connect.smashballoon.com/auth/fb/?wordpress_user=' . $sb_admin_email . '&vn=' . CFFVER . '&state=';
|
387 |
+
$urls['group'] = 'https://connect.smashballoon.com/auth/fb/?wordpress_user=' . $sb_admin_email . '&vn=' . CFFVER . '&state=';
|
388 |
Â
$urls['stateURL'] = $admin_url_state;
|
389 |
Â
|
390 |
Â
return $urls;
|
592 |
Â
}
|
593 |
Â
CFF_Source::insert( $source_data );
|
594 |
Â
}
|
595 |
+
|
596 |
+
CFF_Source::after_update_or_insert( $source_data );
|
597 |
Â
}
|
598 |
Â
|
599 |
Â
/**
|
650 |
Â
if ( isset( $source_data['name'] ) ) {
|
651 |
Â
$source_data['username'] = $source_data['name'];
|
652 |
Â
}
|
653 |
+
$data = $source_data;
|
654 |
Â
|
655 |
Â
return CFF_Db::source_update( $data, $where );
|
656 |
Â
}
|
657 |
Â
|
658 |
+
/**
|
659 |
+
* Do something after a source is updated or inserted
|
660 |
+
*
|
661 |
+
* @param array $source_data
|
662 |
+
* @since 4.0.6/4.0.9
|
663 |
+
*/
|
664 |
+
public static function after_update_or_insert( $source_data ) {
|
665 |
+
|
666 |
+
// check to see if all groups updated
|
667 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
668 |
+
|
669 |
+
if ( empty( $cff_statuses_option['groups_need_update'] ) ) {
|
670 |
+
return;
|
671 |
+
}
|
672 |
+
$groups = \CustomFacebookFeed\Builder\CFF_Db::source_query( array( 'type' => 'group' ) );
|
673 |
+
|
674 |
+
$cff_statuses_option['groups_need_update'] = false;
|
675 |
+
if ( empty( $groups ) ) {
|
676 |
+
update_option( 'cff_statuses', $cff_statuses_option, false );
|
677 |
+
} else {
|
678 |
+
$encryption = new \CustomFacebookFeed\SB_Facebook_Data_Encryption();
|
679 |
+
$groups_need_update = false;
|
680 |
+
foreach ( $groups as $source ) {
|
681 |
+
$info = ! empty( $source['info'] ) ? json_decode( $encryption->decrypt( $source['info'] ) ) : array();
|
682 |
+
if ( \CustomFacebookFeed\Builder\CFF_Source::needs_update( $source, $info ) ) {
|
683 |
+
$groups_need_update = true;
|
684 |
+
}
|
685 |
+
}
|
686 |
+
$cff_statuses_option['groups_need_update'] = $groups_need_update;
|
687 |
+
update_option( 'cff_statuses', $cff_statuses_option, false );
|
688 |
+
}
|
689 |
+
}
|
690 |
+
|
691 |
+
/**
|
692 |
+
* @param array $source
|
693 |
+
* @param array $source_info
|
694 |
+
*
|
695 |
+
* @return bool
|
696 |
+
* @since 4.0.6/4.0.9
|
697 |
+
*/
|
698 |
+
public static function needs_update( $source, $source_info ) {
|
699 |
+
if ( 'group' === $source['account_type'] ) {
|
700 |
+
$connected_version = is_object( $source_info ) && isset( $source_info->connected_version ) ? $source_info->connected_version : 0;
|
701 |
+
if ( version_compare( $connected_version, '4.0.9', '<' ) ) {
|
702 |
+
return true;
|
703 |
+
}
|
704 |
+
}
|
705 |
+
|
706 |
+
return false;
|
707 |
+
}
|
708 |
+
|
709 |
Â
/**
|
710 |
Â
* Attempts to find the album or playlist ID from
|
711 |
Â
* a Facebook URL
|
749 |
Â
$id = explode( '.', $id_pieces )[1];
|
750 |
Â
} else {
|
751 |
Â
$id = $matches[0];
|
Â
|
|
752 |
Â
}
|
753 |
Â
}
|
754 |
Â
|
1055 |
Â
);
|
1056 |
Â
return \CustomFacebookFeed\Builder\CFF_Source::update_or_insert( $source_data );
|
1057 |
Â
}
|
1058 |
+
}
|
inc/Builder/Controls/CFF_Customview_Control.php
CHANGED
@@ -122,11 +122,6 @@ class CFF_Customview_Control extends CFF_Controls_Base{
|
|
122 |
Â
<span>{{source.account_id}}</span>
|
123 |
Â
<div class="cff-fb-srcs-info-icon" v-html="svgIcons['copy2']" @click.prevent.default="copyToClipBoard(source.account_id)"></div>
|
124 |
Â
</div>
|
125 |
-
<div class="cff-fb-srcs-info-item">
|
126 |
-
<strong>{{genericText.token}}</strong>
|
127 |
-
<span>{{source.access_token}}</span>
|
128 |
-
<div class="cff-fb-srcs-info-icon" v-html="svgIcons['copy2']" @click.prevent.default="copyToClipBoard(source.access_token)"></div>
|
129 |
-
</div>
|
130 |
Â
</div>
|
131 |
Â
</div>
|
132 |
Â
|
122 |
Â
<span>{{source.account_id}}</span>
|
123 |
Â
<div class="cff-fb-srcs-info-icon" v-html="svgIcons['copy2']" @click.prevent.default="copyToClipBoard(source.account_id)"></div>
|
124 |
Â
</div>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
125 |
Â
</div>
|
126 |
Â
</div>
|
127 |
Â
|
inc/CFF_Cache.php
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
Â
*/
|
9 |
Â
|
10 |
Â
namespace CustomFacebookFeed;
|
Â
|
|
11 |
Â
|
12 |
Â
class CFF_Cache {
|
13 |
Â
|
@@ -76,6 +77,11 @@ class CFF_Cache {
|
|
76 |
Â
*/
|
77 |
Â
private $header_backup;
|
78 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
79 |
Â
/**
|
80 |
Â
* CFF_Cache constructor. Set the feed id, cache key, legacy
|
81 |
Â
*
|
@@ -96,6 +102,7 @@ class CFF_Cache {
|
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
$this->feed_id = $feed_id;
|
Â
|
|
99 |
Â
}
|
100 |
Â
|
101 |
Â
/**
|
@@ -209,29 +216,31 @@ class CFF_Cache {
|
|
209 |
Â
* @since 4.0
|
210 |
Â
*/
|
211 |
Â
public function get( $type ) {
|
Â
|
|
212 |
Â
switch( $type ) {
|
213 |
Â
case 'posts':
|
214 |
-
return $this->posts;
|
215 |
Â
break;
|
216 |
Â
case 'posts' . $this->suffix:
|
217 |
-
return $this->posts_page;
|
218 |
Â
break;
|
219 |
Â
case 'header':
|
220 |
-
return $this->header;
|
221 |
Â
break;
|
222 |
Â
case 'resized_images':
|
223 |
-
return $this->resized_images;
|
224 |
Â
break;
|
225 |
Â
case 'meta':
|
226 |
-
return $this->meta;
|
227 |
Â
break;
|
228 |
Â
case 'posts_backup':
|
229 |
-
return $this->posts_backup;
|
230 |
Â
break;
|
231 |
Â
case 'header_backup':
|
232 |
-
return $this->header_backup;
|
233 |
Â
break;
|
234 |
Â
}
|
Â
|
|
235 |
Â
}
|
236 |
Â
|
237 |
Â
/**
|
@@ -294,16 +303,18 @@ class CFF_Cache {
|
|
294 |
Â
$cache_value = CFF_Utils::cff_json_encode( $cache_value );
|
295 |
Â
}
|
296 |
Â
|
Â
|
|
Â
|
|
297 |
Â
if ( $this->is_legacy ) {
|
298 |
Â
if ( $cache_key === 'posts' ) {
|
299 |
-
set_transient( $this->feed_id, $
|
300 |
Â
if ( $include_backup ) {
|
301 |
-
set_transient( '!cff_backup_' . $this->feed_id, $
|
302 |
Â
}
|
303 |
Â
} elseif ( strpos( $cache_key, 'posts' ) !== false ) {
|
304 |
-
set_transient( $this->feed_id, $
|
305 |
Â
} elseif ( strpos( $cache_key, 'header' ) !== false ) {
|
306 |
-
set_transient( $this->feed_id, $
|
307 |
Â
}
|
308 |
Â
|
309 |
Â
return 1;
|
@@ -322,7 +333,7 @@ class CFF_Cache {
|
|
322 |
Â
$where = array();
|
323 |
Â
$format = array();
|
324 |
Â
|
325 |
-
$data['cache_value'] = $cache_value;
|
326 |
Â
$format[] = '%s';
|
327 |
Â
|
328 |
Â
$data['last_updated'] = date( 'Y-m-d H:i:s' );
|
@@ -380,7 +391,7 @@ class CFF_Cache {
|
|
380 |
Â
$affected = $wpdb->query( $wpdb->prepare(
|
381 |
Â
"UPDATE $cache_table_name
|
382 |
Â
SET cache_value = ''
|
383 |
-
WHERE feed_id = %d
|
384 |
Â
AND cache_key NOT IN ( 'posts', 'posts_backup', 'header_backup' );",
|
385 |
Â
$this->feed_id ) );
|
386 |
Â
} else {
|
@@ -545,4 +556,45 @@ class CFF_Cache {
|
|
545 |
Â
private function get_wp_cache_key() {
|
546 |
Â
return 'cff_feed_'. $this->feed_id . '_' . $this->page;
|
547 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
548 |
Â
}
|
8 |
Â
*/
|
9 |
Â
|
10 |
Â
namespace CustomFacebookFeed;
|
11 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
12 |
Â
|
13 |
Â
class CFF_Cache {
|
14 |
Â
|
77 |
Â
*/
|
78 |
Â
private $header_backup;
|
79 |
Â
|
80 |
+
/**
|
81 |
+
* @var object|SB_Facebook_Data_Encryption
|
82 |
+
*/
|
83 |
+
protected $encryption;
|
84 |
+
|
85 |
Â
/**
|
86 |
Â
* CFF_Cache constructor. Set the feed id, cache key, legacy
|
87 |
Â
*
|
102 |
Â
}
|
103 |
Â
|
104 |
Â
$this->feed_id = $feed_id;
|
105 |
+
$this->encryption = new SB_Facebook_Data_Encryption();
|
106 |
Â
}
|
107 |
Â
|
108 |
Â
/**
|
216 |
Â
* @since 4.0
|
217 |
Â
*/
|
218 |
Â
public function get( $type ) {
|
219 |
+
$return = array();
|
220 |
Â
switch( $type ) {
|
221 |
Â
case 'posts':
|
222 |
+
$return = $this->posts;
|
223 |
Â
break;
|
224 |
Â
case 'posts' . $this->suffix:
|
225 |
+
$return = $this->posts_page;
|
226 |
Â
break;
|
227 |
Â
case 'header':
|
228 |
+
$return = $this->header;
|
229 |
Â
break;
|
230 |
Â
case 'resized_images':
|
231 |
+
$return = $this->resized_images;
|
232 |
Â
break;
|
233 |
Â
case 'meta':
|
234 |
+
$return = $this->meta;
|
235 |
Â
break;
|
236 |
Â
case 'posts_backup':
|
237 |
+
$return = $this->posts_backup;
|
238 |
Â
break;
|
239 |
Â
case 'header_backup':
|
240 |
+
$return = $this->header_backup;
|
241 |
Â
break;
|
242 |
Â
}
|
243 |
+
return $this->maybe_decrypt( $return );
|
244 |
Â
}
|
245 |
Â
|
246 |
Â
/**
|
303 |
Â
$cache_value = CFF_Utils::cff_json_encode( $cache_value );
|
304 |
Â
}
|
305 |
Â
|
306 |
+
$encrypted_cache_value = $this->maybe_encrypt( $cache_value );
|
307 |
+
|
308 |
Â
if ( $this->is_legacy ) {
|
309 |
Â
if ( $cache_key === 'posts' ) {
|
310 |
+
set_transient( $this->feed_id, $encrypted_cache_value, $this->cache_time );
|
311 |
Â
if ( $include_backup ) {
|
312 |
+
set_transient( '!cff_backup_' . $this->feed_id, $encrypted_cache_value, YEAR_IN_SECONDS );
|
313 |
Â
}
|
314 |
Â
} elseif ( strpos( $cache_key, 'posts' ) !== false ) {
|
315 |
+
set_transient( $this->feed_id, $encrypted_cache_value, $this->cache_time );
|
316 |
Â
} elseif ( strpos( $cache_key, 'header' ) !== false ) {
|
317 |
+
set_transient( $this->feed_id, $encrypted_cache_value, $this->cache_time );
|
318 |
Â
}
|
319 |
Â
|
320 |
Â
return 1;
|
333 |
Â
$where = array();
|
334 |
Â
$format = array();
|
335 |
Â
|
336 |
+
$data['cache_value'] = $this->maybe_encrypt( $cache_value );
|
337 |
Â
$format[] = '%s';
|
338 |
Â
|
339 |
Â
$data['last_updated'] = date( 'Y-m-d H:i:s' );
|
391 |
Â
$affected = $wpdb->query( $wpdb->prepare(
|
392 |
Â
"UPDATE $cache_table_name
|
393 |
Â
SET cache_value = ''
|
394 |
+
WHERE feed_id = %d
|
395 |
Â
AND cache_key NOT IN ( 'posts', 'posts_backup', 'header_backup' );",
|
396 |
Â
$this->feed_id ) );
|
397 |
Â
} else {
|
556 |
Â
private function get_wp_cache_key() {
|
557 |
Â
return 'cff_feed_'. $this->feed_id . '_' . $this->page;
|
558 |
Â
}
|
559 |
+
/**
|
560 |
+
* Uses a raw value and attempts to encrypt it
|
561 |
+
*
|
562 |
+
* @param $value
|
563 |
+
*
|
564 |
+
* @return bool|string
|
565 |
+
*/
|
566 |
+
private function maybe_encrypt( $value ) {
|
567 |
+
if ( ! empty( $value ) && ! is_string( $value ) ) {
|
568 |
+
$value = cff_json_encode( $value );
|
569 |
+
}
|
570 |
+
if ( empty( $value ) ) {
|
571 |
+
return $value;
|
572 |
+
}
|
573 |
+
|
574 |
+
return $this->encryption->encrypt( $value );
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Uses a raw value and attempts to decrypt it
|
579 |
+
*
|
580 |
+
* @param $value
|
581 |
+
*
|
582 |
+
* @return bool|string
|
583 |
+
*/
|
584 |
+
private function maybe_decrypt( $value ) {
|
585 |
+
if ( ! is_string( $value ) ) {
|
586 |
+
return $value;
|
587 |
+
}
|
588 |
+
if ( strpos( $value, '{' ) === 0 ) {
|
589 |
+
return $value;
|
590 |
+
}
|
591 |
+
|
592 |
+
$decrypted = $this->encryption->decrypt( $value );
|
593 |
+
|
594 |
+
if ( ! $decrypted ) {
|
595 |
+
return $value;
|
596 |
+
}
|
597 |
+
|
598 |
+
return $decrypted;
|
599 |
+
}
|
600 |
Â
}
|
inc/CFF_Error_Reporter.php
CHANGED
@@ -308,6 +308,12 @@ class CFF_Error_Reporter
|
|
308 |
Â
delete_option( $this->reporter_key );
|
309 |
Â
}
|
310 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
311 |
Â
/**
|
312 |
Â
* @param $type
|
313 |
Â
* @param $message
|
308 |
Â
delete_option( $this->reporter_key );
|
309 |
Â
}
|
310 |
Â
|
311 |
+
public function reset_api_errors() {
|
312 |
+
$this->errors['connection'] = array();
|
313 |
+
$this->errors['accounts'] = array();
|
314 |
+
update_option( $this->reporter_key, $this->errors, false );
|
315 |
+
}
|
316 |
+
|
317 |
Â
/**
|
318 |
Â
* @param $type
|
319 |
Â
* @param $message
|
inc/CFF_FB_Settings.php
CHANGED
@@ -390,7 +390,10 @@ class CFF_FB_Settings {
|
|
390 |
Â
* @return array
|
391 |
Â
*/
|
392 |
Â
public static function get_legacy_settings( $shortcode_atts ) {
|
Â
|
|
393 |
Â
$options = get_option( 'cff_legacy_feed_settings', array() );
|
Â
|
|
Â
|
|
394 |
Â
if ( ! empty( $options ) ) {
|
395 |
Â
$options = json_decode( $options, true );
|
396 |
Â
if ( empty( $options['id'] ) || empty( $options['sources'] ) ) {
|
390 |
Â
* @return array
|
391 |
Â
*/
|
392 |
Â
public static function get_legacy_settings( $shortcode_atts ) {
|
393 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
394 |
Â
$options = get_option( 'cff_legacy_feed_settings', array() );
|
395 |
+
$options = $encryption->maybe_decrypt( $options );
|
396 |
+
|
397 |
Â
if ( ! empty( $options ) ) {
|
398 |
Â
$options = json_decode( $options, true );
|
399 |
Â
if ( empty( $options['id'] ) || empty( $options['sources'] ) ) {
|
inc/CFF_Group_Posts.php
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
Â
* @since 3.19.3
|
8 |
Â
*/
|
9 |
Â
namespace CustomFacebookFeed;
|
Â
|
|
10 |
Â
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
Â
|
12 |
Â
|
@@ -57,8 +58,10 @@ class CFF_Group_Posts{
|
|
57 |
Â
*/
|
58 |
Â
private $is_event_page;
|
59 |
Â
|
60 |
-
|
61 |
-
|
Â
|
|
Â
|
|
62 |
Â
|
63 |
Â
/**
|
64 |
Â
* Construct.
|
@@ -69,6 +72,7 @@ class CFF_Group_Posts{
|
|
69 |
Â
* @access public
|
70 |
Â
*/
|
71 |
Â
function __construct($group_id, $feed_options, $api_call_url, $data_att_html,$is_event_page) {
|
Â
|
|
72 |
Â
$this->cache_name = '!cff_group_'. $group_id . '_' . str_replace(',', '_', $feed_options['type']);
|
73 |
Â
$this->posts_cache_data = get_option($this->cache_name);
|
74 |
Â
$this->feed_options = $feed_options;
|
@@ -83,7 +87,7 @@ class CFF_Group_Posts{
|
|
83 |
Â
$this->posts_cache_data->shortcode_options = $this->data_att_html;
|
84 |
Â
$this->posts_cache_data->data = [];
|
85 |
Â
}else{
|
86 |
-
$this->posts_cache_data = json_decode($this->posts_cache_data);
|
87 |
Â
}
|
88 |
Â
|
89 |
Â
}
|
@@ -232,7 +236,7 @@ class CFF_Group_Posts{
|
|
232 |
Â
$this->posts_cache_data->is_event_page = $this->is_event_page;
|
233 |
Â
$this->posts_cache_data->data = array_slice( $this->posts_array, 0, 100 );
|
234 |
Â
if(sizeof($this->posts_array) > 0){
|
235 |
-
update_option( $this->cache_name, json_encode($this->posts_cache_data), false );
|
236 |
Â
}
|
237 |
Â
|
238 |
Â
}
|
@@ -288,13 +292,14 @@ class CFF_Group_Posts{
|
|
288 |
Â
static function cron_update_group_persistent_cache(){
|
289 |
Â
global $wpdb;
|
290 |
Â
$table_name = $wpdb->prefix . "options";
|
Â
|
|
291 |
Â
$persistent_groups = $wpdb->get_results( "
|
292 |
Â
SELECT `option_name` AS `name`, `option_value` AS `value`
|
293 |
Â
FROM $table_name
|
294 |
Â
WHERE `option_name` LIKE ('%!cff\_group\_%')
|
295 |
Â
" );
|
296 |
Â
foreach ($persistent_groups as $group) {
|
297 |
-
$group_json = json_decode($group->value, true);
|
298 |
Â
CFF_Group_Posts::update_or_add_group($group->name, $group_json);
|
299 |
Â
}
|
300 |
Â
}
|
@@ -311,6 +316,7 @@ class CFF_Group_Posts{
|
|
311 |
Â
$is_event_page = isset($group_cache['is_event_page']) ? $group_cache['is_event_page'] : false;
|
312 |
Â
$data_att_html = $group_cache['shortcode_options'];
|
313 |
Â
$new_cached_posts = $cached_posts;
|
Â
|
|
314 |
Â
|
315 |
Â
$posts_array_api = json_decode(CFF_Group_Posts::api_call($api_url, $data_att_html));
|
316 |
Â
foreach ($posts_array_api->data as $single_post) {
|
@@ -336,7 +342,7 @@ class CFF_Group_Posts{
|
|
336 |
Â
$new_cached_posts = array_slice( $new_cached_posts, 0, 100 );
|
337 |
Â
$posts_cache_data->data = $new_cached_posts;
|
338 |
Â
if(sizeof($new_cached_posts) > 0){
|
339 |
-
update_option( $cache_name, json_encode($posts_cache_data), false );
|
340 |
Â
}
|
341 |
Â
|
342 |
Â
}
|
7 |
Â
* @since 3.19.3
|
8 |
Â
*/
|
9 |
Â
namespace CustomFacebookFeed;
|
10 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
11 |
Â
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
12 |
Â
|
13 |
Â
|
58 |
Â
*/
|
59 |
Â
private $is_event_page;
|
60 |
Â
|
61 |
+
/**
|
62 |
+
* @var class
|
63 |
+
*/
|
64 |
+
private $encryption;
|
65 |
Â
|
66 |
Â
/**
|
67 |
Â
* Construct.
|
72 |
Â
* @access public
|
73 |
Â
*/
|
74 |
Â
function __construct($group_id, $feed_options, $api_call_url, $data_att_html,$is_event_page) {
|
75 |
+
$this->encryption = new SB_Facebook_Data_Encryption();
|
76 |
Â
$this->cache_name = '!cff_group_'. $group_id . '_' . str_replace(',', '_', $feed_options['type']);
|
77 |
Â
$this->posts_cache_data = get_option($this->cache_name);
|
78 |
Â
$this->feed_options = $feed_options;
|
87 |
Â
$this->posts_cache_data->shortcode_options = $this->data_att_html;
|
88 |
Â
$this->posts_cache_data->data = [];
|
89 |
Â
}else{
|
90 |
+
$this->posts_cache_data = json_decode( $this->encryption->maybe_decrypt( $this->posts_cache_data ) ) ;
|
91 |
Â
}
|
92 |
Â
|
93 |
Â
}
|
236 |
Â
$this->posts_cache_data->is_event_page = $this->is_event_page;
|
237 |
Â
$this->posts_cache_data->data = array_slice( $this->posts_array, 0, 100 );
|
238 |
Â
if(sizeof($this->posts_array) > 0){
|
239 |
+
update_option( $this->cache_name, $this->encryption->maybe_encrypt( json_encode($this->posts_cache_data) ) , false );
|
240 |
Â
}
|
241 |
Â
|
242 |
Â
}
|
292 |
Â
static function cron_update_group_persistent_cache(){
|
293 |
Â
global $wpdb;
|
294 |
Â
$table_name = $wpdb->prefix . "options";
|
295 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
296 |
Â
$persistent_groups = $wpdb->get_results( "
|
297 |
Â
SELECT `option_name` AS `name`, `option_value` AS `value`
|
298 |
Â
FROM $table_name
|
299 |
Â
WHERE `option_name` LIKE ('%!cff\_group\_%')
|
300 |
Â
" );
|
301 |
Â
foreach ($persistent_groups as $group) {
|
302 |
+
$group_json = json_decode( $encryption->maybe_decrypt( $group->value ), true);
|
303 |
Â
CFF_Group_Posts::update_or_add_group($group->name, $group_json);
|
304 |
Â
}
|
305 |
Â
}
|
316 |
Â
$is_event_page = isset($group_cache['is_event_page']) ? $group_cache['is_event_page'] : false;
|
317 |
Â
$data_att_html = $group_cache['shortcode_options'];
|
318 |
Â
$new_cached_posts = $cached_posts;
|
319 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
320 |
Â
|
321 |
Â
$posts_array_api = json_decode(CFF_Group_Posts::api_call($api_url, $data_att_html));
|
322 |
Â
foreach ($posts_array_api->data as $single_post) {
|
342 |
Â
$new_cached_posts = array_slice( $new_cached_posts, 0, 100 );
|
343 |
Â
$posts_cache_data->data = $new_cached_posts;
|
344 |
Â
if(sizeof($new_cached_posts) > 0){
|
345 |
+
update_option( $cache_name, $encryption->maybe_encrypt( json_encode( $posts_cache_data ) ), false );
|
346 |
Â
}
|
347 |
Â
|
348 |
Â
}
|
inc/CFF_Oembed.php
CHANGED
@@ -247,11 +247,19 @@ class CFF_Oembed
|
|
247 |
Â
public static function last_access_token() {
|
248 |
Â
$oembed_token_settings = get_option( 'cff_oembed_token', array() );
|
249 |
Â
$will_expire = CFF_Oembed::oembed_access_token_will_expire();
|
Â
|
|
Â
|
|
250 |
Â
if ( ! empty( $oembed_token_settings['access_token'] )
|
251 |
Â
&& (! $will_expire || $will_expire > time()) ) {
|
Â
|
|
Â
|
|
Â
|
|
252 |
Â
return str_replace(":", ":02Sb981f26534g75h091287a46p5l63", $oembed_token_settings['access_token']);
|
253 |
Â
} else {
|
254 |
Â
$settings_access_token = trim(get_option('cff_access_token'));
|
Â
|
|
Â
|
|
Â
|
|
255 |
Â
if ( ! empty( $settings_access_token ) ) {
|
256 |
Â
return str_replace(":", ":02Sb981f26534g75h091287a46p5l63", $settings_access_token);
|
257 |
Â
}
|
@@ -259,6 +267,9 @@ class CFF_Oembed
|
|
259 |
Â
if ( class_exists( 'SB_Instagram_Oembed' ) ) {
|
260 |
Â
$sbi_oembed_token_settings = get_option( 'sbi_oembed_token', array() );
|
261 |
Â
if ( ! empty( $sbi_oembed_token_settings['access_token'] ) ) {
|
Â
|
|
Â
|
|
Â
|
|
262 |
Â
return $sbi_oembed_token_settings['access_token'];
|
263 |
Â
}
|
264 |
Â
}
|
@@ -405,4 +416,4 @@ function cffOembedInit() {
|
|
405 |
Â
return new CFF_Oembed();
|
406 |
Â
}
|
407 |
Â
cffOembedInit();
|
408 |
-
*/
|
247 |
Â
public static function last_access_token() {
|
248 |
Â
$oembed_token_settings = get_option( 'cff_oembed_token', array() );
|
249 |
Â
$will_expire = CFF_Oembed::oembed_access_token_will_expire();
|
250 |
+
$encryption = new \CustomFacebookFeed\SB_Facebook_Data_Encryption();
|
251 |
+
|
252 |
Â
if ( ! empty( $oembed_token_settings['access_token'] )
|
253 |
Â
&& (! $will_expire || $will_expire > time()) ) {
|
254 |
+
if ( $encryption->decrypt( $oembed_token_settings['access_token'] ) ) {
|
255 |
+
$oembed_token_settings['access_token'] = $encryption->decrypt( $oembed_token_settings['access_token'] );
|
256 |
+
}
|
257 |
Â
return str_replace(":", ":02Sb981f26534g75h091287a46p5l63", $oembed_token_settings['access_token']);
|
258 |
Â
} else {
|
259 |
Â
$settings_access_token = trim(get_option('cff_access_token'));
|
260 |
+
if ( $encryption->decrypt( $settings_access_token ) ) {
|
261 |
+
$settings_access_token = $encryption->decrypt( $settings_access_token );
|
262 |
+
}
|
263 |
Â
if ( ! empty( $settings_access_token ) ) {
|
264 |
Â
return str_replace(":", ":02Sb981f26534g75h091287a46p5l63", $settings_access_token);
|
265 |
Â
}
|
267 |
Â
if ( class_exists( 'SB_Instagram_Oembed' ) ) {
|
268 |
Â
$sbi_oembed_token_settings = get_option( 'sbi_oembed_token', array() );
|
269 |
Â
if ( ! empty( $sbi_oembed_token_settings['access_token'] ) ) {
|
270 |
+
if ( $encryption->decrypt( $sbi_oembed_token_settings['access_token'] ) ) {
|
271 |
+
$sbi_oembed_token_settings['access_token'] = $encryption->decrypt( $sbi_oembed_token_settings['access_token'] );
|
272 |
+
}
|
273 |
Â
return $sbi_oembed_token_settings['access_token'];
|
274 |
Â
}
|
275 |
Â
}
|
416 |
Â
return new CFF_Oembed();
|
417 |
Â
}
|
418 |
Â
cffOembedInit();
|
419 |
+
*/
|
inc/CFF_Shortcode.php
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
Â
namespace CustomFacebookFeed;
|
9 |
Â
|
10 |
Â
use CustomFacebookFeed\Builder\CFF_Source;
|
Â
|
|
11 |
Â
|
12 |
Â
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
Â
die( '-1' );
|
@@ -290,6 +291,7 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
290 |
Â
* @since 2.19
|
291 |
Â
*/
|
292 |
Â
public function display_cff($atts) {
|
Â
|
|
293 |
Â
$this->options = get_option('cff_style_settings');
|
294 |
Â
$data_att_html = $this->cff_get_shortcode_data_attribute_html( $atts );
|
295 |
Â
$feed_id = empty( $atts['feed'] ) ? 'default' : intval( $atts['feed'] );
|
@@ -300,7 +302,10 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
300 |
Â
$this->atts = $this->fb_feed_settings->get_settings();
|
301 |
Â
$id_and_token = $this->fb_feed_settings->get_id_and_token();
|
302 |
Â
$this->page_id = $id_and_token['id'];
|
303 |
-
|
Â
|
|
Â
|
|
Â
|
|
304 |
Â
$this->atts = $this->cff_get_processed_options( $this->atts );
|
305 |
Â
|
306 |
Â
} else {
|
@@ -1835,7 +1840,8 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
1835 |
Â
|
1836 |
Â
if ( ! CFF_Utils::cff_is_pro_version() ) {
|
1837 |
Â
$this->page_id = $settings['id'];
|
1838 |
-
$
|
Â
|
|
1839 |
Â
$this->feed_id = ! empty( $feed_id ) ? $feed_id : 'default';
|
1840 |
Â
}
|
1841 |
Â
|
@@ -1951,7 +1957,10 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
1951 |
Â
if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
|
1952 |
Â
if($cff_cache_time_unit == 'hour' || $cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
|
1953 |
Â
if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
|
1954 |
-
|
Â
|
|
Â
|
|
Â
|
|
1955 |
Â
|
1956 |
Â
|
1957 |
Â
//********************************************//
|
@@ -2165,6 +2174,8 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
2165 |
Â
}
|
2166 |
Â
|
2167 |
Â
public static function get_single_event_data( $eventID, $access_token ) {
|
Â
|
|
Â
|
|
2168 |
Â
//Is it SSL?
|
2169 |
Â
$cff_ssl = '';
|
2170 |
Â
if (is_ssl()) $cff_ssl = '&return_ssl_resources=true';
|
@@ -2176,13 +2187,13 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
2176 |
Â
$transient_name = 'cff_tle_' . $eventID;
|
2177 |
Â
$transient_name = substr($transient_name, 0, 45);
|
2178 |
Â
|
2179 |
-
if ( false === ( $event_json = get_transient( $transient_name ) ) || $event_json === null ) {
|
2180 |
Â
//Get the contents of the Facebook page
|
2181 |
Â
$event_json = CFF_Utils::cff_fetchUrl($event_json_url);
|
2182 |
Â
//Cache the JSON for 180 days as the timeline event info probably isn't going to change
|
2183 |
-
set_transient( $transient_name, $event_json, 60 * 60 * 24 * 180 );
|
2184 |
Â
} else {
|
2185 |
-
$event_json = get_transient( $transient_name );
|
2186 |
Â
//If we can't find the transient then fall back to just getting the json from the api
|
2187 |
Â
if ($event_json == false) $event_json = CFF_Utils::cff_fetchUrl($event_json_url);
|
2188 |
Â
}
|
@@ -2252,4 +2263,4 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
|
|
2252 |
Â
}
|
2253 |
Â
|
2254 |
Â
|
2255 |
-
}
|
8 |
Â
namespace CustomFacebookFeed;
|
9 |
Â
|
10 |
Â
use CustomFacebookFeed\Builder\CFF_Source;
|
11 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
12 |
Â
|
13 |
Â
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
Â
die( '-1' );
|
291 |
Â
* @since 2.19
|
292 |
Â
*/
|
293 |
Â
public function display_cff($atts) {
|
294 |
+
do_action( 'cff_before_display_facebook' );
|
295 |
Â
$this->options = get_option('cff_style_settings');
|
296 |
Â
$data_att_html = $this->cff_get_shortcode_data_attribute_html( $atts );
|
297 |
Â
$feed_id = empty( $atts['feed'] ) ? 'default' : intval( $atts['feed'] );
|
302 |
Â
$this->atts = $this->fb_feed_settings->get_settings();
|
303 |
Â
$id_and_token = $this->fb_feed_settings->get_id_and_token();
|
304 |
Â
$this->page_id = $id_and_token['id'];
|
305 |
+
|
306 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
307 |
+
$this->access_token = $encryption->decrypt($id_and_token['token']) ? $encryption->decrypt($id_and_token['token']) : $id_and_token['token'];
|
308 |
+
|
309 |
Â
$this->atts = $this->cff_get_processed_options( $this->atts );
|
310 |
Â
|
311 |
Â
} else {
|
1840 |
Â
|
1841 |
Â
if ( ! CFF_Utils::cff_is_pro_version() ) {
|
1842 |
Â
$this->page_id = $settings['id'];
|
1843 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
1844 |
+
$this->access_token = $encryption->decrypt($settings['accesstoken']) ? $encryption->decrypt($settings['accesstoken']) : $settings['accesstoken'];
|
1845 |
Â
$this->feed_id = ! empty( $feed_id ) ? $feed_id : 'default';
|
1846 |
Â
}
|
1847 |
Â
|
1957 |
Â
if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
|
1958 |
Â
if($cff_cache_time_unit == 'hour' || $cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
|
1959 |
Â
if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
|
1960 |
+
if ( intval( $cff_cache_time ) < 1 ) {
|
1961 |
+
$cff_cache_time = 1;
|
1962 |
+
}
|
1963 |
+
$cache_seconds = intval( $cff_cache_time ) * intval( $cff_cache_time_unit );
|
1964 |
Â
|
1965 |
Â
|
1966 |
Â
//********************************************//
|
2174 |
Â
}
|
2175 |
Â
|
2176 |
Â
public static function get_single_event_data( $eventID, $access_token ) {
|
2177 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
2178 |
+
|
2179 |
Â
//Is it SSL?
|
2180 |
Â
$cff_ssl = '';
|
2181 |
Â
if (is_ssl()) $cff_ssl = '&return_ssl_resources=true';
|
2187 |
Â
$transient_name = 'cff_tle_' . $eventID;
|
2188 |
Â
$transient_name = substr($transient_name, 0, 45);
|
2189 |
Â
|
2190 |
+
if ( false === ( $event_json = $encryption->maybe_decrypt( get_transient( $transient_name ) ) ) || $event_json === null ) {
|
2191 |
Â
//Get the contents of the Facebook page
|
2192 |
Â
$event_json = CFF_Utils::cff_fetchUrl($event_json_url);
|
2193 |
Â
//Cache the JSON for 180 days as the timeline event info probably isn't going to change
|
2194 |
+
set_transient( $transient_name, $encryption->maybe_encrypt( $event_json ) , 60 * 60 * 24 * 180 );
|
2195 |
Â
} else {
|
2196 |
+
$event_json = $encryption->maybe_decrypt( get_transient( $transient_name ) );
|
2197 |
Â
//If we can't find the transient then fall back to just getting the json from the api
|
2198 |
Â
if ($event_json == false) $event_json = CFF_Utils::cff_fetchUrl($event_json_url);
|
2199 |
Â
}
|
2263 |
Â
}
|
2264 |
Â
|
2265 |
Â
|
2266 |
+
}
|
inc/CFF_Utils.php
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
Â
* @since 2.19
|
8 |
Â
*/
|
9 |
Â
namespace CustomFacebookFeed;
|
Â
|
|
10 |
Â
|
11 |
Â
|
12 |
Â
|
@@ -812,6 +813,11 @@ class CFF_Utils{
|
|
812 |
Â
$header_access_token = reset($access_token);
|
813 |
Â
if( empty($header_access_token) ) $header_access_token = key($access_token);
|
814 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
815 |
Â
$header_details_json_url = 'https://graph.facebook.com/v4.0/'.$page_id.'?fields=id,picture.height(150).width(150),cover,name,link'.$page_only_fields.'&access_token='. $header_access_token;
|
816 |
Â
|
817 |
Â
//Get the data
|
7 |
Â
* @since 2.19
|
8 |
Â
*/
|
9 |
Â
namespace CustomFacebookFeed;
|
10 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
11 |
Â
|
12 |
Â
|
13 |
Â
|
813 |
Â
$header_access_token = reset($access_token);
|
814 |
Â
if( empty($header_access_token) ) $header_access_token = key($access_token);
|
815 |
Â
}
|
816 |
+
|
817 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
818 |
+
$header_access_token = $encryption->decrypt($header_access_token) ? $encryption->decrypt($header_access_token) : $header_access_token;
|
819 |
+
|
820 |
+
|
821 |
Â
$header_details_json_url = 'https://graph.facebook.com/v4.0/'.$page_id.'?fields=id,picture.height(150).width(150),cover,name,link'.$page_only_fields.'&access_token='. $header_access_token;
|
822 |
Â
|
823 |
Â
//Get the data
|
inc/Custom_Facebook_Feed.php
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
Â
*/
|
9 |
Â
|
10 |
Â
namespace CustomFacebookFeed;
|
Â
|
|
11 |
Â
use CustomFacebookFeed\Admin\CFF_Admin;
|
12 |
Â
use CustomFacebookFeed\Admin\CFF_About;
|
13 |
Â
use CustomFacebookFeed\Admin\CFF_New_User;
|
@@ -623,6 +624,36 @@ final class Custom_Facebook_Feed{
|
|
623 |
Â
|
624 |
Â
update_option( 'cff_statuses', $cff_statuses_option );
|
625 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
626 |
Â
}
|
627 |
Â
|
628 |
Â
|
8 |
Â
*/
|
9 |
Â
|
10 |
Â
namespace CustomFacebookFeed;
|
11 |
+
use CustomFacebookFeed\SB_Facebook_Data_Manager;
|
12 |
Â
use CustomFacebookFeed\Admin\CFF_Admin;
|
13 |
Â
use CustomFacebookFeed\Admin\CFF_About;
|
14 |
Â
use CustomFacebookFeed\Admin\CFF_New_User;
|
624 |
Â
|
625 |
Â
update_option( 'cff_statuses', $cff_statuses_option );
|
626 |
Â
}
|
627 |
+
|
628 |
+
if ( (float) $db_ver < 2.2 ) {
|
629 |
+
$manager = new SB_Facebook_Data_Manager();
|
630 |
+
$manager->update_db_for_dpa();
|
631 |
+
update_option( 'cff_db_version', CFF_DBVERSION );
|
632 |
+
}
|
633 |
+
|
634 |
+
if ( version_compare( $db_ver, '2.4', '<' ) ) {
|
635 |
+
update_option( 'cff_db_version', CFF_DBVERSION );
|
636 |
+
|
637 |
+
$groups = \CustomFacebookFeed\Builder\CFF_Db::source_query( array( 'type' => 'group' ) );
|
638 |
+
|
639 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
640 |
+
$cff_statuses_option['groups_need_update'] = false;
|
641 |
+
|
642 |
+
if ( empty( $groups ) ) {
|
643 |
+
update_option( 'cff_statuses', $cff_statuses_option, false );
|
644 |
+
} else {
|
645 |
+
$encryption = new \CustomFacebookFeed\SB_Facebook_Data_Encryption();
|
646 |
+
$groups_need_update = false;
|
647 |
+
foreach ( $groups as $source ) {
|
648 |
+
$info = ! empty( $source['info'] ) ? json_decode( $encryption->decrypt( $source['info'] ) ) : array();
|
649 |
+
if ( \CustomFacebookFeed\Builder\CFF_Source::needs_update( $source, $info ) ) {
|
650 |
+
$groups_need_update = true;
|
651 |
+
}
|
652 |
+
}
|
653 |
+
$cff_statuses_option['groups_need_update'] = $groups_need_update;
|
654 |
+
update_option( 'cff_statuses', $cff_statuses_option, false );
|
655 |
+
}
|
656 |
+
}
|
657 |
Â
}
|
658 |
Â
|
659 |
Â
|
inc/SB_Facebook_Data_Encryption.php
ADDED
@@ -0,0 +1,189 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class SB_Facebook_Data_Encryption
|
4 |
+
*
|
5 |
+
* @copyright 2021 Google LLC
|
6 |
+
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
7 |
+
* @link https://sitekit.withgoogle.com
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace CustomFacebookFeed;
|
11 |
+
// Exit if accessed directly
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class responsible for encrypting and decrypting data.
|
19 |
+
*
|
20 |
+
* @since 2.9.4/5.12.4
|
21 |
+
* @access private
|
22 |
+
* @ignore
|
23 |
+
*/
|
24 |
+
class SB_Facebook_Data_Encryption {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Key to use for encryption.
|
28 |
+
*
|
29 |
+
* @since 2.9.4/5.12.4
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $key;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Salt to use for encryption.
|
36 |
+
*
|
37 |
+
* @since 2.9.4/5.12.4
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
private $salt;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor.
|
44 |
+
*
|
45 |
+
* @since 2.9.4/5.12.4
|
46 |
+
*/
|
47 |
+
public function __construct( $remote = array() ) {
|
48 |
+
if ( ! empty( $remote ) ) {
|
49 |
+
$this->key = $remote['key'];
|
50 |
+
$this->salt = $remote['salt'];
|
51 |
+
} else {
|
52 |
+
$this->key = $this->get_default_key();
|
53 |
+
$this->salt = $this->get_default_salt();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Encrypts a value.
|
59 |
+
*
|
60 |
+
* If a user-based key is set, that key is used. Otherwise the default key is used.
|
61 |
+
*
|
62 |
+
* @since 2.9.4/5.12.4
|
63 |
+
*
|
64 |
+
* @param string $value Value to encrypt.
|
65 |
+
* @return string|bool Encrypted value, or false on failure.
|
66 |
+
*/
|
67 |
+
public function encrypt( $value ) {
|
68 |
+
if ( ! cff_doing_openssl() ) {
|
69 |
+
return $value;
|
70 |
+
}
|
71 |
+
|
72 |
+
$method = 'aes-256-ctr';
|
73 |
+
$ivlen = openssl_cipher_iv_length( $method );
|
74 |
+
$iv = openssl_random_pseudo_bytes( $ivlen );
|
75 |
+
|
76 |
+
$raw_value = openssl_encrypt( $value . $this->salt, $method, $this->key, 0, $iv );
|
77 |
+
if ( ! $raw_value ) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
return base64_encode( $iv . $raw_value );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Decrypts a value.
|
86 |
+
*
|
87 |
+
* If a user-based key is set, that key is used. Otherwise the default key is used.
|
88 |
+
*
|
89 |
+
* @since 2.9.4/5.12.4
|
90 |
+
*
|
91 |
+
* @param string $raw_value Value to decrypt.
|
92 |
+
* @return string|bool Decrypted value, or false on failure.
|
93 |
+
*/
|
94 |
+
public function decrypt( $raw_value ) {
|
95 |
+
if ( ! cff_doing_openssl() ) {
|
96 |
+
return $raw_value;
|
97 |
+
}
|
98 |
+
|
99 |
+
$raw_value = base64_decode( $raw_value, true );
|
100 |
+
|
101 |
+
$method = 'aes-256-ctr';
|
102 |
+
$ivlen = openssl_cipher_iv_length( $method );
|
103 |
+
$iv = substr( $raw_value, 0, $ivlen );
|
104 |
+
|
105 |
+
$raw_value = substr( $raw_value, $ivlen );
|
106 |
+
|
107 |
+
$value = openssl_decrypt( $raw_value, $method, $this->key, 0, $iv );
|
108 |
+
if ( ! $value || substr( $value, - strlen( $this->salt ) ) !== $this->salt ) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
return substr( $value, 0, - strlen( $this->salt ) );
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
public function maybe_encrypt( $raw_value ) {
|
117 |
+
$maybe_decrypted = $this->decrypt( $raw_value );
|
118 |
+
|
119 |
+
if ( $maybe_decrypted ) {
|
120 |
+
return $this->encrypt( $maybe_decrypted );
|
121 |
+
}
|
122 |
+
|
123 |
+
return $this->encrypt( $raw_value );
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Uses a raw value and attempts to decrypt it
|
128 |
+
*
|
129 |
+
* @param $value
|
130 |
+
*
|
131 |
+
* @return bool|string
|
132 |
+
*/
|
133 |
+
public function maybe_decrypt( $value ) {
|
134 |
+
if ( ! is_string( $value ) ) {
|
135 |
+
return $value;
|
136 |
+
}
|
137 |
+
if ( strpos( $value, '{' ) === 0 ) {
|
138 |
+
return $value;
|
139 |
+
}
|
140 |
+
|
141 |
+
$decrypted = $this->decrypt( $value );
|
142 |
+
|
143 |
+
if ( ! $decrypted ) {
|
144 |
+
return $value;
|
145 |
+
}
|
146 |
+
|
147 |
+
return $decrypted;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Gets the default encryption key to use.
|
152 |
+
*
|
153 |
+
* @since 2.9.4/5.12.4
|
154 |
+
*
|
155 |
+
* @return string Default (not user-based) encryption key.
|
156 |
+
*/
|
157 |
+
private function get_default_key() {
|
158 |
+
if ( defined( 'CFF_ENCRYPTION_KEY' ) && '' !== CFF_ENCRYPTION_KEY ) {
|
159 |
+
return CFF_ENCRYPTION_KEY;
|
160 |
+
}
|
161 |
+
|
162 |
+
if ( defined( 'LOGGED_IN_KEY' ) && '' !== LOGGED_IN_KEY ) {
|
163 |
+
return LOGGED_IN_KEY;
|
164 |
+
}
|
165 |
+
|
166 |
+
// If this is reached, you're either not on a live site or have a serious security issue.
|
167 |
+
return 'das-ist-kein-geheimer-schluessel';
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Gets the default encryption salt to use.
|
172 |
+
*
|
173 |
+
* @since 2.9.4/5.12.4
|
174 |
+
*
|
175 |
+
* @return string Encryption salt.
|
176 |
+
*/
|
177 |
+
private function get_default_salt() {
|
178 |
+
if ( defined( 'CFF_ENCRYPTION_SALT' ) && '' !== CFF_ENCRYPTION_SALT ) {
|
179 |
+
return CFF_ENCRYPTION_SALT;
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( defined( 'LOGGED_IN_SALT' ) && '' !== LOGGED_IN_SALT ) {
|
183 |
+
return LOGGED_IN_SALT;
|
184 |
+
}
|
185 |
+
|
186 |
+
// If this is reached, you're either not on a live site or have a serious security issue.
|
187 |
+
return 'das-ist-kein-geheimes-salz';
|
188 |
+
}
|
189 |
+
}
|
inc/SB_Facebook_Data_Manager.php
ADDED
@@ -0,0 +1,539 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class SB_Facebook_Data_Manager
|
4 |
+
*
|
5 |
+
* @since 4.1
|
6 |
+
*/
|
7 |
+
namespace CustomFacebookFeed;
|
8 |
+
use CustomFacebookFeed\Builder\CFF_Db;
|
9 |
+
use CustomFacebookFeed\CFF_Resizer;
|
10 |
+
use CustomFacebookFeed\SB_Facebook_Data_Encryption;
|
11 |
+
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
die( '-1' );
|
14 |
+
}
|
15 |
+
|
16 |
+
class SB_Facebook_Data_Manager {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Key and salt to use for remote encryption.
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*
|
23 |
+
* @since 4.1
|
24 |
+
*/
|
25 |
+
private $key_salt;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Start manager
|
29 |
+
*
|
30 |
+
* @since 4.1
|
31 |
+
*/
|
32 |
+
public function init() {
|
33 |
+
$this->hooks();
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Hook into certain features of the plugin and AJAX calls
|
39 |
+
*
|
40 |
+
* @since 4.1
|
41 |
+
*/
|
42 |
+
public function hooks() {
|
43 |
+
add_action( 'cff_before_display_facebook', array( $this, 'update_last_used' ) );
|
44 |
+
add_action( 'cff_before_display_facebook', array( $this, 'check' ) );
|
45 |
+
add_action( 'sb_facebook_twicedaily', array( $this, 'maybe_delete_old_data' ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* To avoid a database update every page load, the check
|
50 |
+
* is done once a day
|
51 |
+
*
|
52 |
+
* @since 4.1
|
53 |
+
*/
|
54 |
+
public function update_last_used() {
|
55 |
+
$statuses = $this->get_statuses();
|
56 |
+
|
57 |
+
// if this hasn't been updated in the last hour
|
58 |
+
if ( $statuses['last_used'] < cff_get_current_time() - 3600 ) {
|
59 |
+
// update the last used time
|
60 |
+
$statuses['last_used'] = cff_get_current_time();
|
61 |
+
|
62 |
+
$this->update_statuses( $statuses );
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Check for plain text instagram data in posts table
|
69 |
+
*
|
70 |
+
* @since 4.1
|
71 |
+
*/
|
72 |
+
public function check() {
|
73 |
+
$this->encrypt_json_in_cff_facebook_posts();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Delete unused data after a period
|
78 |
+
*
|
79 |
+
* @return bool
|
80 |
+
*
|
81 |
+
* @since 4.1
|
82 |
+
*/
|
83 |
+
public function maybe_delete_old_data() {
|
84 |
+
$statuses = $this->get_statuses();
|
85 |
+
|
86 |
+
$data_was_deleted = false;
|
87 |
+
|
88 |
+
if ( $statuses['last_used'] < cff_get_current_time() - (21 * DAY_IN_SECONDS) ) {
|
89 |
+
|
90 |
+
$this->delete_caches();
|
91 |
+
\cff_main()->cff_error_reporter->add_action_log( 'Deleted all platform data.' );
|
92 |
+
|
93 |
+
$data_was_deleted = true;
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( $statuses['last_used'] < cff_get_current_time() - (90 * DAY_IN_SECONDS) ) {
|
97 |
+
CFF_Db::clear_cff_sources();
|
98 |
+
|
99 |
+
\cff_main()->cff_error_reporter->add_action_log( 'Deleted all connected accounts.' );
|
100 |
+
|
101 |
+
$data_was_deleted = true;
|
102 |
+
}
|
103 |
+
|
104 |
+
return $data_was_deleted;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Delete feed caches
|
109 |
+
*
|
110 |
+
* @param bool $include_backup
|
111 |
+
*
|
112 |
+
* @since 2.9.4/5.12.4
|
113 |
+
*/
|
114 |
+
public function delete_caches( $include_backup = true ) {
|
115 |
+
cff_delete_cache();
|
116 |
+
CFF_Resizer::delete_resizing_table_and_images();
|
117 |
+
\cff_main()->cff_error_reporter->add_action_log( 'Reset resizing tables.' );
|
118 |
+
//CFF_Resizer::create_resizing_table_and_uploads_folder();
|
119 |
+
CFF_Db::clear_cff_feed_caches();
|
120 |
+
CFF_Db::clear_cff_sources();
|
121 |
+
$this->delete_transient_backup_data( true );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Update all parts of the database for FB platform guidelines
|
126 |
+
*
|
127 |
+
* @throws Exception
|
128 |
+
*
|
129 |
+
* @since 4.1
|
130 |
+
*/
|
131 |
+
public function update_db_for_dpa() {
|
132 |
+
global $wpdb;
|
133 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
134 |
+
$table_name_option = $wpdb->prefix . "options";
|
135 |
+
$sources_table_name = $wpdb->prefix . "cff_sources";
|
136 |
+
$wpdb->query( "ALTER TABLE $sources_table_name MODIFY access_token varchar(1000) NOT NULL default ''" );
|
137 |
+
|
138 |
+
$this->encrypt_json_in_cff_facebook_posts();
|
139 |
+
$this->encrypt_sources_access_token();
|
140 |
+
$this->encrypt_cff_backup_cache();
|
141 |
+
$this->encrypt_cff_group_cache();
|
142 |
+
$this->remove_access_token_from_feeds();
|
143 |
+
$this->delete_transient_backup_data();
|
144 |
+
$this->encrypt_cff_legacy_feed();
|
145 |
+
$this->encrypt_oembed();
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Encrypt a set of 50 posts if this has been attempted
|
151 |
+
* less than 30 times.
|
152 |
+
*
|
153 |
+
* @since 4.1
|
154 |
+
*/
|
155 |
+
public function encrypt_json_in_cff_facebook_posts() {
|
156 |
+
$statuses = $this->get_statuses();
|
157 |
+
// if this hasn't been updated in the last hour
|
158 |
+
if ( $statuses['num_db_updates'] > 30 ) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
$statuses['num_db_updates'] = $statuses['num_db_updates'] + 1;
|
163 |
+
$this->update_statuses( $statuses );
|
164 |
+
|
165 |
+
global $wpdb;
|
166 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
167 |
+
$table_name = $wpdb->prefix . CFF_POSTS_TABLE;
|
168 |
+
$feeds_posts_table_name = esc_sql( $wpdb->prefix . CFF_FEEDS_POSTS_TABLE );
|
169 |
+
|
170 |
+
$plaintext_posts = array();
|
171 |
+
|
172 |
+
if ( empty( $plaintext_posts ) ) {
|
173 |
+
$statuses['num_db_updates'] = 31;
|
174 |
+
$this->update_statuses( $statuses );
|
175 |
+
}
|
176 |
+
|
177 |
+
foreach ( $plaintext_posts as $post ) {
|
178 |
+
$json_data = $encryption->encrypt( $post['json_data'] );
|
179 |
+
$updated = $wpdb->query( $wpdb->prepare(
|
180 |
+
"UPDATE $table_name as p
|
181 |
+
INNER JOIN $feeds_posts_table_name AS f ON p.id = f.id
|
182 |
+
SET p.json_data = %s
|
183 |
+
WHERE p.id = %d;", $json_data, $post['id'] ) );
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Encrypt sources Access tokens
|
190 |
+
*
|
191 |
+
* @since 4.1
|
192 |
+
*/
|
193 |
+
public function encrypt_sources_access_token() {
|
194 |
+
global $wpdb;
|
195 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
196 |
+
$sources_table_name = $wpdb->prefix . 'cff_sources';
|
197 |
+
|
198 |
+
$sources_list = $wpdb->get_results( "SELECT * FROM $sources_table_name;", ARRAY_A );
|
199 |
+
foreach ( $sources_list as $source ) {
|
200 |
+
$access_token = $encryption->maybe_encrypt( $source['access_token'] );
|
201 |
+
$info = $encryption->maybe_encrypt( $source['info'] );
|
202 |
+
|
203 |
+
$updated = $wpdb->query( $wpdb->prepare(
|
204 |
+
"UPDATE $sources_table_name as s
|
205 |
+
SET s.access_token = %s,
|
206 |
+
s.info = %s,
|
207 |
+
s.last_updated = %s
|
208 |
+
WHERE s.id = %d;", $access_token, $info, date( 'Y-m-d H:i:s' ), $source['id'] ) );
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Encrypt a Backup Cache Data
|
214 |
+
*
|
215 |
+
* @since 4.1
|
216 |
+
*/
|
217 |
+
public function encrypt_cff_backup_cache() {
|
218 |
+
global $wpdb;
|
219 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
220 |
+
$feed_cache_table_name = $wpdb->prefix . 'cff_feed_caches';
|
221 |
+
|
222 |
+
|
223 |
+
$feed_caches = $wpdb->get_results(
|
224 |
+
"SELECT * FROM $feed_cache_table_name as p
|
225 |
+
WHERE p.cache_value LIKE '%{%';
|
226 |
+
", ARRAY_A );
|
227 |
+
|
228 |
+
if ( empty( $feed_caches ) ) {
|
229 |
+
$statuses['num_db_updates'] = 31;
|
230 |
+
$this->update_statuses( $statuses );
|
231 |
+
}
|
232 |
+
|
233 |
+
foreach ( $feed_caches as $cache ) {
|
234 |
+
$cache_value = $encryption->encrypt( $cache['cache_value'] );
|
235 |
+
$updated = $wpdb->query( $wpdb->prepare(
|
236 |
+
"UPDATE $feed_cache_table_name as p
|
237 |
+
SET p.cache_value = %s
|
238 |
+
WHERE p.id = %d;", $cache_value, $cache['id'] ) );
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Update Group Posts Persistent Cache
|
244 |
+
*
|
245 |
+
* @throws Exception
|
246 |
+
*
|
247 |
+
* @since 4.1
|
248 |
+
*/
|
249 |
+
public function encrypt_cff_group_cache(){
|
250 |
+
global $wpdb;
|
251 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
252 |
+
$table_name = $wpdb->prefix . "options";
|
253 |
+
$persistent_groups = $wpdb->get_results( "
|
254 |
+
SELECT *
|
255 |
+
FROM $table_name
|
256 |
+
WHERE `option_name` LIKE ('%!cff\_group\_%')
|
257 |
+
" );
|
258 |
+
|
259 |
+
foreach ($persistent_groups as $group) {
|
260 |
+
$cache_value = $encryption->maybe_encrypt( $group->option_value );
|
261 |
+
$updated = $wpdb->query( $wpdb->prepare(
|
262 |
+
"UPDATE $table_name as gp
|
263 |
+
SET gp.option_value = %s
|
264 |
+
WHERE gp.option_id = %d;", $cache_value, $group->option_id ) );
|
265 |
+
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
public function encrypt_oembed() {
|
270 |
+
$cff_oembed_data = get_option( 'cff_oembed_token' );
|
271 |
+
$sbi_oembed_data = get_option( 'sbi_oembed_token' );
|
272 |
+
|
273 |
+
if ( empty( $cff_oembed_data['access_token'] ) && empty( $sbi_oembed_data['access_token'] ) ) {
|
274 |
+
return;
|
275 |
+
}
|
276 |
+
|
277 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
278 |
+
if ( isset( $cff_oembed_data['access_token'] ) && ! $encryption->decrypt( $cff_oembed_data['access_token'] ) ) {
|
279 |
+
$cff_oembed_data['access_token'] = $encryption->encrypt( $cff_oembed_data['access_token'] );
|
280 |
+
}
|
281 |
+
|
282 |
+
if ( isset( $sbi_oembed_data['access_token'] ) && ! $encryption->decrypt( $sbi_oembed_data['access_token'] ) ) {
|
283 |
+
$sbi_oembed_data['access_token'] = $encryption->encrypt( $sbi_oembed_data['access_token'] );
|
284 |
+
}
|
285 |
+
|
286 |
+
update_option( 'cff_oembed_token', $cff_oembed_data );
|
287 |
+
update_option( 'sbi_oembed_token', $sbi_oembed_data );
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Update Group Posts Persistent Cache
|
292 |
+
*
|
293 |
+
* @throws Exception
|
294 |
+
*
|
295 |
+
* @since 4.1
|
296 |
+
*/
|
297 |
+
public function encrypt_cff_legacy_feed(){
|
298 |
+
global $wpdb;
|
299 |
+
$encryption = new SB_Facebook_Data_Encryption();
|
300 |
+
$table_name = $wpdb->prefix . "options";
|
301 |
+
$legacyfeed = $wpdb->get_results( "
|
302 |
+
SELECT *
|
303 |
+
FROM $table_name
|
304 |
+
WHERE `option_name` LIKE 'cff_legacy_feed_settings'
|
305 |
+
" );
|
306 |
+
|
307 |
+
foreach ($legacyfeed as $legacy) {
|
308 |
+
$cache_value = $encryption->maybe_encrypt( $legacy->option_value );
|
309 |
+
$updated = $wpdb->query( $wpdb->prepare(
|
310 |
+
"UPDATE $table_name as gp
|
311 |
+
SET gp.option_value = %s
|
312 |
+
WHERE gp.option_id = %d;", $cache_value, $legacy->option_id ) );
|
313 |
+
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Update Feeds Table & Remove the Access Token from the Settings
|
319 |
+
*
|
320 |
+
* @throws Exception
|
321 |
+
*
|
322 |
+
* @since 4.1
|
323 |
+
*/
|
324 |
+
public function remove_access_token_from_feeds() {
|
325 |
+
global $wpdb;
|
326 |
+
$feeds_table_name = $wpdb->prefix . 'cff_feeds';
|
327 |
+
$feeds_list = $wpdb->get_results(
|
328 |
+
"SELECT * FROM $feeds_table_name", ARRAY_A );
|
329 |
+
|
330 |
+
foreach ( $feeds_list as $feed ) {
|
331 |
+
$settings = json_decode( $feed['settings'], true );
|
332 |
+
unset($settings['accesstoken']);
|
333 |
+
|
334 |
+
$settings = json_encode( $settings );
|
335 |
+
|
336 |
+
$updated = $wpdb->query( $wpdb->prepare(
|
337 |
+
"UPDATE $feeds_table_name as f
|
338 |
+
SET f.settings = %s
|
339 |
+
WHERE f.id = %d;", $settings, $feed['id'] ) );
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Data manager statuses
|
345 |
+
*
|
346 |
+
* @return array
|
347 |
+
*
|
348 |
+
* @since 4.1
|
349 |
+
*/
|
350 |
+
public function get_statuses() {
|
351 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
352 |
+
|
353 |
+
$return = isset( $cff_statuses_option['data_manager'] ) ? $cff_statuses_option['data_manager'] : $this->defaults();
|
354 |
+
return $return;
|
355 |
+
}
|
356 |
+
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Delete Backup data
|
360 |
+
*
|
361 |
+
* @since 4.1
|
362 |
+
*/
|
363 |
+
public function delete_transient_backup_data( $processDeleteGroup = false ){
|
364 |
+
global $wpdb;
|
365 |
+
$table_name = $wpdb->prefix . "options";
|
366 |
+
$wpdb->query( "
|
367 |
+
DELETE
|
368 |
+
FROM $table_name
|
369 |
+
WHERE `option_name` LIKE ('%\_transient\_cff\_%')
|
370 |
+
" );
|
371 |
+
$wpdb->query( "
|
372 |
+
DELETE
|
373 |
+
FROM $table_name
|
374 |
+
WHERE `option_name` LIKE ('%\_transient\_!cff\_%')
|
375 |
+
" );
|
376 |
+
$wpdb->query( "
|
377 |
+
DELETE
|
378 |
+
FROM $table_name
|
379 |
+
WHERE `option_name` LIKE ('%\_transient\_cff\_ej\_%')
|
380 |
+
" );
|
381 |
+
$wpdb->query( "
|
382 |
+
DELETE
|
383 |
+
FROM $table_name
|
384 |
+
WHERE `option_name` LIKE ('%\_transient\_cff\_tle\_%')
|
385 |
+
" );
|
386 |
+
$wpdb->query( "
|
387 |
+
DELETE
|
388 |
+
FROM $table_name
|
389 |
+
WHERE `option_name` LIKE ('%\_transient\_cff\_album\_%')
|
390 |
+
" );
|
391 |
+
$wpdb->query( "
|
392 |
+
DELETE
|
393 |
+
FROM $table_name
|
394 |
+
WHERE `option_name` LIKE ('%\_transient\_timeout\_cff\_%')
|
395 |
+
" );
|
396 |
+
$wpdb->query( "
|
397 |
+
DELETE
|
398 |
+
FROM $table_name
|
399 |
+
WHERE `option_name` LIKE ('%\_transient\_timeout\_!cff\_%')
|
400 |
+
" );
|
401 |
+
$wpdb->query( "
|
402 |
+
DELETE
|
403 |
+
FROM $table_name
|
404 |
+
WHERE `option_name` LIKE ('%cff\_backup\_%')
|
405 |
+
" );
|
406 |
+
|
407 |
+
if( $processDeleteGroup === true){
|
408 |
+
$wpdb->query( "
|
409 |
+
DELETE
|
410 |
+
FROM $table_name
|
411 |
+
WHERE `option_name` LIKE ('%!cff\_group\_%')
|
412 |
+
" );
|
413 |
+
$wpdb->query( "
|
414 |
+
DELETE
|
415 |
+
FROM $table_name
|
416 |
+
WHERE `option_name` LIKE 'cff_connected_accounts'
|
417 |
+
" );
|
418 |
+
$wpdb->query( "
|
419 |
+
DELETE
|
420 |
+
FROM $table_name
|
421 |
+
WHERE `option_name` LIKE 'cff_access_token'
|
422 |
+
" );
|
423 |
+
$wpdb->query( "
|
424 |
+
DELETE
|
425 |
+
FROM $table_name
|
426 |
+
WHERE `option_name` LIKE 'cff_oembed_token'
|
427 |
+
" );
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Update data manager status
|
433 |
+
*
|
434 |
+
* @param array $statuses
|
435 |
+
*
|
436 |
+
* @since 4.1
|
437 |
+
*/
|
438 |
+
public function update_statuses( $statuses ) {
|
439 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
440 |
+
$cff_statuses_option['data_manager'] = $statuses;
|
441 |
+
|
442 |
+
update_option( 'cff_statuses', $cff_statuses_option );
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Reset the data manager
|
447 |
+
*
|
448 |
+
* @since 4.1
|
449 |
+
*/
|
450 |
+
public function reset() {
|
451 |
+
$cff_statuses_option = get_option( 'cff_statuses', array() );
|
452 |
+
$cff_statuses_option['data_manager'] = $this->defaults();
|
453 |
+
|
454 |
+
update_option( 'cff_statuses', $cff_statuses_option );
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Default values for manager
|
459 |
+
*
|
460 |
+
* @return array
|
461 |
+
*
|
462 |
+
* @since 4.1
|
463 |
+
*/
|
464 |
+
public function defaults() {
|
465 |
+
return array(
|
466 |
+
'last_used' => cff_get_current_time() - DAY_IN_SECONDS,
|
467 |
+
'num_db_updates' => 0
|
468 |
+
);
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Encrypt using Smash Balloon's support key and salt
|
473 |
+
*
|
474 |
+
* @param string $encrypted_value
|
475 |
+
*
|
476 |
+
* @return bool|string
|
477 |
+
*
|
478 |
+
* @since 2.9.4/5.12.4
|
479 |
+
*/
|
480 |
+
public function remote_encrypt( $encrypted_value ) {
|
481 |
+
$local_encrypt = new SB_Facebook_Data_Encryption();
|
482 |
+
$raw_value = $local_encrypt->decrypt( $encrypted_value );
|
483 |
+
if ( $this->key_salt === null ) {
|
484 |
+
$url = 'https://secure.smashballoon.com/';
|
485 |
+
$args = array(
|
486 |
+
'timeout' => 20
|
487 |
+
);
|
488 |
+
if ( version_compare( get_bloginfo( 'version' ), '3.7' , '<' ) ) {
|
489 |
+
$args['sslverify'] = false;
|
490 |
+
}
|
491 |
+
$response = wp_remote_get( $url, $args );
|
492 |
+
|
493 |
+
if ( ! is_wp_error( $response ) ) {
|
494 |
+
$this->key_salt = $response['body'];
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
$key = substr( $this->key_salt, 0, 64 );
|
499 |
+
$salt = substr( $this->key_salt, 64, 64 );
|
500 |
+
|
501 |
+
$args = array(
|
502 |
+
'key' => $key,
|
503 |
+
'salt' => $salt
|
504 |
+
);
|
505 |
+
|
506 |
+
$remote_encrypt = new SB_Facebook_Data_Encryption( $args );
|
507 |
+
|
508 |
+
return $remote_encrypt->encrypt( $raw_value );
|
509 |
+
}
|
510 |
+
|
511 |
+
public function remote_decrypt( $encrypted_value ) {
|
512 |
+
if ( $this->key_salt === null ) {
|
513 |
+
$url = 'https://secure.smashballoon.com/';
|
514 |
+
$args = array(
|
515 |
+
'timeout' => 20
|
516 |
+
);
|
517 |
+
if ( version_compare( get_bloginfo( 'version' ), '3.7' , '<' ) ) {
|
518 |
+
$args['sslverify'] = false;
|
519 |
+
}
|
520 |
+
$response = wp_remote_get( $url, $args );
|
521 |
+
|
522 |
+
if ( ! is_wp_error( $response ) ) {
|
523 |
+
$this->key_salt = $response['body'];
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
$key = substr( $this->key_salt, 0, 64 );
|
528 |
+
$salt = substr( $this->key_salt, 64, 64 );
|
529 |
+
|
530 |
+
$args = array(
|
531 |
+
'key' => $key,
|
532 |
+
'salt' => $salt
|
533 |
+
);
|
534 |
+
|
535 |
+
$remote_encrypt = new SB_Facebook_Data_Encryption( $args );
|
536 |
+
|
537 |
+
return $remote_encrypt->decrypt( $encrypted_value );
|
538 |
+
}
|
539 |
+
}
|