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

Version Description

  • New option to disable getting the image size and possibly avoid fatal errors (white screen of death) on some edge cases
  • New fb_og_disable filter to completely disable the output based on the developer own rules
Download this release

Release Info

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

Code changes from version 2.0.8.2 to 2.0.9

admin/options-page-general.php CHANGED
@@ -218,6 +218,26 @@ global $webdados_fb;
218
  - <?php _e( 'May cause problems with some multisite configurations but fixes "HTTP request failed" errors', 'wd-fb-og' );?>
219
  </td>
220
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
 
222
  </tbody>
223
  </table>
218
  - <?php _e( 'May cause problems with some multisite configurations but fixes "HTTP request failed" errors', 'wd-fb-og' );?>
219
  </td>
220
  </tr>
221
+
222
+ <tr>
223
+ <th><?php _e( 'Do not get image size', 'wd-fb-og' ); ?>:</th>
224
+ <td>
225
+ <input type="checkbox" name="wonderm00n_open_graph_settings[fb_adv_disable_image_size]" id="fb_adv_disable_image_size" value="1" <?php echo (intval($options['fb_adv_disable_image_size'])==1 ? ' checked="checked"' : '' ); ?>/>
226
+ </td>
227
+ </tr>
228
+ <tr>
229
+ <td colspan="2" class="info">
230
+ - <?php _e('Experimental', 'wd-fb-og'); ?>
231
+ <br/>
232
+ - <b><?php _e( 'This is an advanced option: Don\'t mess with this unless you know what you\'re doing', 'wd-fb-og' ); ?></b>
233
+ <br/>
234
+ - <?php _e( 'You should only activate this option if you\'re getting fatal errors (white screen of death) and only keep it active if this options does solve those errors', 'wd-fb-og' ); ?>
235
+ <br/>
236
+ - <?php _e( 'This can render the "Add image to RSS/RSS2 feeds" and "Open Graph - Include Image Dimensions" options useless', 'wd-fb-og' ); ?>
237
+ </td>
238
+ </tr>
239
+
240
+
241
 
242
  </tbody>
243
  </table>
