WP Embed Facebook - Version 1.1.1

Version Description

  • Corrected links on events.
Download this release

Release Info

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

Version 1.1.1

lang/.pot.pot ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wp-embed-fb\n"
4
+ "POT-Creation-Date: 2014-02-26 10:48-0600\n"
5
+ "PO-Revision-Date: 2014-02-26 10:51-0600\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.6.4\n"
12
+ "X-Poedit-Basepath: .\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "Language: en_US\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
lang/wp-embed-fb-es_ES.mo ADDED
Binary file
lang/wp-embed-fb-es_ES.po ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wp-embed-fb\n"
4
+ "POT-Creation-Date: 2014-02-28 20:03-0600\n"
5
+ "PO-Revision-Date: 2014-02-28 20:03-0600\n"
6
+ "Last-Translator: Miguel Sirvent <miguel.sirvent@gmail.com>\n"
7
+ "Language-Team: Miguel Sirvent <miguel.sirvent@gmail.com>\n"
8
+ "Language: es_ES\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.4\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+
19
+ #: ../lib/admin.php:67
20
+ msgid "Facebook application data"
21
+ msgstr "Datos de la aplicación de Facebook."
22
+
23
+ #: ../lib/admin.php:84
24
+ msgid "Other Options"
25
+ msgstr "Otras Opciones"
26
+
27
+ #: ../lib/admin.php:90
28
+ msgid "Fb Cover Embed Width"
29
+ msgstr "Ancho máximo del Embed"
30
+
31
+ #: ../lib/admin.php:96
32
+ msgid "Enqueue Styles"
33
+ msgstr "Incluir css del plugin"
34
+
35
+ #: ../lib/admin.php:104
36
+ msgid "Save"
37
+ msgstr "Guardar"
38
+
39
+ #: ../lib/admin.php:112
40
+ msgid "Customize"
41
+ msgstr "Customizar"
42
+
43
+ #: ../lib/admin.php:115
44
+ msgid "Support"
45
+ msgstr "Soporte"
46
+
47
+ #: ../lib/admin.php:118
48
+ msgid "Plugin Web Site"
49
+ msgstr "Sitio Web del plugin"
50
+
51
+ #: ../lib/admin.php:126
52
+ msgid "Donate!"
53
+ msgstr "Dona !"
54
+
55
+ #: ../lib/admin.php:127
56
+ msgid "Help me keep this plugin up to date"
57
+ msgstr "Ayúdame a manter este plugin actualizado"
58
+
59
+ #: ../lib/admin.php:129
60
+ msgid "Click the taco !"
61
+ msgstr "Click en el taco !"
62
+
63
+ #: ../lib/admin.php:130
64
+ msgid "3 USD Minimun Suggested Donation"
65
+ msgstr "Mínimo Sugerido 3 USD"
66
+
67
+ #: ../lib/admin.php:140
68
+ msgid "Searching for the Premium version ?"
69
+ msgstr "Buscando la versión premium ?"
70
+
71
+ #: ../lib/admin.php:143
72
+ msgid "Custom templates"
73
+ msgstr "Templates personalizados"
74
+
75
+ #: ../lib/admin.php:146
76
+ msgid "Compatibility with all themes imaginable"
77
+ msgstr "Compatibilidad con todos los themes imaginables"
78
+
79
+ #: ../lib/admin.php:149
80
+ msgid "Multiple fb app id's per each multisite site"
81
+ msgstr "Multiples app's en multisite"
82
+
83
+ #: ../lib/admin.php:152
84
+ msgid "Comming Soon"
85
+ msgstr "Pronto muy pronto"
86
+
87
+ #: ../lib/core.php:89
88
+ msgid "This facebook link is not public"
89
+ msgstr "Este link de Facebook no es público"
90
+
91
+ #: ../lib/core.php:134
92
+ msgid "Web Site"
93
+ msgstr "Sitio Web"
94
+
95
+ #: ../lib/core.php:139
96
+ msgid "Museum/art gallery"
97
+ msgstr "Museo / Galería de Arte"
98
+
99
+ #: ../lib/core.php:140
100
+ msgid "Local business"
101
+ msgstr "Negocio Local"
102
+
103
+ #: ../lib/core.php:141
104
+ msgid "Concert venue"
105
+ msgstr "Foro de Conciertos"
106
+
107
+ #: ../lib/core.php:142
108
+ msgid "Public places"
109
+ msgstr "Lugar publico"
110
+
111
+ #: ../templates/default/band.php:29 ../templates/default/com-page.php:20
112
+ #: ../templates/default/other.php:33
113
+ #, php-format
114
+ msgid "%d people like this."
115
+ msgstr "a %d les gusta esto."
116
+
117
+ #: ../templates/default/event.php:33
118
+ msgid "Creator: "
119
+ msgstr "Creador:"
120
+
121
+ #~ msgid "Something is wrong with this link"
122
+ #~ msgstr "Algo le pasa a este link"
lang/wp-embed-fb.mo ADDED
Binary file
lang/wp-embed-fb.pot ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wp-embed-fb\n"
4
+ "POT-Creation-Date: 2014-02-28 20:05-0600\n"
5
+ "PO-Revision-Date: 2014-02-28 20:05-0600\n"
6
+ "Last-Translator: Miguel Sirvent <miguel.sirvent@gmail.com>\n"
7
+ "Language-Team: Miguel Sirvent <miguel.sirvent@gmail.com>\n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.4\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+
19
+ #: ../lib/admin.php:67
20
+ msgid "Facebook application data"
21
+ msgstr ""
22
+
23
+ #: ../lib/admin.php:84
24
+ msgid "Other Options"
25
+ msgstr ""
26
+
27
+ #: ../lib/admin.php:90
28
+ msgid "Fb Cover Embed Width"
29
+ msgstr ""
30
+
31
+ #: ../lib/admin.php:96
32
+ msgid "Enqueue Styles"
33
+ msgstr ""
34
+
35
+ #: ../lib/admin.php:104
36
+ msgid "Save"
37
+ msgstr ""
38
+
39
+ #: ../lib/admin.php:112
40
+ msgid "Customize"
41
+ msgstr ""
42
+
43
+ #: ../lib/admin.php:115
44
+ msgid "Support"
45
+ msgstr ""
46
+
47
+ #: ../lib/admin.php:118
48
+ msgid "Plugin Web Site"
49
+ msgstr ""
50
+
51
+ #: ../lib/admin.php:126
52
+ msgid "Donate!"
53
+ msgstr ""
54
+
55
+ #: ../lib/admin.php:127
56
+ msgid "Help me keep this plugin up to date"
57
+ msgstr ""
58
+
59
+ #: ../lib/admin.php:129
60
+ msgid "Click the taco !"
61
+ msgstr ""
62
+
63
+ #: ../lib/admin.php:130
64
+ msgid "3 USD Minimun Suggested Donation"
65
+ msgstr ""
66
+
67
+ #: ../lib/admin.php:140
68
+ msgid "Searching for the Premium version ?"
69
+ msgstr ""
70
+
71
+ #: ../lib/admin.php:143
72
+ msgid "Custom templates"
73
+ msgstr ""
74
+
75
+ #: ../lib/admin.php:146
76
+ msgid "Compatibility with all themes imaginable"
77
+ msgstr ""
78
+
79
+ #: ../lib/admin.php:149
80
+ msgid "Multiple fb app id's per each multisite site"
81
+ msgstr ""
82
+
83
+ #: ../lib/admin.php:152
84
+ msgid "Comming Soon"
85
+ msgstr ""
86
+
87
+ #: ../lib/core.php:89
88
+ msgid "This facebook link is not public"
89
+ msgstr ""
90
+
91
+ #: ../lib/core.php:134
92
+ msgid "Web Site"
93
+ msgstr ""
94
+
95
+ #: ../lib/core.php:139
96
+ msgid "Museum/art gallery"
97
+ msgstr ""
98
+
99
+ #: ../lib/core.php:140
100
+ msgid "Local business"
101
+ msgstr ""
102
+
103
+ #: ../lib/core.php:141
104
+ msgid "Concert venue"
105
+ msgstr ""
106
+
107
+ #: ../lib/core.php:142
108
+ msgid "Public places"
109
+ msgstr ""
110
+
111
+ #: ../templates/default/band.php:29 ../templates/default/com-page.php:20
112
+ #: ../templates/default/other.php:33
113
+ #, php-format
114
+ msgid "%d people like this."
115
+ msgstr ""
116
+
117
+ #: ../templates/default/event.php:33
118
+ msgid "Creator: "
119
+ msgstr ""
lib/admin.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmbFbAdmin{
3
+ static function add_page(){
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_enqueue_style'])){
34
+ if ( !is_multisite() )
35
+ update_option('wpemfb_enqueue_style', 'true');
36
+ else // TODO: multiple fb apps for each site
37
+ update_site_option('wpemfb_enqueue_style', 'true');
38
+ }else{
39
+ if ( !is_multisite() ) {
40
+ update_option('wpemfb_enqueue_style', 'false');
41
+ }
42
+ else { // TODO: multiple fb apps for each site
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>
59
+ <div class="welcome-panel">
60
+ <div class="welcome-panel-content">
61
+ <div class="welcome-panel-column-container">
62
+ <div class="welcome-panel-column">
63
+ <form id="config-form" action="#" method="post">
64
+ <table class="form-table">
65
+ <tbody>
66
+ <tr>
67
+ <h3><?php _e('Facebook application data', 'wp-embed-fb') ?></h3>
68
+ </tr>
69
+ <tr valign="middle">
70
+ <th>App ID</th>
71
+ <td>
72
+ <input type="text" name="appid" id="appid" class="input" required="" value="<?php echo get_option('wpemfb_app_id') ?>" />
73
+ </td>
74
+ </tr>
75
+ <tr valign="middle">
76
+ <th>App Secret</th>
77
+ <td>
78
+ <input type="text" name="appsecret" id="appsecret" class="input" required="" value="<?php echo get_option('wpemfb_app_secret') ?>" />
79
+ </td>
80
+ </tr>
81
+ <tr>
82
+ <th>
83
+ <td>
84
+ <h4><?php _e("Other Options", 'wp-embed-fb') ?></h4>
85
+ </td>
86
+
87
+ </th>
88
+ </tr>
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'); ?>
104
+ <input type="submit" name="submit" id="save-config" class="button button-primary button-hero" value="<?php _e('Save','wp-embed-fb') ?>" />
105
+ </td>
106
+ </tr>
107
+ </tbody>
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>
122
+ <div class="welcome-panel-column">
123
+ <p></p>
124
+ </div>
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">
135
+ <input type="image" src="http://saliuitl.org/img/taco.png" border="0" name="submit" alt="PayPal, la forma más segura y rápida de pagar en línea.">
136
+ <img alt="" border="0" src="https://www.paypalobjects.com/es_XC/i/scr/pixel.gif" width="1" height="1">
137
+ </form>
138
+ <img src="<?php echo plugins_url('/img/paypal.png', __FILE__) ?>" width="50px" />
139
+ <p>
140
+ <h3 style="color:red;"><?php _e('Searching for the Premium version ?', 'wp-embed-fb') ?></h3>
141
+ <ul>
142
+ <li>
143
+ <?php _e('Custom templates', 'wp-embed-fb') ?>
144
+ </li>
145
+ <li>
146
+ <?php _e('Compatibility with all themes imaginable', 'wp-embed-fb') ?>
147
+ </li>
148
+ <li>
149
+ <?php _e("Multiple fb app id's per each multisite site", 'wp-embed-fb') ?>
150
+ </li>
151
+ </ul>
152
+ <h4 style="color:#01007E;"><?php _e('Comming Soon', 'wp-embed-fb') ?></h4>
153
+ </p>
154
+ <p style="text-align: center">
155
+ <img src="<?php echo plugins_url('/img/hechoenmexico.png', __FILE__) ?>" width="80px" />
156
+ </p>
157
+
158
+ </div>
159
+ <!-- <div class="welcome-panel-column welcome-panel-last"> -->
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </div><!-- .wrap -->
164
+
165
+
166
+ <?php
167
+ }
168
+ }
169
+ ?>
lib/core.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) {
8
+ if ( !is_multisite() ) {
9
+ $opt = get_option($option);
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);
17
+ }
18
+ }
19
+ return;
20
+ }
21
+ static function uninstall(){
22
+ $defaults = self::getdefaults();
23
+ foreach ($defaults as $option ) {
24
+ if ( !is_multisite() ) {
25
+ delete_option($option);
26
+ }
27
+ else { // TODO: multiple fb apps for each site
28
+ delete_site_option($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
+ );
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);
64
+ if(isset($vars['fbid'])){ //for photos deprecated by fb
65
+ $fb_id = $vars['fbid'];
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');
99
+ if(isset($fb_data['start_time'])) { //is event
100
+ $template = self::locate_template('event');
101
+ //} elseif(isset($fb_data['source'])) { //is photo Deprecated by facebook now embed post
102
+ //$template = self::locate_template('photo');
103
+ } elseif(isset($fb_data['category'])) { //is a page
104
+ if(isset($fb_data['is_community_page']) && $fb_data['is_community_page'] == "1" ){
105
+ $template = self::locate_template('com-page'); //is community page
106
+ }else {
107
+ switch ($fb_data['category']) {
108
+ case 'Musician/band': //is a band page
109
+ $template = self::locate_template('band');
110
+ break; //TODO: add action to add more categories
111
+ default:
112
+ $template = self::locate_template('other');
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]);
133
+ $cleaner = str_replace(array('http://', 'https://'), array('',''), $clean[0]);
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') ,
140
+ __('Local business'),
141
+ __('Concert venue'),
142
+ __('Public places'),
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(){
156
+ if(!class_exists('Facebook'))
157
+ require('fb/facebook.php');
158
+ $config = array();
159
+ $config['appId'] = get_option('wpemfb_app_id');
160
+ $config['secret'] = get_option('wpemfb_app_secret');
161
+ $config['fileUpload'] = false; // optional
162
+ if($config['appId'] != '0' && $config['secret'] != '0' )
163
+ self::$fbsdk = new Facebook($config);
164
+ else
165
+ self::$fbsdk = 'unactive';
166
+ }
167
+ }
168
+ ?>
lib/fb/base_facebook.php ADDED
@@ -0,0 +1,1427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2011 Facebook, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ if (!function_exists('curl_init')) {
19
+ throw new Exception('Facebook needs the CURL PHP extension.');
20
+ }
21
+ if (!function_exists('json_decode')) {
22
+ throw new Exception('Facebook needs the JSON PHP extension.');
23
+ }
24
+
25
+ /**
26
+ * Thrown when an API call returns an exception.
27
+ *
28
+ * @author Naitik Shah <naitik@facebook.com>
29
+ */
30
+ class FacebookApiException extends Exception
31
+ {
32
+ /**
33
+ * The result from the API server that represents the exception information.
34
+ */
35
+ protected $result;
36
+
37
+ /**
38
+ * Make a new API Exception with the given result.
39
+ *
40
+ * @param array $result The result from the API server
41
+ */
42
+ public function __construct($result) {
43
+ $this->result = $result;
44
+
45
+ $code = isset($result['error_code']) ? $result['error_code'] : 0;
46
+
47
+ if (isset($result['error_description'])) {
48
+ // OAuth 2.0 Draft 10 style
49
+ $msg = $result['error_description'];
50
+ } else if (isset($result['error']) && is_array($result['error'])) {
51
+ // OAuth 2.0 Draft 00 style
52
+ $msg = $result['error']['message'];
53
+ } else if (isset($result['error_msg'])) {
54
+ // Rest server style
55
+ $msg = $result['error_msg'];
56
+ } else {
57
+ $msg = 'Unknown Error. Check getResult()';
58
+ }
59
+
60
+ parent::__construct($msg, $code);
61
+ }
62
+
63
+ /**
64
+ * Return the associated result object returned by the API server.
65
+ *
66
+ * @return array The result from the API server
67
+ */
68
+ public function getResult() {
69
+ return $this->result;
70
+ }
71
+
72
+ /**
73
+ * Returns the associated type for the error. This will default to
74
+ * 'Exception' when a type is not available.
75
+ *
76
+ * @return string
77
+ */
78
+ public function getType() {
79
+ if (isset($this->result['error'])) {
80
+ $error = $this->result['error'];
81
+ if (is_string($error)) {
82
+ // OAuth 2.0 Draft 10 style
83
+ return $error;
84
+ } else if (is_array($error)) {
85
+ // OAuth 2.0 Draft 00 style
86
+ if (isset($error['type'])) {
87
+ return $error['type'];
88
+ }
89
+ }
90
+ }
91
+
92
+ return 'Exception';
93
+ }
94
+
95
+ /**
96
+ * To make debugging easier.
97
+ *
98
+ * @return string The string representation of the error
99
+ */
100
+ public function __toString() {
101
+ $str = $this->getType() . ': ';
102
+ if ($this->code != 0) {
103
+ $str .= $this->code . ': ';
104
+ }
105
+ return $str . $this->message;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Provides access to the Facebook Platform. This class provides
111
+ * a majority of the functionality needed, but the class is abstract
112
+ * because it is designed to be sub-classed. The subclass must
113
+ * implement the four abstract methods listed at the bottom of
114
+ * the file.
115
+ *
116
+ * @author Naitik Shah <naitik@facebook.com>
117
+ */
118
+ abstract class BaseFacebook
119
+ {
120
+ /**
121
+ * Version.
122
+ */
123
+ const VERSION = '3.2.0';
124
+
125
+ /**
126
+ * Signed Request Algorithm.
127
+ */
128
+ const SIGNED_REQUEST_ALGORITHM = 'HMAC-SHA256';
129
+
130
+ /**
131
+ * Default options for curl.
132
+ */
133
+ public static $CURL_OPTS = array(
134
+ CURLOPT_CONNECTTIMEOUT => 10,
135
+ CURLOPT_RETURNTRANSFER => true,
136
+ CURLOPT_TIMEOUT => 60,
137
+ CURLOPT_USERAGENT => 'facebook-php-3.2',
138
+ );
139
+
140
+ /**
141
+ * List of query parameters that get automatically dropped when rebuilding
142
+ * the current URL.
143
+ */
144
+ protected static $DROP_QUERY_PARAMS = array(
145
+ 'code',
146
+ 'state',
147
+ 'signed_request',
148
+ );
149
+
150
+ /**
151
+ * Maps aliases to Facebook domains.
152
+ */
153
+ public static $DOMAIN_MAP = array(
154
+ 'api' => 'https://api.facebook.com/',
155
+ 'api_video' => 'https://api-video.facebook.com/',
156
+ 'api_read' => 'https://api-read.facebook.com/',
157
+ 'graph' => 'https://graph.facebook.com/',
158
+ 'graph_video' => 'https://graph-video.facebook.com/',
159
+ 'www' => 'https://www.facebook.com/',
160
+ );
161
+
162
+ /**
163
+ * The Application ID.
164
+ *
165
+ * @var string
166
+ */
167
+ protected $appId;
168
+
169
+ /**
170
+ * The Application App Secret.
171
+ *
172
+ * @var string
173
+ */
174
+ protected $appSecret;
175
+
176
+ /**
177
+ * The ID of the Facebook user, or 0 if the user is logged out.
178
+ *
179
+ * @var integer
180
+ */
181
+ protected $user;
182
+
183
+ /**
184
+ * The data from the signed_request token.
185
+ */
186
+ protected $signedRequest;
187
+
188
+ /**
189
+ * A CSRF state variable to assist in the defense against CSRF attacks.
190
+ */
191
+ protected $state;
192
+
193
+ /**
194
+ * The OAuth access token received in exchange for a valid authorization
195
+ * code. null means the access token has yet to be determined.
196
+ *
197
+ * @var string
198
+ */
199
+ protected $accessToken = null;
200
+
201
+ /**
202
+ * Indicates if the CURL based @ syntax for file uploads is enabled.
203
+ *
204
+ * @var boolean
205
+ */
206
+ protected $fileUploadSupport = false;
207
+
208
+ /**
209
+ * Indicates if we trust HTTP_X_FORWARDED_* headers.
210
+ *
211
+ * @var boolean
212
+ */
213
+ protected $trustForwarded = false;
214
+
215
+ /**
216
+ * Initialize a Facebook Application.
217
+ *
218
+ * The configuration:
219
+ * - appId: the application ID
220
+ * - secret: the application secret
221
+ * - fileUpload: (optional) boolean indicating if file uploads are enabled
222
+ *
223
+ * @param array $config The application configuration
224
+ */
225
+ public function __construct($config) {
226
+ $this->setAppId($config['appId']);
227
+ $this->setAppSecret($config['secret']);
228
+ if (isset($config['fileUpload'])) {
229
+ $this->setFileUploadSupport($config['fileUpload']);
230
+ }
231
+ if (isset($config['trustForwarded']) && $config['trustForwarded']) {
232
+ $this->trustForwarded = true;
233
+ }
234
+ $state = $this->getPersistentData('state');
235
+ if (!empty($state)) {
236
+ $this->state = $state;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Set the Application ID.
242
+ *
243
+ * @param string $appId The Application ID
244
+ * @return BaseFacebook
245
+ */
246
+ public function setAppId($appId) {
247
+ $this->appId = $appId;
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Get the Application ID.
253
+ *
254
+ * @return string the Application ID
255
+ */
256
+ public function getAppId() {
257
+ return $this->appId;
258
+ }
259
+
260
+ /**
261
+ * Set the App Secret.
262
+ *
263
+ * @param string $apiSecret The App Secret
264
+ * @return BaseFacebook
265
+ * @deprecated
266
+ */
267
+ public function setApiSecret($apiSecret) {
268
+ $this->setAppSecret($apiSecret);
269
+ return $this;
270
+ }
271
+
272
+ /**
273
+ * Set the App Secret.
274
+ *
275
+ * @param string $appSecret The App Secret
276
+ * @return BaseFacebook
277
+ */
278
+ public function setAppSecret($appSecret) {
279
+ $this->appSecret = $appSecret;
280
+ return $this;
281
+ }
282
+
283
+ /**
284
+ * Get the App Secret.
285
+ *
286
+ * @return string the App Secret
287
+ * @deprecated
288
+ */
289
+ public function getApiSecret() {
290
+ return $this->getAppSecret();
291
+ }
292
+
293
+ /**
294
+ * Get the App Secret.
295
+ *
296
+ * @return string the App Secret
297
+ */
298
+ public function getAppSecret() {
299
+ return $this->appSecret;
300
+ }
301
+
302
+ /**
303
+ * Set the file upload support status.
304
+ *
305
+ * @param boolean $fileUploadSupport The file upload support status.
306
+ * @return BaseFacebook
307
+ */
308
+ public function setFileUploadSupport($fileUploadSupport) {
309
+ $this->fileUploadSupport = $fileUploadSupport;
310
+ return $this;
311
+ }
312
+
313
+ /**
314
+ * Get the file upload support status.
315
+ *
316
+ * @return boolean true if and only if the server supports file upload.
317
+ */
318
+ public function getFileUploadSupport() {
319
+ return $this->fileUploadSupport;
320
+ }
321
+
322
+ /**
323
+ * DEPRECATED! Please use getFileUploadSupport instead.
324
+ *
325
+ * Get the file upload support status.
326
+ *
327
+ * @return boolean true if and only if the server supports file upload.
328
+ */
329
+ public function useFileUploadSupport() {
330
+ return $this->getFileUploadSupport();
331
+ }
332
+
333
+ /**
334
+ * Sets the access token for api calls. Use this if you get
335
+ * your access token by other means and just want the SDK
336
+ * to use it.
337
+ *
338
+ * @param string $access_token an access token.
339
+ * @return BaseFacebook
340
+ */
341
+ public function setAccessToken($access_token) {
342
+ $this->accessToken = $access_token;
343
+ return $this;
344
+ }
345
+
346
+ /**
347
+ * Extend an access token, while removing the short-lived token that might
348
+ * have been generated via client-side flow. Thanks to http://bit.ly/b0Pt0H
349
+ * for the workaround.
350
+ */
351
+ public function setExtendedAccessToken() {
352
+ try {
353
+ // need to circumvent json_decode by calling _oauthRequest
354
+ // directly, since response isn't JSON format.
355
+ $access_token_response = $this->_oauthRequest(
356
+ $this->getUrl('graph', '/oauth/access_token'),
357
+ $params = array(
358
+ 'client_id' => $this->getAppId(),
359
+ 'client_secret' => $this->getAppSecret(),
360
+ 'grant_type' => 'fb_exchange_token',
361
+ 'fb_exchange_token' => $this->getAccessToken(),
362
+ )
363
+ );
364
+ }
365
+ catch (FacebookApiException $e) {
366
+ // most likely that user very recently revoked authorization.
367
+ // In any event, we don't have an access token, so say so.
368
+ return false;
369
+ }
370
+
371
+ if (empty($access_token_response)) {
372
+ return false;
373
+ }
374
+
375
+ $response_params = array();
376
+ parse_str($access_token_response, $response_params);
377
+
378
+ if (!isset($response_params['access_token'])) {
379
+ return false;
380
+ }
381
+
382
+ $this->destroySession();
383
+
384
+ $this->setPersistentData(
385
+ 'access_token', $response_params['access_token']
386
+ );
387
+ }
388
+
389
+ /**
390
+ * Determines the access token that should be used for API calls.
391
+ * The first time this is called, $this->accessToken is set equal
392
+ * to either a valid user access token, or it's set to the application
393
+ * access token if a valid user access token wasn't available. Subsequent
394
+ * calls return whatever the first call returned.
395
+ *
396
+ * @return string The access token
397
+ */
398
+ public function getAccessToken() {
399
+ if ($this->accessToken !== null) {
400
+ // we've done this already and cached it. Just return.
401
+ return $this->accessToken;
402
+ }
403
+
404
+ // first establish access token to be the application
405
+ // access token, in case we navigate to the /oauth/access_token
406
+ // endpoint, where SOME access token is required.
407
+ $this->setAccessToken($this->getApplicationAccessToken());
408
+ $user_access_token = $this->getUserAccessToken();
409
+ if ($user_access_token) {
410
+ $this->setAccessToken($user_access_token);
411
+ }
412
+
413
+ return $this->accessToken;
414
+ }
415
+
416
+ /**
417
+ * Determines and returns the user access token, first using
418
+ * the signed request if present, and then falling back on
419
+ * the authorization code if present. The intent is to
420
+ * return a valid user access token, or false if one is determined
421
+ * to not be available.
422
+ *
423
+ * @return string A valid user access token, or false if one
424
+ * could not be determined.
425
+ */
426
+ protected function getUserAccessToken() {
427
+ // first, consider a signed request if it's supplied.
428
+ // if there is a signed request, then it alone determines
429
+ // the access token.
430
+ $signed_request = $this->getSignedRequest();
431
+ if ($signed_request) {
432
+ // apps.facebook.com hands the access_token in the signed_request
433
+ if (array_key_exists('oauth_token', $signed_request)) {
434
+ $access_token = $signed_request['oauth_token'];
435
+ $this->setPersistentData('access_token', $access_token);
436
+ return $access_token;
437
+ }
438
+
439
+ // the JS SDK puts a code in with the redirect_uri of ''
440
+ if (array_key_exists('code', $signed_request)) {
441
+ $code = $signed_request['code'];
442
+ $access_token = $this->getAccessTokenFromCode($code, '');
443
+ if ($access_token) {
444
+ $this->setPersistentData('code', $code);
445
+ $this->setPersistentData('access_token', $access_token);
446
+ return $access_token;
447
+ }
448
+ }
449
+
450
+ // signed request states there's no access token, so anything
451
+ // stored should be cleared.
452
+ $this->clearAllPersistentData();
453
+ return false; // respect the signed request's data, even
454
+ // if there's an authorization code or something else
455
+ }
456
+
457
+ $code = $this->getCode();
458
+ if ($code && $code != $this->getPersistentData('code')) {
459
+ $access_token = $this->getAccessTokenFromCode($code);
460
+ if ($access_token) {
461
+ $this->setPersistentData('code', $code);
462
+ $this->setPersistentData('access_token', $access_token);
463
+ return $access_token;
464
+ }
465
+
466
+ // code was bogus, so everything based on it should be invalidated.
467
+ $this->clearAllPersistentData();
468
+ return false;
469
+ }
470
+
471
+ // as a fallback, just return whatever is in the persistent
472
+ // store, knowing nothing explicit (signed request, authorization
473
+ // code, etc.) was present to shadow it (or we saw a code in $_REQUEST,
474
+ // but it's the same as what's in the persistent store)
475
+ return $this->getPersistentData('access_token');
476
+ }
477
+
478
+ /**
479
+ * Retrieve the signed request, either from a request parameter or,
480
+ * if not present, from a cookie.
481
+ *
482
+ * @return string the signed request, if available, or null otherwise.
483
+ */
484
+ public function getSignedRequest() {
485
+ if (!$this->signedRequest) {
486
+ if (isset($_REQUEST['signed_request'])) {
487
+ $this->signedRequest = $this->parseSignedRequest(
488
+ $_REQUEST['signed_request']);
489
+ } else if (isset($_COOKIE[$this->getSignedRequestCookieName()])) {
490
+ $this->signedRequest = $this->parseSignedRequest(
491
+ $_COOKIE[$this->getSignedRequestCookieName()]);
492
+ }
493
+ }
494
+ return $this->signedRequest;
495
+ }
496
+
497
+ /**
498
+ * Get the UID of the connected user, or 0
499
+ * if the Facebook user is not connected.
500
+ *
501
+ * @return string the UID if available.
502
+ */
503
+ public function getUser() {
504
+ if ($this->user !== null) {
505
+ // we've already determined this and cached the value.
506
+ return $this->user;
507
+ }
508
+
509
+ return $this->user = $this->getUserFromAvailableData();
510
+ }
511
+
512
+ /**
513
+ * Determines the connected user by first examining any signed
514
+ * requests, then considering an authorization code, and then
515
+ * falling back to any persistent store storing the user.
516
+ *
517
+ * @return integer The id of the connected Facebook user,
518
+ * or 0 if no such user exists.
519
+ */
520
+ protected function getUserFromAvailableData() {
521
+ // if a signed request is supplied, then it solely determines
522
+ // who the user is.
523
+ $signed_request = $this->getSignedRequest();
524
+ if ($signed_request) {
525
+ if (array_key_exists('user_id', $signed_request)) {
526
+ $user = $signed_request['user_id'];
527
+ $this->setPersistentData('user_id', $signed_request['user_id']);
528
+ return $user;
529
+ }
530
+
531
+ // if the signed request didn't present a user id, then invalidate
532
+ // all entries in any persistent store.
533
+ $this->clearAllPersistentData();
534
+ return 0;
535
+ }
536
+
537
+ $user = $this->getPersistentData('user_id', $default = 0);
538
+ $persisted_access_token = $this->getPersistentData('access_token');
539
+
540
+ // use access_token to fetch user id if we have a user access_token, or if
541
+ // the cached access token has changed.
542
+ $access_token = $this->getAccessToken();
543
+ if ($access_token &&
544
+ $access_token != $this->getApplicationAccessToken() &&
545
+ !($user && $persisted_access_token == $access_token)) {
546
+ $user = $this->getUserFromAccessToken();
547
+ if ($user) {
548
+ $this->setPersistentData('user_id', $user);
549
+ } else {
550
+ $this->clearAllPersistentData();
551
+ }
552
+ }
553
+
554
+ return $user;
555
+ }
556
+
557
+ /**
558
+ * Get a Login URL for use with redirects. By default, full page redirect is
559
+ * assumed. If you are using the generated URL with a window.open() call in
560
+ * JavaScript, you can pass in display=popup as part of the $params.
561
+ *
562
+ * The parameters:
563
+ * - redirect_uri: the url to go to after a successful login
564
+ * - scope: comma separated list of requested extended perms
565
+ *
566
+ * @param array $params Provide custom parameters
567
+ * @return string The URL for the login flow
568
+ */
569
+ public function getLoginUrl($params=array()) {
570
+ $this->establishCSRFTokenState();
571
+ $currentUrl = $this->getCurrentUrl();
572
+
573
+ // if 'scope' is passed as an array, convert to comma separated list
574
+ $scopeParams = isset($params['scope']) ? $params['scope'] : null;
575
+ if ($scopeParams && is_array($scopeParams)) {
576
+ $params['scope'] = implode(',', $scopeParams);
577
+ }
578
+
579
+ return $this->getUrl(
580
+ 'www',
581
+ 'dialog/oauth',
582
+ array_merge(array(
583
+ 'client_id' => $this->getAppId(),
584
+ 'redirect_uri' => $currentUrl, // possibly overwritten
585
+ 'state' => $this->state),
586
+ $params));
587
+ }
588
+
589
+ /**
590
+ * Get a Logout URL suitable for use with redirects.
591
+ *
592
+ * The parameters:
593
+ * - next: the url to go to after a successful logout
594
+ *
595
+ * @param array $params Provide custom parameters
596
+ * @return string The URL for the logout flow
597
+ */
598
+ public function getLogoutUrl($params=array()) {
599
+ return $this->getUrl(
600
+ 'www',
601
+ 'logout.php',
602
+ array_merge(array(
603
+ 'next' => $this->getCurrentUrl(),
604
+ 'access_token' => $this->getUserAccessToken(),
605
+ ), $params)
606
+ );
607
+ }
608
+
609
+ /**
610
+ * Get a login status URL to fetch the status from Facebook.
611
+ *
612
+ * The parameters:
613
+ * - ok_session: the URL to go to if a session is found
614
+ * - no_session: the URL to go to if the user is not connected
615
+ * - no_user: the URL to go to if the user is not signed into facebook
616
+ *
617
+ * @param array $params Provide custom parameters
618
+ * @return string The URL for the logout flow
619
+ */
620
+ public function getLoginStatusUrl($params=array()) {
621
+ return $this->getUrl(
622
+ 'www',
623
+ 'extern/login_status.php',
624
+ array_merge(array(
625
+ 'api_key' => $this->getAppId(),
626
+ 'no_session' => $this->getCurrentUrl(),
627
+ 'no_user' => $this->getCurrentUrl(),
628
+ 'ok_session' => $this->getCurrentUrl(),
629
+ 'session_version' => 3,
630
+ ), $params)
631
+ );
632
+ }
633
+
634
+ /**
635
+ * Make an API call.
636
+ *
637
+ * @return mixed The decoded response
638
+ */
639
+ public function api(/* polymorphic */) {
640
+ $args = func_get_args();
641
+ if (is_array($args[0])) {
642
+ return $this->_restserver($args[0]);
643
+ } else {
644
+ return call_user_func_array(array($this, '_graph'), $args);
645
+ }
646
+ }
647
+
648
+ /**
649
+ * Constructs and returns the name of the cookie that
650
+ * potentially houses the signed request for the app user.
651
+ * The cookie is not set by the BaseFacebook class, but
652
+ * it may be set by the JavaScript SDK.
653
+ *
654
+ * @return string the name of the cookie that would house
655
+ * the signed request value.
656
+ */
657
+ protected function getSignedRequestCookieName() {
658
+ return 'fbsr_'.$this->getAppId();
659
+ }
660
+
661
+ /**
662
+ * Constructs and returns the name of the coookie that potentially contain
663
+ * metadata. The cookie is not set by the BaseFacebook class, but it may be
664
+ * set by the JavaScript SDK.
665
+ *
666
+ * @return string the name of the cookie that would house metadata.
667
+ */
668
+ protected function getMetadataCookieName() {
669
+ return 'fbm_'.$this->getAppId();
670
+ }
671
+
672
+ /**
673
+ * Get the authorization code from the query parameters, if it exists,
674
+ * and otherwise return false to signal no authorization code was
675
+ * discoverable.
676
+ *
677
+ * @return mixed The authorization code, or false if the authorization
678
+ * code could not be determined.
679
+ */
680
+ protected function getCode() {
681
+ if (isset($_REQUEST['code'])) {
682
+ if ($this->state !== null &&
683
+ isset($_REQUEST['state']) &&
684
+ $this->state === $_REQUEST['state']) {
685
+
686
+ // CSRF state has done its job, so clear it
687
+ $this->state = null;
688
+ $this->clearPersistentData('state');
689
+ return $_REQUEST['code'];
690
+ } else {
691
+ self::errorLog('CSRF state token does not match one provided.');
692
+ return false;
693
+ }
694
+ }
695
+
696
+ return false;
697
+ }
698
+
699
+ /**
700
+ * Retrieves the UID with the understanding that
701
+ * $this->accessToken has already been set and is
702
+ * seemingly legitimate. It relies on Facebook's Graph API
703
+ * to retrieve user information and then extract
704
+ * the user ID.
705
+ *
706
+ * @return integer Returns the UID of the Facebook user, or 0
707
+ * if the Facebook user could not be determined.
708
+ */
709
+ protected function getUserFromAccessToken() {
710
+ try {
711
+ $user_info = $this->api('/me');
712
+ return $user_info['id'];
713
+ } catch (FacebookApiException $e) {
714
+ return 0;
715
+ }
716
+ }
717
+
718
+ /**
719
+ * Returns the access token that should be used for logged out
720
+ * users when no authorization code is available.
721
+ *
722
+ * @return string The application access token, useful for gathering
723
+ * public information about users and applications.
724
+ */
725
+ protected function getApplicationAccessToken() {
726
+ return $this->appId.'|'.$this->appSecret;
727
+ }
728
+
729
+ /**
730
+ * Lays down a CSRF state token for this process.
731
+ *
732
+ * @return void
733
+ */
734
+ protected function establishCSRFTokenState() {
735
+ if ($this->state === null) {
736
+ $this->state = md5(uniqid(mt_rand(), true));
737
+ $this->setPersistentData('state', $this->state);
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Retrieves an access token for the given authorization code
743
+ * (previously generated from www.facebook.com on behalf of
744
+ * a specific user). The authorization code is sent to graph.facebook.com
745
+ * and a legitimate access token is generated provided the access token
746
+ * and the user for which it was generated all match, and the user is
747
+ * either logged in to Facebook or has granted an offline access permission.
748
+ *
749
+ * @param string $code An authorization code.
750
+ * @return mixed An access token exchanged for the authorization code, or
751
+ * false if an access token could not be generated.
752
+ */
753
+ protected function getAccessTokenFromCode($code, $redirect_uri = null) {
754
+ if (empty($code)) {
755
+ return false;
756
+ }
757
+
758
+ if ($redirect_uri === null) {
759
+ $redirect_uri = $this->getCurrentUrl();
760
+ }
761
+
762
+ try {
763
+ // need to circumvent json_decode by calling _oauthRequest
764
+ // directly, since response isn't JSON format.
765
+ $access_token_response =
766
+ $this->_oauthRequest(
767
+ $this->getUrl('graph', '/oauth/access_token'),
768
+ $params = array('client_id' => $this->getAppId(),
769
+ 'client_secret' => $this->getAppSecret(),
770
+ 'redirect_uri' => $redirect_uri,
771
+ 'code' => $code));
772
+ } catch (FacebookApiException $e) {
773
+ // most likely that user very recently revoked authorization.
774
+ // In any event, we don't have an access token, so say so.
775
+ return false;
776
+ }
777
+
778
+ if (empty($access_token_response)) {
779
+ return false;
780
+ }
781
+
782
+ $response_params = array();
783
+ parse_str($access_token_response, $response_params);
784
+ if (!isset($response_params['access_token'])) {
785
+ return false;
786
+ }
787
+
788
+ return $response_params['access_token'];
789
+ }
790
+
791
+ /**
792
+ * Invoke the old restserver.php endpoint.
793
+ *
794
+ * @param array $params Method call object
795
+ *
796
+ * @return mixed The decoded response object
797
+ * @throws FacebookApiException
798
+ */
799
+ protected function _restserver($params) {
800
+ // generic application level parameters
801
+ $params['api_key'] = $this->getAppId();
802
+ $params['format'] = 'json-strings';
803
+
804
+ $result = json_decode($this->_oauthRequest(
805
+ $this->getApiUrl($params['method']),
806
+ $params
807
+ ), true);
808
+
809
+ // results are returned, errors are thrown
810
+ if (is_array($result) && isset($result['error_code'])) {
811
+ $this->throwAPIException($result);
812
+ // @codeCoverageIgnoreStart
813
+ }
814
+ // @codeCoverageIgnoreEnd
815
+
816
+ $method = strtolower($params['method']);
817
+ if ($method === 'auth.expiresession' ||
818
+ $method === 'auth.revokeauthorization') {
819
+ $this->destroySession();
820
+ }
821
+
822
+ return $result;
823
+ }
824
+
825
+ /**
826
+ * Return true if this is video post.
827
+ *
828
+ * @param string $path The path
829
+ * @param string $method The http method (default 'GET')
830
+ *
831
+ * @return boolean true if this is video post
832
+ */
833
+ protected function isVideoPost($path, $method = 'GET') {
834
+ if ($method == 'POST' && preg_match("/^(\/)(.+)(\/)(videos)$/", $path)) {
835
+ return true;
836
+ }
837
+ return false;
838
+ }
839
+
840
+ /**
841
+ * Invoke the Graph API.
842
+ *
843
+ * @param string $path The path (required)
844
+ * @param string $method The http method (default 'GET')
845
+ * @param array $params The query/post data
846
+ *
847
+ * @return mixed The decoded response object
848
+ * @throws FacebookApiException
849
+ */
850
+ protected function _graph($path, $method = 'GET', $params = array()) {
851
+ if (is_array($method) && empty($params)) {
852
+ $params = $method;
853
+ $method = 'GET';
854
+ }
855
+ $params['method'] = $method; // method override as we always do a POST
856
+
857
+ if ($this->isVideoPost($path, $method)) {
858
+ $domainKey = 'graph_video';
859
+ } else {
860
+ $domainKey = 'graph';
861
+ }
862
+
863
+ $result = json_decode($this->_oauthRequest(
864
+ $this->getUrl($domainKey, $path),
865
+ $params
866
+ ), true);
867
+
868
+ // results are returned, errors are thrown
869
+ if (is_array($result) && isset($result['error'])) {
870
+ $this->throwAPIException($result);
871
+ // @codeCoverageIgnoreStart
872
+ }
873
+ // @codeCoverageIgnoreEnd
874
+
875
+ return $result;
876
+ }
877
+
878
+ /**
879
+ * Make a OAuth Request.
880
+ *
881
+ * @param string $url The path (required)
882
+ * @param array $params The query/post data
883
+ *
884
+ * @return string The decoded response object
885
+ * @throws FacebookApiException
886
+ */
887
+ protected function _oauthRequest($url, $params) {
888
+ if (!isset($params['access_token'])) {
889
+ $params['access_token'] = $this->getAccessToken();
890
+ }
891
+
892
+ // json_encode all params values that are not strings
893
+ foreach ($params as $key => $value) {
894
+ if (!is_string($value)) {
895
+ $params[$key] = json_encode($value);
896
+ }
897
+ }
898
+
899
+ return $this->makeRequest($url, $params);
900
+ }
901
+
902
+ /**
903
+ * Makes an HTTP request. This method can be overridden by subclasses if
904
+ * developers want to do fancier things or use something other than curl to
905
+ * make the request.
906
+ *
907
+ * @param string $url The URL to make the request to
908
+ * @param array $params The parameters to use for the POST body
909
+ * @param CurlHandler $ch Initialized curl handle
910
+ *
911
+ * @return string The response text
912
+ */
913
+ protected function makeRequest($url, $params, $ch=null) {
914
+ if (!$ch) {
915
+ $ch = curl_init();
916
+ }
917
+
918
+ $opts = self::$CURL_OPTS;
919
+ if ($this->getFileUploadSupport()) {
920
+ $opts[CURLOPT_POSTFIELDS] = $params;
921
+ } else {
922
+ $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
923
+ }
924
+ $opts[CURLOPT_URL] = $url;
925
+
926
+ // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
927
+ // for 2 seconds if the server does not support this header.
928
+ if (isset($opts[CURLOPT_HTTPHEADER])) {
929
+ $existing_headers = $opts[CURLOPT_HTTPHEADER];
930
+ $existing_headers[] = 'Expect:';
931
+ $opts[CURLOPT_HTTPHEADER] = $existing_headers;
932
+ } else {
933
+ $opts[CURLOPT_HTTPHEADER] = array('Expect:');
934
+ }
935
+ //no ssl verification xz3 modifications
936
+ $opts[CURLOPT_SSL_VERIFYPEER] = false;
937
+ //end modifications
938
+ curl_setopt_array($ch, $opts);
939
+ $result = curl_exec($ch);
940
+
941
+ if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
942
+ self::errorLog('Invalid or no certificate authority found, '.
943
+ 'using bundled information');
944
+ curl_setopt($ch, CURLOPT_CAINFO,
945
+ dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
946
+ $result = curl_exec($ch);
947
+ }
948
+
949
+ // With dual stacked DNS responses, it's possible for a server to
950
+ // have IPv6 enabled but not have IPv6 connectivity. If this is
951
+ // the case, curl will try IPv4 first and if that fails, then it will
952
+ // fall back to IPv6 and the error EHOSTUNREACH is returned by the
953
+ // operating system.
954
+ if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
955
+ $matches = array();
956
+ $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
957
+ if (preg_match($regex, curl_error($ch), $matches)) {
958
+ if (strlen(@inet_pton($matches[1])) === 16) {
959
+ self::errorLog('Invalid IPv6 configuration on server, '.
960
+ 'Please disable or get native IPv6 on your server.');
961
+ self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
962
+ curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
963
+ $result = curl_exec($ch);
964
+ }
965
+ }
966
+ }
967
+
968
+ if ($result === false) {
969
+ $e = new FacebookApiException(array(
970
+ 'error_code' => curl_errno($ch),
971
+ 'error' => array(
972
+ 'message' => curl_error($ch),
973
+ 'type' => 'CurlException',
974
+ ),
975
+ ));
976
+ curl_close($ch);
977
+ throw $e;
978
+ }
979
+ curl_close($ch);
980
+ return $result;
981
+ }
982
+
983
+ /**
984
+ * Parses a signed_request and validates the signature.
985
+ *
986
+ * @param string $signed_request A signed token
987
+ * @return array The payload inside it or null if the sig is wrong
988
+ */
989
+ protected function parseSignedRequest($signed_request) {
990
+ list($encoded_sig, $payload) = explode('.', $signed_request, 2);
991
+
992
+ // decode the data
993
+ $sig = self::base64UrlDecode($encoded_sig);
994
+ $data = json_decode(self::base64UrlDecode($payload), true);
995
+
996
+ if (strtoupper($data['algorithm']) !== self::SIGNED_REQUEST_ALGORITHM) {
997
+ self::errorLog(
998
+ 'Unknown algorithm. Expected ' . self::SIGNED_REQUEST_ALGORITHM);
999
+ return null;
1000
+ }
1001
+
1002
+ // check sig
1003
+ $expected_sig = hash_hmac('sha256', $payload,
1004
+ $this->getAppSecret(), $raw = true);
1005
+ if ($sig !== $expected_sig) {
1006
+ self::errorLog('Bad Signed JSON signature!');
1007
+ return null;
1008
+ }
1009
+
1010
+ return $data;
1011
+ }
1012
+
1013
+ /**
1014
+ * Makes a signed_request blob using the given data.
1015
+ *
1016
+ * @param array The data array.
1017
+ * @return string The signed request.
1018
+ */
1019
+ protected function makeSignedRequest($data) {
1020
+ if (!is_array($data)) {
1021
+ throw new InvalidArgumentException(
1022
+ 'makeSignedRequest expects an array. Got: ' . print_r($data, true));
1023
+ }
1024
+ $data['algorithm'] = self::SIGNED_REQUEST_ALGORITHM;
1025
+ $data['issued_at'] = time();
1026
+ $json = json_encode($data);
1027
+ $b64 = self::base64UrlEncode($json);
1028
+ $raw_sig = hash_hmac('sha256', $b64, $this->getAppSecret(), $raw = true);
1029
+ $sig = self::base64UrlEncode($raw_sig);
1030
+ return $sig.'.'.$b64;
1031
+ }
1032
+
1033
+ /**
1034
+ * Build the URL for api given parameters.
1035
+ *
1036
+ * @param $method String the method name.
1037
+ * @return string The URL for the given parameters
1038
+ */
1039
+ protected function getApiUrl($method) {
1040
+ static $READ_ONLY_CALLS =
1041
+ array('admin.getallocation' => 1,
1042
+ 'admin.getappproperties' => 1,
1043
+ 'admin.getbannedusers' => 1,
1044
+ 'admin.getlivestreamvialink' => 1,
1045
+ 'admin.getmetrics' => 1,
1046
+ 'admin.getrestrictioninfo' => 1,
1047
+ 'application.getpublicinfo' => 1,
1048
+ 'auth.getapppublickey' => 1,
1049
+ 'auth.getsession' => 1,
1050
+ 'auth.getsignedpublicsessiondata' => 1,
1051
+ 'comments.get' => 1,
1052
+ 'connect.getunconnectedfriendscount' => 1,
1053
+ 'dashboard.getactivity' => 1,
1054
+ 'dashboard.getcount' => 1,
1055
+ 'dashboard.getglobalnews' => 1,
1056
+ 'dashboard.getnews' => 1,
1057
+ 'dashboard.multigetcount' => 1,
1058
+ 'dashboard.multigetnews' => 1,
1059
+ 'data.getcookies' => 1,
1060
+ 'events.get' => 1,
1061
+ 'events.getmembers' => 1,
1062
+ 'fbml.getcustomtags' => 1,
1063
+ 'feed.getappfriendstories' => 1,
1064
+ 'feed.getregisteredtemplatebundlebyid' => 1,
1065
+ 'feed.getregisteredtemplatebundles' => 1,
1066
+ 'fql.multiquery' => 1,
1067
+ 'fql.query' => 1,
1068
+ 'friends.arefriends' => 1,
1069
+ 'friends.get' => 1,
1070
+ 'friends.getappusers' => 1,
1071
+ 'friends.getlists' => 1,
1072
+ 'friends.getmutualfriends' => 1,
1073
+ 'gifts.get' => 1,
1074
+ 'groups.get' => 1,
1075
+ 'groups.getmembers' => 1,
1076
+ 'intl.gettranslations' => 1,
1077
+ 'links.get' => 1,
1078
+ 'notes.get' => 1,
1079
+ 'notifications.get' => 1,
1080
+ 'pages.getinfo' => 1,
1081
+ 'pages.isadmin' => 1,
1082
+ 'pages.isappadded' => 1,
1083
+ 'pages.isfan' => 1,
1084
+ 'permissions.checkavailableapiaccess' => 1,
1085
+ 'permissions.checkgrantedapiaccess' => 1,
1086
+ 'photos.get' => 1,
1087
+ 'photos.getalbums' => 1,
1088
+ 'photos.gettags' => 1,
1089
+ 'profile.getinfo' => 1,
1090
+ 'profile.getinfooptions' => 1,
1091
+ 'stream.get' => 1,
1092
+ 'stream.getcomments' => 1,
1093
+ 'stream.getfilters' => 1,
1094
+ 'users.getinfo' => 1,
1095
+ 'users.getloggedinuser' => 1,
1096
+ 'users.getstandardinfo' => 1,
1097
+ 'users.hasapppermission' => 1,
1098
+ 'users.isappuser' => 1,
1099
+ 'users.isverified' => 1,
1100
+ 'video.getuploadlimits' => 1);
1101
+ $name = 'api';
1102
+ if (isset($READ_ONLY_CALLS[strtolower($method)])) {
1103
+ $name = 'api_read';
1104
+ } else if (strtolower($method) == 'video.upload') {
1105
+ $name = 'api_video';
1106
+ }
1107
+ return self::getUrl($name, 'restserver.php');
1108
+ }
1109
+
1110
+ /**
1111
+ * Build the URL for given domain alias, path and parameters.
1112
+ *
1113
+ * @param $name string The name of the domain
1114
+ * @param $path string Optional path (without a leading slash)
1115
+ * @param $params array Optional query parameters
1116
+ *
1117
+ * @return string The URL for the given parameters
1118
+ */
1119
+ protected function getUrl($name, $path='', $params=array()) {
1120
+ $url = self::$DOMAIN_MAP[$name];
1121
+ if ($path) {
1122
+ if ($path[0] === '/') {
1123
+ $path = substr($path, 1);
1124
+ }
1125
+ $url .= $path;
1126
+ }
1127
+ if ($params) {
1128
+ $url .= '?' . http_build_query($params, null, '&');
1129
+ }
1130
+
1131
+ return $url;
1132
+ }
1133
+
1134
+ protected function getHttpHost() {
1135
+ if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
1136
+ return $_SERVER['HTTP_X_FORWARDED_HOST'];
1137
+ }
1138
+ return $_SERVER['HTTP_HOST'];
1139
+ }
1140
+
1141
+ protected function getHttpProtocol() {
1142
+ if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
1143
+ if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
1144
+ return 'https';
1145
+ }
1146
+ return 'http';
1147
+ }
1148
+ if (isset($_SERVER['HTTPS']) &&
1149
+ ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) {
1150
+ return 'https';
1151
+ }
1152
+ return 'http';
1153
+ }
1154
+
1155
+ /**
1156
+ * Get the base domain used for the cookie.
1157
+ */
1158
+ protected function getBaseDomain() {
1159
+ // The base domain is stored in the metadata cookie if not we fallback
1160
+ // to the current hostname
1161
+ $metadata = $this->getMetadataCookie();
1162
+ if (array_key_exists('base_domain', $metadata) &&
1163
+ !empty($metadata['base_domain'])) {
1164
+ return trim($metadata['base_domain'], '.');
1165
+ }
1166
+ return $this->getHttpHost();
1167
+ }
1168
+
1169
+ /**
1170
+
1171
+ /**
1172
+ * Returns the Current URL, stripping it of known FB parameters that should
1173
+ * not persist.
1174
+ *
1175
+ * @return string The current URL
1176
+ */
1177
+ protected function getCurrentUrl() {
1178
+ $protocol = $this->getHttpProtocol() . '://';
1179
+ $host = $this->getHttpHost();
1180
+ $currentUrl = $protocol.$host.$_SERVER['REQUEST_URI'];
1181
+ $parts = parse_url($currentUrl);
1182
+
1183
+ $query = '';
1184
+ if (!empty($parts['query'])) {
1185
+ // drop known fb params
1186
+ $params = explode('&', $parts['query']);
1187
+ $retained_params = array();
1188
+ foreach ($params as $param) {
1189
+ if ($this->shouldRetainParam($param)) {
1190
+ $retained_params[] = $param;
1191
+ }
1192
+ }
1193
+
1194
+ if (!empty($retained_params)) {
1195
+ $query = '?'.implode($retained_params, '&');
1196
+ }
1197
+ }
1198
+
1199
+ // use port if non default
1200
+ $port =
1201
+ isset($parts['port']) &&
1202
+ (($protocol === 'http://' && $parts['port'] !== 80) ||
1203
+ ($protocol === 'https://' && $parts['port'] !== 443))
1204
+ ? ':' . $parts['port'] : '';
1205
+
1206
+ // rebuild
1207
+ return $protocol . $parts['host'] . $port . $parts['path'] . $query;
1208
+ }
1209
+
1210
+ /**
1211
+ * Returns true if and only if the key or key/value pair should
1212
+ * be retained as part of the query string. This amounts to
1213
+ * a brute-force search of the very small list of Facebook-specific
1214
+ * params that should be stripped out.
1215
+ *
1216
+ * @param string $param A key or key/value pair within a URL's query (e.g.
1217
+ * 'foo=a', 'foo=', or 'foo'.
1218
+ *
1219
+ * @return boolean
1220
+ */
1221
+ protected function shouldRetainParam($param) {
1222
+ foreach (self::$DROP_QUERY_PARAMS as $drop_query_param) {
1223
+ if (strpos($param, $drop_query_param.'=') === 0) {
1224
+ return false;
1225
+ }
1226
+ }
1227
+
1228
+ return true;
1229
+ }
1230
+
1231
+ /**
1232
+ * Analyzes the supplied result to see if it was thrown
1233
+ * because the access token is no longer valid. If that is
1234
+ * the case, then we destroy the session.
1235
+ *
1236
+ * @param $result array A record storing the error message returned
1237
+ * by a failed API call.
1238
+ */
1239
+ protected function throwAPIException($result) {
1240
+ $e = new FacebookApiException($result);
1241
+ switch ($e->getType()) {
1242
+ // OAuth 2.0 Draft 00 style
1243
+ case 'OAuthException':
1244
+ // OAuth 2.0 Draft 10 style
1245
+ case 'invalid_token':
1246
+ // REST server errors are just Exceptions
1247
+ case 'Exception':
1248
+ $message = $e->getMessage();
1249
+ if ((strpos($message, 'Error validating access token') !== false) ||
1250
+ (strpos($message, 'Invalid OAuth access token') !== false) ||
1251
+ (strpos($message, 'An active access token must be used') !== false)
1252
+ ) {
1253
+ $this->destroySession();
1254
+ }
1255
+ break;
1256
+ }
1257
+
1258
+ throw $e;
1259
+ }
1260
+
1261
+
1262
+ /**
1263
+ * Prints to the error log if you aren't in command line mode.
1264
+ *
1265
+ * @param string $msg Log message
1266
+ */
1267
+ protected static function errorLog($msg) {
1268
+ // disable error log if we are running in a CLI environment
1269
+ // @codeCoverageIgnoreStart
1270
+ if (php_sapi_name() != 'cli') {
1271
+ error_log($msg);
1272
+ }
1273
+ // uncomment this if you want to see the errors on the page
1274
+ // print 'error_log: '.$msg."\n";
1275
+ // @codeCoverageIgnoreEnd
1276
+ }
1277
+
1278
+ /**
1279
+ * Base64 encoding that doesn't need to be urlencode()ed.
1280
+ * Exactly the same as base64_encode except it uses
1281
+ * - instead of +
1282
+ * _ instead of /
1283
+ * No padded =
1284
+ *
1285
+ * @param string $input base64UrlEncoded string
1286
+ * @return string
1287
+ */
1288
+ protected static function base64UrlDecode($input) {
1289
+ return base64_decode(strtr($input, '-_', '+/'));
1290
+ }
1291
+
1292
+ /**
1293
+ * Base64 encoding that doesn't need to be urlencode()ed.
1294
+ * Exactly the same as base64_encode except it uses
1295
+ * - instead of +
1296
+ * _ instead of /
1297
+ *
1298
+ * @param string $input string
1299
+ * @return string base64Url encoded string
1300
+ */
1301
+ protected static function base64UrlEncode($input) {
1302
+ $str = strtr(base64_encode($input), '+/', '-_');
1303
+ $str = str_replace('=', '', $str);
1304
+ return $str;
1305
+ }
1306
+
1307
+ /**
1308
+ * Destroy the current session
1309
+ */
1310
+ public function destroySession() {
1311
+ $this->accessToken = null;
1312
+ $this->signedRequest = null;
1313
+ $this->user = null;
1314
+ $this->clearAllPersistentData();
1315
+
1316
+ // Javascript sets a cookie that will be used in getSignedRequest that we
1317
+ // need to clear if we can
1318
+ $cookie_name = $this->getSignedRequestCookieName();
1319
+ if (array_key_exists($cookie_name, $_COOKIE)) {
1320
+ unset($_COOKIE[$cookie_name]);
1321
+ if (!headers_sent()) {
1322
+ $base_domain = $this->getBaseDomain();
1323
+ setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
1324
+ } else {
1325
+ // @codeCoverageIgnoreStart
1326
+ self::errorLog(
1327
+ 'There exists a cookie that we wanted to clear that we couldn\'t '.
1328
+ 'clear because headers was already sent. Make sure to do the first '.
1329
+ 'API call before outputing anything.'
1330
+ );
1331
+ // @codeCoverageIgnoreEnd
1332
+ }
1333
+ }
1334
+ }
1335
+
1336
+ /**
1337
+ * Parses the metadata cookie that our Javascript API set
1338
+ *
1339
+ * @return an array mapping key to value
1340
+ */
1341
+ protected function getMetadataCookie() {
1342
+ $cookie_name = $this->getMetadataCookieName();
1343
+ if (!array_key_exists($cookie_name, $_COOKIE)) {
1344
+ return array();
1345
+ }
1346
+
1347
+ // The cookie value can be wrapped in "-characters so remove them
1348
+ $cookie_value = trim($_COOKIE[$cookie_name], '"');
1349
+
1350
+ if (empty($cookie_value)) {
1351
+ return array();
1352
+ }
1353
+
1354
+ $parts = explode('&', $cookie_value);
1355
+ $metadata = array();
1356
+ foreach ($parts as $part) {
1357
+ $pair = explode('=', $part, 2);
1358
+ if (!empty($pair[0])) {
1359
+ $metadata[urldecode($pair[0])] =
1360
+ (count($pair) > 1) ? urldecode($pair[1]) : '';
1361
+ }
1362
+ }
1363
+
1364
+ return $metadata;
1365
+ }
1366
+
1367
+ protected static function isAllowedDomain($big, $small) {
1368
+ if ($big === $small) {
1369
+ return true;
1370
+ }
1371
+ return self::endsWith($big, '.'.$small);
1372
+ }
1373
+
1374
+ protected static function endsWith($big, $small) {
1375
+ $len = strlen($small);
1376
+ if ($len === 0) {
1377
+ return true;
1378
+ }
1379
+ return substr($big, -$len) === $small;
1380
+ }
1381
+
1382
+ /**
1383
+ * Each of the following four methods should be overridden in
1384
+ * a concrete subclass, as they are in the provided Facebook class.
1385
+ * The Facebook class uses PHP sessions to provide a primitive
1386
+ * persistent store, but another subclass--one that you implement--
1387
+ * might use a database, memcache, or an in-memory cache.
1388
+ *
1389
+ * @see Facebook
1390
+ */
1391
+
1392
+ /**
1393
+ * Stores the given ($key, $value) pair, so that future calls to
1394
+ * getPersistentData($key) return $value. This call may be in another request.
1395
+ *
1396
+ * @param string $key
1397
+ * @param array $value
1398
+ *
1399
+ * @return void
1400
+ */
1401
+ abstract protected function setPersistentData($key, $value);
1402
+
1403
+ /**
1404
+ * Get the data for $key, persisted by BaseFacebook::setPersistentData()
1405
+ *
1406
+ * @param string $key The key of the data to retrieve
1407
+ * @param boolean $default The default value to return if $key is not found
1408
+ *
1409
+ * @return mixed
1410
+ */
1411
+ abstract protected function getPersistentData($key, $default = false);
1412
+
1413
+ /**
1414
+ * Clear the data with $key from the persistent storage
1415
+ *
1416
+ * @param string $key
1417
+ * @return void
1418
+ */
1419
+ abstract protected function clearPersistentData($key);
1420
+
1421
+ /**
1422
+ * Clear all data from the persistent storage
1423
+ *
1424
+ * @return void
1425
+ */
1426
+ abstract protected function clearAllPersistentData();
1427
+ }
lib/fb/facebook.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2011 Facebook, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ require_once "base_facebook.php";
19
+
20
+ /**
21
+ * Extends the BaseFacebook class with the intent of using
22
+ * PHP sessions to store user ids and access tokens.
23
+ */
24
+ class Facebook extends BaseFacebook
25
+ {
26
+ const FBSS_COOKIE_NAME = 'fbss';
27
+
28
+ // We can set this to a high number because the main session
29
+ // expiration will trump this.
30
+ const FBSS_COOKIE_EXPIRE = 31556926; // 1 year
31
+
32
+ // Stores the shared session ID if one is set.
33
+ protected $sharedSessionID;
34
+
35
+ /**
36
+ * Identical to the parent constructor, except that
37
+ * we start a PHP session to store the user ID and
38
+ * access token if during the course of execution
39
+ * we discover them.
40
+ *
41
+ * @param Array $config the application configuration. Additionally
42
+ * accepts "sharedSession" as a boolean to turn on a secondary
43
+ * cookie for environments with a shared session (that is, your app
44
+ * shares the domain with other apps).
45
+ * @see BaseFacebook::__construct in facebook.php
46
+ */
47
+ public function __construct($config) {
48
+ if (!session_id()) {
49
+ session_start();
50
+ }
51
+ parent::__construct($config);
52
+ if (!empty($config['sharedSession'])) {
53
+ $this->initSharedSession();
54
+ }
55
+ }
56
+
57
+ protected static $kSupportedKeys =
58
+ array('state', 'code', 'access_token', 'user_id');
59
+
60
+ protected function initSharedSession() {
61
+ $cookie_name = $this->getSharedSessionCookieName();
62
+ if (isset($_COOKIE[$cookie_name])) {
63
+ $data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
64
+ if ($data && !empty($data['domain']) &&
65
+ self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
66
+ // good case
67
+ $this->sharedSessionID = $data['id'];
68
+ return;
69
+ }
70
+ // ignoring potentially unreachable data
71
+ }
72
+ // evil/corrupt/missing case
73
+ $base_domain = $this->getBaseDomain();
74
+ $this->sharedSessionID = md5(uniqid(mt_rand(), true));
75
+ $cookie_value = $this->makeSignedRequest(
76
+ array(
77
+ 'domain' => $base_domain,
78
+ 'id' => $this->sharedSessionID,
79
+ )
80
+ );
81
+ $_COOKIE[$cookie_name] = $cookie_value;
82
+ if (!headers_sent()) {
83
+ $expire = time() + self::FBSS_COOKIE_EXPIRE;
84
+ setcookie($cookie_name, $cookie_value, $expire, '/', '.'.$base_domain);
85
+ } else {
86
+ // @codeCoverageIgnoreStart
87
+ self::errorLog(
88
+ 'Shared session ID cookie could not be set! You must ensure you '.
89
+ 'create the Facebook instance before headers have been sent. This '.
90
+ 'will cause authentication issues after the first request.'
91
+ );
92
+ // @codeCoverageIgnoreEnd
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Provides the implementations of the inherited abstract
98
+ * methods. The implementation uses PHP sessions to maintain
99
+ * a store for authorization codes, user ids, CSRF states, and
100
+ * access tokens.
101
+ */
102
+ protected function setPersistentData($key, $value) {
103
+ if (!in_array($key, self::$kSupportedKeys)) {
104
+ self::errorLog('Unsupported key passed to setPersistentData.');
105
+ return;
106
+ }
107
+
108
+ $session_var_name = $this->constructSessionVariableName($key);
109
+ $_SESSION[$session_var_name] = $value;
110
+ }
111
+
112
+ protected function getPersistentData($key, $default = false) {
113
+ if (!in_array($key, self::$kSupportedKeys)) {
114
+ self::errorLog('Unsupported key passed to getPersistentData.');
115
+ return $default;
116
+ }
117
+
118
+ $session_var_name = $this->constructSessionVariableName($key);
119
+ return isset($_SESSION[$session_var_name]) ?
120
+ $_SESSION[$session_var_name] : $default;
121
+ }
122
+
123
+ protected function clearPersistentData($key) {
124
+ if (!in_array($key, self::$kSupportedKeys)) {
125
+ self::errorLog('Unsupported key passed to clearPersistentData.');
126
+ return;
127
+ }
128
+
129
+ $session_var_name = $this->constructSessionVariableName($key);
130
+ unset($_SESSION[$session_var_name]);
131
+ }
132
+
133
+ protected function clearAllPersistentData() {
134
+ foreach (self::$kSupportedKeys as $key) {
135
+ $this->clearPersistentData($key);
136
+ }
137
+ if ($this->sharedSessionID) {
138
+ $this->deleteSharedSessionCookie();
139
+ }
140
+ }
141
+
142
+ protected function deleteSharedSessionCookie() {
143
+ $cookie_name = $this->getSharedSessionCookieName();
144
+ unset($_COOKIE[$cookie_name]);
145
+ $base_domain = $this->getBaseDomain();
146
+ setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
147
+ }
148
+
149
+ protected function getSharedSessionCookieName() {
150
+ return self::FBSS_COOKIE_NAME . '_' . $this->getAppId();
151
+ }
152
+
153
+ protected function constructSessionVariableName($key) {
154
+ $parts = array('fb', $this->getAppId(), $key);
155
+ if ($this->sharedSessionID) {
156
+ array_unshift($parts, $this->sharedSessionID);
157
+ }
158
+ return implode('_', $parts);
159
+ }
160
+ }
lib/img/hechoenmexico.png ADDED
Binary file
lib/img/paypal.png ADDED
Binary file
lib/img/taco.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
+
60
+ = 1.2 =
61
+ * Embed posts
62
+ * Embed photos
63
+ * Like buttons
64
+
65
+ = 1.1.1 =
66
+ * Corrected links on events.
67
+
68
+ = 1.1 =
69
+ * Making the plugin public.
70
+
71
+ = 1.0 =
72
+ * Making the plugin.
templates/default/band.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 $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 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>
33
+ </div>
34
+
35
+
36
+
37
+
templates/default/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 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>
24
+ </div>
25
+
templates/default/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 ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ style=" width:<?php echo $width ?>px;
9
+ margin-left: auto;
10
+ margin-right: auto;
11
+ ">
12
+ <div class="wpemfb-pagebk"
13
+ style=" height:<?php echo $height ?>px;
14
+ width:<?php echo $width?>px;
15
+ background-image: url(<?php echo $fb_data['cover']['source'] ?>);
16
+ background-position: 0% <?php echo $fb_data['cover']['offset_y'] ?>%;
17
+ ">
18
+
19
+ </div>
20
+ <div class="wpemfb-info">
21
+ <div class="wpemfb-pic">
22
+ <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
23
+ <img src="http://graph.facebook.com/<?php echo $fb_data['id'] ?>/picture" />
24
+ </a>
25
+ </div>
26
+ <div class="wpemfb-desc">
27
+ <h4 class="wpemfb-title" >
28
+ <a href="<?php echo $fb_data['link'] ?>" target="_blank" rel="nofollow">
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>
37
+ </div>
templates/default/photo.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+
2
+ <pre><?php print_r($fb_data) ?></pre>
templates/default/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
+ <h3><?php echo $fb_data['name'] ?></h3>
18
+ </a>
19
+ </h4>
20
+ </div>
21
+ </div>
22
+ </div>
23
+
templates/default/wpemfb.css ADDED
@@ -0,0 +1,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
+ }
21
+ .wpemfb-info a:hover {
22
+ color: #23487E;
23
+ text-decoration: underline !important;
24
+ }
25
+ .wpemfb-title{
26
+ padding: 0 !important;
27
+ margin: 0 !important;
28
+ }
29
+ .wpemfb-pic{
30
+ display: table-cell;
31
+ vertical-align: middle;
32
+ margin: 0px;
33
+ padding: 5px;
34
+ width: 10%;
35
+ }
36
+ .wpemfb-desc{
37
+ display: table-cell;
38
+ vertical-align: middle;
39
+ }
40
+
wp-embed-fb.php ADDED
@@ -0,0 +1,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.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()){
34
+ require_once WPEMFBLIB.'admin.php';
35
+ add_action('admin_menu', array('EmbFbAdmin','add_page'));
36
+ }
37
+
38
+ ?>