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

Version Description

  • Type 'website' was being used as default for all the urls beside posts. This is wrong. According to Facebook Open Graph specification only the homepage should be 'website' and all the other contents must bu 'article'. This was fixed.
  • On Category and Tags pages, their descriptions, if not blank, are used for the og:description tag.
  • If the description comes out empty, the title is used on this tag.
Download this release

Release Info

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

Code changes from version 0.1.6 to 0.1.8

Files changed (2) hide show
  1. readme.txt +31 -20
  2. wonderm00n-open-graph.php +15 -6
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, seo, share, social, meta
5
  Requires at least: 3
6
  Tested up to: 3.2.1
7
- Stable tag: 0.1.6
8
 
9
  This plugin inserts Facebook Open Graph Tags into your WordPress Blog/Website for more effective Facebook sharing results.
10
 
@@ -16,14 +16,14 @@ It allows the user to choose which tags are, or not, included and also the defau
16
 
17
  The tags that this plugin inserts are:
18
 
19
- * **og:app_id** : From settings on the options screen
20
- * **og:admins** : From settings on the options screen
21
- * **og:site_name** : From blog title
22
- * **og:title** : From post/page/archive/tag/... title
23
- * **og:url** : From the post/page permalink
24
- * **og:type** : "article" for posts and pages and "website" for all the others
25
- * **og:description** : From post/page excerpt if it exists, or from post/page content
26
- * **og:image** : From post/page featured/thumbnail image, or if it doesn't exists from the first image in the post content, or if it doesn't exists from the first image on the post media gallery, or if it doesn't exists from the default image defined on the options menu
27
 
28
  == Installation ==
29
 
@@ -33,35 +33,46 @@ The tags that this plugin inserts are:
33
 
34
  == Changelog ==
35
 
 
 
 
 
 
 
 
 
 
 
36
  = 0.1.6 =
37
 
38
- * Settings link now shows up on the plugins list
39
- * Small fix to ensure admin functions only are running when on the admin interface
40
- * Some admin options now only show up when the tag is set to be included
 
41
 
42
  = 0.1.5 =
43
 
44
  * Fixed the way Categories and Tags pages links were being retrieved that would cause an error on WP 3.0
45
- * Added the option to use a Custom text as homepage og:description instead of the Website Tagline
46
- * Fixed a bug that wouldn't allow to uncheck the og:image tag
47
 
48
  = 0.1.4 =
49
 
50
- * Shortcodes are now stripped from og:description
51
- * Changed og:app_id and og:admins not to be included by default
52
 
53
  = 0.1.3 =
54
 
55
- * Just fixing some typos
56
 
57
  = 0.1.2 =
58
 
59
- * Fixing a bug for themes that do not support post thumbnail
60
 
61
  = 0.1.1 =
62
 
63
- * Adding Open Graph Namespace to the HTML tag
64
 
65
  = 0.1 =
66
 
67
- * First release
4
  Tags: facebook, open graph, seo, share, social, meta
5
  Requires at least: 3
6
  Tested up to: 3.2.1
7
+ Stable tag: 0.1.8
8
 
9
  This plugin inserts Facebook Open Graph Tags into your WordPress Blog/Website for more effective Facebook sharing results.
10
 
16
 
17
  The tags that this plugin inserts are:
18
 
19
+ * **og:app_id** : From settings on the options screen.
20
+ * **og:admins** : From settings on the options screen.
21
+ * **og:site_name** : From blog title.
22
+ * **og:title** : From post/page/archive/tag/... title.
23
+ * **og:url** : From the post/page permalink.
24
+ * **og:type** : "website" for the homepage and "article" for all the others.
25
+ * **og:description** : From post/page excerpt if it exists, or from post/page content. From category/tag description on it's pages, if it exists. From tagline, or custom text, on all the others.
26
+ * **og:image** : From post/page featured/thumbnail image, or if it doesn't exists from the first image in the post content, or if it doesn't exists from the first image on the post media gallery, or if it doesn't exists from the default image defined on the options menu.
27
 
28
  == Installation ==
29
 
33
 
34
  == Changelog ==
35
 