includes/class-webdados-fb-open-graph.php CHANGED
@@ -41,6 +41,7 @@ class Webdados_FB {
41
  'fb_image_use_content' => 0,
42
  'fb_image_use_media' => 0,
43
  'fb_image_use_default' => 1,
 
44
  //OG
45
  'fb_title_show' => 1,
46
  'fb_sitename_show' => 1,
@@ -133,6 +134,7 @@ class Webdados_FB {
133
  'fb_image_use_content' => 'intval',
134
  'fb_image_use_media' => 'intval',
135
  'fb_image_use_default' => 'intval',
 
136
  'fb_image_min_size' => 'intval',
137
  'fb_show_wpseoyoast' => 'intval',
138
  'fb_show_aioseop' => 'intval',
41
  'fb_image_use_content' => 0,
42
  'fb_image_use_media' => 0,
43
  'fb_image_use_default' => 1,
44
+ 'fb_adv_disable_image_size' => 0,
45
  //OG
46
  'fb_title_show' => 1,
47
  'fb_sitename_show' => 1,
134
  'fb_image_use_content' => 'intval',
135
  'fb_image_use_media' => 'intval',
136
  'fb_image_use_default' => 'intval',
137
+ 'fb_adv_disable_image_size' => 'intval',
138
  'fb_image_min_size' => 'intval',
139
  'fb_show_wpseoyoast' => 'intval',
140
  'fb_show_aioseop' => 'intval',
lang/wd-fb-og-pt_PT.mo CHANGED
Binary file
lang/wd-fb-og-pt_PT.po CHANGED
@@ -3,8 +3,8 @@ msgstr ""
3
  "Project-Id-Version: Facebook Open Graph Meta Tags for WordPress v2.0.3\n"
4
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wonderm00ns-simple-"
5
  "facebook-open-graph-tags\n"
6
- "POT-Creation-Date: 2017-03-28 22:37+0100\n"
7
- "PO-Revision-Date: 2017-03-28 22:39+0100\n"
8
  "Last-Translator: Wonderm00n <wonderm00n@gmail.com>\n"
9
  "Language-Team: Webdados <info@webdados.pt>\n"
10
  "Language: pt_PT\n"
@@ -12,7 +12,7 @@ msgstr ""
12
  "Content-Type: text/plain; charset=UTF-8\n"
13
  "Content-Transfer-Encoding: 8bit\n"
14
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
15
- "X-Generator: Poedit 2.0\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
18
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
@@ -445,15 +445,15 @@ msgstr "Facebook Platform App ID"
445
  msgid "From your Facebook Developers dashboard"
446
  msgstr "Do seu “Facebook Developers dashboard”"
447
 
448
- #: admin/options-page-facebook.php:341
449
  msgid "Declaration Method"
450
  msgstr "Método de Declaração"
451
 
452
- #: admin/options-page-facebook.php:351
453
  msgid "or"
454
  msgstr "Ou"
455
 
456
- #: admin/options-page-facebook.php:353
457
  msgid ""
458
  "Prefix is recommended because it validates properly with the W3C validator, "
459
  "xmlns is the legacy method"
@@ -461,15 +461,15 @@ msgstr ""
461
  "Prefix é recomendado porque valida correctamente no W3C validator, xmlns é o "
462
  "método antigo"
463
 
464
- #: admin/options-page-facebook.php:362
465
  msgid "Facebook Open Graph Tags cache"
466
  msgstr "Cache de Tags Facebook Open Graph"
467
 
468
- #: admin/options-page-facebook.php:368
469
  msgid "Clear cache"
470
  msgstr "Limpar cache"
471
 
472
- #: admin/options-page-facebook.php:375
473
  msgid ""
474
  "Try to clear the Facebook Open Graph Tags cache when saving a post or page, "
475
  "so the link preview on Facebook is immediately updated"
@@ -477,11 +477,11 @@ msgstr ""
477
  "Tentar actualizar a cache das Tags Facebook Open Graph ao gravar um post, "
478
  "para que a pré-visualização no Facebook seja imediatamente actualizada"
479
 
480
- #: admin/options-page-facebook.php:380
481
  msgid "Suppress cache notices"
482
  msgstr "Esconder notificações de cache"
483
 
484
- #: admin/options-page-facebook.php:387
485
  msgid ""
486
  "Sometimes we aren't able to update the cache and the post author will see a "
487
  "notice if this option is not checked"
@@ -618,7 +618,8 @@ msgstr ""
618
  "cima, será utilizada. Na página inicial, arquivos e outras secções do "
619
  "website a imagem utilizada será a por omissão."
620
 
621
- #: admin/options-page-general.php:169 admin/options-page-schema.php:66
 
622
  msgid "Experimental"
623
  msgstr "Experimental"
624
 
@@ -675,7 +676,7 @@ msgstr ""
675
  msgid "Force getimagesize on local file"
676
  msgstr "Forçar “getimagesize” em ficheiro local"
677
 
678
- #: admin/options-page-general.php:214
679
  msgid ""
680
  "This is an advanced option: Don't mess with this unless you know what you're "
681
  "doing"
@@ -694,44 +695,65 @@ msgstr ""
694
  "Pode causar problemas com algumas configurações “multisite” mas corrige "
695
  "erros \"HTTP request failed\""
696
 
697
- #: admin/options-page-general.php:227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
  msgid "URL settings"
699
  msgstr "Opções de URL"
700
 
701
  # @ wd-fb-og
702
- #: admin/options-page-general.php:233
703
  msgid "Add trailing slash at the end"
704
  msgstr "Adicionar barra invertida no final"
705
 
706
- #: admin/options-page-general.php:240
707
  msgid "If missing, a trailing slash will be added at the end"
708
  msgstr "Se em falta, será adicionada uma barra invertida no final"
709
 
710
- #: admin/options-page-general.php:242
711
  msgid "Homepage example:"
712
  msgstr "Exemplo da Página Inicial:"
713
 
714
- #: admin/options-page-general.php:251
715
  msgid "Author settings"
716
  msgstr "Opções de Autor"
717
 
718
- #: admin/options-page-general.php:257
719
  msgid "Hide Author on Pages"
720
  msgstr "Esconder Autor nas Páginas"
721
 
722
- #: admin/options-page-general.php:264
723
  msgid "Hides all Author tags on Pages"
724
  msgstr "Esconde todas as tags de Autor nas Páginas"
725
 
726
- #: admin/options-page-general.php:273
727
  msgid "Other settings"
728
  msgstr "Outras opções"
729
 
730
- #: admin/options-page-general.php:279
731
  msgid "Keep data on uninstall"
732
  msgstr "Manter opções ao desinstalar"
733
 
734
- #: admin/options-page-general.php:286
735
  msgid ""
736
  "Keep the plugin settings on the database even if the plugin is uninstalled"
737
  msgstr ""
3
  "Project-Id-Version: Facebook Open Graph Meta Tags for WordPress v2.0.3\n"
4
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wonderm00ns-simple-"
5
  "facebook-open-graph-tags\n"
6
+ "POT-Creation-Date: 2017-09-12 13:33+0100\n"
7
+ "PO-Revision-Date: 2017-09-12 13:37+0100\n"
8
  "Last-Translator: Wonderm00n <wonderm00n@gmail.com>\n"
9
  "Language-Team: Webdados <info@webdados.pt>\n"
10
  "Language: pt_PT\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
13
  "Content-Transfer-Encoding: 8bit\n"
14
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
15
+ "X-Generator: Poedit 2.0.3\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
18
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
445
  msgid "From your Facebook Developers dashboard"
446
  msgstr "Do seu “Facebook Developers dashboard”"
447
 
448
+ #: admin/options-page-facebook.php:340
449
  msgid "Declaration Method"
450
  msgstr "Método de Declaração"
451
 
452
+ #: admin/options-page-facebook.php:350
453
  msgid "or"
454
  msgstr "Ou"
455
 
456
+ #: admin/options-page-facebook.php:352
457
  msgid ""
458
  "Prefix is recommended because it validates properly with the W3C validator, "
459
  "xmlns is the legacy method"
461
  "Prefix é recomendado porque valida correctamente no W3C validator, xmlns é o "
462
  "método antigo"
463
 
464
+ #: admin/options-page-facebook.php:361
465
  msgid "Facebook Open Graph Tags cache"
466
  msgstr "Cache de Tags Facebook Open Graph"
467
 
468
+ #: admin/options-page-facebook.php:367
469
  msgid "Clear cache"
470
  msgstr "Limpar cache"
471
 
472
+ #: admin/options-page-facebook.php:374
473
  msgid ""
474
  "Try to clear the Facebook Open Graph Tags cache when saving a post or page, "
475
  "so the link preview on Facebook is immediately updated"
477
  "Tentar actualizar a cache das Tags Facebook Open Graph ao gravar um post, "
478
  "para que a pré-visualização no Facebook seja imediatamente actualizada"
479
 
480
+ #: admin/options-page-facebook.php:379
481
  msgid "Suppress cache notices"
482
  msgstr "Esconder notificações de cache"
483
 
484
+ #: admin/options-page-facebook.php:386
485
  msgid ""
486
  "Sometimes we aren't able to update the cache and the post author will see a "
487
  "notice if this option is not checked"
618
  "cima, será utilizada. Na página inicial, arquivos e outras secções do "
619
  "website a imagem utilizada será a por omissão."
620
 
621
+ #: admin/options-page-general.php:169 admin/options-page-general.php:230
622
+ #: admin/options-page-schema.php:66
623
  msgid "Experimental"
624
  msgstr "Experimental"
625
 
676
  msgid "Force getimagesize on local file"
677
  msgstr "Forçar “getimagesize” em ficheiro local"
678
 
679
+ #: admin/options-page-general.php:214 admin/options-page-general.php:232
680
  msgid ""
681
  "This is an advanced option: Don't mess with this unless you know what you're "
682
  "doing"
695
  "Pode causar problemas com algumas configurações “multisite” mas corrige "
696
  "erros \"HTTP request failed\""
697
 
698
+ #: admin/options-page-general.php:223
699
+ msgid "Do not get image size"
700
+ msgstr "Não calcular tamanho da imagem"
701
+
702
+ #: admin/options-page-general.php:234
703
+ msgid ""
704
+ "You should only activate this option if you're getting fatal errors (white "
705
+ "screen of death) and only keep it active if this options does solve those "
706
+ "errors"
707
+ msgstr ""
708
+ "Só deve activar esta opção se estiver a obter erros fatais (<em>white screen "
709
+ "of death</em>) e mantê-la activa apenas se esta opção resolver esses erros"
710
+
711
+ #: admin/options-page-general.php:236
712
+ msgid ""
713
+ "This can render the \"Add image to RSS/RSS2 feeds\" and \"Open Graph - "
714
+ "Include Image Dimensions\" options useless"
715
+ msgstr ""
716
+ "Pode fazer com que as opções “Incluir a imagem aos feeds RSS/RSS2” e “Open "
717
+ "Graph - Incluir Dimensão da Imagem” deixem de funcionar"
718
+
719
+ #: admin/options-page-general.php:247
720
  msgid "URL settings"
721
  msgstr "Opções de URL"
722
 
723
  # @ wd-fb-og
724
+ #: admin/options-page-general.php:253
725
  msgid "Add trailing slash at the end"
726
  msgstr "Adicionar barra invertida no final"
727
 
728
+ #: admin/options-page-general.php:260
729
  msgid "If missing, a trailing slash will be added at the end"
730
  msgstr "Se em falta, será adicionada uma barra invertida no final"
731
 
732
+ #: admin/options-page-general.php:262
733
  msgid "Homepage example:"
734
  msgstr "Exemplo da Página Inicial:"
735
 
736
+ #: admin/options-page-general.php:271
737
  msgid "Author settings"
738
  msgstr "Opções de Autor"
739
 
740
+ #: admin/options-page-general.php:277
741
  msgid "Hide Author on Pages"
742
  msgstr "Esconder Autor nas Páginas"
743
 
744
+ #: admin/options-page-general.php:284
745
  msgid "Hides all Author tags on Pages"
746
  msgstr "Esconde todas as tags de Autor nas Páginas"
747
 
748
+ #: admin/options-page-general.php:293
749
  msgid "Other settings"
750
  msgstr "Outras opções"
751
 
752
+ #: admin/options-page-general.php:299
753
  msgid "Keep data on uninstall"
754
  msgstr "Manter opções ao desinstalar"
755
 
756
+ #: admin/options-page-general.php:306
757
  msgid ""
758
  "Keep the plugin settings on the database even if the plugin is uninstalled"
759
  msgstr ""
lang/wd-fb-og.pot CHANGED
@@ -4,14 +4,14 @@ msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Facebook Open Graph, Google+ and Twitter Card Tags "
6
  "2.0.3\n"
7
- "POT-Creation-Date: 2017-03-28 22:37+0100\n"
8
  "PO-Revision-Date: 2016-09-26 14:52+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: \n"
11
  "MIME-Version: 1.0\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
13
  "Content-Transfer-Encoding: 8bit\n"
14
- "X-Generator: Poedit 2.0\n"
15
  "X-Poedit-Basepath: ..\n"
16
  "X-Poedit-WPHeader: wonderm00n-open-graph.php\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
@@ -399,39 +399,39 @@ msgstr ""
399
  msgid "From your Facebook Developers dashboard"
400
  msgstr ""
401
 
402
- #: admin/options-page-facebook.php:341
403
  msgid "Declaration Method"
404
  msgstr ""
405
 
406
- #: admin/options-page-facebook.php:351
407
  msgid "or"
408
  msgstr ""
409
 
410
- #: admin/options-page-facebook.php:353
411
  msgid ""
412
  "Prefix is recommended because it validates properly with the W3C validator, "
413
  "xmlns is the legacy method"
414
  msgstr ""
415
 
416
- #: admin/options-page-facebook.php:362
417
  msgid "Facebook Open Graph Tags cache"
418
  msgstr ""
419
 
420
- #: admin/options-page-facebook.php:368
421
  msgid "Clear cache"
422
  msgstr ""
423
 
424
- #: admin/options-page-facebook.php:375
425
  msgid ""
426
  "Try to clear the Facebook Open Graph Tags cache when saving a post or page, "
427
  "so the link preview on Facebook is immediately updated"
428
  msgstr ""
429
 
430
- #: admin/options-page-facebook.php:380
431
  msgid "Suppress cache notices"
432
  msgstr ""
433
 
434
- #: admin/options-page-facebook.php:387
435
  msgid ""
436
  "Sometimes we aren't able to update the cache and the post author will see a "
437
  "notice if this option is not checked"
@@ -547,7 +547,8 @@ msgid ""
547
  "is always used."
548
  msgstr ""
549
 
550
- #: admin/options-page-general.php:169 admin/options-page-schema.php:66
 
551
  msgid "Experimental"
552
  msgstr ""
553
 
@@ -594,7 +595,7 @@ msgstr ""
594
  msgid "Force getimagesize on local file"
595
  msgstr ""
596
 
597
- #: admin/options-page-general.php:214
598
  msgid ""
599
  "This is an advanced option: Don't mess with this unless you know what you're "
600
  "doing"
@@ -610,43 +611,60 @@ msgid ""
610
  "request failed\" errors"
611
  msgstr ""
612
 
613
- #: admin/options-page-general.php:227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
614
  msgid "URL settings"
615
  msgstr ""
616
 
617
- #: admin/options-page-general.php:233
618
  msgid "Add trailing slash at the end"
619
  msgstr ""
620
 
621
- #: admin/options-page-general.php:240
622
  msgid "If missing, a trailing slash will be added at the end"
623
  msgstr ""
624
 
625
- #: admin/options-page-general.php:242
626
  msgid "Homepage example:"
627
  msgstr ""
628
 
629
- #: admin/options-page-general.php:251
630
  msgid "Author settings"
631
  msgstr ""
632
 
633
- #: admin/options-page-general.php:257
634
  msgid "Hide Author on Pages"
635
  msgstr ""
636
 
637
- #: admin/options-page-general.php:264
638
  msgid "Hides all Author tags on Pages"
639
  msgstr ""
640
 
641
- #: admin/options-page-general.php:273
642
  msgid "Other settings"
643
  msgstr ""
644
 
645
- #: admin/options-page-general.php:279
646
  msgid "Keep data on uninstall"
647
  msgstr ""
648
 
649
- #: admin/options-page-general.php:286
650
  msgid ""
651
  "Keep the plugin settings on the database even if the plugin is uninstalled"
652
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Facebook Open Graph, Google+ and Twitter Card Tags "
6
  "2.0.3\n"
7
+ "POT-Creation-Date: 2017-09-12 13:33+0100\n"
8
  "PO-Revision-Date: 2016-09-26 14:52+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: \n"
11
  "MIME-Version: 1.0\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
13
  "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Generator: Poedit 2.0.3\n"
15
  "X-Poedit-Basepath: ..\n"
16
  "X-Poedit-WPHeader: wonderm00n-open-graph.php\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
399
  msgid "From your Facebook Developers dashboard"
400
  msgstr ""
401
 
402
+ #: admin/options-page-facebook.php:340
403
  msgid "Declaration Method"
404
  msgstr ""
405
 
406
+ #: admin/options-page-facebook.php:350
407
  msgid "or"
408
  msgstr ""
409
 
410
+ #: admin/options-page-facebook.php:352
411
  msgid ""
412
  "Prefix is recommended because it validates properly with the W3C validator, "
413
  "xmlns is the legacy method"
414
  msgstr ""
415
 
416
+ #: admin/options-page-facebook.php:361
417
  msgid "Facebook Open Graph Tags cache"
418
  msgstr ""
419
 
420
+ #: admin/options-page-facebook.php:367
421
  msgid "Clear cache"
422
  msgstr ""
423
 
424
+ #: admin/options-page-facebook.php:374
425
  msgid ""
426
  "Try to clear the Facebook Open Graph Tags cache when saving a post or page, "
427
  "so the link preview on Facebook is immediately updated"
428
  msgstr ""
429
 
430
+ #: admin/options-page-facebook.php:379
431
  msgid "Suppress cache notices"
432
  msgstr ""
433
 
434
+ #: admin/options-page-facebook.php:386
435
  msgid ""
436
  "Sometimes we aren't able to update the cache and the post author will see a "
437
  "notice if this option is not checked"
547
  "is always used."
548
  msgstr ""
549
 
550
+ #: admin/options-page-general.php:169 admin/options-page-general.php:230
551
+ #: admin/options-page-schema.php:66
552
  msgid "Experimental"
553
  msgstr ""
554
 
595
  msgid "Force getimagesize on local file"
596
  msgstr ""
597
 
598
+ #: admin/options-page-general.php:214 admin/options-page-general.php:232
599
  msgid ""
600
  "This is an advanced option: Don't mess with this unless you know what you're "
601
  "doing"
611
  "request failed\" errors"
612
  msgstr ""
613
 
614
+ #: admin/options-page-general.php:223
615
+ msgid "Do not get image size"
616
+ msgstr ""
617
+
618
+ #: admin/options-page-general.php:234
619
+ msgid ""
620
+ "You should only activate this option if you're getting fatal errors (white "
621
+ "screen of death) and only keep it active if this options does solve those "
622
+ "errors"
623
+ msgstr ""
624
+
625
+ #: admin/options-page-general.php:236
626
+ msgid ""
627
+ "This can render the \"Add image to RSS/RSS2 feeds\" and \"Open Graph - "
628
+ "Include Image Dimensions\" options useless"
629
+ msgstr ""
630
+
631
+ #: admin/options-page-general.php:247
632
  msgid "URL settings"
633
  msgstr ""
634
 
635
+ #: admin/options-page-general.php:253
636
  msgid "Add trailing slash at the end"
637
  msgstr ""
638
 
639
+ #: admin/options-page-general.php:260
640
  msgid "If missing, a trailing slash will be added at the end"
641
  msgstr ""
642
 
643
+ #: admin/options-page-general.php:262
644
  msgid "Homepage example:"
645
  msgstr ""
646
 
647
+ #: admin/options-page-general.php:271
648
  msgid "Author settings"
649
  msgstr ""
650
 
651
+ #: admin/options-page-general.php:277
652
  msgid "Hide Author on Pages"
653
  msgstr ""
654
 
655
+ #: admin/options-page-general.php:284
656
  msgid "Hides all Author tags on Pages"
657
  msgstr ""
658
 
659
+ #: admin/options-page-general.php:293
660
  msgid "Other settings"
661
  msgstr ""
662
 
663
+ #: admin/options-page-general.php:299
664
  msgid "Keep data on uninstall"
665
  msgstr ""
666
 
667
+ #: admin/options-page-general.php:306
668
  msgid ""
669
  "Keep the plugin settings on the database even if the plugin is uninstalled"
670
  msgstr ""
public/class-webdados-fb-open-graph-public.php CHANGED
@@ -42,270 +42,273 @@ class Webdados_FB_Public {
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
- $price = version_compare( WC_VERSION, '3.0', '>=' ) ? wc_get_price_including_tax($product) : $product->get_price_including_tax();
202
- $currency = get_woocommerce_currency();
203
- $fb_additional_tags['property']['product_price_amount'] = array(
204
- $price
205
- );
206
- if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['property']['product_price_currency'] = array(
207
- $currency
208
- );
209
- $fb_additional_tags['name']['twitter_label1'] = array(
210
- __('Price', 'wd-fb-og')
211
- );
212
- if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['name']['twitter_data1'] = array(
213
- $price.' '.get_woocommerce_currency()
214
- );
215
- //Additional product images?
216
- if ( intval($this->options['fb_image_show'])==1 && $this->options['fb_wc_useproductgallery']==1 ) {
217
- if ( $attachment_ids = version_compare( WC_VERSION, '3.0', '>=' ) ? $product->get_gallery_image_ids() : $product->get_gallery_attachment_ids() ) {
218
- foreach ( $attachment_ids as $attachment_id ) {
219
- if ( $image_link = wp_get_attachment_url( $attachment_id ) ) {
220
- if ( trim($image_link)!='' ) {
221
- $fb_image_additional[] = array(
222
- 'fb_image' => trim($image_link),
223
- 'png_overlay' => ( intval($this->options['fb_wc_usepg_png_overlay']) ? true : false ),
224
- );
225
  }
226
  }
227
  }
228
  }
229
  }
230
- }
231
-
232
- } else {
233
-
234
- //Other pages - Defaults
235
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_bloginfo( 'name' ) ), true ) );
236
- $fb_url = ( ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //Not really canonical but will work for now
237
- $fb_image = trim( $this->options['fb_image'] );
238
-
239
- $this->options['fb_article_sections_show'] = 0;
240
- $this->options['fb_article_dates_show'] = 0;
241
- $this->options['fb_author_show'] = 0;
242
- $this->options['fb_author_show_meta'] = 0;
243
- $this->options['fb_author_show_linkrelgp'] = 0;
244
- $this->options['fb_author_show_twitter'] = 0;
245
- $this->options['fb_author_show_twitter'] = 0;
246
-
247
- //Category
248
- if ( is_category() ) {
249
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_cat_title( '', false ) ), true ) );
250
- $term = $wp_query->get_queried_object();
251
- $fb_url = get_term_link( $term, $term->taxonomy );
252
- $cat_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( category_description() ), true ) ) );
253
- if ( trim($cat_desc)!='' ) $fb_desc = $cat_desc;
254
  } else {
255
- if ( is_tag() ) {
256
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_tag_title( '', false ) ), true ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  $term = $wp_query->get_queried_object();
258
  $fb_url = get_term_link( $term, $term->taxonomy );
259
- $tag_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( tag_description() ), true ) ) );
260
- if ( trim($tag_desc)!='' ) $fb_desc = $tag_desc;
261
  } else {
262
- if (is_tax()) {
263
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_term_title( '', false ) ), true ) );
264
  $term = $wp_query->get_queried_object();
