Open Graph for Facebook, Google+ and Twitter Card Tags - Version 2.0.6

Version Description

  • New fb_og_enabled filter that allow other plugins/themes to completely disable the tags output on specific situations
  • Fix: Use WP_PLUGIN_DIR instead of harcoded paths (Thanks thomasbachem)
  • Fix: Extra validation when getting Yoast SEO's icon on the 3rd party settings tab
Download this release

Release Info

Developer webdados
Plugin Icon Open Graph for Facebook, Google+ and Twitter Card Tags
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

admin/options-page-3rdparty.php CHANGED
@@ -24,11 +24,15 @@ global $webdados_fb;
24
  <div class="postbox">
25
  <h3 class="hndle">
26
  <?php
27
- if ( $webdados_fb->is_yoast_seo_active() ) {
28
  $wpseo_utils = new WPSEO_Utils();
29
- ?>
30
- <img src="<?php echo 'data:image/svg+xml;base64,' . base64_encode( str_replace('fill:#82878c', 'fill:#23282d', $wpseo_utils->get_icon_svg(false) ) ) ; ?>"/>
31
- <?php
 
 
 
 
32
  } else {
33
  ?><i class="dashicons-before dashicons-editor-code"></i><?php
34
  }
24
  <div class="postbox">
25
  <h3 class="hndle">
26
  <?php
27
+ if ( $webdados_fb->is_yoast_seo_active() && class_exists('WPSEO_Utils') ) {
28
  $wpseo_utils = new WPSEO_Utils();
29
+ if( method_exists($wpseo_utils, 'get_icon_svg') ) {
30
+ ?>
31
+ <img src="<?php echo 'data:image/svg+xml;base64,' . base64_encode( str_replace('fill:#82878c', 'fill:#23282d', $wpseo_utils->get_icon_svg(false) ) ) ; ?>"/>
32
+ <?php
33
+ } else {
34
+ ?><i class="dashicons-before dashicons-editor-code"></i><?php
35
+ }
36
  } else {
37
  ?><i class="dashicons-before dashicons-editor-code"></i><?php
38
  }
admin/options-page-facebook.php CHANGED
@@ -230,7 +230,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
230
  $info = curl_getinfo($ch);
231
  if (intval($info['http_code'])==200) {
232
  //Save the file locally
233
- $fh = fopen(ABSPATH . 'wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/FacebookLocales.xml', 'w') or die("Can't open file");
234
  fwrite($fh, $fb_locales);
235
  fclose($fh);
236
  $listLocales=true;
@@ -243,7 +243,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
243
  }
244
  //Offline
