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

Version Description

  • Fix: Fatal error integrating with WPSEO's last version
  • Fix: Checking for post_type when saving the meta box field and updating/purging Facebook Open Graph Tags cache to avoid doing it when unnecessary
Download this release

Release Info

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

Code changes from version 1.5.1 to 1.5.2

Files changed (2) hide show
  1. readme.txt +5 -1
  2. wonderm00n-open-graph.php +34 -22
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, seo, share, social, meta, twitter card, twitter, schema, google+, g+, google, google plus, image, like, meta, search engine optimization
5
  Requires at least: 3.5
6
  Tested up to: 4.0.1
7
- Stable tag: 1.5.1
8
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and other Meta Tags into your WordPress Website for more efficient sharing results.
9
 
10
  == Description ==
@@ -76,6 +76,10 @@ It allows the user to choose which tags are, or not, included and also the defau
76
 
77
  == Changelog ==
78
 
 
 
 
 
79
  = 1.5.1 =
80
  * Fix: error checking and reporting when updating/purging Facebook Open Graph Tags cache to avoid fatal errors on failure
81
  * Fix: change Facebook cache update call from https to http to avoid errors on some server configurations
4
  Tags: facebook, open graph, open graph protocol, seo, share, social, meta, twitter card, twitter, schema, google+, g+, google, google plus, image, like, meta, search engine optimization
5
  Requires at least: 3.5
6
  Tested up to: 4.0.1
7
+ Stable tag: 1.5.2
8
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and other Meta Tags into your WordPress Website for more efficient sharing results.
9
 
10
  == Description ==
76
 
77
  == Changelog ==
78
 
79
+ = 1.5.2 =
80
+ * Fix: Fatal error integrating with WPSEO's last version
81
+ * Fix: Checking for post_type when saving the meta box field and updating/purging Facebook Open Graph Tags cache to avoid doing it when unnecessary
82
+
83
  = 1.5.1 =
84
  * Fix: error checking and reporting when updating/purging Facebook Open Graph Tags cache to avoid fatal errors on failure
85
  * Fix: change Facebook cache update call from https to http to avoid errors on some server configurations
wonderm00n-open-graph.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
- * @version 1.5.1
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 and Twitter Card 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
- Version: 1.5.1
11
  Author: Webdados
12
  Author URI: http://www.webdados.pt
13
  Text Domain: wd-fb-og
@@ -16,7 +16,7 @@ Domain Path: /lang
16
 
17
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
 
19
- $webdados_fb_open_graph_plugin_version='1.5.1';
20
  $webdados_fb_open_graph_plugin_name='Facebook Open Graph, Google+ and Twitter Card Tags';