265
- $fb_url = get_term_link($term, $term->taxonomy);
266
- $tax_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( term_description() ), true ) ) );
267
- if ( trim($tax_desc)!='' ) $fb_desc = $tax_desc;
268
- //WooCommerce
269
- if ( $webdados_fb->is_woocommerce_active() && intval($this->options['fb_wc_usecategthumb'])==1 && is_product_category() ) {
270
- if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
271
- if ( $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ) ) {
272
- if ( $image = wp_get_attachment_url( $thumbnail_id ) ) {
273
- $fb_image = $image;
 
 
 
 
 
 
 
 
274
  }
275
  }
276
  }
277
- }
278
- } else {
279
- if ( is_search() ) {
280
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( __('Search for', 'wd-fb-og').' "'.get_search_query().'"' ), true ) );
281
- $fb_url = get_search_link();
282
  } else {
283
- if (is_author()) {
284
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_the_author_meta('display_name', get_query_var('author') ) ), true ) );
285
- $fb_url = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
286
  } else {
287
- if ( is_archive() ) {
288
- if ( is_day() ) {
289
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'day' ) . ' ' .single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
290
- $fb_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
291
- } else {
292
- if ( is_month() ) {
293
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
294
- $fb_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
295
  } else {
296
- if ( is_year() ) {
297
- $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'year' ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
298
- $fb_url = get_year_link( get_query_var( 'year' ) );
 
 
 
 
 
299
  }
300
  }
301
- }
302
- } else {
303
- if (is_front_page()) {
304
- $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '');
305
- $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
306
- $fb_desc = $fb_desc_homepage;
307
  } else {
308
- //Others... Defaults already set up there
 
 
 
 
 
 
309
  }
310
  }
311
  }
@@ -313,334 +316,340 @@ class Webdados_FB_Public {
313
  }
314
  }
315
  }
316
- }
317
-
318
- //og:type for WPML root page?
319
- if ( $webdados_fb->is_wpml_active() ) {
320
- if ( class_exists('WPML_Root_Page') ) {
321
- if ( WPML_Root_Page::is_current_request_root() ) {
322
- $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
323
  }
324
  }
325
- }
326
-
327
-
328
-
329
- //Default description, if empty until now
330
- if ( trim($fb_desc)=='' ) {
331
- switch( $this->options['fb_desc_default_option'] ) {
332
- case 'custom':
333
- $fb_desc = $this->options['fb_desc_default'];
334
- //WPML?
335
- if ( $webdados_fb->is_wpml_active() ) {
336
- global $sitepress;
337
- if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
338
- $fb_desc = icl_t( 'wd-fb-og', 'wd_fb_og_fb_desc_default', $fb_desc );
339
  }
340
- }
341
- break;
342
- default:
343
- $fb_desc = $fb_desc_homepage;
344
- break;
345
  }
346
- }
347
-
348
- //Trim description
349
- $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
350
- $fb_desc = trim(
351
- intval($this->options['fb_desc_chars'])>0
352
- ?
353
- mb_substr( wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) ), 0, intval($this->options['fb_desc_chars']) )
354
- :
355
- wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) )
356
- );
357
-
358
- //YOAST SEO?
359
- if ( $this->options['fb_show_wpseoyoast']==1 ) {
360
- if ( $webdados_fb->is_yoast_seo_active() ) {
361
- $wpseo = WPSEO_Frontend::get_instance();
362
- //Title
363
- $fb_title_temp = $wpseo->title(false);
364
- $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
365
- //Title - SubHeading plugin
366
- if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
367
- if ( $webdados_fb->is_subheading_plugin_active() ) {
368
- if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
369
- $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
370
- } else {
371
- $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
372
  }
373
  }
 
 
 
 
 
 
374
  }
375
- //URL
376
- $fb_url_temp = $wpseo->canonical(false);
377
- $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);
378
- //Description
379
- $fb_desc_temp = $wpseo->metadesc(false);
380
- $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
381
  }
382
- }
383
-
384
- //All in One SEO Pack?
385
- if ( $this->options['fb_show_aioseop']==1 ) {
386
- if ( $webdados_fb->is_aioseop_active() ) {
387
- global $aiosp;
388
- //Title - Why are we getting the first post title on archives and homepage...?!?
389
- $fb_title_temp = $aiosp->orig_title;
390
- $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
391
- //Title - SubHeading plugin
392
- if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
393
- if ( $webdados_fb->is_subheading_plugin_active() ) {
394
- if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
395
- $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
396
- } else {
397
- $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
398
  }
399
  }
400
- }
401
- //URL - See aioseop_class.php 3898 - We have a problem because wp_query is not the same right now
402
- /*$fb_url_temp = '';
403
- $aioseop_options = get_option( 'aioseop_options' );
404
- $opts = $aiosp->meta_opts;
405
- var_dump($wp_query);
406
- $show_page = true;
407
- if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) {
408
- $show_page = false;
409
- }
410
- if ( $aioseop_options['aiosp_can'] ) {
411
- if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) {
412
- $fb_url_temp = $opts['aiosp_custom_link'];
413
  }
414
- if ( empty( $url ) ) {
415
- $fb_url_temp = $aiosp->aiosp_mrt_get_url( $wp_query, $show_page );
 
 
 
 
 
 
 
 
 
416
  }
417
-
418
- $fb_url_temp = $aiosp->validate_url_scheme( $fb_url_temp );
419
-
420
- $fb_url_temp = apply_filters( 'aioseop_canonical_url', $fb_url_temp );
421
- }
422
- var_dump($fb_url_temp);
423
- $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);*/
424
- //Description - Why are we getting the first post description on archives and homepage...?!?
425
- if ( is_home() && ! is_front_page() ) {
426
- $post = aiosp_common::get_blog_page();
427
- } else {
428
- $post = $aiosp->get_queried_object();
429
  }
430
- $fb_desc_temp = apply_filters( 'aioseop_description', $aiosp->get_main_description( $post ) );
431
- $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
432
-
433
  }
