WP Embed Facebook - Version 1.2

Version Description

  • Embed posts
  • Embed photos
  • Like buttons
Download this release

Release Info

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

Code changes from version 1.3 to 1.2

lib/admin.php CHANGED
@@ -4,84 +4,68 @@ class EmbFbAdmin{
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
- }
61
- if(isset($_POST['wpemfb_fb_root'])){
62
- if ( !is_multisite() )
63
- update_option('wpemfb_fb_root', 'true');
64
- else // TODO: multiple fb apps for each site
65
- update_site_option('wpemfb_fb_root', 'true');
66
- }else{
67
- if ( !is_multisite() ) {
68
- update_option('wpemfb_fb_root', 'false');
69
- }
70
  else { // TODO: multiple fb apps for each site
71
- update_site_option('wpemfb_fb_root', 'false');
72
  }
73
  }
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,7 +75,6 @@ class EmbFbAdmin{
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,73 +82,59 @@ class EmbFbAdmin{
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">
132
- <th><?php _e('Add like button to pages','wp-embed-fb') ?></th>
133
- <td>
134
- <input type="checkbox" name="wpemfb_show_like" <?php echo $checked2 ?> />
135
- </td>
136
- </tr>
137
  <tr valign="middle">
138
  <th><?php _e('Enqueue Styles','wp-embed-fb') ?></th>
139
  <td>
140
- <input type="checkbox" name="wpemfb_enqueue_style" <?php echo $checked ?> />
141
  </td>
142
  </tr>
143
  <tr valign="middle">
144
- <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>
145
  <td>
146
- <input type="checkbox" name="wpemfb_fb_root" <?php echo $checked3 ?> />
147
  </td>
148
- </tr>
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>
156
  </table>
157
  </form
158
  <ul class="">
159
- <!--
160
  <li>
161
  <a href="http://www.saliuitl.org/wp-embed-fb/customize"><?php _e('Customize','wp-embed-fb') ?></a>
162
  </li>
163
  <li>
164
  <a href="http://www.saliuitl.org/wp-embed-fb/support"><?php _e('Support','wp-embed-fb') ?></a>
165
- </li>
166
- -->
167
  <li>
168
- <a href="http://www.saliuitl.org/en/wp-embed-facebook"><?php _e('Plugin Web Site','wp-embed-fb') ?></a>
169
  </li>
170
  </ul>
171
  </div>
@@ -175,7 +144,10 @@ class EmbFbAdmin{
175
  <div class="welcome-panel-column welcome-panel-last">
176
  <h3 style="color:red;"><?php _e('Donate!', 'wp-embed-fb') ?></h3>
177
  <p><?php _e('Help me keep this plugin up to date', 'wp-embed-fb') ?></p>
178
- <p><strong><?php _e('Click the taco !', 'wp-embed-fb') ?></strong></p>
 
 
 
179
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
180
  <input type="hidden" name="cmd" value="_s-xclick">
181
  <input type="hidden" name="hosted_button_id" value="9TEJ8CGXMJEDG">
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
  }
59
  }
60
+
61
  }
