WP Embed Facebook - Version 1.9.6.3

Version Description

  • Fixed MultiSite error
  • New Shortcode use [facebook=FB_Object_ID ] solution for fb permalinks
  • Fixed raw attribute on shortcode when url is video
Download this release

Release Info

Developer poxtron
Plugin Icon 128x128 WP Embed Facebook
Version 1.9.6.3
Comparing to
See all releases

Code changes from version 1.9.6.1 to 1.9.6.3

Files changed (5) hide show
  1. lib/admin.php +12 -11
  2. lib/core.php +37 -23
  3. readme.txt +17 -9
  4. templates/default/video.php +1 -1
  5. wp-embed-facebook.php +1 -1
lib/admin.php CHANGED
@@ -12,14 +12,14 @@ class EmbFbAdmin
12
  $url = "https://ajax.googleapis.com/ajax/libs/jqueryui/" . $queryui->ver . "/themes/smoothness/jquery-ui.css";
13
  wp_enqueue_style('jquery-ui-start', $url, false, null);
14
  }
15
- $translation_array = array('local' => get_locale(), 'fb_id' => get_site_option('wpemfb_app_id'), 'fb_root' => get_site_option('wpemfb_fb_root'));
16
  wp_localize_script('wpemfb', 'WEF', $translation_array);
17
  wp_enqueue_script('wpemfb');
18
  }
19
 
20
  static function admin_init()
21
  {
22
- $theme = get_site_option('wpemfb_theme');
23
  add_editor_style(WPEMFBURL . 'templates/' . $theme . '/wpemfb.css');
24
  }
25
 
@@ -36,13 +36,13 @@ class EmbFbAdmin
36
  {
37
  if ($type == 'direct') {
38
  if (isset($_POST[$option])) {
39
- update_site_option($option, $_POST[$option]);
40
  }
41
  } else {
42
  if (isset($_POST[$option])) {
43
- update_site_option($option, 'true');
44
  } else {
45
- update_site_option($option, 'false');
46
  }
47
  }
48
  }
@@ -76,8 +76,8 @@ class EmbFbAdmin
76
  self::save_option($option, $type);
77
  }
78
  if (isset($_POST['wpemfb_max_width']) && is_int($_POST['wpemfb_max_width'])) {
79
- $prop = get_site_option('wpemfb_proportions') * $_POST['wpemfb_max_width'];
80
- update_site_option('wpemfb_height', $prop);
81
  }
82
  }