245
  if (!$listLocales) {
246
- if ($fb_locales=file_get_contents(ABSPATH . 'wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/FacebookLocales.xml')) {
247
  $listLocales=true;
248
  $loadedOffline=true;
249
  }
230
  $info = curl_getinfo($ch);
231
  if (intval($info['http_code'])==200) {
232
  //Save the file locally
233
+ $fh = fopen(WP_PLUGIN_DIR . '/wonderm00ns-simple-facebook-open-graph-tags/includes/FacebookLocales.xml', 'w') or die("Can't open file");
234
  fwrite($fh, $fb_locales);
235
  fclose($fh);
236
  $listLocales=true;
243
  }
244
  //Offline
245
  if (!$listLocales) {
246
+ if ($fb_locales=file_get_contents(WP_PLUGIN_DIR . '/wonderm00ns-simple-facebook-open-graph-tags/includes/FacebookLocales.xml')) {
247
  $listLocales=true;
248
  $loadedOffline=true;
249
  }
public/class-webdados-fb-open-graph-public.php CHANGED
@@ -42,266 +42,269 @@ class Webdados_FB_Public {
42
  public function insert_meta_tags() {
43
  global $webdados_fb, $wp_query;
44
 
45
- //Also set Title Tag? - Needed??
46
- $fb_set_title_tag=0;
47
-
48
- //Init values
49
- $fb_locale = '';
50
- $fb_title = '';
51
- $fb_url = '';
52
- $fb_desc = '';
53
- $fb_image = '';
54
- $fb_type = 'article';
55
- $fb_author = '';
56
- $fb_author_meta = '';
57
- $fb_author_linkrelgp = '';
58
- $fb_author_twitter = '';
59
- $fb_article_pub_date = '';
60
- $fb_article_mod_date = '';
61
- $fb_image_additional = array();
62
- $fb_additional_tags = array(
63
- 'name' => array(),
64
- 'property' => array(),
65
- );
66
- $fb_publisher = trim($this->options['fb_publisher']);
67
- $fb_publisher_schema = trim($this->options['fb_publisher_schema']);
68
- $fb_publisher_twitteruser = trim($this->options['fb_publisher_twitteruser']);
69
-
70
- //Homepage Description
71
- switch( $this->options['fb_desc_homepage'] ) {
72
- case 'custom':
73
- $fb_desc_homepage = $this->options['fb_desc_homepage_customtext'];
74
- //WPML?
75
- if ( $webdados_fb->is_wpml_active() ) {
76
- global $sitepress;
77
- if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
78
- $fb_desc_homepage = icl_t( 'wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc_homepage );
79
- }
80
- }
81
- break;
82
- default:
83
- $fb_desc_homepage = get_bloginfo( 'description' );
84
- break;
85
- }
86
-
87
  //Open tag
88
  $html='
89
  <!-- START - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
90
  ';
91
 
92
- if ( is_singular() ) {
93
-
94
- global $post;
95
- // Title
96
- //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page
97
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( $post->post_title ), true ) );
98
- //SubHeading
99
- if ( isset($this->options['fb_show_subheading']) && intval($this->options['fb_show_subheading'])==1 && $webdados_fb->is_subheading_plugin_active() ) {
100
- if (isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
101
- $fb_title = trim( trim(get_the_subheading()).' - '.trim($fb_title), ' -' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  } else {
103
- $fb_title = trim( trim($fb_title).' - '.trim(get_the_subheading()), ' -' );
 
104
  }
105
- }
106
- // URL
107
- $fb_url = get_permalink();
108
- // Type if it's a homepage page
109
- if ( is_front_page() ) {
110
- /* Fix homepage type when it's a static page */
111
- $fb_url = get_option('home' ).(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '' );
112
- $fb_type = trim($this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage']);
113
- }
114
- // Description
115
- if ( trim($post->post_excerpt) != '' ) {
116
- //If there's an excerpt that's what we'll use
117
- $fb_desc = trim($post->post_excerpt);
118
- } else {
119
- //If not we grab it from the content
120
- $fb_desc = trim($post->post_content);
121
- }
122
- // Image
123
- if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
124
- $fb_image = $this->get_post_image();
125
- }
126
- // Author
127
- $author_id = $post->post_author;
128
- if ( $author_id > 0 && ! ( is_page() && intval($this->options['fb_author_hide_on_pages'])==1 ) ) {
129
- $fb_author = get_the_author_meta('facebook', $author_id);
130
- $fb_author_meta = get_the_author_meta('display_name', $author_id);
131
- $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id);
132
- $fb_author_twitter = get_the_author_meta('twitter', $author_id);
133
- }
134
-
135
- //Published and Modified time - We should check this out and maybe have it for any kind of post...
136
- if ( is_singular('post' ) ) {
137
- $fb_article_pub_date = get_the_date('c' );
138
- $fb_article_mod_date = get_the_modified_date('c' );
139
- } else {
140
- //Reset dates show because we're not on posts
141
- $this->options['fb_article_dates_show'] = 0;
142
- }
143
- //Sections
144
- if ( is_singular('post' ) ) {
145
- $cats = get_the_category();
146
- if ( !is_wp_error($cats) && (is_array($cats) && count($cats)>0) ) {
147
- $fb_sections = array();
148
- foreach ($cats as $cat) {
149
- $fb_sections[] = $cat->name;
150
  }
 
 
151
  }
152
- } else {
153
- $this->options['fb_article_sections_show'] = 0;
154
- }
155
- // Business Directory Plugin
156
- if ( isset( $this->options['fb_show_businessdirectoryplugin'] ) && $webdados_fb->is_business_directory_active() ) {
157
- global $wpbdp;
158
- $bdp_action = wpbdp_current_action();
159
- $bdp_disable_cpt = wpbdp_get_option( 'disable-cpt' );
160
- $current_view_object = $wpbdp->dispatcher->current_view_object();
161
- switch( $bdp_action ) {
162
- case 'show_listing':
163
- $fb_title = trim( esc_attr( wp_strip_all_tags( stripslashes( $this->post->post_title ), true ) ).' - '.$fb_title, ' -' );
164
- $fb_set_title_tag = 1;
165
- $fb_url = get_permalink($this->post->ID);
166
- if ( trim($this->post->post_excerpt)!='' ) {
167
- //If there's an excerpt that's what we'll use
168
- $fb_desc = trim($this->post->post_excerpt);
169
- } else {
170
- //If not we grab it from the content
171
- $fb_desc = trim($this->post->post_content);
172
- }
173
- if (intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1) {
174
- $thumbdone = false;
175
- if ( intval($this->options['fb_image_use_featured'])==1 ) {
176
- //Featured
177
- if ( $id_attachment = get_post_thumbnail_id( $this->post->ID ) ) {
178
- //There's a featured/thumbnail image for this listing
179
- $fb_image = wp_get_attachment_url( $id_attachment, false );
180
- $thumbdone = true;
181
- } else {
182
  }
183
- }
184
- if ( !$thumbdone ) {
185
- //Main image loaded
186
- if ( $thumbnail_id = wpbdp_listings_api()->get_thumbnail_id( $this->post->ID ) ) {
187
- $fb_image = wp_get_attachment_url( $thumbnail_id, false );
188
- $thumbdone = true;
189
  }
190
  }
191
- }
192
  }
193
- }
194
- // WooCommerce
195
- if ( $webdados_fb->is_woocommerce_active() && is_product() ) {
196
- $fb_type = 'product';
197
- $product = new WC_Product( $post->ID );
198
- //Price
199
- $fb_additional_tags['property']['og_price_amount'] = array(
200
- $product->get_price_including_tax()
201
- );
202
- if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['property']['og_price_currency'] = array(
203
- get_woocommerce_currency()
204
- );
205
- $fb_additional_tags['name']['twitter_label1'] = array(
206
- __('Price', 'wd-fb-og')
207
- );
208
- if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['name']['twitter_data1'] = array(
209
- $product->get_price_including_tax().' '.get_woocommerce_currency()
210
- );
211
- //Additional product images?
212
- if ( intval($this->options['fb_image_show'])==1 && $this->options['fb_wc_useproductgallery']==1 ) {
213
- if ( $attachment_ids = $product->get_gallery_attachment_ids() ) {
214
- foreach ( $attachment_ids as $attachment_id ) {
215
- if ( $image_link = wp_get_attachment_url( $attachment_id ) ) {
216
- if ( trim($image_link)!='' ) {
217
- $fb_image_additional[] = array(
218
- 'fb_image' => trim($image_link),
219
- 'png_overlay' => ( intval($this->options['fb_wc_usepg_png_overlay']) ? true : false ),
220
- );
221
  }
222
  }
223
  }
224
  }
225
  }
226
- }
227
-
228
- } else {
229
-
230
- //Other pages - Defaults
231
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_bloginfo( 'name' ) ), true ) );
232
- $fb_url = ( ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //Not really canonical but will work for now
233
- $fb_image = trim( $this->options['fb_image'] );
234
-
235
- $this->options['fb_article_sections_show'] = 0;
236
- $this->options['fb_article_dates_show'] = 0;
237
- $this->options['fb_author_show'] = 0;
238
- $this->options['fb_author_show_meta'] = 0;
239
- $this->options['fb_author_show_linkrelgp'] = 0;
240
- $this->options['fb_author_show_twitter'] = 0;
241
- $this->options['fb_author_show_twitter'] = 0;
242
-
243
- //Category
244
- if ( is_category() ) {
245
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_cat_title( '', false ) ), true ) );
246
- $term = $wp_query->get_queried_object();
247
- $fb_url = get_term_link( $term, $term->taxonomy );
248
- $cat_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( category_description() ), true ) ) );
249
- if ( trim($cat_desc)!='' ) $fb_desc = $cat_desc;
250
  } else {
251
- if ( is_tag() ) {
252
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_tag_title( '', false ) ), true ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  $term = $wp_query->get_queried_object();
254
  $fb_url = get_term_link( $term, $term->taxonomy );
255
- $tag_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( tag_description() ), true ) ) );
256
- if ( trim($tag_desc)!='' ) $fb_desc = $tag_desc;
257
  } else {
258
- if (is_tax()) {
259
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_term_title( '', false ) ), true ) );
260
  $term = $wp_query->get_queried_object();