434
- }
435
-
436
- //Apply Filters
437
- $fb_locale = apply_filters('fb_og_locale', $fb_locale);
438
- $fb_title = apply_filters('fb_og_title', $fb_title);
439
- $fb_url = apply_filters('fb_og_url', $fb_url);
440
- $fb_type = apply_filters('fb_og_type', $fb_type);
441
- $fb_desc = apply_filters('fb_og_desc', $fb_desc);
442
- $fb_image = apply_filters('fb_og_image', $fb_image);
443
- $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional);
444
-
445
- //Image size
446
- $fb_image_size = false;
447
- if ( intval($this->options['fb_image_show'])==1 && trim($fb_image)!='' ) {
448
- if ( intval($this->options['fb_image_size_show'])==1 ) {
449
- if ( isset($this->image_size) && is_array($this->image_size) ) { //Already fetched
450
- $fb_image_size = $this->image_size;
451
- } else {
452
- $fb_image_size = $this->get_open_graph_image_size($fb_image);
453
  }
 
 
454
  }
455
- } else {
456
- $this->options['fb_image_show'] = 0;
457
- }
458
-
459
- //Image overlay - Single?
460
- if ( intval($this->options['fb_image_show'])==1 && intval($this->options['fb_image_overlay'])==1 && apply_filters('fb_og_image_overlay', true, $fb_image) ) {
461
- //Single
462
- $temp_fb_image_overlay = $this->get_image_with_overlay($fb_image);
463
- if ( $temp_fb_image_overlay['overlay'] ) {
464
- $fb_image = $temp_fb_image_overlay['fb_image'];
465
- //We know the exact size now. We better just show it, right?
466
- $this->options['fb_image_size_show'] = 1;
467
- $fb_image_size = array(WEBDADOS_FB_W, WEBDADOS_FB_H);
468
- }
469
- //Additional
470
- if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)>0 ) {
471
- foreach($fb_image_additional as $key => $value ) {
472
- if ($value['png_overlay']) {
473
- $temp_fb_image_overlay = $this->get_image_with_overlay($value['fb_image']);
474
- if ( $temp_fb_image_overlay['overlay'] ) {
475
- $fb_image_additional[$key]['fb_image'] = $temp_fb_image_overlay['fb_image'];
476
  }
477
  }
478
  }
479
  }
480
- }
481
-
482
- //No spaces on URLs
483
- if ( isset($fb_url) && trim($fb_url)!='' ) $fb_url= str_replace(' ', '%20', trim($fb_url));
484
- if ( isset($fb_publisher) && trim($fb_publisher)!='' ) $fb_publisher= str_replace(' ', '%20', trim($fb_publisher));
485
- if ( isset($fb_publisher_schema) && trim($fb_publisher_schema)!='' ) $fb_publisher_schema= str_replace(' ', '%20', trim($fb_publisher_schema));
486
- if ( isset($fb_author) && trim($fb_author)!='' ) $fb_author= str_replace(' ', '%20', trim($fb_author));
487
- if ( isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp)!='' ) $fb_author_linkrelgp= str_replace(' ', '%20', trim($fb_author_linkrelgp));
488
- if ( isset($fb_image) && trim($fb_image)!='' ) $fb_image= str_replace(' ', '%20', trim($fb_image));
489
- if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) ) {
490
- foreach ( $fb_image_additional as $key => $value ) {
491
- $fb_image_additional[$key]['fb_image'] = str_replace( ' ', '%20', trim($value['fb_image']) );
492
  }
493
- }
494
-
495
- //If there's still no description let's just add the title as a last resort
496
- if ( trim($fb_desc)=='' ) $fb_desc = $fb_title;
497
-
498
- //Print tags
499
- // Facebook
500
- $html.=' <!-- Facebook Open Graph -->
501
  ';
502
- //Locale
503
- 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']) : $webdados_fb->get_locale() )).'"/>
504
  ';
505
- //Site name
506
- if ( intval($this->options['fb_sitename_show'])==1 ) $html.=' <meta property="og:site_name" content="'.trim(esc_attr(get_bloginfo('name' ))).'"/>
507
  ';
508
- //Title
509
- if ( intval($this->options['fb_title_show'])==1 && trim($fb_title)!='' ) $html.=' <meta property="og:title" content="'.trim(esc_attr($fb_title)).'"/>
510
  ';
511
- //URL
512
- if ( intval($this->options['fb_url_show'])==1 && trim($fb_url)!='' ) $html.=' <meta property="og:url" content="'.trim(esc_attr($fb_url)).'"/>
513
  ';
514
- //Type
515
- if ( intval($this->options['fb_type_show'])==1 && trim($fb_type)!='' ) $html.=' <meta property="og:type" content="'.trim(esc_attr($fb_type)).'"/>
516
  ';
517
- //Description
518
- if ( intval($this->options['fb_desc_show'])==1 && trim($fb_desc)!='' ) $html.=' <meta property="og:description" content="'.trim(esc_attr($fb_desc)).'"/>
519
  ';
520
- //Image
521
- if( intval($this->options['fb_image_show'])==1 && trim($fb_image)!='' ) $html.=' <meta property="og:image" content="'.trim(esc_attr($fb_image)).'"/>
522
  ';
523
- //Additional Images
524
- if( intval($this->options['fb_image_show'])==1 && isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)>0 ) {
525
- foreach ($fb_image_additional as $fb_image_additional_temp) {
526
- $html.=' <meta property="og:image" content="'.trim(esc_attr($fb_image_additional_temp['fb_image'])).'"/>
527
  ';
528
- }
529
- } else {
530
- //Image Size - We only show the image size if we only have one image
531
- if( intval($this->options['fb_image_size_show'])==1 && isset($fb_image_size) && is_array($fb_image_size) ) $html.=' <meta property="og:image:width" content="'.intval(esc_attr($fb_image_size[0])).'"/>
532
  <meta property="og:image:height" content="'.intval(esc_attr($fb_image_size[1])).'"/>
533
  ';
534
- }
535
- //Dates
536
- if ( intval($this->options['fb_article_dates_show'])==1 && trim($fb_article_pub_date)!='' ) $html.=' <meta property="article:published_time" content="'.trim(esc_attr($fb_article_pub_date)).'"/>
537
  ';
538
- if ( intval($this->options['fb_article_dates_show'])==1 && trim($fb_article_mod_date)!='') $html.=' <meta property="article:modified_time" content="'.trim(esc_attr($fb_article_mod_date)).'" />
539
  <meta property="og:updated_time" content="'.trim(esc_attr($fb_article_mod_date)).'" />
540
  ';
541
- //Sections
542
- if (intval($this->options['fb_article_sections_show'])==1 && isset($fb_sections) && is_array($fb_sections) && count($fb_sections)>0) {
543
- foreach($fb_sections as $fb_section) {
544
- $html.=' <meta property="article:section" content="'.trim(esc_attr($fb_section)).'"/>
545
  ';
 
546
  }
547
- }
548
- //Author
549
- if ( intval($this->options['fb_author_show'])==1 && $fb_author!='') $html.=' <meta property="article:author" content="'.trim(esc_attr($fb_author)).'"/>
550
  ';
551
- //Publisher
552
- if ( intval($this->options['fb_publisher_show'])==1 && trim($fb_publisher)!='') $html.=' <meta property="article:publisher" content="'.trim(esc_attr($fb_publisher)).'"/>
553
  ';
554
- //App ID
555
- if ( intval($this->options['fb_app_id_show'])==1 && trim($this->options['fb_app_id'])!='' ) $html.=' <meta property="fb:app_id" content="'.trim(esc_attr($this->options['fb_app_id'])).'"/>
556
  ';
557
- //Admins
558
- if ( intval($this->options['fb_admin_id_show'])==1 && trim($this->options['fb_admin_id'])!='' ) $html.=' <meta property="fb:admins" content="'.trim(esc_attr($this->options['fb_admin_id'])).'"/>
559
  ';
560
- // Schema
561
- $html.=' <!-- Google+ / Schema.org -->
562
  ';
563
- //Title
564
- if ( intval($this->options['fb_title_show_schema'])==1 && trim($fb_title)!='' ) $html.=' <meta itemprop="name" content="'.trim(esc_attr($fb_title)).'"/>
565
  ';
566
- //Description
567
- if ( intval($this->options['fb_desc_show_schema'])==1 && trim($fb_desc)!='' ) $html.=' <meta itemprop="description" content="'.trim(esc_attr($fb_desc)).'"/>
568
  ';
569
- //Image
570
- if( intval($this->options['fb_image_show_schema'])==1 && trim($fb_image)!='' ) $html.=' <meta itemprop="image" content="'.trim(esc_attr($fb_image)).'"/>
571
  ';
572
- //Author
573
- if ( intval($this->options['fb_author_show_linkrelgp'])==1 && trim($fb_author_linkrelgp)!='') $html.=' <link rel="author" href="'.trim(esc_attr($fb_author_linkrelgp)).'"/>
574
  ';
575
- //Publisher
576
- if ( intval($this->options['fb_publisher_show_schema'])==1 && trim($fb_publisher_schema)!='') $html.=' <link rel="publisher" href="'.trim(esc_attr($fb_publisher_schema)).'"/>
577
  ';
578
- // Twitter
579
- $html.=' <!-- Twitter Cards -->
580
  ';
581
- //Title
582
- if ( intval($this->options['fb_title_show_twitter'])==1 && trim($fb_title)!='' ) $html.=' <meta name="twitter:title" content="'.trim(esc_attr($fb_title)).'"/>
583
  ';
584
- //URL
585
- if ( intval($this->options['fb_url_show_twitter'])==1 && trim($fb_url)!='' ) $html.=' <meta name="twitter:url" content="'.trim(esc_attr($fb_url)).'"/>
586
  ';
587
- //Description
588
- if ( intval($this->options['fb_desc_show_twitter'])==1 && trim($fb_desc)!='' ) $html.=' <meta name="twitter:description" content="'.trim(esc_attr($fb_desc)).'"/>
589
  ';
590
- //Image
591
- if( intval($this->options['fb_image_show_twitter'])==1 && trim($fb_image)!='' ) $html.=' <meta name="twitter:image" content="'.trim(esc_attr($fb_image)).'"/>
592
  ';