62
  static function embedfb_page() {
63
+ //global $new_emb_fbsdk; //TODO: eliminate this test
64
+ if(isset($_POST['submit'])){
65
  self::savedata();
66
  }
67
  $checked = (get_option('wpemfb_enqueue_style') === 'true') ? 'checked' : '' ;
68
  $checked2 = (get_option('wpemfb_show_like') === 'true') ? 'checked' : '' ;
 
 
 
69
  ?>
70
  <div class="wrap">
71
  <h2>WP Embed Facebook</h2>
75
  <div class="welcome-panel-column">
76
  <form id="config-form" action="#" method="post">
77
  <table class="form-table">
 
78
  <tbody>
79
  <tr>
80
  <h3><?php _e('Facebook application data', 'wp-embed-fb') ?></h3>
82
  <tr valign="middle">
83
  <th>App ID</th>
84
  <td>
85
+ <input type="text" name="appid" id="appid" class="input" required="" value="<?php echo get_option('wpemfb_app_id') ?>" />
86
  </td>
87
  </tr>
88
  <tr valign="middle">
89
  <th>App Secret</th>
90
  <td>
91
+ <input type="text" name="appsecret" id="appsecret" class="input" required="" value="<?php echo get_option('wpemfb_app_secret') ?>" />
92
  </td>
93
  </tr>
 
 
 
 
 
 
 
 
 
94
  <tr>
95
  <th>
96
+ <td>
97
  <h4><?php _e("Other Options", 'wp-embed-fb') ?></h4>
98
+ </td>
99
+
100
  </th>
101
  </tr>
102
  <tr valign="middle">
103
  <th><?php _e('Fb Cover Embed Width','wp-embed-fb') ?></th>
104
  <td>
105
+ <input type="text" name="max-width" id="max-width" class="input" value="<?php echo get_option('wpemfb_max_width') ?>" /
106
  </td>
107
  </tr>
 
 
 
 
 
 
108
  <tr valign="middle">
109
  <th><?php _e('Enqueue Styles','wp-embed-fb') ?></th>
110
  <td>
111
+ <input type="checkbox" name="wpemfb_enqueue_style" <?php echo $checked ?> /><br>
112
  </td>
113
  </tr>
114
  <tr valign="middle">
115
+ <th><?php _e('Add like button to pages','wp-embed-fb') ?></th>
116
  <td>
117
+ <input type="checkbox" name="wpemfb_show_like" <?php echo $checked2 ?> /><br>
118
  </td>
119
+ </tr>
120
  <tr>
121
  <td>
122
  <?php //echo wp_nonce_field('wpebfb','nonce'); ?>
123
+ <input type="submit" name="submit" id="save-config" class="button button-primary button-hero" value="<?php _e('Save','wp-embed-fb') ?>" />
124
  </td>
125
  </tr>
126
  </tbody>
127
  </table>
128
  </form
129
  <ul class="">
 
130
  <li>
131
  <a href="http://www.saliuitl.org/wp-embed-fb/customize"><?php _e('Customize','wp-embed-fb') ?></a>
132
  </li>
133
  <li>
134
  <a href="http://www.saliuitl.org/wp-embed-fb/support"><?php _e('Support','wp-embed-fb') ?></a>
135
+ </li>
 
136
  <li>
137
+ <a href="http://www.saliuitl.org/wp-embed-fb"><?php _e('Plugin Web Site','wp-embed-fb') ?></a>
138
  </li>
139
  </ul>
140
  </div>
144
  <div class="welcome-panel-column welcome-panel-last">
145
  <h3 style="color:red;"><?php _e('Donate!', 'wp-embed-fb') ?></h3>
146
  <p><?php _e('Help me keep this plugin up to date', 'wp-embed-fb') ?></p>
147
+ <p>
148
+ <strong><?php _e('Click the taco !', 'wp-embed-fb') ?></strong><br>
149
+ <small><?php _e('3 USD Minimun Suggested Donation', 'wp-embed-fb') ?></small>
150
+ </p>
151
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
152
  <input type="hidden" name="cmd" value="_s-xclick">
153
  <input type="hidden" name="hosted_button_id" value="9TEJ8CGXMJEDG">
lib/core.php CHANGED
@@ -1,15 +1,7 @@
1
  <?php
2
- /*
3
- * Main Class of the plugin.
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
- */
13
  static function install(){
14
  $defaults = self::getdefaults();
15
  foreach ($defaults as $option => $value) {
@@ -18,7 +10,7 @@ class WP_Embed_FB {
18
  if($opt === false)
19
  update_option($option, $value);
20
  }
21
- else { // TODO: multiple fb apps for each site probably not needed for public data
22
  $opt = get_option($option);
23
  if($opt === false)
24
  update_site_option($option, $value);
@@ -26,9 +18,6 @@ class WP_Embed_FB {
26
  }
27
  return;
28
  }
29
- /*
30
- * Delete all plugin options on uninstall
31
- */
32
  static function uninstall(){
33
  $defaults = self::getdefaults();
34
  foreach ($defaults as $option ) {
@@ -40,57 +29,58 @@ class WP_Embed_FB {
40
  }
41
  }
42
  return;
43
- }
44
- /*
45
- * Default options
46
- */
47
  static function getdefaults(){
48
  return array(
49
  'wpemfb_max_width' => '600',
50
  'wpemfb_enqueue_style' => 'true',
 
51
  'wpemfb_app_id' => '0',
52
  'wpemfb_app_secret' => '0',
53
  'wpemfb_proportions' => 0.36867,
54
  'wpemfb_height' => '221.202',
55
  'wpemfb_show_like' => 'true',
56
- 'wpemfb_fb_root' => 'true',
57
- 'wpemfb_theme' => 'default',
58
  );
59
  }
60
- /*
61
- * load translations and facebook sdk
62
- */
63
- static function init(){
64
- load_plugin_textdomain( 'wp-embed-fb', '', WPEMFBLIB.'/lang' );
65
- FaceInit::init();
66
- }
67
- /*
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
- /*
76
- * the_content filter to process fb url's
77
- */
78
  static function the_content($the_content){
79
  preg_match_all("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", $the_content, $matches, PREG_SET_ORDER);
80
  if(!empty($matches) && is_array($matches)){
81
  self::$fbsdk = FaceInit::$fbsdk;
82
- if(self::$fbsdk !== 'unactive'){
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();
96
  parse_str(parse_url($match[2], PHP_URL_QUERY), $vars);
@@ -99,7 +89,7 @@ class WP_Embed_FB {
99
  } else {
100
  $url = explode('?', $match[2]);
101
  $clean = explode('/', $url[0]);
102
- $end = end($clean);
103
  if(empty($end)){
104
  array_pop($clean);
105
  }
@@ -109,13 +99,25 @@ class WP_Embed_FB {
109
  $post = $clean[$key +1];
110
  $fb_data = array('user' => $user ,'is_post' => $post);
111
  return self::print_fb_data($fb_data);
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
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;
121
  try {
@@ -124,51 +126,34 @@ class WP_Embed_FB {
124
  $res = self::print_fb_data($fb_data);
125
  } catch(FacebookApiException $e) {
126
  $res = '<p><a href="http://wwww.facebook.com/'.$url.'" target="_blank" rel="nofollow">http://wwww.facebook.com/'.$url.'</a>';
127
- //uncoment this lines to debug
128
- //if(is_super_admin()){
129
- //$res .= '<span style="color: red">'.__('This facebook link is not public', 'wp-embed-fb').'</span></p>';
130
- //$res .= print_r($e->getResult(),true);
131
- //$res .= 'fb_id'.$fb_id;
132
- //}
133
 
134
  }
135
  return $res;
136
  }
137
- /*
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,25 +163,16 @@ class WP_Embed_FB {
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
- /*
195
- * Formatting functions.
196
- */
197
- /*
198
- * If a user has a lot of websites registered on fb this function will only link to the first one
199
- */
200
  static function getwebsite($urls){
201
  $url = explode(' ',$urls);
202
  $clean = explode('?', $url[0]);
@@ -204,9 +180,6 @@ class WP_Embed_FB {
204
  $ret = '<a href="http://'.$cleaner.'" title="'.__('Web Site', 'wp-embed-fb').'" target="_blank">'.__('Web Site','wp-embed-fb').'</a>';
205
  return $ret;
206
  }
207
- /*
208
- * Translate fb categories to current locale
209
- */
210
  static function fb_categories($category){
211
  $fbcats = array(
212
  __('Museum/art gallery') ,
@@ -222,74 +195,8 @@ class WP_Embed_FB {
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
291
- * https://developers.facebook.com/docs/reference/php/
292
- */
293
  class FaceInit {
294
  static $fbsdk;
295
  static function init(){
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
  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
  }
19
  return;
20
  }
 
 
 
21
  static function uninstall(){
22
  $defaults = self::getdefaults();
23
  foreach ($defaults as $option ) {
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
  'wpemfb_show_like' => 'true',
 
 
43
  );
44
  }
 
 
 
 
 
 
 
 
 
 
45
  static function wp_enqueue_scripts(){
46
+
47
+ wp_register_style( 'wpemfb-style', plugins_url('../templates/default/wpemfb.css', __FILE__) );
48
  wp_enqueue_style( 'wpemfb-style' );
49
  }
 
 
 
50
  static function the_content($the_content){
51
  preg_match_all("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", $the_content, $matches, PREG_SET_ORDER);
52
  if(!empty($matches) && is_array($matches)){
53
  self::$fbsdk = FaceInit::$fbsdk;
54
+ if(self::$fbsdk !== 'unactive')
55
+ foreach($matches as $match) {
56
  $the_content = preg_replace("/<p>(http|https):\/\/www\.facebook\.com\/([^<\s]*)<\/p>/", self::fb_embed($match), $the_content, 1);
57
+ }
 
58
  }
59
+
60
+ return self::fb_scripts().$the_content;
61
+ }
62
+ static function fb_scripts(){
63
+ ob_start();
64
+ ?>
65
+ <div id="fb-root"></div>
66
+ <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>
67
+ <?php
68
+ return ob_get_clean();
69
+ }
70
+ static function like_btn($fb_id,$likes=null){
71
+ $opt = get_option('wpemfb_show_like');
72
+ if($opt === 'true') :
73
+ ob_start();
74
+ ?>
75
+ <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>
76
+ <?php
77
+ ob_end_flush();
78
+ return;
79
+ else :
80
+ printf( __( '%d people like this.', 'wp-embed-fb' ), $likes );
81
+ return;
82
+ endif;
83
  }
 
 
 
 
84
  static function fb_embed($match){ //TODO: photos!
85
  $vars = array();
86
  parse_str(parse_url($match[2], PHP_URL_QUERY), $vars);
89
  } else {
90
  $url = explode('?', $match[2]);
91
  $clean = explode('/', $url[0]);
92
+ $end = end($clean);
93
  if(empty($end)){
94
  array_pop($clean);
95
  }
99
  $post = $clean[$key +1];
100
  $fb_data = array('user' => $user ,'is_post' => $post);
101
  return self::print_fb_data($fb_data);
102
+ } else {
103
+ $wp_emb_fbsdk = self::$fbsdk;
104
+ try {
105
+ $fb_data = $wp_emb_fbsdk->api('/'.$fb_id);
106
+ //$res = '<pre>'.print_r($fb_data,true).'</pre>'; //to inspect what elements are queried by default
107
+ $res = self::print_fb_data($fb_data);
108
+ } catch(FacebookApiException $e) {
109
+ $res = '<p><a href="http://wwww.facebook.com/'.$match[2].'" target="_blank" rel="nofollow">http://wwww.facebook.com/'.$match[2].'</a><br>';
110
+ if(is_super_admin()){
111
+ $res .= '<span style="color: red">'.__('This facebook link is not public', 'wp-embed-fb').'</span></p>';
112
+ $res .= print_r($e->getResult(),true); //see the problem here
113
+ }
114
+
115
+ }
116
+ return $res;
117
+ }
118
  }
119
  return self::fb_api_get($fb_id, $match[2]);
120
  }
 
 
 
121
  static function fb_api_get($fb_id, $url){
122
  $wp_emb_fbsdk = self::$fbsdk;
123
  try {
126
  $res = self::print_fb_data($fb_data);
127
  } catch(FacebookApiException $e) {
128
  $res = '<p><a href="http://wwww.facebook.com/'.$url.'" target="_blank" rel="nofollow">http://wwww.facebook.com/'.$url.'</a>';
129
+ if(is_super_admin()){
130
+ $res .= '<span style="color: red">'.__('This facebook link is not public', 'wp-embed-fb').'</span></p>';
131
+ $res .= print_r($e->getResult(),true); //see the problem here
132
+ $res .= 'fb_id'.$fb_id;
133
+ }
 
134
 
135
  }
136
  return $res;
137
  }
 
 
 
138
  static function print_fb_data($fb_data){
139
+ $width = get_option('wpemfb_max_width');
140
+ $height = get_option('wpemfb_height');
 
 
 
 
 
 
141
  if(isset($fb_data['start_time'])) { //is event
142
  $template = self::locate_template('event');
143
+ //} elseif(isset($fb_data['source'])) { //is photo Deprecated by facebook now embed post
144
  //$template = self::locate_template('photo');
145
  } elseif(isset($fb_data['category'])) { //is a page
146
  if(isset($fb_data['is_community_page']) && $fb_data['is_community_page'] == "1" ){
147
  $template = self::locate_template('com-page'); //is community page
148
  }else {
149
+ switch ($fb_data['category']) {
150
+ case 'Musician/band': //is a band page
151
+ $template = self::locate_template('band');
152
+ break; //TODO: add action to add more categories
153
+ default:
154
+ $template = self::locate_template('other');
155
+ break;
156
+ }
 
 
 
 
 
 
 
157
  }
158
  } elseif(isset($fb_data['is_post'])) {
159
  $template = self::locate_template('posts');
163
  $template = self::locate_template('profile');
164
  }
165
  ob_start();
166
+ include($template);
167
  return ob_get_clean();
168
  }
 
 
 
169
  static function locate_template($template_name){
170
+ $located = locate_template(array('plugins/wp-embed-fb/'.$template_name.'.php'));
171
+ if( empty($located) ){
172
+ $located = plugin_dir_path( __FILE__ ).'../templates/default/'.$template_name.'.php';
173
+ }
174
  return $located;
175
  }
 
 
 
 
 
 
176
  static function getwebsite($urls){
177
  $url = explode(' ',$urls);
178
  $clean = explode('?', $url[0]);
180
  $ret = '<a href="http://'.$cleaner.'" title="'.__('Web Site', 'wp-embed-fb').'" target="_blank">'.__('Web Site','wp-embed-fb').'</a>';
181
  return $ret;
182
  }
 
 
 
183
  static function fb_categories($category){
184
  $fbcats = array(
185
  __('Museum/art gallery') ,
195
  return;
196
  //$replace = array('Museo - Galería de Arte','Negocio Local','Sala de Conciertos','Espacio público');
197
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
+
 
 
 
200
  class FaceInit {
201
  static $fbsdk;
202
  static function init(){
readme.txt CHANGED
@@ -1,74 +1,58 @@
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.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
 
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
- * Embed Personal Data
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.3 =
65
- * Shortcode [facebook=url ] width is optional
66
- * Themes
67
- * Multilingual Like Buttons
68
-
69
- = 1.2.2 =
70
- * Bugs and documentation
71
-
72
  = 1.2.1 =
73
  * Updated Instructions
74
  * Change theme template directory
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
templates/classic/com-page.php DELETED
@@ -1,25 +0,0 @@
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 DELETED
@@ -1,36 +0,0 @@
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/classic/photo.php DELETED
@@ -1,27 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
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 DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,37 +0,0 @@
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/{page.php → band.php} RENAMED
@@ -3,39 +3,35 @@
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>
 
 
 
 
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
+
templates/default/com-page.php CHANGED
@@ -3,10 +3,8 @@
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">
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">
templates/default/event.php CHANGED
@@ -3,14 +3,12 @@
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">
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">
templates/{classic/page.php → default/other.php} RENAMED
@@ -29,13 +29,7 @@
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>
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>
templates/default/photo.php CHANGED
@@ -3,13 +3,12 @@
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,4 +25,5 @@
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>
 
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
  <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 DELETED
@@ -1,2 +0,0 @@
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/default/profile.php CHANGED
@@ -3,10 +3,8 @@
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,7 +14,7 @@
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>
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
  <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>
templates/default/wpemfb.css CHANGED
@@ -1,18 +1,20 @@
 
 
 
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,6 +37,4 @@
35
  display: table-cell;
36
  vertical-align: middle;
37
  }
38
- .fb-btns {
39
- float: right;
40
- }
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
  display: table-cell;
38
  vertical-align: middle;
39
  }
40
+
 
 
wp-embed-fb.php CHANGED
@@ -1,38 +1,38 @@
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
  ?>
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.2
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()){
34
+ require_once WPEMFBLIB.'admin.php';
35
  add_action('admin_menu', array('EmbFbAdmin','add_page'));
 
 
36
  }
37
 
38
  ?>