261
- $fb_url = get_term_link($term, $term->taxonomy);
262
- $tax_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( term_description() ), true ) ) );
263
- if ( trim($tax_desc)!='' ) $fb_desc = $tag_desc;
264
- //WooCommerce
265
- if ( $webdados_fb->is_woocommerce_active() && intval($this->options['fb_wc_usecategthumb'])==1 && is_product_category() ) {
266
- if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
267
- if ( $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ) ) {
268
- if ( $image = wp_get_attachment_url( $thumbnail_id ) ) {
269
- $fb_image = $image;
 
 
 
 
 
 
 
 
270
  }
271
  }
272
  }
273
- }
274
- } else {
275
- if ( is_search() ) {
276
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( __('Search for', 'wd-fb-og').' "'.get_search_query().'"' ), true ) );
277
- $fb_url = get_search_link();
278
  } else {
279
- if (is_author()) {
280
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_the_author_meta('display_name', get_query_var('author') ) ), true ) );
281
- $fb_url = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
282
  } else {
283
- if ( is_archive() ) {
284
- if ( is_day() ) {
285
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'day' ) . ' ' .single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
286
- $fb_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
287
- } else {
288
- if ( is_month() ) {
289
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
290
- $fb_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
291
  } else {
292
- if ( is_year() ) {
293
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'year' ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
294
- $fb_url = get_year_link( get_query_var( 'year' ) );
 
 
 
 
 
295
  }
296
  }
297
- }
298
- } else {
299
- if (is_front_page()) {
300
- $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '');
301
- $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
302
- $fb_desc = $fb_desc_homepage;
303
  } else {
304
- //Others... Defaults already set up there
 
 
 
 
 
 
305
  }
306
  }
307
  }
@@ -309,191 +312,190 @@ class Webdados_FB_Public {
309
  }
310
  }
311
  }
312
- }
313
-
314
- //og:type for WPML root page?
315
- if ( $webdados_fb->is_wpml_active() ) {
316
- if ( class_exists('WPML_Root_Page') ) {
317
- if ( WPML_Root_Page::is_current_request_root() ) {
318
- $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
319
  }
320
  }
321
- }
322
-
323
-
324
-
325
- //Default description, if empty until now
326
- if ( trim($fb_desc)=='' ) {
327
- switch( $this->options['fb_desc_default_option'] ) {
328
- case 'custom':
329
- $fb_desc = $this->options['fb_desc_default'];
330
- //WPML?
331
- if ( $webdados_fb->is_wpml_active() ) {
332
- global $sitepress;
333
- if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
334
- $fb_desc = icl_t( 'wd-fb-og', 'wd_fb_og_fb_desc_default', $fb_desc );
335
  }
336
- }
337
- break;
338
- default:
339
- $fb_desc = $fb_desc_homepage;
340
- break;
341
  }
342
- }
343
-
344
- //Trim description
345
- $fb_desc = trim( str_replace('&nbsp;', ' ', $fb_desc) ); //Non-breaking spaces are usefull on a meta description. We'll just convert them to normal spaces to really trim it
346
- $fb_desc = trim(
347
- intval($this->options['fb_desc_chars'])>0
348
- ?
349
- mb_substr( wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) ), 0, intval($this->options['fb_desc_chars']) )
350
- :
351
- wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) )
352
- );
353
-
354
- //YOAST SEO?
355
- if ( $this->options['fb_show_wpseoyoast']==1 ) {
356
- if ( $webdados_fb->is_yoast_seo_active() ) {
357
- $wpseo = WPSEO_Frontend::get_instance();
358
- //Title
359
- $fb_title_temp = $wpseo->title(false);
360
- $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
361
- //Title - SubHeading plugin
362
- if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
363
- if ( $webdados_fb->is_subheading_plugin_active() ) {
364
- if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
365
- $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
366
- } else {
367
- $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
368
  }
369
  }
 
 
 
 
 
 
370
  }
371
- //URL
372
- $fb_url_temp = $wpseo->canonical(false);
373
- $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);
374
- //Description
375
- $fb_desc_temp = $wpseo->metadesc(false);
376
- $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
377
  }
378
- }
379
-
380
- //All in One SEO Pack?
381
- if ( $this->options['fb_show_aioseop']==1 ) {
382
- if ( $webdados_fb->is_aioseop_active() ) {
383
- global $aiosp;
384
- //Title - Why are we getting the first post title on archives and homepage...?!?
385
- $fb_title_temp = $aiosp->orig_title;
386
- $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
387
- //Title - SubHeading plugin
388
- if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
389
- if ( $webdados_fb->is_subheading_plugin_active() ) {
390
- if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
391
- $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
392
- } else {
393
- $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
394
  }
395
  }
396
- }
397
- //URL - See aioseop_class.php 3898 - We have a problem because wp_query is not the same right now
398
- /*$fb_url_temp = '';
399
- $aioseop_options = get_option( 'aioseop_options' );
400
- $opts = $aiosp->meta_opts;
401
- var_dump($wp_query);
402
- $show_page = true;
403
- if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) {
404
- $show_page = false;
405
- }
406
- if ( $aioseop_options['aiosp_can'] ) {
407
- if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) {
408
- $fb_url_temp = $opts['aiosp_custom_link'];
409
  }
410
- if ( empty( $url ) ) {
411
- $fb_url_temp = $aiosp->aiosp_mrt_get_url( $wp_query, $show_page );
 
 
 
 
 
 
 
 
 
412
  }
413
-
414
- $fb_url_temp = $aiosp->validate_url_scheme( $fb_url_temp );
415
-
416
- $fb_url_temp = apply_filters( 'aioseop_canonical_url', $fb_url_temp );
417
- }
418
- var_dump($fb_url_temp);
419
- $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);*/
420
- //Description - Why are we getting the first post description on archives and homepage...?!?
421
- if ( is_home() && ! is_front_page() ) {
422
- $post = aiosp_common::get_blog_page();
423
- } else {
424
- $post = $aiosp->get_queried_object();
425
  }