36
+ = 0.1.8 =
37
+
38
+ * Type 'website' was being used as default for all the urls beside posts. This is wrong. According to Facebook Open Graph specification only the homepage should be 'website' and all the other contents must bu 'article'. This was fixed.
39
+ * On Category and Tags pages, their descriptions, if not blank, are used for the og:description tag.
40
+ * If the description comes out empty, the title is used on this tag.
41
+
42
+ = 0.1.7 =
43
+
44
+ * Changed the plugin priority, so that it shows up as late as possible on the <head> tag, and it won't be override by another plugin's Open Graph implementation, because other plugins usually don't allow to disable the tags. If you want to keep a specific tag from another plugin, you can just disable that tag on this plugin options.
45
+
46
  = 0.1.6 =
47
 
48
+ * Settings link now shows up on the plugins list.
49
+ * Small fix to ensure admin functions only are running when on the admin interface.
50
+ * Some admin options now only show up when the tag is set to be included.
51
+
52
 
53
  = 0.1.5 =
54
 
55
  * Fixed the way Categories and Tags pages links were being retrieved that would cause an error on WP 3.0
56
+ * Added the option to use a Custom text as homepage og:description instead of the Website Tagline.
57
+ * Fixed a bug that wouldn't allow to uncheck the og:image tag.
58
 
59
  = 0.1.4 =
60
 
61
+ * Shortcodes are now stripped from og:description.
62
+ * Changed og:app_id and og:admins not to be included by default.
63
 
64
  = 0.1.3 =
65
 
66
+ * Just fixing some typos.
67
 
68
  = 0.1.2 =
69
 
70
+ * Fixing a bug for themes that do not support post thumbnail.
71
 
72
  = 0.1.1 =
73
 
74
+ * Adding Open Graph Namespace to the HTML tag.
75
 
76
  = 0.1 =
77
 
78
+ * First release.
wonderm00n-open-graph.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /**
3
  * @package Wonderm00n's Simple Facebook Open Graph Meta Tags
4
- * @version 0.1.6
5
  */
6
  /*
7
  Plugin Name: Wonderm00n's Simple Facebook Open Graph Meta Tags
8
  Plugin URI: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-facebook-open-graph-tags/
9
  Description: This plugin inserts Facebook Open Graph Tags into your Wordpress Blog/Website for better Facebook sharing
10
  Author: Marco Almeida (Wonderm00n)
11
- Version: 0.1.6
12
  Author URI: http://wonderm00n.com
13
  */
14
 
