WP Embed Facebook - Version 2.0.2

Version Description

  • Added options for page social plugins
  • Changed admin layout
  • Does not need facebook app for simple embeds
  • More human friendly
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.2

lib/admin/admin.css ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .sections {
2
+ padding:1px 22px 22px 22px;
3
+ background: #fff;
4
+ border:1px solid #ccc;
5
+ border-top:0px;
6
+ margin-bottom: 20px;
7
+ }
8
+ section {
9
+ display:none;
10
+ }
11
+
12
+ section:first-child {
13
+ display:block;
14
+ }
15
+
16
+
17
+ .no-js h2.nav-tab-wrapper {
18
+ display:none;
19
+ }
20
+
21
+ .no-js .sections {
22
+ border-top:1px solid #ccc;
23
+ margin-top:22px;
24
+ }
25
+
26
+ .no-js section {
27
+ border-top: 1px dashed #aaa;
28
+ margin-top:22px;
29
+ padding-top:22px;
30
+ }
31
+
32
+ .no-js section:first-child {
33
+ margin:0px;
34
+ padding:0px;
35
+ border:0px;
36
+ }
37
+ .nav-tab-active {
38
+ background-color: #ffffff;
39
+ }
40
+
41
+ .ui-widget-content th {
42
+ font-weight: normal;
43
+ padding-right: 10px;
44
+ }
45
+
46
+ .settings-col {
47
+ width: 50% !important;
48
+ padding-right: 2% !important;
49
+ text-align: left !important;
50
+ }
51
+
52
+ .welcome-panel-last {
53
+ width: 47% !important;
54
+ text-align: center;
55
+ }
56
+
57
+ @media (max-width: 870px) {
58
+ .settings-col {
59
+ width: 100% !important;
60
+ }
61
+
62
+ .welcome-panel-last {
63
+ width: 100% !important;
64
+ }
65
+ }
66
+ .welcome-panel-last .button-red {
67
+ background: #D2002C none repeat scroll 0% 0%;
68
+ border-color: #AA0012;
69
+ box-shadow: 0px 1px 0px rgba(230, 14, 23, 0.5) inset, 0px 1px 0px rgba(173, 173, 173, 0.15);
70
+ color: #FFF;
71
+ text-decoration: none;
72
+ }
73
+ .welcome-panel-last .button-red:focus, .welcome-panel-last .button-red:hover {
74
+ background: #AB1F42 none repeat scroll 0% 0%;
75
+ border-color: #AA0012;
76
+ box-shadow: 0px 1px 0px rgba(230, 14, 23, 0.5) inset;
77
+ color: #FFF;
78
+ }
79
+ .welcome-panel-last p {
80
+ font-size: 14px;
81
+ line-height: 14px;
82
+ margin: 0;
83
+ padding: 0 0 16px;
84
+ }
85
+ .welcome-panel-last h4 {
86
+ padding: 0 0 10px;
87
+ }
lib/admin/admin.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function ($) {
2
+ if (pagenow == 'settings_page_embedfacebook') {
3
+ var sections = $('section');
4
+ sections.first().show();
5
+ $(".nav-tab-wrapper a").on('click', function (event) {
6
+ event.preventDefault();
7
+ sections.hide();
8
+ $.each($(".nav-tab-wrapper a"), function (key, value) {
9
+ $(value).removeClass("nav-tab-active");
10
+ });
11
+ sections.eq($(this).index()).show();
12
+ $(this).addClass('nav-tab-active')
13
+ });
14
+ }
15
+ });
16
+
17
+ jQuery(document).on( 'click', '.wpemfb_warning .notice-dismiss', function() {
18
+ jQuery.post(ajaxurl, { action: 'close_warning' });
19
+ })
lib/class-wef-social-plugins.php CHANGED
@@ -29,8 +29,11 @@ class WEF_Social_Plugins {
29
  'show_faces' => 'false',
30
  );
31
  $options = wp_parse_args( $options, $defaults );
32
-
33
- return '<div class="fb-like" data-href="' . $href . '" data-colorscheme="' . $options['colorscheme'] . '" data-layout="' . $options['layout'] . '" data-action="like" data-show-faces="' . $options['show_faces'] . '" data-share="' . $options['share'] . '" ></div>';
 
 
 
34
  }
35
 
36
  /**
@@ -69,11 +72,11 @@ class WEF_Social_Plugins {
69
  */
70
  static function page_plugin( $href, $width, $options = array() ) {
71
  $defaults = array(
72
- 'hide_cover' => 'false',
73
- 'show_facepile' => 'true',
74
- 'show_posts' => 'false',
75
- 'small_header' => 'false',
76
- 'height' => '500'
77
  );
78
  $options = wp_parse_args( $options, $defaults );
79
 
29
  'show_faces' => 'false',
30
  );
31
  $options = wp_parse_args( $options, $defaults );
32
+ $string = '';
33
+ foreach($options as $data => $value){
34
+ $string .= " data-".str_replace('_','-',$data)."=$value";
35
+ }
36
+ return '<div class="fb-like" data-href="' . $href . '"'.$string.' data-action="like"></div>';
37
  }
38
 
39
  /**
72
  */