426
- $fb_desc_temp = apply_filters( 'aioseop_description', $aiosp->get_main_description( $post ) );
427
- $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
428
-
429
  }
430
- }
431
-
432
- //Apply Filters
433
- $fb_locale = apply_filters('fb_og_locale', $fb_locale);
434
- $fb_title = apply_filters('fb_og_title', $fb_title);
435
- $fb_url = apply_filters('fb_og_url', $fb_url);
436
- $fb_type = apply_filters('fb_og_type', $fb_type);
437
- $fb_desc = apply_filters('fb_og_desc', $fb_desc);
438
- $fb_image = apply_filters('fb_og_image', $fb_image);
439
- $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional);
440
-
441
- //Image size
442
- $fb_image_size = false;
443
- if ( intval($this->options['fb_image_show'])==1 && trim($fb_image)!='' ) {
444
- if ( intval($this->options['fb_image_size_show'])==1 ) {
445
- if ( isset($this->image_size) && is_array($this->image_size) ) { //Already fetched
446
- $fb_image_size = $this->image_size;
447
- } else {
448
- $fb_image_size = $this->get_open_graph_image_size($fb_image);
449
  }
 
 
450
  }
451
- } else {
452
- $this->options['fb_image_show'] = 0;
453
- }
454
-
455
- //Image overlay - Single?
456
- if ( intval($this->options['fb_image_show'])==1 && intval($this->options['fb_image_overlay'])==1 && apply_filters('fb_og_image_overlay', true, $fb_image) ) {
457
- //Single
458
- $temp_fb_image_overlay = $this->get_image_with_overlay($fb_image);
459
- if ( $temp_fb_image_overlay['overlay'] ) {
460
- $fb_image = $temp_fb_image_overlay['fb_image'];
461
- //We know the exact size now. We better just show it, right?
462
- $this->options['fb_image_size_show'] = 1;
463
- $fb_image_size = array(WEBDADOS_FB_W, WEBDADOS_FB_H);
464
- }
465
- //Additional
466
- if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)>0 ) {
467
- foreach($fb_image_additional as $key => $value ) {
468
- if ($value['png_overlay']) {
469
- $temp_fb_image_overlay = $this->get_image_with_overlay($value['fb_image']);
470
- if ( $temp_fb_image_overlay['overlay'] ) {
471
- $fb_image_additional[$key]['fb_image'] = $temp_fb_image_overlay['fb_image'];
472
  }
473
  }
474
  }
475
  }
476
- }
477
-
478
- //No spaces on URLs
479
- if ( isset($fb_url) && trim($fb_url)!='' ) $fb_url= str_replace(' ', '%20', trim($fb_url));
480
- if ( isset($fb_publisher) && trim($fb_publisher)!='' ) $fb_publisher= str_replace(' ', '%20', trim($fb_publisher));
481
- if ( isset($fb_publisher_schema) && trim($fb_publisher_schema)!='' ) $fb_publisher_schema= str_replace(' ', '%20', trim($fb_publisher_schema));
482
- if ( isset($fb_author) && trim($fb_author)!='' ) $fb_author= str_replace(' ', '%20', trim($fb_author));
483
- if ( isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp)!='' ) $fb_author_linkrelgp= str_replace(' ', '%20', trim($fb_author_linkrelgp));
484
- if ( isset($fb_image) && trim($fb_image)!='' ) $fb_image= str_replace(' ', '%20', trim($fb_image));
485
- if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) ) {
486
- foreach ( $fb_image_additional as $key => $value ) {
487
- $fb_image_additional[$key]['fb_image'] = str_replace( ' ', '%20', trim($value['fb_image']) );
488
  }
489
- }
490
-
491
- //If there's still no description let's just add the title as a last resort
492
- if ( trim($fb_desc)=='' ) $fb_desc = $fb_title;
493
-
494
- //Print tags
495
- // Facebook
496
- $html.=' <!-- Facebook Open Graph -->
497
  ';
498
  //Locale
499
  if ( intval($this->options['fb_locale_show'])==1 ) $html.=' <meta property="og:locale" content="'.trim(esc_attr( trim($this->options['fb_locale'])!='' ? trim($this->options['fb_locale']) : trim(get_locale()) )).'"/>
@@ -626,7 +628,13 @@ class Webdados_FB_Public {
626
  }
627
  }
628
  }
 
 
 
 
629
 
 
 
630
  //Close tag
631
  $html.='<!-- END - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
632
 
