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

Version Description

  • Fix getting image size when a remote image is used on the post content (thanks contemplate and Steve)
  • Change the way the default settings are load so that even settings that are not user defined will be available (like the new image minimum size which is, for now, "hardcoded")
Download this release

Release Info

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

Code changes from version 1.3.3 to 1.3.4

Files changed (2) hide show
  1. readme.txt +6 -2
  2. wonderm00n-open-graph.php +56 -14
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.3.3
8
 
9
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and other Meta Tags into your WordPress Website for more efficient sharing results.
10
 
@@ -74,8 +74,12 @@ It allows the user to choose which tags are, or not, included and also the defau
74
 
75
  == Changelog ==
76
 
 
 
 
 
77
  = 1.3.3 =
78
- * Fix where servers with allow_url_fopen disabled would not be able to get_image_size for post content or media gallery images
79
 
80
  = 1.3.2 =
81
  * Added Google+ Publisher tag
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.3.4
8
 
9
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and other Meta Tags into your WordPress Website for more efficient sharing results.
10
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.3.4 =
78
+ * Fix getting image size when a remote image is used on the post content (thanks contemplate and Steve)
79
+ * Change the way the default settings are load so that even settings that are not user defined will be available (like the new image minimum size which is, for now, "hardcoded")
80
+
81
  = 1.3.3 =
82
+ * Fix where servers with allow_url_fopen disabled would not be able to get_image_size for post content or media gallery images (thanks joneiseman)
83
 
84
  = 1.3.2 =
85
  * Added Google+ Publisher tag
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.3.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 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.3.3
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
- $wonderm00n_open_graph_plugin_version='1.3.3';
20
  $wonderm00n_open_graph_plugin_name='Facebook Open Graph, Google+ and Twitter Card Tags';
