WP Embed Facebook - Version 1.2.2

Version Description

  • Bugs and documentation
Download this release

Release Info

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

Code changes from version 1.1.1 to 1.2.2

lib/admin.php CHANGED
@@ -30,6 +30,19 @@ class EmbFbAdmin{
30
  update_site_option('wpemfb_height', $prop);
31
  }
32
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  if(isset($_POST['wpemfb_enqueue_style'])){
34
  if ( !is_multisite() )
35
  update_option('wpemfb_enqueue_style', 'true');
@@ -43,16 +56,29 @@ class EmbFbAdmin{
43
  update_site_option('wpemfb_enqueue_style', 'false');
44
  }
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
-
48
  }
49
  static function embedfb_page() {
50
  //global $new_emb_fbsdk; //TODO: eliminate this test
51
  if(isset($_POST['submit'])){
52
  self::savedata();
53
  }
54
- $style = get_option('wpemfb_enqueue_style');
55
- $checked = ($style === 'true') ? 'checked' : '' ;
 
56
  ?>
57
  <div class="wrap">
58
  <h2>WP Embed Facebook</h2>
@@ -89,15 +115,27 @@ class EmbFbAdmin{
89
  <tr valign="middle">
90
  <th><?php _e('Fb Cover Embed Width','wp-embed-fb') ?></th>
91
  <td>
92
- <input type="text" name="max-width" id="max-width" class="input" value="<?php echo get_option('wpemfb_max_width') ?>" /
93
  </td>
94
  </tr>
 
 
 
 
 
 
95
  <tr valign="middle">
96
  <th><?php _e('Enqueue Styles','wp-embed-fb') ?></th>
97
  <td>
98
- <input type="checkbox" name="wpemfb_enqueue_style" <?php echo $checked ?> /><br>
99
  </td>
100
  </tr>
 
 
 
 
 
 
101
  <tr>
102
  <td>
103
  <?php //echo wp_nonce_field('wpebfb','nonce'); ?>
@@ -108,14 +146,16 @@ class EmbFbAdmin{
108
  </table>
109
  </form
110
  <ul class="">
 
111
  <li>
112
  <a href="http://www.saliuitl.org/wp-embed-fb/customize"><?php _e('Customize','wp-embed-fb') ?></a>
113
  </li>
114
  <li>
115
  <a href="http://www.saliuitl.org/wp-embed-fb/support"><?php _e('Support','wp-embed-fb') ?></a>
116
- </li>
 
117
  <li>
118
- <a href="http://www.saliuitl.org/wp-embed-fb"><?php _e('Plugin Web Site','wp-embed-fb') ?></a>
119
  </li>
120
  </ul>
121
  </div>
@@ -125,10 +165,7 @@ class EmbFbAdmin{
125
  <div class="welcome-panel-column welcome-panel-last">
126
  <h3 style="color:red;"><?php _e('Donate!', 'wp-embed-fb') ?></h3>
127
  <p><?php _e('Help me keep this plugin up to date', 'wp-embed-fb') ?></p>
128
- <p>
129
- <strong><?php _e('Click the taco !', 'wp-embed-fb') ?></strong><br>
130
- <small><?php _e('3 USD Minimun Suggested Donation', 'wp-embed-fb') ?></small>
131
- </p>
132
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
133
  <input type="hidden" name="cmd" value="_s-xclick">
134
  <input type="hidden" name="hosted_button_id" value="9TEJ8CGXMJEDG">
30
  update_site_option('wpemfb_height', $prop);
31
  }
32
  }
33
+ if(isset($_POST['wpemfb_show_like'])){
34
+ if ( !is_multisite() )
35
+ update_option('wpemfb_show_like', 'true');
36
+ else // TODO: multiple fb apps for each site
37
+ update_site_option('wpemfb_show_like', 'true');
38
+ }else{
39
+ if ( !is_multisite() ) {
40
+ update_option('wpemfb_show_like', 'false');
41
+ }
42
+ else { // TODO: multiple fb apps for each site
43
+ update_site_option('wpemfb_show_like', 'false');
44
+ }
45
+ }
46
  if(isset($_POST['wpemfb_enqueue_style'])){
47
  if ( !is_multisite() )
48
  update_option('wpemfb_enqueue_style', 'true');
56
  update_site_option('wpemfb_enqueue_style', 'false');
57
  }
58
  }
59
+ if(isset($_POST['wpemfb_fb_root'])){
60
+ if ( !is_multisite() )
61
+ update_option('wpemfb_fb_root', 'true');
62
+ else // TODO: multiple fb apps for each site
63
+ update_site_option('wpemfb_fb_root', 'true');
64
+ }else{
65
+ if ( !is_multisite() ) {
66
+ update_option('wpemfb_fb_root', 'false');
67
+ }
68
+ else { // TODO: multiple fb apps for each site
69
+ update_site_option('wpemfb_fb_root', 'false');
70
+ }
71
+ }
72
  }
 