42
  public function insert_meta_tags() {
43
  global $webdados_fb, $wp_query;
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  //Open tag
46
  $html='
47
  <!-- START - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
48
  ';
49
 
50
+ if ( apply_filters('fb_og_enabled', true) ) {
51
+
52
+ //Also set Title Tag? - Needed??
53
+ $fb_set_title_tag=0;
54
+
55
+ //Init values
56
+ $fb_locale = '';
57
+ $fb_title = '';
58
+ $fb_url = '';
59
+ $fb_desc = '';
60
+ $fb_image = '';
61
+ $fb_type = 'article';
62
+ $fb_author = '';
63
+ $fb_author_meta = '';
64
+ $fb_author_linkrelgp = '';
65
+ $fb_author_twitter = '';
66
+ $fb_article_pub_date = '';
67
+ $fb_article_mod_date = '';
68
+ $fb_image_additional = array();
69
+ $fb_additional_tags = array(
70
+ 'name' => array(),
71
+ 'property' => array(),
72
+ );
73
+ $fb_publisher = trim($this->options['fb_publisher']);
74
+ $fb_publisher_schema = trim($this->options['fb_publisher_schema']);
75
+ $fb_publisher_twitteruser = trim($this->options['fb_publisher_twitteruser']);
76
+
77
+ //Homepage Description
78
+ switch( $this->options['fb_desc_homepage'] ) {
79
+ case 'custom':
80
+ $fb_desc_homepage = $this->options['fb_desc_homepage_customtext'];
81
+ //WPML?
82
+ if ( $webdados_fb->is_wpml_active() ) {
83
+ global $sitepress;
84
+ if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
85
+ $fb_desc_homepage = icl_t( 'wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc_homepage );
86
+ }
87
+ }
88
+ break;
89
+ default:
90
+ $fb_desc_homepage = get_bloginfo( 'description' );
91
+ break;
92
+ }
93
+
94
+ if ( is_singular() ) {
95
+
96
+ global $post;
97
+ // Title
98
+ //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page
99
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( $post->post_title ), true ) );
100
+ //SubHeading
101
+ if ( isset($this->options['fb_show_subheading']) && intval($this->options['fb_show_subheading'])==1 && $webdados_fb->is_subheading_plugin_active() ) {
102
+ if (isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
103
+ $fb_title = trim( trim(get_the_subheading()).' - '.trim($fb_title), ' -' );
104
+ } else {
105
+ $fb_title = trim( trim($fb_title).' - '.trim(get_the_subheading()), ' -' );
106
+ }
107
+ }
108
+ // URL
109
+ $fb_url = get_permalink();
110
+ // Type if it's a homepage page
111
+ if ( is_front_page() ) {
112
+ /* Fix homepage type when it's a static page */
113
+ $fb_url = get_option('home' ).(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '' );
114
+ $fb_type = trim($this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage']);
115
+ }
116
+ // Description
117
+ if ( trim($post->post_excerpt) != '' ) {
118
+ //If there's an excerpt that's what we'll use
119
+ $fb_desc = trim($post->post_excerpt);
120
  } else {
121
+ //If not we grab it from the content
122
+ $fb_desc = trim($post->post_content);
123
  }
124
+ // Image
125
+ if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
126
+ $fb_image = $this->get_post_image();
127
+ }
128
+ // Author
129
+ $author_id = $post->post_author;
130
+ if ( $author_id > 0 && ! ( is_page() && intval($this->options['fb_author_hide_on_pages'])==1 ) ) {
131
+ $fb_author = get_the_author_meta('facebook', $author_id);
132
+ $fb_author_meta = get_the_author_meta('display_name', $author_id);
133
+ $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id);
134
+ $fb_author_twitter = get_the_author_meta('twitter', $author_id);
135
+ }
136
+
137
+ //Published and Modified time - We should check this out and maybe have it for any kind of post...
138
+ if ( is_singular('post' ) ) {
139
+ $fb_article_pub_date = get_the_date('c' );
140
+ $fb_article_mod_date = get_the_modified_date('c' );
141
+ } else {
142
+ //Reset dates show because we're not on posts
143
+ $this->options['fb_article_dates_show'] = 0;
144
+ }
145
+ //Sections
146
+ if ( is_singular('post' ) ) {
147
+ $cats = get_the_category();
148
+ if ( !is_wp_error($cats) && (is_array($cats) && count($cats)>0) ) {
149
+ $fb_sections = array();
150
+ foreach ($cats as $cat) {
151
+ $fb_sections[] = $cat->name;
152
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
154
+ } else {
155
+ $this->options['fb_article_sections_show'] = 0;
156
  }
157
+ // Business Directory Plugin
158
+ if ( isset( $this->options['fb_show_businessdirectoryplugin'] ) && $webdados_fb->is_business_directory_active() ) {
159
+ global $wpbdp;
160
+ $bdp_action = wpbdp_current_action();
161
+ $bdp_disable_cpt = wpbdp_get_option( 'disable-cpt' );
162
+ $current_view_object = $wpbdp->dispatcher->current_view_object();
163
+ switch( $bdp_action ) {
164
+ case 'show_listing':
165
+ $fb_title = trim( esc_attr( wp_strip_all_tags( stripslashes( $this->post->post_title ), true ) ).' - '.$fb_title, ' -' );
166
+ $fb_set_title_tag = 1;
167
+ $fb_url = get_permalink($this->post->ID);
168
+ if ( trim($this->post->post_excerpt)!='' ) {
169
+ //If there's an excerpt that's what we'll use
170
+ $fb_desc = trim($this->post->post_excerpt);
171
+ } else {
172
+ //If not we grab it from the content
173
+ $fb_desc = trim($this->post->post_content);
174
+ }
175
+ if (intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1) {
176
+ $thumbdone = false;
177
+ if ( intval($this->options['fb_image_use_featured'])==1 ) {
178
+ //Featured
179
+ if ( $id_attachment = get_post_thumbnail_id( $this->post->ID ) ) {
180
+ //There's a featured/thumbnail image for this listing
181
+ $fb_image = wp_get_attachment_url( $id_attachment, false );
182
+ $thumbdone = true;
183
+ } else {
184
+ }
 
 
185
  }
186
+ if ( !$thumbdone ) {
187
+ //Main image loaded
188
+ if ( $thumbnail_id = wpbdp_listings_api()->get_thumbnail_id( $this->post->ID ) ) {
189
+ $fb_image = wp_get_attachment_url( $thumbnail_id, false );
190
+ $thumbdone = true;
191
+ }
192
  }
193
  }
194
+ }
195
  }
196
+ // WooCommerce
197
+ if ( $webdados_fb->is_woocommerce_active() && is_product() ) {
198
+ $fb_type = 'product';
199
+ $product = new WC_Product( $post->ID );
200
+ //Price
201
+ $fb_additional_tags['property']['og_price_amount'] = array(
202
+ $product->get_price_including_tax()
203
+ );
204
+ if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['property']['og_price_currency'] = array(
205
+ get_woocommerce_currency()
206
+ );
207
+ $fb_additional_tags['name']['twitter_label1'] = array(
208
+ __('Price', 'wd-fb-og')
209
+ );
210
+ if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['name']['twitter_data1'] = array(
211
+ $product->get_price_including_tax().' '.get_woocommerce_currency()
212
+ );
213
+ //Additional product images?
214
+ if ( intval($this->options['fb_image_show'])==1 && $this->options['fb_wc_useproductgallery']==1 ) {
215
+ if ( $attachment_ids = $product->get_gallery_attachment_ids() ) {
216
+ foreach ( $attachment_ids as $attachment_id ) {
217
+ if ( $image_link = wp_get_attachment_url( $attachment_id ) ) {
218
+ if ( trim($image_link)!='' ) {
219
+ $fb_image_additional[] = array(
220
+ 'fb_image' => trim($image_link),
221
+ 'png_overlay' => ( intval($this->options['fb_wc_usepg_png_overlay']) ? true : false ),
222
+ );
223
+ }
224
  }
225
  }
226
  }
227
  }
228
  }
229
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  } else {
231
+
232
+ //Other pages - Defaults
233
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_bloginfo( 'name' ) ), true ) );
234
+ $fb_url = ( ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //Not really canonical but will work for now
235
+ $fb_image = trim( $this->options['fb_image'] );
236
+
237
+ $this->options['fb_article_sections_show'] = 0;
238
+ $this->options['fb_article_dates_show'] = 0;
239
+ $this->options['fb_author_show'] = 0;
240
+ $this->options['fb_author_show_meta'] = 0;
241
+ $this->options['fb_author_show_linkrelgp'] = 0;
242
+ $this->options['fb_author_show_twitter'] = 0;
243
+ $this->options['fb_author_show_twitter'] = 0;
244
+
245
+ //Category
246
+ if ( is_category() ) {
247
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_cat_title( '', false ) ), true ) );
248
  $term = $wp_query->get_queried_object();