593
- //Twitter Card
594
- if( intval($this->options['fb_title_show_twitter'])==1 || intval($this->options['fb_url_show_twitter'])==1 || intval($this->options['fb_desc_show_twitter'])==1 || intval($this->options['fb_publisher_show_twitter'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) $html.=' <meta name="twitter:card" content="'.trim(esc_attr($this->options['fb_twitter_card_type'])).'"/>
595
  ';
596
- //Author
597
- if ( intval($this->options['fb_author_show_twitter'])==1 && trim($fb_author_twitter)!='' ) $html.=' <meta name="twitter:creator" content="@'.trim(esc_attr( $fb_author_twitter )).'"/>
598
  ';
599
- //Publisher
600
- if ( intval($this->options['fb_publisher_show_twitter'])==1 && trim($fb_publisher_twitteruser)!='') $html.=' <meta name="twitter:site" content="@'.trim(esc_attr($fb_publisher_twitteruser)).'"/>
601
  ';
602
- // SEO
603
- $html.=' <!-- SEO -->
604
  ';
605
- //Title
606
- if ( intval($fb_set_title_tag)==1 && trim($fb_title)!='' ) {
607
- //Does nothing so far. We try to create the <title> tag but it's too late now
608
- //We should use wp_title(), but do we want to? This is only because Business Directory Plugin and they seem to have it covered by now...
609
- }
610
- //URL
611
- if ( intval($this->options['fb_url_canonical'])==1 ) $html.=' <link rel="canonical" href="'.trim(esc_attr($fb_url)).'"/>
612
  ';
613
- //Description
614
- if ( intval($this->options['fb_desc_show_meta'])==1 && trim($fb_desc)!='' ) $html.=' <meta name="description" content="'.trim(esc_attr($fb_desc)).'"/>
615
  ';
616
- //Author
617
- if (intval($this->options['fb_author_show_meta'])==1 && $fb_author_meta!='') $html.=' <meta name="author" content="'.trim(esc_attr($fb_author_meta)).'"/>
618
  ';
619
- //Publisher
620
- if ( intval($this->options['fb_publisher_show_meta'])==1 ) $html.=' <meta name="publisher" content="'.trim(esc_attr(get_bloginfo('name' ))).'"/>
621
  ';
622
- // SEO
623
- $html.=' <!-- Misc. tags -->
624
  ';
625
- foreach ($fb_additional_tags as $type => $tags) {
626
- foreach($tags as $tag => $values) {
627
- foreach($values as $value) {
628
- $html.=' <meta '.$type.'="'.str_replace('_', ':', trim($tag)).'" content="'.trim(esc_attr($value)).'"/>
629
  ';
 
630
  }
631
  }
632
- }
633
- } else {
634
-
635
- $html.=' <!-- Removed by fb_og_enabled filter -->
636
  ';
637
-
638
- }
639
 
640
- //Close tag
641
- $html.='<!-- END - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
642
-
 
 
 
 
 
 
 
 
643
  ';
 
644
  echo apply_filters('fb_og_output', $html);
645
 
646
  }
@@ -741,11 +750,18 @@ class Webdados_FB_Public {
741
  );
742
  }
743
  if ($imagetemp) {
744
- if ($img_size = $this->get_open_graph_image_size($imagetempsize)) {
745
- if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
746
- $fb_image = $imagetemp;
747
- $thumbdone = true;
748
- break;
 
 
 
 
 
 
 
749
  }
750
  }
751
  }
@@ -773,11 +789,18 @@ class Webdados_FB_Public {
773
  :
774
  ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
775
  );
776
- if ( $img_size = $this->get_open_graph_image_size($imagetempsize) ) {
777
- if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
778
- $fb_image = $imagetemp;
779
- $thumbdone = true;
780
- break;
 
 
 
 
 
 
 
781
  }
782
  }
783
  }
@@ -821,17 +844,24 @@ class Webdados_FB_Public {
821
 
822
  /* Get image size */
823
  private function get_open_graph_image_size_curl( $image, $headers ) {
824
- $curl = curl_init($image);
825
- if ( is_array($headers) ) curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
826
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
827
- //Set HTTP REFERER and USER AGENT just in case. Some servers may have hotlinking protection
828
- curl_setopt($curl, CURLOPT_REFERER, ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
829
- curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
830
- $data = curl_exec($curl);
831
- curl_close($curl);
832
- return $data;
 
 
 
 
833
  }
834
  private function get_open_graph_image_size( $image ) {
 
 
 
835
  $transient_key = 'webdados_og_image_size_' . md5($image);
836
  $transient_val = get_transient($transient_key);
837
  if ($transient_val) {
@@ -858,8 +888,12 @@ class Webdados_FB_Public {
858
  }
859
  if ( !$done_partial && !$tried_full ) {
860
  //Try again with the whole image - In case of Warning
861
- $data = $this->get_open_graph_image_size_curl($image, null);
862
- $im = @imagecreatefromstring($data);
 
 
 
 
863
  }
864
  if ( $im ) {
865
  if ( $x=imagesx($im) ) {
@@ -990,9 +1024,18 @@ class Webdados_FB_Public {
990
  $filesize = $header['Content-Length'];
991
  $url = $fb_image;
992
  }
993
- list( $width, $height, $type, $attr ) = $this->get_open_graph_image_size( $url );
994
- echo '<enclosure url="' . $fb_image . '" length="' . $filesize . '" type="'.image_type_to_mime_type($type).'"/>';
995
- echo '<media:content url="'.$fb_image.'" width="'.$width.'" height="'.$height.'" medium="image" type="'.image_type_to_mime_type($type).'"/>';
 
 
 
 
 
 
 
 
 
996
  }
997
  }
998
  }
42
  public function insert_meta_tags() {
43
  global $webdados_fb, $wp_query;
44
 
45
+ if ( !apply_filters( 'fb_og_disable', false ) ) {
46
+
47
+ //Open tag
48
+ $html='
49
  <!-- START - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
50
  ';
 
 
51
 
52
+ if ( apply_filters('fb_og_enabled', true) ) {
53
+
54
+ //Also set Title Tag? - Needed??
55
+ $fb_set_title_tag=0;
56
+
57
+ //Init values
58
+ $fb_locale = '';
59
+ $fb_title = '';
60
+ $fb_url = '';
61
+ $fb_desc = '';
62
+ $fb_image = '';
63
+ $fb_type = 'article';
64
+ $fb_author = '';
65
+ $fb_author_meta = '';
66
+ $fb_author_linkrelgp = '';
67
+ $fb_author_twitter = '';
68
+ $fb_article_pub_date = '';
69
+ $fb_article_mod_date = '';
70
+ $fb_image_additional = array();
71
+ $fb_additional_tags = array(
72
+ 'name' => array(),
73
+ 'property' => array(),
74
+ );
75
+ $fb_publisher = trim($this->options['fb_publisher']);
76
+ $fb_publisher_schema = trim($this->options['fb_publisher_schema']);
77
+ $fb_publisher_twitteruser = trim($this->options['fb_publisher_twitteruser']);
78
+
79
+ //Homepage Description
80
+ switch( $this->options['fb_desc_homepage'] ) {
81
+ case 'custom':
82
+ $fb_desc_homepage = $this->options['fb_desc_homepage_customtext'];
83
+ //WPML?
84
+ if ( $webdados_fb->is_wpml_active() ) {
85
+ global $sitepress;
86
+ if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
87
+ $fb_desc_homepage = icl_t( 'wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc_homepage );
88
+ }
89
  }
90
+ break;
91
+ default:
92
+ $fb_desc_homepage = get_bloginfo( 'description' );
93
+ break;
94
+ }
95
+
96
+ if ( is_singular() ) {
97
+
98
+ global $post;
99
+ // Title
100
+ //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page
101
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( $post->post_title ), true ) );
102
+ //SubHeading
103
+ if ( isset($this->options['fb_show_subheading']) && intval($this->options['fb_show_subheading'])==1 && $webdados_fb->is_subheading_plugin_active() ) {
104
+ if (isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
105
+ $fb_title = trim( trim(get_the_subheading()).' - '.trim($fb_title), ' -' );
106
+ } else {
107
+ $fb_title = trim( trim($fb_title).' - '.trim(get_the_subheading()), ' -' );
108
+ }
109
+ }
110
+ // URL
111
+ $fb_url = get_permalink();
112
+ // Type if it's a homepage page
113
+ if ( is_front_page() ) {
114
+ /* Fix homepage type when it's a static page */
115
+ $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '' );
116
+ $fb_type = trim($this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage']);
117
+ }
118
+ // Description
119
+ if ( trim($post->post_excerpt) != '' ) {
120
+ //If there's an excerpt that's what we'll use
121
+ $fb_desc = trim($post->post_excerpt);
122
  } else {
123
+ //If not we grab it from the content
124
+ $fb_desc = trim($post->post_content);
125
  }
126
+ // Image
127
+ if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
128
+ $fb_image = $this->get_post_image();
129
+ }
130
+ // Author
131
+ $author_id = $post->post_author;
132
+ if ( $author_id > 0 && ! ( is_page() && intval($this->options['fb_author_hide_on_pages'])==1 ) ) {
133
+ $fb_author = get_the_author_meta('facebook', $author_id);
134
+ $fb_author_meta = get_the_author_meta('display_name', $author_id);
135
+ $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id);
136
+ $fb_author_twitter = get_the_author_meta('twitter', $author_id);
137
+ }
138
+
139
+ //Published and Modified time - We should check this out and maybe have it for any kind of post...
140
+ if ( is_singular('post' ) ) {
141
+ $fb_article_pub_date = get_the_date('c' );
142
+ $fb_article_mod_date = get_the_modified_date('c' );
143
+ } else {
144
+ //Reset dates show because we're not on posts
145
+ $this->options['fb_article_dates_show'] = 0;
146
+ }
147
+ //Sections
148
+ if ( is_singular('post' ) ) {
149
+ $cats = get_the_category();
150
+ if ( !is_wp_error($cats) && (is_array($cats) && count($cats)>0) ) {
151
+ $fb_sections = array();
152
+ foreach ($cats as $cat) {
153
+ $fb_sections[] = $cat->name;
154
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
+ } else {
157
+ $this->options['fb_article_sections_show'] = 0;
158
  }
159
+ // Business Directory Plugin
160
+ if ( isset( $this->options['fb_show_businessdirectoryplugin'] ) && $webdados_fb->is_business_directory_active() ) {
161
+ global $wpbdp;
162
+ $bdp_action = wpbdp_current_action();
163
+ $bdp_disable_cpt = wpbdp_get_option( 'disable-cpt' );
164
+ $current_view_object = $wpbdp->dispatcher->current_view_object();
165
+ switch( $bdp_action ) {
166
+ case 'show_listing':
167
+ $fb_title = trim( esc_attr( wp_strip_all_tags( stripslashes( $this->post->post_title ), true ) ).' - '.$fb_title, ' -' );
168
+ $fb_set_title_tag = 1;
169
+ $fb_url = get_permalink($this->post->ID);
170
+ if ( trim($this->post->post_excerpt)!='' ) {
171
+ //If there's an excerpt that's what we'll use
172
+ $fb_desc = trim($this->post->post_excerpt);
173
+ } else {
174
+ //If not we grab it from the content
175
+ $fb_desc = trim($this->post->post_content);
176
+ }
177
+ if (intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1) {
178
+ $thumbdone = false;
179
+ if ( intval($this->options['fb_image_use_featured'])==1 ) {
180
+ //Featured
181
+ if ( $id_attachment = get_post_thumbnail_id( $this->post->ID ) ) {
182
+ //There's a featured/thumbnail image for this listing
183
+ $fb_image = wp_get_attachment_url( $id_attachment, false );
184
+ $thumbdone = true;
185
+ } else {
186
+ }
 
 
187
  }
188
+ if ( !$thumbdone ) {
189
+ //Main image loaded
190
+ if ( $thumbnail_id = wpbdp_listings_api()->get_thumbnail_id( $this->post->ID ) ) {
191
+ $fb_image = wp_get_attachment_url( $thumbnail_id, false );
192
+ $thumbdone = true;
193
+ }
194
  }
195
  }
196
+ }
197
  }
198
+ // WooCommerce
199
+ if ( $webdados_fb->is_woocommerce_active() && is_product() ) {
200
+ $fb_type = 'product';
201
+ $product = new WC_Product( $post->ID );
202
+ //Price
203
+ $price = version_compare( WC_VERSION, '3.0', '>=' ) ? wc_get_price_including_tax($product) : $product->get_price_including_tax();
204
+ $currency = get_woocommerce_currency();
205
+ $fb_additional_tags['property']['product_price_amount'] = array(
206
+ $price
207
+ );
208
+ if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['property']['product_price_currency'] = array(
209
+ $currency
210
+ );
211
+ $fb_additional_tags['name']['twitter_label1'] = array(
212
+ __('Price', 'wd-fb-og')
213
+ );
214
+ if ( function_exists('get_woocommerce_currency') ) $fb_additional_tags['name']['twitter_data1'] = array(
215
+ $price.' '.get_woocommerce_currency()
216
+ );
217
+ //Additional product images?
218
+ if ( intval($this->options['fb_image_show'])==1 && $this->options['fb_wc_useproductgallery']==1 ) {
219
+ if ( $attachment_ids = version_compare( WC_VERSION, '3.0', '>=' ) ? $product->get_gallery_image_ids() : $product->get_gallery_attachment_ids() ) {
220
+ foreach ( $attachment_ids as $attachment_id ) {
221
+ if ( $image_link = wp_get_attachment_url( $attachment_id ) ) {
222
+ if ( trim($image_link)!='' ) {
223
+ $fb_image_additional[] = array(
224
+ 'fb_image' => trim($image_link),
225
+ 'png_overlay' => ( intval($this->options['fb_wc_usepg_png_overlay']) ? true : false ),
226
+ );
227
+ }
228
  }
229
  }
230
  }
231
  }
232
  }
233
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  } else {
235
+
236
+ //Other pages - Defaults
237
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_bloginfo( 'name' ) ), true ) );
238
+ $fb_url = ( ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //Not really canonical but will work for now
239
+ $fb_image = trim( $this->options['fb_image'] );
240
+
241
+ $this->options['fb_article_sections_show'] = 0;
242
+ $this->options['fb_article_dates_show'] = 0;
243
+ $this->options['fb_author_show'] = 0;
244
+ $this->options['fb_author_show_meta'] = 0;
245
+ $this->options['fb_author_show_linkrelgp'] = 0;
246
+ $this->options['fb_author_show_twitter'] = 0;
247
+ $this->options['fb_author_show_twitter'] = 0;
248
+
249
+ //Category
250
+ if ( is_category() ) {
251
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_cat_title( '', false ) ), true ) );
252
  $term = $wp_query->get_queried_object();
253
  $fb_url = get_term_link( $term, $term->taxonomy );
254
+ $cat_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( category_description() ), true ) ) );
255
+ if ( trim($cat_desc)!='' ) $fb_desc = $cat_desc;
256
  } else {
257
+ if ( is_tag() ) {
258
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_tag_title( '', false ) ), true ) );
259
  $term = $wp_query->get_queried_object();