73
  }
74
  static function embedfb_page() {
75
  //global $new_emb_fbsdk; //TODO: eliminate this test
76
  if(isset($_POST['submit'])){
77
  self::savedata();
78
  }
79
+ $checked = (get_option('wpemfb_enqueue_style') === 'true') ? 'checked' : '' ;
80
+ $checked2 = (get_option('wpemfb_show_like') === 'true') ? 'checked' : '' ;
81
+ $checked3 = (get_option('wpemfb_fb_root') === 'true') ? 'checked' : '' ;
82
  ?>
83
  <div class="wrap">
84
  <h2>WP Embed Facebook</h2>
115
  <tr valign="middle">
116
  <th><?php _e('Fb Cover Embed Width','wp-embed-fb') ?></th>
117
  <td>
118
+ <input type="text" name="max-width" id="max-width" class="input" value="<?php echo get_option('wpemfb_max_width') ?>" />
119
  </td>
120
  </tr>
121
+ <tr valign="middle">
122
+ <th><?php _e('Add like button to pages','wp-embed-fb') ?></th>
123
+ <td>
124
+ <input type="checkbox" name="wpemfb_show_like" <?php echo $checked2 ?> />
125
+ </td>
126
+ </tr>
127
  <tr valign="middle">
128
  <th><?php _e('Enqueue Styles','wp-embed-fb') ?></th>
129
  <td>
130
+ <input type="checkbox" name="wpemfb_enqueue_style" <?php echo $checked ?> />
131
  </td>
132
  </tr>
133
+ <tr valign="middle">
134
+ <th><?php _e('Add fb-root and javascript on top of content','wp-embed-fb') ?><br><small><?php _e('Some themes may not need this','wp-embed-fb') ?></small></th>
135
+ <td>
136
+ <input type="checkbox" name="wpemfb_fb_root" <?php echo $checked3 ?> />
137
+ </td>
138
+ </tr>
139
  <tr>
140
  <td>
141
  <?php //echo wp_nonce_field('wpebfb','nonce'); ?>
146
  </table>
147
  </form
148
  <ul class="">
149
+ <!--
150
  <li>
151
  <a href="http://www.saliuitl.org/wp-embed-fb/customize"><?php _e('Customize','wp-embed-fb') ?></a>
152
  </li>
153
  <li>
154
  <a href="http://www.saliuitl.org/wp-embed-fb/support"><?php _e('Support','wp-embed-fb') ?></a>
155
+ </li>
156
+ -->
157
  <li>
158
+ <a href="http://www.saliuitl.org/en/wp-embed-facebook"><?php _e('Plugin Web Site','wp-embed-fb') ?></a>
159
  </li>
160
  </ul>
161
  </div>
165
  <div class="welcome-panel-column welcome-panel-last">
166
  <h3 style="color:red;"><?php _e('Donate!', 'wp-embed-fb') ?></h3>
167
  <p><?php _e('Help me keep this plugin up to date', 'wp-embed-fb') ?></p>
168
+ <p><strong><?php _e('Click the taco !', 'wp-embed-fb') ?></strong></p>
 
 
 
169
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
170
  <input type="hidden" name="cmd" value="_s-xclick">
171
  <input type="hidden" name="hosted_button_id" value="9TEJ8CGXMJEDG">
lib/core.php CHANGED
@@ -1,7 +1,13 @@
1
  <?php
 
 
 
2
  class WP_Embed_FB {
3
  static $fbsdk;
4
  protected static $_values = array();
 
 
 
5
  static function install(){
6
  $defaults = self::getdefaults();
7
  foreach ($defaults as $option => $value) {
@@ -10,7 +16,7 @@ class WP_Embed_FB {
10
  if($opt === false)
11
  update_option($option, $value);
12
  }
13
- else { // TODO: multiple fb apps for each site
14
  $opt = get_option($option);
15
  if($opt === false)
16
  update_site_option($option, $value);
@@ -18,6 +24,9 @@ class WP_Embed_FB {
18
  }
19
  return;
20
  }
 
 
 
21
  static function uninstall(){
22
  $defaults = self::getdefaults();
23
  foreach ($defaults as $option ) {
@@ -29,35 +38,89 @@ class WP_Embed_FB {
29
  }
30
  }
31
  return;
32
- }
 
 
 
33
  static function getdefaults(){
34
  return array(
35
  'wpemfb_max_width' => '600',
36
  'wpemfb_enqueue_style' => 'true',
37
- //TODO: Quitar esto ponerlo en 0
38
  'wpemfb_app_id' => '0',
39
  'wpemfb_app_secret' => '0',
40
  'wpemfb_proportions' => 0.36867,
41
  'wpemfb_height' => '221.202',
 
 
42
  );
43
  }
 
 
 
 
 
 
 
 
 
 
44
  static function wp_enqueue_scripts(){
45
-
46
- wp_register_style( 'wpemfb-style', plugins_url('../templates/default/wpemfb.css', __FILE__) );
47
  wp_enqueue_style( 'wpemfb-style' );
48
  }
 
 
 
49
  static function the_content($the_content){
50
  preg_match_all("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", $the_content, $matches, PREG_SET_ORDER);
51
  if(!empty($matches) && is_array($matches)){
52
  self::$fbsdk = FaceInit::$fbsdk;
53
- if(self::$fbsdk !== 'unactive')
54
- foreach($matches as $match) {
55
  $the_content = preg_replace("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", self::fb_embed($match), $the_content, 1);
56
- }
 
 
 
 
 
 
 
 
57
  }
58
-
59
  return $the_content;
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  static function fb_embed($match){ //TODO: photos!
62
  $vars = array();
63
  parse_str(parse_url($match[2], PHP_URL_QUERY), $vars);
@@ -66,33 +129,44 @@ class WP_Embed_FB {
66
  } else {
67
  $url = explode('?', $match[2]);
68
  $clean = explode('/', $url[0]);
69
- $last = end($clean);
70
- if( empty( $last ) )
71
- $fb_id = $clean[count($clean)-2];//penultimo valor
72
- else
73
- $fb_id = $last;
 
 
 
 
 
 
74
  }
75
- //do_action('') TODO: extend
76
- //echo $fb_id.'<br>';
77
- $res = self::fb_api_get($fb_id);
78
- return $res;
79
  }
80
- static function fb_api_get($fb_id){
 
 
 
81
  $wp_emb_fbsdk = self::$fbsdk;
82
  try {
83
  $fb_data = $wp_emb_fbsdk->api('/'.$fb_id);
84
  //$res = '<pre>'.print_r($fb_data,true).'</pre>'; //to inspect what elements are queried by default
85
  $res = self::print_fb_data($fb_data);
86
  } catch(FacebookApiException $e) {
87
- $res = '<p><a href="http://wwww.facebook.com/'.$match[2].'" target="_blank" rel="nofollow">http://wwww.facebook.com/'.$match[2].'</a>';
88
- if(is_super_admin()){
89
- $res .= '<span style="color: red">'.__('This facebook link is not public', 'wp-embed-fb').'</span></p>';
90
- //$res .= print_r($e->getResult(),true); //see the problem here
91
- }
 
 
92
 
93
  }
94
  return $res;
95
  }
 
 
 
96
  static function print_fb_data($fb_data){
97
  $width = get_option('wpemfb_max_width');
98
  $height = get_option('wpemfb_height');
@@ -113,20 +187,33 @@ class WP_Embed_FB {
113
  break;
114
  }
115
  }
116
- } else { //is profile
 
 
 
 
117
  $template = self::locate_template('profile');
118
  }
119
  ob_start();
120
  include($template);
121
  return ob_get_clean();
122
  }
 
 
 
123
  static function locate_template($template_name){
124
- $located = locate_template(array('plugins/wp-embed-fb/'.$template_name.'.php'));
125
  if( empty($located) ){
126
  $located = plugin_dir_path( __FILE__ ).'../templates/default/'.$template_name.'.php';
127
  }
128
  return $located;
129
  }
 
 
 
 
 
 
130
  static function getwebsite($urls){
131
  $url = explode(' ',$urls);
132
  $clean = explode('?', $url[0]);
@@ -134,6 +221,9 @@ class WP_Embed_FB {
134
  $ret = '<a href="http://'.$cleaner.'" title="'.__('Web Site', 'wp-embed-fb').'" target="_blank">'.__('Web Site','wp-embed-fb').'</a>';
135
  return $ret;
136
  }
 
 
 
137
  static function fb_categories($category){
138
  $fbcats = array(
139
  __('Museum/art gallery') ,
@@ -143,13 +233,17 @@ class WP_Embed_FB {
143
  );
144
  //$catsflip = array_flip($fbcats); TODO: Translate categories
145
  if($id = array_search($category, $fbcats) !== false)
146
- return $fbcats[$id];
147
  else
148
- return (string)$category;
 
149
  //$replace = array('Museo - Galería de Arte','Negocio Local','Sala de Conciertos','Espacio público');
150
  }
151
  }
152
-
 
 
 
153
  class FaceInit {
154
  static $fbsdk;
155
  static function init(){
1
  <?php
2
+ /*
3
+ * Main Class of the plugin.
4
+ */
5
  class WP_Embed_FB {
6
  static $fbsdk;
7
  protected static $_values = array();
8
+ /*
9
+ * Save default values to data base
10
+ */
11
  static function install(){
12
  $defaults = self::getdefaults();
13
  foreach ($defaults as $option => $value) {
16
  if($opt === false)
17
  update_option($option, $value);
18
  }
19
+ else { // TODO: multiple fb apps for each site probably not needed for public data
20
  $opt = get_option($option);
21
  if($opt === false)
22
  update_site_option($option, $value);
24
  }
25
  return;
26
  }
27
+ /*
28
+ * Delete all plugin options on uninstall
29
+ */
30
  static function uninstall(){
31
  $defaults = self::getdefaults();
32
  foreach ($defaults as $option ) {
38
  }
39
  }
40
  return;
41
+ }
42
+ /*
43
+ * Default options
44
+ */
45
  static function getdefaults(){
46
  return array(
47
  'wpemfb_max_width' => '600',
48
  'wpemfb_enqueue_style' => 'true',
 
49
  'wpemfb_app_id' => '0',
50
  'wpemfb_app_secret' => '0',
51
  'wpemfb_proportions' => 0.36867,
52
  'wpemfb_height' => '221.202',
53
+ 'wpemfb_show_like' => 'true',
54
+ 'wpemfb_fb_root' => 'true',
55
  );
56
  }
57
+ /*
58
+ * load translations and facebook sdk
59
+ */
60
+ static function init(){
61
+ load_plugin_textdomain( 'wp-embed-fb', '', WPEMFBLIB.'/lang' );
62
+ FaceInit::init();
63
+ }
64
+ /*
65
+ * Enqueue wp embed facebook styles
66
+ */
67
  static function wp_enqueue_scripts(){
68
+ wp_register_style( 'wpemfb-style', plugins_url('/wp-embed-facebook/templates/default/wpemfb.css'));
 
69
  wp_enqueue_style( 'wpemfb-style' );
70
  }
71
+ /*
72
+ * the_content filter to process fb url's
73
+ */
74
  static function the_content($the_content){
75
  preg_match_all("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", $the_content, $matches, PREG_SET_ORDER);
76
  if(!empty($matches) && is_array($matches)){
77
  self::$fbsdk = FaceInit::$fbsdk;
78
+ if(self::$fbsdk !== 'unactive'){
79
+ foreach($matches as $match) {
80
  $the_content = preg_replace("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", self::fb_embed($match), $the_content, 1);
81
+ }
82
+ $opt = get_option('wpemfb_fb_root');
83
+ if($opt === 'true'){
84
+ return self::fb_scripts().$the_content;
85
+ } else {
86
+ return $the_content;
87
+ }
88
+ }
89
+
90
  }
 
91
  return $the_content;
92
  }
93
+ /*
94
+ * facebook scripts required to show like buttons and posts
95
+ */
96
+ static function fb_scripts(){
97
+ ob_start();
98
+ ?>
99
+ <div id="fb-root"></div>
100
+ <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
101
+ <?php
102
+ return ob_get_clean();
103
+ }
104
+ /*
105
+ * show like buttons or like count
106
+ */
107
+ static function like_btn($fb_id,$likes=null){
108
+ $opt = get_option('wpemfb_show_like');
109
+ if($opt === 'true') :
110
+ ob_start();
111
+ ?>
112
+ <div class="fb-like" data-href="https://facebook.com/<?php echo $fb_id ?>" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>
113
+ <?php
114
+ ob_end_flush();
115
+ return;
116
+ else :
117
+ printf( __( '%d people like this.', 'wp-embed-fb' ), $likes );
118
+ return;
119
+ endif;
120
+ }
121
+ /*
122
+ * Extracto fb id from the url
123
+ */
124
  static function fb_embed($match){ //TODO: photos!
125
  $vars = array();
126
  parse_str(parse_url($match[2], PHP_URL_QUERY), $vars);
129
  } else {
130
  $url = explode('?', $match[2]);
131
  $clean = explode('/', $url[0]);
132
+ $end = end($clean);
133
+ if(empty($end)){
134
+ array_pop($clean);
135
+ }
136
+ $fb_id = end($clean);
137
+ if( $key = array_search('posts',$clean) !== false ){
138
+ $user = $clean[$key -1];
139
+ $post = $clean[$key +1];
140
+ $fb_data = array('user' => $user ,'is_post' => $post);
141
+ return self::print_fb_data($fb_data);
142
+ }
143
  }
144
+ return self::fb_api_get($fb_id, $match[2]);
 
 
 
145
  }
146
+ /*
147
+ * get data from fb
148
+ */
149
+ static function fb_api_get($fb_id, $url){
150
  $wp_emb_fbsdk = self::$fbsdk;
151
  try {
152
  $fb_data = $wp_emb_fbsdk->api('/'.$fb_id);
153
  //$res = '<pre>'.print_r($fb_data,true).'</pre>'; //to inspect what elements are queried by default
154
  $res = self::print_fb_data($fb_data);
155
  } catch(FacebookApiException $e) {
156
+ $res = '<p><a href="http://wwww.facebook.com/'.$url.'" target="_blank" rel="nofollow">http://wwww.facebook.com/'.$url.'</a>';
157
+ //uncoment this lines to debug
158
+ //if(is_super_admin()){
159
+ //$res .= '<span style="color: red">'.__('This facebook link is not public', 'wp-embed-fb').'</span></p>';
160
+ //$res .= print_r($e->getResult(),true);
161
+ //$res .= 'fb_id'.$fb_id;
162
+ //}
163
 
164
  }
165
  return $res;
166
  }
167
+ /*
168
+ * find out what kind of data we got from facebook
169
+ */
170
  static function print_fb_data($fb_data){
171
  $width = get_option('wpemfb_max_width');
172
  $height = get_option('wpemfb_height');
187
  break;
188
  }
189
  }
190
+ } elseif(isset($fb_data['is_post'])) {
191
+ $template = self::locate_template('posts');
192
+ } elseif(isset($fb_data['width'])) {
193
+ $template = self::locate_template('photo');
194
+ }else { //is profile
195
  $template = self::locate_template('profile');
196
  }
197
  ob_start();
198
  include($template);
199
  return ob_get_clean();
200
  }
201
+ /*
202
+ * locate the proper template to show the embed
203
+ */
204
  static function locate_template($template_name){
205
+ $located = locate_template(array('plugins/wp-embed-facebook/'.$template_name.'.php'));
206
  if( empty($located) ){
207
  $located = plugin_dir_path( __FILE__ ).'../templates/default/'.$template_name.'.php';
208
  }
209
  return $located;
210
  }
211
+ /*
212
+ * Formatting functions.
213
+ */
214
+ /*
215
+ * If a user has a lot of websites registered on fb this function will only link to the first one
216
+ */
217
  static function getwebsite($urls){
218
  $url = explode(' ',$urls);
219
  $clean = explode('?', $url[0]);
221
  $ret = '<a href="http://'.$cleaner.'" title="'.__('Web Site', 'wp-embed-fb').'" target="_blank">'.__('Web Site','wp-embed-fb').'</a>';
222
  return $ret;
223
  }
224
+ /*
225
+ * Translate fb categories to current locale
226
+ */
227
  static function fb_categories($category){
228
  $fbcats = array(
229
  __('Museum/art gallery') ,
233
  );
234
  //$catsflip = array_flip($fbcats); TODO: Translate categories
235
  if($id = array_search($category, $fbcats) !== false)
236
+ echo $fbcats[$id];
237
  else
238
+ echo (string)$category;
239
+ return;
240
  //$replace = array('Museo - Galería de Arte','Negocio Local','Sala de Conciertos','Espacio público');
241
  }
242
  }
243
+ /*
244
+ * Trigering the FaceInit::init(); will give you access to the fb php sdk on FaceInit::$fbsdk which you can use to make any call shown here
245
+ * https://developers.facebook.com/docs/reference/php/
246
+ */
247
  class FaceInit {
248
  static $fbsdk;
249
  static function init(){
readme.txt CHANGED
@@ -1,58 +1,69 @@
1
  === WP Embed Facebook ===
2
  Contributors: poxtron
3
- Donate link: http://www.saliuitl.org/en/wp-embed-facebook
4
- Tags: facebook, embed, open graph, fbsdk, Facebook events,
5
  Requires at least: 3.0.1
6
  Tested up to: 3.8.1
7
- Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Embed a Facebook page, post, event, photo or profile to any WP post or page.
12
 
13
  == Description ==
14
 
15
- This plugin embeds public the content of a Facebook page directly into a wordpress post.
16
 
17
  = Supported Embeds =
18
- * Public Posts
19
- * Public Photos
20
- * Public Events
21
  * Fan pages
22
  * Community pages
23
- * Public Profiles
 
 
24
 
25
  = Requirements =
26
  * Facebook App id and Secret
27
 
 
 
 
28
  = Options =
29
  In Settings > Embed Facebook.
30
 
31
  * Change embed width
32
  * Show like buttons on embedded Facebook pages and photos
33
-
34
- = How to use it =
35
- Put on a single and separate line the Facebook link.
36
 
37
  **[Demo](http://saliuitl.org/en/wp-embed-facebook)**
38
 
39
- = Notes =
40
- * The information that is shown on your post if from facebook directly, no images or data are stored on your server.
41
- * You can not embed data that is not public like “invite only” events, or private profiles.
42
- * To customise de the look of the embeds copy the contents of wp-embed-facebook/templates/default/ to your-theme/plugins/wp-embed-facebook
43
 
44
  = On the next version =
45
  * Templates
 
46
  == Installation ==
47
 
48
  1. Download wp embed facebook plugin from [Wordpress](http://wordpress.org/plugins/wp-embed-facebook)
49
- 1. Create a [facebook app](https://developers.facebook.com/apps) and configure for your domain.
50
- 1. Copy the app id and app secret to the “Embed Facebook” page under the Setting section.
51
- 1. Put a single
52
- 1. Enjoy !
 
 
 
 
 
 
 
 
53
 
54
  == Changelog ==
55
 
 
 
 
56
  = 1.2.1 =
57
  * Updated Instructions
58
  * Change theme template directory
1
  === WP Embed Facebook ===
2
  Contributors: poxtron
3
+ Donate link: http://www.saliuitl.org/en/wp-embed-facebook/donate
4
+ Tags: facebook, embed, opengraph, fbsdk, facebook events, facebook pages, facebook profiles,
5
  Requires at least: 3.0.1
6
  Tested up to: 3.8.1
7
+ Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Embed a Facebook page, post, event, photo or profile to any Wordpress post or page.
12
 
13
  == Description ==
14
 
15
+ With this plugin you can embed any public facebook 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 try to fetch data associated with that url and display it on publishing, if the data is not public, like “invite only” events or private profiles, it'll return a link.
16
 
17
  = Supported Embeds =
18
+ * Events
 
 
19
  * Fan pages
20
  * Community pages
21
+ * Profiles
22
+ * Posts
23
+ * Photos
24
 
25
  = Requirements =
26
  * Facebook App id and Secret
27
 
28
+ = How to use it =
29
+ Put on a single and separate line the Facebook URL.
30
+
31
  = Options =
32
  In Settings > Embed Facebook.
33
 
34
  * Change embed width
35
  * Show like buttons on embedded Facebook pages and photos
36
+ * Remove plugin styles
37
+ * Add fb-root
 
38
 
39
  **[Demo](http://saliuitl.org/en/wp-embed-facebook)**
40
 
41
+ * The information that shown on your post, is from facebook directly, no images or data are stored on your server.
 
 
 
42
 
43
  = On the next version =
44
  * Templates
45
+
46
  == Installation ==
47
 
48
  1. Download wp embed facebook plugin from [Wordpress](http://wordpress.org/plugins/wp-embed-facebook)
49
+ 1. Extract to /wp-content/plugins/ folder, and activate the plugin in /wp-admin/.
50
+ 1. Create a [facebook app](https://developers.facebook.com/apps).
51
+ 1. Copy the app id and app secret to the “Embed Facebook” page under the Settings section.
52
+ 1. Copy on a single line any facebook url.
53
+ 1. Enjoy and tell someone !
54
+
55
+ == Customisation ==
56
+
57
+ 1. Copy the contents of `wp-embed-facebook/templates/default/` to `your-theme/plugins/wp-embed-facebook`
58
+ 1. Untick "Enqueue Styles" option to use your own css.
59
+ 1. Access all facebook data retrieved from the url using `print_r($fb_data)` on any template file.
60
+ 1. Click the taco ! ;)
61
 
62
  == Changelog ==
63
 
64
+ = 1.2.2 =
65
+ * Bugs and documentation
66
+
67
  = 1.2.1 =
68
  * Updated Instructions
69
  * Change theme template directory
templates/default/band.php CHANGED
@@ -26,7 +26,7 @@
26
  </a>
27
  </h4>
28
  <?php echo isset($fb_data['genre']) ? $fb_data['genre'].'<br>' : '' ?>
29
- <?php printf( __( '%d people like this.', 'wp-embed-fb' ), $fb_data['likes'] ); ?><br>
30
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
31
  </div>
32
  </div>
26
  </a>
27
  </h4>
28
  <?php echo isset($fb_data['genre']) ? $fb_data['genre'].'<br>' : '' ?>
29
+ <?php WP_Embed_FB::like_btn($fb_data['id'],$fb_data['likes']) ?><br>
30
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
31
  </div>
32
  </div>
templates/default/com-page.php CHANGED
@@ -17,7 +17,7 @@
17
  <?php echo $fb_data['name'] ?>
18
  </a>
19
  </h4>
20
- <?php printf( __( '%d people like this.', 'wp-embed-fb' ), $fb_data['likes'] ); ?><br>
21
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
22
  </div>
23
  </div>
17
  <?php echo $fb_data['name'] ?>
18
  </a>
19
  </h4>
20
+ <?php WP_Embed_FB::like_btn($fb_data['id'],$fb_data['likes']) ?><br>
21
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
22
  </div>
23
  </div>
templates/default/other.php CHANGED
@@ -29,8 +29,8 @@
29
  <?php echo $fb_data['name'] ?>
30
  </a>
31
  </h4>
32
- <?php echo WP_Embed_FB::fb_categories($fb_data['category']) ?><br>
33
- <?php printf( __( '%d people like this.', 'wp-embed-fb' ), $fb_data['likes'] ); ?><br>
34
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
35
  </div>
36
  </div>
29
  <?php echo $fb_data['name'] ?>
30
  </a>
31
  </h4>
32
+ <?php WP_Embed_FB::fb_categories($fb_data['category']) ?><br>
33
+ <?php WP_Embed_FB::like_btn($fb_data['id'],$fb_data['likes']) ?><br>
34
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
35
  </div>
36
  </div>
templates/default/photo.php CHANGED
@@ -1,2 +1,29 @@
1
-
2
- <pre><?php print_r($fb_data) ?></pre>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * You can create your own template by placing a copy of this file on yourtheme/plugins/wp-embed-fb/
4
+ * to access all fb data print_r($fb_data)
5
+ */
6
+ ?>
7
+ <div class="wpemfb-container">
8
+ <div class="wpemfb-info">
9
+ <div class="wpemfb-pic">
10
+ <img src="http://graph.facebook.com/<?php echo $fb_data['from']['id'] ?>/picture" />
11
+ </a>
12
+ </div>
13
+ <div class="wpemfb-desc">
14
+ <h4 class="wpemfb-title" >
15
+ <a href="https://facebook.com/<?php echo $fb_data['from']['id'] ?>" target="_blank" rel="nofollow">
16
+ <?php echo $fb_data['from']['name'] ?>
17
+ </a>
18
+ </h4>
19
+ <?php if(isset($fb_data['from']['category'])) : ?>
20
+ <?php WP_Embed_FB::fb_categories($fb_data['from']['category']) ?><br>
21
+ <?php endif; ?>
22
+ <?php WP_Embed_FB::like_btn($fb_data['id']) ?><br>
23
+ </div>
24
+ </div>
25
+ <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
26
+ <img src="<?php echo $fb_data['source'] ?>" width="<?php echo $width ?>" height="auto" />
27
+ </a>
28
+ </div>
29
+ </div>
templates/default/posts.php ADDED
@@ -0,0 +1 @@
 
1
+ <div class="fb-post" data-href="https://www.facebook.com/poxtron/posts/10153452851830203" data-width="<?php echo $width ?>">
wp-embed-fb.php CHANGED
@@ -1,33 +1,32 @@
1
  <?php
2
  /**
3
- * @package WP_Embed_FB
4
- * @version 1.0
5
  */
6
  /*
7
  Plugin Name: WP Embed Facebook
8
- Plugin URI: http://www.saliuitl.org/wp-embed-facebook/
9
- Description: This plugin transforms facebook links into graphic content.
10
  Author: Miguel Sirvent
11
- Version: 1.1.1
12
- Author URI: http://www.facebook.com/poxtron
13
  */
14
 
15
- add_action('init','wpemfblang');
16
- function wpemfblang(){
17
- load_plugin_textdomain( 'wp-embed-fb', '', basename( dirname( __FILE__ ) ) . '/lang' );
18
- }
19
-
20
- define('WPEMFBLIB',dirname( __FILE__ ) . '/lib/');
21
-
22
  require_once WPEMFBLIB.'core.php';
23
 
 
 
 
24
  register_activation_hook( __FILE__, array('WP_Embed_FB', 'install') );
25
- //register_uninstall_hook( __FILE__, array('WP_Embed_FB', 'uninstall') );
26
- register_deactivation_hook( __FILE__, array('WP_Embed_FB', 'uninstall'));
27
- add_action('init',array('FaceInit','init'));
28
-
29
  add_action( 'wp_enqueue_scripts', array('WP_Embed_FB', 'wp_enqueue_scripts') );
30
-
31
  add_filter('the_content', array('WP_Embed_FB','the_content'),10,1);
32
 
33
  if(is_admin()){
1
  <?php
2
  /**
3
+ * @package WP_Embed_Facebook
4
+ * @version 1.2.2
5
  */
6
  /*
7
  Plugin Name: WP Embed Facebook
8
+ Plugin URI: http://www.saliuitl.org/en/wp-embed-facebook/
9
+ Description: Embed a Facebook page, post, event, photo or profile to any Wordpress post or page. Copy any fb url to a single line on your post.
10
  Author: Miguel Sirvent
11
+ Version: 1.2.2
12
+ Author URI: http://www.saliuitl.org/
13
  */
14
 
15
+ /*
16
+ * Global definitions and core include.
17
+ */
18
+ load_plugin_textdomain( 'wp-embed-fb', '', WPEMFBLIB.'/lang' );
19
+ define('WPEMFDIR',dirname( __FILE__));
20
+ define('WPEMFBLIB',WPEMFDIR.'/lib/');
 
21
  require_once WPEMFBLIB.'core.php';
22
 
23
+ /*
24
+ * All actions, filters and hooks.
25
+ */
26
  register_activation_hook( __FILE__, array('WP_Embed_FB', 'install') );
27
+ register_uninstall_hook( __FILE__, array('WP_Embed_FB', 'uninstall') );
28
+ add_action('init',array('WP_Embed_FB','init'));
 
 
29
  add_action( 'wp_enqueue_scripts', array('WP_Embed_FB', 'wp_enqueue_scripts') );
 
30
  add_filter('the_content', array('WP_Embed_FB','the_content'),10,1);
31
 
32
  if(is_admin()){