249
  $fb_url = get_term_link( $term, $term->taxonomy );
250
+ $cat_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( category_description() ), true ) ) );
251
+ if ( trim($cat_desc)!='' ) $fb_desc = $cat_desc;
252
  } else {
253
+ if ( is_tag() ) {
254
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_tag_title( '', false ) ), true ) );
255
  $term = $wp_query->get_queried_object();
256
+ $fb_url = get_term_link( $term, $term->taxonomy );
257
+ $tag_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( tag_description() ), true ) ) );
258
+ if ( trim($tag_desc)!='' ) $fb_desc = $tag_desc;
259
+ } else {
260
+ if (is_tax()) {
261
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_term_title( '', false ) ), true ) );
262
+ $term = $wp_query->get_queried_object();
263
+ $fb_url = get_term_link($term, $term->taxonomy);
264
+ $tax_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( term_description() ), true ) ) );
265
+ if ( trim($tax_desc)!='' ) $fb_desc = $tag_desc;
266
+ //WooCommerce
267
+ if ( $webdados_fb->is_woocommerce_active() && intval($this->options['fb_wc_usecategthumb'])==1 && is_product_category() ) {
268
+ if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
269
+ if ( $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ) ) {
270
+ if ( $image = wp_get_attachment_url( $thumbnail_id ) ) {
271
+ $fb_image = $image;
272
+ }
273
  }
274
  }
275
  }
 
 
 
 
 
276
  } else {
277
+ if ( is_search() ) {
278
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( __('Search for', 'wd-fb-og').' "'.get_search_query().'"' ), true ) );
279
+ $fb_url = get_search_link();
280
  } else {
281
+ if (is_author()) {
282
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_the_author_meta('display_name', get_query_var('author') ) ), true ) );
283
+ $fb_url = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
284
+ } else {
285
+ if ( is_archive() ) {
286
+ if ( is_day() ) {
287
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'day' ) . ' ' .single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
288
+ $fb_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
289
  } else {
290
+ if ( is_month() ) {
291
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
292
+ $fb_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
293
+ } else {
294
+ if ( is_year() ) {
295
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'year' ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
296
+ $fb_url = get_year_link( get_query_var( 'year' ) );
297
+ }
298
  }
299
  }
 
 
 
 
 
 
300
  } else {
301
+ if (is_front_page()) {
302
+ $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '');
303
+ $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
304
+ $fb_desc = $fb_desc_homepage;
305
+ } else {
306
+ //Others... Defaults already set up there
307
+ }
308
  }
309
  }
310
  }
312
  }
313
  }
314
  }
315
+
316
+ //og:type for WPML root page?
317
+ if ( $webdados_fb->is_wpml_active() ) {
318
+ if ( class_exists('WPML_Root_Page') ) {
319
+ if ( WPML_Root_Page::is_current_request_root() ) {
320
+ $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
321
+ }
322
  }
323
  }
324
+
325
+
326
+
327
+ //Default description, if empty until now
328
+ if ( trim($fb_desc)=='' ) {
329
+ switch( $this->options['fb_desc_default_option'] ) {
330
+ case 'custom':
331
+ $fb_desc = $this->options['fb_desc_default'];
332
+ //WPML?
333
+ if ( $webdados_fb->is_wpml_active() ) {
334
+ global $sitepress;
335
+ if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
336
+ $fb_desc = icl_t( 'wd-fb-og', 'wd_fb_og_fb_desc_default', $fb_desc );
337
+ }
338
  }
339
+ break;
340
+ default:
341
+ $fb_desc = $fb_desc_homepage;
342
+ break;
343
+ }
344
  }
