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

Version Description

  • Added the ability to set/replace the Canonical URL tag. Very important for SEO in the "Business Directory Plugin" integration.
Download this release

Release Info

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

Code changes from version 0.4 to 0.4.1

includes/settings-page.php CHANGED
@@ -22,6 +22,7 @@
22
  update_option('wonderm00n_open_graph_fb_sitename_show', intval($_POST['fb_sitename_show']));
23
  update_option('wonderm00n_open_graph_fb_title_show', intval($_POST['fb_title_show']));
24
  update_option('wonderm00n_open_graph_fb_url_show', intval($_POST['fb_url_show']));
 
25
  update_option('wonderm00n_open_graph_fb_url_add_trailing', intval($_POST['fb_url_add_trailing']));
26
  update_option('wonderm00n_open_graph_fb_type_show', intval($_POST['fb_type_show']));
27
  update_option('wonderm00n_open_graph_fb_type_homepage', trim($_POST['fb_type_homepage']));
@@ -189,11 +190,18 @@
189
  <input type="checkbox" name="fb_url_show" id="fb_url_show" value="1" <?php echo (intval($fb_url_show)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlOptions();"/>
190
  </td>
191
  </tr>
 
 
 
 
 
 
192
  <tr class="fb_url_options">
193
  <th scope="row" nowrap="nowrap">Add trailing slash at the end:</th>
194
  <td>
195
  <input type="checkbox" name="fb_url_add_trailing" id="fb_url_add_trailing" value="1" <?php echo (intval($fb_url_add_trailing)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlTrail();"/>
196
- (on the homepage will be: <i><?php echo get_option('siteurl'); ?><span id="fb_url_add_trailing_example">/</span></i>)
 
197
  </td>
198
  </tr>
199
  <tr>
@@ -204,7 +212,8 @@
204
  <th scope="row" nowrap="nowrap">Include Type (og:type) tag?</th>
205
  <td>
206
  <input type="checkbox" name="fb_type_show" id="fb_type_show" value="1" <?php echo (intval($fb_type_show)==1 ? ' checked="checked"' : ''); ?> onclick="showTypeOptions();"/>
207
- (will be &quot;article&quot; for posts and pages and &quot;website&quot; or &quot;blog&quot; for the homepage)
 
208
  </td>
209
  </tr>
210
  <tr class="fb_type_options">
@@ -230,7 +239,9 @@
230
  <tr class="fb_description_options">
231
  <th scope="row" nowrap="nowrap">Description maximum length:</th>
232
  <td>
233
- <input type="text" name="fb_desc_chars" id="fb_desc_chars" size="3" maxlength="3" value="<?php echo (intval($fb_desc_chars)>0 ? intval($fb_desc_chars) : ''); ?>"/> characters, 0 or blank for no maximum length
 
 
234
  </td>
235
  </tr>
236
  <tr class="fb_description_options">
@@ -269,7 +280,8 @@
269
  <th scope="row" nowrap="nowrap">Also add image to RSS/RSS2 feeds?</th>
270
  <td>
271
  <input type="checkbox" name="fb_image_rss" id="fb_image_rss" value="1" <?php echo (intval($fb_image_rss)==1 ? ' checked="checked"' : ''); ?> onclick="showImageOptions();"/>
272
- (for auto-posting apps like RSS Graffiti, twitterfeed, ...)
 
273
  </td>
274
  </tr>
275
  <tr class="fb_image_options">
@@ -323,6 +335,8 @@
323
  <th scope="row" nowrap="nowrap">Use listing BDP listing contents as OG tags?</th>
324
  <td>
325
  <input type="checkbox" name="fb_show_businessdirectoryplugin" id="fb_show_businessdirectoryplugin" value="1" <?php echo (intval($fb_show_businessdirectoryplugin)==1 ? ' checked="checked"' : ''); ?>/>
 
 
326
  </td>
327
  </tr>
328
  </table>
22
  update_option('wonderm00n_open_graph_fb_sitename_show', intval($_POST['fb_sitename_show']));
23
  update_option('wonderm00n_open_graph_fb_title_show', intval($_POST['fb_title_show']));
24
  update_option('wonderm00n_open_graph_fb_url_show', intval($_POST['fb_url_show']));
25
+ update_option('wonderm00n_open_graph_fb_url_canonical', intval($_POST['fb_url_canonical']));
26
  update_option('wonderm00n_open_graph_fb_url_add_trailing', intval($_POST['fb_url_add_trailing']));
27
  update_option('wonderm00n_open_graph_fb_type_show', intval($_POST['fb_type_show']));
28
  update_option('wonderm00n_open_graph_fb_type_homepage', trim($_POST['fb_type_homepage']));
190
  <input type="checkbox" name="fb_url_show" id="fb_url_show" value="1" <?php echo (intval($fb_url_show)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlOptions();"/>
191
  </td>
192
  </tr>
193
+ <tr class="fb_url_options">
194
+ <th scope="row" nowrap="nowrap">Also set Canonical URL:</th>
195
+ <td>
196
+ <input type="checkbox" name="fb_url_canonical" id="fb_url_canonical" value="1" <?php echo (intval($fb_url_canonical)==1 ? ' checked="checked"' : ''); ?>/>
197
+ </td>
198
+ </tr>
199
  <tr class="fb_url_options">
200
  <th scope="row" nowrap="nowrap">Add trailing slash at the end:</th>
201
  <td>
202
  <input type="checkbox" name="fb_url_add_trailing" id="fb_url_add_trailing" value="1" <?php echo (intval($fb_url_add_trailing)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlTrail();"/>
203
+ <br/>
204
+ On the homepage will be: <i><?php echo get_option('siteurl'); ?><span id="fb_url_add_trailing_example">/</span></i>
205
  </td>
206
  </tr>
207
  <tr>
212
  <th scope="row" nowrap="nowrap">Include Type (og:type) tag?</th>
213
  <td>
214
  <input type="checkbox" name="fb_type_show" id="fb_type_show" value="1" <?php echo (intval($fb_type_show)==1 ? ' checked="checked"' : ''); ?> onclick="showTypeOptions();"/>
215
+ <br/>
216
+ Will be &quot;article&quot; for posts and pages and &quot;website&quot; or &quot;blog&quot; for the homepage
217
  </td>
218
  </tr>
219
  <tr class="fb_type_options">
239
  <tr class="fb_description_options">
240
  <th scope="row" nowrap="nowrap">Description maximum length:</th>
241
  <td>
242
+ <input type="text" name="fb_desc_chars" id="fb_desc_chars" size="3" maxlength="3" value="<?php echo (intval($fb_desc_chars)>0 ? intval($fb_desc_chars) : ''); ?>"/> characters,
243
+ <br/>
244
+ 0 or blank for no maximum length
245
  </td>
246
  </tr>
247
  <tr class="fb_description_options">
280
  <th scope="row" nowrap="nowrap">Also add image to RSS/RSS2 feeds?</th>
281
  <td>
282
  <input type="checkbox" name="fb_image_rss" id="fb_image_rss" value="1" <?php echo (intval($fb_image_rss)==1 ? ' checked="checked"' : ''); ?> onclick="showImageOptions();"/>
283
+ <br/>
284
+ For auto-posting apps like RSS Graffiti, twitterfeed, ...
285
  </td>
286
  </tr>
287
  <tr class="fb_image_options">
335
  <th scope="row" nowrap="nowrap">Use listing BDP listing contents as OG tags?</th>
336
  <td>
337
  <input type="checkbox" name="fb_show_businessdirectoryplugin" id="fb_show_businessdirectoryplugin" value="1" <?php echo (intval($fb_show_businessdirectoryplugin)==1 ? ' checked="checked"' : ''); ?>/>
338
+ <br/>
339
+ Setting "Include URL", "Also set Canonical URL", "Include Description" and "Include Image" options above is HIGHLY recommended
340
  </td>
341
  </tr>
342
  </table>
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.5
7
- Stable tag: 0.4
8
 
9
  This plugin inserts Facebook Open Graph Tags into your WordPress Blog/Website for more effective Facebook sharing results.
10
 
@@ -35,6 +35,10 @@ The tags that this plugin inserts are:
35
 
36
  == Changelog ==
37
 
 
 
 
 
38
  = 0.4 =
39
 
40
  * "Business Directory Plugin" plugin integration. It's now possible to populate "og:title", "og:url", "og:description" and "og:image" tags with each listing details. If a featured image is set it will be used. If not, the listing main image is used.
4
  Tags: facebook, open graph, seo, share, social, meta
5
  Requires at least: 3
6
  Tested up to: 3.5
7
+ Stable tag: 0.4.1
8
 
9
  This plugin inserts Facebook Open Graph Tags into your WordPress Blog/Website for more effective Facebook sharing results.
10
 
35
 
36
  == Changelog ==
37
 
38
+ = 0.4.1 =
39
+
40
+ * Added the ability to set/replace the Canonical URL tag. Very important for SEO in the "Business Directory Plugin" integration.
41
+
42
  = 0.4 =
43
 
44
  * "Business Directory Plugin" plugin integration. It's now possible to populate "og:title", "og:url", "og:description" and "og:image" tags with each listing details. If a featured image is set it will be used. If not, the listing main image is used.
wonderm00n-open-graph.php CHANGED
@@ -1,18 +1,18 @@
1
  <?php
2
  /**
3
  * @package Wonderm00n's Simple Facebook Open Graph Meta Tags
4
- * @version 0.4
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.4
12
  Author URI: http://wonderm00n.com
13
  */
14
 
15
- $wonderm00n_open_graph_plugin_version='0.4';
16
  $wonderm00n_open_graph_plugin_settings=array(
17
  'fb_app_id_show',
18
  'fb_app_id',
@@ -23,6 +23,7 @@ $wonderm00n_open_graph_plugin_settings=array(
23
  'fb_sitename_show',
24
  'fb_title_show',
25
  'fb_url_show',
 
26
  'fb_url_add_trailing',
27
  'fb_type_show',
28
  'fb_type_homepage',
@@ -244,8 +245,15 @@ function wonderm00n_open_graph() {
244
  ';
245
  if (intval($fb_title_show)==1) $html.='<meta property="og:title" content="'.trim($fb_title).'" />
246
  ';
247
- if (intval($fb_url_show)==1) $html.='<meta property="og:url" content="'.trim(esc_attr($fb_url)).'" />
 
248
  ';
 
 
 
 
 
 
249
  if (intval($fb_type_show)==1) $html.='<meta property="og:type" content="'.trim(esc_attr($fb_type)).'" />
250
  ';
251
  if (intval($fb_desc_show)==1) $html.='<meta property="og:description" content="'.trim($fb_desc).'" />
@@ -404,6 +412,7 @@ if ( is_admin() ) {
404
  'fb_sitename_show' => 1,
405
  'fb_title_show' => 1,
406
  'fb_url_show' => 1,
 
407
  'fb_type_show' => 1,
408
  'fb_desc_show' => 1,
409
  'fb_desc_chars' => 300,
1
  <?php
2
  /**
3
  * @package Wonderm00n's Simple Facebook Open Graph Meta Tags
4
+ * @version 0.4.1
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.4.1
12
  Author URI: http://wonderm00n.com
13
  */
14
 
15
+ $wonderm00n_open_graph_plugin_version='0.4.1';
16
  $wonderm00n_open_graph_plugin_settings=array(
17
  'fb_app_id_show',
18
  'fb_app_id',
23
  'fb_sitename_show',
24
  'fb_title_show',
25
  'fb_url_show',
26
+ 'fb_url_canonical',
27
  'fb_url_add_trailing',
28
  'fb_type_show',
29
  'fb_type_homepage',
245
  ';
246
  if (intval($fb_title_show)==1) $html.='<meta property="og:title" content="'.trim($fb_title).'" />
247
  ';
248
+ if (intval($fb_url_show)==1) {
249
+ $html.='<meta property="og:url" content="'.trim(esc_attr($fb_url)).'" />
250
  ';
251
+ if (intval($fb_url_canonical)==1) {
252
+ remove_action('wp_head', 'rel_canonical'); //Try to remove the old canonical URL - Not working I guess...
253
+ $html.='<link rel="canonical" href="'.trim(esc_attr($fb_url)).'" />
254
+ ';
255
+ }
256
+ }
257
  if (intval($fb_type_show)==1) $html.='<meta property="og:type" content="'.trim(esc_attr($fb_type)).'" />
258
  ';
259
  if (intval($fb_desc_show)==1) $html.='<meta property="og:description" content="'.trim($fb_desc).'" />
412
  'fb_sitename_show' => 1,
413
  'fb_title_show' => 1,
414
  'fb_url_show' => 1,
415
+ 'fb_url_canonical' => 1,
416
  'fb_type_show' => 1,
417
  'fb_desc_show' => 1,
418
  'fb_desc_chars' => 300,