73
  static function page_plugin( $href, $width, $options = array() ) {
74
  $defaults = array(
75
+ 'hide_cover' => get_option('wpemfb_page_hide_cover'),
76
+ 'show_facepile' => get_option('wpemfb_page_show_faces'),
77
+ 'show_posts' => get_option('wpemfb_page_show_posts'),
78
+ 'small_header' => get_option('wpemfb_page_small_header'),
79
+ 'height' => get_option('wpemfb_page_height'),
80
  );
81
  $options = wp_parse_args( $options, $defaults );
82
 
lib/class-wp-embed-fb-admin.php CHANGED
@@ -2,64 +2,157 @@
2
 
3
  class WP_Embed_FB_Admin {
4
  /**
5
- * @param string $hook_suffix
 
 
 
 
 
 
 
 
 
 
 
 
6
  */
7
  static function admin_enqueue_scripts( $hook_suffix ) {
8
  if ( $hook_suffix == 'settings_page_embedfacebook' ) {
9
- global $wp_scripts;
10
- wp_enqueue_script( 'wpemfb-admin', WP_Embed_FB_Plugin::get_url() . 'lib/js/admin.js', array( 'jquery-ui-accordion' ) );
11
- $queryui = $wp_scripts->query( 'jquery-ui-core' );
12
- $url = "https://ajax.googleapis.com/ajax/libs/jqueryui/" . $queryui->ver . "/themes/smoothness/jquery-ui.css";
13
- wp_enqueue_style( 'jquery-ui-start', $url, false, null );
14
  }
 
15
  }
16
 
17
- static function admin_init( ) {
 
 
 
18
  $theme = get_option( 'wpemfb_theme' );
19
  add_editor_style( WP_Embed_FB_Plugin::get_url() . '/templates/' . $theme . '/' . $theme . '.css' );
20
  }
21
 
22
- static function add_page() {
23
- add_options_page( 'EmbedFacebook', 'Embed Facebook', 'manage_options', 'embedfacebook', array(
24
- __CLASS__,
25
- 'embedfb_page'
26
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  * @param $option string option name
31
  * @param $type string direct or true/false
32
  */
33
  static function save_option( $option, $type ) {
34
  if ( $type == 'direct' ) {
35
  if ( isset( $_POST[ $option ] ) ) {
36
- update_option( $option, sanitize_text_field($_POST[ $option ]) );
37
  }
38
- }
39
- elseif($type == 'bool') {
40
  if ( isset( $_POST[ $option ] ) ) {
41
  update_option( $option, 'true' );
42
  } else {
43
  update_option( $option, 'false' );
44
  }
45
  }
46
- elseif($type == 'inverse') {
47
- if ( !isset( $_POST[ $option ] ) ) {
48
- update_option( $option, 'true' );
49
- } else {
50
- update_option( $option, 'false' );
51
- }
52
- }
53
  }
54
 
 
 
 
55
  static function savedata() {
56
  if ( isset( $_POST['wpemfb_app_secret'], $_POST['wpemfb_app_id'] ) ) {
57
-
58
  $options = WP_Embed_FB_Plugin::getdefaults();
59
 
60
  foreach ( $options as $option => $value ) {
61
- if( $value == 'true' || $value == 'false' ){
62
- $type = (strpos($option,'_raw_') !== false) ? 'inverse':'bool';
63
  } else {
64
  $type = 'direct';
65
  }
@@ -67,7 +160,7 @@ class WP_Embed_FB_Admin {
67
  }
68
  if ( isset( $_POST['wpemfb_max_width'] ) && is_int( $_POST['wpemfb_max_width'] ) ) {
69
  $prop = get_option( 'wpemfb_proportions' ) * $_POST['wpemfb_max_width'];
70
- update_option( 'wpemfb_height', $prop );
71
  }
72
  }
73
  /**
@@ -79,120 +172,14 @@ class WP_Embed_FB_Admin {
79
  do_action( 'wpemfb_admin_save_data' );
80
  }
81
 
82
- static function field( $type, $name, $label, $args = array() ) {
83
- switch ( $type ) {
84
- case 'checkbox':
85
- if(strpos($name,'_raw_') !== false) :
86
- $checked = ( get_option( $name ) === 'true' ) ? '' : 'checked';
87
- else :
88
- $checked = ( get_option( $name ) === 'true' ) ? 'checked' : '';
89
- endif;
90
-
91
- ob_start();
92
- ?>
93
- <tr valign="middle">
94
- <th><?php echo $label ?></th>
95
- <td>
96
- <input type="checkbox"
97
- name="<?php echo $name ?>" <?php echo $checked ?> />
98
- </td>
99
- </tr>
100
- <?php
101
- ob_end_flush();
102
- break;
103
- default:
104
- ob_start();
105
- ?>
106
- <tr valign="middle">
107
- <th><?php echo $label ?></th>
108
- <td>
109
- <input id="<?php echo $name ?>"
110
- type="<?php echo $type ?>"
111
- name="<?php echo $name ?>" <?php echo isset( $args['required'] ) ? 'required' : '' ?>
112
- value="<?php echo get_option( $name ) ?>" size="38"/>
113
- </td>
114
- </tr>
115
- <?php
116
- ob_end_flush();
117
- break;
118
- }
119
- }
120
-
121
- static function section( $title = '' ) {
122
- if ( ! empty( $title ) ) :
123
- ?>
124
- <h5><?php echo $title ?></h5>
125
- <div>
126
- <table>
127
- <tbody>
128
- <?php
129
- else :
130
- ?>
131
- </tbody>
132
- </table>
133
- </div>
134
- <?php
135
- endif;
136
- }
137
-
138
- static function embedfb_page() {
139
  if ( isset( $_POST['save-data'] ) && wp_verify_nonce( $_POST['save-data'], 'wp-embed-facebook' ) ) {
140
  self::savedata();
141
-
142
  }
143
- $sel1 = ( get_option( 'wpemfb_theme' ) === 'default' ) ? 'selected' : '';
144
- $sel2 = ( get_option( 'wpemfb_theme' ) === 'classic' ) ? 'selected' : '';
145
-
146
  ?>
147
- <style>
148
- .ui-widget-content th {
149
- font-weight: normal;
150
- padding-right: 10px;
151
- }
152
-
153
- .settings-col {
154
- width: 50% !important;
155
- padding-right: 2% !important;
156
- text-align: left !important;
157
- }
158
-
159
- .welcome-panel-last {
160
- width: 47% !important;
161
- text-align: center;
162
- }
163
-
164
- @media (max-width: 870px) {
165
- .settings-col {
166
- width: 100% !important;
167
- }
168
-
169
- .welcome-panel-last {
170
- width: 100% !important;
171
- }
172
- }
173
- .welcome-panel-last .button-red {
174
- background: #D2002C none repeat scroll 0% 0%;
175
- border-color: #AA0012;
176
- box-shadow: 0px 1px 0px rgba(230, 14, 23, 0.5) inset, 0px 1px 0px rgba(173, 173, 173, 0.15);
177
- color: #FFF;
178
- text-decoration: none;
179
- }
180
- .welcome-panel-last .button-red:focus, .welcome-panel-last .button-red:hover {
181
- background: #AB1F42 none repeat scroll 0% 0%;
182
- border-color: #AA0012;
183
- box-shadow: 0px 1px 0px rgba(230, 14, 23, 0.5) inset;
184
- color: #FFF;
185
- }
186
- .welcome-panel-last p {
187
- font-size: 14px;
188
- line-height: 14px;
189
- margin: 0;
190
- padding: 0 0 16px;
191
- }
192
- .welcome-panel-last h4 {
193
- padding: 0 0 10px;
194
- }
195
- </style>
196
  <div class="wrap">
197
  <h2>WP Embed Facebook</h2>
198
 
@@ -202,73 +189,102 @@ class WP_Embed_FB_Admin {
202
  <div class="welcome-panel-column settings-col">
203
  <form id="config-form" action="#" method="post">
204
  <?php wp_nonce_field( 'wp-embed-facebook', 'save-data' ); ?>
205
- <div id="accordion">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  <?php
207
- self::section( __( 'Facebook application data', 'wp-embed-facebook' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  self::field( 'text', 'wpemfb_app_id', __( 'App ID', 'wp-embed-facebook' ), array( 'required' => 'true' ) );
209
  self::field( 'text', 'wpemfb_app_secret', __( 'App Secret', 'wp-embed-facebook' ), array( 'required' => 'true' ) );
210
  self::section();
211
  ?>
212
- <?php self::section( __( "General ", 'wp-embed-facebook' ) ); ?>
213
- <tr valign="middle">
214
- <th><?php _e( "Template to use", 'wp-embed-facebook' ) ?></th>
215
- <td>
216
- <select name="wpemfb_theme">
217
- <option value="default" <?php echo $sel1 ?> >Default</option>
218
- <option value="classic" <?php echo $sel2 ?> >Classic</option>
219
- <?php
220
- /**
221
- * Add a new theme option
222
- * @since 1.8
223
- */
224
- do_action( 'wpemfb_admin_theme' );
225
- ?>
226
- </select>
227
- </td>
228
- </tr>
229
  <?php
230
- self::field( 'number', 'wpemfb_max_width', __( 'Embed Max-Width', 'wp-embed-facebook' ) );
 
 
 
 
 
 
 
 
 
231
  self::section();
232
-
233
- self::section(__( "Album ", 'wp-embed-facebook' ));
234
- self::field( 'number', 'wpemfb_max_photos', __( 'Number of Photos <br>on Embedded Albums', 'wp-embed-facebook' ) );
235
  self::section();
236
-
237
- self::section(__( "Event ", 'wp-embed-facebook' ));
238
- self::field( 'checkbox', 'wpemfb_ev_local_tz', __( 'Show events on local time', 'wp-embed-facebook' ) );
239
  self::section();
240
-
241
- self::section( __( "Pages ", 'wp-embed-facebook' ) );
242
- self::field( 'checkbox', 'wpemfb_raw_page', __( 'Embed Pages as Social Plugins', 'wp-embed-facebook' ) );
243
  self::field( 'checkbox', 'wpemfb_show_like', __( 'Show like button', 'wp-embed-facebook' ) );
244
  self::field( 'checkbox', 'wpemfb_show_posts', __( 'Show latest posts', 'wp-embed-facebook' ) );
245
  self::field( 'number', 'wpemfb_max_posts', __( 'Number of posts', 'wp-embed-facebook' ) );
246
  self::section();
247
-
248
- self::section(__( "Photo ", 'wp-embed-facebook' ));
249
- self::field( 'checkbox', 'wpemfb_raw_photo', __( 'Embed Photos as Social Plugins', 'wp-embed-facebook' ) );
250
- self::section();
251
-
252
- self::section(__( "Post ", 'wp-embed-facebook' ));
253
- self::field( 'checkbox', 'wpemfb_raw_post', __( 'Embed Posts as Social Plugins', 'wp-embed-facebook' ) );
254
  self::section();
255
-
256
- self::section(__( "Profile ", 'wp-embed-facebook' ));
257
- self::field( 'checkbox', 'wpemfb_show_follow', __( 'Show follow button <br>on Embedded Profiles', 'wp-embed-facebook' ) );
258
  self::section();
259
-
260
- self::section(__( "Video ", 'wp-embed-facebook' ));
261
- self::field( 'checkbox', 'wpemfb_raw_video', __( 'Embed Videos as Social Plugins', 'wp-embed-facebook' ) );
262
- self::field( 'checkbox', 'wpemfb_video_as_post', __( 'Use Posts social plugin', 'wp-embed-facebook' ) );
263
  self::field( 'checkbox', 'wpemfb_video_ratio', __( 'Force 16:9 ratio', 'wp-embed-facebook' ) );
264
- //self::field( 'checkbox', 'wpemfb_raw_video_fb', __( 'Use Facebook embed code on raw videos', 'wp-embed-facebook' ) );
265
  //TODO update class and delete 'wpemfb_raw_video_fb' option forever
266
  self::section();
267
- /**
268
- * Add more options to the plugin page save them with 'wpemfb_admin_save_data' action
269
- * @since 1.8
270
- */
271
- do_action( 'wpemfb_options' );
 
 
 
 
272
  self::section( __( 'Advanced ', 'wp-embed-facebook' ) );
273
  self::field( 'checkbox', 'wpemfb_enqueue_style', __( 'Enqueue Styles', 'wp-embed-facebook' ) );
274
  self::field( 'checkbox', 'wpemfb_fb_root', __( 'Add fb-root on top of content', 'wp-embed-facebook' ) );
@@ -277,52 +293,67 @@ class WP_Embed_FB_Admin {
277
  self::field( 'checkbox', 'wpemfb_enq_fbjs', __( 'Enqueue Facebook SDK', 'wp-embed-facebook' ) );
278
  self::section();
279
  ?>
280
- </div>
281
- <p><?php _e('All options can be overwritten using the [facebook=url ]','wp-embed-facebook') ?> <a href="http://www.wpembedfb.com/documentation/shortcodes/">shortcode</a></p>
282
  <input type="submit" name="submit" class="button button-primary alignright"
283
  value="<?php _e( 'Save', 'wp-embed-facebook' ) ?>"/>
 
 
 
284
  <br>
285
  <br>
286
  </form>
287
  </div>
288
  <div class="welcome-panel-column welcome-panel-last">
289
  <?php ob_start(); ?>
290
- <h4><?php _e( "Keep this plugin's core free and accessible to all.", 'wp-embed-facebook' ) ?></h4>
291
- <p><strong><a href="http://wordpress.org/plugins/wp-embed-facebook">Rate it <span style="color: gold;">&#9733;&#9733;&#9733;&#9733;&#9733;</span></strong></a></p>
292
- <p><strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R8Q85GT3Q8Q26" >Donate</a></strong></p>
293
- <hr>
294
- <br>
295
  <h3><?php _e( 'Premium Extension Available', 'wp-embed-facebook' ) ?></h3>
296
  <br>
 
297
  <div class="features-list">
298
- <p><?php _e( 'Embed a Facebook Page with all its details.', 'wp-embed-facebook' ) ?></p>
299
- <p><?php _e( 'Embed an Event with all its details.', 'wp-embed-facebook' ) ?></p>
300
- <p><?php _e( 'One Year Premium Support', 'wp-embed-facebook' ) ?></p>
301
- <p>
302
- <?php _e( 'Plus new features cooking', 'wp-embed-facebook' ) ?>
303
- <br>
304
- <small>
305
- <?php _e( 'Upcoming events widget, events with maps...', 'wp-embed-facebook' ) ?>
306
- </small>
307
- </p>
 
 
 
308
  </div>
309
- <h2><?php _e( 'Only $6.99 USD', 'wp-embed-facebook' ) ?><br><small style="font-size: 12px; color: #d0d0d0">Price will change very soon</small></h2>
 
 
 
 
 
310
  <br>
311
  <a class="button button-red"
312
  href="http://www.wpembedfb.com/premium"><?php _e( 'Check it out', 'wp-embed-facebook' ) ?></a>
313
  <br>
314
  <br>
315
  <hr>
316
- <p><a href="http://www.wpembedfb.com"><small><?php _e( 'More information', 'wp-embed-facebook' ) ?></small></a></p>
 
 
 
 
 
 
 
 
 
 
 
 
317
  <?php echo apply_filters( 'wpemfb_admin', ob_get_clean() ); ?>
318
  </div>
319
  </div>
320
  </div>
321
  </div>
322
  </div>
323
- <script>
324
-
325
- </script>
326
  <?php
327
  }
328
  }
2
 
3
  class WP_Embed_FB_Admin {
4
  /**
5
+ * Add WP Embed Facebook page to Settings
6
+ */
7
+ static function add_page() {
8
+ add_options_page( 'EmbedFacebook', 'Embed Facebook', 'manage_options', 'embedfacebook', array(
9
+ __CLASS__,
10
+ 'wpemfb_page'
11
+ ) );
12
+ }
13
+
14
+ /**
15
+ * Enqueue WP Embed Facebook js and css to admin page
16
+ *
17
+ * @param string $hook_suffix current page
18
  */
19
  static function admin_enqueue_scripts( $hook_suffix ) {
20
  if ( $hook_suffix == 'settings_page_embedfacebook' ) {
21
+ wp_enqueue_style( 'wpemfb-admin-css', WP_Embed_FB_Plugin::get_url() . 'lib/admin/admin.css' );
 
 
 
 
22
  }
23
+ wp_enqueue_script( 'wpemfb-admin', WP_Embed_FB_Plugin::get_url() . 'lib/admin/admin.js', array( 'jquery-ui-accordion' ) );
24
  }
25
 
26
+ /**
27
+ * Add template editor style to the embeds.
28
+ */
29
+ static function admin_init() {
30
  $theme = get_option( 'wpemfb_theme' );
31
  add_editor_style( WP_Embed_FB_Plugin::get_url() . '/templates/' . $theme . '/' . $theme . '.css' );
32
  }
33
 
34
+ /**
35
+ * Render form sections
36
+ *
37
+ * @param string $title
38
+ */
39
+ static function section( $title = '' ) {
40
+ if ( ! empty( $title ) ) :
41
+ ?>
42
+ <h4><?php echo $title ?></h4>
43
+ <table>
44
+ <tbody>
45
+ <?php
46
+ else :
47
+ ?>
48
+ </tbody>
49
+ </table>
50
+ <?php
51
+ endif;
52
  }
53
 
54
  /**
55
+ * Render form fields
56
+ *
57
+ * @param string $type Type of input field
58
+ * @param string $name Input name
59
+ * @param string $label Input Label
60
+ * @param array $args
61
+ */
62
+ static function field( $type, $name = '', $label = '', $args = array() ) {
63
+ switch ( $type ) {
64
+ case 'checkbox':
65
+ $checked = ( get_option( $name ) === 'true' ) ? 'checked' : '';
66
+ ob_start();
67
+ ?>
68
+ <tr valign="middle">
69
+ <th><?php echo $label ?></th>
70
+ <td>
71
+ <input type="checkbox" id="<?php echo $name ?>"
72
+ name="<?php echo $name ?>" <?php echo $checked ?> />
73
+ </td>
74
+ </tr>
75
+ <?php
76
+ ob_end_flush();
77
+ break;
78
+ case 'select' :
79
+ $option = get_option( $name );
80
+ ob_start();
81
+ ?>
82
+ <tr valign="middle">
83
+ <th><?php echo $label ?></th>
84
+ <td>
85
+ <select name="<?php echo $name ?>">
86
+ <?php foreach ( $args as $value => $name ) : ?>
87
+ <option
88
+ value="<?php echo $value ?>" <?php echo $option == $value ? 'selected' : '' ?>><?php echo $name ?></option>
89
+ <?php endforeach; ?>
90
+ </select>
91
+ </td>
92
+ </tr>
93
+ <?php
94
+ ob_end_flush();
95
+ break;
96
+ case 'string' :
97
+ ob_start();
98
+ ?>
99
+ <tr valign="middle">
100
+ <th><?php echo $label ?></th>
101
+ <td>
102
+ <p><?php echo $name ?></p>
103
+ </td>
104
+ </tr>
105
+ <?php
106
+ ob_end_flush();
107
+ break;
108
+ default:
109
+ ob_start();
110
+ ?>
111
+ <tr valign="middle">
112
+ <th><?php echo $label ?></th>
113
+ <td>
114
+ <input id="<?php echo $name ?>"
115
+ type="<?php echo $type ?>"
116
+ name="<?php echo $name ?>" <?php echo isset( $args['required'] ) ? 'required' : '' ?>
117
+ value="<?php echo get_option( $name ) ?>" size="38"/>
118
+ </td>
119
+ </tr>
120
+ <?php
121
+ ob_end_flush();
122
+ break;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Saves $_POST values to the database
128
+ *
129
  * @param $option string option name
130
  * @param $type string direct or true/false
131
  */
132
  static function save_option( $option, $type ) {
133
  if ( $type == 'direct' ) {
134
  if ( isset( $_POST[ $option ] ) ) {
135
+ update_option( $option, sanitize_text_field( $_POST[ $option ] ) );
136
  }
137
+ } elseif ( $type == 'bool' ) {
 
138
  if ( isset( $_POST[ $option ] ) ) {
139
  update_option( $option, 'true' );
140
  } else {
141
  update_option( $option, 'false' );
142
  }
143
  }
 
 
 
 
 
 
 
144
  }
145
 
146
+ /**
147
+ * Gets $_POST variables and saves them to the database
148
+ */
149
  static function savedata() {
150
  if ( isset( $_POST['wpemfb_app_secret'], $_POST['wpemfb_app_id'] ) ) {
 
151
  $options = WP_Embed_FB_Plugin::getdefaults();
152
 
153
  foreach ( $options as $option => $value ) {
154
+ if ( $value == 'true' || $value == 'false' ) {
155
+ $type = 'bool';
156
  } else {
157
  $type = 'direct';
158
  }
160
  }
161
  if ( isset( $_POST['wpemfb_max_width'] ) && is_int( $_POST['wpemfb_max_width'] ) ) {
162
  $prop = get_option( 'wpemfb_proportions' ) * $_POST['wpemfb_max_width'];
163
+ update_option( 'wpemfb_height', $prop );//TODO height is deprecated
164
  }
165
  }
166
  /**
172
  do_action( 'wpemfb_admin_save_data' );
173
  }
174
 
175
+ /**
176
+ * Renders the wp-admin settings page
177
+ */
178
+ static function wpemfb_page() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  if ( isset( $_POST['save-data'] ) && wp_verify_nonce( $_POST['save-data'], 'wp-embed-facebook' ) ) {
180
  self::savedata();
 
181
  }
 
 
 
182
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  <div class="wrap">
184
  <h2>WP Embed Facebook</h2>
185
 
189
  <div class="welcome-panel-column settings-col">
190
  <form id="config-form" action="#" method="post">
191
  <?php wp_nonce_field( 'wp-embed-facebook', 'save-data' ); ?>
192
+ <?php
193
+ $tabs = array(
194
+ __( 'General', 'wp-embed-facebook' ),
195
+ __( 'Custom Embeds', 'wp-embed-facebook' ),
196
+ __( 'Geeky Stuff', 'wp-embed-facebook' ),
197
+ );
198
+ $tabs = apply_filters( 'wpemfb_tabs', $tabs );
199
+ ?>
200
+ <h2 class="nav-tab-wrapper">
201
+ <?php
202
+ foreach ( $tabs as $tab ) {
203
+ $class = $tabs[0] == $tab ? "nav-tab-active" : "";
204
+ echo "<a class='nav-tab $class' href='#'>$tab</a>";
205
+ }
206
+ ?>
207
+ </h2>
208
+ <section class="sections">
209
+ <?php
210
+ self::section( __( 'For all embeds', 'wp-embed-facebook' ) );
211
+ self::field( 'number', 'wpemfb_max_width', __( 'Maximum width in pixels', 'wp-embed-facebook' ) );
212
+ self::field( 'select', 'wpemfb_sdk_lang', __( 'Like Buttons Language', 'wp-embed-facebook' ), WP_Embed_FB_Plugin::get_fb_locales() );
213
+ self::section();
214
+ ?>
215
  <?php
216
+ self::section( __( 'Social Plugin Defaults', 'wp-embed-facebook' ) );
217
+ self::field( 'string', '', '---- ' . __( 'Page Plugin', 'wp-embed-facebook' ) . ' ----' );
218
+ self::field( 'number', 'wpemfb_page_height', __( 'Maximum height in pixels', 'wp-embed-facebook' ) );
219
+ self::field( 'checkbox', 'wpemfb_page_show_faces', __( "Show Friend's Faces", 'wp-embed-facebook' ) );
220
+ self::field( 'checkbox', 'wpemfb_page_small_header', __( 'Use Small Header', 'wp-embed-facebook' ) );
221
+ self::field( 'checkbox', 'wpemfb_page_hide_cover', __( 'Hide Cover Photo', 'wp-embed-facebook' ) );
222
+ self::field( 'checkbox', 'wpemfb_page_show_posts', __( 'Show Page Posts', 'wp-embed-facebook' ) );
223
+ self::field( 'string', '', '---- ' . __( 'Videos', 'wp-embed-facebook' ) . ' ----' );
224
+ self::field( 'checkbox', 'wpemfb_video_as_post', __( 'Embed Video as Post', 'wp-embed-facebook' ) );
225
+ self::section();
226
+ if ( ! WP_Embed_FB_Plugin::has_fb_app() ) :
227
+ ?>
228
+ <p>
229
+ <?php _e( 'By default you can only embed public pages, videos, photos and posts.', 'wp-embed-facebook' ) ?>
230
+ <br><?php _e( 'To embed embed albums, events, profiles and raw video you will need a Facebook App.', 'wp-embed-facebook' ) ?>
231
+ </p>
232
+ <?php
233
+ endif;
234
+ self::section( __( 'Facebook credentials', 'wp-embed-facebook' ) );
235
  self::field( 'text', 'wpemfb_app_id', __( 'App ID', 'wp-embed-facebook' ), array( 'required' => 'true' ) );
236
  self::field( 'text', 'wpemfb_app_secret', __( 'App Secret', 'wp-embed-facebook' ), array( 'required' => 'true' ) );
237
  self::section();
238
  ?>
239
+ <p><a href="https://developers.facebook.com/apps"
240
+ target="_blank"><?php _e( 'Your Facebook Apps', 'wp-embed-facebook' ) ?></a>
241
+ </p>
242
+ </section>
243
+ <section class="sections">
 
 
 
 
 
 
 
 
 
 
 
 
244
  <?php
245
+ self::section( __( "General", 'wp-embed-facebook' ) );
246
+ /**
247
+ * Filter available templates
248
+ * @since 2.0.2
249
+ */
250
+ $templates = apply_filters( 'wpemfb_admin_theme', array(
251
+ 'default' => 'Default',
252
+ 'classic' => 'Classic'
253
+ ) );
254
+ self::field( 'select', 'wpemfb_theme', 'Template to use', $templates );
255
  self::section();
256
+ self::section( __( "Albums", 'wp-embed-facebook' ) );
257
+ self::field( 'number', 'wpemfb_max_photos', __( 'Number of Photos', 'wp-embed-facebook' ) );
 
258
  self::section();
259
+ self::section( __( "Events", 'wp-embed-facebook' ) );
260
+ self::field( 'checkbox', 'wpemfb_ev_local_tz', __( 'Use WordPress timezone string to calculate the date', 'wp-embed-facebook' ) );
 
261
  self::section();
262
+ self::section( __( "Pages", 'wp-embed-facebook' ) );
263
+ self::field( 'checkbox', 'wpemfb_raw_page', __( 'Use custom embed by default', 'wp-embed-facebook' ) );
 
264
  self::field( 'checkbox', 'wpemfb_show_like', __( 'Show like button', 'wp-embed-facebook' ) );
265
  self::field( 'checkbox', 'wpemfb_show_posts', __( 'Show latest posts', 'wp-embed-facebook' ) );
266
  self::field( 'number', 'wpemfb_max_posts', __( 'Number of posts', 'wp-embed-facebook' ) );
267
  self::section();
268
+ self::section( __( "Photo", 'wp-embed-facebook' ) );
269
+ self::field( 'checkbox', 'wpemfb_raw_photo', __( 'Use custom embed by default', 'wp-embed-facebook' ) );
 
 
 
 
 
270
  self::section();
271
+ self::section( __( "Posts", 'wp-embed-facebook' ) );
272
+ self::field( 'checkbox', 'wpemfb_raw_post', __( 'Use custom embed by default', 'wp-embed-facebook' ) );
 
273
  self::section();
274
+ self::section( __( "Videos", 'wp-embed-facebook' ) );
275
+ self::field( 'checkbox', 'wpemfb_raw_video', __( 'Use custom embed by default', 'wp-embed-facebook' ) );
 
 
276
  self::field( 'checkbox', 'wpemfb_video_ratio', __( 'Force 16:9 ratio', 'wp-embed-facebook' ) );
 
277
  //TODO update class and delete 'wpemfb_raw_video_fb' option forever
278
  self::section();
279
+ self::section( __( "Profiles", 'wp-embed-facebook' ) );
280
+ self::field( 'checkbox', 'wpemfb_show_follow', __( 'Show follow button', 'wp-embed-facebook' ) );
281
+ self::section();
282
+ ?>
283
+
284
+ </section>
285
+ <?php do_action( 'wpemfb_options' ); ?>
286
+ <section class="sections">
287
+ <?php
288
  self::section( __( 'Advanced ', 'wp-embed-facebook' ) );
289
  self::field( 'checkbox', 'wpemfb_enqueue_style', __( 'Enqueue Styles', 'wp-embed-facebook' ) );
290
  self::field( 'checkbox', 'wpemfb_fb_root', __( 'Add fb-root on top of content', 'wp-embed-facebook' ) );
293
  self::field( 'checkbox', 'wpemfb_enq_fbjs', __( 'Enqueue Facebook SDK', 'wp-embed-facebook' ) );
294
  self::section();
295
  ?>
296
+ </section>
 
297
  <input type="submit" name="submit" class="button button-primary alignright"
298
  value="<?php _e( 'Save', 'wp-embed-facebook' ) ?>"/>
299
+
300
+ <p><?php _e( 'All options can be overwritten using the [facebook=url ]', 'wp-embed-facebook' ) ?>
301
+ <a href="http://www.wpembedfb.com/documentation">shortcode</a></p>
302
  <br>
303
  <br>
304
  </form>
305
  </div>
306
  <div class="welcome-panel-column welcome-panel-last">
307
  <?php ob_start(); ?>
 
 
 
 
 
308
  <h3><?php _e( 'Premium Extension Available', 'wp-embed-facebook' ) ?></h3>
309
  <br>
310
+
311
  <div class="features-list">
312
+ <p><?php _e( 'Embed a Facebook Page with all its details.', 'wp-embed-facebook' ) ?></p>
313
+
314
+ <p><?php _e( 'Embed an Event with all its details.', 'wp-embed-facebook' ) ?></p>
315
+
316
+ <p><?php _e( 'One Year Premium Support', 'wp-embed-facebook' ) ?></p>
317
+
318
+ <p>
319
+ <?php _e( 'Plus new features cooking', 'wp-embed-facebook' ) ?>
320
+ <br>
321
+ <small>
322
+ <?php _e( 'Upcoming events widget, events with maps...', 'wp-embed-facebook' ) ?>
323
+ </small>
324
+ </p>
325
  </div>
326
+ <h2>
327
+ <?php _e( 'Only $6.99 USD', 'wp-embed-facebook' ) ?>
328
+ <br>
329
+ <small
330
+ style="font-size: 12px; color: rgb(152, 152, 152)"><?php _e( 'Price will change very soon', 'wp-embed-facebook' ) ?></small>
331
+ </h2>
332
  <br>
333
  <a class="button button-red"
334
  href="http://www.wpembedfb.com/premium"><?php _e( 'Check it out', 'wp-embed-facebook' ) ?></a>
335
  <br>
336
  <br>
337
  <hr>
338
+ <h4><?php _e( "Keep this plugin's core free and accessible to all.", 'wp-embed-facebook' ) ?></h4>
339
+
340
+ <p><strong><a href="http://wordpress.org/plugins/wp-embed-facebook">Rate it <span
341
+ style="color: gold;">&#9733;&#9733;&#9733;&#9733;&#9733;</span></strong></a>
342
+ </p>
343
+
344
+ <p><strong><a
345
+ href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R8Q85GT3Q8Q26"><?php _e( 'Donate', 'wp-embed-facebook' ) ?></a></strong>
346
+ </p>
347
+ <hr>
348
+ <p><a href="http://www.wpembedfb.com">
349
+ <small><?php _e( 'More information', 'wp-embed-facebook' ) ?></small>
350
+ </a></p>
351
  <?php echo apply_filters( 'wpemfb_admin', ob_get_clean() ); ?>
352
  </div>
353
  </div>
354
  </div>
355
  </div>
356
  </div>
 
 
 
357
  <?php
358
  }
359
  }
lib/class-wp-embed-fb-plugin.php CHANGED
@@ -55,29 +55,36 @@ class WP_Embed_FB_Plugin {
55
  */
56
  static function getdefaults(){
57
  return array(
58
- 'wpemfb_max_width' => '450',
59
- 'wpemfb_max_photos' => '24',
60
- 'wpemfb_max_posts' => '2',
61
- 'wpemfb_show_posts' => 'false',
62
- 'wpemfb_enqueue_style' => 'true',
63
- 'wpemfb_app_id' => '0',
64
- 'wpemfb_app_secret' => '0',
65
- 'wpemfb_proportions' => 0.36867,
66
- 'wpemfb_height' => '221.202',
67
- 'wpemfb_show_like' => 'true',
68
- 'wpemfb_fb_root' => 'true',
69
- 'wpemfb_theme' => 'default',
70
- 'wpemfb_show_follow' => 'true',
71
- 'wpemfb_video_ratio' => 'false',
72
- 'wpemfb_raw_video' => 'true',
73
- 'wpemfb_video_as_post' => 'true',
74
- 'wpemfb_raw_photo' => 'false',
75
- 'wpemfb_raw_post' => 'true',
76
- 'wpemfb_raw_page' => 'true',
77
- 'wpemfb_enq_lightbox' => 'true',
78
- 'wpemfb_enq_wpemfb' => 'true',
79
- 'wpemfb_enq_fbjs' => 'true',
80
- 'wpemfb_ev_local_tz' => 'false',
 
 
 
 
 
 
 
81
  );
82
  }
83
  //("uninstalled","deactivated","activated","reactivated")
@@ -128,7 +135,7 @@ class WP_Embed_FB_Plugin {
128
  self::get_url().'lib/js/fb.js',
129
  array( 'jquery' )
130
  );
131
- $translation_array = array( 'local' => get_locale(), 'fb_id'=>get_option('wpemfb_app_id') );
132
  wp_localize_script( 'wpemfb-fbjs', 'WEF', $translation_array );
133
  }
134
  }
@@ -159,4 +166,177 @@ class WP_Embed_FB_Plugin {
159
  static function fb_root($content){
160
  return '<div id="fb-root"></div>'.PHP_EOL.$content;
161
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
55
  */
56
  static function getdefaults(){
57
  return array(
58
+ 'wpemfb_max_width' => '450',
59
+ 'wpemfb_max_photos' => '24',
60
+ 'wpemfb_max_posts' => '2',
61
+ 'wpemfb_show_posts' => 'false',
62
+ 'wpemfb_app_id' => '0',
63
+ 'wpemfb_app_secret' => '0',
64
+ 'wpemfb_proportions' => 0.36867,
65
+ 'wpemfb_height' => '221.202',
66
+ 'wpemfb_show_like' => 'true',
67
+ 'wpemfb_fb_root' => 'true',
68
+ 'wpemfb_theme' => 'default',
69
+ 'wpemfb_show_follow' => 'true',
70
+ 'wpemfb_video_ratio' => 'false',
71
+ 'wpemfb_video_as_post' => 'false',
72
+ 'wpemfb_raw_video' => 'false',
73
+ 'wpemfb_raw_photo' => 'false',
74
+ 'wpemfb_raw_post' => 'false',
75
+ 'wpemfb_raw_page' => 'false',
76
+ 'wpemfb_enqueue_style' => 'true',
77
+ 'wpemfb_enq_lightbox' => 'true',
78
+ 'wpemfb_enq_wpemfb' => 'true',
79
+ 'wpemfb_enq_fbjs' => 'true',
80
+ 'wpemfb_ev_local_tz' => 'false',
81
+ 'wpemfb_page_height' => '500',
82
+ 'wpemfb_page_show_faces' => 'true',
83
+ 'wpemfb_page_small_header' => 'false',
84
+ 'wpemfb_page_hide_cover' => 'false',
85
+ 'wpemfb_page_show_posts' => 'false',
86
+ 'wpemfb_sdk_lang' => array_key_exists(get_locale(), self::get_fb_locales()) ? get_locale() : 'en_US',
87
+ 'wpemfb_close_warning' => 'false',
88
  );
89
  }
90
  //("uninstalled","deactivated","activated","reactivated")
135
  self::get_url().'lib/js/fb.js',
136
  array( 'jquery' )
137
  );
138
+ $translation_array = array( 'local' => get_option('wpemfb_sdk_lang'), 'fb_id'=>get_option('wpemfb_app_id') == '0' ? '' : get_option('wpemfb_app_id'));
139
  wp_localize_script( 'wpemfb-fbjs', 'WEF', $translation_array );
140
  }
141
  }
166
  static function fb_root($content){
167
  return '<div id="fb-root"></div>'.PHP_EOL.$content;
168
  }
169
+ static function admin_notices(){
170
+ if(!self::has_fb_app()){
171
+ if(get_option('wpemfb_close_warning') == 'false') :
172
+ ?>
173
+ <div class="error notice wpemfb_warning is-dismissible">
174
+ <p><?php _e('Setup Facebook App Id and Secret to access custom embeds.','wp-embed-facebook') ?>
175
+ <a href="<?php echo admin_url("options-general.php?page=embedfacebook") ?>">
176
+ <?php _e('Settings.','wp-embed-facebook') ?>
177
+ </a>
178
+ </p>
179
+ </div>
180
+ <?php
181
+ endif;
182
+ } else {
183
+ //TODO rate and buy notice.
184
+ }
185
+ }
186
+ static function close_warning(){
187
+ if(current_user_can('manage_options'))
188
+ update_option('wpemfb_close_warning','true');
189
+ die;
190
+ }
191
+ static function has_fb_app(){
192
+ $app_id = get_option('wpemfb_app_id');
193
+ $app_secret = get_option('wpemfb_app_secret');
194
+ if(empty($app_id) || empty($app_id) || $app_id === '0' || $app_secret === '0' ){
195
+ return false;
196
+ } else {
197
+ return true;
198
+ }
199
+ }
200
+ static function get_fb_locales(){
201
+ return array(
202
+ 'af_ZA'=>'Afrikaans',
203
+ 'ak_GH'=>'Akan',
204
+ 'am_ET'=>'Amharic',
205
+ 'ar_AR'=>'Arabic',
206
+ 'as_IN'=>'Assamese',
207
+ 'ay_BO'=>'Aymara',
208
+ 'az_AZ'=>'Azerbaijani',
209
+ 'be_BY'=>'Belarusian',
210
+ 'bg_BG'=>'Bulgarian',
211
+ 'bn_IN'=>'Bengali',
212
+ 'br_FR'=>'Breton',
213
+ 'bs_BA'=>'Bosnian',
214
+ 'ca_ES'=>'Catalan',
215
+ 'cb_IQ'=>'Sorani Kurdish',
216
+ 'ck_US'=>'Cherokee',
217
+ 'co_FR'=>'Corsican',
218
+ 'cs_CZ'=>'Czech',
219
+ 'cx_PH'=>'Cebuano',
220
+ 'cy_GB'=>'Welsh',
221
+ 'da_DK'=>'Danish',
222
+ 'de_DE'=>'German',
223
+ 'el_GR'=>'Greek',
224
+ 'en_GB'=>'English (UK)',
225
+ 'en_IN'=>'English (India)',
226
+ 'en_PI'=>'English (Pirate)',
227
+ 'en_UD'=>'English (Upside Down)',
228
+ 'en_US'=>'English (US)',
229
+ 'eo_EO'=>'Esperanto',
230
+ 'es_CL'=>'Spanish (Chile)',
231
+ 'es_CO'=>'Spanish (Colombia)',
232
+ 'es_ES'=>'Spanish (Spain)',
233
+ 'es_LA'=>'Spanish',
234
+ 'es_MX'=>'Spanish (Mexico)',
235
+ 'es_VE'=>'Spanish (Venezuela)',
236
+ 'et_EE'=>'Estonian',
237
+ 'eu_ES'=>'Basque',
238
+ 'fa_IR'=>'Persian',
239
+ 'fb_LT'=>'Leet Speak',
240
+ 'ff_NG'=>'Fulah',
241
+ 'fi_FI'=>'Finnish',
242
+ 'fo_FO'=>'Faroese',
243
+ 'fr_CA'=>'French (Canada)',
244
+ 'fr_FR'=>'French (France)',
245
+ 'fy_NL'=>'Frisian',
246
+ 'ga_IE'=>'Irish',
247
+ 'gl_ES'=>'Galician',
248
+ 'gn_PY'=>'Guarani',
249
+ 'gu_IN'=>'Gujarati',
250
+ 'gx_GR'=>'Classical Greek',
251
+ 'ha_NG'=>'Hausa',
252
+ 'he_IL'=>'Hebrew',
253
+ 'hi_IN'=>'Hindi',
254
+ 'hr_HR'=>'Croatian',
255
+ 'hu_HU'=>'Hungarian',
256
+ 'hy_AM'=>'Armenian',
257
+ 'id_ID'=>'Indonesian',
258
+ 'ig_NG'=>'Igbo',
259
+ 'is_IS'=>'Icelandic',
260
+ 'it_IT'=>'Italian',
261
+ 'ja_JP'=>'Japanese',
262
+ 'ja_KS'=>'Japanese (Kansai)',
263
+ 'jv_ID'=>'Javanese',
264
+ 'ka_GE'=>'Georgian',
265
+ 'kk_KZ'=>'Kazakh',
266
+ 'km_KH'=>'Khmer',
267
+ 'kn_IN'=>'Kannada',
268
+ 'ko_KR'=>'Korean',
269
+ 'ku_TR'=>'Kurdish (Kurmanji)',
270
+ 'la_VA'=>'Latin',
271
+ 'lg_UG'=>'Ganda',
272
+ 'li_NL'=>'Limburgish',
273
+ 'ln_CD'=>'Lingala',
274
+ 'lo_LA'=>'Lao',
275
+ 'lt_LT'=>'Lithuanian',
276
+ 'lv_LV'=>'Latvian',
277
+ 'mg_MG'=>'Malagasy',
278
+ 'mk_MK'=>'Macedonian',
279
+ 'ml_IN'=>'Malayalam',
280
+ 'mn_MN'=>'Mongolian',
281
+ 'mr_IN'=>'Marathi',
282
+ 'ms_MY'=>'Malay',
283
+ 'mt_MT'=>'Maltese',
284
+ 'my_MM'=>'Burmese',
285
+ 'nb_NO'=>'Norwegian (bokmal)',
286
+ 'nd_ZW'=>'Ndebele',
287
+ 'ne_NP'=>'Nepali',
288
+ 'nl_BE'=>'Dutch (België)',
289
+ 'nl_NL'=>'Dutch',
290
+ 'nn_NO'=>'Norwegian (nynorsk)',
291
+ 'ny_MW'=>'Chewa',
292
+ 'or_IN'=>'Oriya',
293
+ 'pa_IN'=>'Punjabi',
294
+ 'pl_PL'=>'Polish',
295
+ 'ps_AF'=>'Pashto',
296
+ 'pt_BR'=>'Portuguese (Brazil)',
297
+ 'pt_PT'=>'Portuguese (Portugal)',
298
+ 'qu_PE'=>'Quechua',
299
+ 'rm_CH'=>'Romansh',
300
+ 'ro_RO'=>'Romanian',
301
+ 'ru_RU'=>'Russian',
302
+ 'rw_RW'=>'Kinyarwanda',
303
+ 'sa_IN'=>'Sanskrit',
304
+ 'sc_IT'=>'Sardinian',
305
+ 'se_NO'=>'Northern Sámi',
306
+ 'si_LK'=>'Sinhala',
307
+ 'sk_SK'=>'Slovak',
308
+ 'sl_SI'=>'Slovenian',
309
+ 'sn_ZW'=>'Shona',
310
+ 'so_SO'=>'Somali',
311
+ 'sq_AL'=>'Albanian',
312
+ 'sr_RS'=>'Serbian',
313
+ 'sv_SE'=>'Swedish',
314
+ 'sw_KE'=>'Swahili',
315
+ 'sy_SY'=>'Syriac',
316
+ 'sz_PL'=>'Silesian',
317
+ 'ta_IN'=>'Tamil',
318
+ 'te_IN'=>'Telugu',
319
+ 'tg_TJ'=>'Tajik',
320
+ 'th_TH'=>'Thai',
321
+ 'tk_TM'=>'Turkmen',
322
+ 'tl_PH'=>'Filipino',
323
+ 'tl_ST'=>'Klingon',
324
+ 'tr_TR'=>'Turkish',
325
+ 'tt_RU'=>'Tatar',
326
+ 'tz_MA'=>'Tamazight',
327
+ 'uk_UA'=>'Ukrainian',
328
+ 'ur_PK'=>'Urdu',
329
+ 'uz_UZ'=>'Uzbek',
330
+ 'vi_VN'=>'Vietnamese',
331
+ 'wo_SN'=>'Wolof',
332
+ 'xh_ZA'=>'Xhosa',
333
+ 'yi_DE'=>'Yiddish',
334
+ 'yo_NG'=>'Yoruba',
335
+ 'zh_CN'=>'Simplified Chinese (China)',
336
+ 'zh_HK'=>'Traditional Chinese (Hong Kong)',
337
+ 'zh_TW'=>'Traditional Chinese (Taiwan)',
338
+ 'zu_ZA'=>'Zulu',
339
+ 'zz_TR'=>'Zazaki',
340
+ );
341
+ }
342
  }
lib/class-wp-embed-fb.php CHANGED
@@ -55,11 +55,12 @@ class WP_Embed_FB {
55
  require_once "base_facebook.php";
56
  require_once "class-sigami-facebook.php";
57
  $config = array();
58
- $config['appId'] = get_option('wpemfb_app_id');
59
- $config['secret'] = get_option('wpemfb_app_secret');
60
- $config['fileUpload'] = false; // optional
61
- if($config['appId'] != '0' && $config['secret'] != '0' )
62
- self::$fbsdk = new Sigami_Facebook($config);
 
63
  return self::$fbsdk;
64
  }
65
  }
@@ -98,18 +99,20 @@ class WP_Embed_FB {
98
  }
99
  if(in_array('posts',$juiceArray)){
100
  $type = 'post';
101
- try{
102
- $data = $fbsdk->api('/'.$juiceArray[0].'?fields=id');
103
- $fb_id = $data['id'].'_'.$fb_id;
104
- } catch(FacebookApiException $e){
105
- $res = '<p><a href="https://www.facebook.com/'.$juice.'" target="_blank" rel="nofollow">https://www.facebook.com/'.$juice.'</a>';
106
- if(is_super_admin()){
107
- $error = $e->getResult();
108
- $res .= '<br><span style="color: #4a0e13">'.__('Code').':&nbsp;'.$error['error']['code'].' '.$type.'</span>';
109
- $res .= '<br><span style="color: #4a0e13">'.__('Error').':&nbsp;'.$error['error']['message'].'</span>';
 
 
 
 
110
  }
111
- $res .= '</p>';
112
- return $res;
113
  }
114
  }elseif(in_array('photos',$juiceArray) || in_array('photo.php',$juiceArray) ){
115
  $type = 'photo';
@@ -128,24 +131,28 @@ class WP_Embed_FB {
128
  */
129
  $type = apply_filters('wpemfb_embed_type', $type, $juiceArray);//TODO Check if this works ok with premium
130
  if(!$type){
131
- try{
132
- $metadata = $fbsdk->api('/'.$fb_id.'?metadata=1');
133
- $type = $metadata['metadata']['type'];
134
- } catch(FacebookApiException $e){
135
- $res = '<p><a href="https://www.facebook.com/'.$juice.'" target="_blank" rel="nofollow">https://www.facebook.com/'.$juice.'</a>';
136
- if(is_super_admin()){
137
- //TODO explain this type of error
138
- /*
139
- "message": "(#803) Cannot query users by their username ",
140
- "type": "OAuthException",
141
- "code": 803
142
- */
143
- $error = $e->getResult();
144
- $res .= '<br><span style="color: #4a0e13">'.__('Code').':&nbsp;'.$error['error']['code'].'</span>';
145
- $res .= '<br><span style="color: #4a0e13">'.__('Error').':&nbsp;'.$error['error']['message'].'</span>';
 
 
 
 
146
  }
147
- $res .= '</p>';
148
- return $res;
149
  }
150
  }
151
  $return = self::print_embed($fb_id,$type,$match[2]);
55
  require_once "base_facebook.php";
56
  require_once "class-sigami-facebook.php";
57
  $config = array();
58
+ if(WP_Embed_FB_Plugin::has_fb_app()){
59
+ $config['appId'] = get_option('wpemfb_app_id');
60
+ $config['secret'] = get_option('wpemfb_app_secret');
61
+ }
62
+ //$config['fileUpload'] = false; // optional
63
+ self::$fbsdk = new Sigami_Facebook($config);
64
  return self::$fbsdk;
65
  }
66
  }
99
  }
100
  if(in_array('posts',$juiceArray)){
101
  $type = 'post';
102
+ if(WP_Embed_FB_Plugin::has_fb_app()){
103
+ try{
104
+ $data = $fbsdk->api('/'.$juiceArray[0].'?fields=id');
105
+ $fb_id = $data['id'].'_'.$fb_id;
106
+ } catch(FacebookApiException $e){
107
+ $res = '<p><a href="https://www.facebook.com/'.$juice.'" target="_blank" rel="nofollow">https://www.facebook.com/'.$juice.'</a>';
108
+ if(is_super_admin()){
109
+ $error = $e->getResult();
110
+ $res .= '<br><span style="color: #4a0e13">'.__('Code').':&nbsp;'.$error['error']['code'].' '.$type.'</span>';
111
+ $res .= '<br><span style="color: #4a0e13">'.__('Error').':&nbsp;'.$error['error']['message'].'</span>';
112
+ }
113
+ $res .= '</p>';
114
+ return $res;
115
  }
 
 
116
  }
117
  }elseif(in_array('photos',$juiceArray) || in_array('photo.php',$juiceArray) ){
118
  $type = 'photo';
131
  */
132
  $type = apply_filters('wpemfb_embed_type', $type, $juiceArray);//TODO Check if this works ok with premium
133
  if(!$type){
134
+ if(WP_Embed_FB_Plugin::has_fb_app()){
135
+ try{
136
+ $metadata = $fbsdk->api('/'.$fb_id.'?metadata=1');
137
+ $type = $metadata['metadata']['type'];
138
+ } catch(FacebookApiException $e){
139
+ $res = '<p><a href="https://www.facebook.com/'.$juice.'" target="_blank" rel="nofollow">https://www.facebook.com/'.$juice.'</a>';
140
+ if(is_super_admin()){
141
+ //TODO explain this type of error
142
+ /*
143
+ "message": "(#803) Cannot query users by their username ",
144
+ "type": "OAuthException",
145
+ "code": 803
146
+ */
147
+ $error = $e->getResult();
148
+ $res .= '<br><span style="color: #4a0e13">'.__('Code').':&nbsp;'.$error['error']['code'].'</span>';
149
+ $res .= '<br><span style="color: #4a0e13">'.__('Error').':&nbsp;'.$error['error']['message'].'</span>';
150
+ }
151
+ $res .= '</p>';
152
+ return $res;
153
  }
154
+ } else {
155
+ $type = 'page';
156
  }
157
  }
158
  $return = self::print_embed($fb_id,$type,$match[2]);
lib/js/admin.js DELETED
@@ -1,3 +0,0 @@
1
- jQuery(function() {
2
- jQuery( "#accordion" ).accordion();
3
- });
 
 
 
lib/js/wpembedfb.js CHANGED
@@ -8,12 +8,6 @@ jQuery(window).resize(function(){
8
  });
9
  function resize_cover(){
10
  jQuery(".wef-measure > .cover").each(function(){
11
- //console.log(jQuery(one_cover));
12
  jQuery(this).css("height",0.368 * jQuery(this).width());
13
  });
14
- //var v_width = cover.width();
15
- //var v_height = 0.368 * v_width;
16
- //cover.css("height",v_height );
17
- //console.log(v_height);
18
- //console.log(jQuery(".wpemfb-cover").height());
19
  }
8
  });
9
  function resize_cover(){
10
  jQuery(".wef-measure > .cover").each(function(){
 
11
  jQuery(this).css("height",0.368 * jQuery(this).width());
12
  });
 
 
 
 
 
13
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: Facebook, facebook, Social Plugins, embed facebook, facebook video, facebook posts, facebook publication, facebook publications, facebook event, facebook events, facebook pages, facebook page, facebook profiles, facebook album, facebook albums, facebook photos, facebook photo, social,
5
  Requires at least: 3.8.1
6
  Tested up to: 4.3.2
7
- Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -54,13 +54,13 @@ Assuming all settings are in their default state.
54
 
55
  `[facebook=https://www.facebook.com/sydneyoperahouse ]`
56
 
57
- * Changing the number of posts shown
58
 
59
  `[facebook=https://www.facebook.com/sydneyoperahouse posts=2 ]`
60
 
61
  * Use facebook [page plugin](https://developers.facebook.com/docs/plugins/page-plugin)
62
 
63
- `[facebook=https://www.facebook.com/sydneyoperahouse social_plugin=page attributes=adapt_container,show_friends,small_cover,hide_cover,show_posts ]`
64
 
65
  All attributes are optional and if 'attributes' is not present it will use the default values
66
 
@@ -138,6 +138,12 @@ This is a facebook limitation, will try to work around it.
138
 
139
  == Changelog ==
140
 
 
 
 
 
 
 
141
  = 2.0.1 =
142
  * Fixed message on photo single post
143
 
@@ -294,5 +300,5 @@ This is a facebook limitation, will try to work around it.
294
 
295
  == Upgrade Notice ==
296
 
297
- = 2.0.1 =
298
- * show messages on picture single post
4
  Tags: Facebook, facebook, Social Plugins, embed facebook, facebook video, facebook posts, facebook publication, facebook publications, facebook event, facebook events, facebook pages, facebook page, facebook profiles, facebook album, facebook albums, facebook photos, facebook photo, social,
5
  Requires at least: 3.8.1
6
  Tested up to: 4.3.2
7
+ Stable tag: 2.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
54
 
55
  `[facebook=https://www.facebook.com/sydneyoperahouse ]`
56
 
57
+ * Changing the number of posts shown only for custom embeds
58
 
59
  `[facebook=https://www.facebook.com/sydneyoperahouse posts=2 ]`
60
 
61
  * Use facebook [page plugin](https://developers.facebook.com/docs/plugins/page-plugin)
62
 
63
+ `[facebook=https://www.facebook.com/sydneyoperahouse social_plugin=true ]`
64
 
65
  All attributes are optional and if 'attributes' is not present it will use the default values
66
 
138
 
139
  == Changelog ==
140
 
141
+ = 2.0.2 =
142
+ * Added options for page social plugins
143
+ * Changed admin layout
144
+ * Does not need facebook app for simple embeds
145
+ * More human friendly
146
+
147
  = 2.0.1 =
148
  * Fixed message on photo single post
149
 
300
 
301
  == Upgrade Notice ==
302
 
303
+ = 2.0.2 =
304
+ * More human friendly.
wp-embed-facebook.php CHANGED
@@ -4,14 +4,18 @@ Plugin Name: WP Embed Facebook
4
  Plugin URI: http://www.wpembedfb.com
5
  Description: Embed any public Facebook video, photo, album, event, page, profile, or post. Copy the facebook url to a single line on your post, or use shortcode [facebook=url ] more information at <a href="http://www.wpembedfb.com" title="plugin website">www.wpembedfb.com</a>
6
  Author: Miguel Sirvent
7
- Version: 2.0.1
8
  Author URI: http://profiles.wordpress.org/poxtron/
9
  */
 
 
10
  require_once('lib/class-wp-embed-fb-plugin.php');
11
  require_once('lib/class-wef-social-plugins.php');
12
  require_once('lib/class-wp-embed-fb.php');
13
 
14
- add_action('init',array('WP_Embed_FB_Plugin','init'),1);//DONE
 
 
15
 
16
  register_activation_hook(__FILE__, array('WP_Embed_FB_Plugin', 'install') );
17
  register_uninstall_hook(__FILE__, array('WP_Embed_FB_Plugin', 'uninstall') );
4
  Plugin URI: http://www.wpembedfb.com
5
  Description: Embed any public Facebook video, photo, album, event, page, profile, or post. Copy the facebook url to a single line on your post, or use shortcode [facebook=url ] more information at <a href="http://www.wpembedfb.com" title="plugin website">www.wpembedfb.com</a>
6
  Author: Miguel Sirvent
7
+ Version: 2.0.2
8
  Author URI: http://profiles.wordpress.org/poxtron/
9
  */
10
+
11
+
12
  require_once('lib/class-wp-embed-fb-plugin.php');
13
  require_once('lib/class-wef-social-plugins.php');
14
  require_once('lib/class-wp-embed-fb.php');
15
 
16
+ add_action('init',array('WP_Embed_FB_Plugin','init'));
17
+ add_action('admin_notices',array('WP_Embed_FB_Plugin','admin_notices'));
18
+ add_action('wp_ajax_close_warning',array('WP_Embed_FB_Plugin','close_warning'));
19
 
20
  register_activation_hook(__FILE__, array('WP_Embed_FB_Plugin', 'install') );
21
  register_uninstall_hook(__FILE__, array('WP_Embed_FB_Plugin', 'uninstall') );