PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.1.1
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.1.1
4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / admin / admin-functions.php
custom-facebook-feed / admin Last commit date
assets 4 years ago builder 4 years ago templates 4 years ago views 4 years ago addon-functions.php 4 years ago admin-functions.php 4 years ago enqueu-script.php 4 years ago
admin-functions.php
458 lines
1 <?php
2 use CustomFacebookFeed\CFF_Utils;
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(){
10 CustomFacebookFeed\CFF_Group_Posts::cron_update_group_persistent_cache();
11 }
12
13 //Create Style page
14 /**
15 * @deprecated
16 */
17 function cff_style_page() {} //End Style_Page
18
19 //Create Settings page
20 /**
21 * @deprecated
22 */
23 function cff_settings_page() {} //End Settings_Page
24
25 /**
26 * @deprecated
27 */
28 function cff_oembeds_page() {}
29
30 /**
31 * @deprecated
32 */
33 function cff_social_wall_page() {}
34
35 function cff_lite_dismiss() {
36 check_ajax_referer( 'cff_nonce' , 'cff_nonce');
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 );
40 if ( ! current_user_can( $cap ) ) {
41 wp_send_json_error(); // This auto-dies.
42 }
43
44 set_transient( 'facebook_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS );
45
46 die();
47 }
48 add_action( 'wp_ajax_cff_lite_dismiss', 'cff_lite_dismiss' );
49
50 //If PPCA notice is dismissed then don't show again
51 add_action('admin_init', 'cff_nag_ppca_ignore');
52 function cff_nag_ppca_ignore() {
53 global $current_user;
54 $user_id = $current_user->ID;
55 if ( isset($_GET['cff_nag_ppca_ignore']) && '0' == $_GET['cff_nag_ppca_ignore'] ) {
56 add_user_meta($user_id, 'cff_ignore_ppca_notice', 'true', true);
57 }
58 }
59
60
61 // Add a Settings link to the plugin on the Plugins page
62 $cff_plugin_file = 'custom-facebook-feed/custom-facebook-feed.php';
63 add_filter( "plugin_action_links_{$cff_plugin_file}", 'cff_add_settings_link', 10, 2 );
64
65 //modify the link by unshifting the array
66 function cff_add_settings_link( $links, $file ) {
67 $pro_link = '<a href="https://smashballoondemo.com/?utm_campaign=facebook-free&utm_source=plugins-page&utm_medium=upgrade-link" target="_blank" style="font-weight: bold; color: #1da867;">' . __( 'Try the Pro Demo', 'custom-facebook-feed' ) . '</a>';
68 $cff_settings_link = '<a href="' . admin_url( 'admin.php?page=cff-feed-builder' ) . '">' . __( 'Settings', 'cff-feed-builder', 'custom-facebook-feed' ) . '</a>';
69 array_unshift( $links, $pro_link, $cff_settings_link );
70
71 return $links;
72 }
73
74
75 //Delete cache
76 function cff_delete_cache(){
77 global $wpdb;
78 $table_name = $wpdb->prefix . "options";
79 $wpdb->query( "
80 DELETE
81 FROM $table_name
82 WHERE `option_name` LIKE ('%\_transient\_cff\_%')
83 " );
84 $wpdb->query( "
85 DELETE
86 FROM $table_name
87 WHERE `option_name` LIKE ('%\_transient\_cff\_tle\_%')
88 " );
89 $wpdb->query( "
90 DELETE
91 FROM $table_name
92 WHERE `option_name` LIKE ('%\_transient\_timeout\_cff\_%')
93 " );
94
95 //Clear cache of major caching plugins
96 if(isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')){
97 $GLOBALS['wp_fastest_cache']->deleteCache();
98 }
99 //WP Super Cache
100 if (function_exists('wp_cache_clear_cache')) {
101 wp_cache_clear_cache();
102 }
103 //W3 Total Cache
104 if (function_exists('w3tc_flush_all')) {
105 w3tc_flush_all();
106 }
107 if (function_exists('sg_cachepress_purge_cache')) {
108 sg_cachepress_purge_cache();
109 }
110
111 // Litespeed Cache
112 if ( method_exists( 'LiteSpeed_Cache_API', 'purge' ) ) {
113 LiteSpeed_Cache_API::purge( 'esi.custom-facebook-feed' );
114 }
115
116 }
117
118 //Cron job to clear transients
119 add_action('cff_cron_job', 'cff_cron_clear_cache');
120 function cff_cron_clear_cache() {
121 //Delete all transients
122 cff_delete_cache();
123 }
124
125 //NOTICES
126 function cff_get_current_time() {
127 $current_time = time();
128
129 // where to do tests
130 // $current_time = strtotime( 'November 25, 2020' );
131
132 return $current_time;
133 }
134
135 // generates the html for the admin notices
136 function cff_notices_html() {
137 // reset everything for testing
138 /*
139 global $current_user;
140 $user_id = $current_user->ID;
141 // delete_user_meta( $user_id, 'cff_ignore_bfcm_sale_notice' );
142 // delete_user_meta( $user_id, 'cff_ignore_new_user_sale_notice' );
143 // $cff_statuses_option = array( 'first_install' => strtotime( 'December 8, 2017' ) );
144 // $cff_statuses_option = array( 'first_install' => time() );
145
146 // update_option( 'cff_statuses', $cff_statuses_option, false );
147 // delete_option( 'cff_rating_notice');
148 // delete_transient( 'custom_facebook_rating_notice_waiting' );
149
150 // set_transient( 'custom_facebook_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
151 delete_transient('custom_facebook_rating_notice_waiting');
152 update_option( 'cff_rating_notice', 'pending', false );
153 */
154 }
155
156 function cff_get_future_date( $month, $year, $week, $day, $direction ) {
157 if ( $direction > 0 ) {
158 $startday = 1;
159 } else {
160 $startday = date( 't', mktime(0, 0, 0, $month, 1, $year ) );
161 }
162
163 $start = mktime( 0, 0, 0, $month, $startday, $year );
164 $weekday = date( 'N', $start );
165
166 $offset = 0;
167 if ( $direction * $day >= $direction * $weekday ) {
168 $offset = -$direction * 7;
169 }
170
171 $offset += $direction * ($week * 7) + ($day - $weekday);
172 return mktime( 0, 0, 0, $month, $startday + $offset, $year );
173 }
174
175 function cff_admin_hide_unrelated_notices() {
176
177 // Bail if we're not on a cff screen or page.
178 if ( ! isset( $_GET['page'] ) || strpos( $_GET['page'], 'cff') === false ) {
179 return;
180 }
181
182 // Extra banned classes and callbacks from third-party plugins.
183 $blacklist = array(
184 'classes' => array(),
185 'callbacks' => array(
186 'cffdb_admin_notice', // 'Database for cff' plugin.
187 ),
188 );
189
190 global $wp_filter;
191
192 foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) {
193 if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) {
194 continue;
195 }
196 foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) {
197 foreach ( $hooks as $name => $arr ) {
198 if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
199 unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
200 continue;
201 }
202 $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : '';
203 if (
204 ! empty( $class ) &&
205 strpos( $class, 'cff' ) !== false &&
206 ! in_array( $class, $blacklist['classes'], true )
207 ) {
208 continue;
209 }
210 if (
211 ! empty( $name ) && (
212 strpos( $name, 'cff' ) === false ||
213 in_array( $class, $blacklist['classes'], true ) ||
214 in_array( $name, $blacklist['callbacks'], true )
215 )
216 ) {
217 unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
218 }
219 }
220 }
221 }
222 }
223 add_action( 'admin_print_scripts', 'cff_admin_hide_unrelated_notices' );
224
225 /**
226 * Remove admin notices from inside our plugin screens so we can show our customized notices
227 *
228 * @since 4.0
229 */
230 add_action( 'in_admin_header', 'cff_remove_admin_notices' );
231 function cff_remove_admin_notices() {
232 $current_screen = get_current_screen();
233 $not_allowed_screens = array(
234 'facebook-feed_page_cff-feed-builder',
235 'facebook-feed_page_cff-settings',
236 'facebook-feed_page_cff-oembeds-manager',
237 'facebook-feed_page_cff-extensions-manager',
238 'facebook-feed_page_cff-about-us',
239 'facebook-feed_page_cff-support',
240 );
241
242 if ( in_array( $current_screen->base, $not_allowed_screens ) ) {
243 remove_all_actions('admin_notices');
244 remove_all_actions('all_admin_notices');
245 }
246 }
247
248 function cff_free_add_caps() {
249 global $wp_roles;
250
251 $wp_roles->add_cap( 'administrator', 'manage_custom_facebook_feed_options' );
252
253 }
254 add_action( 'admin_init', 'cff_free_add_caps', 90 );
255
256
257
258
259
260 function cff_oembed_disable() {
261 check_ajax_referer( 'cff_nonce' , 'cff_nonce');
262
263 $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
264 $cap = apply_filters( 'cff_settings_pages_capability', $cap );
265 if ( ! current_user_can( $cap ) ) {
266 wp_send_json_error(); // This auto-dies.
267 }
268
269 $oembed_settings = get_option( 'cff_oembed_token', array() );
270 $oembed_settings['access_token'] = '';
271 $oembed_settings['disabled'] = true;
272 echo '<strong>';
273 if ( update_option( 'cff_oembed_token', $oembed_settings ) ) {
274 _e( 'Facebook oEmbeds will no longer be handled by Custom Facebook Feed.', 'custom-facebook-feed' );
275 } else {
276 _e( 'An error occurred when trying to disable your oEmbed token.', 'custom-facebook-feed' );
277 }
278 echo '</strong>';
279
280 die();
281 }
282 add_action( 'wp_ajax_cff_oembed_disable', 'cff_oembed_disable' );
283
284
285
286 function cff_custom_cssjs_notice() {
287 $cff_statuses_option = get_option( 'cff_statuses', array() );
288 if ( ! empty( $cff_statuses_option['custom_js_css_dismissed'] ) ) {
289 return;
290 }
291
292 if ( ! empty( $_GET['cff_dismiss_notice'] ) && $_GET['cff_dismiss_notice'] === 'customjscss' ) {
293 $cff_statuses_option['custom_js_css_dismissed'] = true;
294 update_option( 'cff_statuses', $cff_statuses_option, false );
295 return;
296 }
297 $cff_style_settings = get_option( 'cff_style_settings' );
298
299 $custom_js_not_empty = ! empty( $cff_style_settings['cff_custom_js'] ) && trim($cff_style_settings['cff_custom_js']) !== '';
300 $custom_css_not_empty = ! empty( $cff_style_settings['cff_custom_css_read_only'] ) && trim($cff_style_settings['cff_custom_css_read_only']) !== '';
301
302 if ( ! $custom_js_not_empty && ! $custom_css_not_empty ) {
303 return;
304 }
305
306 $cff_notifications = new \CustomFacebookFeed\Admin\CFF_Notifications();
307 $notifications = $cff_notifications->get();
308
309 if ( ! empty( $notifications ) && ( ! empty( $_GET['page'] ) && strpos( $_GET['page'], 'cff-' ) !== false ) ) {
310 return;
311 }
312 $close_href = add_query_arg( array( 'cff_dismiss_notice' => 'customjscss' ) );
313
314 ?>
315 <div class="notice notice-warning is-dismissible cff-dismissible">
316 <p><?php if ( $custom_js_not_empty ) : ?>
317 <?php echo sprintf( __( 'You are currently using Custom CSS or JavaScript in the Custom Facebook Feed plugin, however, these settings have now been deprecated. To continue using any custom code, please go to the Custom CSS and JS settings %shere%s and follow the directions.', 'custom-facebook-feed' ), '<a href="' . admin_url( 'admin.php?page=cff-settings&view=feeds' ) . '">', '</a>' ); ?>
318 <?php else : ?>
319 <?php echo sprintf( __( 'You are currently using Custom CSS in the Custom Facebook Feed plugin, however, this setting has now been deprecated. Your CSS has been moved to the "Additional CSS" field in the WordPress Customizer %shere%s instead.', 'custom-facebook-feed' ), '<a href="' . esc_url( wp_customize_url() ) . '">', '</a>' ); ?>
320 <?php endif; ?>
321 &nbsp;<a href="<?php echo esc_attr( $close_href ); ?>"><?php echo __( 'Dismiss', 'custom-facebook-feed' ); ?></a>
322 </p>
323 </div>
324 <?php
325 }
326 add_action( 'admin_notices', 'cff_custom_cssjs_notice' );
327 add_action( 'cff_admin_notices', 'cff_custom_cssjs_notice' );
328
329 function cff_dismiss_custom_cssjs_notice() {
330 check_ajax_referer( 'cff_nonce' , 'cff_nonce');
331
332 $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
333 $cap = apply_filters( 'cff_settings_pages_capability', $cap );
334 //Only display notice to admins
335 if ( !current_user_can( $cap ) ) return;
336
337 $cff_statuses_option = get_option( 'cff_statuses', array() );
338 $cff_statuses_option['custom_js_css_dismissed'] = true;
339 update_option( 'cff_statuses', $cff_statuses_option, false );
340 }
341 add_action( 'wp_ajax_cff_dismiss_custom_cssjs_notice', 'cff_dismiss_custom_cssjs_notice' );
342
343
344 function cff_ppca_token_check_flag() {
345 check_ajax_referer( 'cff_nonce' , 'cff_nonce');
346
347 $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
348 $cap = apply_filters( 'cff_settings_pages_capability', $cap );
349 if ( ! current_user_can( $cap ) ) {
350 wp_send_json_error(); // This auto-dies.
351 }
352
353 if( get_transient('cff_ppca_access_token_invalid') ){
354 print_r(true);
355 } else {
356 print_r(false);
357 }
358
359 die();
360 }
361 add_action( 'wp_ajax_cff_ppca_token_check_flag', 'cff_ppca_token_check_flag' );
362
363 /**
364 * Adds CSS to the end of the customizer "Additonal CSS" setting
365 *
366 * @param $custom_css
367 *
368 * @return bool|int
369 *
370 * @since 4.0.2/4.0.7
371 */
372 function cff_transfer_css( $custom_css ) {
373 $value = '';
374 $post = wp_get_custom_css_post( get_stylesheet() );
375 if ( $post ) {
376 $value = $post->post_content;
377 }
378 $value .= "\n\n/* Custom Facebook Feed */\n" . $custom_css . "\n/* Custom Facebook Feed - End */";
379
380 $r = wp_update_custom_css_post(
381 $value,
382 array(
383 'stylesheet' => get_stylesheet(),
384 )
385 );
386
387 if ( $r instanceof WP_Error ) {
388 return false;
389 }
390 $post_id = $r->ID;
391
392 return $post_id;
393 }
394
395 /**
396 * Validates CSS to detect anything that might be harmful
397 *
398 * @param $css
399 *
400 * @return bool|WP_Error
401 *
402 * @since 4.0.2/4.0.7
403 */
404 function cff_validate_css( $css ) {
405 $validity = new WP_Error();
406
407 if ( preg_match( '#</?\w+#', $css ) ) {
408 $validity->add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) );
409 }
410
411 if ( ! $validity->has_errors() ) {
412 $validity = true;
413 }
414 return $validity;
415 }
416
417 /**
418 * Check to see if CSS has been transferred
419 *
420 * @since 4.0.2/4.0.7
421 */
422 function cff_check_custom_css() {
423 $cff_style_settings = get_option( 'cff_style_settings', array() );
424 $custom_css = isset( $cff_style_settings['cff_custom_css'] ) ? stripslashes( trim( $cff_style_settings['cff_custom_css'] ) ) : '';
425
426 // only try once
427 if ( empty( $custom_css ) ) {
428 return;
429 }
430
431 // custom css set to nothing after trying the update once
432 $cff_style_settings['cff_custom_css_read_only'] = $custom_css;
433 $cff_style_settings['cff_custom_css'] = '';
434 update_option( 'cff_style_settings', $cff_style_settings );
435 if ( ! function_exists( 'wp_get_custom_css_post' )
436 || ! function_exists( 'wp_update_custom_css_post' ) ) {
437 return;
438 }
439
440 // make sure this is valid CSS or don't transfer
441 if ( is_wp_error( cff_validate_css( $custom_css ) ) ) {
442 return;
443 }
444
445 cff_transfer_css( $custom_css );
446 }
447 add_action( 'init', 'cff_check_custom_css' );
448
449 function cff_doing_openssl() {
450 return extension_loaded( 'openssl' );
451 }
452 function cff_delete_all_platform_data(){
453 $manager = new SB_Facebook_Data_Manager();
454 $manager->delete_caches();
455 \cff_main()->cff_error_reporter->add_action_log( 'Deleted all platform data.' );
456 \cff_main()->cff_error_reporter->reset_api_errors();
457 }
458