PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.0.1
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.0.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 / inc / Custom_Facebook_Feed.php
custom-facebook-feed / inc Last commit date
Admin 4 years ago Builder 4 years ago Helpers 5 years ago CFF_Autolink.php 5 years ago CFF_Blocks.php 4 years ago CFF_Cache.php 4 years ago CFF_Education.php 5 years ago CFF_Elementor_Base.php 4 years ago CFF_Elementor_Widget.php 4 years ago CFF_Error_Reporter.php 4 years ago CFF_FB_Settings.php 4 years ago CFF_Feed_Elementor_Control.php 4 years ago CFF_Feed_Locator.php 4 years ago CFF_Feed_Pro.php 4 years ago CFF_GDPR_Integrations.php 4 years ago CFF_Group_Posts.php 5 years ago CFF_HTTP_Request.php 4 years ago CFF_Oembed.php 5 years ago CFF_Parse.php 4 years ago CFF_Resizer.php 4 years ago CFF_Response.php 4 years ago CFF_Shortcode.php 4 years ago CFF_Shortcode_Display.php 4 years ago CFF_SiteHealth.php 4 years ago CFF_Utils.php 4 years ago CFF_View.php 4 years ago Custom_Facebook_Feed.php 4 years ago
Custom_Facebook_Feed.php
920 lines
1 <?php
2 /**
3 * CustomFacebookFeed plugin.
4 *
5 * The main Custom_Facebook_Feed class that runs the plugins & registers all the ressources.
6 *
7 * @since 2.19
8 */
9
10 namespace CustomFacebookFeed;
11 use CustomFacebookFeed\Admin\CFF_Admin;
12 use CustomFacebookFeed\Admin\CFF_About;
13 use CustomFacebookFeed\Admin\CFF_New_User;
14 use CustomFacebookFeed\Admin\CFF_Notifications;
15 use CustomFacebookFeed\Admin\CFF_Tracking;
16 use CustomFacebookFeed\Builder\CFF_Feed_Builder;
17 use CustomFacebookFeed\Admin\CFF_Global_Settings;
18 use CustomFacebookFeed\Admin\CFF_oEmbeds;
19 use CustomFacebookFeed\Admin\CFF_Extensions;
20 use CustomFacebookFeed\Admin\CFF_About_Us;
21 use CustomFacebookFeed\Admin\CFF_Support;
22
23
24 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
25
26
27
28 final class Custom_Facebook_Feed{
29
30 /**
31 * Instance
32 *
33 * @since 2.19
34 * @access private
35 * @static
36 * @var Custom_Facebook_Feed
37 */
38 private static $instance;
39
40
41 /**
42 * CFF_Admin.
43 *
44 * Admin admin panel.
45 *
46 * @since 2.19
47 * @access public
48 *
49 * @var CFF_Admin
50 */
51 public $cff_admin;
52
53
54 /**
55 * CFF_About.
56 *
57 * About page panel.
58 *
59 * @since 2.19
60 * @access public
61 *
62 * @var CFF_About
63 */
64 public $cff_about;
65
66 /**
67 * CFF_Error_Reporter.
68 *
69 * Error Reporter panel.
70 *
71 * @since 2.19
72 * @access public
73 *
74 * @var CFF_Error_Reporter
75 */
76 public $cff_error_reporter;
77
78 /**
79 * cff_blocks.
80 *
81 * Blocks.
82 *
83 * @since 2.19
84 * @access public
85 *
86 * @var cff_blocks
87 */
88 public $cff_blocks;
89
90 /**
91 * CFF_Notifications.
92 *
93 * Notifications System.
94 *
95 * @since 2.19
96 * @access public
97 *
98 * @var CFF_Notifications
99 */
100 public $cff_notifications;
101
102 /**
103 * CFF_New_User.
104 *
105 * New User.
106 *
107 * @since 2.19
108 * @access public
109 *
110 * @var CFF_New_User
111 */
112 public $cff_newuser;
113
114 /**
115 * CFF_Oembed.
116 *
117 * Oembed Element.
118 *
119 * @since 2.19
120 * @access public
121 *
122 * @var CFF_Oembed
123 */
124 public $cff_oembed;
125
126 /**
127 * CFF_Tracking.
128 *
129 * Tracking System.
130 *
131 * @since 2.19
132 * @access public
133 *
134 * @var CFF_Tracking
135 */
136 public $cff_tracking;
137
138 /**
139 * CFF_Shortcode.
140 *
141 * Shortcode Class.
142 *
143 * @since 2.19
144 * @access public
145 *
146 * @var CFF_Shortcode
147 */
148 public $cff_shortcode;
149
150 /**
151 * CFF_SiteHealth.
152 *
153 *
154 * @since 2.19
155 * @access public
156 *
157 * @var CFF_SiteHealth
158 */
159 public $cff_sitehealth;
160
161
162 /**
163 * CFF_Feed_Builder.
164 *
165 * Feed Builder.
166 *
167 * @since 4.0
168 * @access public
169 *
170 * @var CFF_Feed_Builder
171 */
172 public $cff_feed_builder;
173
174 /**
175 * CFF_Global_Settings.
176 *
177 * Global Settings.
178 *
179 * @since 4.0
180 * @access public
181 *
182 * @var CFF_Global_Settings
183 */
184 public $cff_global_settings;
185
186 /**
187 * CFF_oEmbeds.
188 *
189 * oEmbeds Page.
190 *
191 * @since 4.0
192 * @access public
193 *
194 * @var CFF_oEmbeds
195 */
196 public $cff_oembeds;
197
198 /**
199 * CFF_About_Us.
200 *
201 * About Us Page.
202 *
203 * @since 4.0
204 * @access public
205 * @var CFF_About_Us
206 */
207 public $cff_about_us;
208
209 /**
210 * CFF_Support.
211 *
212 * Support Page.
213 *
214 * @since 4.0
215 * @access public
216 *
217 * @var CFF_Support
218 */
219 public $cff_support;
220
221 /**
222 * CFF_Tooltip_Wizard.
223 *
224 * GB Blocks Pages.
225 *
226 * @since 4.0
227 * @access public
228 *
229 * @var CFF_Tooltip_Wizard
230 */
231 public $cff_tooltip_wizard;
232
233 /**
234 * CFF_Elementor_Base.
235 *
236 * Elementor Base.
237 *
238 * @since 4.0
239 * @access public
240 *
241 * @var CFF_Elementor_Base
242 */
243 public $cff_elementor_base;
244
245 /**
246 * Custom_Facebook_Feed Instance.
247 *
248 * Just one instance of the Custom_Facebook_Feed class
249 *
250 * @since 2.19
251 * @access public
252 * @static
253 *
254 * @return Custom_Facebook_Feed
255 */
256 public static function instance() {
257 if ( null === self::$instance) {
258 self::$instance = new self();
259
260 if( !class_exists('CFF_Utils') ) include CFF_PLUGIN_DIR. 'inc/CFF_Utils.php';
261
262
263 add_action( 'plugins_loaded', [ self::$instance, 'load_textdomain' ], 10 );
264 add_action( 'init', [ self::$instance, 'init' ], 0 );
265
266
267
268 add_action( 'wp_loaded', [ self::$instance, 'cff_check_for_db_updates' ] );
269
270 add_action( 'wp_head', [ self::$instance, 'cff_custom_css' ] );
271 add_action( 'wp_footer', [ self::$instance, 'cff_js' ] );
272
273 add_filter( 'cron_schedules', [ self::$instance, 'cff_cron_custom_interval' ] );
274 add_filter('widget_text', 'do_shortcode');
275
276 add_action('wp_ajax_feed_locator', [self::$instance, 'cff_feed_locator']);
277 add_action('wp_ajax_nopriv_feed_locator', [self::$instance, 'cff_feed_locator']);
278
279 register_activation_hook( CFF_FILE, [ self::$instance, 'cff_activate' ] );
280 register_deactivation_hook( CFF_FILE, [ self::$instance, 'cff_deactivate' ] );
281 register_uninstall_hook( CFF_FILE, array('CustomFacebookFeed\Custom_Facebook_Feed','cff_uninstall'));
282
283
284 }
285 return self::$instance;
286 }
287
288 /**
289 * Load Custom_Facebook_Feed textdomain.
290 *
291 * @since 2.19
292 *
293 * @return void
294 * @access public
295 */
296 public function load_textdomain(){
297 load_plugin_textdomain( 'custom-facebook-feed' );
298 }
299
300
301 /**
302 * Init.
303 *
304 * Initialize Custom_Facebook_Feed plugin.
305 *
306 * @since 2.19
307 * @access public
308 */
309 public function init() {
310 //Load Composer Autoload
311 require CFF_PLUGIN_DIR . 'vendor/autoload.php';
312 $this->cff_tracking = new CFF_Tracking();
313 $this->cff_oembed = new CFF_Oembed();
314 $this->cff_error_reporter = new CFF_Error_Reporter();
315 $this->cff_admin = new CFF_Admin();
316 $this->cff_blocks = new CFF_Blocks();
317 $this->cff_shortcode = new CFF_Shortcode();
318 $this->cff_feed_builder = new CFF_Feed_Builder();
319 $this->cff_global_settings = new CFF_Global_Settings();
320 $this->cff_oembeds = new CFF_oEmbeds();
321 $this->cff_about_us = new CFF_About_Us();
322 $this->cff_support = new CFF_Support();
323 $this->cff_elementor_base = CFF_Elementor_Base::instance();
324
325
326 $this->cff_ppca_check_notice_dismiss();
327 $this->register_assets();
328 $this->group_posts_process();
329
330 if ( $this->cff_blocks->allow_load() ) {
331 $this->cff_blocks->load();
332 }
333
334
335 if ( is_admin() ) {
336 $this->cff_about = new CFF_About();
337 $this->cff_tooltip_wizard = new Builder\CFF_Tooltip_Wizard();
338 if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 && version_compare( get_bloginfo('version'), '4.6' , '>' ) ) {
339 $this->cff_notifications = new CFF_Notifications();
340 $this->cff_notifications->init();
341
342 $this->cff_newuser = new CFF_New_User();
343 $this->cff_newuser->init();
344
345 require_once trailingslashit( CFF_PLUGIN_DIR ) . 'admin/addon-functions.php';
346 $this->cff_sitehealth = new CFF_SiteHealth();
347 if ( $this->cff_sitehealth->allow_load() ) {
348 $this->cff_sitehealth->load();
349 }
350 }
351 }
352 }
353
354 /**
355 * Launch the Group Posts Cache Process
356 *
357 *
358 * @return void
359 * @access public
360 */
361 function group_posts_process(){
362 $cff_cron_schedule = 'hourly';
363 $cff_cache_time = get_option( 'cff_cache_time' );
364 $cff_cache_time_unit = get_option( 'cff_cache_time_unit' );
365 if( $cff_cache_time_unit == 'hours' && $cff_cache_time > 5 ) $cff_cron_schedule = 'twicedaily';
366 if( $cff_cache_time_unit == 'days' ) $cff_cron_schedule = 'daily';
367 CFF_Group_Posts::group_schedule_event(time(), $cff_cron_schedule);
368 }
369
370 /**
371 * Register Assets
372 *
373 * @since 2.19
374 */
375 public function register_assets(){
376 add_action( 'wp_enqueue_scripts' , array( $this, 'enqueue_styles_assets' ) );
377 add_action( 'wp_enqueue_scripts' , array( $this, 'enqueue_scripts_assets' ) );
378 }
379
380
381 /**
382 * Enqueue & Register Styles
383 *
384 * @since 2.19
385 */
386 public function enqueue_styles_assets(){
387 //Minify files?
388 $options = get_option('cff_style_settings');
389 isset($options[ 'cff_minify' ]) ? $cff_minify = $options[ 'cff_minify' ] : $cff_minify = '';
390 $cff_minify ? $cff_min = '.min' : $cff_min = '';
391
392 // Respects SSL, Style.css is relative to the current file
393 wp_register_style(
394 'cff',
395 CFF_PLUGIN_URL . 'assets/css/cff-style'.$cff_min.'.css' ,
396 array(),
397 CFFVER
398 );
399
400 $options['cff_enqueue_with_shortcode'] = isset( $options['cff_enqueue_with_shortcode'] ) ? $options['cff_enqueue_with_shortcode'] : false;
401 if ( isset( $options['cff_enqueue_with_shortcode'] ) && !$options['cff_enqueue_with_shortcode'] ) {
402 wp_enqueue_style( 'cff' );
403 }
404
405 $options = get_option('cff_style_settings');
406
407 if ( CFF_GDPR_Integrations::doing_gdpr( $options ) ) {
408 $options[ 'cff_font_source' ] = 'local';
409 }
410 if( !isset( $options[ 'cff_font_source' ] ) ){
411 wp_enqueue_style( 'sb-font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
412 } else {
413
414 if( $options[ 'cff_font_source' ] == 'none' ){
415 //Do nothing
416 } else if( $options[ 'cff_font_source' ] == 'local' ){
417 wp_enqueue_style(
418 'sb-font-awesome',
419 CFF_PLUGIN_URL . 'assets/css/font-awesome.min.css',
420 array(),
421 '4.7.0'
422 );
423 } else {
424 wp_enqueue_style( 'sb-font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
425 }
426
427 }
428 }
429
430
431 /**
432 * Enqueue & Register Scripts
433 *
434 *
435 * @since 2.19
436 * @access public
437 */
438 public function enqueue_scripts_assets(){
439 //Minify files?
440 $options = get_option('cff_style_settings');
441 isset($options[ 'cff_minify' ]) ? $cff_minify = $options[ 'cff_minify' ] : $cff_minify = '';
442 $cff_minify ? $cff_min = '.min' : $cff_min = '';
443
444 //Register the script to make it available
445 wp_register_script(
446 'cffscripts',
447 CFF_PLUGIN_URL . 'assets/js/cff-scripts'.$cff_min.'.js' ,
448 array('jquery'),
449 CFFVER,
450 true
451 );
452 $options['cff_enqueue_with_shortcode'] = isset( $options['cff_enqueue_with_shortcode'] ) ? $options['cff_enqueue_with_shortcode'] : false;
453 if ( isset( $options['cff_enqueue_with_shortcode'] ) && !$options['cff_enqueue_with_shortcode'] ) {
454 wp_enqueue_script( 'cffscripts' );
455 }
456 }
457
458
459 /**
460 * DB Update Checker.
461 *
462 * Check for the db updates
463 *
464 * @since 2.19
465 * @access public
466 */
467 function cff_check_for_db_updates(){
468 $db_ver = get_option( 'cff_db_version', 0 );
469 if ( (float) $db_ver < 1.0 ) {
470 global $wp_roles;
471 $wp_roles->add_cap( 'administrator', 'manage_custom_facebook_feed_options' );
472 $cff_statuses_option = get_option( 'cff_statuses', array() );
473 if ( ! isset( $cff_statuses_option['first_install'] ) ) {
474 $options_set = get_option( 'cff_page_id', false );
475 if ( $options_set ) {
476 $cff_statuses_option['first_install'] = 'from_update';
477 } else {
478 $cff_statuses_option['first_install'] = time();
479 }
480 $cff_rating_notice_option = get_option( 'cff_rating_notice', false );
481 if ( $cff_rating_notice_option === 'dismissed' ) {
482 $cff_statuses_option['rating_notice_dismissed'] = time();
483 }
484 $cff_rating_notice_waiting = get_transient( 'custom_facebook_rating_notice_waiting' );
485 if ( $cff_rating_notice_waiting === false
486 && $cff_rating_notice_option === false ) {
487 $time = 2 * WEEK_IN_SECONDS;
488 set_transient( 'custom_facebook_rating_notice_waiting', 'waiting', $time );
489 update_option( 'cff_rating_notice', 'pending', false );
490 }
491 update_option( 'cff_statuses', $cff_statuses_option, false );
492 }
493 update_option( 'cff_db_version', CFF_DBVERSION );
494 }
495 if ( (float) $db_ver < 1.1 ) {
496 if ( ! wp_next_scheduled( 'cff_feed_issue_email' ) ) {
497 $timestamp = strtotime( 'next monday' );
498 $timestamp = $timestamp + (3600 * 24 * 7);
499 $six_am_local = $timestamp + CFF_Utils::cff_get_utc_offset() + (6*60*60);
500 wp_schedule_event( $six_am_local, 'cffweekly', 'cff_feed_issue_email' );
501 }
502 update_option( 'cff_db_version', CFF_DBVERSION );
503 }
504 if ( (float) $db_ver < 1.2 ) {
505 if ( ! wp_next_scheduled( 'cff_notification_update' ) ) {
506 $timestamp = strtotime( 'next monday' );
507 $timestamp = $timestamp + (3600 * 24 * 7);
508 $six_am_local = $timestamp + CFF_Utils::cff_get_utc_offset() + (6*60*60);
509
510 wp_schedule_event( $six_am_local, 'cffweekly', 'cff_notification_update' );
511 }
512 update_option( 'cff_db_version', CFF_DBVERSION );
513 }
514
515 if ( (float) $db_ver < 1.3 ) {
516 CFF_Feed_Locator::create_table();
517 update_option( 'cff_db_version', CFF_DBVERSION );
518 }
519
520 if ( (float) $db_ver < 1.4 ) {
521 Builder\CFF_Db::create_tables();
522 update_option( 'cff_db_version', CFF_DBVERSION );
523 }
524
525 //\CustomFacebookFeed\Builder\CFF_Db::reset_tables();\CustomFacebookFeed\Builder\CFF_Db::reset_db_update();die();
526 /**
527 * for 4.0 update
528 */
529 if ( (float) $db_ver < 2.1 ) {
530 $options = get_option( 'cff_style_settings', array() );
531 $legacy_at = get_option( 'cff_access_token' );
532 $options_support_legacy = false; // in case the locator table doesn't have any feeds in it but someone might be using legacy feeds
533 if ( ! empty( $legacy_at ) ) {
534 $options_support_legacy = true;
535 \CustomFacebookFeed\Builder\CFF_Feed_Saver::set_legacy_feed_settings();
536 }
537
538 \CustomFacebookFeed\Builder\CFF_Db::create_tables();
539 update_option( 'cff_db_version', CFF_DBVERSION );
540
541 // are there existing feeds to toggle legacy onboarding?
542 $cff_statuses_option = get_option( 'cff_statuses', array() );
543 $cff_statuses_option['legacy_onboarding'] = array(
544 'active' => false,
545 'type'=> 'single'
546 );
547
548 \CustomFacebookFeed\Builder\CFF_Source::set_legacy_source_queue();
549 if ( \CustomFacebookFeed\Builder\CFF_Source::should_do_source_updates() ) {
550 \CustomFacebookFeed\Builder\CFF_Source::batch_process_legacy_source_queue();
551 }
552
553 \CustomFacebookFeed\Builder\CFF_Source::update_source_from_legacy_settings();
554
555 // how many legacy feeds?
556 $args = array(
557 'html_location' => array( 'header', 'footer', 'sidebar', 'content', 'unknown' ),
558 'group_by' => 'shortcode_atts',
559 'page' => 1
560 );
561 $feeds_data = \CustomFacebookFeed\CFF_Feed_Locator::legacy_facebook_feed_locator_query( $args );
562 $num_legacy = count( $feeds_data );
563
564 $cff_statuses_option['support_legacy_shortcode'] = false;
565
566 if ( $num_legacy > 0 ) {
567
568 if ( $num_legacy > 1 ) {
569 $cff_statuses_option['legacy_onboarding'] = array(
570 'active' => true,
571 'type'=> 'multiple'
572 );
573 $cff_statuses_option['support_legacy_shortcode'] = true;
574 } else {
575 $cff_statuses_option['legacy_onboarding'] = array(
576 'active' => true,
577 'type'=> 'single'
578 );
579
580 $shortcode_atts = $feeds_data[0]['shortcode_atts'] != '[""]' ? json_decode( $feeds_data[0]['shortcode_atts'], true ) : [];
581 $shortcode_atts = is_array( $shortcode_atts ) ? $shortcode_atts : array();
582
583 $cff_statuses_option['support_legacy_shortcode'] = $shortcode_atts;
584
585 $settings_data = \CustomFacebookFeed\Builder\CFF_Post_Set::legacy_to_builder_convert( $shortcode_atts );
586
587 if ( isset( $settings_data['id'] ) ) {
588 $source_ids = explode( ',', str_replace( ' ', '', $settings_data['id'] ) );
589 } else {
590 $source_ids = (array)get_option( 'cff_page_id', array() );
591 }
592
593 $source_list = \CustomFacebookFeed\Builder\CFF_Feed_Builder::get_source_list();
594
595 $supported_sources = array();
596 $feed_name = 'Existing Feed';
597 foreach ( $source_list as $source ) {
598 if ( in_array( $source['account_id'], $source_ids, true ) ) {
599 $supported_sources[] = $source['account_id'];
600 $feed_name = $source['username'];
601 }
602 }
603
604 $feed_saver = new \CustomFacebookFeed\Builder\CFF_Feed_Saver( false );
605 $feed_saver->set_data( $settings_data );
606
607 $feed_saver->set_feed_name( $feed_name );
608
609 $new_feed_id = $feed_saver->update_or_insert();
610
611 $args = array(
612 'new_feed_id' => $new_feed_id,
613 'legacy_feed_id' => $feeds_data[0]['feed_id'],
614 );
615
616 CFF_Feed_Locator::update_legacy_to_builder( $args );
617 }
618 } elseif ( $num_legacy === 0 && $options_support_legacy ) {
619 $cff_statuses_option['support_legacy_shortcode'] = true;
620 }
621
622 update_option( 'cff_statuses', $cff_statuses_option );
623 }
624 }
625
626
627 /**
628 * Activate
629 *
630 * CFF activation action.
631 *
632 * @since 2.19
633 * @access public
634 */
635 function cff_activate() {
636 $options = get_option( 'cff_style_settings' );
637
638 //Run cron twice daily when plugin is first activated for new users
639 if ( ! wp_next_scheduled( 'cff_cron_job' ) ) {
640 wp_schedule_event( time(), 'twicedaily', 'cff_cron_job' );
641 }
642 if ( ! wp_next_scheduled( 'cff_feed_issue_email' ) ) {
643 CFF_Utils::cff_schedule_report_email();
644 }
645 // set usage tracking to false if fresh install.
646 $usage_tracking = get_option( 'cff_usage_tracking', false );
647
648 if ( ! is_array( $usage_tracking ) ) {
649 $usage_tracking = array(
650 'enabled' => false,
651 'last_send' => 0
652 );
653 update_option( 'cff_usage_tracking', $usage_tracking, false );
654 }
655
656 if ( ! wp_next_scheduled( 'cff_notification_update' ) ) {
657 $timestamp = strtotime( 'next monday' );
658 $timestamp = $timestamp + (3600 * 24 * 7);
659 $six_am_local = $timestamp + CFF_Utils::cff_get_utc_offset() + (6*60*60);
660 wp_schedule_event( $six_am_local, 'cffweekly', 'cff_notification_update' );
661 }
662
663 if ( ! empty( $options ) ) {
664 return;
665 }
666
667 //Show all post types
668 $options[ 'cff_show_links_type' ] = true;
669 $options[ 'cff_show_event_type' ] = true;
670 $options[ 'cff_show_video_type' ] = true;
671 $options[ 'cff_show_photos_type' ] = true;
672 $options[ 'cff_show_status_type' ] = true;
673 $options[ 'cff_show_albums_type' ] = true;
674 $options[ 'cff_show_author' ] = true;
675 $options[ 'cff_show_text' ] = true;
676 $options[ 'cff_show_desc' ] = true;
677 $options[ 'cff_show_shared_links' ] = true;
678 $options[ 'cff_show_date' ] = true;
679 $options[ 'cff_show_media' ] = true;
680 $options[ 'cff_show_media_link' ] = true;
681 $options[ 'cff_show_event_title' ] = true;
682 $options[ 'cff_show_event_details' ] = true;
683 $options[ 'cff_show_meta' ] = true;
684 $options[ 'cff_show_link' ] = true;
685 $options[ 'cff_show_like_box' ] = true;
686 $options[ 'cff_show_facebook_link' ] = true;
687 $options[ 'cff_show_facebook_share' ] = true;
688 $options[ 'cff_event_title_link' ] = true;
689
690 update_option( 'cff_style_settings', $options );
691
692 get_option('cff_show_access_token');
693 update_option( 'cff_show_access_token', true );
694
695 }
696
697
698 /**
699 * Deactivate
700 *
701 * CFF deactivation action.
702 *
703 * @since 2.19
704 * @access public
705 */
706 function cff_deactivate() {
707 wp_clear_scheduled_hook( 'cff_cron_job');
708 wp_clear_scheduled_hook( 'cff_notification_update');
709 wp_clear_scheduled_hook( 'cff_feed_issue_email' );
710 wp_clear_scheduled_hook( 'cff_usage_tracking_cron' );
711 }
712
713
714 /**
715 * Uninstall
716 *
717 * CFF uninstallation action.
718 *
719 * @since 2.19
720 * @access public
721 */
722 public static function cff_uninstall(){
723 if ( ! current_user_can( 'activate_plugins' ) ){
724 return;
725 }
726 //If the user is preserving the settings then don't delete them
727 $cff_preserve_settings = get_option( 'cff_preserve_settings' );
728 if ( ! empty( $cff_preserve_settings ) ){
729 return;
730 }
731
732 //Settings
733 delete_option( 'cff_show_access_token' );
734 delete_option( 'cff_access_token' );
735 delete_option( 'cff_page_id' );
736 delete_option( 'cff_num_show' );
737 delete_option( 'cff_post_limit' );
738 delete_option( 'cff_show_others' );
739 delete_option( 'cff_cache_time' );
740 delete_option( 'cff_cache_time_unit' );
741 delete_option( 'cff_locale' );
742 delete_option( 'cff_ajax' );
743 delete_option( 'cff_preserve_settings' );
744 //Style & Layout
745 delete_option( 'cff_title_length' );
746 delete_option( 'cff_body_length' );
747 delete_option('cff_style_settings');
748
749 delete_option( 'cff_usage_tracking_config' );
750 delete_option( 'cff_usage_tracking' );
751
752 delete_option( 'cff_statuses' );
753 delete_option( 'cff_rating_notice' );
754 delete_option( 'cff_review_consent' );
755 delete_option( 'cff_db_version' );
756 delete_option( 'cff_newuser_notifications' );
757 delete_option( 'cff_notifications' );
758
759 delete_option( 'cff_legacy_feed_settings' );
760 delete_option( 'cff_theme_styles' );
761 delete_option( 'cff_caching_type' );
762 delete_option( 'cff_oembed_token' );
763
764 global $wp_roles;
765 $wp_roles->remove_cap( 'administrator', 'manage_custom_facebook_feed_options' );
766
767 global $wpdb;
768 $locator_table_name = $wpdb->prefix . CFF_FEED_LOCATOR;
769 $wpdb->query( "DROP TABLE IF EXISTS $locator_table_name" );
770
771 $feeds_table_name = $wpdb->prefix . 'cff_feeds';
772 $wpdb->query( "DROP TABLE IF EXISTS $feeds_table_name" );
773
774 $feed_caches_table_name = $wpdb->prefix . 'cff_feed_caches';
775 $wpdb->query( "DROP TABLE IF EXISTS $feed_caches_table_name" );
776
777 $sources_table_name = $wpdb->prefix . 'cff_sources';
778 $wpdb->query( "DROP TABLE IF EXISTS $sources_table_name" );
779
780 $table_name = esc_sql( $wpdb->prefix . "postmeta" );
781 $result = $wpdb->query("
782 DELETE
783 FROM $table_name
784 WHERE meta_key = '_cff_oembed_done_checking';");
785
786 $usermeta_table_name = $wpdb->prefix . "usermeta";
787 $result = $wpdb->query( "
788 DELETE
789 FROM $usermeta_table_name
790 WHERE meta_key LIKE ('cff\_%')
791 " );
792 }
793
794
795
796 /**
797 * Custom CSS
798 *
799 * Adding custom CSS
800 *
801 * @since 2.19
802 * @access public
803 */
804 function cff_custom_css() {
805 $options = get_option('cff_style_settings');
806 isset($options[ 'cff_custom_css' ]) ? $cff_custom_css = $options[ 'cff_custom_css' ] : $cff_custom_css = '';
807
808 if( !empty($cff_custom_css) ) echo "\r\n";
809 if( !empty($cff_custom_css) ) echo '<!-- Custom Facebook Feed Custom CSS -->';
810 if( !empty($cff_custom_css) ) echo "\r\n";
811 if( !empty($cff_custom_css) ) echo '<style type="text/css">';
812 if( !empty($cff_custom_css) ) echo "\r\n";
813 if( !empty($cff_custom_css) ) echo stripslashes($cff_custom_css);
814 if( !empty($cff_custom_css) ) echo "\r\n";
815 if( !empty($cff_custom_css) ) echo '</style>';
816 if( !empty($cff_custom_css) ) echo "\r\n";
817 }
818
819
820 /**
821 * Custom JS
822 *
823 * Adding custom JS
824 *
825 * @since 2.19
826 * @access public
827 */
828 function cff_js() {
829 $options = get_option('cff_style_settings');
830 $cff_custom_js = isset($options[ 'cff_custom_js' ]) ? $options[ 'cff_custom_js' ] : '';
831
832 //Link hashtags?
833 isset($options[ 'cff_link_hashtags' ]) ? $cff_link_hashtags = $options[ 'cff_link_hashtags' ] : $cff_link_hashtags = 'true';
834 ($cff_link_hashtags == 'true' || $cff_link_hashtags == 'on') ? $cff_link_hashtags = 'true' : $cff_link_hashtags = 'false';
835
836 //If linking the post text then don't link the hashtags
837 isset($options[ 'cff_title_link' ]) ? $cff_title_link = $options[ 'cff_title_link' ] : $cff_title_link = false;
838 ($cff_title_link == 'true' || $cff_title_link == 'on') ? $cff_title_link = true : $cff_title_link = false;
839 if ($cff_title_link) $cff_link_hashtags = 'false';
840
841 echo '<!-- Custom Facebook Feed JS -->';
842 echo "\r\n";
843 echo '<script type="text/javascript">';
844 echo 'var cffajaxurl = "' . admin_url('admin-ajax.php') . '";';
845 echo "\r\n";
846 echo 'var cfflinkhashtags = "' . $cff_link_hashtags . '";';
847 echo "\r\n";
848 if( !empty($cff_custom_js) ) echo "jQuery( document ).ready(function($) {";
849 if( !empty($cff_custom_js) ) echo "\r\n";
850 if( !empty($cff_custom_js) ) echo stripslashes($cff_custom_js);
851 if( !empty($cff_custom_js) ) echo "\r\n";
852 if( !empty($cff_custom_js) ) echo "});";
853 if( !empty($cff_custom_js) ) echo "\r\n";
854 echo '</script>';
855 echo "\r\n";
856 }
857
858
859 /**
860 * Notice Dismiss
861 *
862 * PPCA Check Notice Dismiss
863 *
864 * @since 2.19
865 * @access public
866 */
867 function cff_ppca_check_notice_dismiss() {
868 global $current_user;
869 $user_id = $current_user->ID;
870 if ( isset($_GET['cff_ppca_check_notice_dismiss']) && '0' == $_GET['cff_ppca_check_notice_dismiss'] ) {
871 add_user_meta($user_id, 'cff_ppca_check_notice_dismiss', 'true', true);
872 }
873 }
874
875
876 /**
877 * Cron Custom Interval
878 *
879 * Cron Job Custom Interval
880 *
881 * @since 2.19
882 * @access public
883 */
884 function cff_cron_custom_interval( $schedules ) {
885 $schedules['cffweekly'] = array(
886 'interval' => 3600 * 24 * 7,
887 'display' => __( 'Weekly' )
888 );
889 return $schedules;
890 }
891
892 /**
893 * Feed Locator Ajax Call
894 *
895 *
896 * @since 2.19
897 * @access public
898 */
899 function cff_feed_locator(){
900 $feed_locator_data_array = isset($_POST['feedLocatorData']) && !empty($_POST['feedLocatorData']) && is_array($_POST['feedLocatorData']) ? $_POST['feedLocatorData'] : false;
901 if($feed_locator_data_array != false):
902 foreach ($feed_locator_data_array as $single_feed_locator) {
903 $feed_details = array(
904 'feed_id' => $single_feed_locator['feedID'],
905 'atts' => $single_feed_locator['shortCodeAtts'],
906 'location' => array(
907 'post_id' => $single_feed_locator['postID'],
908 'html' => $single_feed_locator['location']
909 )
910 );
911 $locator = new CFF_Feed_Locator( $feed_details );
912 $locator->add_or_update_entry();
913 }
914 endif;
915 die();
916 }
917 }
918
919
920