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

Version Description

  • Changed the way the admin notices are generated so we do not have to use PHP sessions
Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.4

admin/class-webdados-fb-open-graph-admin.php CHANGED
@@ -14,6 +14,10 @@ class Webdados_FB_Admin {
14
  /* Database options */
15
  private $options;
16
 
 
 
 
 
17
  /* Construct */
18
  public function __construct( $options, $version ) {
19
  $this->options = $options;
@@ -229,28 +233,78 @@ class Webdados_FB_Admin {
229
  if ($save) {
230
  //Force Facebook update anyway - Our meta box could be hidden - Not really! We'll just update if we got our metabox
231
  if (get_post_status($post_id)=='publish' && intval($this->options['fb_adv_notify_fb'])==1) {
 
 
232
  $fb_debug_url='http://graph.facebook.com/?id='.urlencode(get_permalink($post_id)).'&scrape=true&method=post';
233
- $response=wp_remote_get($fb_debug_url);
234
  if ( is_wp_error($response) ) {
235
- $_SESSION['wd_fb_og_updated_error']=1;
236
- $_SESSION['wd_fb_og_updated_error_message']=__('URL failed:', 'wonderm00ns-simple-facebook-open-graph-tags').' '.$fb_debug_url;
 
 
237
  } else {
238
  if ( $response['response']['code']==200 && intval($this->options['fb_adv_supress_fb_notice'])==0 ) {
239
- $_SESSION['wd_fb_og_updated']=1;
 
 
240
  } else {
 
 
 
 
 
 
 
 
 
241
  if ( $response['response']['code']==500 ) {
242
  $_SESSION['wd_fb_og_updated_error']=1;
243
  $error=json_decode($response['body']);
244
  $_SESSION['wd_fb_og_updated_error_message']=__('Facebook returned:', 'wonderm00ns-simple-facebook-open-graph-tags').' '.$error->error->message;
245
- }
246
  }
247
  }
 
248
  }
249
  }
250
  return $post_id;
251
  }
 
 
 
 
 
252
  public function admin_notices() {
253
- if ($screen = get_current_screen()) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  if (isset($_SESSION['wd_fb_og_updated']) && $_SESSION['wd_fb_og_updated']==1 && $screen->parent_base=='edit' && $screen->base=='post') {
255
  global $post;
256
  ?>
@@ -273,7 +327,7 @@ class Webdados_FB_Admin {
273
  }
274
  unset($_SESSION['wd_fb_og_updated']);
275
  unset($_SESSION['wd_fb_og_updated_error']);
276
- unset($_SESSION['wd_fb_og_updated_error_message']);
277
  }
278
 
279
  /* Options page */
14
  /* Database options */
15
  private $options;
16
 
17
+ /* Update FB status */
18
+ private $update_status;
19
+ private $update_error;
20
+
21
  /* Construct */
22
  public function __construct( $options, $version ) {
23
  $this->options = $options;
233
  if ($save) {
234
  //Force Facebook update anyway - Our meta box could be hidden - Not really! We'll just update if we got our metabox
235
  if (get_post_status($post_id)=='publish' && intval($this->options['fb_adv_notify_fb'])==1) {
236
+ $status = 0;
237
+ $error = false;
238
  $fb_debug_url='http://graph.facebook.com/?id='.urlencode(get_permalink($post_id)).'&scrape=true&method=post';
239
+ $response = wp_remote_get($fb_debug_url);
240
  if ( is_wp_error($response) ) {
241
+ $this->update_status = -1;
242
+ $this->update_error = __('URL failed:', 'wonderm00ns-simple-facebook-open-graph-tags').' '.$fb_debug_url;
243
+ //$_SESSION['wd_fb_og_updated_error']=1;
244
+ //$_SESSION['wd_fb_og_updated_error_message']=__('URL failed:', 'wonderm00ns-simple-facebook-open-graph-tags').' '.$fb_debug_url;
245
  } else {
246
  if ( $response['response']['code']==200 && intval($this->options['fb_adv_supress_fb_notice'])==0 ) {
247
+ $this->update_status = 1;
248
+ $this->update_error = false;
249
+ //$_SESSION['wd_fb_og_updated']=1;
250
  } else {
251
+ $body = json_decode($response['body']);
252
+ if ( isset($body->error->message) ) {
253
+ $this->update_status = -2;
254
+ $this->update_error = __('Facebook returned:', 'wonderm00ns-simple-facebook-open-graph-tags').' '.$body->error->message;
255
+ } else {
256
+ $this->update_status = -3;
257
+ $this->update_error = __('Unknown Error', 'wonderm00ns-simple-facebook-open-graph-tags');
258
+ }
259
+ /*
260
  if ( $response['response']['code']==500 ) {
261
  $_SESSION['wd_fb_og_updated_error']=1;
262
  $error=json_decode($response['body']);
263
  $_SESSION['wd_fb_og_updated_error_message']=__('Facebook returned:', 'wonderm00ns-simple-facebook-open-graph-tags').' '.$error->error->message;
264
+ }*/
265
  }
266
  }
267
+ add_filter( 'redirect_post_location', array( $this, 'redirect_post_location' ), 10, 2 );
268
  }
269
  }
270
  return $post_id;
271
  }
272
+ public function redirect_post_location( $location, $post_id ) {
273
+ $location = add_query_arg( 'wd_fb_og_status', $this->update_status , $location );
274
+ if ( $this->update_error ) $location = add_query_arg( 'wd_fb_og_error', urlencode($this->update_error) , $location );
275
+ return $location;
276
+ }
277
  public function admin_notices() {
278
+ if ( isset($_GET['wd_fb_og_status']) ) {
279
+ if ( $screen = get_current_screen() ) {
280
+ if ( $screen->parent_base=='edit' && $screen->base=='post' ) {
281
+ global $post;
282
+ switch ( $_GET['wd_fb_og_status'] ) {
283
+ case '1':
284
+ ?>
285
+ <div class="updated">
286
+ <p><?php _e('Facebook Open Graph Tags cache updated/purged.', 'wonderm00ns-simple-facebook-open-graph-tags'); ?> <a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode(get_permalink($post->ID));?>" target="_blank"><?php _e('Share this on Facebook', 'wonderm00ns-simple-facebook-open-graph-tags'); ?></a></p>
287
+ </div>
288
+ <?php
289
+ break;
290
+ case '-1':
291
+ case '-2':
292
+ case '-3':
293
+ ?>
294
+ <div class="error">
295
+ <p><?php
296
+ echo '<b>'.__('Error: Facebook Open Graph Tags cache NOT updated/purged.', 'wonderm00ns-simple-facebook-open-graph-tags').'</b>';
297
+ if ( isset($_GET['wd_fb_og_error']) ) echo '<br/>'.$_GET['wd_fb_og_error'];
298
+ ?></p>
299
+ </div>
300
+ <?php
301
+ break;
302
+
303
+ }
304
+ }
305
+ }
306
+ }
307
+ /*if ($screen = get_current_screen()) {
308
  if (isset($_SESSION['wd_fb_og_updated']) && $_SESSION['wd_fb_og_updated']==1 && $screen->parent_base=='edit' && $screen->base=='post') {
309
  global $post;
310
  ?>
327
  }
328
  unset($_SESSION['wd_fb_og_updated']);
329
  unset($_SESSION['wd_fb_og_updated_error']);
330
+ unset($_SESSION['wd_fb_og_updated_error_message']);*/
331
  }
332
 
333
  /* Options page */
includes/class-webdados-fb-open-graph.php CHANGED
@@ -230,8 +230,8 @@ class Webdados_FB {
230
  add_action( 'save_post', array( $plugin_admin, 'save_meta_boxes' ) );
231
  add_action( 'admin_notices', array( $plugin_admin, 'admin_notices' ) );
232
  // Session start so we can know if the cache was cleared on Facebook
233
- if(!session_id())
234
- @session_start(); //We use @ because some other plugin could previously sent something to the browser
235
  }
236
 
237
  /* Public hooks */
230
  add_action( 'save_post', array( $plugin_admin, 'save_meta_boxes' ) );
231
  add_action( 'admin_notices', array( $plugin_admin, 'admin_notices' ) );
232
  // Session start so we can know if the cache was cleared on Facebook
233
+ //if(!session_id())
234
+ //@session_start(); //We use @ because some other plugin could previously sent something to the browser
235
  }
236
 
237
  /* Public hooks */
lang/wonderm00ns-simple-facebook-open-graph-tags.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-09-26 11:14+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"
@@ -21,80 +21,80 @@ msgstr ""
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
- #: admin/class-webdados-fb-open-graph-admin.php:48
25
  msgid "Settings"
26
  msgstr ""
27
 
28
- #: admin/class-webdados-fb-open-graph-admin.php:59
29
  msgid "Google+"
30
  msgstr ""
31
 
32
- #: admin/class-webdados-fb-open-graph-admin.php:61
33
  #: admin/options-page-twitter.php:110
34
  msgid "Twitter username (without @)"
35
  msgstr ""
36
 
37
- #: admin/class-webdados-fb-open-graph-admin.php:63
38
  msgid "Facebook profile URL"
39
  msgstr ""
40
 
41
- #: admin/class-webdados-fb-open-graph-admin.php:99
42
- #: admin/class-webdados-fb-open-graph-admin.php:124
43
- #: admin/class-webdados-fb-open-graph-admin.php:291
44
  msgid "Use this image"
45
  msgstr ""
46
 
47
- #: admin/class-webdados-fb-open-graph-admin.php:104
48
  #: admin/options-page-general.php:121 admin/options-page-general.php:187
49
  msgid "Upload/Choose"
50
  msgstr ""
51
 
52
- #: admin/class-webdados-fb-open-graph-admin.php:105
53
  msgid "Clear field"
54
  msgstr ""
55
 
56
- #: admin/class-webdados-fb-open-graph-admin.php:107
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:123
63
- #: admin/class-webdados-fb-open-graph-admin.php:290
64
  msgid "Select image"
65
  msgstr ""
66
 
67
- #: admin/class-webdados-fb-open-graph-admin.php:155
68
  msgid "Use this description"
69
  msgstr ""
70
 
71
- #: admin/class-webdados-fb-open-graph-admin.php:161
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:167
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:236
82
  msgid "URL failed:"
83
  msgstr ""
84
 
85
- #: admin/class-webdados-fb-open-graph-admin.php:244
86
- msgid "Facebook returned:"
87
  msgstr ""
88
 
89
- #: admin/class-webdados-fb-open-graph-admin.php:258
90
  msgid "Facebook Open Graph Tags cache updated/purged."
91
  msgstr ""
92
 
93
- #: admin/class-webdados-fb-open-graph-admin.php:258
94
  msgid "Share this on Facebook"
95
  msgstr ""
96
 
97
- #: admin/class-webdados-fb-open-graph-admin.php:266
98
  msgid "Error: Facebook Open Graph Tags cache NOT updated/purged."
99
  msgstr ""
100
 
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-11-20 13:02+0000\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.4\n"
15
  "X-Poedit-Basepath: ..\n"
16
  "X-Poedit-WPHeader: wonderm00n-open-graph.php\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
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:103
42
+ #: admin/class-webdados-fb-open-graph-admin.php:128
43
+ #: admin/class-webdados-fb-open-graph-admin.php:345
44
  msgid "Use this image"
45
  msgstr ""
46
 
47
+ #: admin/class-webdados-fb-open-graph-admin.php:108
48
  #: admin/options-page-general.php:121 admin/options-page-general.php:187
49
  msgid "Upload/Choose"
50
  msgstr ""
51
 
52
+ #: admin/class-webdados-fb-open-graph-admin.php:109
53
  msgid "Clear field"
54
  msgstr ""
55
 
56
+ #: admin/class-webdados-fb-open-graph-admin.php:111
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:127
63
+ #: admin/class-webdados-fb-open-graph-admin.php:344
64
  msgid "Select image"
65
  msgstr ""
66
 
67
+ #: admin/class-webdados-fb-open-graph-admin.php:159
68
  msgid "Use this description"
69
  msgstr ""
70
 
71
+ #: admin/class-webdados-fb-open-graph-admin.php:165
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:171
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:242
82
  msgid "URL failed:"
83
  msgstr ""
84
 
85
+ #: admin/class-webdados-fb-open-graph-admin.php:257
86
+ msgid "Unknown Error"
87
  msgstr ""
88
 
89
+ #: admin/class-webdados-fb-open-graph-admin.php:286
90
  msgid "Facebook Open Graph Tags cache updated/purged."
91
  msgstr ""
92
 
93
+ #: admin/class-webdados-fb-open-graph-admin.php:286
94
  msgid "Share this on Facebook"
95
  msgstr ""
96
 
97
+ #: admin/class-webdados-fb-open-graph-admin.php:296
98
  msgid "Error: Facebook Open Graph Tags cache NOT updated/purged."
99
  msgstr ""
100
 
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.3
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 2.1.4
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
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.5
6
  Tested up to: 4.9
7
- Stable tag: 2.1.3
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 ==
@@ -126,6 +126,9 @@ We DO NOT provide email support for this plugin. If you send us an email asking
126
 
127
  == Changelog ==
128
 
 
 
 
129
  = 2.1.3 =
130
  * Fixed some PHP notices and warnings
131
  * Tested with WooCommerce 3.2
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
7
+ Stable tag: 2.1.4
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 ==
126
 
127
  == Changelog ==
128
 
129
+ = 2.1.4 =
130
+ * Changed the way the admin notices are generated so we do not have to use PHP sessions
131
+
132
  = 2.1.3 =
133
  * Fixed some PHP notices and warnings
134
  * Tested with WooCommerce 3.2
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.3
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.1.3
12
  Author: Webdados
13
  Author URI: http://www.webdados.pt
14
  Text Domain: wonderm00ns-simple-facebook-open-graph-tags
@@ -18,7 +18,7 @@ WC tested up to: 3.2
18
 
19
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
20
 
21
- define( 'WEBDADOS_FB_VERSION', '2.1.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.1.4
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.1.4
12
  Author: Webdados
13
  Author URI: http://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.1.4' );
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 );