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

Version Description

  • New "Tools" panel on the settings page
  • Tool to clear all the plugin transients, thus resetting size caching for all images (use it only )
  • Small bug fix when the settings aren't yet saved at least one time
  • When getting the image size, the full image is used again, instead of the partial 32Kb (that caused WSOD in some environments), but this can be overridden (and use the partial again) by returning false to the new fb_og_image_size_use_partial filter
  • Transient validity is now one week (now that we get the all image and the process can slow down the page load a bit), instead of one day
  • Fix when getting the image and description for the blog url when it's set as a page (Thanks @alexiswilke)
  • Ability to disable image size cache (transients) completely by returning false to the new filter fb_og_image_size_cache (which we do NOT recommend)
  • Improved the FAQ
Download this release

Release Info

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

Code changes from version 2.1.6.3 to 2.2

admin/class-webdados-fb-open-graph-admin.php CHANGED
@@ -30,6 +30,8 @@ class Webdados_FB_Admin {
30
  $options_page = add_options_page( WEBDADOS_FB_PLUGIN_NAME, WEBDADOS_FB_PLUGIN_NAME, 'manage_options', basename(__FILE__), array( $this, 'options_page' ) );
31
  add_action( 'admin_print_styles-' . $options_page, array( $this, 'admin_style' ) );
32
  add_action( 'admin_print_scripts-' . $options_page, array( $this, 'admin_scripts' ) );
 
 
33
  }
34
 
35
  /* Register settings and sanitization */
@@ -88,6 +90,14 @@ class Webdados_FB_Admin {
88
  return array_diff( $public_types, $exclude_types );
89
  }
90
 
 
 
 
 
 
 
 
 
91
  /* Meta boxes on posts */
92
  public function add_meta_boxes( $usercontacts ) {
93
  global $post;
@@ -409,6 +419,7 @@ class Webdados_FB_Admin {
409
  wp_localize_script( 'webdados_fb_admin_script', 'texts', array(
410
  'select_image' => __('Select image', 'wonderm00ns-simple-facebook-open-graph-tags'),
411
  'use_this_image' => __('Use this image', 'wonderm00ns-simple-facebook-open-graph-tags'),
 
412
  ) );
413
  }
414
 
@@ -440,4 +451,30 @@ class Webdados_FB_Admin {
440
  return $options;
441
  }
442
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  }
30
  $options_page = add_options_page( WEBDADOS_FB_PLUGIN_NAME, WEBDADOS_FB_PLUGIN_NAME, 'manage_options', basename(__FILE__), array( $this, 'options_page' ) );
31
  add_action( 'admin_print_styles-' . $options_page, array( $this, 'admin_style' ) );
32
  add_action( 'admin_print_scripts-' . $options_page, array( $this, 'admin_scripts' ) );
33
+ add_filter( 'pre_update_option_wonderm00n_open_graph_settings', array( $this, 'run_tools' ) );
34
+ add_action( 'admin_notices', array( $this, 'admin_notice' ) );
35
  }
36
 
37
  /* Register settings and sanitization */
90
  return array_diff( $public_types, $exclude_types );
91
  }
92
 
93
+ /* Admin notices */
94
+ public function admin_notice() {
95
+ if ( $admin_notice = get_option( 'wonderm00n_open_graph_admin_notice' ) ) {
96
+ echo $admin_notice;
97
+ update_option( 'wonderm00n_open_graph_admin_notice', '' );
98
+ }
99
+ }
100
+
101
  /* Meta boxes on posts */
102
  public function add_meta_boxes( $usercontacts ) {
103
  global $post;
419
  wp_localize_script( 'webdados_fb_admin_script', 'texts', array(
420
  'select_image' => __('Select image', 'wonderm00ns-simple-facebook-open-graph-tags'),
421
  'use_this_image' => __('Use this image', 'wonderm00ns-simple-facebook-open-graph-tags'),
422
+ 'confirm_tool' => __('Are you sure you want to run this tool?', 'wonderm00ns-simple-facebook-open-graph-tags'),
423
  ) );
424
  }
425
 
451
  return $options;
452
  }
453
 
454
+ /* Run tools */
455
+ public function run_tools( $value ) {
456
+ if ( is_array( $_POST['tools'] ) ) {
457
+ foreach ( $_POST['tools'] as $tool ) {
458
+ $function = 'run_tool_'.$tool;
459
+ $this->$function();
460
+ }
461
+ }
462
+ return $value;
463
+ }
464
+ public function run_tool_clear_transients() {
465
+ global $wpdb;
466
+ $records = 0;
467
+ $sql = "DELETE FROM $wpdb->options WHERE option_name LIKE '%webdados_og_image_size_%'";
468
+ $clean = $wpdb -> query( $sql );
469
+ $records .= $clean;
470
+ // If multisite, and the main network, also clear the sitemeta table
471
+ if ( is_multisite() && is_main_network() ) {
472
+ $sql = "DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE '%webdados_og_image_size_%'";
473
+ $clean = $wpdb -> query( $sql );
474
+ $records .= $clean;
475
+ }
476
+ $admin_notice_message = '<div class="updated notice is-dismissible"><p>'.sprintf( __( '%d transients deleted', 'wonderm00ns-simple-facebook-open-graph-tags' ), intval($records/2) ).'</p></div>';
477
+ update_option( 'wonderm00n_open_graph_admin_notice', $admin_notice_message );
478
+ }
479
+
480
  }
admin/js/webdados-fb-open-graph-admin.js CHANGED
@@ -60,6 +60,13 @@
60
  showYoastSEOOptions();
61
  showSubheadingOptions();
62
 
 
 
 
 
 
 
 
63
  //Functions