83
  /**
@@ -99,7 +99,7 @@ class EmbFbAdmin
99
  <th><?php echo $label ?></th>
100
  <td>
101
  <input type="checkbox"
102
- name="<?php echo $name ?>" <?php echo (get_site_option($name) === 'true') ? 'checked' : '' ?> />
103
  </td>
104
  </tr>
105
  <?php
@@ -113,11 +113,12 @@ class EmbFbAdmin
113
  <td>
114
  <input type="<?php echo $type ?>"
115
  name="<?php echo $name ?>" <?php echo isset($args['required']) ? 'required' : '' ?>
116
- value="<?php echo get_site_option($name) ?>" size="38"/>
117
  </td>
118
  </tr>
119
  <?php
120
  ob_end_flush();
 
121
  }
122
  }
123
  static function section($title=''){
@@ -142,8 +143,8 @@ class EmbFbAdmin
142
  self::savedata();
143
 
144
  }
145
- $sel1 = (get_site_option('wpemfb_theme') === 'default') ? 'selected' : '';
146
- $sel2 = (get_site_option('wpemfb_theme') === 'classic') ? 'selected' : '';
147
 
148
  ?>
149
  <style>
12
  $url = "https://ajax.googleapis.com/ajax/libs/jqueryui/" . $queryui->ver . "/themes/smoothness/jquery-ui.css";
13
  wp_enqueue_style('jquery-ui-start', $url, false, null);
14
  }
15
+ $translation_array = array('local' => get_locale(), 'fb_id' => get_option('wpemfb_app_id'), 'fb_root' => get_option('wpemfb_fb_root'));
16
  wp_localize_script('wpemfb', 'WEF', $translation_array);
17
  wp_enqueue_script('wpemfb');
18
  }
19
 
20
  static function admin_init()
21
  {
22
+ $theme = get_option('wpemfb_theme');
23
  add_editor_style(WPEMFBURL . 'templates/' . $theme . '/wpemfb.css');
24
  }
25
 
36
  {
37
  if ($type == 'direct') {
38
  if (isset($_POST[$option])) {
39
+ update_option($option, $_POST[$option]);
40
  }
41
  } else {
42
  if (isset($_POST[$option])) {
43
+ update_option($option, 'true');
44
  } else {
45
+ update_option($option, 'false');
46
  }
47
  }
48
  }
76
  self::save_option($option, $type);
77
  }
78
  if (isset($_POST['wpemfb_max_width']) && is_int($_POST['wpemfb_max_width'])) {
79
+ $prop = get_option('wpemfb_proportions') * $_POST['wpemfb_max_width'];
80
+ update_option('wpemfb_height', $prop);
81
  }
82
  }
83
  /**
99
  <th><?php echo $label ?></th>
100
  <td>
101
  <input type="checkbox"
102
+ name="<?php echo $name ?>" <?php echo (get_option($name) === 'true') ? 'checked' : '' ?> />
103
  </td>
104
  </tr>
105
  <?php
113
  <td>
114
  <input type="<?php echo $type ?>"
115
  name="<?php echo $name ?>" <?php echo isset($args['required']) ? 'required' : '' ?>
116
+ value="<?php echo get_option($name) ?>" size="38"/>
117
  </td>
118
  </tr>
119
  <?php
120
  ob_end_flush();
121
+ break;
122
  }
123
  }
124
  static function section($title=''){
143
  self::savedata();
144
 
145
  }
146
+ $sel1 = (get_option('wpemfb_theme') === 'default') ? 'selected' : '';
147
+ $sel2 = (get_option('wpemfb_theme') === 'classic') ? 'selected' : '';
148
 
149
  ?>
150
  <style>
lib/core.php CHANGED
@@ -11,16 +11,15 @@ class WP_Embed_FB {
11
  static $raw = '';
12
  static $premium = '';
13
  static $num_posts = '';
14
- static $poster = '';
15
  /**
16
  * Save default values to data base
17
  */