21
  $wonderm00n_open_graph_plugin_settings=array(
22
  'fb_app_id_show',
@@ -62,9 +62,11 @@ $wonderm00n_open_graph_plugin_settings=array(
62
  'fb_image_use_content',
63
  'fb_image_use_media',
64
  'fb_image_use_default',
 
65
  'fb_show_wpseoyoast',
66
  'fb_show_subheading',
67
- 'fb_show_businessdirectoryplugin'
 
68
  );
69
 
70
  //We have to remove canonical NOW because the plugin runs too late - We're also loading the settings which is cool
@@ -426,9 +428,10 @@ add_action("do_feed_rss2","wonderm00n_open_graph_images_on_feed",5,1);
426
 
427
  //Post image
428
  function wonderm00n_open_graph_post_image($fb_image_use_specific=1,$fb_image_use_featured=1, $fb_image_use_content=1, $fb_image_use_media=1, $fb_image_use_default=1, $default_image='') {
429
- global $post;
430
  $thumbdone=false;
431
  $fb_image='';
 
432
  //Specific post image
433
  if (intval($fb_image_use_specific)==1) {
434
  if ($fb_image=trim(get_post_meta($post->ID, '_webdados_fb_open_graph_specific_image', true))) {
@@ -463,19 +466,36 @@ function wonderm00n_open_graph_post_image($fb_image_use_specific=1,$fb_image_use
463
  if (stristr($image, 'http://') || stristr($image, 'https://')) {
464
  //Complete URL - offsite
465
  if (intval(ini_get('allow_url_fopen'))==1) {
466
- //If it's offsite we can't probably getimagesize'it, so we won't use it
467
  $imagetemp=$image;
 
 
 
 
468
  }
469
  } else {
470
  $imagetemp=site_url().$image;
 
 
 
 
 
 
 
471
  }
472
  } else {
473
  //Complete URL - onsite
474
  $imagetemp=$image;
 
 
 
 
 
 
 
475
  }
476
  if ($imagetemp) {
477
- $img_size = getimagesize(ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp));
478
- if ($img_size[0] >= 200 && $img_size[1] >= 200) {
479
  $fb_image=$imagetemp;
480
  $thumbdone=true;
481
  break;
@@ -492,8 +512,15 @@ function wonderm00n_open_graph_post_image($fb_image_use_specific=1,$fb_image_use
492
  if ($images) {
493
  foreach($images as $image) {
494
  $imagetemp=wp_get_attachment_url($image->ID, false);
495
- $img_size = getimagesize(ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp));
496
- if ($img_size[0] >= 200 && $img_size[1] >= 200) {
 
 
 
 
 
 
 
497
  $fb_image=$imagetemp;
498
  $thumbdone=true;
499
  break;
@@ -533,7 +560,7 @@ if ( is_admin() ) {
533
  //Clear WPSEO notices
534
  global $wpdb;
535
  $wpdb->query(
536
- $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'wd_fb_og_wpseo_notice_ignore'")
537
  );
538
  }
539
 
@@ -754,22 +781,37 @@ function wonderm00n_open_graph_default_values() {
754
  'fb_image_use_content' => 1,
755
  'fb_image_use_media' => 1,
756
  'fb_image_use_default' => 1,
757
- 'fb_keep_data_uninstall' => 1
 
758
  );
759
  }
760
  function wonderm00n_open_graph_load_settings() {
 
761
  $defaults=wonderm00n_open_graph_default_values();
762
  //Load the user settings (if they exist)
763
  if ($usersettings=get_option('webdados_fb_open_graph_settings')) {
764
  //Merge the settings "all together now" (yes, it's a Beatles reference)
765
- foreach($usersettings as $key => $value) {
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  //if ($value=='') {
767
  if (strlen(trim($value))==0) {
768
  if (!empty($defaults[$key])) {
769
  $usersettings[$key]=$defaults[$key];
770
  }
771
  }
772
- }
773
  } else {
774
  $usersettings=$defaults;
775
  }
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 1.3.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 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.3.4
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
+ $wonderm00n_open_graph_plugin_version='1.3.4';
20
  $wonderm00n_open_graph_plugin_name='Facebook Open Graph, Google+ and Twitter Card Tags';
21
  $wonderm00n_open_graph_plugin_settings=array(
22
  'fb_app_id_show',
62
  'fb_image_use_content',
63
  'fb_image_use_media',
64
  'fb_image_use_default',
65
+ 'fb_image_min_size',
66
  'fb_show_wpseoyoast',
67
  'fb_show_subheading',
68
+ 'fb_show_businessdirectoryplugin',
69
+ 'fb_keep_data_uninstall'
70
  );
71
 
72
  //We have to remove canonical NOW because the plugin runs too late - We're also loading the settings which is cool
428
 
429
  //Post image
430
  function wonderm00n_open_graph_post_image($fb_image_use_specific=1,$fb_image_use_featured=1, $fb_image_use_content=1, $fb_image_use_media=1, $fb_image_use_default=1, $default_image='') {
431
+ global $post, $webdados_fb_open_graph_settings;
432
  $thumbdone=false;
433
  $fb_image='';
434
+ $minsize=intval($webdados_fb_open_graph_settings['fb_image_min_size']);
435
  //Specific post image
436
  if (intval($fb_image_use_specific)==1) {
437
  if ($fb_image=trim(get_post_meta($post->ID, '_webdados_fb_open_graph_specific_image', true))) {
466
  if (stristr($image, 'http://') || stristr($image, 'https://')) {
467
  //Complete URL - offsite
468
  if (intval(ini_get('allow_url_fopen'))==1) {
 
469
  $imagetemp=$image;
470
+ $imagetempsize=$imagetemp;
471
+ } else {
472
+ //If it's offsite we can't getimagesize'it, so we won't use it
473
+ //We could save a temporary version locally and then getimagesize'it but do we want to do this every single time?
474
  }
475
  } else {
476
  $imagetemp=site_url().$image;
477
+ $imagetempsize=(
478
+ intval(ini_get('allow_url_fopen'))==1
479
+ ?
480
+ $imagetemp
481
+ :
482
+ ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
483
+ );
484
  }
485
  } else {
486
  //Complete URL - onsite
487
  $imagetemp=$image;
488
+ $imagetempsize=(
489
+ intval(ini_get('allow_url_fopen'))==1
490
+ ?
491
+ $imagetemp
492
+ :
493
+ ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
494
+ );
495
  }
496
  if ($imagetemp) {
497
+ $img_size = getimagesize($imagetempsize);
498
+ if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
499
  $fb_image=$imagetemp;
500
  $thumbdone=true;
501
  break;
512
  if ($images) {
513
  foreach($images as $image) {
514
  $imagetemp=wp_get_attachment_url($image->ID, false);
515
+ $imagetempsize=(
516
+ intval(ini_get('allow_url_fopen'))==1
517
+ ?
518
+ $imagetemp
519
+ :
520
+ ABSPATH.str_replace(trailingslashit(site_url()), '', $imagetemp)
521
+ );
522
+ $img_size = getimagesize($imagetempsize);
523
+ if ($img_size[0] >= $minsize && $img_size[1] >= $minsize) {
524
  $fb_image=$imagetemp;
525
  $thumbdone=true;
526
  break;
560
  //Clear WPSEO notices
561
  global $wpdb;
562
  $wpdb->query(
563
+ $wpdb->prepare("DELETE FROM %s WHERE meta_key LIKE 'wd_fb_og_wpseo_notice_ignore'", $wpdb->usermeta)
564
  );
565
  }
566
 
781
  'fb_image_use_content' => 1,
782
  'fb_image_use_media' => 1,
783
  'fb_image_use_default' => 1,
784
+ 'fb_keep_data_uninstall' => 1,
785
+ 'fb_image_min_size' => 200
786
  );
787
  }
788
  function wonderm00n_open_graph_load_settings() {
789
+ global $wonderm00n_open_graph_plugin_settings;
790
  $defaults=wonderm00n_open_graph_default_values();
791
  //Load the user settings (if they exist)
792
  if ($usersettings=get_option('webdados_fb_open_graph_settings')) {
793
  //Merge the settings "all together now" (yes, it's a Beatles reference)
794
+ foreach($wonderm00n_open_graph_plugin_settings as $key) {
795
+ if (isset($usersettings[$key])) {
796
+ if (strlen(trim($usersettings[$key]))==0) {
797
+ if (!empty($defaults[$key])) {
798
+ $usersettings[$key]=$defaults[$key];
799
+ }
800
+ }
801
+ } else {
802
+ if (!empty($defaults[$key])) {
803
+ $usersettings[$key]=$defaults[$key];
804
+ }
805
+ }
806
+ }
807
+ /*foreach($usersettings as $key => $value) {
808
  //if ($value=='') {
809
  if (strlen(trim($value))==0) {
810
  if (!empty($defaults[$key])) {
811
  $usersettings[$key]=$defaults[$key];
812
  }
813
  }
814
+ }*/
815
  } else {
816
  $usersettings=$defaults;
817
  }