21
  $webdados_fb_open_graph_plugin_settings=array(
22
  'fb_app_id_show',
@@ -317,7 +317,7 @@ function webdados_fb_open_graph() {
317
  //YOAST?
318
  if ($fb_show_wpseoyoast==1) {
319
  if ( defined('WPSEO_VERSION') ) {
320
- $wpseo = new WPSEO_Frontend();
321
  //App ID - From our plugin
322
  //Admin ID - From our plugin
323
  //Locale - From our plugin
@@ -773,9 +773,18 @@ if (is_admin()) {
773
  $save=true;
774
 
775
  // If this is an autosave, our form has not been submitted, so we don't want to do anything.
776
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
777
  return $post_id;
778
 
 
 
 
 
 
 
 
 
 
779
  // Check if our nonce is set.
780
  if (!isset($_POST['webdados_fb_open_graph_custom_box_nonce']))
781
  $save=false;
@@ -803,21 +812,23 @@ if (is_admin()) {
803
  update_post_meta($post_id, '_webdados_fb_open_graph_specific_image', $mydata);
804
  }
805
 
806
- //Force Facebook update anyway - Our meta box could be hidden
807
- if (get_post_status($post_id)=='publish' && intval($webdados_fb_open_graph_settings['fb_adv_notify_fb'])==1) {
808
- $fb_debug_url='http://graph.facebook.com/?id='.urlencode(get_permalink($post_id)).'&scrape=true&method=post';
809
- $response=wp_remote_get($fb_debug_url);
810
- if (is_wp_error($response)) {
811
- $_SESSION['wd_fb_og_updated_error']=1;
812
- $_SESSION['wd_fb_og_updated_error_message']=__('URL failed:', 'wd-fb-og').' '.$fb_debug_url;
813
- } else {
814
- if ($response['response']['code']==200 && intval($webdados_fb_open_graph_settings['fb_adv_supress_fb_notice'])==0) {
815
- $_SESSION['wd_fb_og_updated']=1;
816
  } else {
817
- if ($response['response']['code']==500) {
818
- $_SESSION['wd_fb_og_updated_error']=1;
819
- $error=json_decode($response['body']);
820
- $_SESSION['wd_fb_og_updated_error_message']=__('Facebook returned:', 'wd-fb-og').' '.$error->error->message;
 
 
 
 
821
  }
822
  }
823
  }
@@ -829,14 +840,15 @@ if (is_admin()) {
829
  add_action('save_post', 'webdados_fb_open_graph_add_posts_options_box_save');
830
  function webdados_fb_open_graph_facebook_updated() {
831
  if ($screen = get_current_screen()) {
832
- if (isset($_SESSION['wd_fb_og_updated']) && $_SESSION['wd_fb_og_updated']==1 && $screen->id=='post') {
 
833
  ?>
834
  <div class="updated">
835
- <p><?php _e('Facebook Open Graph Tags cache updated/purged.', 'wd-fb-og'); ?> <a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode(get_permalink($post_id));?>" target="_blank"><?php _e('Share this on Facebook', 'wd-fb-og'); ?></a></p>
836
  </div>
837
  <?php
838
  } else {
839
- if (isset($_SESSION['wd_fb_og_updated_error']) && $_SESSION['wd_fb_og_updated_error']==1 && $screen->id=='post') {
840
  ?>
841
  <div class="error">
842
  <p><?php
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 1.5.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 and Twitter Card 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
+ Version: 1.5.2
11
  Author: Webdados
12
  Author URI: http://www.webdados.pt
13
  Text Domain: wd-fb-og
16
 
17
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
 
19
+ $webdados_fb_open_graph_plugin_version='1.5.2';
20
  $webdados_fb_open_graph_plugin_name='Facebook Open Graph, Google+ and Twitter Card Tags';
21
  $webdados_fb_open_graph_plugin_settings=array(
22
  'fb_app_id_show',
317
  //YOAST?
318
  if ($fb_show_wpseoyoast==1) {
319
  if ( defined('WPSEO_VERSION') ) {
320
+ $wpseo = WPSEO_Frontend::get_instance();
321
  //App ID - From our plugin
322
  //Admin ID - From our plugin
323
  //Locale - From our plugin
773
  $save=true;
774
 
775
  // If this is an autosave, our form has not been submitted, so we don't want to do anything.
776
+ if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || empty($_POST['post_type']))
777
  return $post_id;
778
 
779
+ // If the post is not publicly_queryable (or a page) this doesn't make sense
780
+ $post_type=get_post_type_object(get_post_type($post_id));
781
+ if ($post_type->publicly_queryable || $post_type->name=='page') {
782
+ //OK - Go on
783
+ } else {
784
+ //Not publicly_queryable (or page) -> Go away
785
+ return $post_id;
786
+ }
787
+
788
  // Check if our nonce is set.
789
  if (!isset($_POST['webdados_fb_open_graph_custom_box_nonce']))
790
  $save=false;
812
  update_post_meta($post_id, '_webdados_fb_open_graph_specific_image', $mydata);
813
  }
814
 
815
+ if ($save) {
816
+ //Force Facebook update anyway - Our meta box could be hidden - Not really! We'll just update if we got our metabox
817
+ if (get_post_status($post_id)=='publish' && intval($webdados_fb_open_graph_settings['fb_adv_notify_fb'])==1) {
818
+ $fb_debug_url='http://graph.facebook.com/?id='.urlencode(get_permalink($post_id)).'&scrape=true&method=post';
819
+ $response=wp_remote_get($fb_debug_url);
820
+ if (is_wp_error($response)) {
821
+ $_SESSION['wd_fb_og_updated_error']=1;
822
+ $_SESSION['wd_fb_og_updated_error_message']=__('URL failed:', 'wd-fb-og').' '.$fb_debug_url;
 
 
823
  } else {
824
+ if ($response['response']['code']==200 && intval($webdados_fb_open_graph_settings['fb_adv_supress_fb_notice'])==0) {
825
+ $_SESSION['wd_fb_og_updated']=1;
826
+ } else {
827
+ if ($response['response']['code']==500) {
828
+ $_SESSION['wd_fb_og_updated_error']=1;
829
+ $error=json_decode($response['body']);
830
+ $_SESSION['wd_fb_og_updated_error_message']=__('Facebook returned:', 'wd-fb-og').' '.$error->error->message;
831
+ }
832
  }
833
  }
834
  }
840
  add_action('save_post', 'webdados_fb_open_graph_add_posts_options_box_save');
841
  function webdados_fb_open_graph_facebook_updated() {
842
  if ($screen = get_current_screen()) {
843
+ if (isset($_SESSION['wd_fb_og_updated']) && $_SESSION['wd_fb_og_updated']==1 && $screen->parent_base=='edit' && $screen->base=='post') {
844
+ global $post;
845
  ?>
846
  <div class="updated">
847
+ <p><?php _e('Facebook Open Graph Tags cache updated/purged.', 'wd-fb-og'); ?> <a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode(get_permalink($post->ID));?>" target="_blank"><?php _e('Share this on Facebook', 'wd-fb-og'); ?></a></p>
848
  </div>
849
  <?php
850
  } else {
851
+ if (isset($_SESSION['wd_fb_og_updated_error']) && $_SESSION['wd_fb_og_updated_error']==1 && $screen->parent_base=='edit' && $screen->base=='post') {
852
  ?>
853
  <div class="error">
854
  <p><?php