WD Facebook Feed – Custom Facebook Feed Plugin - Version 1.0.38

Version Description

  • New: Using page access token
  • New: Reset and update cached Facebook data
  • Changed: Uninstall page moved from separate menu to settings page
  • Changed: Session usage removed
  • Fixed: WordPress loopback request error because of sessions
  • Fixed: PHP notices in widget
Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 WD Facebook Feed – Custom Facebook Feed Plugin
Version 1.0.38
Comparing to
See all releases

Code changes from version 1.0.37 to 1.0.38

admin/controllers/FFWDControllerUninstall_ffwd.php CHANGED
@@ -37,6 +37,12 @@ class FFWDControllerUninstall_ffwd
37
  public function execute()
38
  {
39
  $task = ((isset($_POST['task'])) ? esc_html(stripslashes($_POST['task'])) : '');
 
 
 
 
 
 
40
  if ($task != '') {
41
  if (!WDW_FFWD_Library::verify_nonce('uninstall_ffwd')) {
42
  die('Sorry, your nonce did not verify.');
37
  public function execute()
38
  {
39
  $task = ((isset($_POST['task'])) ? esc_html(stripslashes($_POST['task'])) : '');
40
+ $ffwd_uninstall = get_option("ffwd_uninstall");
41
+ if(isset($ffwd_uninstall) && $ffwd_uninstall ==="1"){
42
+ $task = 'uninstall';
43
+ $this->$task();
44
+ return;
45
+ }
46
  if ($task != '') {
47
  if (!WDW_FFWD_Library::verify_nonce('uninstall_ffwd')) {
48
  die('Sorry, your nonce did not verify.');
admin/models/FFWDModelInfo_ffwd.php CHANGED
@@ -305,6 +305,7 @@ class FFWDModelInfo_ffwd {
305
  $row = new stdClass();
306
  $row->id = 0;
307
  $row->name = '';
 
308
  $row->type = '';
309
  $row->content_type = 'specific';
310
  $row->content = 'photos';
305
  $row = new stdClass();
306
  $row->id = 0;
307
  $row->name = '';
308
+ $row->page_access_token = '';
309
  $row->type = '';
310
  $row->content_type = 'specific';
311
  $row->content = 'photos';
admin/models/FFWDModelUninstall_ffwd.php CHANGED
@@ -30,8 +30,9 @@ class FFWDModelUninstall_ffwd
30
  $wpdb->query("DROP TABLE " . $wpdb->prefix . "wd_fb_shortcode");
31
  delete_option('ffwd_admin_notice');
32
  delete_option("ffwd_version");
33
- delete_option("ffwd_subscribe_done");
34
  delete_option('wds_bk_notice_status');
 
35
 
36
  }
37
  ////////////////////////////////////////////////////////////////////////////////////////
30
  $wpdb->query("DROP TABLE " . $wpdb->prefix . "wd_fb_shortcode");
31
  delete_option('ffwd_admin_notice');
32
  delete_option("ffwd_version");
33
+ //delete_option("ffwd_subscribe_done");
34
  delete_option('wds_bk_notice_status');
35
+ add_option('ffwd_uninstall', '1');
36
 
37
  }
38
  ////////////////////////////////////////////////////////////////////////////////////////
admin/views/FFWDViewInfo_ffwd.php CHANGED
@@ -340,7 +340,7 @@ class FFWDViewInfo_ffwd
340
  }
341
 
342
  .ffwd_main_set_c {
343
- width: 598px;
344
  /*height: 400px;*/
345
  padding: 9px;
346
  }
@@ -417,7 +417,7 @@ class FFWDViewInfo_ffwd
417
  .ffwd_view_t_s, .ffwd_varied_f {
418
  padding: 9px;
419
  box-sizing: border-box;
420
- width: 440px;
421
  margin: 0px 10px 0px 0px;
422
  }
423
 
@@ -678,6 +678,15 @@ class FFWDViewInfo_ffwd
678
  <br>
679
  </td>
680
  </tr>
 
 
 
 
 
 
 
 
 
681
  </tbody>
682
  <tbody id="ffwd_group_warning"
683
  style="display: <?php echo $type == 'group' ? 'block' : 'none' ?>;">
340
  }
341
 
342
  .ffwd_main_set_c {
343
+ width: 100%;
344
  /*height: 400px;*/
345
  padding: 9px;
346
  }
417
  .ffwd_view_t_s, .ffwd_varied_f {
418
  padding: 9px;
419
  box-sizing: border-box;
420
+ width: 660px;
421
  margin: 0px 10px 0px 0px;
422
  }
423
 
678
  <br>
679
  </td>
680
  </tr>
681
+ <tr>
682
+ <td class="ffwd_set_l">
683
+ <label for="page_access_token">Page access token: </label>
684
+ </td>
685
+ <td>
686
+ <input type="text" id="page_access_token" name="page_access_token" value="<?php echo $row->page_access_token; ?>" size="39"/>
687
+ <p class="description">Use this <a target="_blank" href="https://web-dorado.com/wordpress-facebook-feed/options.html">tutorial</a> to get page access token. If you do not use page access token, built-in tokens will be used instead, which may cause API rate limit errors.</p>
688
+ </td>
689
+ </tr>
690
  </tbody>
691
  <tbody id="ffwd_group_warning"
692
  style="display: <?php echo $type == 'group' ? 'block' : 'none' ?>;">
admin/views/FFWDViewOptions_ffwd.php CHANGED
@@ -92,7 +92,7 @@ class FFWDViewOptions_ffwd
92
 
93
  <!--User options-->
94
  <div class="spider_div_options" id="div_content_1" style="">
95
- <table style="width: 60%;">
96
  <tbody>
97
  <tr>
98
  <td class="spider_label_options">
@@ -101,7 +101,7 @@ class FFWDViewOptions_ffwd
101
  <td>
102
  <input type="text" name="<?php echo WD_FB_PREFIX; ?>_app_id"
103
  id="<?php echo WD_FB_PREFIX; ?>_app_id" size="30"
104
- value="<?php echo $row->app_id; ?>" class=""
105
  onchange="if(wd_fb_log_in) alert('Before change app id and secret please logout from curent app.')"/>
106
 
107
  </td>
@@ -113,10 +113,9 @@ class FFWDViewOptions_ffwd
113
  <td>
114
  <input type="text" name="<?php echo WD_FB_PREFIX; ?>_app_secret"
115
  id="<?php echo WD_FB_PREFIX; ?>_app_secret" size="40"
116
- value="<?php echo $row->app_secret; ?>" class=""
117
  onchange="if(wd_fb_log_in) alert('Before change app id and secret please logout from curent app.'); "/>
118
- <div class="spider_description">App ID and App Secret are optional. You only need to fill in this fields if you want your application Access Token to be used instead of the default Access Token.</div>
119
-
120
  </td>
121
  </tr>
122
  <!--<tr>
@@ -149,7 +148,7 @@ class FFWDViewOptions_ffwd
149
  <label>Timezone:</label>
150
  </td>
151
  <td>
152
- <input type="text" value="<?php echo $row->date_timezone ?>" name="<?php echo WD_FB_PREFIX; ?>_date_timezone" />
153
 
154
  <div class="spider_description">If left empty, the server timezone will be used</div>
155
  </td>
@@ -165,7 +164,7 @@ class FFWDViewOptions_ffwd
165
  foreach ($this->model->date_formats as $key => $date_format) {
166
  ?>
167
  <option
168
- value="<?php echo $key; ?>" <?php if ($row->post_date_format == $key) echo 'selected="selected"'; ?>><?php echo $date_format; ?></option>
169
  <?php
170
  }
171
  ?>
@@ -192,7 +191,25 @@ class FFWDViewOptions_ffwd
192
  <div class="spider_description">Choose a date type.</div>
193
  </td>
194
  </tr>
195
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  </tbody>
197
  </table>
198
  </div>
92
 
93
  <!--User options-->
94
  <div class="spider_div_options" id="div_content_1" style="">
95
+ <table style="width: 90%;">
96
  <tbody>
97
  <tr>
98
  <td class="spider_label_options">
101
  <td>
102
  <input type="text" name="<?php echo WD_FB_PREFIX; ?>_app_id"
103
  id="<?php echo WD_FB_PREFIX; ?>_app_id" size="30"
104
+ value="<?php echo isset($row->app_id) ? $row->app_id : ''; ?>" class=""
105
  onchange="if(wd_fb_log_in) alert('Before change app id and secret please logout from curent app.')"/>
106
 
107
  </td>
113
  <td>
114
  <input type="text" name="<?php echo WD_FB_PREFIX; ?>_app_secret"
115
  id="<?php echo WD_FB_PREFIX; ?>_app_secret" size="40"
116
+ value="<?php echo isset($row->app_secret) ? $row->app_secret : ''; ?>" class=""
117
  onchange="if(wd_fb_log_in) alert('Before change app id and secret please logout from curent app.'); "/>
118
+ <div class="spider_description">To get data from Facebook, you need app ID and app Secret. Create your app and get app ID and secret using this <a target="_blank" href="https://web-dorado.com/wordpress-facebook-feed/options.html">tutorial</a>. If you do not use custom app and page access tokens, built-in tokens will be used instead, which may cause API rate limit errors.</div>
 
119
  </td>
120
  </tr>
121
  <!--<tr>
148
  <label>Timezone:</label>
149
  </td>
150
  <td>
151
+ <input type="text" value="<?php echo isset($row->date_timezone) ? $row->date_timezone : ''; ?>" name="<?php echo WD_FB_PREFIX; ?>_date_timezone" />
152
 
153
  <div class="spider_description">If left empty, the server timezone will be used</div>
154
  </td>
164
  foreach ($this->model->date_formats as $key => $date_format) {
165
  ?>
166
  <option
167
+ value="<?php echo $key; ?>" <?php if (isset($row->post_date_format) && $row->post_date_format == $key) echo 'selected="selected"'; ?>><?php echo $date_format; ?></option>
168
  <?php
169
  }
170
  ?>
191
  <div class="spider_description">Choose a date type.</div>
192
  </td>
193
  </tr>
194
+ <tr>
195
+ <td class="spider_label_options">
196
+ <label>Reset cache:</label>
197
+ </td>
198
+ <td>
199
+ <a href="#" class="ffwd_reset_cache button">Reset cache</a>
200
+ <span class="ffwd_reset_cache_res"></span>
201
+ <div class="spider_description">Click to get new data from Facebook</div>
202
+
203
+ </td>
204
+ </tr>
205
+ <tr>
206
+ <td class="spider_label_options">
207
+ <label>Uninstall:</label>
208
+ </td>
209
+ <td>
210
+ <a href="admin.php?page=uninstall_ffwd" class="button">Uninstall</a>
211
+ </td>
212
+ </tr>
213
  </tbody>
214
  </table>
215
  </div>
css/ffwd_tables.css CHANGED
@@ -323,7 +323,7 @@
323
  .spider_label_options {
324
  font-weight: bold;
325
  vertical-align: top;
326
- width: 150px;
327
  }
328
 
329
  .spider_int_input {
@@ -1106,3 +1106,24 @@ div.ffwd_error {
1106
  margin: 0 !important;
1107
  font-size: 14px;
1108
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  .spider_label_options {
324
  font-weight: bold;
325
  vertical-align: top;
326
+ width: 185px;
327
  }
328
 
329
  .spider_int_input {
1106
  margin: 0 !important;
1107
  font-size: 14px;
1108
  }
1109
+
1110
+
1111
+ .spider_div_options .spider_description, .spider_div_options .spider_description a{
1112
+ font-size: 15px;
1113
+ }
1114
+ .spider_div_options .spider_label_options label{
1115
+ font-size: 15px;
1116
+ }
1117
+
1118
+ .ffwd_p .ffwd_set_l label{
1119
+ font-size: 15px;
1120
+ }
1121
+ .ffwd_p .description{
1122
+ font-size: 15px;
1123
+ }
1124
+
1125
+ .ffwd_reset_cache_res{
1126
+ font-size: 19px;
1127
+ margin: 4px 0px 0px 12px;
1128
+ display: inline-block;
1129
+ }
facebook-feed-wd.php CHANGED
@@ -4,21 +4,24 @@
4
  * Plugin Name: WD Facebook Feed
5
  * Plugin URI: https://web-dorado.com/products/wordpress-facebook-feed-plugin.html
6
  * Description:WD Facebook Feed is a completely customizable, responsive solution to help you display your Facebook feed on your WordPress website.
7
- * Version: 1.0.37
8
  * Author: WebDorado
9
  * Author URI: https://web-dorado.com/wordpress-plugins-bundle.html
10
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
11
  */
12
 
 
 
13
  define( 'WD_FFWD_DIR', WP_PLUGIN_DIR . "/" . plugin_basename( dirname( __FILE__ ) ) );
14
  define( 'WD_FFWD_URL', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
15
  define( 'WD_FFWD_PRO', true );
16
  define( 'WD_FB_PREFIX', 'ffwd' );
17
- if ( session_id() == '' ) {
18
- session_start();
19
  }
20
 
21
 
 
22
  function ffwd_use_home_url() {
23
  $home_url = str_replace( "http://", "", home_url() );
24
  $home_url = str_replace( "https://", "", $home_url );
@@ -45,33 +48,36 @@ if ( ffwd_use_home_url() ) {
45
 
46
  // Plugin menu.
47
  function ffwd_menu_panel() {
48
-
49
  $parent_slug = null;
 
50
  if ( get_option( "ffwd_subscribe_done" ) == 1 || ( isset( $_GET["page"] ) && $_GET["page"] == "uninstall_ffwd" ) ) {
51
  $parent_slug = "info_ffwd";
52
- $galleries_page = add_menu_page( 'Facebook Feed WD', 'Facebook Feed WD', 'manage_options', 'info_ffwd', 'ffwd_menu', WD_FFWD_URL . '/images/ffwd/ffwd_logo_small.png' );
 
 
 
53
 
54
  }
55
-
56
- $galleries_page = add_submenu_page( $parent_slug, 'Feeds', 'Feeds', 'manage_options', 'info_ffwd', 'ffwd_menu' );
57
- add_action( 'admin_print_styles-' . $galleries_page, 'ffwd_styles' );
58
- add_action( 'admin_print_scripts-' . $galleries_page, 'ffwd_scripts' );
59
- add_action( 'load-' . $galleries_page, 'ffwd_add_ffwd_info_per_page_option' );
60
-
61
- $options_page = add_submenu_page( $parent_slug, 'Options', 'Options', 'manage_options', 'options_ffwd', 'ffwd_menu' );
62
- add_action( 'admin_print_styles-' . $options_page, 'ffwd_styles' );
63
- add_action( 'admin_print_scripts-' . $options_page, 'ffwd_admin_scripts' );
64
-
65
- $themes_page = add_submenu_page( $parent_slug, 'Themes', 'Themes', 'manage_options', 'themes_ffwd', 'ffwd_menu' );
66
- add_action( 'admin_print_styles-' . $themes_page, 'ffwd_styles' );
67
- add_action( 'admin_print_scripts-' . $themes_page, 'ffwd_admin_scripts' );
68
- add_action( 'load-' . $themes_page, 'ffwd_add_themes_per_page_option' );
69
-
70
- $licensing_page = add_submenu_page( $parent_slug, 'Buy Pro', 'Buy Pro', 'manage_options', 'ffwd_licensing', 'ffwd_licensing_page' );
71
- add_action( 'admin_print_styles-' . $licensing_page, 'ffwd_styles' );
72
-
73
-
74
- $uninstall_page = add_submenu_page( $parent_slug, 'Uninstall', 'Uninstall', 'manage_options', 'uninstall_ffwd', 'ffwd_menu' );
75
  add_action( 'admin_print_styles-' . $uninstall_page, 'ffwd_styles' );
76
  add_action( 'admin_print_scripts-' . $uninstall_page, 'ffwd_admin_scripts' );
77
  }
@@ -95,7 +101,7 @@ function ffwd_privacy_policy($content){
95
  return $content;
96
  }
97
 
98
- if ( ! isset( $_REQUEST['ajax'] ) ) {
99
  if ( ! class_exists( "DoradoWeb" ) ) {
100
  require_once( WD_FFWD_DIR . '/wd/start.php' );
101
  }
@@ -238,8 +244,6 @@ Multiple Feeds per Post/Page", "wd_ads" ),
238
  );
239
 
240
  dorado_web_init( $ffwd_options );
241
-
242
-
243
  }
244
 
245
 
@@ -353,6 +357,17 @@ add_action( 'wp_ajax_check_app', 'ffwd_ajax' );
353
  add_action( 'wp_ajax_nopriv_dropp_objects', 'ffwd_ajax' );
354
  add_action( 'wp_ajax_dropp_objects', 'ffwd_ajax' );
355
 
 
 
 
 
 
 
 
 
 
 
 
356
  function ffwd_ajax() {
357
  if ( function_exists( 'current_user_can' ) ) {
358
  if ( ! current_user_can( 'manage_options' ) ) {
@@ -448,6 +463,7 @@ add_filter( 'mce_buttons', 'ffwd_add_button', 0 );
448
 
449
  // Activate plugin.
450
  function ffwd_activate() {
 
451
  global $wpdb;
452
  $wd_fb_shortcode = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "wd_fb_shortcode` (
453
  `id` bigint(20) NOT NULL,
@@ -459,6 +475,7 @@ function ffwd_activate() {
459
  $wd_fb_info = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "wd_fb_info` (
460
  `id` int(10) NOT NULL AUTO_INCREMENT,
461
  `name` varchar(255) NOT NULL,
 
462
  `type` varchar(10) NOT NULL,
463
  `content_type` varchar(15) NOT NULL,
464
  `content` varchar(256) NOT NULL,
@@ -554,7 +571,17 @@ function ffwd_activate() {
554
 
555
 
556
  $wpdb->query( $wd_fb_info );
557
- //message-i , description , name encoding --> utf16_bin
 
 
 
 
 
 
 
 
 
 
558
  $wd_fb_data = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "wd_fb_data` (
559
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
560
  `fb_id` int NOT NULL,
@@ -774,6 +801,13 @@ function ffwd_set_option_themes( $status, $option, $value ) {
774
  function ffwd_admin_scripts() {
775
  wp_enqueue_script( 'thickbox' );
776
  wp_enqueue_script( 'ffwd_admin', WD_FFWD_URL . '/js/ffwd.js', array(), ffwd_get_version() );
 
 
 
 
 
 
 
777
  global $wp_scripts;
778
  if ( isset( $wp_scripts->registered['jquery'] ) ) {
779
  $jquery = $wp_scripts->registered['jquery'];
@@ -795,7 +829,7 @@ function ffwd_admin_scripts() {
795
 
796
  wp_localize_script( 'ffwd-deactivate-popup', 'ffwdWDDeactivateVars', array(
797
  "prefix" => "ffwd" ,
798
- "deactivate_class" => 'ffwd_deactivate_link',
799
  "email" => $admin_data->data->user_email,
800
  "plugin_wd_url" => "https://web-dorado.com/products/wordpress-google-maps-plugin.html",
801
  ));
@@ -897,8 +931,9 @@ function wd_fb_update($from_plugin=0) {
897
  $current_time=current_time('timestamp');
898
  $update_time=get_option('ffwd_autoupdate_time');
899
  $autoupdate_interval = 1440;//WDFacebookFeed::get_autoupdate_interval();
900
- if(!$update_time)
901
- update_option('ffwd_autoupdate_time',$autoupdate_interval*60+$current_time);
 
902
 
903
  if(($current_time>=$update_time && $from_plugin) || !$from_plugin )
904
  {
@@ -1014,17 +1049,14 @@ if ( !function_exists('wd_bps_install_notice_status') ) {
1014
 
1015
  function ffwd_version() {
1016
 
1017
- $version = '1.0.37';
1018
 
1019
  if ( get_option( 'ffwd_version' ) === false ) {
1020
  add_option( 'ffwd_version', $version );
1021
  } else {
1022
  update_option( 'ffwd_version', $version );
1023
-
1024
-
1025
  }
1026
 
1027
-
1028
  return $version;
1029
 
1030
  }
4
  * Plugin Name: WD Facebook Feed
5
  * Plugin URI: https://web-dorado.com/products/wordpress-facebook-feed-plugin.html
6
  * Description:WD Facebook Feed is a completely customizable, responsive solution to help you display your Facebook feed on your WordPress website.
7
+ * Version: 1.0.38
8
  * Author: WebDorado
9
  * Author URI: https://web-dorado.com/wordpress-plugins-bundle.html
10
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
11
  */
12
 
13
+
14
+
15
  define( 'WD_FFWD_DIR', WP_PLUGIN_DIR . "/" . plugin_basename( dirname( __FILE__ ) ) );
16
  define( 'WD_FFWD_URL', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
17
  define( 'WD_FFWD_PRO', true );
18
  define( 'WD_FB_PREFIX', 'ffwd' );
19
+ if(! defined( 'FFWD_VERSION' ) ){
20
+ define ('FFWD_VERSION',"1.0.38");
21
  }
22
 
23
 
24
+
25
  function ffwd_use_home_url() {
26
  $home_url = str_replace( "http://", "", home_url() );
27
  $home_url = str_replace( "https://", "", $home_url );
48
 
49
  // Plugin menu.
50
  function ffwd_menu_panel() {
51
+ $ffwd_uninstall = get_option("ffwd_uninstall");
52
  $parent_slug = null;
53
+
54
  if ( get_option( "ffwd_subscribe_done" ) == 1 || ( isset( $_GET["page"] ) && $_GET["page"] == "uninstall_ffwd" ) ) {
55
  $parent_slug = "info_ffwd";
56
+ if(isset($ffwd_uninstall) && $ffwd_uninstall ==="1"){
57
+ $parent_slug = 'uninstall_ffwd';
58
+ }
59
+ $galleries_page = add_menu_page( 'Facebook Feed WD', 'Facebook Feed WD', 'manage_options', $parent_slug, 'ffwd_menu', WD_FFWD_URL . '/images/ffwd/ffwd_logo_small.png' );
60
 
61
  }
62
+ if($ffwd_uninstall !=="1"){
63
+ $galleries_page = add_submenu_page( $parent_slug, 'Feeds', 'Feeds', 'manage_options', 'info_ffwd', 'ffwd_menu' );
64
+ add_action( 'admin_print_styles-' . $galleries_page, 'ffwd_styles' );
65
+ add_action( 'admin_print_scripts-' . $galleries_page, 'ffwd_scripts' );
66
+ add_action( 'load-' . $galleries_page, 'ffwd_add_ffwd_info_per_page_option' );
67
+
68
+ $options_page = add_submenu_page( $parent_slug, 'Options', 'Options', 'manage_options', 'options_ffwd', 'ffwd_menu' );
69
+ add_action( 'admin_print_styles-' . $options_page, 'ffwd_styles' );
70
+ add_action( 'admin_print_scripts-' . $options_page, 'ffwd_admin_scripts' );
71
+
72
+ $themes_page = add_submenu_page( $parent_slug, 'Themes', 'Themes', 'manage_options', 'themes_ffwd', 'ffwd_menu' );
73
+ add_action( 'admin_print_styles-' . $themes_page, 'ffwd_styles' );
74
+ add_action( 'admin_print_scripts-' . $themes_page, 'ffwd_admin_scripts' );
75
+ add_action( 'load-' . $themes_page, 'ffwd_add_themes_per_page_option' );
76
+
77
+ $licensing_page = add_submenu_page( $parent_slug, 'Buy Pro', 'Buy Pro', 'manage_options', 'ffwd_licensing', 'ffwd_licensing_page' );
78
+ add_action( 'admin_print_styles-' . $licensing_page, 'ffwd_styles' );
79
+ }
80
+ $uninstall_page = add_submenu_page( '', 'Uninstall', 'Uninstall', 'manage_options', 'uninstall_ffwd', 'ffwd_menu' );
 
81
  add_action( 'admin_print_styles-' . $uninstall_page, 'ffwd_styles' );
82
  add_action( 'admin_print_scripts-' . $uninstall_page, 'ffwd_admin_scripts' );
83
  }
101
  return $content;
102
  }
103
 
104
+ if ( ! isset( $_REQUEST['ajax'] )) {
105
  if ( ! class_exists( "DoradoWeb" ) ) {
106
  require_once( WD_FFWD_DIR . '/wd/start.php' );
107
  }
244
  );
245
 
246
  dorado_web_init( $ffwd_options );
 
 
247
  }
248
 
249
 
357
  add_action( 'wp_ajax_nopriv_dropp_objects', 'ffwd_ajax' );
358
  add_action( 'wp_ajax_dropp_objects', 'ffwd_ajax' );
359
 
360
+ // For reset_cache
361
+ add_action( 'wp_ajax_ffwd_reset_cache', 'ffwd_reset_cache' );
362
+
363
+ function ffwd_reset_cache(){
364
+ if ( isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], WD_FFWD_URL . '_ajax_nonce' )) {
365
+ delete_option("ffwd_autoupdate_time");
366
+ echo json_encode(array("success"=>true));die;
367
+ }
368
+ echo json_encode(array("success"=>false));die;
369
+ }
370
+
371
  function ffwd_ajax() {
372
  if ( function_exists( 'current_user_can' ) ) {
373
  if ( ! current_user_can( 'manage_options' ) ) {
463
 
464
  // Activate plugin.
465
  function ffwd_activate() {
466
+ delete_option("ffwd_uninstall");
467
  global $wpdb;
468
  $wd_fb_shortcode = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "wd_fb_shortcode` (
469
  `id` bigint(20) NOT NULL,
475
  $wd_fb_info = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "wd_fb_info` (
476
  `id` int(10) NOT NULL AUTO_INCREMENT,
477
  `name` varchar(255) NOT NULL,
478
+ `page_access_token` text NOT NULL,
479
  `type` varchar(10) NOT NULL,
480
  `content_type` varchar(15) NOT NULL,
481
  `content` varchar(256) NOT NULL,
571
 
572
 
573
  $wpdb->query( $wd_fb_info );
574
+
575
+ $old_version = ffwd_get_version();
576
+ $FFWD_version_compare = version_compare($old_version, '1.0.37','<=');
577
+ if($FFWD_version_compare){
578
+ $wd_fb_info_collation = "ALTER TABLE `" . $wpdb->prefix . "wd_fb_info`
579
+ ADD `page_access_token` text NOT NULL AFTER `name`";
580
+ $wpdb->query($wd_fb_info_collation);
581
+ }
582
+
583
+
584
+ //message-i , description , name encoding --> utf16_bin
585
  $wd_fb_data = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "wd_fb_data` (
586
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
587
  `fb_id` int NOT NULL,
801
  function ffwd_admin_scripts() {
802
  wp_enqueue_script( 'thickbox' );
803
  wp_enqueue_script( 'ffwd_admin', WD_FFWD_URL . '/js/ffwd.js', array(), ffwd_get_version() );
804
+ wp_localize_script('ffwd_admin', 'ffwd_ajax', array(
805
+ 'ajaxurl' => admin_url('admin-ajax.php'),
806
+ 'ajaxnonce' => wp_create_nonce(WD_FFWD_URL . '_ajax_nonce'),
807
+ ));
808
+
809
+
810
+
811
  global $wp_scripts;
812
  if ( isset( $wp_scripts->registered['jquery'] ) ) {
813
  $jquery = $wp_scripts->registered['jquery'];
829
 
830
  wp_localize_script( 'ffwd-deactivate-popup', 'ffwdWDDeactivateVars', array(
831
  "prefix" => "ffwd" ,
832
+ "deactivate_class" => '',
833
  "email" => $admin_data->data->user_email,
834
  "plugin_wd_url" => "https://web-dorado.com/products/wordpress-google-maps-plugin.html",
835
  ));
931
  $current_time=current_time('timestamp');
932
  $update_time=get_option('ffwd_autoupdate_time');
933
  $autoupdate_interval = 1440;//WDFacebookFeed::get_autoupdate_interval();
934
+ if(!$update_time){
935
+ update_option('ffwd_autoupdate_time',$autoupdate_interval*60+$current_time);
936
+ }
937
 
938
  if(($current_time>=$update_time && $from_plugin) || !$from_plugin )
939
  {
1049
 
1050
  function ffwd_version() {
1051
 
1052
+ $version = FFWD_VERSION;
1053
 
1054
  if ( get_option( 'ffwd_version' ) === false ) {
1055
  add_option( 'ffwd_version', $version );
1056
  } else {
1057
  update_option( 'ffwd_version', $version );
 
 
1058
  }
1059
 
 
1060
  return $version;
1061
 
1062
  }
framework/WDFacebookFeed.php CHANGED
@@ -29,7 +29,7 @@ class WDFacebookFeed {
29
  protected static $timeline_max_call_count = 10;
30
  protected static $valid_content = array('statuses', 'photos', 'videos', 'links', 'events', 'albums');
31
  protected static $access_token;
32
- protected static $exist_access;
33
  protected static $auto_update_feed=0;
34
 
35
  protected static $updateOnVersionChange=false;
@@ -238,6 +238,12 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
238
 
239
  ////////////////////////
240
  $name = ((isset($_POST['name'])) ? esc_html(stripslashes($_POST['name'])) : '');
 
 
 
 
 
 
241
  $update_mode = ((isset($_POST['update_mode'])) ? esc_html(stripslashes($_POST['update_mode'])) : '');
242
  $published = ((isset($_POST['published'])) ? (int) esc_html(stripslashes($_POST['published'])) : 1);
243
  $content = implode(",", self::$content);
@@ -257,6 +263,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
257
  self::$timeline_type='feed';
258
  $save = $wpdb->update($wpdb->prefix . 'wd_fb_info', array(
259
  'name' => $name,
 
260
  'type' => self::$fb_type,
261
  'content_type' => self::$content_type,
262
  'content' => $content,
@@ -401,7 +408,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
401
  self::$content_url = isset($row->content_url) ? $row->content_url : '';
402
  self::$limit = isset($row->limit) ? $row->limit : '';
403
  self::$id = isset($row->from) ? $row->from : '';
404
- self::$access_token = isset($row->access_token) ? $row->access_token : '';
405
 
406
  self::$update_mode = isset($row->update_mode) ? $row->update_mode : self::$update_mode;
407
  self::get_rows_for_delete();
@@ -448,7 +455,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
448
  self::$timeline_type = isset($row->timeline_type) ? $row->timeline_type : 'posts';
449
  self::$limit = isset($row->limit) ? $row->limit : '';
450
  self::$id = isset($row->from) ? $row->from : '';
451
- self::$access_token = isset($row->access_token) ? $row->access_token : '';
452
  self::$update_mode = isset($row->update_mode) ? $row->update_mode : self::$update_mode;
453
  $function_name = self::$content_type;
454
  self::$function_name();
@@ -473,7 +480,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
473
  self::$timeline_type = isset($row->timeline_type) ? $row->timeline_type : 'posts';
474
  self::$limit = isset($row->limit) ? $row->limit : '';
475
  self::$id = isset($row->from) ? $row->from : '';
476
- self::$access_token = isset($row->access_token) ? $row->access_token : '';
477
  self::$update_mode = isset($row->update_mode) ? $row->update_mode : self::$update_mode;
478
  $function_name = self::$content_type;
479
  self::$function_name();
@@ -483,6 +490,9 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
483
  }
484
 
485
  public static function update_db() {
 
 
 
486
  global $wpdb;
487
  $data = self::$data['data'];
488
  $id = self::$fb_id;
@@ -625,38 +635,15 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
625
  }
626
 
627
  public static function set_access_token() {
628
- $fb_option_data = self::get_fb_option_data();
629
-
630
-
631
- $exist_access = ((isset($_POST['exist_access'])) ? $_POST['exist_access'] : 1);
632
-
633
- if($fb_option_data->access_token!='')
634
- {
635
- $exist_access=0;
636
- }
637
- // If fb type is profile so get user access token
638
- if(self::$fb_type == 'profile') {
639
- self::$facebook_sdk->setExtendedAccessToken();
640
- self::$access_token = self::$facebook_sdk->getAccessToken();
641
- self::$exist_access = $exist_access;
642
- return;
643
- }
644
- // If fb type is page or group so get any valid access token
645
- if($exist_access) {
646
- $rand_key = array_rand(self::$access_tokens);
647
- self::$access_token = self::$access_tokens[$rand_key];
648
- }
649
- else {
650
-
651
- self::$access_token = esc_html(stripslashes($fb_option_data->access_token));
652
-
653
- }
654
-
655
- if (!empty($fb_option_data->app_id) && !empty($fb_option_data->app_secret)) {
656
- self::$access_token = $fb_option_data->app_id . '|' . $fb_option_data->app_secret;
657
- }
658
-
659
- self::$exist_access = $exist_access;
660
  }
661
 
662
  public static function check_fb_page_url() {
@@ -680,10 +667,13 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
680
  }
681
  else
682
  $name_id = $third_token[0];
683
- // If not set access token , get random from our's
684
- $rand_key = array_rand(self::$access_tokens);
685
- $access_token = self::$access_tokens[$rand_key];
686
- // Get data (including page id) by graph url
 
 
 
687
  $fb_graph_url = str_replace (
688
  array('{FB_ID}', '{EDGE}','{ACCESS_TOKEN}', '{FIELDS}', '{LIMIT}', '{OTHER}'),
689
  array($name_id, '', 'access_token='.$access_token.'&', 'fields=id&', 'limit=10', ''),
@@ -739,30 +729,33 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
739
  if( $data['error']['code']==4)
740
  update_option('ffwd_limit_notice',1);
741
  self::wd_fb_massage('error', $data['error']['message']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
742
  }
743
- // Set next page if it exists
744
- $paging = array_key_exists ( 'paging' , $data ) ? $data['paging'] : array();
745
- $next_page = array_key_exists ( 'next' , $paging ) ? $paging['next'] : 0;
746
- $post_data = isset($data['data']) ? $data['data'] : array();
747
- foreach($post_data as $next) {
748
- if(strpos($content, $next['type']) === false)
749
- continue;
750
- if(self::$timeline_type == 'others' && self::$id == $next['from']['id'])
751
- continue;
752
 
753
- if($next['type']=='status' && !isset($next['description']) && !isset($next['message']) && !isset($next['name']))
754
- continue;
755
 
756
- if(count(self::$complite_timeline_data) < self::$limit)
757
- array_push(self::$complite_timeline_data, $next);
758
- }
759
- if(count(self::$complite_timeline_data) < self::$limit && self::$timeline_max_call_count > 0 && $next_page) {
760
- self::$timeline_max_call_count--;
761
- return self::complite_timeline($next_page);
762
- }
763
- else {
764
- return self::$complite_timeline_data;
765
- }
766
  }
767
 
768
  public static function timeline() {
@@ -776,6 +769,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
776
  self::set_timeline_type();
777
  self::$complite_timeline_data = array();
778
  $data = array();
 
779
  $fields = 'fields=comments.limit(25).summary(true){parent.fields(id),created_time,from,like_count,message,comment_count},attachments,shares,id,name,story,link,created_time,updated_time,from{picture,name,link},message,type,source,place,message_tags,with_tags,story_tags,description,status_type&'; $edge = (self::$fb_type == 'group') ? 'feed' : (self::$timeline_type == 'feed' || self::$timeline_type == 'others') ? 'feed' : 'posts';
780
  $fb_graph_url = str_replace (
781
  array('{FB_ID}', '{EDGE}','{ACCESS_TOKEN}', '{FIELDS}', '{LIMIT}', '{OTHER}'),
@@ -835,7 +829,9 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
835
 
836
  foreach ($data as $key => $next) {
837
 
838
-
 
 
839
  /**
840
  * check if content_type is timeline dont save wd_fb_data if
841
  * $content string not contain $next['type']
@@ -1128,6 +1124,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
1128
  public static function save_db() {
1129
  global $wpdb;
1130
  $name = ((isset($_POST['name'])) ? esc_html(stripslashes($_POST['name'])) : '');
 
1131
  $update_mode = ((isset($_POST['update_mode'])) ? esc_html(stripslashes($_POST['update_mode'])) : '');
1132
  // Collapse content types (multiple when content type is timeline, one when specific)
1133
  $content = implode(",", self::$content);
@@ -1215,6 +1212,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
1215
  self::$timeline_type='feed';
1216
  $save_fb_info = $wpdb->insert($wpdb->prefix . 'wd_fb_info', array(
1217
  'name' => $name,
 
1218
  'type' => self::$fb_type,
1219
  'content_type' => 'timeline',
1220
  'content' => $content,
@@ -1567,7 +1565,7 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
1567
 
1568
  $fb_graph_url = str_replace (
1569
  array('{FB_ID}', '{EDGE}','{ACCESS_TOKEN}', '{FIELDS}', '{LIMIT}', '{OTHER}'),
1570
- array($app_id, '', 'access_token=' . $app_id . '|' . $app_secret . '&', 'fields=roles&', '', ''),
1571
  self::$graph_url
1572
  );
1573
 
@@ -1684,9 +1682,6 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
1684
 
1685
  public static function decap_do_curl($uri)
1686
  {
1687
-
1688
-
1689
-
1690
  $facebook_graph_results = null;
1691
  $facebook_graph_url = $uri; //TODO: Add URL checking here, else error out
1692
 
@@ -1716,6 +1711,25 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
1716
  return self::decap_do_curl($facebook_graph_url);
1717
  }
1718
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1719
  if(isset($facebook_graph_results["error"]) && count(self::$access_tokens)>1){
1720
  if (($key = array_search(self::$access_token, self::$access_tokens)) !== false) {
1721
  unset(self::$access_tokens[$key]);
@@ -1735,7 +1749,30 @@ $ffwd_info_options[$ffwd_option_db] =((isset($_POST[$ffwd_option_db])) ? esc_htm
1735
  }
1736
  return $facebook_graph_results;
1737
  }
 
 
 
1738
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1739
  public static function get_autoupdate_interval(){
1740
  global $wpdb;
1741
  $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'wd_fb_option WHERE id="%d"', 1));
29
  protected static $timeline_max_call_count = 10;
30
  protected static $valid_content = array('statuses', 'photos', 'videos', 'links', 'events', 'albums');
31
  protected static $access_token;
32
+ protected static $exist_access = false;
33
  protected static $auto_update_feed=0;
34
 
35
  protected static $updateOnVersionChange=false;
238
 
239
  ////////////////////////
240
  $name = ((isset($_POST['name'])) ? esc_html(stripslashes($_POST['name'])) : '');
241
+ $page_access_token = ((isset($_POST['page_access_token'])) ? esc_html(stripslashes($_POST['page_access_token'])) : '');
242
+
243
+ $new_access_token = self::update_page_access_token($page_access_token);
244
+ if($new_access_token["success"]){
245
+ $page_access_token = $new_access_token["new_token"];
246
+ }
247
  $update_mode = ((isset($_POST['update_mode'])) ? esc_html(stripslashes($_POST['update_mode'])) : '');
248
  $published = ((isset($_POST['published'])) ? (int) esc_html(stripslashes($_POST['published'])) : 1);
249
  $content = implode(",", self::$content);
263
  self::$timeline_type='feed';
264
  $save = $wpdb->update($wpdb->prefix . 'wd_fb_info', array(
265
  'name' => $name,
266
+ 'page_access_token' => $page_access_token,
267
  'type' => self::$fb_type,
268
  'content_type' => self::$content_type,
269
  'content' => $content,
408
  self::$content_url = isset($row->content_url) ? $row->content_url : '';
409
  self::$limit = isset($row->limit) ? $row->limit : '';
410
  self::$id = isset($row->from) ? $row->from : '';
411
+ self::$access_token = isset($row->page_access_token) ? $row->page_access_token : '';
412
 
413
  self::$update_mode = isset($row->update_mode) ? $row->update_mode : self::$update_mode;
414
  self::get_rows_for_delete();
455
  self::$timeline_type = isset($row->timeline_type) ? $row->timeline_type : 'posts';
456
  self::$limit = isset($row->limit) ? $row->limit : '';
457
  self::$id = isset($row->from) ? $row->from : '';
458
+ self::$access_token = isset($row->page_access_token) ? $row->page_access_token : '';
459
  self::$update_mode = isset($row->update_mode) ? $row->update_mode : self::$update_mode;
460
  $function_name = self::$content_type;
461
  self::$function_name();
480
  self::$timeline_type = isset($row->timeline_type) ? $row->timeline_type : 'posts';
481
  self::$limit = isset($row->limit) ? $row->limit : '';
482
  self::$id = isset($row->from) ? $row->from : '';
483
+ self::$access_token = isset($row->page_access_token) ? $row->page_access_token : '';
484
  self::$update_mode = isset($row->update_mode) ? $row->update_mode : self::$update_mode;
485
  $function_name = self::$content_type;
486
  self::$function_name();
490
  }
491
 
492
  public static function update_db() {
493
+ if(!isset(self::$data['data'])){
494
+ return;
495
+ }
496
  global $wpdb;
497
  $data = self::$data['data'];
498
  $id = self::$fb_id;
635
  }
636
 
637
  public static function set_access_token() {
638
+ if(isset($_POST["page_access_token"]) && $_POST["page_access_token"] != ""){
639
+ self::$access_token = $_POST["page_access_token"];
640
+ self::$exist_access = true;
641
+ }else{
642
+ if(!isset(self::$access_token) || empty(self::$access_token)){
643
+ $rand_key = array_rand(self::$access_tokens);
644
+ self::$access_token = self::$access_tokens[$rand_key];
645
+ }
646
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  }
648
 
649
  public static function check_fb_page_url() {
667
  }
668
  else
669
  $name_id = $third_token[0];
670
+ // If not set access token , get random from our's
671
+ if (empty(self::$access_token)) {
672
+ $rand_key = array_rand(self::$access_tokens);
673
+ $access_token = self::$access_tokens[$rand_key];
674
+ } else {
675
+ $access_token = self::$access_token;
676
+ }
677
  $fb_graph_url = str_replace (
678
  array('{FB_ID}', '{EDGE}','{ACCESS_TOKEN}', '{FIELDS}', '{LIMIT}', '{OTHER}'),
679
  array($name_id, '', 'access_token='.$access_token.'&', 'fields=id&', 'limit=10', ''),
729
  if( $data['error']['code']==4)
730
  update_option('ffwd_limit_notice',1);
731
  self::wd_fb_massage('error', $data['error']['message']);
732
+ }else{
733
+ // Set next page if it exists
734
+ $paging = array_key_exists ( 'paging' , $data ) ? $data['paging'] : array();
735
+ $next_page = array_key_exists ( 'next' , $paging ) ? $paging['next'] : 0;
736
+ $post_data = isset($data['data']) ? $data['data'] : array();
737
+ foreach($post_data as $next) {
738
+ if(strpos($content, $next['type']) === false)
739
+ continue;
740
+ if(self::$timeline_type == 'others' && self::$id == $next['from']['id'])
741
+ continue;
742
+
743
+ if($next['type']=='status' && !isset($next['description']) && !isset($next['message']) && !isset($next['name']))
744
+ continue;
745
+
746
+ if(count(self::$complite_timeline_data) < self::$limit)
747
+ array_push(self::$complite_timeline_data, $next);
748
+ }
749
+ if(count(self::$complite_timeline_data) < self::$limit && self::$timeline_max_call_count > 0 && $next_page) {
750
+ self::$timeline_max_call_count--;
751
+ return self::complite_timeline($next_page);
752
+ }
753
+ else {
754
+ return self::$complite_timeline_data;
755
+ }
756
  }
 
 
 
 
 
 
 
 
 
757
 
 
 
758
 
 
 
 
 
 
 
 
 
 
 
759
  }
760
 
761
  public static function timeline() {
769
  self::set_timeline_type();
770
  self::$complite_timeline_data = array();
771
  $data = array();
772
+ self::set_access_token();
773
  $fields = 'fields=comments.limit(25).summary(true){parent.fields(id),created_time,from,like_count,message,comment_count},attachments,shares,id,name,story,link,created_time,updated_time,from{picture,name,link},message,type,source,place,message_tags,with_tags,story_tags,description,status_type&'; $edge = (self::$fb_type == 'group') ? 'feed' : (self::$timeline_type == 'feed' || self::$timeline_type == 'others') ? 'feed' : 'posts';
774
  $fb_graph_url = str_replace (
775
  array('{FB_ID}', '{EDGE}','{ACCESS_TOKEN}', '{FIELDS}', '{LIMIT}', '{OTHER}'),
829
 
830
  foreach ($data as $key => $next) {
831
 
832
+ if(!isset($ids[$key])){
833
+ continue;
834
+ }
835
  /**
836
  * check if content_type is timeline dont save wd_fb_data if
837
  * $content string not contain $next['type']
1124
  public static function save_db() {
1125
  global $wpdb;
1126
  $name = ((isset($_POST['name'])) ? esc_html(stripslashes($_POST['name'])) : '');
1127
+ $page_access_token = ((isset($_POST['page_access_token'])) ? esc_html(stripslashes($_POST['page_access_token'])) : '');
1128
  $update_mode = ((isset($_POST['update_mode'])) ? esc_html(stripslashes($_POST['update_mode'])) : '');
1129
  // Collapse content types (multiple when content type is timeline, one when specific)
1130
  $content = implode(",", self::$content);
1212
  self::$timeline_type='feed';
1213
  $save_fb_info = $wpdb->insert($wpdb->prefix . 'wd_fb_info', array(
1214
  'name' => $name,
1215
+ 'page_access_token' => $page_access_token,
1216
  'type' => self::$fb_type,
1217
  'content_type' => 'timeline',
1218
  'content' => $content,
1565
 
1566
  $fb_graph_url = str_replace (
1567
  array('{FB_ID}', '{EDGE}','{ACCESS_TOKEN}', '{FIELDS}', '{LIMIT}', '{OTHER}'),
1568
+ array($app_id, '', 'access_token=' . self::$access_token . '&', 'fields=roles&', '', ''),
1569
  self::$graph_url
1570
  );
1571
 
1682
 
1683
  public static function decap_do_curl($uri)
1684
  {
 
 
 
1685
  $facebook_graph_results = null;
1686
  $facebook_graph_url = $uri; //TODO: Add URL checking here, else error out
1687
 
1711
  return self::decap_do_curl($facebook_graph_url);
1712
  }
1713
  }
1714
+ /* if(isset($facebook_graph_results["error"]) && isset($facebook_graph_results["error"]['code']) && $facebook_graph_results["error"]['code']===190){
1715
+ if(self::$exist_access){
1716
+ $fb_option_data = self::get_fb_option_data();
1717
+
1718
+ if(isset($fb_option_data->app_id) && isset($fb_option_data->app_secret)){
1719
+ $app_id = $fb_option_data->app_id;
1720
+ $app_secret = $fb_option_data->app_secret;
1721
+ if(!empty($app_id) && !empty($app_id)){
1722
+ $res = self::update_page_access_token(self::$access_token);
1723
+ if($res["success"]){
1724
+ self::$access_token = $res["success"];
1725
+ }
1726
+ }
1727
+ }
1728
+ }
1729
+ }*/
1730
+
1731
+
1732
+
1733
  if(isset($facebook_graph_results["error"]) && count(self::$access_tokens)>1){
1734
  if (($key = array_search(self::$access_token, self::$access_tokens)) !== false) {
1735
  unset(self::$access_tokens[$key]);
1749
  }
1750
  return $facebook_graph_results;
1751
  }
1752
+ private static function update_page_access_token($old_access_token){
1753
+ global $wpdb;
1754
+ $fb_option_data = self::get_fb_option_data();
1755
 
1756
+ $return_data = array(
1757
+ 'success'=>false,
1758
+ 'new_token'=>null,
1759
+ );
1760
+ if(isset($fb_option_data->app_id) && isset($fb_option_data->app_secret)) {
1761
+ $app_id = $fb_option_data->app_id;
1762
+ $app_secret = $fb_option_data->app_secret;
1763
+ $url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&client_secret=" . $app_secret . "&grant_type=fb_exchange_token&fb_exchange_token=" . $old_access_token;
1764
+ $response = wp_remote_get($url);
1765
+ if (isset($response['body'])) {
1766
+ $data = json_decode($response['body'], true);
1767
+ if (isset($data["access_token"]) && !empty($data["access_token"])) {
1768
+ $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "wd_fb_info SET page_access_token = %s WHERE page_access_token = %s", $data["access_token"], $old_access_token));
1769
+ $return_data["success"] = true;
1770
+ $return_data["new_token"] = $data["access_token"];
1771
+ }
1772
+ }
1773
+ }
1774
+ return $return_data;
1775
+ }
1776
  public static function get_autoupdate_interval(){
1777
  global $wpdb;
1778
  $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'wd_fb_option WHERE id="%d"', 1));
frontend/models/FFWDModelBlog_style.php CHANGED
@@ -106,7 +106,9 @@ class FFWDModelBlog_style extends FFWDModelMain {
106
  $event_date_format = $this->options->event_date_format;
107
  $post_date_format = $this->options->post_date_format;
108
  $date_timezone = isset($this->options->date_timezone) && $this->options->date_timezone!='' ? $this->options->date_timezone : date_default_timezone_get() ;
109
-
 
 
110
  $date_create = new DateTime($object_row->created_time);
111
  $date_create->setTimezone(new DateTimeZone($date_timezone));
112
  $date_update = new DateTime($object_row->updated_time);
106
  $event_date_format = $this->options->event_date_format;
107
  $post_date_format = $this->options->post_date_format;
108
  $date_timezone = isset($this->options->date_timezone) && $this->options->date_timezone!='' ? $this->options->date_timezone : date_default_timezone_get() ;
109
+ if (!in_array($date_timezone, DateTimeZone::listIdentifiers())) {
110
+ $date_timezone = "UTC";
111
+ }
112
  $date_create = new DateTime($object_row->created_time);
113
  $date_create->setTimezone(new DateTimeZone($date_timezone));
114
  $date_update = new DateTime($object_row->updated_time);
js/ffwd.js CHANGED
@@ -12,8 +12,10 @@ function spider_ajax_save(wd_fb_prefix) {
12
  }
13
 
14
  /* Get params for facebook call */
 
15
  var ffwd_nonce = jQuery("#ffwd_nonce").val(),
16
  name = jQuery("#name").val(),
 
17
  update_mode = jQuery("input[name=update_mode]:checked").val(),
18
 
19
  content_url = '',
@@ -141,6 +143,7 @@ function spider_ajax_save(wd_fb_prefix) {
141
  data["published"] = published;
142
  data["ffwd_nonce"] = ffwd_nonce;
143
  data["name"] = name;
 
144
  data["fb_type"] = fb_type;
145
  data["content_url"] = content_url;
146
  data["content_type"] = content_type;
@@ -900,3 +903,64 @@ function bwg_change_theme_type(type) {
900
  jQuery("#type_Navigation").attr("style", "border: none;color:#23282D");
901
  jQuery("#type_" + type).attr("style", "border-top: 1px solid #3B5A9A;border-left: 1px solid #3B5A9A;border-right: 1px solid #3B5A9A;color:#3b5a9a");
902
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
14
  /* Get params for facebook call */
15
+ var page_access_token = jQuery("#page_access_token").val();
16
  var ffwd_nonce = jQuery("#ffwd_nonce").val(),
17
  name = jQuery("#name").val(),
18
+
19
  update_mode = jQuery("input[name=update_mode]:checked").val(),
20
 
21
  content_url = '',
143
  data["published"] = published;
144
  data["ffwd_nonce"] = ffwd_nonce;
145
  data["name"] = name;
146
+ data["page_access_token"] = page_access_token;
147
  data["fb_type"] = fb_type;
148
  data["content_url"] = content_url;
149
  data["content_type"] = content_type;
903
  jQuery("#type_Navigation").attr("style", "border: none;color:#23282D");
904
  jQuery("#type_" + type).attr("style", "border-top: 1px solid #3B5A9A;border-left: 1px solid #3B5A9A;border-right: 1px solid #3B5A9A;color:#3b5a9a");
905
  }
906
+
907
+ jQuery(document).ready(function () {
908
+ jQuery(".ffwd_reset_cache").click(function (e) {
909
+ jQuery(".ffwd_reset_cache_res").html("");
910
+ e.preventDefault();
911
+ jQuery.ajax({
912
+ url: ffwd_ajax.ajaxurl,
913
+ type: "POST",
914
+ dataType: 'json',
915
+ data: {
916
+ action: 'ffwd_reset_cache',
917
+ nonce: ffwd_ajax.ajaxnonce,
918
+ },
919
+ success: function (data)
920
+ {
921
+ if(data.success){
922
+ jQuery(".ffwd_reset_cache_res").html("Success");
923
+ jQuery(".ffwd_reset_cache_res").css({
924
+ 'color':'#0BF235'
925
+ });
926
+ }else{
927
+ jQuery(".ffwd_reset_cache_res").html("Error");
928
+ jQuery(".ffwd_reset_cache_res").css({
929
+ 'color':'#F30202'
930
+ });
931
+ }
932
+ },
933
+ error: function (data)
934
+ {
935
+ jQuery(".ffwd_reset_cache_res").html("Error");
936
+ jQuery(".ffwd_reset_cache_res").css({
937
+ 'color':'#F30202'
938
+ });
939
+ }
940
+ });
941
+
942
+ });
943
+
944
+
945
+
946
+ var selected_fb_type = jQuery("#ffwd_type").val();
947
+
948
+ if(selected_fb_type !== "page"){
949
+ jQuery("#page_access_token").closest("tr").css({
950
+ 'display':'none'
951
+ });
952
+ }
953
+
954
+ jQuery("#ffwd_type").change(function () {
955
+ var fb_type = jQuery("#ffwd_type").val();
956
+ if(fb_type === "page"){
957
+ jQuery("#page_access_token").closest("tr").css({
958
+ 'display':'table-row'
959
+ });
960
+ }else{
961
+ jQuery("#page_access_token").closest("tr").css({
962
+ 'display':'none'
963
+ });
964
+ }
965
+ });
966
+ });
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: customizable facebook feed, facebook, facebook events, facebook feed, face
4
  Requires at least: 3.4
5
  Requires PHP: 5.2
6
  Tested up to: 4.9
7
- Stable tag: 1.0.37
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -100,6 +100,14 @@ The plugin uses Facebook API to get public data from Facebook. All the received
100
 
101
  == Changelog ==
102
 
 
 
 
 
 
 
 
 
103
  = 1.0.37 =
104
  * Changed: API requests reduced from frontend
105
  * Changed: Use another token if API returns any kind of error
4
  Requires at least: 3.4
5
  Requires PHP: 5.2
6
  Tested up to: 4.9
7
+ Stable tag: 1.0.38
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
100
 
101
  == Changelog ==
102
 
103
+ = 1.0.38 =
104
+ * New: Using page access token
105
+ * New: Reset and update cached Facebook data
106
+ * Changed: Uninstall page moved from separate menu to settings page
107
+ * Changed: Session usage removed
108
+ * Fixed: WordPress loopback request error because of sessions
109
+ * Fixed: PHP notices in widget
110
+
111
  = 1.0.37 =
112
  * Changed: API requests reduced from frontend
113
  * Changed: Use another token if API returns any kind of error