260
+ $fb_url = get_term_link( $term, $term->taxonomy );
261
+ $tag_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( tag_description() ), true ) ) );
262
+ if ( trim($tag_desc)!='' ) $fb_desc = $tag_desc;
263
+ } else {
264
+ if (is_tax()) {
265
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_term_title( '', false ) ), true ) );
266
+ $term = $wp_query->get_queried_object();
267
+ $fb_url = get_term_link($term, $term->taxonomy);
268
+ $tax_desc = trim( esc_attr( wp_strip_all_tags( stripslashes( term_description() ), true ) ) );
269
+ if ( trim($tax_desc)!='' ) $fb_desc = $tax_desc;
270
+ //WooCommerce
271
+ if ( $webdados_fb->is_woocommerce_active() && intval($this->options['fb_wc_usecategthumb'])==1 && is_product_category() ) {
272
+ if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
273
+ if ( $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ) ) {
274
+ if ( $image = wp_get_attachment_url( $thumbnail_id ) ) {
275
+ $fb_image = $image;
276
+ }
277
  }
278
  }
279
  }
 
 
 
 
 
280
  } else {
281
+ if ( is_search() ) {
282
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( __('Search for', 'wd-fb-og').' "'.get_search_query().'"' ), true ) );
283
+ $fb_url = get_search_link();
284
  } else {
285
+ if (is_author()) {
286
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_the_author_meta('display_name', get_query_var('author') ) ), true ) );
287
+ $fb_url = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
288
+ } else {
289
+ if ( is_archive() ) {
290
+ if ( is_day() ) {
291
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'day' ) . ' ' .single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
292
+ $fb_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
293
  } else {
294
+ if ( is_month() ) {
295
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( single_month_title( ' ', false ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
296
+ $fb_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
297
+ } else {
298
+ if ( is_year() ) {
299
+ $fb_title = esc_attr( wp_strip_all_tags( stripslashes( get_query_var( 'year' ) . ' ' . __( 'Archives', 'wd-fb-og' ) ), true ) );
300
+ $fb_url = get_year_link( get_query_var( 'year' ) );
301
+ }
302
  }
303
  }
 
 
 
 
 
 
304
  } else {
305
+ if (is_front_page()) {
306
+ $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '');
307
+ $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
308
+ $fb_desc = $fb_desc_homepage;
309
+ } else {
310
+ //Others... Defaults already set up there
311
+ }
312
  }
313
  }
314
  }
316
  }
317
  }
318
  }
319
+
320
+ //og:type for WPML root page?
321
+ if ( $webdados_fb->is_wpml_active() ) {
322
+ if ( class_exists('WPML_Root_Page') ) {
323
+ if ( WPML_Root_Page::is_current_request_root() ) {
324
+ $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
325
+ }
326
  }
327
  }
328
+
329
+
330
+
331
+ //Default description, if empty until now
332
+ if ( trim($fb_desc)=='' ) {
333
+ switch( $this->options['fb_desc_default_option'] ) {
334
+ case 'custom':
335
+ $fb_desc = $this->options['fb_desc_default'];
336
+ //WPML?
337
+ if ( $webdados_fb->is_wpml_active() ) {
338
+ global $sitepress;
339
+ if ( ICL_LANGUAGE_CODE != $sitepress->get_default_language() ) {
340
+ $fb_desc = icl_t( 'wd-fb-og', 'wd_fb_og_fb_desc_default', $fb_desc );
341
+ }
342
  }
343
+ break;
344
+ default:
345
+ $fb_desc = $fb_desc_homepage;
346
+ break;
347
+ }
348
  }
349
+
350
+ //Trim description
351
+ $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
352
+ $fb_desc = trim(
353
+ intval($this->options['fb_desc_chars'])>0
354
+ ?
355
+ mb_substr( wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) ), 0, intval($this->options['fb_desc_chars']) )
356
+ :
357
+ wp_strip_all_tags( strip_shortcodes( stripslashes( $fb_desc ), true ) )
358
+ );
359
+
360
+ //YOAST SEO?
361
+ if ( $this->options['fb_show_wpseoyoast']==1 ) {
362
+ if ( $webdados_fb->is_yoast_seo_active() ) {
363
+ $wpseo = WPSEO_Frontend::get_instance();
364
+ //Title
365
+ $fb_title_temp = $wpseo->title(false);
366
+ $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
367
+ //Title - SubHeading plugin
368
+ if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
369
+ if ( $webdados_fb->is_subheading_plugin_active() ) {
370
+ if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
371
+ $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
372
+ } else {
373
+ $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
374
+ }
375
  }
376
  }
377
+ //URL
378
+ $fb_url_temp = $wpseo->canonical(false);
379
+ $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);
380
+ //Description
381
+ $fb_desc_temp = $wpseo->metadesc(false);
382
+ $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
383
  }
 
 
 
 
 
 
384
  }
385
+
386
+ //All in One SEO Pack?
387
+ if ( $this->options['fb_show_aioseop']==1 ) {
388
+ if ( $webdados_fb->is_aioseop_active() ) {
389
+ global $aiosp;
390
+ //Title - Why are we getting the first post title on archives and homepage...?!?
391
+ $fb_title_temp = $aiosp->orig_title;
392
+ $fb_title = wp_strip_all_tags( trim($fb_title_temp)!='' ? trim($fb_title_temp) : $fb_title, true);
393
+ //Title - SubHeading plugin
394
+ if ( $fb_title_temp!='' && $this->options['fb_show_subheading']==1 ) {
395
+ if ( $webdados_fb->is_subheading_plugin_active() ) {
396
+ if ( isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position']=='before' ) {
397
+ $fb_title = trim( trim( get_the_subheading() ).' - '.trim($fb_title), ' -');
398
+ } else {
399
+ $fb_title = trim( trim( $fb_title ).' - '.trim( get_the_subheading() ), ' -');
400
+ }
401
  }
402
  }
403
+ //URL - See aioseop_class.php 3898 - We have a problem because wp_query is not the same right now
404
+ /*$fb_url_temp = '';
405
+ $aioseop_options = get_option( 'aioseop_options' );
406
+ $opts = $aiosp->meta_opts;
407
+ var_dump($wp_query);
408
+ $show_page = true;
409
+ if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) {
410
+ $show_page = false;
 
 
 
 
 
411
  }
412
+ if ( $aioseop_options['aiosp_can'] ) {
413
+ if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) {
414
+ $fb_url_temp = $opts['aiosp_custom_link'];
415
+ }
416
+ if ( empty( $url ) ) {
417
+ $fb_url_temp = $aiosp->aiosp_mrt_get_url( $wp_query, $show_page );
418
+ }
419
+
420
+ $fb_url_temp = $aiosp->validate_url_scheme( $fb_url_temp );
421
+
422
+ $fb_url_temp = apply_filters( 'aioseop_canonical_url', $fb_url_temp );
423
  }
424
+ var_dump($fb_url_temp);
425
+ $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);*/
426
+ //Description - Why are we getting the first post description on archives and homepage...?!?
427
+ if ( is_home() && ! is_front_page() ) {
428
+ $post = aiosp_common::get_blog_page();
429
+ } else {
430
+ $post = $aiosp->get_queried_object();
431
+ }
432
+ $fb_desc_temp = apply_filters( 'aioseop_description', $aiosp->get_main_description( $post ) );
433
+ $fb_desc = wp_strip_all_tags( trim($fb_desc_temp)!='' ? trim($fb_desc_temp) : $fb_desc, true);
434
+
 
435
  }
 
 
 
436
  }