345
+
346
+ //Trim description
347
+ $fb_desc = trim( str_replace('&nbsp;', ' ', $fb_desc) ); //Non-breaking spaces are usefull on a meta description. We'll just convert them to normal spaces to really trim it
348
+ $fb_desc = trim(
349
+ intval($this->options['fb_desc_chars'])>0
350
+ ?
351
+ mb_substr( wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) ), 0, intval($this->options['fb_desc_chars']) )
352
+ :
353
+ wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) )
354
+ );
355
+
356
+ //YOAST SEO?
357
+ if ( $this->options['fb_show_wpseoyoast']==1 ) {
358
+ if ( $webdados_fb->is_yoast_seo_active() ) {
359
+ $wpseo = WPSEO_Frontend::get_instance();
360
+ //Title
361
+ $fb_title_temp = $wpseo->title(false);
362
+ $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
363
+ //Title - SubHeading plugin
364
+ if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
365
+ if ( $webdados_fb->is_subheading_plugin_active() ) {
366
+ if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
367
+ $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
368
+ } else {
369
+ $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
370
+ }
371
  }
372
  }
373
+ //URL
374
+ $fb_url_temp = $wpseo->canonical(false);
375
+ $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);
376
+ //Description
377
+ $fb_desc_temp = $wpseo->metadesc(false);
378
+ $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
379
  }
 
 
 
 
 
 
380
  }
381
+
382
+ //All in One SEO Pack?
383
+ if ( $this->options['fb_show_aioseop']==1 ) {
384
+ if ( $webdados_fb->is_aioseop_active() ) {
385
+ global $aiosp;
386
+ //Title - Why are we getting the first post title on archives and homepage...?!?
387
+ $fb_title_temp = $aiosp->orig_title;
388
+ $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
389
+ //Title - SubHeading plugin
390
+ if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
391
+ if ( $webdados_fb->is_subheading_plugin_active() ) {
392
+ if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
393
+ $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
394
+ } else {
395
+ $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
396
+ }
397
  }
398
  }
399
+ //URL - See aioseop_class.php 3898 - We have a problem because wp_query is not the same right now
400
+ /*$fb_url_temp = '';
401
+ $aioseop_options = get_option( 'aioseop_options' );
402
+ $opts = $aiosp->meta_opts;
403
+ var_dump($wp_query);
404
+ $show_page = true;
405
+ if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) {
406
+ $show_page = false;
 
 
 
 
 
407
  }
408
+ if ( $aioseop_options['aiosp_can'] ) {
409
+ if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) {
410
+ $fb_url_temp = $opts['aiosp_custom_link'];
411
+ }
412
+ if ( empty( $url ) ) {
413
+ $fb_url_temp = $aiosp->aiosp_mrt_get_url( $wp_query, $show_page );
414
+ }
415
+
416
+ $fb_url_temp = $aiosp->validate_url_scheme( $fb_url_temp );
417
+
418
+ $fb_url_temp = apply_filters( 'aioseop_canonical_url', $fb_url_temp );
419
  }
420
+ var_dump($fb_url_temp);
421
+ $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);*/
422
+ //Description - Why are we getting the first post description on archives and homepage...?!?
423
+ if ( is_home() && ! is_front_page() ) {
424
+ $post = aiosp_common::get_blog_page();
425
+ } else {
426
+ $post = $aiosp->get_queried_object();
427
+ }
428
+ $fb_desc_temp = apply_filters( 'aioseop_description', $aiosp->get_main_description( $post ) );
429
+ $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
430
+
 
431
  }
 
 
 
432
  }
433
+
434
+ //Apply Filters
435
+ $fb_locale = apply_filters('fb_og_locale', $fb_locale);
436
+ $fb_title = apply_filters('fb_og_title', $fb_title);
437
+ $fb_url = apply_filters('fb_og_url', $fb_url);
438
+ $fb_type = apply_filters('fb_og_type', $fb_type);
439
+ $fb_desc = apply_filters('fb_og_desc', $fb_desc);
440
+ $fb_image = apply_filters('fb_og_image', $fb_image);
441
+ $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional);
442
+
443
+ //Image size
444
+ $fb_image_size = false;
445
+ if ( intval($this->options['fb_image_show'])==1 && trim($fb_image)!='' ) {
446
+ if ( intval($this->options['fb_image_size_show'])==1 ) {
447
+ if ( isset($this->image_size) && is_array($this->image_size) ) { //Already fetched
448
+ $fb_image_size = $this->image_size;
449
+ } else {
450
+ $fb_image_size = $this->get_open_graph_image_size($fb_image);
451
+ }
452
  }
453
+ } else {
454
+ $this->options['fb_image_show'] = 0;
455
  }
456
+
457
+ //Image overlay - Single?
458
+ if ( intval($this->options['fb_image_show'])==1 && intval($this->options['fb_image_overlay'])==1 && apply_filters('fb_og_image_overlay', true, $fb_image) ) {
459
+ //Single
460
+ $temp_fb_image_overlay = $this->get_image_with_overlay($fb_image);
461
+ if ( $temp_fb_image_overlay['overlay'] ) {
462
+ $fb_image = $temp_fb_image_overlay['fb_image'];
463
+ //We know the exact size now. We better just show it, right?
464
+ $this->options['fb_image_size_show'] = 1;
465
+ $fb_image_size = array(WEBDADOS_FB_W, WEBDADOS_FB_H);
466
+ }
467
+ //Additional
468
+ if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)>0 ) {
469
+ foreach($fb_image_additional as $key => $value ) {
470
+ if ($value['png_overlay']) {
471
+ $temp_fb_image_overlay = $this->get_image_with_overlay($value['fb_image']);
472
+ if ( $temp_fb_image_overlay['overlay'] ) {
473
+ $fb_image_additional[$key]['fb_image'] = $temp_fb_image_overlay['fb_image'];
474
+ }
 
 
475
  }
476
  }
477
  }
478
  }