64
  function showDescriptionCustomText(focus) {
65
  if ($('#fb_desc_homepage').val()=='custom') {
60
  showYoastSEOOptions();
61
  showSubheadingOptions();
62
 
63
+ //Tools
64
+ $('.fb-og-tool').on('click', function(event) {
65
+ if ( !confirm(texts.confirm_tool) ) {
66
+ event.preventDefault();
67
+ }
68
+ });
69
+
70
  //Functions
71
  function showDescriptionCustomText(focus) {
72
  if ($('#fb_desc_homepage').val()=='custom') {
admin/options-page-general.php CHANGED
@@ -176,8 +176,6 @@ global $webdados_fb;
176
  <?php if ( extension_loaded('gd') ) { ?>
177
  <tr>
178
  <td colspan="2" class="info">
179
- - <?php _e('Experimental', 'wonderm00ns-simple-facebook-open-graph-tags'); ?>
180
- <br/>
181
  - <?php printf( __( 'The original image will be resized/cropped to %dx%dpx and the chosen PNG (that should also have this size) will be overlaid on it. It will only work for locally hosted images.', 'wonderm00ns-simple-facebook-open-graph-tags' ), WEBDADOS_FB_W, WEBDADOS_FB_H);?>
182
  <br/>
183
  - <?php printf( __( 'You can see an example of the end result <a href="%s" target="_blank">here</a>', '' ), 'https://www.flickr.com/photos/wonderm00n/29890263040/in/dateposted-public/' ); ?>
@@ -244,12 +242,12 @@ global $webdados_fb;
244
  </tr>
245
  <tr>
246
  <td colspan="2" class="info">
247
- - <?php _e('Experimental', 'wonderm00ns-simple-facebook-open-graph-tags'); ?>
248
- <br/>
249
  - <strong><?php _e( 'This is an advanced option: Don\'t mess with this unless you know what you\'re doing', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?></strong>
250
  <br/>
251
  - <?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', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>
252
  <br/>
 
 
253
  - <?php _e( 'This can render the "Add image to RSS/RSS2 feeds" and "Open Graph - Include Image Dimensions" options useless', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>
254
  </td>
255
  </tr>
176
  <?php if ( extension_loaded('gd') ) { ?>
177
  <tr>
178
  <td colspan="2" class="info">
 
 
179
  - <?php printf( __( 'The original image will be resized/cropped to %dx%dpx and the chosen PNG (that should also have this size) will be overlaid on it. It will only work for locally hosted images.', 'wonderm00ns-simple-facebook-open-graph-tags' ), WEBDADOS_FB_W, WEBDADOS_FB_H);?>
180
  <br/>
181
  - <?php printf( __( 'You can see an example of the end result <a href="%s" target="_blank">here</a>', '' ), 'https://www.flickr.com/photos/wonderm00n/29890263040/in/dateposted-public/' ); ?>
242
  </tr>
243
  <tr>
244
  <td colspan="2" class="info">
 
 
245
  - <strong><?php _e( 'This is an advanced option: Don\'t mess with this unless you know what you\'re doing', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?></strong>
246
  <br/>
247
  - <?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', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>
248
  <br/>
249
+ - <?php _e( 'Should not be needed on version 2.2 and above', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>
250
+ <br/>
251
  - <?php _e( 'This can render the "Add image to RSS/RSS2 feeds" and "Open Graph - Include Image Dimensions" options useless', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>
252
  </td>
253
  </tr>
admin/options-page-tools.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 2.1.2
5
+ */
6
+
7
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
+
9
+ ?>
10
+ <div class="menu_containt_div" id="tabs-7">
11
+ <p><?php _e( 'Just some random tools', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?></p>
12
+ <div class="postbox">
13
+ <h3 class="hndle"><i class="dashicons-before dashicons-format-image"></i> <?php _e( 'Image tools', 'wonderm00ns-simple-facebook-open-graph-tags' ) ?></h3>
14
+ <div class="inside">
15
+ <table class="form-table">
16
+ <tbody>
17
+
18
+ <tr>
19
+ <th><?php _e( 'Clear all transients', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>:</th>
20
+ <td>
21
+ <input type="checkbox" name="tools[]" value="clear_transients"/>
22
+ <!-- This is not a good idea because the page will always keep the run_tool variable -->
23
+ <!--<a href="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>&amp;run_tool=clear_transients" class="button fb-og-tool"><?php _e( 'Do it', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?></a>-->
24
+ </td>
25
+ </tr>
26
+ <tr>
27
+ <td colspan="2" class="info">
28
+ - <strong><?php _e( 'This is an advanced tool: Don\'t mess with this unless you know what you\'re doing', 'wonderm00ns-simple-facebook-open-graph-tags' ); ?></strong>
29
+ <br/>
30
+ - <?php _e( 'We use transients to cache the image sizes, so that we only have to calculate them once (a week). Because of some server issues it may happen that we cannot correctly get the image size and we\'ll cache that, meaning that we\'ll never try it again (for a week). This tool will delete ALL the transients and force the image size calculation to be done again for all images, as they\'re nedded.' , 'wonderm00ns-simple-facebook-open-graph-tags' ); ?>
31
+ </td>
32
+ </tr>
33
+
34
+
35
+
36
+ </tbody>
37
+ </table>
38
+ </div>
39
+ </div>
40
+ </div>
admin/options-page.php CHANGED
@@ -65,6 +65,12 @@ $out_link_utm='?utm_source='.urlencode(home_url()).'&amp;utm_medium=link&amp;utm
65
  <?php _e( '3rd party', 'wonderm00ns-simple-facebook-open-graph-tags' ) ?>
66
  </a>
67
  </li>
 
 
 
 
 
 
68
  </ul>
69
  </h2>
70
 
@@ -90,6 +96,9 @@ $out_link_utm='?utm_source='.urlencode(home_url()).'&amp;utm_medium=link&amp;utm
90
 
91
  <!-- 3rd party integrations -->
92
  <?php include 'options-page-3rdparty.php'; ?>
 
 
 
93
 
94
  <div class="clear"></div>
95
  <?php submit_button(); ?>
65
  <?php _e( '3rd party', 'wonderm00ns-simple-facebook-open-graph-tags' ) ?>
66
  </a>
67
  </li>
68
+ <li>
69
+ <a class="nav-tab" href="#tabs-7" data-tab-index="6">
70
+ <i class="dashicons-before dashicons-admin-tools"></i>
71
+ <?php _e( 'Tools', 'wonderm00ns-simple-facebook-open-graph-tags' ) ?>
72
+ </a>
73
+ </li>
74
  </ul>
75
  </h2>
76
 
96
 
97
  <!-- 3rd party integrations -->
98
  <?php include 'options-page-3rdparty.php'; ?>
99
+
100
+ <!-- Tools -->
101
+ <?php include 'options-page-tools.php'; ?>
102
 
103
  <div class="clear"></div>
104
  <?php submit_button(); ?>
includes/class-webdados-fb-open-graph.php CHANGED
@@ -166,6 +166,7 @@ class Webdados_FB {
166
  /* Load Options */
167
  private function load_options() {
168
  $user_options = get_option( 'wonderm00n_open_graph_settings' );
 
169
  $all_options = $this->all_options();
170
  $default_options = $this->default_options();
171
  if ( is_array( $all_options ) ) {
166
  /* Load Options */
167
  private function load_options() {
168
  $user_options = get_option( 'wonderm00n_open_graph_settings' );
169
+ if ( !is_array($user_options) ) $user_options = array();
170
  $all_options = $this->all_options();
171
  $default_options = $this->default_options();
172
  if ( is_array( $all_options ) ) {
lang/wonderm00ns-simple-facebook-open-graph-tags.pot CHANGED
@@ -4,7 +4,7 @@ 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-12-23 17:11+0000\n"
8
  "PO-Revision-Date: 2016-09-26 14:52+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: \n"
@@ -21,122 +21,131 @@ msgstr ""
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
- #: admin/class-webdados-fb-open-graph-admin.php:52
25
  msgid "Settings"
26
  msgstr ""
27
 
28
- #: admin/class-webdados-fb-open-graph-admin.php:63
29
  msgid "Google+"
30
  msgstr ""
31
 
32
- #: admin/class-webdados-fb-open-graph-admin.php:65
33
  #: admin/options-page-twitter.php:110
34
  msgid "Twitter username (without @)"
35
  msgstr ""
36
 
37
- #: admin/class-webdados-fb-open-graph-admin.php:67
38
  msgid "Facebook profile URL"
39
  msgstr ""
40
 
41
- #: admin/class-webdados-fb-open-graph-admin.php:115
42
- #: admin/class-webdados-fb-open-graph-admin.php:140
43
- #: admin/class-webdados-fb-open-graph-admin.php:408
44
  msgid "Use this image"
45
  msgstr ""
46
 
47
- #: admin/class-webdados-fb-open-graph-admin.php:120
48
- #: admin/options-page-general.php:121 admin/options-page-general.php:193
49
  msgid "Upload/Choose"
50
  msgstr ""
51
 
52
- #: admin/class-webdados-fb-open-graph-admin.php:121
53
  msgid "Clear field"
54
  msgstr ""
55
 
56
- #: admin/class-webdados-fb-open-graph-admin.php:123
57
  #: admin/options-page-general.php:128
58
  #, php-format
59
  msgid "Recommended size: %dx%dpx"
60
  msgstr ""
61
 
62
- #: admin/class-webdados-fb-open-graph-admin.php:139
63
- #: admin/class-webdados-fb-open-graph-admin.php:407
64
  msgid "Select image"
65
  msgstr ""
66
 
67
- #: admin/class-webdados-fb-open-graph-admin.php:171
68
  msgid "Use this description"
69
  msgstr ""
70
 
71
- #: admin/class-webdados-fb-open-graph-admin.php:177
72
  msgid "The Yoast SEO integration is active, so it's description will be used"
73
  msgstr ""
74
 
75
- #: admin/class-webdados-fb-open-graph-admin.php:183
76
  msgid ""
77
  "If this field is not filled, the description will be generated from the "
78
  "excerpt, if it exists, or from the content"
79
  msgstr ""
80
 
81
- #: admin/class-webdados-fb-open-graph-admin.php:261
82
  msgid "URL failed:"
83
  msgstr ""
84
 
85
- #: admin/class-webdados-fb-open-graph-admin.php:273
86
  msgid "Facebook returned:"
87
  msgstr ""
88
 
89
- #: admin/class-webdados-fb-open-graph-admin.php:276
90
  msgid "Unknown error"
91
  msgstr ""
92
 
93
- #: admin/class-webdados-fb-open-graph-admin.php:305
94
  msgid "Facebook Open Graph Tags cache updated/purged."
95
  msgstr ""
96
 
97
- #: admin/class-webdados-fb-open-graph-admin.php:305
98
- #: admin/class-webdados-fb-open-graph-admin.php:382
99
  msgid "Share this on Facebook"
100
  msgstr ""
101
 
102
- #: admin/class-webdados-fb-open-graph-admin.php:315
103
  msgid "Error: Facebook Open Graph Tags cache NOT updated/purged."
104
  msgstr ""
105
 
106
- #: admin/class-webdados-fb-open-graph-admin.php:320
107
  msgid "This is NOT a plugin error."
108
  msgstr ""
109
 
110
- #: admin/class-webdados-fb-open-graph-admin.php:323
111
  msgid "Do not open support tickets about this issue."
112
  msgstr ""
113
 
114
- #: admin/class-webdados-fb-open-graph-admin.php:324
115
  msgid ""
116
  "Lately and unfortunately, Facebook is not allowing to update the cache "
117
  "programmatically."
118
  msgstr ""
119
 
120
- #: admin/class-webdados-fb-open-graph-admin.php:326
121
  msgid ""
122
  "Have you already configured the App ID and App Secret, needed for flushing "
123
  "the cache on Facebook?"
124
  msgstr ""
125
 
126
- #: admin/class-webdados-fb-open-graph-admin.php:327
127
  msgid ""
128
  "If you haven't, go to the settings page (Open Graph tab), and do it now."
129
  msgstr ""
130
 
131
- #: admin/class-webdados-fb-open-graph-admin.php:331
132
  msgid ""
133
  "Click here to try to clear the cache manually and then click \"Scrape Again\""
134
  msgstr ""
135
 
136
- #: admin/class-webdados-fb-open-graph-admin.php:381
137
  msgid "Manually update Facebook cache"
138
  msgstr ""
139
 
 
 
 
 
 
 
 
 
 
140
  #: admin/options-page-3rdparty.php:13
141
  msgid "Settings for 3rd party integration with other plugins."
142
  msgstr ""
@@ -597,7 +606,7 @@ msgstr ""
597
  msgid "Default image"
598
  msgstr ""
599
 
600
- #: admin/options-page-general.php:126 admin/options-page-general.php:198
601
  msgid "URL (with http(s)://)"
602
  msgstr ""
603
 
@@ -636,12 +645,7 @@ msgstr ""
636
  msgid "No"
637
  msgstr ""
638
 
639
- #: admin/options-page-general.php:179 admin/options-page-general.php:247
640
- #: admin/options-page-schema.php:70
641
- msgid "Experimental"
642
- msgstr ""
643
-
644
- #: admin/options-page-general.php:181
645
  #, php-format
646
  msgid ""
647
  "The original image will be resized/cropped to %dx%dpx and the chosen PNG "
@@ -649,118 +653,122 @@ msgid ""
649
  "for locally hosted images."
650
  msgstr ""
651
 
652
- #: admin/options-page-general.php:183
653
  #, php-format
654
  msgid ""
655
  "You can see an example of the end result <a href=\"%s\" target=\"_blank"
656
  "\">here</a>"
657
  msgstr ""
658
 
659
- #: admin/options-page-general.php:185
660
  #, php-format
661
  msgid ""
662
  "If you activate this option globally, you can disable it based on your "
663
  "conditions using the <i>%1$s</i> filter"
664
  msgstr ""
665
 
666
- #: admin/options-page-general.php:190
667
  msgid "PNG logo"
668
  msgstr ""
669
 
670
- #: admin/options-page-general.php:200
671
  #, php-format
672
  msgid "Size: %dx%dpx"
673
  msgstr ""
674
 
675
- #: admin/options-page-general.php:206
676
  #, php-format
677
  msgid ""
678
  "You need the <a href=\"%s\" target=\"_blank\">PHP GD library</a> to use this "
679
  "feature. Please ask your hosting company to enable it."
680
  msgstr ""
681
 
682
- #: admin/options-page-general.php:212
683
  msgid "Add image to RSS/RSS2 feeds"
684
  msgstr ""
685
 
686
- #: admin/options-page-general.php:219
687
  msgid "For auto-posting apps like RSS Graffiti, twitterfeed, ..."
688
  msgstr ""
689
 
690
- #: admin/options-page-general.php:224
691
  msgid "Force getimagesize on local file"
692
  msgstr ""
693
 
694
- #: admin/options-page-general.php:231 admin/options-page-general.php:249
695
  msgid ""
696
  "This is an advanced option: Don't mess with this unless you know what you're "
697
  "doing"
698
  msgstr ""
699
 
700
- #: admin/options-page-general.php:233
701
  msgid "Force getimagesize on local file even if allow_url_fopen=1"
702
  msgstr ""
703
 
704
- #: admin/options-page-general.php:235
705
  msgid ""
706
  "May cause problems with some multisite configurations but fixes \"HTTP "
707
  "request failed\" errors"
708
  msgstr ""
709
 
710
- #: admin/options-page-general.php:240
711
  msgid "Do not get image size"
712
  msgstr ""
713
 
714
- #: admin/options-page-general.php:251
715
  msgid ""
716
  "You should only activate this option if you're getting fatal errors (white "
717
  "screen of death) and only keep it active if this options does solve those "
718
  "errors"
719
  msgstr ""
720
 
721
- #: admin/options-page-general.php:253
 
 
 
 
722
  msgid ""
723
  "This can render the \"Add image to RSS/RSS2 feeds\" and \"Open Graph - "
724
  "Include Image Dimensions\" options useless"
725
  msgstr ""
726
 
727
- #: admin/options-page-general.php:264
728
  msgid "URL settings"
729
  msgstr ""
730
 
731
- #: admin/options-page-general.php:270
732
  msgid "Add trailing slash at the end"
733
  msgstr ""
734
 
735
- #: admin/options-page-general.php:277
736
  msgid "If missing, a trailing slash will be added at the end"
737
  msgstr ""
738
 
739
- #: admin/options-page-general.php:279
740
  msgid "Homepage example:"
741
  msgstr ""
742
 
743
- #: admin/options-page-general.php:288
744
  msgid "Author settings"
745
  msgstr ""
746
 
747
- #: admin/options-page-general.php:294
748
  msgid "Hide Author on Pages"
749
  msgstr ""
750
 
751
- #: admin/options-page-general.php:301
752
  msgid "Hides all Author tags on Pages"
753
  msgstr ""
754
 
755
- #: admin/options-page-general.php:310
756
  msgid "Other settings"
757
  msgstr ""
758
 
759
- #: admin/options-page-general.php:316
760
  msgid "Keep data on uninstall"
761
  msgstr ""
762
 
763
- #: admin/options-page-general.php:323
764
  msgid ""
765
  "Keep the plugin settings on the database even if the plugin is uninstalled"
766
  msgstr ""
@@ -856,6 +864,10 @@ msgstr ""
856
  msgid "Include Title"
857
  msgstr ""
858
 
 
 
 
 
859
  #: admin/options-page-schema.php:72
860
  msgid ""
861
  "Added to the HTML tag, if you want to avoid W3C and Structured Data "
@@ -916,6 +928,38 @@ msgstr ""
916
  msgid "From the user Display name"
917
  msgstr ""
918
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
919
  #: admin/options-page-twitter.php:11
920
  msgid "Tags used by Twitter to render their Cards."
921
  msgstr ""
@@ -983,17 +1027,21 @@ msgstr ""
983
  msgid "3rd party"
984
  msgstr ""
985
 
986
- #: public/class-webdados-fb-open-graph-public.php:220
 
 
 
 
987
  msgid "Price"
988
  msgstr ""
989
 
990
- #: public/class-webdados-fb-open-graph-public.php:300
991
  msgid "Search for"
992
  msgstr ""
993
 
994
- #: public/class-webdados-fb-open-graph-public.php:309
995
- #: public/class-webdados-fb-open-graph-public.php:313
996
- #: public/class-webdados-fb-open-graph-public.php:317
997
  msgid "Archives"
998
  msgstr ""
999
 
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-12-29 13:59+0000\n"
8
  "PO-Revision-Date: 2016-09-26 14:52+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: \n"
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
+ #: admin/class-webdados-fb-open-graph-admin.php:55
25
  msgid "Settings"
26
  msgstr ""
27
 
28
+ #: admin/class-webdados-fb-open-graph-admin.php:66
29
  msgid "Google+"
30
  msgstr ""
31
 
32
+ #: admin/class-webdados-fb-open-graph-admin.php:68
33
  #: admin/options-page-twitter.php:110
34
  msgid "Twitter username (without @)"
35
  msgstr ""
36
 
37
+ #: admin/class-webdados-fb-open-graph-admin.php:70
38
  msgid "Facebook profile URL"
39
  msgstr ""
40
 
41
+ #: admin/class-webdados-fb-open-graph-admin.php:126
42
+ #: admin/class-webdados-fb-open-graph-admin.php:151
43
+ #: admin/class-webdados-fb-open-graph-admin.php:421
44
  msgid "Use this image"
45
  msgstr ""
46
 
47
+ #: admin/class-webdados-fb-open-graph-admin.php:131
48
+ #: admin/options-page-general.php:121 admin/options-page-general.php:191
49
  msgid "Upload/Choose"
50
  msgstr ""
51
 
52
+ #: admin/class-webdados-fb-open-graph-admin.php:132
53
  msgid "Clear field"
54
  msgstr ""
55
 
56
+ #: admin/class-webdados-fb-open-graph-admin.php:134
57
  #: admin/options-page-general.php:128
58
  #, php-format
59
  msgid "Recommended size: %dx%dpx"
60
  msgstr ""
61
 
62
+ #: admin/class-webdados-fb-open-graph-admin.php:150
63
+ #: admin/class-webdados-fb-open-graph-admin.php:420
64
  msgid "Select image"
65
  msgstr ""
66
 
67
+ #: admin/class-webdados-fb-open-graph-admin.php:182
68
  msgid "Use this description"
69
  msgstr ""
70
 
71
+ #: admin/class-webdados-fb-open-graph-admin.php:188
72
  msgid "The Yoast SEO integration is active, so it's description will be used"
73
  msgstr ""
74
 
75
+ #: admin/class-webdados-fb-open-graph-admin.php:194
76
  msgid ""
77
  "If this field is not filled, the description will be generated from the "
78
  "excerpt, if it exists, or from the content"
79
  msgstr ""
80
 
81
+ #: admin/class-webdados-fb-open-graph-admin.php:272
82
  msgid "URL failed:"
83
  msgstr ""
84
 
85
+ #: admin/class-webdados-fb-open-graph-admin.php:284
86
  msgid "Facebook returned:"
87
  msgstr ""
88
 
89
+ #: admin/class-webdados-fb-open-graph-admin.php:287
90
  msgid "Unknown error"
91
  msgstr ""
92
 
93
+ #: admin/class-webdados-fb-open-graph-admin.php:317
94
  msgid "Facebook Open Graph Tags cache updated/purged."
95
  msgstr ""
96
 
97
+ #: admin/class-webdados-fb-open-graph-admin.php:317
98
+ #: admin/class-webdados-fb-open-graph-admin.php:395
99
  msgid "Share this on Facebook"
100
  msgstr ""
101
 
102
+ #: admin/class-webdados-fb-open-graph-admin.php:327
103
  msgid "Error: Facebook Open Graph Tags cache NOT updated/purged."
104
  msgstr ""
105
 
106
+ #: admin/class-webdados-fb-open-graph-admin.php:332
107
  msgid "This is NOT a plugin error."
108
  msgstr ""
109
 
110
+ #: admin/class-webdados-fb-open-graph-admin.php:335
111
  msgid "Do not open support tickets about this issue."
112
  msgstr ""
113
 
114
+ #: admin/class-webdados-fb-open-graph-admin.php:336
115
  msgid ""
116
  "Lately and unfortunately, Facebook is not allowing to update the cache "
117
  "programmatically."
118
  msgstr ""
119
 
120
+ #: admin/class-webdados-fb-open-graph-admin.php:338
121
  msgid ""
122
  "Have you already configured the App ID and App Secret, needed for flushing "
123
  "the cache on Facebook?"
124
  msgstr ""
125
 
126
+ #: admin/class-webdados-fb-open-graph-admin.php:339
127
  msgid ""
128
  "If you haven't, go to the settings page (Open Graph tab), and do it now."
129
  msgstr ""
130
 
131
+ #: admin/class-webdados-fb-open-graph-admin.php:343
132
  msgid ""
133
  "Click here to try to clear the cache manually and then click \"Scrape Again\""
134
  msgstr ""
135
 
136
+ #: admin/class-webdados-fb-open-graph-admin.php:394
137
  msgid "Manually update Facebook cache"
138
  msgstr ""
139
 
140
+ #: admin/class-webdados-fb-open-graph-admin.php:422
141
+ msgid "Are you sure you want to run this tool?"
142
+ msgstr ""
143
+
144
+ #: admin/class-webdados-fb-open-graph-admin.php:476
145
+ #, php-format
146
+ msgid "%d transients deleted"
147
+ msgstr ""
148
+
149
  #: admin/options-page-3rdparty.php:13
150
  msgid "Settings for 3rd party integration with other plugins."
151
  msgstr ""
606
  msgid "Default image"
607
  msgstr ""
608
 
609
+ #: admin/options-page-general.php:126 admin/options-page-general.php:196
610
  msgid "URL (with http(s)://)"
611
  msgstr ""
612
 
645
  msgid "No"
646
  msgstr ""
647
 
648
+ #: admin/options-page-general.php:179
 
 
 
 
 
649
  #, php-format
650
  msgid ""
651
  "The original image will be resized/cropped to %dx%dpx and the chosen PNG "
653
  "for locally hosted images."
654
  msgstr ""
655
 
656
+ #: admin/options-page-general.php:181
657
  #, php-format
658
  msgid ""
659
  "You can see an example of the end result <a href=\"%s\" target=\"_blank"
660
  "\">here</a>"
661
  msgstr ""
662
 
663
+ #: admin/options-page-general.php:183
664
  #, php-format
665
  msgid ""
666
  "If you activate this option globally, you can disable it based on your "
667
  "conditions using the <i>%1$s</i> filter"
668
  msgstr ""
669
 
670
+ #: admin/options-page-general.php:188
671
  msgid "PNG logo"
672
  msgstr ""
673
 
674
+ #: admin/options-page-general.php:198
675
  #, php-format
676
  msgid "Size: %dx%dpx"
677
  msgstr ""
678
 
679
+ #: admin/options-page-general.php:204
680
  #, php-format
681
  msgid ""
682
  "You need the <a href=\"%s\" target=\"_blank\">PHP GD library</a> to use this "
683
  "feature. Please ask your hosting company to enable it."
684
  msgstr ""
685
 
686
+ #: admin/options-page-general.php:210
687
  msgid "Add image to RSS/RSS2 feeds"
688
  msgstr ""
689
 
690
+ #: admin/options-page-general.php:217
691
  msgid "For auto-posting apps like RSS Graffiti, twitterfeed, ..."
692
  msgstr ""
693
 
694
+ #: admin/options-page-general.php:222
695
  msgid "Force getimagesize on local file"
696
  msgstr ""
697
 
698
+ #: admin/options-page-general.php:229 admin/options-page-general.php:245
699
  msgid ""
700
  "This is an advanced option: Don't mess with this unless you know what you're "
701
  "doing"
702
  msgstr ""
703
 
704
+ #: admin/options-page-general.php:231
705
  msgid "Force getimagesize on local file even if allow_url_fopen=1"
706
  msgstr ""
707
 
708
+ #: admin/options-page-general.php:233
709
  msgid ""
710
  "May cause problems with some multisite configurations but fixes \"HTTP "
711
  "request failed\" errors"
712
  msgstr ""
713
 
714
+ #: admin/options-page-general.php:238
715
  msgid "Do not get image size"
716
  msgstr ""
717
 
718
+ #: admin/options-page-general.php:247
719
  msgid ""
720
  "You should only activate this option if you're getting fatal errors (white "
721
  "screen of death) and only keep it active if this options does solve those "
722
  "errors"
723
  msgstr ""
724
 
725
+ #: admin/options-page-general.php:249
726
+ msgid "Should not be needed on version 2.2 and above"
727
+ msgstr ""
728
+
729
+ #: admin/options-page-general.php:251
730
  msgid ""
731
  "This can render the \"Add image to RSS/RSS2 feeds\" and \"Open Graph - "
732
  "Include Image Dimensions\" options useless"
733
  msgstr ""
734
 
735
+ #: admin/options-page-general.php:262
736
  msgid "URL settings"
737
  msgstr ""
738
 
739
+ #: admin/options-page-general.php:268
740
  msgid "Add trailing slash at the end"
741
  msgstr ""
742
 
743
+ #: admin/options-page-general.php:275
744
  msgid "If missing, a trailing slash will be added at the end"
745
  msgstr ""
746
 
747
+ #: admin/options-page-general.php:277
748
  msgid "Homepage example:"
749
  msgstr ""
750
 
751
+ #: admin/options-page-general.php:286
752
  msgid "Author settings"
753
  msgstr ""
754
 
755
+ #: admin/options-page-general.php:292
756
  msgid "Hide Author on Pages"
757
  msgstr ""
758
 
759
+ #: admin/options-page-general.php:299
760
  msgid "Hides all Author tags on Pages"
761
  msgstr ""
762
 
763
+ #: admin/options-page-general.php:308
764
  msgid "Other settings"
765
  msgstr ""
766
 
767
+ #: admin/options-page-general.php:314
768
  msgid "Keep data on uninstall"
769
  msgstr ""
770
 
771
+ #: admin/options-page-general.php:321
772
  msgid ""
773
  "Keep the plugin settings on the database even if the plugin is uninstalled"
774
  msgstr ""
864
  msgid "Include Title"
865
  msgstr ""
866
 
867
+ #: admin/options-page-schema.php:70
868
+ msgid "Experimental"
869
+ msgstr ""
870
+
871
  #: admin/options-page-schema.php:72
872
  msgid ""
873
  "Added to the HTML tag, if you want to avoid W3C and Structured Data "
928
  msgid "From the user Display name"
929
  msgstr ""
930
 
931
+ #: admin/options-page-tools.php:11
932
+ msgid "Just some random tools"
933
+ msgstr ""
934
+
935
+ #: admin/options-page-tools.php:13
936
+ msgid "Image tools"
937
+ msgstr ""
938
+
939
+ #: admin/options-page-tools.php:19
940
+ msgid "Clear all transients"
941
+ msgstr ""
942
+
943
+ #: admin/options-page-tools.php:23
944
+ msgid "Do it"
945
+ msgstr ""
946
+
947
+ #: admin/options-page-tools.php:28
948
+ msgid ""
949
+ "This is an advanced tool: Don't mess with this unless you know what you're "
950
+ "doing"
951
+ msgstr ""
952
+
953
+ #: admin/options-page-tools.php:30
954
+ msgid ""
955
+ "We use transients to cache the image sizes, so that we only have to "
956
+ "calculate them once (a week). Because of some server issues it may happen "
957
+ "that we cannot correctly get the image size and we'll cache that, meaning "
958
+ "that we'll never try it again (for a week). This tool will delete ALL the "
959
+ "transients and force the image size calculation to be done again for all "
960
+ "images, as they're nedded."
961
+ msgstr ""
962
+
963
  #: admin/options-page-twitter.php:11
964
  msgid "Tags used by Twitter to render their Cards."
965
  msgstr ""
1027
  msgid "3rd party"
1028
  msgstr ""
1029
 
1030
+ #: admin/options-page.php:71
1031
+ msgid "Tools"
1032
+ msgstr ""
1033
+
1034
+ #: public/class-webdados-fb-open-graph-public.php:231
1035
  msgid "Price"
1036
  msgstr ""
1037
 
1038
+ #: public/class-webdados-fb-open-graph-public.php:311
1039
  msgid "Search for"
1040
  msgstr ""
1041
 
1042
+ #: public/class-webdados-fb-open-graph-public.php:320
1043
+ #: public/class-webdados-fb-open-graph-public.php:324
1044
+ #: public/class-webdados-fb-open-graph-public.php:328
1045
  msgid "Archives"
1046
  msgstr ""
1047
 
public/class-webdados-fb-open-graph-public.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
- * @version 2.1.6.3
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -22,6 +22,12 @@ class Webdados_FB_Public {
22
  /* BDP Post temporary holder */
23
  private $post = false;
24
 
 
 
 
 
 
 
25
 
26
 
27
  /* Construct */
@@ -54,6 +60,11 @@ class Webdados_FB_Public {
54
  ';
55
 
56
  if ( apply_filters('fb_og_enabled', true) ) {
 
 
 
 
 
57
 
58
  //Also set Title Tag? - Needed??
59
  $fb_set_title_tag=0;
@@ -97,7 +108,7 @@ class Webdados_FB_Public {
97
  break;
98
  }
99
 
100
- if ( is_singular() ) {
101
 
102
  global $post;
103
  // Title
@@ -320,24 +331,24 @@ class Webdados_FB_Public {
320
  }
321
  }
322
  } else {
323
- if ( is_front_page() ) {
324
  $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '');
325
  $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
326
  $fb_desc = $fb_desc_homepage;
327
  } else {
328
- if ( is_home() ) {
329
- global $post;
330
- if ( $post ) {
331
  //Blog page
332
  $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
333
- if ( $fb_desc = trim( get_post_meta($post->ID, '_webdados_fb_open_graph_specific_description', true) ) ) {
334
  //OK - From our metabox
335
  } else {
336
  //Use default
337
  $fb_desc = $fb_desc_homepage;
338
  }
339
  if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
340
- $fb_image = $this->get_post_image();
341
  }
342
  }
343
  } else {
@@ -695,67 +706,93 @@ class Webdados_FB_Public {
695
 
696
 
697
  /* Get post image - Singular pages */
698
- private function get_post_image() {
699
- global $post;
700
- $thumbdone = false;
701
- $fb_image = '';
702
- $minsize = intval($this->options['fb_image_min_size']);
703
- //Attachment page? - This overrides the other options
704
- if ( is_attachment() ) {
705
- if ( $temp=wp_get_attachment_image_src(null, 'full' ) ) {
706
- $fb_image = trim($temp[0]);
707
- $img_size = array(intval($temp[1]), intval($temp[2]));
708
- if ( trim($fb_image)!='' ) {
709
- $thumbdone=true;
710
- }
711
- }
712
  }
713
- //Specific post image
714
- if ( !$thumbdone ) {
715
- if ( intval($this->options['fb_image_use_specific'])==1 ) {
716
- if ( $fb_image = trim(get_post_meta($post->ID, '_webdados_fb_open_graph_specific_image', true)) ) {
 
 
 
 
 
717
  if ( trim($fb_image)!='' ) {
718
  $thumbdone=true;
719
  }
720
  }
721
  }
722
- }
723
- //Featured image
724
- if ( !$thumbdone ) {
725
- if ( function_exists('get_post_thumbnail_id' ) ) {
726
- if ( intval($this->options['fb_image_use_featured'])==1 ) {
727
- if ( $id_attachment=get_post_thumbnail_id($post->ID) ) {
728
- //There's a featured/thumbnail image for this post
729
- $fb_image = wp_get_attachment_url($id_attachment, false);
730
- $thumbdone = true;
731
  }
732
  }
733
  }
734
- }
735
- //From post/page content
736
- if ( !$thumbdone ) {
737
- if ( intval($this->options['fb_image_use_content'])==1 ) {
738
- $imgreg = '/<img .*src=["\']([^ ^"^\']*)["\']/';
739
- preg_match_all($imgreg, trim($post->post_content), $matches);
740
- if ($matches[1]) {
741
- $imagetemp=false;
742
- foreach($matches[1] as $image) {
743
- //There's an image on the content
744
- $pos = strpos($image, site_url());
745
- if ($pos === false) {
746
- if (stristr($image, 'http://' ) || stristr($image, 'https://' ) || mb_substr($image, 0, 2)=='//' ) {
747
- if (mb_substr($image, 0, 2)=='//' ) $image=((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https:' : 'http:' ).$image;
748
- //Complete URL - offsite
749
- //if ( intval(ini_get('allow_url_fopen' ))==1 ) {
750
- $imagetemp=$image;
751
- $imagetempsize=$imagetemp;
752
- //} else {
753
- //If it's offsite we can't getimagesize'it, so we won't use it
754
- //We could save a temporary version locally and then getimagesize'it but do we want to do this every single time?
755
- //}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
756
  } else {
757
- //Partial URL - we guess it's onsite because no http(s)://
758
- $imagetemp=site_url().$image;
759
  $imagetempsize=(
760
  intval(ini_get('allow_url_fopen' ))==1
761
  ?
@@ -770,10 +807,34 @@ class Webdados_FB_Public {
770
  ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
771
  );
772
  }
773
- } else {
774
- //Complete URL - onsite
775
- $imagetemp=$image;
776
- $imagetempsize=(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  intval(ini_get('allow_url_fopen' ))==1
778
  ?
779
  (
@@ -786,15 +847,13 @@ class Webdados_FB_Public {
786
  :
787
  ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
788
  );
789
- }
790
- if ($imagetemp) {
791
  if ( intval($this->options['fb_adv_disable_image_size'])==1 ) {
792
  //If we don't check for image size, we'll just accept the first one
793
  $fb_image = $imagetemp;
794
  $thumbdone = true;
795
  break; //Break the foreach
796
  } else {
797
- if ($img_size = $this->get_open_graph_image_size($imagetempsize)) {
798
  if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
799
  $fb_image = $imagetemp;
800
  $thumbdone = true;
@@ -806,58 +865,22 @@ class Webdados_FB_Public {
806
  }
807
  }
808
  }
809
- }
810
- //From media gallery
811
- if ( !$thumbdone ) {
812
- if ( intval($this->options['fb_image_use_media'])==1 ) {
813
- $images = get_posts(array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'order' => 'ASC','orderby' => 'menu_order','post_mime_type' => 'image','post_parent' => $post->ID));
814
- if ( $images ) {
815
- foreach( $images as $image ) {
816
- $imagetemp = wp_get_attachment_url($image->ID, false);
817
- $imagetempsize = (
818
- intval(ini_get('allow_url_fopen' ))==1
819
- ?
820
- (
821
- intval($this->options['fb_adv_force_local'])==1
822
- ?
823
- ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
824
- :
825
- $imagetemp
826
- )
827
- :
828
- ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
829
- );
830
- if ( intval($this->options['fb_adv_disable_image_size'])==1 ) {
831
- //If we don't check for image size, we'll just accept the first one
832
- $fb_image = $imagetemp;
833
- $thumbdone = true;
834
- break; //Break the foreach
835
- } else {
836
- if ( $img_size = $this->get_open_graph_image_size($imagetempsize) ) {
837
- if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
838
- $fb_image = $imagetemp;
839
- $thumbdone = true;
840
- break; //Break the foreach
841
- }
842
- }
843
- }
844
- }
845
  }
846
  }
 
 
 
 
 
847
  }
848
- //From default
849
- if ( !$thumbdone ) {
850
- if ( intval($this->options['fb_image_use_default'])==1 ) {
851
- //Well... We sure did try. We'll just keep the default one!
852
- $fb_image = $this->options['fb_image'];
853
- } else {
854
- //User chose not to use default on pages/posts
855
- $fb_image = '';
856
- }
857
- }
858
- //Return
859
- return $fb_image;
860
-
861
  }
862
 
863
 
@@ -890,7 +913,10 @@ class Webdados_FB_Public {
890
  curl_setopt($curl, CURLOPT_REFERER, ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
891
  curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
892
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); //Try to fix White Screen Of Death - https://wordpress.org/support/topic/html-truncated/#post-9714288
 
 
893
  $data = curl_exec($curl);
 
894
  curl_close($curl);
895
  return $data;
896
  } catch(Exception $e) {
@@ -901,17 +927,23 @@ class Webdados_FB_Public {
901
  //Just in case we've missed it somewhere...
902
  if ( intval($this->options['fb_adv_disable_image_size'])==1 ) return false;
903
  //Go ahead
904
- $transient_key = 'webdados_og_image_size_' . md5($image);
905
- $transient_val = get_transient($transient_key);
906
- if ($transient_val) {
907
- return $transient_val;
 
 
908
  }
909
  if ( stristr($image, 'http://' ) || stristr($image, 'https://' ) || mb_substr($image, 0, 2)=='//' ) {
910
- if ( function_exists('curl_version' ) && function_exists('imagecreatefromstring' ) ) {
911
- //We'll get just a part of the image to speed things up. From http://stackoverflow.com/questions/4635936/super-fast-getimagesize-in-php
912
- $headers = array(
913
- "Range: bytes=0-32768"
914
- );
 
 
 
 
915
  $data = $this->get_open_graph_image_size_curl($image, $headers);
916
  if ( $data ) {
917
  $done_partial = false;
@@ -920,18 +952,22 @@ class Webdados_FB_Public {
920
  $im = @imagecreatefromstring($data); //Mute errors because we're not loading the all image
921
  if ($im) $done_partial = true;
922
  } catch(Exception $e) {
923
- //Try again with the whole image - In case of Fatal Error
924
- $tried_full = true;
925
- $data = $this->get_open_graph_image_size_curl($image, null);
926
- $im = @imagecreatefromstring($data);
927
- }
928
- if ( !$done_partial && !$tried_full ) {
929
- //Try again with the whole image - In case of Warning
930
- if ( $data = $this->get_open_graph_image_size_curl($image, null) ) {
931
  $im = @imagecreatefromstring($data);
932
- } else {
933
- //No way...
934
- $im = false;
 
 
 
 
 
 
 
 
935
  }
936
  }
937
  if ( $im ) {
@@ -975,8 +1011,8 @@ class Webdados_FB_Public {
975
  //Local path
976
  $img_size = getimagesize($image);
977
  }
978
- if ($img_size) {
979
- set_transient($transient_key, $img_size, DAY_IN_SECONDS);
980
  }
981
  $this->image_size = $img_size;
982
  return $img_size;
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 2.2
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
22
  /* BDP Post temporary holder */
23
  private $post = false;
24
 
25
+ /* Use partial image when getting it's size? */
26
+ private $image_size_use_partial = false;
27
+
28
+ /* Cache / transient validity - Default: one week */
29
+ private $transient_validity = WEEK_IN_SECONDS;
30
+
31
 
32
 
33
  /* Construct */
60
  ';
61
 
62
  if ( apply_filters('fb_og_enabled', true) ) {
63
+
64
+ //Partial image - Since 2.2 we do NOT get partial by default anymore - Advanced users can use this filter to use it again
65
+ $this->image_size_use_partial = apply_filters( 'fb_og_image_size_use_partial', false );
66
+ //If we're using partial image, we lower the transient validity to one day
67
+ if ( $this->image_size_use_partial ) $this->transient_validity = DAY_IN_SECONDS;
68
 
69
  //Also set Title Tag? - Needed??
70
  $fb_set_title_tag=0;
108
  break;
109
  }
110
 
111
+ if ( is_singular() ) { //Including homepage if set as static page
112
 
113
  global $post;
114
  // Title
331
  }
332
  }
333
  } else {
334
+ if ( is_front_page() ) { //Regular homepage
335
  $fb_url = get_option('home').(intval($this->options['fb_url_add_trailing'])==1 ? '/' : '');
336
  $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
337
  $fb_desc = $fb_desc_homepage;
338
  } else {
339
+ if ( is_home() ) { //Blog page (set as page)
340
+ if ( 'page' === get_option( 'show_on_front' ) && $page_for_posts = get_option( 'page_for_posts' ) ) {
341
+ //$post = get_post( $page_for_posts ); //This is NOT the global $post and it's actually not needed because we'll use the post ID = $page_for_posts
342
  //Blog page
343
  $fb_type = trim( $this->options['fb_type_homepage']=='' ? 'website' : $this->options['fb_type_homepage'] );
344
+ if ( $fb_desc = trim( get_post_meta($page_for_posts, '_webdados_fb_open_graph_specific_description', true) ) ) {
345
  //OK - From our metabox
346
  } else {
347
  //Use default
348
  $fb_desc = $fb_desc_homepage;
349
  }
350
  if ( intval($this->options['fb_image_show'])==1 || intval($this->options['fb_image_show_schema'])==1 || intval($this->options['fb_image_show_twitter'])==1 ) {
351
+ $fb_image = $this->get_post_image( $page_for_posts );
352
  }
353
  }
354
  } else {
706
 
707
 
708
  /* Get post image - Singular pages */
709
+ private function get_post_image( $post_id = NULL ) {
710
+ if ( $post_id ) {
711
+ $current_post = false;
712
+ //Specific post
713
+ $post = get_post( $post_id );
714
+ } else {
715
+ $current_post = true;
716
+ //Current post
717
+ global $post;
 
 
 
 
 
718
  }
719
+ if ( $post ) {
720
+ $thumbdone = false;
721
+ $fb_image = '';
722
+ $minsize = intval($this->options['fb_image_min_size']);
723
+ //Attachment page? - This overrides the other options
724
+ if ( !$current_post && is_attachment() ) {
725
+ if ( $temp=wp_get_attachment_image_src(null, 'full' ) ) {
726
+ $fb_image = trim($temp[0]);
727
+ $img_size = array(intval($temp[1]), intval($temp[2]));
728
  if ( trim($fb_image)!='' ) {
729
  $thumbdone=true;
730
  }
731
  }
732
  }
733
+ //Specific post image
734
+ if ( !$thumbdone ) {
735
+ if ( intval($this->options['fb_image_use_specific'])==1 ) {
736
+ if ( $fb_image = trim(get_post_meta($post->ID, '_webdados_fb_open_graph_specific_image', true)) ) {
737
+ if ( trim($fb_image)!='' ) {
738
+ $thumbdone=true;
739
+ }
 
 
740
  }
741
  }
742
  }
743
+ //Featured image
744
+ if ( !$thumbdone ) {
745
+ if ( function_exists('get_post_thumbnail_id' ) ) {
746
+ if ( intval($this->options['fb_image_use_featured'])==1 ) {
747
+ if ( $id_attachment=get_post_thumbnail_id($post->ID) ) {
748
+ //There's a featured/thumbnail image for this post
749
+ $fb_image = wp_get_attachment_url($id_attachment, false);
750
+ $thumbdone = true;
751
+ }
752
+ }
753
+ }
754
+ }
755
+ //From post/page content
756
+ if ( !$thumbdone ) {
757
+ if ( intval($this->options['fb_image_use_content'])==1 ) {
758
+ $imgreg = '/<img .*src=["\']([^ ^"^\']*)["\']/';
759
+ preg_match_all($imgreg, trim($post->post_content), $matches);
760
+ if ($matches[1]) {
761
+ $imagetemp=false;
762
+ foreach($matches[1] as $image) {
763
+ //There's an image on the content
764
+ $pos = strpos( $image, site_url() );
765
+ if ( $pos === false ) {
766
+ if (stristr($image, 'http://' ) || stristr($image, 'https://' ) || mb_substr($image, 0, 2)=='//' ) {
767
+ if (mb_substr($image, 0, 2)=='//' ) $image=((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https:' : 'http:' ).$image;
768
+ //Complete URL - offsite
769
+ //if ( intval(ini_get('allow_url_fopen' ))==1 ) {
770
+ $imagetemp=$image;
771
+ $imagetempsize=$imagetemp;
772
+ //} else {
773
+ //If it's offsite we can't getimagesize'it, so we won't use it
774
+ //We could save a temporary version locally and then getimagesize'it but do we want to do this every single time?
775
+ //}
776
+ } else {
777
+ //Partial URL - we guess it's onsite because no http(s)://
778
+ $imagetemp=site_url().$image;
779
+ $imagetempsize=(
780
+ intval(ini_get('allow_url_fopen' ))==1
781
+ ?
782
+ (
783
+ intval($this->options['fb_adv_force_local'])==1
784
+ ?
785
+ ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
786
+ :
787
+ $imagetemp
788
+ )
789
+ :
790
+ ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
791
+ );
792
+ }
793
  } else {
794
+ //Complete URL - onsite
795
+ $imagetemp=$image;
796
  $imagetempsize=(
797
  intval(ini_get('allow_url_fopen' ))==1
798
  ?
807
  ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
808
  );
809
  }
810
+ if ($imagetemp) {
811
+ if ( intval($this->options['fb_adv_disable_image_size'])==1 ) {
812
+ //If we don't check for image size, we'll just accept the first one
813
+ $fb_image = $imagetemp;
814
+ $thumbdone = true;
815
+ break; //Break the foreach
816
+ } else {
817
+ if ( $img_size = $this->get_open_graph_image_size( $imagetempsize ) ) {
818
+ if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
819
+ $fb_image = $imagetemp;
820
+ $thumbdone = true;
821
+ break; //Break the foreach
822
+ }
823
+ }
824
+ }
825
+ }
826
+ }
827
+ }
828
+ }
829
+ }
830
+ //From media gallery
831
+ if ( !$thumbdone ) {
832
+ if ( intval($this->options['fb_image_use_media'])==1 ) {
833
+ $images = get_posts(array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'order' => 'ASC','orderby' => 'menu_order','post_mime_type' => 'image','post_parent' => $post->ID));
834
+ if ( $images ) {
835
+ foreach( $images as $image ) {
836
+ $imagetemp = wp_get_attachment_url($image->ID, false);
837
+ $imagetempsize = (
838
  intval(ini_get('allow_url_fopen' ))==1
839
  ?
840
  (
847
  :
848
  ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
849
  );
 
 
850
  if ( intval($this->options['fb_adv_disable_image_size'])==1 ) {
851
  //If we don't check for image size, we'll just accept the first one
852
  $fb_image = $imagetemp;
853
  $thumbdone = true;
854
  break; //Break the foreach
855
  } else {
856
+ if ( $img_size = $this->get_open_graph_image_size($imagetempsize) ) {
857
  if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
858
  $fb_image = $imagetemp;
859
  $thumbdone = true;
865
  }
866
  }
867
  }
868
+ //From default
869
+ if ( !$thumbdone ) {
870
+ if ( intval($this->options['fb_image_use_default'])==1 ) {
871
+ //Well... We sure did try. We'll just keep the default one!
872
+ $fb_image = $this->options['fb_image'];
873
+ } else {
874
+ //User chose not to use default on pages/posts
875
+ $fb_image = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
876
  }
877
  }
878
+ //Return
879
+ return $fb_image;
880
+ } else {
881
+ //No post
882
+ return false;
883
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
884
  }
885
 
886
 
913
  curl_setopt($curl, CURLOPT_REFERER, ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://' ).$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
914
  curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
915
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); //Try to fix White Screen Of Death - https://wordpress.org/support/topic/html-truncated/#post-9714288
916
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
917
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
918
  $data = curl_exec($curl);
919
+ //if ( !$data ) var_dump( curl_error( $curl ) ); //Debug
920
  curl_close($curl);
921
  return $data;
922
  } catch(Exception $e) {
927
  //Just in case we've missed it somewhere...
928
  if ( intval($this->options['fb_adv_disable_image_size'])==1 ) return false;
929
  //Go ahead
930
+ if ( apply_filters( 'fb_og_image_size_cache', true ) ) {
931
+ $transient_key = 'webdados_og_image_size_' . md5($image);
932
+ $transient_val = get_transient($transient_key);
933
+ if ($transient_val) {
934
+ return $transient_val;
935
+ }
936
  }
937
  if ( stristr($image, 'http://' ) || stristr($image, 'https://' ) || mb_substr($image, 0, 2)=='//' ) {
938
+ if ( function_exists( 'curl_version' ) && function_exists( 'imagecreatefromstring' ) ) {
939
+ //If true - We'll get just a part of the image to speed things up. From http://stackoverflow.com/questions/4635936/super-fast-getimagesize-in-php
940
+ if ( $this->image_size_use_partial ) {
941
+ $headers = array(
942
+ "Range: bytes=0-32768"
943
+ );
944
+ } else {
945
+ $headers = null;
946
+ }
947
  $data = $this->get_open_graph_image_size_curl($image, $headers);
948
  if ( $data ) {
949
  $done_partial = false;
952
  $im = @imagecreatefromstring($data); //Mute errors because we're not loading the all image
953
  if ($im) $done_partial = true;
954
  } catch(Exception $e) {
955
+ if ( !$this->image_size_use_partial ) { //We already tried it full
956
+ //Try again with the whole image - In case of Fatal Error
957
+ $tried_full = true;
958
+ $data = $this->get_open_graph_image_size_curl($image, null);
 
 
 
 
959
  $im = @imagecreatefromstring($data);
960
+ }
961
+ }
962
+ if ( !$this->image_size_use_partial ) { //We already tried it full
963
+ if ( !$done_partial && !$tried_full ) {
964
+ //Try again with the whole image - In case of Warning
965
+ if ( $data = $this->get_open_graph_image_size_curl($image, null) ) {
966
+ $im = @imagecreatefromstring($data);
967
+ } else {
968
+ //No way...
969
+ $im = false;
970
+ }
971
  }
972
  }
973
  if ( $im ) {
1011
  //Local path
1012
  $img_size = getimagesize($image);
1013
  }
1014
+ if ( $img_size && apply_filters( 'fb_og_image_size_cache', true ) ) {
1015
+ set_transient( $transient_key, $img_size, $this->transient_validity );
1016
  }
1017
  $this->image_size = $img_size;
1018
  return $img_size;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://bit.ly/donate_fb_opengraph
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.5
6
  Tested up to: 4.9.1
7
- Stable tag: 2.1.6.3
8
 
9
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and SEO Meta Tags into your WordPress Website for more efficient sharing results.
10
 
@@ -125,7 +125,7 @@ Chouck out this [code snippet](https://gist.github.com/webdados/ef5d5db01f01bee6
125
 
126
  Go to the plugin settings and check the `Do not get image size` option.
127
  This happens on some edge cases we haven't yet been able to identify.
128
- Update: Probably fixed on 2.1.4.5
129
 
130
  = Yoast SEO shows up a big nasty warning if both plugins are active. Is the world in danger if I keep both plugins active? =
131
 
@@ -147,6 +147,16 @@ We DO NOT provide email support for this plugin. If you send us an email asking
147
 
148
  == Changelog ==
149
 
 
 
 
 
 
 
 
 
 
 
150
  = 2.1.6.3 =
151
  * Fix the "Suppress cache notices" option (Thanks @digbymaass)
152
 
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.5
6
  Tested up to: 4.9.1
7
+ Stable tag: 2.2
8
 
9
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and SEO Meta Tags into your WordPress Website for more efficient sharing results.
10
 
125
 
126
  Go to the plugin settings and check the `Do not get image size` option.
127
  This happens on some edge cases we haven't yet been able to identify.
128
+ Update: Probably fixed for some users on 2.1.4.5 and completely on 2.2 (pending confirmation)
129
 
130
  = Yoast SEO shows up a big nasty warning if both plugins are active. Is the world in danger if I keep both plugins active? =
131
 
147
 
148
  == Changelog ==
149
 
150
+ = 2.2 =
151
+ * New "Tools" panel on the settings page
152
+ * Tool to clear all the plugin transients, thus resetting size caching for all images (use it only )
153
+ * Small bug fix when the settings aren't yet saved at least one time
154
+ * When getting the image size, the full image is used again, instead of the partial 32Kb (that caused WSOD in some environments), but this can be overridden (and use the partial again) by returning false to the new `fb_og_image_size_use_partial` filter
155
+ * Transient validity is now one week (now that we get the all image and the process can slow down the page load a bit), instead of one day
156
+ * Fix when getting the image and description for the blog url when it's set as a page (Thanks @alexiswilke)
157
+ * Ability to disable image size cache (transients) completely by returning false to the new filter `fb_og_image_size_cache` (which we do NOT recommend)
158
+ * Improved the FAQ
159
+
160
  = 2.1.6.3 =
161
  * Fix the "Suppress cache notices" option (Thanks @digbymaass)
162
 
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.1.6.3
5
  */
6
  /*
7
  Plugin Name: Facebook Open Graph, Google+ and Twitter Card Tags
8
  Plugin URI: https://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.1.6.3
12
  Author: Webdados
13
  Author URI: https://www.webdados.pt
14
  Text Domain: wonderm00ns-simple-facebook-open-graph-tags
@@ -18,7 +18,7 @@ WC tested up to: 3.2.6
18
 
19
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
20
 
21
- define( 'WEBDADOS_FB_VERSION', '2.1.6.3' );
22
  define( 'WEBDADOS_FB_PLUGIN_NAME', 'Facebook Open Graph, Google+ and Twitter Card Tags' );
23
  define( 'WEBDADOS_FB_W', 1200 );
24
  define( 'WEBDADOS_FB_H', 630 );
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 2.2
5
  */
6
  /*
7
  Plugin Name: Facebook Open Graph, Google+ and Twitter Card Tags
8
  Plugin URI: https://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.2
12
  Author: Webdados
13
  Author URI: https://www.webdados.pt
14
  Text Domain: wonderm00ns-simple-facebook-open-graph-tags
18
 
19
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
20
 
21
+ define( 'WEBDADOS_FB_VERSION', '2.2' );
22
  define( 'WEBDADOS_FB_PLUGIN_NAME', 'Facebook Open Graph, Google+ and Twitter Card Tags' );
23
  define( 'WEBDADOS_FB_W', 1200 );
24
  define( 'WEBDADOS_FB_H', 630 );