437
+
438
+ //Apply Filters
439
+ $fb_locale = apply_filters('fb_og_locale', $fb_locale);
440
+ $fb_title = apply_filters('fb_og_title', $fb_title);
441
+ $fb_url = apply_filters('fb_og_url', $fb_url);
442
+ $fb_type = apply_filters('fb_og_type', $fb_type);
443
+ $fb_desc = apply_filters('fb_og_desc', $fb_desc);
444
+ $fb_image = apply_filters('fb_og_image', $fb_image);
445
+ $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional);
446
+
447
+ //Image size
448
+ $fb_image_size = false;
449
+ if ( intval($this->options['fb_image_show'])==1 && trim($fb_image)!='' ) {
450
+ if ( intval($this->options['fb_image_size_show'])==1 && intval($this->options['fb_adv_disable_image_size'])==0 ) {
451
+ if ( isset($this->image_size) && is_array($this->image_size) ) { //Already fetched
452
+ $fb_image_size = $this->image_size;
453
+ } else {
454
+ $fb_image_size = $this->get_open_graph_image_size($fb_image);
455
+ }
456
  }
457
+ } else {
458
+ $this->options['fb_image_show'] = 0;
459
  }
460
+
461
+ //Image overlay - Single?
462
+ if ( intval($this->options['fb_image_show'])==1 && intval($this->options['fb_image_overlay'])==1 && apply_filters('fb_og_image_overlay', true, $fb_image) ) {
463
+ //Single
464
+ $temp_fb_image_overlay = $this->get_image_with_overlay($fb_image);
465
+ if ( $temp_fb_image_overlay['overlay'] ) {
466
+ $fb_image = $temp_fb_image_overlay['fb_image'];
467
+ //We know the exact size now. We better just show it, right?
468
+ $this->options['fb_image_size_show'] = 1;
469
+ $fb_image_size = array(WEBDADOS_FB_W, WEBDADOS_FB_H);
470
+ }
471
+ //Additional
472
+ if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)>0 ) {
473
+ foreach($fb_image_additional as $key => $value ) {
474
+ if ($value['png_overlay']) {
475
+ $temp_fb_image_overlay = $this->get_image_with_overlay($value['fb_image']);
476
+ if ( $temp_fb_image_overlay['overlay'] ) {
477
+ $fb_image_additional[$key]['fb_image'] = $temp_fb_image_overlay['fb_image'];
478
+ }
 
 
479
  }
480
  }
481
  }
482
  }
483
+
484
+ //No spaces on URLs
485
+ if ( isset($fb_url) && trim($fb_url)!='' ) $fb_url= str_replace(' ', '%20', trim($fb_url));
486
+ if ( isset($fb_publisher) && trim($fb_publisher)!='' ) $fb_publisher= str_replace(' ', '%20', trim($fb_publisher));
487
+ if ( isset($fb_publisher_schema) && trim($fb_publisher_schema)!='' ) $fb_publisher_schema= str_replace(' ', '%20', trim($fb_publisher_schema));
488
+ if ( isset($fb_author) && trim($fb_author)!='' ) $fb_author= str_replace(' ', '%20', trim($fb_author));
489
+ if ( isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp)!='' ) $fb_author_linkrelgp= str_replace(' ', '%20', trim($fb_author_linkrelgp));
490
+ if ( isset($fb_image) && trim($fb_image)!='' ) $fb_image= str_replace(' ', '%20', trim($fb_image));
491
+ if ( isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) ) {
492
+ foreach ( $fb_image_additional as $key => $value ) {
493
+ $fb_image_additional[$key]['fb_image'] = str_replace( ' ', '%20', trim($value['fb_image']) );
494
+ }
495
  }
496
+
497
+ //If there's still no description let's just add the title as a last resort
498
+ if ( trim($fb_desc)=='' ) $fb_desc = $fb_title;
499
+
500
+ //Print tags
501
+ // Facebook
502
+ $html.=' <!-- Facebook Open Graph -->
 
503
  ';
504
+ //Locale
505
+ 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']) : $webdados_fb->get_locale() )).'"/>
506
  ';
507
+ //Site name
508
+ if ( intval($this->options['fb_sitename_show'])==1 ) $html.=' <meta property="og:site_name" content="'.trim(esc_attr(get_bloginfo('name' ))).'"/>
509
  ';
510
+ //Title
511
+ if ( intval($this->options['fb_title_show'])==1 && trim($fb_title)!='' ) $html.=' <meta property="og:title" content="'.trim(esc_attr($fb_title)).'"/>
512
  ';
513
+ //URL
514
+ if ( intval($this->options['fb_url_show'])==1 && trim($fb_url)!='' ) $html.=' <meta property="og:url" content="'.trim(esc_attr($fb_url)).'"/>
515
  ';
516
+ //Type
517
+ if ( intval($this->options['fb_type_show'])==1 && trim($fb_type)!='' ) $html.=' <meta property="og:type" content="'.trim(esc_attr($fb_type)).'"/>
518
  ';
519
+ //Description
520
+ if ( intval($this->options['fb_desc_show'])==1 && trim($fb_desc)!='' ) $html.=' <meta property="og:description" content="'.trim(esc_attr($fb_desc)).'"/>
521
  ';
522
+ //Image
523
+ if( intval($this->options['fb_image_show'])==1 && trim($fb_image)!='' ) $html.=' <meta property="og:image" content="'.trim(esc_attr($fb_image)).'"/>
524
  ';
525
+ //Additional Images
526
+ if( intval($this->options['fb_image_show'])==1 && isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)>0 ) {
527
+ foreach ($fb_image_additional as $fb_image_additional_temp) {
528
+ $html.=' <meta property="og:image" content="'.trim(esc_attr($fb_image_additional_temp['fb_image'])).'"/>
529
  ';
530
+ }
531
+ } else {
532
+ //Image Size - We only show the image size if we only have one image
533
+ if( intval($this->options['fb_image_size_show'])==1 && isset($fb_image_size) && is_array($fb_image_size) ) $html.=' <meta property="og:image:width" content="'.intval(esc_attr($fb_image_size[0])).'"/>
534
  <meta property="og:image:height" content="'.intval(esc_attr($fb_image_size[1])).'"/>
535
  ';
536
+ }
537
+ //Dates
538
+ if ( intval($this->options['fb_article_dates_show'])==1 && trim($fb_article_pub_date)!='' ) $html.=' <meta property="article:published_time" content="'.trim(esc_attr($fb_article_pub_date)).'"/>
539
  ';
540
+ if ( intval($this->options['fb_article_dates_show'])==1 && trim($fb_article_mod_date)!='') $html.=' <meta property="article:modified_time" content="'.trim(esc_attr($fb_article_mod_date)).'" />
541
  <meta property="og:updated_time" content="'.trim(esc_attr($fb_article_mod_date)).'" />
542
  ';
543
+ //Sections
544
+ if (intval($this->options['fb_article_sections_show'])==1 && isset($fb_sections) && is_array($fb_sections) && count($fb_sections)>0) {
545
+ foreach($fb_sections as $fb_section) {
546
+ $html.=' <meta property="article:section" content="'.trim(esc_attr($fb_section)).'"/>
547
  ';
548
+ }
549
  }
550
+ //Author
551
+ if ( intval($this->options['fb_author_show'])==1 && $fb_author!='') $html.=' <meta property="article:author" content="'.trim(esc_attr($fb_author)).'"/>
 
552
  ';
553
+ //Publisher
554
+ if ( intval($this->options['fb_publisher_show'])==1 && trim($fb_publisher)!='') $html.=' <meta property="article:publisher" content="'.trim(esc_attr($fb_publisher)).'"/>
555
  ';
556
+ //App ID
557
+ if ( intval($this->options['fb_app_id_show'])==1 && trim($this->options['fb_app_id'])!='' ) $html.=' <meta property="fb:app_id" content="'.trim(esc_attr($this->options['fb_app_id'])).'"/>
558
  ';
559
+ //Admins
560
+ if ( intval($this->options['fb_admin_id_show'])==1 && trim($this->options['fb_admin_id'])!='' ) $html.=' <meta property="fb:admins" content="'.trim(esc_attr($this->options['fb_admin_id'])).'"/>
561
  ';
562
+ // Schema
563
+ $html.=' <!-- Google+ / Schema.org -->
564
  ';
565
+ //Title
566
+ if ( intval($this->options['fb_title_show_schema'])==1 && trim($fb_title)!='' ) $html.=' <meta itemprop="name" content="'.trim(esc_attr($fb_title)).'"/>
567
  ';
568
+ //Description
569
+ if ( intval($this->options['fb_desc_show_schema'])==1 && trim($fb_desc)!='' ) $html.=' <meta itemprop="description" content="'.trim(esc_attr($fb_desc)).'"/>
570
  ';
571
+ //Image
572
+ if( intval($this->options['fb_image_show_schema'])==1 && trim($fb_image)!='' ) $html.=' <meta itemprop="image" content="'.trim(esc_attr($fb_image)).'"/>
573
  ';
574
+ //Author
575
+ if ( intval($this->options['fb_author_show_linkrelgp'])==1 && trim($fb_author_linkrelgp)!='') $html.=' <link rel="author" href="'.trim(esc_attr($fb_author_linkrelgp)).'"/>
576
  ';
577
+ //Publisher
578
+ if ( intval($this->options['fb_publisher_show_schema'])==1 && trim($fb_publisher_schema)!='') $html.=' <link rel="publisher" href="'.trim(esc_attr($fb_publisher_schema)).'"/>
579
  ';
580
+ // Twitter
581
+ $html.=' <!-- Twitter Cards -->
582
  ';
583
+ //Title
584
+ if ( intval($this->options['fb_title_show_twitter'])==1 && trim($fb_title)!='' ) $html.=' <meta name="twitter:title" content="'.trim(esc_attr($fb_title)).'"/>
585
  ';
586
+ //URL
587
+ if ( intval($this->options['fb_url_show_twitter'])==1 && trim($fb_url)!='' ) $html.=' <meta name="twitter:url" content="'.trim(esc_attr($fb_url)).'"/>
588
  ';
589
+ //Description
590
+ if ( intval($this->options['fb_desc_show_twitter'])==1 && trim($fb_desc)!='' ) $html.=' <meta name="twitter:description" content="'.trim(esc_attr($fb_desc)).'"/>
591
  ';
592
+ //Image
593
+ if( intval($this->options['fb_image_show_twitter'])==1 && trim($fb_image)!='' ) $html.=' <meta name="twitter:image" content="'.trim(esc_attr($fb_image)).'"/>
594
  ';