479
+
480
+ //No spaces on URLs
481
+ if ( isset($fb_url) && trim($fb_url)!='' ) $fb_url= str_replace(' ', '%20', trim($fb_url));
482
+ if ( isset($fb_publisher) && trim($fb_publisher)!='' ) $fb_publisher= str_replace(' ', '%20', trim($fb_publisher));
483
+ if ( isset($fb_publisher_schema) && trim($fb_publisher_schema)!='' ) $fb_publisher_schema= str_replace(' ', '%20', trim($fb_publisher_schema));
484
+ if ( isset($fb_author) && trim($fb_author)!='' ) $fb_author= str_replace(' ', '%20', trim($fb_author));
485
+ if ( isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp)!='' ) $fb_author_linkrelgp= str_replace(' ', '%20', trim($fb_author_linkrelgp));
486
+ if ( isset($fb_image) && trim($fb_image)!='' ) $fb_image= str_replace(' ', '%20', trim($fb_image));
487
+ if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) ) {
488
+ foreach ( $fb_image_additional as $key => $value ) {
489
+ $fb_image_additional[$key]['fb_image'] = str_replace( ' ', '%20', trim($value['fb_image']) );
490
+ }
491
  }
492
+
493
+ //If there's still no description let's just add the title as a last resort
494
+ if ( trim($fb_desc)=='' ) $fb_desc = $fb_title;
495
+
496
+ //Print tags
497
+ // Facebook
498
+ $html.=' <!-- Facebook Open Graph -->
 
499
  ';
500
  //Locale
501
  if ( intval($this->options['fb_locale_show'])==1 ) $html.=' <meta property="og:locale" content="'.trim(esc_attr( trim($this->options['fb_locale'])!='' ? trim($this->options['fb_locale']) : trim(get_locale()) )).'"/>
628
  }
629
  }
630
  }
631
+ } else {
632
+
633
+ $html.=' <!-- Removed by fb_og_enabled filter -->
634
+ ';
635
 
636
+ }
637
+
638
  //Close tag
639
  $html.='<!-- END - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
640
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-faceb
4
  Tags: facebook, open graph, open graph protocol, share, social, meta, rss, twitter card, twitter, schema, google+, g+, google, google plus, image, like, seo, search engine optimization, woocommerce, yoast seo, wordpress seo, woocommerce, subheading, php7
5
  Requires at least: 4.0
6
  Tested up to: 4.6.1
7
- Stable tag: 2.0.5
8
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and SEO Meta Tags into your WordPress Website for more efficient sharing results.
9
 
10
  == Description ==
@@ -121,6 +121,11 @@ We DO NOT provide email support for this plugin. If you send us an email asking
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
124
  = 2.0.5 =
125
  * Calculated image dimensions are now stored in, 1 day valid, transients in order to avoid unnecessary http requests and improve performance (Thanks Piotr Bogdan)
126
 
4
  Tags: facebook, open graph, open graph protocol, share, social, meta, rss, twitter card, twitter, schema, google+, g+, google, google plus, image, like, seo, search engine optimization, woocommerce, yoast seo, wordpress seo, woocommerce, subheading, php7
5
  Requires at least: 4.0
6
  Tested up to: 4.6.1
7
+ Stable tag: 2.0.6
8
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and SEO Meta Tags into your WordPress Website for more efficient sharing results.
9
 
10
  == Description ==
121
 
122
  == Changelog ==
123
 
124
+ = 2.0.6 =
125
+ * New `fb_og_enabled` filter that allow other plugins/themes to completely disable the tags output on specific situations
126
+ * Fix: Use `WP_PLUGIN_DIR` instead of harcoded paths (Thanks thomasbachem)
127
+ * Fix: Extra validation when getting Yoast SEO's icon on the 3rd party settings tab
128
+
129
  = 2.0.5 =
130
  * Calculated image dimensions are now stored in, 1 day valid, transients in order to avoid unnecessary http requests and improve performance (Thanks Piotr Bogdan)
131
 
wonderm00n-open-graph.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
- * @version 2.0.5
5
  */
6
  /*
7
  Plugin Name: Facebook Open Graph, Google+ and Twitter Card Tags
8
  Plugin URI: http://www.webdados.pt/produtos-e-servicos/internet/desenvolvimento-wordpress/facebook-open-graph-meta-tags-wordpress/
9
  Description: Inserts Facebook Open Graph, Google+/Schema.org, Twitter Card and SEO Meta Tags into your WordPress Blog/Website for more effective and efficient Facebook, Google+ and Twitter sharing results. You can also choose to insert the "enclosure" and "media:content" tags to the RSS feeds, so that apps like RSS Graffiti and Twitterfeed post the image to Facebook correctly.
10
 
11
- Version: 2.0.5
12
  Author: Webdados
13
  Author URI: http://www.webdados.pt
14
  Text Domain: wd-fb-og
@@ -17,7 +17,7 @@ Domain Path: /lang
17
 
18
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
19
 
20
- define( 'WEBDADOS_FB_VERSION', '2.0.5' );
21
  define( 'WEBDADOS_FB_PLUGIN_NAME', 'Facebook Open Graph, Google+ and Twitter Card Tags' );
22
  define( 'WEBDADOS_FB_W', 1200 );
23
  define( 'WEBDADOS_FB_H', 630 );
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 2.0.6
5
  */
6
  /*
7
  Plugin Name: Facebook Open Graph, Google+ and Twitter Card Tags
8
  Plugin URI: http://www.webdados.pt/produtos-e-servicos/internet/desenvolvimento-wordpress/facebook-open-graph-meta-tags-wordpress/
9
  Description: Inserts Facebook Open Graph, Google+/Schema.org, Twitter Card and SEO Meta Tags into your WordPress Blog/Website for more effective and efficient Facebook, Google+ and Twitter sharing results. You can also choose to insert the "enclosure" and "media:content" tags to the RSS feeds, so that apps like RSS Graffiti and Twitterfeed post the image to Facebook correctly.
10
 
11
+ Version: 2.0.6
12
  Author: Webdados
13
  Author URI: http://www.webdados.pt
14
  Text Domain: wd-fb-og
17
 
18
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
19
 
20
+ define( 'WEBDADOS_FB_VERSION', '2.0.6' );
21
  define( 'WEBDADOS_FB_PLUGIN_NAME', 'Facebook Open Graph, Google+ and Twitter Card Tags' );
22
  define( 'WEBDADOS_FB_W', 1200 );
23
  define( 'WEBDADOS_FB_H', 630 );