18
  static function install(){
19
  $defaults = self::getdefaults();
20
  foreach ($defaults as $option => $value) {
21
- $opt = get_site_option($option);
22
  if($opt === false)
23
- update_site_option($option, $value);
24
  if(!isset($type))
25
  $type = $opt==false?"activated":"reactivated";
26
  }
@@ -32,9 +31,20 @@ class WP_Embed_FB {
32
  */
33
  static function uninstall(){
34
  $defaults = self::getdefaults();
35
- foreach ($defaults as $option ) {
36
- delete_site_option($option);
37
- }
 
 
 
 
 
 
 
 
 
 
 
38
  self::whois('uninstalled');
39
  return;
40
  }
@@ -183,21 +193,14 @@ class WP_Embed_FB {
183
 
184
  if (!empty(self::$raw)) {
185
  $raw_photo = self::$raw;
186
- $raw_video = self::$raw;
187
  } else {
188
  $raw_photo = get_option('wpemfb_raw_photo') == 'true' ? 'true' : 'false';
189
- $raw_video = get_option('wpemfb_raw_video') == 'true' ? 'true' : 'false';
190
  }
 
 
191
  //is video
192
  if (isset($vars['v'])) { //is video
193
- if ($raw_video == 'true') {
194
- //$fb_data = array( 'v_id' => $vars['v'], 'is_video' => '' );
195
- return self::fb_api_get($vars['v'], $match[2]);
196
- //return self::print_fb_data($fb_data);
197
- } else {
198
- $fb_data = array('link' => $match[2], 'is_post' => '');
199
- return self::print_fb_data($fb_data);
200
- }
201
  }
202
  //photos
203
  if ('photo.php' == $last || (array_search('photos', $clean) !== false)) {
@@ -251,7 +254,7 @@ class WP_Embed_FB {
251
  $num_posts = self::$num_posts !== '' && is_numeric(self::$num_posts) ? self::$num_posts : get_option("wpemfb_max_posts");
252
  $api_string2 = '';
253
  if(isset($fb_data['embed_html']))
254
- $fb_data = array_merge($fb_data,array('is_video' => '1'));
255
  elseif( isset($fb_data['category']) && get_option("wpemfb_show_posts") == "true")
256
  $api_string2 = '/'.$fb_data['id'].'?fields=posts.limit('.$num_posts.'){message,shares,link,picture,object_id,likes.limit(1).summary(true),comments.limit(1).summary(true)}';
257
 
@@ -286,9 +289,7 @@ class WP_Embed_FB {
286
  $res = '<p><a href="https://www.facebook.com/'.$url.'" target="_blank" rel="nofollow">https://www.facebook.com/'.$url.'</a>';
287
  if(is_super_admin()){
288
  $error = $e->getResult();
289
- $res .= '<br><span style="color: #4a0e13">' .__('This facebook link is not public', 'wp-embed-facebook').'</span>';
290
- $res .= '<br>';
291
- $res .= $error['error']['message'];
292
  }
293
  $res .= '</p>';
294
  }
@@ -302,7 +303,16 @@ class WP_Embed_FB {
302
  */
303
  static function print_fb_data($fb_data){
304
  if(isset($fb_data['is_video'])) { //is raw video
305
- $template = self::locate_template('video');
 
 
 
 
 
 
 
 
 
306
  } elseif(isset($fb_data['is_post'])) { //is post
307
  $template = self::locate_template('posts');
308
  } elseif(isset($fb_data['start_time'])) { //is event
@@ -349,7 +359,6 @@ class WP_Embed_FB {
349
  $width = self::$width;
350
  $height = self::$height;
351
  }
352
- $poster = self::$poster;
353
  $prop = get_option('wpemfb_proportions');
354
  ob_start();
355
  //show embed post on admin
@@ -454,7 +463,12 @@ class WP_Embed_FB {
454
  */
455
  static function shortcode($atts){
456
  if(!empty($atts) && isset($atts[0])){
457
- $url = '<p>'.trim($atts[0],'=').'</p>';
 
 
 
 
 
458
  if(isset($atts['width'])){
459
  $prop = get_option('wpemfb_proportions');
460
  self::$width = $atts['width'];
11
  static $raw = '';
12
  static $premium = '';
13
  static $num_posts = '';
 
14
  /**
15
  * Save default values to data base
16
  */
17
  static function install(){
18
  $defaults = self::getdefaults();
19
  foreach ($defaults as $option => $value) {
20
+ $opt = get_option($option);
21
  if($opt === false)
22
+ update_option($option, $value);
23
  if(!isset($type))
24
  $type = $opt==false?"activated":"reactivated";
25
  }
31
  */
32
  static function uninstall(){
33
  $defaults = self::getdefaults();
34
+ if ( is_multisite() ) {
35
+ $sites = wp_get_sites();
36
+ foreach ($sites as $site) {
37
+ switch_to_blog($site['blog_id']);
38
+ foreach ($defaults as $option ) {
39
+ delete_option($option);
40
+ }
41
+ }
42
+ restore_current_blog();
43
+ } else {
44
+ foreach ($defaults as $option ) {
45
+ delete_option($option);
46
+ }
47
+ }
48
  self::whois('uninstalled');
49
  return;
50
  }
193
 
194
  if (!empty(self::$raw)) {
195
  $raw_photo = self::$raw;
 
196
  } else {
197
  $raw_photo = get_option('wpemfb_raw_photo') == 'true' ? 'true' : 'false';
 
198
  }
199
+ //var_dump($raw_video);
200
+ //die();
201
  //is video
202
  if (isset($vars['v'])) { //is video
203
+ $fb_id = $vars['v'];
 
 
 
 
 
 
 
204
  }
205
  //photos
206
  if ('photo.php' == $last || (array_search('photos', $clean) !== false)) {
254
  $num_posts = self::$num_posts !== '' && is_numeric(self::$num_posts) ? self::$num_posts : get_option("wpemfb_max_posts");
255
  $api_string2 = '';
256
  if(isset($fb_data['embed_html']))
257
+ $fb_data = array_merge($fb_data,array('is_video' => '1','link'=>$url));
258
  elseif( isset($fb_data['category']) && get_option("wpemfb_show_posts") == "true")
259
  $api_string2 = '/'.$fb_data['id'].'?fields=posts.limit('.$num_posts.'){message,shares,link,picture,object_id,likes.limit(1).summary(true),comments.limit(1).summary(true)}';
260
 
289
  $res = '<p><a href="https://www.facebook.com/'.$url.'" target="_blank" rel="nofollow">https://www.facebook.com/'.$url.'</a>';
290
  if(is_super_admin()){
291
  $error = $e->getResult();
292
+ $res .= '<br><span style="color: #4a0e13">'.__('Error').':&nbsp;'.$error['error']['message'].'</span>';
 
 
293
  }
294
  $res .= '</p>';
295
  }
303
  */
304
  static function print_fb_data($fb_data){
305
  if(isset($fb_data['is_video'])) { //is raw video
306
+ if (!empty(self::$raw)) {
307
+ $raw_video = self::$raw;
308
+ } else {
309
+ $raw_video = get_option('wpemfb_raw_video') == 'true' ? 'true' : 'false';
310
+ }
311
+ if ($raw_video == 'true') {
312
+ $template = self::locate_template('video');
313
+ } else {
314
+ $template = self::locate_template('posts');
315
+ }
316
  } elseif(isset($fb_data['is_post'])) { //is post
317
  $template = self::locate_template('posts');
318
  } elseif(isset($fb_data['start_time'])) { //is event
359
  $width = self::$width;
360
  $height = self::$height;
361
  }
 
362
  $prop = get_option('wpemfb_proportions');
363
  ob_start();
364
  //show embed post on admin
463
  */
464
  static function shortcode($atts){
465
  if(!empty($atts) && isset($atts[0])){
466
+ $clean = trim($atts[0],'=');
467
+ if( is_numeric($clean) )
468
+ $url = '<p>https://www.facebook.com/'.$clean.'/</p>';
469
+ else
470
+ $url = '<p>'.$clean.'</p>';
471
+
472
  if(isset($atts['width'])){
473
  $prop = get_option('wpemfb_proportions');
474
  self::$width = $atts['width'];
readme.txt CHANGED
@@ -3,18 +3,18 @@ Contributors: poxtron
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R8Q85GT3Q8Q26
4
  Tags: Facebook, facebook, Social Plugins, embed facebook, facebook video, facebook posts, facebook publication, facebook publications, facebook event, facebook events, facebook pages, facebook page, facebook profiles, facebook album, facebook albums, facebook photos, facebook photo, social,
5
  Requires at least: 3.8.1
6
- Tested up to: 4.2.3
7
- Stable tag: 1.9.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Embed a Facebook video, page, event, album, photo, profile or post to any Wordpress post or page.
12
 
13
  == Description ==
14
 
15
- **[Demo](http://www.wpembedfb.com/demo/)**
16
 
17
- Embed any public facebook video, page, post, profile, photo or event directly into a wordpress post, without having to write a single line of code. Simply put the facebook url on a separate line on the content of any post, and this plugin will fetch data associated with that url and display it, if the data is not public, like “invite only” events or private profiles, will return a link.
18
 
19
  = Supported Embeds =
20
  * Facebook Videos
@@ -34,7 +34,7 @@ Embed any public facebook video, page, post, profile, photo or event directly in
34
  = How to use it =
35
  Copy the facebook url on a single line.
36
  Or you can use a shortcode `[facebook=url width=200 raw=true]`
37
- width and raw are optional, raw only works for videos and photos
38
 
39
  = Options =
40
  * Settings -> Embed Facebook.
@@ -67,7 +67,7 @@ It is possible that another plugin or your theme already has the Facebook SDK fo
67
 
68
  = Is there a way to embed an album with more than 100 photos ? =
69
 
70
- This is a facebook limitation, will try to work around it and update this feature on the premium plugin.
71
 
72
  = How to change embedded post background =
73
 
@@ -82,6 +82,14 @@ The embedded post code comes directly from facebook so there is no easy way to c
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
 
 
85
  = 1.9.6.1 =
86
  * Fixed headers already sent notice.
87
  * Added Links to Facebook Apps and plugin settings
@@ -203,5 +211,5 @@ The embedded post code comes directly from facebook so there is no easy way to c
203
 
204
  == Upgrade Notice ==
205
 
206
- = 1.9.6.1 =
207
- * Fixed headers already sent notice.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R8Q85GT3Q8Q26
4
  Tags: Facebook, facebook, Social Plugins, embed facebook, facebook video, facebook posts, facebook publication, facebook publications, facebook event, facebook events, facebook pages, facebook page, facebook profiles, facebook album, facebook albums, facebook photos, facebook photo, social,
5
  Requires at least: 3.8.1
6
+ Tested up to: 4.3
7
+ Stable tag: 1.9.6.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Embed a Facebook video, page, event, album, photo, profile or post to any WordPress post or page.
12
 
13
  == Description ==
14
 
15
+ Embed any public facebook video, page, post, profile, photo or event directly into a WordPress post, without having to write a single line of code. Simply put the facebook url on a separate line on the content of any post, and this plugin will fetch data associated with that url and display it. If the data is not public, like “invite only” events or private profiles it will return a link.
16
 
17
+ **[Demo](http://www.wpembedfb.com/demo/)**
18
 
19
  = Supported Embeds =
20
  * Facebook Videos
34
  = How to use it =
35
  Copy the facebook url on a single line.
36
  Or you can use a shortcode `[facebook=url width=200 raw=true]`
37
+ width and raw are optional, raw only works for videos and photos.
38
 
39
  = Options =
40
  * Settings -> Embed Facebook.
67
 
68
  = Is there a way to embed an album with more than 100 photos ? =
69
 
70
+ This is a facebook limitation, will try to work around it.
71
 
72
  = How to change embedded post background =
73
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.9.6.3 =
86
+ * Fixed MultiSite error
87
+ * New Shortcode use [facebook=FB_Object_ID ] solution for fb permalinks
88
+ * Fixed raw attribute on shortcode when url is video
89
+
90
+ = 1.9.6.2 =
91
+ * Local Release
92
+
93
  = 1.9.6.1 =
94
  * Fixed headers already sent notice.
95
  * Added Links to Facebook Apps and plugin settings
211
 
212
  == Upgrade Notice ==
213
 
214
+ = 1.9.6.3 =
215
+ * Fixed MultiSite error and new shortcode use [facebook=FB_Object_ID ]
templates/default/video.php CHANGED
@@ -15,7 +15,7 @@
15
  $type = end($type_array);
16
  $clean_type = strtolower($type);
17
 
18
- if( get_site_option('wpemfb_raw_video_fb') == 'false' && $clean_type == 'mp4' ) : ?>
19
  <?php $end = isset($fb_data['format']) ? end($fb_data['format']) : $fb_data; ?>
20
 
21
  <video controls poster="<?php echo $end['picture'] ?>" >
15
  $type = end($type_array);
16
  $clean_type = strtolower($type);
17
 
18
+ if( get_option('wpemfb_raw_video_fb') == 'false' && $clean_type == 'mp4' ) : ?>
19
  <?php $end = isset($fb_data['format']) ? end($fb_data['format']) : $fb_data; ?>
20
 
21
  <video controls poster="<?php echo $end['picture'] ?>" >
wp-embed-facebook.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Embed Facebook
4
  Plugin URI: http://www.wpembedfb.com
5
  Description: Embed a Facebook video, photo, album, event, page, profile, or post. Copy any facebook url to a single line on your post, or use shortcode [facebook='url' width='' ] more info at <a href="http://www.wpembedfb.com" title="plugin website">www.wpembedfb.com</a>
6
  Author: Miguel Sirvent
7
- Version: 1.9.6.1
8
  Author URI: http://profiles.wordpress.org/poxtron/
9
  */
10
 
4
  Plugin URI: http://www.wpembedfb.com
5
  Description: Embed a Facebook video, photo, album, event, page, profile, or post. Copy any facebook url to a single line on your post, or use shortcode [facebook='url' width='' ] more info at <a href="http://www.wpembedfb.com" title="plugin website">www.wpembedfb.com</a>
6
  Author: Miguel Sirvent
7
+ Version: 1.9.6.3
8
  Author URI: http://profiles.wordpress.org/poxtron/
9
  */
10