595
+ //Twitter Card
596
+ if( intval($this->options['fb_title_show_twitter'])==1 || intval($this->options['fb_url_show_twitter'])==1 || intval($this->options['fb_desc_show_twitter'])==1 || intval($this->options['fb_publisher_show_twitter'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) $html.=' <meta name="twitter:card" content="'.trim(esc_attr($this->options['fb_twitter_card_type'])).'"/>
597
  ';
598
+ //Author
599
+ if ( intval($this->options['fb_author_show_twitter'])==1 && trim($fb_author_twitter)!='' ) $html.=' <meta name="twitter:creator" content="@'.trim(esc_attr( $fb_author_twitter )).'"/>
600
  ';
601
+ //Publisher
602
+ if ( intval($this->options['fb_publisher_show_twitter'])==1 && trim($fb_publisher_twitteruser)!='') $html.=' <meta name="twitter:site" content="@'.trim(esc_attr($fb_publisher_twitteruser)).'"/>
603
  ';
604
+ // SEO
605
+ $html.=' <!-- SEO -->
606
  ';
607
+ //Title
608
+ if ( intval($fb_set_title_tag)==1 && trim($fb_title)!='' ) {
609
+ //Does nothing so far. We try to create the <title> tag but it's too late now
610
+ //We should use wp_title(), but do we want to? This is only because Business Directory Plugin and they seem to have it covered by now...
611
+ }
612
+ //URL
613
+ if ( intval($this->options['fb_url_canonical'])==1 ) $html.=' <link rel="canonical" href="'.trim(esc_attr($fb_url)).'"/>
614
  ';
615
+ //Description
616
+ if ( intval($this->options['fb_desc_show_meta'])==1 && trim($fb_desc)!='' ) $html.=' <meta name="description" content="'.trim(esc_attr($fb_desc)).'"/>
617
  ';
618
+ //Author
619
+ if (intval($this->options['fb_author_show_meta'])==1 && $fb_author_meta!='') $html.=' <meta name="author" content="'.trim(esc_attr($fb_author_meta)).'"/>
620
  ';
621
+ //Publisher
622
+ if ( intval($this->options['fb_publisher_show_meta'])==1 ) $html.=' <meta name="publisher" content="'.trim(esc_attr(get_bloginfo('name' ))).'"/>
623
  ';
624
+ // SEO
625
+ $html.=' <!-- Misc. tags -->
626
  ';
627
+ foreach ($fb_additional_tags as $type => $tags) {
628
+ foreach($tags as $tag => $values) {
629
+ foreach($values as $value) {
630
+ $html.=' <meta '.$type.'="'.str_replace('_', ':', trim($tag)).'" content="'.trim(esc_attr($value)).'"/>
631
  ';
632
+ }
633
  }
634
  }
635
+ } else {
636
+
637
+ $html.=' <!-- Removed by fb_og_enabled filter -->
 
638
  ';
 
 
639
 
640
+ }
641
+
642
+ //Close tag
643
+ $html.='<!-- END - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
644
+
645
+ ';
646
+ } else {
647
+ $html = '
648
+ <!-- START - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
649
+ <!-- Disabled by the "fb_og_disable" filter -->
650
+ <!-- END - '.WEBDADOS_FB_PLUGIN_NAME.' '.WEBDADOS_FB_VERSION.' -->
651
  ';
652
+ }
653
  echo apply_filters('fb_og_output', $html);
654
 
655
  }
750
  );
751
  }
752
  if ($imagetemp) {
753
+ if ( intval($this->options['fb_adv_disable_image_size'])==1 ) {
754
+ //If we don't check for image size, we'll just accept the first one
755
+ $fb_image = $imagetemp;
756
+ $thumbdone = true;
757
+ break; //Break the foreach
758
+ } else {
759
+ if ($img_size = $this->get_open_graph_image_size($imagetempsize)) {
760
+ if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
761
+ $fb_image = $imagetemp;
762
+ $thumbdone = true;
763
+ break; //Break the foreach
764
+ }
765
  }
766
  }
767
  }
789
  :
790
  ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
791
  );
792
+ if ( intval($this->options['fb_adv_disable_image_size'])==1 ) {
793
+ //If we don't check for image size, we'll just accept the first one
794
+ $fb_image = $imagetemp;
795
+ $thumbdone = true;
796
+ break; //Break the foreach
797
+ } else {
798
+ if ( $img_size = $this->get_open_graph_image_size($imagetempsize) ) {
799
+ if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
800
+ $fb_image = $imagetemp;
801
+ $thumbdone = true;
802
+ break; //Break the foreach
803
+ }
804
  }
805
  }
806
  }
844
 
845
  /* Get image size */
846
  private function get_open_graph_image_size_curl( $image, $headers ) {
847
+ try {
848
+ $curl = curl_init($image);
849
+ if ( is_array($headers) ) curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
850
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
851
+ //Set HTTP REFERER and USER AGENT just in case. Some servers may have hotlinking protection
852
+ curl_setopt($curl, CURLOPT_REFERER, ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
853
+ curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
854
+ $data = curl_exec($curl);
855
+ curl_close($curl);
856
+ return $data;
857
+ } catch(Exception $e) {
858
+ return false;
859
+ }
860
  }
861
  private function get_open_graph_image_size( $image ) {
862
+ //Just in case we've missed it somewhere...
863
+ if ( intval($this->options['fb_adv_disable_image_size'])==1 ) return false;
864
+ //Go ahead
865
  $transient_key = 'webdados_og_image_size_' . md5($image);
866
  $transient_val = get_transient($transient_key);
867
  if ($transient_val) {
888
  }
889
  if ( !$done_partial && !$tried_full ) {
890
  //Try again with the whole image - In case of Warning
891
+ if ( $data = $this->get_open_graph_image_size_curl($image, null) ) {
892
+ $im = @imagecreatefromstring($data);
893
+ } else {
894
+ //No way...
895
+ $im = false;
896
+ }
897
  }
898
  if ( $im ) {
899
  if ( $x=imagesx($im) ) {
1024
  $filesize = $header['Content-Length'];
1025
  $url = $fb_image;
1026
  }
1027
+ if ( intval($this->options['fb_adv_disable_image_size'])==0 ) {
1028
+ if ( list( $width, $height, $type, $attr ) = $this->get_open_graph_image_size( $url ) ) {
1029
+ echo '<enclosure url="' . $fb_image . '" length="' . $filesize . '" type="'.image_type_to_mime_type($type).'"/>';
1030
+ echo '<media:content url="'.$fb_image.'" width="'.$width.'" height="'.$height.'" medium="image" type="'.image_type_to_mime_type($type).'"/>';
1031
+ } else {
1032
+ echo '<enclosure url="' . $fb_image . '" length="' . $filesize . '" type="'.image_type_to_mime_type(null).'"/>';
1033
+ echo '<media:content url="'.$fb_image.'" width="" height="" medium="image" type="'.image_type_to_mime_type(null).'"/>';
1034
+ }
1035
+ } else {
1036
+ echo '<enclosure url="' . $fb_image . '" length="' . $filesize . '" type="'.image_type_to_mime_type(null).'"/>';
1037
+ echo '<media:content url="'.$fb_image.'" width="" height="" medium="image" type="'.image_type_to_mime_type(null).'"/>';
1038
+ }
1039
  }
1040
  }
1041
  }
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.7.3
7
- Stable tag: 2.0.8.2
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 ==
@@ -97,13 +97,14 @@ We like to work with everybody, so (if you want to) our plugin can even integrat
97
 
98
  1. Are you using a big enough image? The minimum image size is 200x200 pixels but we recommend 1200x630.
99
  2. Are you sure you only have one `og:image` tag on the source code? Make sure you're not using more than one plugin to set OG tags?
100
- 3. Go to the [Facebook URL Debugger](https://developers.facebook.com/tools/debug/), insert your URL, click `Debug`. Then click on `Scrape again` to make sure Facebook gets the current version of your HTML code and not a cached version. If the image that shows up on the preview (bottom of the page) is the correct one, then the tags are well set and it "should" be the one that Facebook uses when sharing the post. If it still does not use the correct image when sharing, despite the debugger shows it correctly, there's nothing more we can do about that. That's just Facebook being Facebook.
101
 
102
  = When I save/edit my post I get the "Facebook Open Graph Tags cache NOT updated/purged" error. Should I worry? =
103
 
104
  Each time you edit a post, if the option "Try to update Facebook Open Graph Tags cache when saving the post" is activated, we'll try to notify Facebook of the changes so it clears up it's cache and read the new Open Graph tags of this specific URL.
105
  If this is a new post and it's the first time you're saving it, the error is "normal" and you should ignore it (wer're looking at a workaround to not show you this error).
106
- If this is not a new post and it's not the first time you're saving it, and if this happens always, then maybe your server does not support calling remote URLs with PHP and you should disable the "Try to update Facebook Open Graph Tags cache when saving the post" option. In that scenario we recommend you to use the [Facebook URL Debugger](https://developers.facebook.com/tools/debug/) to `Fetch new scrape information` each time you update your post.
 
107
 
108
  = Can this plugin get content from "random plugin"? =
109
 
@@ -121,6 +122,10 @@ We DO NOT provide email support for this plugin. If you send us an email asking
121
 
122
  == Changelog ==
123
 
 
 
 
 
124
  = 2.0.8.2 =
125
  * New `fb_og_output` filter on the plugin global output
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.7.3
7
+ Stable tag: 2.0.9
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 ==
97
 
98
  1. Are you using a big enough image? The minimum image size is 200x200 pixels but we recommend 1200x630.
99
  2. Are you sure you only have one `og:image` tag on the source code? Make sure you're not using more than one plugin to set OG tags?
100
+ 3. Go to the [Facebook Sharing Debugger](https://developers.facebook.com/tools/debug/), insert your URL, click `Debug`. Then click on `Scrape again` to make sure Facebook gets the current version of your HTML code and not a cached version. If the image that shows up on the preview (bottom of the page) is the correct one, then the tags are well set and it "should" be the one that Facebook uses when sharing the post. If it still does not use the correct image when sharing, despite the debugger shows it correctly, there's nothing more we can do about that. That's just Facebook being Facebook.
101
 
102
  = When I save/edit my post I get the "Facebook Open Graph Tags cache NOT updated/purged" error. Should I worry? =
103
 
104
  Each time you edit a post, if the option "Try to update Facebook Open Graph Tags cache when saving the post" is activated, we'll try to notify Facebook of the changes so it clears up it's cache and read the new Open Graph tags of this specific URL.
105
  If this is a new post and it's the first time you're saving it, the error is "normal" and you should ignore it (wer're looking at a workaround to not show you this error).
106
+ If this is not a new post and it's not the first time you're saving it, and if this happens always, then maybe your server does not support calling remote URLs with PHP and you should disable the "Try to update Facebook Open Graph Tags cache when saving the post" option. In that scenario we recommend you to use the [Facebook Sharing Debugger](https://developers.facebook.com/tools/debug/) to `Fetch new scrape information` each time you update your post.
107
+ Sometimes the plugin just can't update the Facebook cache itself and you may need to do it manually on the link provided above.
108
 
109
  = Can this plugin get content from "random plugin"? =
110
 
122
 
123
  == Changelog ==
124
 
125
+ = 2.0.9 =
126
+ * New option to disable getting the image size and possibly avoid fatal errors (white screen of death) on some edge cases
127
+ * New `fb_og_disable` filter to completely disable the output based on the developer own rules
128
+
129
  = 2.0.8.2 =
130
  * New `fb_og_output` filter on the plugin global output
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.8.2
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.8.2
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.8.2' );
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.9
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.9
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.9' );
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 );