@@ -30,12 +30,12 @@ function wonderm00n_open_graph() {
30
  $fb_image_show=get_option('wonderm00n_open_graph_fb_image_show');
31
  $fb_image=get_option('wonderm00n_open_graph_fb_image');
32
 
 
33
  if (is_singular()) {
34
  //It's a Post or a Page or an attachment page
35
  global $post;
36
  $fb_title=esc_attr(strip_tags(stripslashes($post->post_title)));
37
  $fb_url=get_permalink();
38
- $fb_type='article';
39
  if (trim($post->post_excerpt)!='') {
40
  //If there's an excerpt that's waht we'll use
41
  $fb_desc=trim($post->post_excerpt);
@@ -84,7 +84,6 @@ function wonderm00n_open_graph() {
84
  //Other pages - Defaults
85
  $fb_title=esc_attr(strip_tags(stripslashes(get_bloginfo('name'))));
86
  $fb_url=get_option('siteurl');
87
- $fb_type='website';
88
  switch(trim($fb_desc_homepage)) {
89
  case 'custom':
90
  $fb_desc=esc_attr(strip_tags(stripslashes($fb_desc_homepage_customtext)));
@@ -98,11 +97,15 @@ function wonderm00n_open_graph() {
98
  $fb_title=esc_attr(strip_tags(stripslashes(single_cat_title('', false))));
99
  $term=$wp_query->get_queried_object();
100
  $fb_url=get_term_link($term, $term->taxonomy);
 
 
101
  } else {
102
  if (is_tag()) {
103
  $fb_title=esc_attr(strip_tags(stripslashes(single_tag_title('', false))));
104
  $term=$wp_query->get_queried_object();
105
  $fb_url=get_term_link($term, $term->taxonomy);
 
 
106
  } else {
107
  if (is_tax()) {
108
  $fb_title=esc_attr(strip_tags(stripslashes(single_term_title('', false))));
@@ -133,7 +136,11 @@ function wonderm00n_open_graph() {
133
  }
134
  }
135
  } else {
136
- //Home or others... Defaults already set up there
 
 
 
 
137
  }
138
  }
139
  }
@@ -141,6 +148,8 @@ function wonderm00n_open_graph() {
141
  }
142
  }
143
  }
 
 
144
 
145
  $html.='<!-- START - Wonderm00n\'s Simple Facebook Open Graph Tags -->
146
  ';
@@ -164,7 +173,7 @@ function wonderm00n_open_graph() {
164
  ';
165
  echo $html;
166
  }
167
- add_action('wp_head', 'wonderm00n_open_graph', 1);
168
 
169
  function wonderm00n_open_graph_add_opengraph_namespace( $output ) {
170
  if (stristr($output,'xmlns:og')) {
1
  <?php
2
  /**
3
  * @package Wonderm00n's Simple Facebook Open Graph Meta Tags
4
+ * @version 0.1.8
5
  */
6
  /*
7
  Plugin Name: Wonderm00n's Simple Facebook Open Graph Meta Tags
8
  Plugin URI: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-facebook-open-graph-tags/
9
  Description: This plugin inserts Facebook Open Graph Tags into your Wordpress Blog/Website for better Facebook sharing
10
  Author: Marco Almeida (Wonderm00n)
11
+ Version: 0.1.8
12
  Author URI: http://wonderm00n.com
13
  */
14
 
30
  $fb_image_show=get_option('wonderm00n_open_graph_fb_image_show');
31
  $fb_image=get_option('wonderm00n_open_graph_fb_image');
32
 
33
+ $fb_type='article';
34
  if (is_singular()) {
35
  //It's a Post or a Page or an attachment page
36
  global $post;
37
  $fb_title=esc_attr(strip_tags(stripslashes($post->post_title)));
38
  $fb_url=get_permalink();
 
39
  if (trim($post->post_excerpt)!='') {
40
  //If there's an excerpt that's waht we'll use
41
  $fb_desc=trim($post->post_excerpt);
84
  //Other pages - Defaults
85
  $fb_title=esc_attr(strip_tags(stripslashes(get_bloginfo('name'))));
86
  $fb_url=get_option('siteurl');
 
87
  switch(trim($fb_desc_homepage)) {
88
  case 'custom':
89
  $fb_desc=esc_attr(strip_tags(stripslashes($fb_desc_homepage_customtext)));
97
  $fb_title=esc_attr(strip_tags(stripslashes(single_cat_title('', false))));
98
  $term=$wp_query->get_queried_object();
99
  $fb_url=get_term_link($term, $term->taxonomy);
100
+ $cat_desc=trim(esc_attr(strip_tags(stripslashes(category_description()))));
101
+ if (trim($cat_desc)!='') $fb_desc=$cat_desc;
102
  } else {
103
  if (is_tag()) {
104
  $fb_title=esc_attr(strip_tags(stripslashes(single_tag_title('', false))));
105
  $term=$wp_query->get_queried_object();
106
  $fb_url=get_term_link($term, $term->taxonomy);
107
+ $tag_desc=trim(esc_attr(strip_tags(stripslashes(tag_description()))));
108
+ if (trim($tag_desc)!='') $fb_desc=$tag_desc;
109
  } else {
110
  if (is_tax()) {
111
  $fb_title=esc_attr(strip_tags(stripslashes(single_term_title('', false))));
136
  }
137
  }
138
  } else {
139
+ if (is_front_page()) {
140
+ $fb_type='website';
141
+ } else {
142
+ //Others... Defaults already set up there
143
+ }
144
  }
145
  }
146
  }
148
  }
149
  }
150
  }
151
+ //If no description let's just add the title
152
+ if (trim($fb_desc)=='') $fb_desc=$fb_title;
153
 
154
  $html.='<!-- START - Wonderm00n\'s Simple Facebook Open Graph Tags -->
155
  ';
173
  ';
174
  echo $html;
175
  }
176
+ add_action('wp_head', 'wonderm00n_open_graph', 9999);
177
 
178
  function wonderm00n_open_graph_add_opengraph_namespace( $output ) {
179
  if (stristr($output,'xmlns:og')) {