WP Embed Facebook - Version 1.3

Version Description

  • Shortcode [facebook=url ] width is optional
  • Themes
  • Multilingual Like Buttons
Download this release

Release Info

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

Code changes from version 1.2.3 to 1.3

lib/admin.php CHANGED
@@ -4,55 +4,57 @@ class EmbFbAdmin{
4
  add_options_page('EmbedFacebook', 'Embed Facebook', 'manage_options', 'embedfacebook', array('EmbFbAdmin', 'embedfb_page'));
5
  }
6
  static function savedata(){
7
- //if ( !empty($_POST) && check_admin_referer('wp-embed-fb','nonce') )
8
- if(isset($_POST['appsecret'], $_POST['appid' ] )) {
9
- $wpemfb_width = get_option('wpemfb_max_width');
10
- $proportions = get_option('wpemfb_proportions');
11
-
12
- if($_POST['appid'] && $_POST['appsecret']){
13
  if ( !is_multisite() ) {
14
- update_option('wpemfb_app_id',$_POST['appid']);
15
- update_option('wpemfb_app_secret',$_POST['appsecret']);
16
  }
17
- else { // TODO: multiple fb apps for each site
18
- update_site_option('wpemfb_app_id',$_POST['appid']);
19
- update_site_option('wpemfb_app_secret',$_POST['appsecret']);
20
  }
21
  }
22
- if(isset($_POST['max-width'])){
23
- $prop = get_option('wpemfb_proportions') * $_POST['max-width'];
24
  if ( !is_multisite() ) {
25
- update_option('wpemfb_max_width', $_POST['max-width']);
26
  update_option('wpemfb_height', $prop );
27
  }
28
- else { // TODO: multiple fb apps for each site
29
- update_site_option('wpemfb_max_width', $_POST['max-width']);
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');
49
- else // TODO: multiple fb apps for each site
50
  update_site_option('wpemfb_enqueue_style', 'true');
51
  }else{
52
  if ( !is_multisite() ) {
53
  update_option('wpemfb_enqueue_style', 'false');
54
  }
55
- else { // TODO: multiple fb apps for each site
56
  update_site_option('wpemfb_enqueue_style', 'false');
57
  }
58
  }
@@ -72,13 +74,14 @@ class EmbFbAdmin{
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>
@@ -88,6 +91,7 @@ class EmbFbAdmin{
88
  <div class="welcome-panel-column">
89
  <form id="config-form" action="#" method="post">
90
  <table class="form-table">
 
91
  <tbody>
92
  <tr>
93
  <h3><?php _e('Facebook application data', 'wp-embed-fb') ?></h3>
@@ -95,27 +99,33 @@ class EmbFbAdmin{
95
  <tr valign="middle">
96
  <th>App ID</th>
97
  <td>
98
- <input type="text" name="appid" id="appid" class="input" required="" value="<?php echo get_option('wpemfb_app_id') ?>" />
99
  </td>
100
  </tr>
101
  <tr valign="middle">
102
  <th>App Secret</th>
103
  <td>
104
- <input type="text" name="appsecret" id="appsecret" class="input" required="" value="<?php echo get_option('wpemfb_app_secret') ?>" />
105
  </td>
106
  </tr>
 
 
 
 
 
 
 
 
 
107
  <tr>
108
  <th>
109
- <td>
110
  <h4><?php _e("Other Options", 'wp-embed-fb') ?></h4>
111
- </td>
112
-
113
  </th>
114
  </tr>
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">
@@ -139,7 +149,7 @@ class EmbFbAdmin{
139
  <tr>
140
  <td>
141
  <?php //echo wp_nonce_field('wpebfb','nonce'); ?>
142
- <input type="submit" name="submit" id="save-config" class="button button-primary button-hero" value="<?php _e('Save','wp-embed-fb') ?>" />
143
  </td>
144
  </tr>
145
  </tbody>
4
  add_options_page('EmbedFacebook', 'Embed Facebook', 'manage_options', 'embedfacebook', array('EmbFbAdmin', 'embedfb_page'));
5
  }
6
  static function savedata(){
7
+ if(isset($_POST['wpemfb_app_secret'], $_POST['wpemfb_app_id' ] )) {
8
+ if($_POST['wpemfb_app_id'] && $_POST['wpemfb_app_secret']){
 
 
 
 
9
  if ( !is_multisite() ) {
10
+ update_option('wpemfb_app_id',$_POST['wpemfb_app_id']);
11
+ update_option('wpemfb_app_secret',$_POST['wpemfb_app_secret']);
12
  }
13
+ else {
14
+ update_site_option('wpemfb_app_id',$_POST['wpemfb_app_id']);
15
+ update_site_option('wpemfb_app_secret',$_POST['wpemfb_app_secret']);
16
  }
17
  }
18
+ if(isset($_POST['wpemfb_max_width'])){
19
+ $prop = get_option('wpemfb_proportions') * $_POST['wpemfb_max_width'];
20
  if ( !is_multisite() ) {
21
+ update_option('wpemfb_max_width', $_POST['wpemfb_max_width']);
22
  update_option('wpemfb_height', $prop );
23
  }
24
+ else {
25
+ update_site_option('wpemfb_max_width', $_POST['wpemfb_max_width']);
26
  update_site_option('wpemfb_height', $prop);
27
  }
28
  }
29
+ if(isset($_POST['wpemfb_theme'])){
30
+ if ( !is_multisite() )
31
+ update_option('wpemfb_theme', $_POST['wpemfb_theme']);
32
+ else
33
+ update_site_option('wpemfb_theme', $_POST['wpemfb_theme']);
34
+ }
35
  if(isset($_POST['wpemfb_show_like'])){
36
  if ( !is_multisite() )
37
  update_option('wpemfb_show_like', 'true');
38
+ else
39
  update_site_option('wpemfb_show_like', 'true');
40
  }else{
41
  if ( !is_multisite() ) {
42
  update_option('wpemfb_show_like', 'false');
43
  }
44
+ else {
45
  update_site_option('wpemfb_show_like', 'false');
46
  }
47
  }
48
  if(isset($_POST['wpemfb_enqueue_style'])){
49
  if ( !is_multisite() )
50
  update_option('wpemfb_enqueue_style', 'true');
51
+ else
52
  update_site_option('wpemfb_enqueue_style', 'true');
53
  }else{
54
  if ( !is_multisite() ) {
55
  update_option('wpemfb_enqueue_style', 'false');
56
  }
57
+ else {
58
  update_site_option('wpemfb_enqueue_style', 'false');
59
  }
60
  }
74
  }
75
  }
76
  static function embedfb_page() {
77
+ if(isset($_POST['submit']) && check_admin_referer( 'wp-embed-fb','save-data' )){
 
78
  self::savedata();
79
  }
80
  $checked = (get_option('wpemfb_enqueue_style') === 'true') ? 'checked' : '' ;
81
  $checked2 = (get_option('wpemfb_show_like') === 'true') ? 'checked' : '' ;
82
  $checked3 = (get_option('wpemfb_fb_root') === 'true') ? 'checked' : '' ;
83
+ $sel1 = (get_option('wpemfb_theme') === 'default') ? 'selected' : '' ;
84
+ $sel2 = (get_option('wpemfb_theme') === 'classic') ? 'selected' : '' ;
85
  ?>
86
  <div class="wrap">
87
  <h2>WP Embed Facebook</h2>
91
  <div class="welcome-panel-column">
92
  <form id="config-form" action="#" method="post">
93
  <table class="form-table">
94
+ <?php wp_nonce_field( 'wp-embed-fb','save-data' ); ?>
95
  <tbody>
96
  <tr>
97
  <h3><?php _e('Facebook application data', 'wp-embed-fb') ?></h3>
99
  <tr valign="middle">
100
  <th>App ID</th>
101
  <td>
102
+ <input type="text" name="wpemfb_app_id" required value="<?php echo get_option('wpemfb_app_id') ?>" />
103
  </td>
104
  </tr>
105
  <tr valign="middle">
106
  <th>App Secret</th>
107
  <td>
108
+ <input type="text" name="wpemfb_app_secret" required value="<?php echo get_option('wpemfb_app_secret') ?>" />
109
  </td>
110
  </tr>
111
+ <tr>
112
+ <th><?php _e("Theme to use", 'wp-embed-fb') ?></th>
113
+ <td>
114
+ <select name="wpemfb_theme">
115
+ <option value="default" <?php echo $sel1 ?> >Default</option>
116
+ <option value="classic" <?php echo $sel2 ?> >Classic</option>
117
+ </select>
118
+ </td>
119
+ </tr>
120
  <tr>
121
  <th>
 
122
  <h4><?php _e("Other Options", 'wp-embed-fb') ?></h4>
 
 
123
  </th>
124
  </tr>
125
  <tr valign="middle">
126
  <th><?php _e('Fb Cover Embed Width','wp-embed-fb') ?></th>
127
  <td>
128
+ <input type="text" name="wpemfb_max_width" value="<?php echo get_option('wpemfb_max_width') ?>" />
129
  </td>
130
  </tr>
131
  <tr valign="middle">
149
  <tr>
150
  <td>
151
  <?php //echo wp_nonce_field('wpebfb','nonce'); ?>
152
+ <input type="submit" name="submit" class="button button-primary button-hero" value="<?php _e('Save','wp-embed-fb') ?>" />
153
  </td>
154
  </tr>
155
  </tbody>
lib/core.php CHANGED
@@ -4,7 +4,9 @@
4
  */
5
  class WP_Embed_FB {
6
  static $fbsdk;
7
- protected static $_values = array();
 
 
8
  /*
9
  * Save default values to data base
10
  */
@@ -52,6 +54,7 @@ class WP_Embed_FB {
52
  'wpemfb_height' => '221.202',
53
  'wpemfb_show_like' => 'true',
54
  'wpemfb_fb_root' => 'true',
 
55
  );
56
  }
57
  /*
@@ -65,7 +68,8 @@ class WP_Embed_FB {
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
  /*
@@ -79,47 +83,13 @@ class WP_Embed_FB {
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();
@@ -144,7 +114,7 @@ class WP_Embed_FB {
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;
@@ -168,24 +138,37 @@ class WP_Embed_FB {
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');
 
 
 
 
 
 
173
  if(isset($fb_data['start_time'])) { //is event
174
  $template = self::locate_template('event');
175
- //} elseif(isset($fb_data['source'])) { //is photo Deprecated by facebook now embed post
176
  //$template = self::locate_template('photo');
177
  } elseif(isset($fb_data['category'])) { //is a page
178
  if(isset($fb_data['is_community_page']) && $fb_data['is_community_page'] == "1" ){
179
  $template = self::locate_template('com-page'); //is community page
180
  }else {
181
- switch ($fb_data['category']) {
182
- case 'Musician/band': //is a band page
183
- $template = self::locate_template('band');
184
- break; //TODO: add action to add more categories
185
- default:
186
- $template = self::locate_template('other');
187
- break;
188
- }
 
 
 
 
 
 
 
189
  }
190
  } elseif(isset($fb_data['is_post'])) {
191
  $template = self::locate_template('posts');
@@ -195,17 +178,17 @@ class WP_Embed_FB {
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
  /*
@@ -239,6 +222,69 @@ class WP_Embed_FB {
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
4
  */
5
  class WP_Embed_FB {
6
  static $fbsdk;
7
+ static $width = '';
8
+ static $height = '';
9
+ static $theme = '';
10
  /*
11
  * Save default values to data base
12
  */
54
  'wpemfb_height' => '221.202',
55
  'wpemfb_show_like' => 'true',
56
  'wpemfb_fb_root' => 'true',
57
+ 'wpemfb_theme' => 'default',
58
  );
59
  }
60
  /*
68
  * Enqueue wp embed facebook styles
69
  */
70
  static function wp_enqueue_scripts(){
71
+ $theme = get_option('wpemfb_theme');
72
+ wp_register_style( 'wpemfb-style', plugins_url('/wp-embed-facebook/templates/'.$theme.'/wpemfb.css'));
73
  wp_enqueue_style( 'wpemfb-style' );
74
  }
75
  /*
83
  foreach($matches as $match) {
84
  $the_content = preg_replace("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", self::fb_embed($match), $the_content, 1);
85
  }
 
 
 
 
 
 
86
  }
 
87
  }
88
  return $the_content;
89
  }
90
+ /**
91
+ * Extract fb_id from the url
92
+ * @param array $match[2]=
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  */
94
  static function fb_embed($match){ //TODO: photos!
95
  $vars = array();
114
  return self::fb_api_get($fb_id, $match[2]);
115
  }
116
  /*
117
+ * get data from fb using $fbsdk->api('/'.$fb_id) :)
118
  */
119
  static function fb_api_get($fb_id, $url){
120
  $wp_emb_fbsdk = self::$fbsdk;
138
  * find out what kind of data we got from facebook
139
  */
140
  static function print_fb_data($fb_data){
141
+ if(empty(self::$width)){
142
+ $width = get_option('wpemfb_max_width');
143
+ $height = get_option('wpemfb_height');
144
+ } else {
145
+ $width = self::$width;
146
+ $height = self::$height;
147
+ }
148
+ $prop = get_option('wpemfb_proportions');
149
  if(isset($fb_data['start_time'])) { //is event
150
  $template = self::locate_template('event');
151
+ //} elseif(isset($fb_data['source'])) { //is photo Deprecated by facebook
152
  //$template = self::locate_template('photo');
153
  } elseif(isset($fb_data['category'])) { //is a page
154
  if(isset($fb_data['is_community_page']) && $fb_data['is_community_page'] == "1" ){
155
  $template = self::locate_template('com-page'); //is community page
156
  }else {
157
+ $template = self::locate_template('page');
158
+ /**
159
+ * To add a new template for a fb category add something like this to your functions.php file
160
+ *
161
+ * add_action( 'wpemfb_category_template', 'your_function', 10, 1 );
162
+ * function your_fuction($category) {
163
+ * if($category == 'Museum/art gallery'){
164
+ * $template = WP_Embed_FB::locate_template('museum')
165
+ * }
166
+ * }
167
+ *
168
+ * then create a file named museum.php inside your-theme/plugins/wp-embed-facebook/default/
169
+ * remember you can use print_r($fb_data) to see all facebook data.
170
+ */
171
+ do_action('wpemfb_category_template',$fb_data['category']);
172
  }
173
  } elseif(isset($fb_data['is_post'])) {
174
  $template = self::locate_template('posts');
178
  $template = self::locate_template('profile');
179
  }
180
  ob_start();
181
+ include($template);
182
  return ob_get_clean();
183
  }
184
  /*
185
  * locate the proper template to show the embed
186
  */
187
  static function locate_template($template_name){
188
+ $theme = get_option('wpemfb_theme');
189
+ $located = locate_template(array('plugins/wp-embed-facebook/'.$theme.'/'.$template_name.'.php'));
190
+ if(empty($located))
191
+ $located = WPEMFBDIR.'/templates/'.$theme.'/'.$template_name.'.php';
192
  return $located;
193
  }
194
  /*
222
  return;
223
  //$replace = array('Museo - Galería de Arte','Negocio Local','Sala de Conciertos','Espacio público');
224
  }
225
+ /*
226
+ * facebook scripts required to show like buttons and posts added on top of the content
227
+ */
228
+ static function fb_scripts($the_content){
229
+ $opt = get_option('wpemfb_fb_root');
230
+ if($opt === 'true'){
231
+ ob_start();
232
+ ?>
233
+ <div id="fb-root"></div>
234
+ <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/<?php echo get_locale() ?>/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
235
+ <?php
236
+ $scripts = ob_get_clean();
237
+ return $scripts.$the_content;
238
+ }
239
+ return $the_content;
240
+ }
241
+ /*
242
+ * show like buttons or like count
243
+ */
244
+ static function like_btn($fb_id,$likes=null,$share=false,$faces=false){
245
+ $opt = get_option('wpemfb_show_like');
246
+ if($opt === 'true') :
247
+ ob_start();
248
+ ?>
249
+ <div class="fb-like" data-href="https://facebook.com/<?php echo $fb_id ?>" data-layout="button_count" data-action="like" data-show-faces="<?php echo $faces ? 'true' : 'false' ?>" data-share="<?php echo $share ? 'true' : 'false' ?>" ></div>
250
+ <?php
251
+ ob_end_flush();
252
+ return;
253
+ else :
254
+ printf( __( '%d people like this.', 'wp-embed-fb' ), $likes );
255
+ return;
256
+ endif;
257
+ }
258
+ /**
259
+ * Shotcode function
260
+ * [facebook='url' width='600'] width is optional
261
+ * @param array [0]=>url ['width']=>embed width
262
+ */
263
+ static function shortcode($atts){
264
+ if(!empty($atts) && isset($atts[0])){
265
+ $url = '<p>'.trim($atts[0],'=').'</p>';
266
+ if(isset($atts['width'])){
267
+ $prop = get_option('wpemfb_proportions');
268
+ self::$width = $atts['width'];
269
+ self::$height = $prop * $atts['width'];
270
+ }
271
+ $embed = self::the_content($url);
272
+ self::$height = '';
273
+ self::$width = '';
274
+ self::$theme = '';
275
+ return $embed;
276
+ }
277
+ return;
278
+ }
279
+ static function shortcode_atts($atts){
280
+ if(isset($atts['width'])){
281
+ $width = $atts['width'];
282
+ $prop = get_option('wpemfb_proportions');
283
+ $height = $width * $prop;
284
+ }
285
+ if(isset($atts['theme']))
286
+ $temp = $atts['theme'];
287
+ }
288
  }
289
  /*
290
  * 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
readme.txt CHANGED
@@ -2,9 +2,9 @@
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.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -41,7 +41,7 @@ In Settings > Embed Facebook.
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
 
@@ -61,6 +61,11 @@ In Settings > Embed Facebook.
61
 
62
  == Changelog ==
63
 
 
 
 
 
 
64
  = 1.2.2 =
65
  * Bugs and documentation
66
 
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.8.1
6
  Tested up to: 3.8.1
7
+ Stable tag: 1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
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
+ * Embed Personal Data
45
 
46
  == Installation ==
47
 
61
 
62
  == Changelog ==
63
 
64
+ = 1.3 =
65
+ * Shortcode [facebook=url ] width is optional
66
+ * Themes
67
+ * Multilingual Like Buttons
68
+
69
  = 1.2.2 =
70
  * Bugs and documentation
71
 
templates/classic/com-page.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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" style="min-width:<?php echo $width ?>px">
8
+ <div class="wpemfb-info" style="width: <?php echo $width ?>">
9
+ <div class="wpemfb-pic">
10
+ <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
11
+ <img src="http://graph.facebook.com/<?php echo $fb_data['id'] ?>/picture" />
12
+ </a>
13
+ </div>
14
+ <div class="wpemfb-desc">
15
+ <h4 class="wpemfb-title" >
16
+ <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
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>
24
+ </div>
25
+
templates/classic/event.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <?php
8
+ $start_time_format = !empty($fb_data['is_date_only']) ? '%e %b %Y' : '%e %b %Y %l:%M %P';
9
+ $start_time = strtotime($fb_data['start_time']) + get_option('gmt_offset')*3600; //shows event date on local time
10
+ ?>
11
+ <div class="wpemfb-container" style="min-width:<?php echo $width ?>px">
12
+
13
+ <div class="wpemfb-info">
14
+ <div class="wpemfb-pic">
15
+ <a href="http://www.facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
16
+ <img src="http://graph.facebook.com/<?php echo $fb_data['id'] ?>/picture" />
17
+ </a>
18
+ </div>
19
+ <div class="wpemfb-desc">
20
+ <h4 class="wpemfb-title" >
21
+ <a href="http://www.facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
22
+ <?php echo $fb_data['name'] ?>
23
+ </a>
24
+ </h4>
25
+ <?php echo strftime($start_time_format, $start_time ) ?><br>
26
+ <?php
27
+ if(isset($fb_data['venue']['id'])){
28
+ echo '<a href="http://www.facebook.com/'.$fb_data['venue']['id'].'" target="_blank">'.$fb_data['location'].'</a>';
29
+ } else {
30
+ echo $fb_data['location'];
31
+ } ?>
32
+ <br>
33
+ <?php echo __('Creator: ', 'wp-embed-fb').'<a href="http://www.facebook.com/'.$fb_data['owner']['id'].'" target="_blank">'.$fb_data['owner']['name'].'</a>' ?>
34
+ </div>
35
+ </div>
36
+ </div>
templates/{default/other.php → classic/page.php} RENAMED
@@ -29,7 +29,13 @@
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>
29
  <?php echo $fb_data['name'] ?>
30
  </a>
31
  </h4>
32
+ <?php
33
+ if($fb_data['category'] == 'Musician/band'){
34
+ echo isset($fb_data['genre']) ? $fb_data['genre'].'<br>' : '';
35
+ } else {
36
+ WP_Embed_FB::fb_categories($fb_data['category']);
37
+ }
38
+ ?><br>
39
  <?php WP_Embed_FB::like_btn($fb_data['id'],$fb_data['likes']) ?><br>
40
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
41
  </div>
templates/classic/photo.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </div>
12
+ <div class="wpemfb-desc">
13
+ <h4 class="wpemfb-title" >
14
+ <a href="https://facebook.com/<?php echo $fb_data['from']['id'] ?>" target="_blank" rel="nofollow">
15
+ <?php echo $fb_data['from']['name'] ?>
16
+ </a>
17
+ </h4>
18
+ <?php if(isset($fb_data['from']['category'])) : ?>
19
+ <?php WP_Embed_FB::fb_categories($fb_data['from']['category']) ?><br>
20
+ <?php endif; ?>
21
+ <?php WP_Embed_FB::like_btn($fb_data['id']) ?><br>
22
+ </div>
23
+ </div>
24
+ <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
25
+ <img src="<?php echo $fb_data['source'] ?>" width="<?php echo $width ?>" height="auto" />
26
+ </a>
27
+ </div>
templates/classic/posts.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <div class="fb-post" data-href="https://www.facebook.com/<?php echo $fb_data['user'] ?>/posts/<?php echo $fb_data['is_post'] ?>" data-width="<?php echo $width ?>">
2
+ </div>
templates/classic/profile.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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" style="min-width:<?php echo $width ?>px">
8
+ <div class="wpemfb-info">
9
+ <div class="wpemfb-pic">
10
+ <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
11
+ <img src="http://graph.facebook.com/<?php echo $fb_data['id'] ?>/picture" />
12
+ </a>
13
+ </div>
14
+ <div class="wpemfb-desc">
15
+ <h4 class="wpemfb-title" >
16
+ <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
17
+ <?php echo $fb_data['name'] ?>
18
+ </a>
19
+ </h4>
20
+ </div>
21
+ </div>
22
+ </div>
23
+
templates/classic/wpemfb.css ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wpemfb-container{
2
+ margin-top:5px;
3
+ border: 1px solid #23487E;
4
+ border-radius: 2px;
5
+ box-shadow: 2px 2px 3px #1A3151;
6
+ display: inline-table;
7
+ height: auto;
8
+ margin-left: auto ;
9
+ margin-right: auto ;
10
+ }
11
+ .wpemfb-pagebk{
12
+ background-size: 100%;
13
+ }
14
+ .wpemfb-info a {
15
+ color: #23487E;
16
+ text-decoration: none !important;
17
+ }
18
+ .wpemfb-info a:hover {
19
+ color: #23487E;
20
+ text-decoration: underline !important;
21
+ }
22
+ .wpemfb-title{
23
+ padding: 0 !important;
24
+ margin: 0 !important;
25
+ }
26
+ .wpemfb-pic{
27
+ display: table-cell;
28
+ vertical-align: middle;
29
+ margin: 0px;
30
+ padding: 5px;
31
+ width: 10%;
32
+ }
33
+ .wpemfb-desc{
34
+ display: table-cell;
35
+ vertical-align: middle;
36
+ }
37
+
templates/default/com-page.php CHANGED
@@ -3,8 +3,10 @@
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" style="min-width:<?php echo $width ?>px">
8
  <div class="wpemfb-info" style="width: <?php echo $width ?>">
9
  <div class="wpemfb-pic">
10
  <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
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
+ $width = $width - 20;
7
+ $height = $width * $prop;
8
  ?>
9
+ <div class="wpemfb-container">
10
  <div class="wpemfb-info" style="width: <?php echo $width ?>">
11
  <div class="wpemfb-pic">
12
  <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
templates/default/event.php CHANGED
@@ -3,12 +3,14 @@
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
  <?php
8
  $start_time_format = !empty($fb_data['is_date_only']) ? '%e %b %Y' : '%e %b %Y %l:%M %P';
9
  $start_time = strtotime($fb_data['start_time']) + get_option('gmt_offset')*3600; //shows event date on local time
10
  ?>
11
- <div class="wpemfb-container" style="min-width:<?php echo $width ?>px">
12
 
13
  <div class="wpemfb-info">
14
  <div class="wpemfb-pic">
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
+ $width = $width - 20;
7
+ $height = $width * $prop;
8
  ?>
9
  <?php
10
  $start_time_format = !empty($fb_data['is_date_only']) ? '%e %b %Y' : '%e %b %Y %l:%M %P';
11
  $start_time = strtotime($fb_data['start_time']) + get_option('gmt_offset')*3600; //shows event date on local time
12
  ?>
13
+ <div class="wpemfb-container">
14
 
15
  <div class="wpemfb-info">
16
  <div class="wpemfb-pic">
templates/default/{band.php → page.php} RENAMED
@@ -3,35 +3,39 @@
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" style="min-width:<?php echo $height ?>px">
8
  <div class="wpemfb-pagebk"
9
  style=" height:<?php echo $height ?>px;
10
  width:<?php echo $width?>px;
11
  background-image: url(<?php echo $fb_data['cover']['source'] ?>);
12
  background-position: 0% <?php echo $fb_data['cover']['offset_y'] ?>%;
13
- ">
14
 
15
  </div>
16
  <div class="wpemfb-info">
17
  <div class="wpemfb-pic">
18
- <a href="<?php echo $fb_data['link'] ?>" target="_blank">
19
  <img src="http://graph.facebook.com/<?php echo $fb_data['id'] ?>/picture" />
20
  </a>
21
  </div>
22
  <div class="wpemfb-desc">
23
  <h4 class="wpemfb-title" >
24
- <a href="<?php echo $fb_data['link'] ?>" target="_blank">
25
  <?php echo $fb_data['name'] ?>
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>
33
  </div>
34
-
35
-
36
-
37
-
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
+ $width = $width - 20;
7
+ $height = $width * $prop;
8
  ?>
9
+ <div class="wpemfb-container" style=" width:<?php echo $width ?>px; ">
10
  <div class="wpemfb-pagebk"
11
  style=" height:<?php echo $height ?>px;
12
  width:<?php echo $width?>px;
13
  background-image: url(<?php echo $fb_data['cover']['source'] ?>);
14
  background-position: 0% <?php echo $fb_data['cover']['offset_y'] ?>%;
15
+ " onclick="window.open('<?php echo $fb_data['link'] ?>', '_blank')" >
16
 
17
  </div>
18
  <div class="wpemfb-info">
19
  <div class="wpemfb-pic">
20
+ <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
21
  <img src="http://graph.facebook.com/<?php echo $fb_data['id'] ?>/picture" />
22
  </a>
23
  </div>
24
  <div class="wpemfb-desc">
25
  <h4 class="wpemfb-title" >
26
+ <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
27
  <?php echo $fb_data['name'] ?>
28
  </a>
29
  </h4>
30
+ <?php
31
+ if($fb_data['category'] == 'Musician/band'){
32
+ echo isset($fb_data['genre']) ? $fb_data['genre'].'<br>' : '';
33
+ } else {
34
+ WP_Embed_FB::fb_categories($fb_data['category']);
35
+ }
36
+ ?><br>
37
+ <div class="fb-btns"><?php WP_Embed_FB::like_btn($fb_data['id'],$fb_data['likes']) ?></div>
38
  <?php echo isset($fb_data["website"]) ? WP_Embed_FB::getwebsite($fb_data["website"]) : ""; ?>
39
  </div>
40
  </div>
41
  </div>
 
 
 
 
templates/default/photo.php CHANGED
@@ -3,12 +3,13 @@
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" >
@@ -25,5 +26,4 @@
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>
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
+ $width = $width - 20;
7
+ $height = $width * $prop;
8
  ?>
9
  <div class="wpemfb-container">
10
  <div class="wpemfb-info">
11
  <div class="wpemfb-pic">
12
+ <img src="http://graph.facebook.com/<?php echo $fb_data['from']['id'] ?>/picture" />
 
13
  </div>
14
  <div class="wpemfb-desc">
15
  <h4 class="wpemfb-title" >
26
  <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
27
  <img src="<?php echo $fb_data['source'] ?>" width="<?php echo $width ?>" height="auto" />
28
  </a>
29
+ </div>
 
templates/default/profile.php CHANGED
@@ -3,8 +3,10 @@
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" style="min-width:<?php echo $width ?>px">
8
  <div class="wpemfb-info">
9
  <div class="wpemfb-pic">
10
  <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
@@ -14,7 +16,7 @@
14
  <div class="wpemfb-desc">
15
  <h4 class="wpemfb-title" >
16
  <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
17
- <h3><?php echo $fb_data['name'] ?></h3>
18
  </a>
19
  </h4>
20
  </div>
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
+ $width = $width - 20;
7
+ $height = $width * $prop;
8
  ?>
9
+ <div class="wpemfb-container">
10
  <div class="wpemfb-info">
11
  <div class="wpemfb-pic">
12
  <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
16
  <div class="wpemfb-desc">
17
  <h4 class="wpemfb-title" >
18
  <a href="http://facebook.com/<?php echo $fb_data['id'] ?>" target="_blank" rel="nofollow">
19
+ <?php echo $fb_data['name'] ?>
20
  </a>
21
  </h4>
22
  </div>
templates/default/wpemfb.css CHANGED
@@ -1,20 +1,18 @@
1
- .wpemfb-dummy {
2
- padding-top: 80%;
3
- }
4
  .wpemfb-container{
5
- margin-top:5px;
6
- border: 1px solid #23487E;
7
  border-radius: 2px;
8
- box-shadow: 2px 2px 3px #1A3151;
9
  display: inline-table;
 
10
  height: auto;
11
- margin-left: auto ;
12
- margin-right: auto ;
13
  }
14
  .wpemfb-pagebk{
15
  background-size: 100%;
 
16
  }
17
  .wpemfb-info a {
 
18
  color: #23487E;
19
  text-decoration: none !important;
20
  }
@@ -37,4 +35,6 @@
37
  display: table-cell;
38
  vertical-align: middle;
39
  }
40
-
 
 
 
 
 
1
  .wpemfb-container{
2
+ border: 1px solid #DEDEDE;
 
3
  border-radius: 2px;
 
4
  display: inline-table;
5
+ font-family: Helvetica;
6
  height: auto;
7
+ margin: 5px auto;
8
+ padding: 10px;
9
  }
10
  .wpemfb-pagebk{
11
  background-size: 100%;
12
+ cursor: pointer;
13
  }
14
  .wpemfb-info a {
15
+ font-family: Helvetica;
16
  color: #23487E;
17
  text-decoration: none !important;
18
  }
35
  display: table-cell;
36
  vertical-align: middle;
37
  }
38
+ .fb-btns {
39
+ float: right;
40
+ }
wp-embed-fb.php CHANGED
@@ -1,37 +1,38 @@
1
  <?php
2
  /**
3
  * @package WP_Embed_Facebook
4
- * @version 1.2.3
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.3
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()){
33
- require_once WPEMFBLIB.'admin.php';
34
  add_action('admin_menu', array('EmbFbAdmin','add_page'));
 
 
35
  }
36
 
37
  ?>
1
  <?php
2
  /**
3
  * @package WP_Embed_Facebook
4
+ * @version 1.3
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, or use shortcode [facebook url='' width='' temp='']
10
  Author: Miguel Sirvent
11
+ Version: 1.3
12
  Author URI: http://www.saliuitl.org/
13
  */
14
 
15
  /*
16
  * Global definitions and core include.
17
  */
18
+ define('WPEMFBDIR',dirname(__FILE__));
19
+ require_once WPEMFBDIR.'/lib/core.php';
 
 
20
 
21
  /*
22
  * All actions, filters and hooks.
23
  */
24
+ register_activation_hook(__FILE__, array('WP_Embed_FB', 'install') );
25
+ register_uninstall_hook(__FILE__, array('WP_Embed_FB', 'uninstall') );
26
  add_action('init',array('WP_Embed_FB','init'));
27
+ add_action('wp_enqueue_scripts', array('WP_Embed_FB', 'wp_enqueue_scripts') );
28
+ add_filter('the_content', array('WP_Embed_FB','fb_scripts'),10,1);
29
+ add_filter('the_content', array('WP_Embed_FB','the_content'),10,2);
30
+ add_shortcode('facebook', array('WP_Embed_FB','shortcode') );
31
  if(is_admin()){
32
+ require_once WPEMFBDIR.'/lib/admin.php';
33
  add_action('admin_menu', array('EmbFbAdmin','add_page'));
34
+ add_action('admin_init', array('EmbFbAdmin','admin_init'));
35
+
36
  }
37
 
38
  ?>