All In One Schema Rich Snippets - Version 1.0.2

Version Description

  • Added: RDFa Breadcrumbs Plugin is now a part of All in One Schema.org Rich Snippets !
  • Added: Star rating and review for recipe
  • Bug fixes for recipe type
  • Bug fix on post update
Download this release

Release Info

Developer brainstormforce
Plugin Icon 128x128 All In One Schema Rich Snippets
Version 1.0.2
Comparing to
See all releases

Code changes from version 1.0.1 to 1.0.2

admin/index.php CHANGED
@@ -3,6 +3,7 @@
3
  function bsf_admin_styles() {
4
  // wp_enqueue_style( 'ui_style' );
5
  wp_enqueue_style( 'star_style' );
 
6
  wp_enqueue_script( 'bsf_jquery' );
7
  wp_enqueue_script( 'bsf_jquery_ui' );
8
  wp_enqueue_script( 'bsf_jquery_star' );
@@ -11,24 +12,26 @@ function bsf_admin_styles() {
11
  //The Main Admin Dashboard for Rich Snippets Plugin
12
  function rich_snippet_dashboard() {
13
  $plugins_url = plugins_url();
 
14
  echo '<div class="wrap">';
15
  echo '<div id="star-icons-32" class="icon32"></div><h2>'.__("All in One Rich Snippets Dashboard","rich-snippets").'</h2>';
16
  echo '<div class="clear"></div><div id="tabs">';
17
  echo '<ul class="subsubsub">
18
  <li class="active"><a id="t1" class="current" href="#tab-1">'.__(" How to Use","rich-snippets").'</a> |</li>
19
  <li class="active"><a id="t2" class="" href="#tab-2">'.__("FAQs","rich-snippets").'</a> |</li>
20
- <li class="active"><a id="t3" class="" href="#tab-3">'.__("Get in Touch","rich-snippets").'</a></li>
 
21
  </ul>
22
  <div class="clear"></div>
23
  <div id="tab-1">
24
  <table class="wp-list-table widefat fixed">
25
  <thead> <tr><th>'.__("<span>Usage Instructions</span>","rich-snippets").'</th></tr></thead>
26
  <tbody><tr><td><h3>'.__("Notice that you have a new meta box below the field where you enter content for your post or page.","rich-snippets").'</h3>
27
- <img src="'.plugins_url("/all-in-one-schema.org-rich-snippets/screenshot-1.png").'"/>
28
  <h3>'.__("Select type of your content.","rich-snippets").'</h3>
29
- <img src="'.plugins_url("/all-in-one-schema.org-rich-snippets/screenshot-2.png").'"/>
30
  <h3>'.__("Fill in as much data as you can","rich-snippets").'</h3>
31
- <img src="'.plugins_url("/all-in-one-schema.org-rich-snippets/screenshot-3.png").'"/>
32
  <h3>'.__("And publish! Isn't that simple?").'</h3>
33
  </td></tr></tbody>
34
  </table>
@@ -56,6 +59,56 @@ function rich_snippet_dashboard() {
56
  '.__("<p>Optionally, you can mail us on : </p><p><a class='button-primary' href='mailto:contact@brainstormforce.com'>contact@brainstormforce.com</a></p>").'</td></tr></tbody>
57
  </table>
58
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  </div> ';
60
  echo '<div id="sidebar"></div>';
61
  echo '
@@ -66,19 +119,44 @@ function rich_snippet_dashboard() {
66
  jQuery(this).toggleClass("current");
67
  jQuery("#t2").removeClass("current");
68
  jQuery("#t3").removeClass("current");
 
69
  });
70
  jQuery( "#t2" ).click(function() {
71
  jQuery(this).toggleClass("current");
72
  jQuery("#t1").removeClass("current");
73
  jQuery("#t3").removeClass("current");
 
74
  });
75
  jQuery( "#t3" ).click(function() {
76
  jQuery(this).toggleClass("current");
77
  jQuery("#t2").removeClass("current");
78
  jQuery("#t1").removeClass("current");
79
-
 
 
 
 
 
 
80
  });
81
  });
82
  </script>';
83
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  ?>
3
  function bsf_admin_styles() {
4
  // wp_enqueue_style( 'ui_style' );
5
  wp_enqueue_style( 'star_style' );
6
+ wp_enqueue_style( 'meta_style' );
7
  wp_enqueue_script( 'bsf_jquery' );
8
  wp_enqueue_script( 'bsf_jquery_ui' );
9
  wp_enqueue_script( 'bsf_jquery_star' );
12
  //The Main Admin Dashboard for Rich Snippets Plugin
13
  function rich_snippet_dashboard() {
14
  $plugins_url = plugins_url();
15
+ $args = get_option('rdfa_options');
16
  echo '<div class="wrap">';
17
  echo '<div id="star-icons-32" class="icon32"></div><h2>'.__("All in One Rich Snippets Dashboard","rich-snippets").'</h2>';
18
  echo '<div class="clear"></div><div id="tabs">';
19
  echo '<ul class="subsubsub">
20
  <li class="active"><a id="t1" class="current" href="#tab-1">'.__(" How to Use","rich-snippets").'</a> |</li>
21
  <li class="active"><a id="t2" class="" href="#tab-2">'.__("FAQs","rich-snippets").'</a> |</li>
22
+ <li class="active"><a id="t3" class="" href="#tab-3">'.__("Get in Touch","rich-snippets").'</a> |</li>
23
+ <li class="active"><a id="t4" class="" href="#tab-4">'.__("Breadcrumbs","rich-snippets").'</a></li>
24
  </ul>
25
  <div class="clear"></div>
26
  <div id="tab-1">
27
  <table class="wp-list-table widefat fixed">
28
  <thead> <tr><th>'.__("<span>Usage Instructions</span>","rich-snippets").'</th></tr></thead>
29
  <tbody><tr><td><h3>'.__("Notice that you have a new meta box below the field where you enter content for your post or page.","rich-snippets").'</h3>
30
+ <img src="'.plugins_url("/all-in-one-schemaorg-rich-snippets/screenshot-1.png").'"/>
31
  <h3>'.__("Select type of your content.","rich-snippets").'</h3>
32
+ <img src="'.plugins_url("/all-in-one-schemaorg-rich-snippets/screenshot-2.png").'"/>
33
  <h3>'.__("Fill in as much data as you can","rich-snippets").'</h3>
34
+ <img src="'.plugins_url("/all-in-one-schemaorg-rich-snippets/screenshot-3.png").'"/>
35
  <h3>'.__("And publish! Isn't that simple?").'</h3>
36
  </td></tr></tbody>
37
  </table>
59
  '.__("<p>Optionally, you can mail us on : </p><p><a class='button-primary' href='mailto:contact@brainstormforce.com'>contact@brainstormforce.com</a></p>").'</td></tr></tbody>
60
  </table>
61
  </div>
62
+ <div id="tab-4">
63
+ <table class="wp-list-table widefat fixed">
64
+ <thead> <tr><th>'.__("<span>Configure Breadcrumbs Options</span>","rich-snippets").'</th></tr></thead>
65
+ <tbody>
66
+ <tr><td>
67
+ <form method="POST" action="">
68
+ '.wp_nonce_field("rdfa_breadcrumb_option").'
69
+ <table class="form-table bsf_metabox">
70
+ <tr valign="top">
71
+ <th scope="row" class="bsf_metabox">'.__("Prefix", "rich-snippets").'</th>
72
+ <td class="bsf_metabox"><input type="text" name="prefix" value="'.$args['prefix'].'" /></td>
73
+ </tr>
74
+ <tr valign="top">
75
+ <th class="bsf_metabox" scope="row">'.__("Suffix", "rich-snippets").'</th>
76
+ <td class="bsf_metabox"><input type="text" name="suffix" value="'.$args['suffix'].'" /></td>
77
+ </tr>
78
+ <tr valign="top">
79
+ <th class="bsf_metabox" scope="row">'.__("Title", "rich-snippets").'</th>
80
+ <td class="bsf_metabox"><input type="text" name="title" value="'.$args['title'].'" /></td>
81
+ </tr>
82
+ <tr valign="top">
83
+ <th class="bsf_metabox" scope="row">'.__("Home Title", "rich-snippets").'</th>
84
+ <td class="bsf_metabox"><input type="text" name="home_title" value="'.$args['home_title'].'" /></td>
85
+ </tr>
86
+ <tr valign="top">
87
+ <th class="bsf_metabox" scope="row">'.__("Breadcrumb Seperator", "rich-snippets").'</th>
88
+ <td class="bsf_metabox"><input type="text" name="separator" value="'.$args['separator'].'" /></td>
89
+ </tr>
90
+ <tr valign="top">
91
+ <th class="bsf_metabox" scope="row"></th>
92
+ <td class="bsf_metabox"><input type="submit" name="submit" value="'.__("Update Options", "rich-snippets").'" class="button-primary" /></td>
93
+ </tr>
94
+ <tr><td></td>
95
+ <td>
96
+ <pre>
97
+ &lt;?php
98
+ if(function_exists("bsf_breadcrumb"))
99
+ {
100
+ bsf_breadcrumb();
101
+ }
102
+ ?&gt;
103
+ </pre>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+ </form>
108
+ </td></tr>
109
+ </tbody>
110
+ </table>
111
+ </div>
112
  </div> ';
113
  echo '<div id="sidebar"></div>';
114
  echo '
119
  jQuery(this).toggleClass("current");
120
  jQuery("#t2").removeClass("current");
121
  jQuery("#t3").removeClass("current");
122
+ jQuery("#t4").removeClass("current");
123
  });
124
  jQuery( "#t2" ).click(function() {
125
  jQuery(this).toggleClass("current");
126
  jQuery("#t1").removeClass("current");
127
  jQuery("#t3").removeClass("current");
128
+ jQuery("#t4").removeClass("current");
129
  });
130
  jQuery( "#t3" ).click(function() {
131
  jQuery(this).toggleClass("current");
132
  jQuery("#t2").removeClass("current");
133
  jQuery("#t1").removeClass("current");
134
+ jQuery("#t4").removeClass("current");
135
+ });
136
+ jQuery( "#t4" ).click(function() {
137
+ jQuery(this).toggleClass("current");
138
+ jQuery("#t2").removeClass("current");
139
+ jQuery("#t1").removeClass("current");
140
+ jQuery("#t3").removeClass("current");
141
  });
142
  });
143
  </script>';
144
  }
145
+ if(isset($_POST['submit'])) {
146
+
147
+ check_admin_referer('rdfa_breadcrumb_option');
148
+
149
+ foreach(array('prefix','suffix','title','home_title','separator') as $option) {
150
+ if(isset($_POST[$option])) {
151
+ $args[$option] = $_POST[$option];
152
+ }
153
+ }
154
+ if(update_option('rdfa_options',$args)) {
155
+ echo '<div class="updated"><p>' . __('Success! Your changes were successfully saved!', 'rich-snippets') . '</p></div>';
156
+ } else {
157
+ echo '<div class="error"><p>' . __('Sorry, But Your Changes Are Not Saved!', 'rich-snippets') . '</p></div>';
158
+ }
159
+ $args = get_option('rdfa_options');
160
+ }
161
+
162
  ?>
css/rating.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */
2
+ div.rating-cancel,div.star-rating{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}
3
+ div.rating-cancel,div.rating-cancel a{background:url(delete.gif) no-repeat 0 -16px}
4
+ div.star-rating,div.star-rating a{background:url(star.gif) no-repeat 0 0px}
5
+ div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0}
6
+ div.star-rating-on a{background-position:0 -16px!important}
7
+ div.star-rating-hover a{background-position:0 -32px}
8
+ /* Read Only CSS */
9
+ div.star-rating-readonly a{cursor:default !important}
10
+ /* Partial Star CSS */
11
+ div.star-rating{background:transparent!important;overflow:hidden!important}
12
+ div.star-block{float: left; width: 100%; margin-bottom: 15px}
13
+ p#star-block{float: left; width: 100%; margin-bottom: 10px}
14
+ /* END jQuery.Rating Plugin CSS */
functions.php CHANGED
@@ -27,21 +27,21 @@ function display_rich_snippet($content) {
27
  // echo $post->ID;
28
  $review = $content;
29
  $review .= '<div><h3>Review Summary :</h3></div>';
30
- $review .= "<div xmlns:v='http://rdf.data-vocabulary.org/#' typeof='v:Review'><table style='width:100%;'>";
31
  $item = get_post_meta( $post->ID, '_bsf_item_name', true );
32
  $rating = get_post_meta( $post->ID, '_bsf_rating', true );
33
  $desc = get_post_meta( $post->ID, '_bsf_item_desc', true );
34
  $reviewer = get_post_meta( $post->ID, '_bsf_item_reviewer', true);
35
  $post_date = get_the_date('Y-m-d');
36
  if(trim($reviewer) != "")
37
- $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Reviewer : </td><td><span property='v:reviewer'>".$reviewer."</span></td></tr>";
38
- $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Review Date : </td><td><span property='v:dtreviewed' content='".$post_date."'>".$post_date."</span></td></tr>";
39
  if(trim($item) != "")
40
- $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Item Name : </td><td><span property='v:itemreviewed'>".$item."</span></td></tr>";
41
  if(trim($rating) != "")
42
- $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Author Rating: </td><td><span property='v:rating'>".$rating."</span></td></tr>";
43
  if(trim($desc) != "")
44
- $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Item Description: </td><td><span property='v:summary'>".$desc."</span></td></tr>";
45
  $review .= "</table></div>";
46
  return $review;
47
  }
@@ -230,8 +230,8 @@ function display_rich_snippet($content) {
230
  {
231
  global $post;
232
  $recipe = $content;
233
- $recipe .= '<div><h3>Recipe in Short :</h3></div>';
234
- $recipe .= '<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Recipe"><table id="tbl-rich-snippet">';
235
  $recipes_name = get_post_meta( $post->ID, '_bsf_recipes_name', true );
236
  $recipes_preptime = get_post_meta( $post->ID, '_bsf_recipes_preptime', true );
237
  $recipes_cooktime = get_post_meta( $post->ID, '_bsf_recipes_cooktime', true );
@@ -239,22 +239,26 @@ function display_rich_snippet($content) {
239
  $recipes_photo = get_post_meta( $post->ID, '_bsf_recipes_photo', true );
240
  $recipes_desc = get_post_meta( $post->ID, '_bsf_recipes_desc', true );
241
  $recipes_ingredient = get_post_meta( $post->ID, '_bsf_recipes_ingredient', true );
 
 
 
242
  if(trim($recipes_photo) != "")
243
- $recipe .= '<tr class="tbl-bsf-tr"><td rowspan="8" style="padding:5px; width:180px;"><img width="160" height="160" src="'.$recipes_photo.'" rel="v:photo" /></td></tr>';
244
  if(trim($recipes_name) != "")
245
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Recipe : <h1 property="v:name">'.$recipes_name.'</h1></td></tr>';
246
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Published on : <span property="v:published" content="'.get_the_date('Y-m-d').'">'.get_the_date('Y-m-d').'</span></td></tr>';
247
  if(trim($recipes_preptime) != "")
248
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Prep. Time : <span property="v:prepTime" content="'.$recipes_preptime.'">'.$recipes_preptime.'</span></td></tr>';
249
  if(trim($recipes_cooktime) != "")
250
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Cook Time : <span property="v:cookTime" content="'.$recipes_cooktime.'">'.$recipes_cooktime.'</span></td></tr>';
251
  if(trim($recipes_totaltime) != "")
252
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Total Time : '.$recipes_totaltime.'</td></tr>';
253
  if(trim($recipes_ingredient) != "")
254
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Ingredients Used : '.$recipes_ingredient.'</td></tr>';
255
  if(trim($recipes_desc) != "")
256
- $recipe .= '<tr class="tbl-bsf-tr"><td></td><td class="tbl-bsf-td">Summary : <span property="v:summary">'.$recipes_desc.'</span></td></tr>';
257
- $recipe .= '</table></div>';
 
258
  return $recipe;
259
  }
260
  else if($type == '8')
@@ -320,4 +324,46 @@ function display_rich_snippet($content) {
320
  }
321
  //Filter the content and return with rich snippet output
322
  add_filter('the_content','display_rich_snippet');
323
- require_once('meta-boxes.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  // echo $post->ID;
28
  $review = $content;
29
  $review .= '<div><h3>Review Summary :</h3></div>';
30
+ $review .= '<div itemscope itemtype="http://data-vocabulary.org/Review"><table style="width:100%;">';
31
  $item = get_post_meta( $post->ID, '_bsf_item_name', true );
32
  $rating = get_post_meta( $post->ID, '_bsf_rating', true );
33
  $desc = get_post_meta( $post->ID, '_bsf_item_desc', true );
34
  $reviewer = get_post_meta( $post->ID, '_bsf_item_reviewer', true);
35
  $post_date = get_the_date('Y-m-d');
36
  if(trim($reviewer) != "")
37
+ $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Reviewer : </td><td><span itemprop='reviewer'>".$reviewer."</span></td></tr>";
38
+ $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Review Date : </td><td><time itemprop='dtreviewed' datetime='".$post_date."'>".$post_date."</time></td></tr>";
39
  if(trim($item) != "")
40
+ $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Item Name : </td><td><span itemprop='itemreviewed'>".$item."</span></td></tr>";
41
  if(trim($rating) != "")
42
+ $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Author Rating: </td><td><span itemprop='rating'>".$rating."</span></td></tr>";
43
  if(trim($desc) != "")
44
+ $review .= "<tr style='border:1px solid #ddd;'><td style='padding:5px;'>Item Description: </td><td><span itemprop='summary'>".$desc."</span></td></tr>";
45
  $review .= "</table></div>";
46
  return $review;
47
  }
230
  {
231
  global $post;
232
  $recipe = $content;
233
+ $recipe .= '<h3>Recipe in Short :</h3>';
234
+ $recipe .= '<div itemscope itemtype="http://data-vocabulary.org/Recipe">';
235
  $recipes_name = get_post_meta( $post->ID, '_bsf_recipes_name', true );
236
  $recipes_preptime = get_post_meta( $post->ID, '_bsf_recipes_preptime', true );
237
  $recipes_cooktime = get_post_meta( $post->ID, '_bsf_recipes_cooktime', true );
239
  $recipes_photo = get_post_meta( $post->ID, '_bsf_recipes_photo', true );
240
  $recipes_desc = get_post_meta( $post->ID, '_bsf_recipes_desc', true );
241
  $recipes_ingredient = get_post_meta( $post->ID, '_bsf_recipes_ingredient', true );
242
+ $comments = wp_count_comments();
243
+ $count = $comments->approved;
244
+ $agregate = average_rating();
245
  if(trim($recipes_photo) != "")
246
+ $recipe .= '<img class="alignleft" itemprop="photo" width="160" height="160" src="'.$recipes_photo.'"/>';
247
  if(trim($recipes_name) != "")
248
+ $recipe .= '<strong>Recipe Name:</strong> <span itemprop="name">'.$recipes_name.'</span><br/>';
249
+ $recipe .= '<strong>Published on : </strong><time datetime="'.get_the_date('Y-m-d').'" itemprop="published">'.get_the_date('Y-m-d').'</time><br/>';
250
  if(trim($recipes_preptime) != "")
251
+ $recipe .= '<strong>Prep. Time : </strong><time datetime="PT'.$recipes_preptime.'" itemprop="prepTime">'.$recipes_preptime.'</time><br/>';
252
  if(trim($recipes_cooktime) != "")
253
+ $recipe .= '<strong>Cook Time : </strong><time datetime="PT'.$recipes_cooktime.'" itemprop="cookTime">'.$recipes_cooktime.'</span><br/> ';
254
  if(trim($recipes_totaltime) != "")
255
+ $recipe .= '<strong>Total Time :</strong><time datetime="PT'.$recipes_totaltime.'" itemprop="cookTime">'.$recipes_totaltime.'</span><br/><br/>';
256
  if(trim($recipes_ingredient) != "")
257
+ $recipe .= '<strong>Ingredients Used : </strong>'.$recipes_ingredient.'<br/>';
258
  if(trim($recipes_desc) != "")
259
+ $recipe .= '<strong>Summary : </strong><span itemprop="summary">'.$recipes_desc.'</span><br/>';
260
+ $recipe .= '<strong>Average Rating : </strong><span itemprop="review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate"><span itemprop="rating">'.$agregate.'</span> Based on <span itemprop="count">'.$count.'</span> Reviews</span></div>';
261
+ // $recipe .= display_rating();
262
  return $recipe;
263
  }
264
  else if($type == '8')
324
  }
325
  //Filter the content and return with rich snippet output
326
  add_filter('the_content','display_rich_snippet');
327
+ require_once('meta-boxes.php');
328
+
329
+ wp_enqueue_style('rating.css', plugin_dir_url(__FILE__) . 'css/jquery.rating.css');
330
+ wp_enqueue_script('jquery');
331
+ wp_enqueue_script('jquery.rating', plugin_dir_url(__FILE__) . 'js/jquery.rating.min.js', array('jquery'));
332
+
333
+ function display_rating() {
334
+ $rating .= '<br/><strong>Your Rating:</strong><div class="star-blocks">';
335
+ $rating .= '<input type="radio" name="star-review" class="star star-1" value="1"/>';
336
+ $rating .= '<input type="radio" name="star-review" class="star star-2" value="2"/>';
337
+ $rating .= '<input type="radio" name="star-review" class="star star-3" value="3"/>';
338
+ $rating .= '<input type="radio" name="star-review" class="star star-4" value="4"/>';
339
+ $rating .= '<input type="radio" name="star-review" class="star star-5" value="5"/>';
340
+ $rating .= '</div>';
341
+ return $rating;
342
+ }
343
+ function average_rating() {
344
+ global $wpdb;
345
+ $post_id = get_the_ID();
346
+ $ratings = $wpdb->get_results("
347
+
348
+ SELECT $wpdb->commentmeta.meta_value
349
+ FROM $wpdb->commentmeta
350
+ INNER JOIN $wpdb->comments on $wpdb->comments.comment_id=$wpdb->commentmeta.comment_id
351
+ WHERE $wpdb->commentmeta.meta_key='rating'
352
+ AND $wpdb->comments.comment_post_id=$post_id
353
+ AND $wpdb->comments.comment_approved =1
354
+
355
+ ");
356
+ $counter = 0;
357
+ $average_rating = 0;
358
+ if ($ratings) {
359
+ foreach ($ratings as $rating) {
360
+ $average_rating = $average_rating + $rating->meta_value;
361
+ $counter++;
362
+ }
363
+ //round the average to the nearast 1/2 point
364
+ return (round(($average_rating/$counter)*2,0)/2);
365
+ } else {
366
+ //no ratings
367
+ return 'no rating';
368
+ }
369
+ }
images/1star.gif ADDED
Binary file
images/2star.gif ADDED
Binary file
images/3star.gif ADDED
Binary file
images/4star.gif ADDED
Binary file
images/5star.gif ADDED
Binary file
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: All In One Schema.org Rich Snippets
4
  Plugin URI: http://www.brainstormforce.com
5
  Description: The All in One Rich Snippets gives the power to the blog author to control the rich snippets to be shown in the search results by the search engines.
6
- Version: 1.0.1
7
  Author: Brainstorm Force
8
  Author URI: http://www.brainstormforce.com
9
  License: GPL2
@@ -41,6 +41,8 @@ if ( !class_exists( "RichSnippets" ) )
41
 
42
  add_action( 'admin_init', array( $this, 'set_styles' ));
43
 
 
 
44
  add_action( 'wp_head', array($this, 'frontend_style') );
45
 
46
  add_filter('plugins_loaded', array( $this, 'rich_snippet_translation'));
@@ -51,8 +53,30 @@ if ( !class_exists( "RichSnippets" ) )
51
 
52
  $plugin = plugin_basename(__FILE__);
53
  add_filter("plugin_action_links_$plugin", array( $this,'bsf_settings_link') );
54
- }
55
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  function frontend_style() {
57
  wp_register_style( 'bsf_style', plugins_url('/css/style.css', __FILE__) );
58
  wp_enqueue_style('bsf_style');
@@ -76,7 +100,6 @@ if ( !class_exists( "RichSnippets" ) )
76
  wp_enqueue_script('wp-pointer');
77
  add_action('admin_print_footer_scripts', array( $this,'custom_print_footer_scripts') );
78
  }
79
-
80
  function custom_print_footer_scripts(){
81
  $pointer_content = '<h3>Rich Snippets Installed !</h3>';
82
  $pointer_content .= '<p>Check out this panel to know more about "All in One Schema.org Rich Snippets".</p>';
@@ -125,6 +148,7 @@ if ( !class_exists( "RichSnippets" ) )
125
 
126
  function set_styles() {
127
  wp_register_style( 'star_style', plugins_url('/css/jquery.rating.css', __FILE__) );
 
128
  wp_register_script( 'bsf_jquery_ui', plugins_url('/js/jquery-ui.js', __FILE__) );
129
  wp_register_script( 'bsf_jquery_star', plugins_url('/js/jquery.rating.min.js', __FILE__) );
130
  wp_register_script( 'bsf_toggle', plugins_url('/js/toggle.js', __FILE__) );
@@ -145,8 +169,7 @@ if ( !class_exists( "RichSnippets" ) )
145
  background: url(<?php echo plugins_url('/images/star.png',__FILE__); ?>) no-repeat 0 -32px !important;
146
  }
147
  #star-icons-32.icon32 {background: url(<?php echo plugins_url('/images/gray-32.png',__FILE__); ?>) no-repeat;}
148
- </style>
149
-
150
  <?php }
151
 
152
  /* Translation */
@@ -155,16 +178,138 @@ if ( !class_exists( "RichSnippets" ) )
155
  // Load Translation File
156
  load_plugin_textdomain('rich-snippets', false, basename( dirname( __FILE__ ) ) . '/lang/' );
157
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
159
  }
160
-
161
  require_once('functions.php');
162
-
163
  add_filter( 'bsf_meta_boxes', 'bsf_metaboxes' );
164
-
165
  // Instantiating the Class
166
  if (class_exists("RichSnippets")) {
167
  $RichSnippets= new RichSnippets();
168
  }
169
-
170
  ?>
3
  Plugin Name: All In One Schema.org Rich Snippets
4
  Plugin URI: http://www.brainstormforce.com
5
  Description: The All in One Rich Snippets gives the power to the blog author to control the rich snippets to be shown in the search results by the search engines.
6
+ Version: 1.0.2
7
  Author: Brainstorm Force
8
  Author URI: http://www.brainstormforce.com
9
  License: GPL2
41
 
42
  add_action( 'admin_init', array( $this, 'set_styles' ));
43
 
44
+ add_action( 'admin_init', array( $this, 'rdfa_breadcrumb_settings' ));
45
+
46
  add_action( 'wp_head', array($this, 'frontend_style') );
47
 
48
  add_filter('plugins_loaded', array( $this, 'rich_snippet_translation'));
53
 
54
  $plugin = plugin_basename(__FILE__);
55
  add_filter("plugin_action_links_$plugin", array( $this,'bsf_settings_link') );
56
+
57
+ // Extended Comments
58
+ add_filter('comment_form_default_fields',array( $this,'custom_fields'));
59
+ // Add fields after default fields above the comment box, always visible
60
+
61
+ add_action( 'comment_form_logged_in_after', array( $this,'additional_fields' ));
62
+ add_action( 'comment_form_after_fields', array( $this,'additional_fields' ));
63
+
64
+ // Save the comment meta data along with comment
65
+
66
+ add_action( 'comment_post', array( $this,'save_comment_meta_data' ));
67
+ // Add the filter to check if the comment meta data has been filled or not
68
+
69
+ add_filter( 'preprocess_comment', array( $this,'verify_comment_meta_data' ));
70
+ //Add an edit option in comment edit screen
71
+
72
+ add_action( 'edit_comment', array( $this,'extend_comment_edit_metafields' ));
73
+
74
+ // Add the comment meta (saved earlier) to the comment text
75
+ // You can also output the comment meta values directly in comments template
76
+
77
+ add_filter( 'comment_text', array( $this,'modify_comment'));
78
+
79
+ }
80
  function frontend_style() {
81
  wp_register_style( 'bsf_style', plugins_url('/css/style.css', __FILE__) );
82
  wp_enqueue_style('bsf_style');
100
  wp_enqueue_script('wp-pointer');
101
  add_action('admin_print_footer_scripts', array( $this,'custom_print_footer_scripts') );
102
  }
 
103
  function custom_print_footer_scripts(){
104
  $pointer_content = '<h3>Rich Snippets Installed !</h3>';
105
  $pointer_content .= '<p>Check out this panel to know more about "All in One Schema.org Rich Snippets".</p>';
148
 
149
  function set_styles() {
150
  wp_register_style( 'star_style', plugins_url('/css/jquery.rating.css', __FILE__) );
151
+ wp_register_style( 'meta_style', plugins_url('admin/css/style.css', __FILE__) );
152
  wp_register_script( 'bsf_jquery_ui', plugins_url('/js/jquery-ui.js', __FILE__) );
153
  wp_register_script( 'bsf_jquery_star', plugins_url('/js/jquery.rating.min.js', __FILE__) );
154
  wp_register_script( 'bsf_toggle', plugins_url('/js/toggle.js', __FILE__) );
169
  background: url(<?php echo plugins_url('/images/star.png',__FILE__); ?>) no-repeat 0 -32px !important;
170
  }
171
  #star-icons-32.icon32 {background: url(<?php echo plugins_url('/images/gray-32.png',__FILE__); ?>) no-repeat;}
172
+ </style>
 
173
  <?php }
174
 
175
  /* Translation */
178
  // Load Translation File
179
  load_plugin_textdomain('rich-snippets', false, basename( dirname( __FILE__ ) ) . '/lang/' );
180
  }
181
+ function custom_fields($fields) {
182
+
183
+ $commenter = wp_get_current_commenter();
184
+ $req = get_option( 'require_name_email' );
185
+ $aria_req = ( $req ? " aria-required='true'" : '' );
186
+
187
+ $fields[ 'author' ] = '<p class="comment-form-author">'.
188
+ '<label for="author">' . __( 'Name' ) . '</label>'.
189
+ ( $req ? '<span class="required">*</span>' : '' ).
190
+ '<input id="author" name="author" type="text" value="'. esc_attr( $commenter['comment_author'] ) .
191
+ '" size="30" tabindex="1"' . $aria_req . ' /></p>';
192
+
193
+ $fields[ 'email' ] = '<p class="comment-form-email">'.
194
+ '<label for="email">' . __( 'Email' ) . '</label>'.
195
+ ( $req ? '<span class="required">*</span>' : '' ).
196
+ '<input id="email" name="email" type="text" value="'. esc_attr( $commenter['comment_author_email'] ) .
197
+ '" size="30" tabindex="2"' . $aria_req . ' /></p>';
198
+
199
+ $fields[ 'url' ] = '<p class="comment-form-url">'.
200
+ '<label for="url">' . __( 'Website' ) . '</label>'.
201
+ '<input id="url" name="url" type="text" value="'. esc_attr( $commenter['comment_author_url'] ) .
202
+ '" size="30" tabindex="3" /></p>';
203
+
204
+ $fields[ 'phone' ] = '<p class="comment-form-phone">'.
205
+ '<label for="phone">' . __( 'Phone' ) . '</label>'.
206
+ '<input id="phone" name="phone" type="text" size="30" tabindex="4" /></p>';
207
+
208
+ return $fields;
209
+ }
210
+ function additional_fields () {
211
+ global $post;
212
+ $id = $post->ID;
213
+ $type = get_post_meta($id, '_bsf_post_type', true);
214
+ if($type == '7')
215
+ {
216
+ echo '<label for="rating">'. __('Your Rating :') . '<span class="required">*</span></label><br/><span class="commentratingbox">';
217
+
218
+ for( $i=1; $i <= 5; $i++ )
219
+ echo '<span class="commentrating star-blocks"><input type="radio" name="rating" id="rating" class="star" value="'. $i .'"/></span>';
220
+
221
+ echo'</span><br/></p>';
222
+ echo '<br/><p class="comment-form-title">'.
223
+ '<label for="title">' . __( 'Comment Title' ) . '</label>'.
224
+ '<input id="title" name="title" type="text" size="30" tabindex="5" /></p>';
225
+
226
+ echo '<p class="comment-form-rating">';
227
+ }
228
+ }
229
+ function save_comment_meta_data( $comment_id ) {
230
+ if ( ( isset( $_POST['phone'] ) ) && ( $_POST['phone'] != '') )
231
+ $phone = wp_filter_nohtml_kses($_POST['phone']);
232
+ add_comment_meta( $comment_id, 'phone', $phone );
233
+
234
+ if ( ( isset( $_POST['title'] ) ) && ( $_POST['title'] != '') )
235
+ $title = wp_filter_nohtml_kses($_POST['title']);
236
+ add_comment_meta( $comment_id, 'title', $title );
237
+
238
+ if ( ( isset( $_POST['rating'] ) ) && ( $_POST['rating'] != '') )
239
+ $rating = wp_filter_nohtml_kses($_POST['rating']);
240
+ add_comment_meta( $comment_id, 'rating', $rating );
241
+ }
242
+ function verify_comment_meta_data( $commentdata ) {
243
+ if ( ! isset( $_POST['rating'] ) )
244
+ wp_die( __( 'Error: You did not add your rating. Hit the BACK button of your Web browser and resubmit your comment with rating.' ) );
245
+ return $commentdata;
246
+ }
247
+ function extend_comment_edit_metafields( $comment_id ) {
248
+ if( ! isset( $_POST['extend_comment_update'] ) || ! wp_verify_nonce( $_POST['extend_comment_update'], 'extend_comment_update' ) ) return;
249
+
250
+ if ( ( isset( $_POST['phone'] ) ) && ( $_POST['phone'] != '') ) :
251
+ $phone = wp_filter_nohtml_kses($_POST['phone']);
252
+ update_comment_meta( $comment_id, 'phone', $phone );
253
+ else :
254
+ delete_comment_meta( $comment_id, 'phone');
255
+ endif;
256
+
257
+ if ( ( isset( $_POST['title'] ) ) && ( $_POST['title'] != '') ):
258
+ $title = wp_filter_nohtml_kses($_POST['title']);
259
+ update_comment_meta( $comment_id, 'title', $title );
260
+ else :
261
+ delete_comment_meta( $comment_id, 'title');
262
+ endif;
263
+
264
+ if ( ( isset( $_POST['rating'] ) ) && ( $_POST['rating'] != '') ):
265
+ $rating = wp_filter_nohtml_kses($_POST['rating']);
266
+ update_comment_meta( $comment_id, 'rating', $rating );
267
+ else :
268
+ delete_comment_meta( $comment_id, 'rating');
269
+ endif;
270
+
271
+ }
272
+ function modify_comment( $text ){
273
+
274
+ $plugin_url_path = WP_PLUGIN_URL;
275
+
276
+ if( $commenttitle = get_comment_meta( get_comment_ID(), 'title', true ) ) {
277
+ $commenttitle = '<strong>' . esc_attr( $commenttitle ) . '</strong><br/>';
278
+ $text = $commenttitle . $text;
279
+ }
280
+
281
+ if( $commentrating = get_comment_meta( get_comment_ID(), 'rating', true ) ) {
282
+ $commentrating = '<p class="comment-rating"> <img src="'. $plugin_url_path .
283
+ '/all-in-one-schemaorg-rich-snippets/images/'. $commentrating . 'star.gif"/><br/>Rating: <strong>'. $commentrating .' / 5</strong></p>';
284
+ $text = $text . $commentrating;
285
+ return $text;
286
+ } else {
287
+ return $text;
288
+ }
289
+ }
290
+ function rdfa_breadcrumb_settings() {
291
+ //Settings page for RDFa Breadcrumb
292
+
293
+ $opt = array(
294
+ 'prefix' => '<p>',
295
+ 'suffix' => '</p>',
296
+ 'title' => __( ' ', 'rich-snippets' ),
297
+ 'home_title' => __( 'Home', 'rich-snippets' ),
298
+ 'separator' => '&raquo',
299
+ 'front_page' => false,
300
+ 'show_blog' => false,
301
+ 'singular_post_taxonomy'=> 'category',
302
+ 'echo' => true
303
+ );
304
+ add_option("rdfa_options",$opt);
305
+ }
306
  }
307
  }
 
308
  require_once('functions.php');
309
+ require_once('rdfa-breadcrumbs.php');
310
  add_filter( 'bsf_meta_boxes', 'bsf_metaboxes' );
 
311
  // Instantiating the Class
312
  if (class_exists("RichSnippets")) {
313
  $RichSnippets= new RichSnippets();
314
  }
 
315
  ?>
js/toggle.js CHANGED
@@ -18,7 +18,7 @@ function hidden() {
18
  }
19
  //Function to expand the updated snippet block
20
  function expand_default(selected) {
21
- jQuery("#_bsf_post_type").attr("disabled",true);
22
  hidden();
23
  if(selected == '1')
24
  {
18
  }
19
  //Function to expand the updated snippet block
20
  function expand_default(selected) {
21
+ jQuery("#_bsf_post_type").css("display","none");
22
  hidden();
23
  if(selected == '1')
24
  {
meta-boxes.php CHANGED
@@ -4,11 +4,12 @@ function bsf_metaboxes( array $meta_boxes ) {
4
 
5
  // Start with an underscore to hide fields from custom fields list
6
  $prefix = '_bsf_';
7
-
 
8
  $meta_boxes[] = array(
9
  'id' => 'review_metabox',
10
  'title' => __('Configure Rich Snippet','rich-snippets'),
11
- 'pages' => array( 'post','page' ), // Post type
12
  'context' => 'normal',
13
  'priority' => 'high',
14
  'show_names' => true, // Show field names on the left
@@ -398,21 +399,21 @@ function bsf_metaboxes( array $meta_boxes ) {
398
  ),
399
  array(
400
  'name' => __('Time Required ','rich-snippets'),
401
- 'desc' => __('Preperation time','rich-snippets'),
402
  'id' => $prefix . 'recipes_preptime',
403
  'class' => 'recipes',
404
  'type' => 'text_small',
405
  ),
406
  array(
407
  'name' => __('','rich-snippets'),
408
- 'desc' => __('Cook Time.','rich-snippets'),
409
  'id' => $prefix . 'recipes_cooktime',
410
  'class' => 'recipes',
411
  'type' => 'text_small',
412
  ),
413
  array(
414
  'name' => __('','rich-snippets'),
415
- 'desc' => __('Total Time','rich-snippets'),
416
  'id' => $prefix . 'recipes_totaltime',
417
  'class' => 'recipes',
418
  'type' => 'text_small',
4
 
5
  // Start with an underscore to hide fields from custom fields list
6
  $prefix = '_bsf_';
7
+ $post_types=get_post_types('','names');
8
+
9
  $meta_boxes[] = array(
10
  'id' => 'review_metabox',
11
  'title' => __('Configure Rich Snippet','rich-snippets'),
12
+ 'pages' => $post_types, //array( 'post','page' ), // Custom Post types
13
  'context' => 'normal',
14
  'priority' => 'high',
15
  'show_names' => true, // Show field names on the left
399
  ),
400
  array(
401
  'name' => __('Time Required ','rich-snippets'),
402
+ 'desc' => __('Preperation time (Format: 1H30M. H - Hours, M - Minutes )','rich-snippets'),
403
  'id' => $prefix . 'recipes_preptime',
404
  'class' => 'recipes',
405
  'type' => 'text_small',
406
  ),
407
  array(
408
  'name' => __('','rich-snippets'),
409
+ 'desc' => __('Cook Time. (Format: 1H30M. H - Hours, M - Minutes )','rich-snippets'),
410
  'id' => $prefix . 'recipes_cooktime',
411
  'class' => 'recipes',
412
  'type' => 'text_small',
413
  ),
414
  array(
415
  'name' => __('','rich-snippets'),
416
+ 'desc' => __('Total Time (Format: 1H30M. H - Hours, M - Minutes )','rich-snippets'),
417
  'id' => $prefix . 'recipes_totaltime',
418
  'class' => 'recipes',
419
  'type' => 'text_small',
rdfa-breadcrumbs.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shows a breadcrumb for all types of pages.
4
+ * @Package : RDFa Breadcrumb
5
+ * @since 1.0
6
+ * @param array $args
7
+ * @return string
8
+ */
9
+
10
+ function bsf_breadcrumb() {
11
+
12
+ /* Set up the arguments for the breadcrumb. */
13
+
14
+ $opts = get_option("rdfa_options");
15
+
16
+ $args = array(
17
+ 'prefix' => $opts['prefix'],
18
+ 'suffix' => $opts['suffix'],
19
+ 'title' => $opts['title'], //__( ' ', 'rich-snippets' ),
20
+ 'home_title' => $opts['home_title'], //__( 'Home', 'rich-snippets' ),
21
+ 'separator' => $opts['separator'],
22
+ 'front_page' => false,
23
+ 'show_blog' => false,
24
+ 'singular_post_taxonomy'=> 'category',
25
+ 'echo' => true
26
+ );
27
+
28
+ if ( is_front_page() && !$args['front_page'] )
29
+ return apply_filters( 'bsf_breadcrumb', false );
30
+
31
+ /* Format the title. */
32
+ $title = ( !empty( $args['title'] ) ? '<span class="breadcrumbs-title">' . $args['title'] . '</span>': '' );
33
+
34
+ $separator = ( !empty( $args['separator'] ) ) ? "<span class='separator'>{$args['separator']}</span>" : "<span class='separator'>/</span>";
35
+
36
+ /* Get the items. */
37
+ $items = bsf_breadcrumb_get_items( $args );
38
+
39
+ $breadcrumbs = '<!-- RDFa Breadcrumbs Plugin by Nitin Yawalkar -->';
40
+ $breadcrumbs .= '<div class="breadcrumb breadcrumbs"><div class="rdfa-breadcrumb"><div xmlns:v="http://rdf.data-vocabulary.org/#">';
41
+ $breadcrumbs .= $args['prefix'];
42
+ $breadcrumbs .= $title;
43
+ $breadcrumbs .= join( " {$separator} ", $items );
44
+ $breadcrumbs .= $args['suffix'];
45
+ $breadcrumbs .= '</div></div></div>';
46
+ $breadcrumbs .= '<!-- RDFa Breadcrumbs Plugin by Nitin Yawalkar -->';
47
+
48
+ $breadcrumbs = apply_filters( 'bsf_breadcrumb', $breadcrumbs );
49
+
50
+ if ( !$args['echo'] )
51
+ return $breadcrumbs;
52
+ else
53
+ echo $breadcrumbs;
54
+ }
55
+
56
+ /**
57
+ * Gets the items for the RDFa Breadcrumb.
58
+ *
59
+ * @since 0.4
60
+ */
61
+ function bsf_breadcrumb_get_items( $args ) {
62
+ global $wp_query;
63
+
64
+ $item = array();
65
+
66
+ $show_on_front = get_option( 'show_on_front' );
67
+
68
+ /* Front page. */
69
+ if ( is_front_page() ) {
70
+ $item['last'] = $args['home_title'];
71
+ }
72
+
73
+ /* Link to front page. */
74
+ if ( !is_front_page() )
75
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="'. home_url( '/' ) .'" class="home">' . $args['home_title'] . '</a></span>';
76
+
77
+ /* If bbPress is installed and we're on a bbPress page. */
78
+ if ( function_exists( 'is_bbpress' ) && is_bbpress() )
79
+ $item = array_merge( $item, bsf_breadcrumb_get_bbpress_items() );
80
+
81
+ /* If viewing a home/post page. */
82
+ elseif ( is_home() ) {
83
+ $home_page = get_page( $wp_query->get_queried_object_id() );
84
+ $item = array_merge( $item, bsf_breadcrumb_get_parents( $home_page->post_parent ) );
85
+ $item['last'] = get_the_title( $home_page->ID );
86
+ }
87
+
88
+ /* If viewing a singular post. */
89
+ elseif ( is_singular() ) {
90
+
91
+ $post = $wp_query->get_queried_object();
92
+ $post_id = (int) $wp_query->get_queried_object_id();
93
+ $post_type = $post->post_type;
94
+
95
+ $post_type_object = get_post_type_object( $post_type );
96
+
97
+ if ( 'post' === $wp_query->post->post_type && $args['show_blog'] ) {
98
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_permalink( get_option( 'page_for_posts' ) ) . '">' . get_the_title( get_option( 'page_for_posts' ) ) . '</a></span>';
99
+ }
100
+
101
+ if ( 'page' !== $wp_query->post->post_type ) {
102
+
103
+ /* If there's an archive page, add it. */
104
+ if ( function_exists( 'get_post_type_archive_link' ) && !empty( $post_type_object->has_archive ) )
105
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a></span>';
106
+
107
+ if ( isset( $args["singular_{$wp_query->post->post_type}_taxonomy"] ) && is_taxonomy_hierarchical( $args["singular_{$wp_query->post->post_type}_taxonomy"] ) ) {
108
+ $terms = wp_get_object_terms( $post_id, $args["singular_{$wp_query->post->post_type}_taxonomy"] );
109
+ $item = array_merge( $item, bsf_breadcrumb_get_term_parents( $terms[0], $args["singular_{$wp_query->post->post_type}_taxonomy"] ) );
110
+ }
111
+
112
+ elseif ( isset( $args["singular_{$wp_query->post->post_type}_taxonomy"] ) )
113
+ $item[] = get_the_term_list( $post_id, $args["singular_{$wp_query->post->post_type}_taxonomy"], '', ', ', '' );
114
+ }
115
+
116
+ if ( ( is_post_type_hierarchical( $wp_query->post->post_type ) || 'attachment' === $wp_query->post->post_type ) && $parents = bsf_breadcrumb_get_parents( $wp_query->post->post_parent ) ) {
117
+ $item = array_merge( $item, $parents );
118
+ }
119
+
120
+ $item['last'] = get_the_title();
121
+ }
122
+
123
+ /* If viewing any type of archive. */
124
+ else if ( is_archive() ) {
125
+
126
+ if ( is_category() || is_tag() || is_tax() ) {
127
+
128
+ $term = $wp_query->get_queried_object();
129
+ $taxonomy = get_taxonomy( $term->taxonomy );
130
+
131
+ if ( ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent ) && $parents = bsf_breadcrumb_get_term_parents( $term->parent, $term->taxonomy ) )
132
+ $item = array_merge( $item, $parents );
133
+
134
+ $item['last'] = $term->name;
135
+ }
136
+
137
+ else if ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
138
+ $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
139
+ $item['last'] = $post_type_object->labels->name;
140
+ }
141
+
142
+ else if ( is_date() ) {
143
+
144
+ if ( is_day() )
145
+ $item['last'] = __( 'Archives for ', 'rich-snippets' ) . get_the_time( 'F j, Y' );
146
+
147
+ elseif ( is_month() )
148
+ $item['last'] = __( 'Archives for ', 'rich-snippets' ) . single_month_title( ' ', false );
149
+
150
+ elseif ( is_year() )
151
+ $item['last'] = __( 'Archives for ', 'rich-snippets' ) . get_the_time( 'Y' );
152
+ }
153
+
154
+ else if ( is_author() )
155
+ $item['last'] = __( 'Archives by: ', 'rich-snippets' ) . get_the_author_meta( 'display_name', $wp_query->post->post_author );
156
+ }
157
+
158
+ /* If viewing search results. */
159
+ else if ( is_search() )
160
+ $item['last'] = __( 'Search results for "', 'rich-snippets' ) . stripslashes( strip_tags( get_search_query() ) ) . '"';
161
+
162
+ /* If viewing a 404 error page. */
163
+ else if ( is_404() )
164
+ $item['last'] = __( 'Page Not Found', 'rich-snippets' );
165
+
166
+ return apply_filters( 'bsf_breadcrumb_items', $item );
167
+ }
168
+
169
+ /**
170
+ * Gets the items for the breadcrumb item if bbPress is installed.
171
+ *
172
+ * @since 0.4
173
+ *
174
+ * @param array $args Mixed arguments for the menu.
175
+ * @return array List of items to be shown in the item.
176
+ */
177
+ function bsf_breadcrumb_get_bbpress_items( $args = array() ) {
178
+
179
+ $item = array();
180
+
181
+ $post_type_object = get_post_type_object( bbp_get_forum_post_type() );
182
+
183
+ if ( !empty( $post_type_object->has_archive ) && !bbp_is_forum_archive() )
184
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '">' . bbp_get_forum_archive_title() . '</a></span>';
185
+
186
+ if ( bbp_is_forum_archive() )
187
+ $item[] = bbp_get_forum_archive_title();
188
+
189
+ elseif ( bbp_is_topic_archive() )
190
+ $item[] = bbp_get_topic_archive_title();
191
+
192
+ elseif ( bbp_is_single_view() )
193
+ $item[] = bbp_get_view_title();
194
+
195
+ elseif ( bbp_is_single_topic() ) {
196
+
197
+ $topic_id = get_queried_object_id();
198
+
199
+ $item = array_merge( $item, bsf_breadcrumb_get_parents( bbp_get_topic_forum_id( $topic_id ) ) );
200
+
201
+ if ( bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit() )
202
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_topic_permalink( $topic_id ) . '">' . bbp_get_topic_title( $topic_id ) . '</a></span>';
203
+ else
204
+ $item[] = bbp_get_topic_title( $topic_id );
205
+
206
+ if ( bbp_is_topic_split() )
207
+ $item[] = __( 'Split', 'rich-snippets' );
208
+
209
+ elseif ( bbp_is_topic_merge() )
210
+ $item[] = __( 'Merge', 'rich-snippets' );
211
+
212
+ elseif ( bbp_is_topic_edit() )
213
+ $item[] = __( 'Edit', 'rich-snippets' );
214
+ }
215
+
216
+ elseif ( bbp_is_single_reply() ) {
217
+
218
+ $reply_id = get_queried_object_id();
219
+
220
+ $item = array_merge( $item, bsf_breadcrumb_get_parents( bbp_get_reply_topic_id( $reply_id ) ) );
221
+
222
+ if ( !bbp_is_reply_edit() ) {
223
+ $item[] = bbp_get_reply_title( $reply_id );
224
+
225
+ } else {
226
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_reply_url( $reply_id ) . '">' . bbp_get_reply_title( $reply_id ) . '</a></span>';
227
+ $item[] = __( 'Edit', 'rich-snippets' );
228
+ }
229
+ }
230
+ elseif ( bbp_is_single_forum() ) {
231
+
232
+ $forum_id = get_queried_object_id();
233
+ $forum_parent_id = bbp_get_forum_parent( $forum_id );
234
+
235
+ if ( 0 !== $forum_parent_id)
236
+ $item = array_merge( $item, bsf_breadcrumb_get_parents( $forum_parent_id ) );
237
+
238
+ $item[] = bbp_get_forum_title( $forum_id );
239
+ }
240
+
241
+ elseif ( bbp_is_single_user() || bbp_is_single_user_edit() ) {
242
+
243
+ if ( bbp_is_single_user_edit() ) {
244
+ $item[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field( 'display_name' ) . '</a></span>';
245
+ $item[] = __( 'Edit' );
246
+ } else {
247
+ $item[] = bbp_get_displayed_user_field( 'display_name' );
248
+ }
249
+ }
250
+
251
+ return apply_filters( 'bsf_breadcrumb_get_bbpress_items', $item, $args );
252
+ }
253
+
254
+ /**
255
+ * Gets parent pages of any post type.
256
+ *
257
+ * @since 0.1
258
+ * @param int $post_id ID of the post whose parents we want.
259
+ * @param string $separator.
260
+ * @return string $html String of parent page links.
261
+ */
262
+ function bsf_breadcrumb_get_parents( $post_id = '', $separator = '/' ) {
263
+
264
+ $parents = array();
265
+
266
+ if ( $post_id == 0 )
267
+ return $parents;
268
+
269
+ while ( $post_id ) {
270
+ $page = get_page( $post_id );
271
+ $parents[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a></span>';
272
+ $post_id = $page->post_parent;
273
+ }
274
+
275
+ if ( $parents )
276
+ $parents = array_reverse( $parents );
277
+
278
+ return $parents;
279
+ }
280
+
281
+ /**
282
+ * Searches for term parents of hierarchical taxonomies.
283
+ *
284
+ * @since 0.1
285
+ * @param int $parent_id The ID of the first parent.
286
+ * @param object|string $taxonomy The taxonomy of the term whose parents we want.
287
+ * @return string $html String of links to parent terms.
288
+ */
289
+ function bsf_breadcrumb_get_term_parents( $parent_id = '', $taxonomy = '', $separator = '/' ) {
290
+
291
+ $html = array();
292
+ $parents = array();
293
+
294
+ if ( empty( $parent_id ) || empty( $taxonomy ) )
295
+ return $parents;
296
+
297
+ while ( $parent_id ) {
298
+ $parent = get_term( $parent_id, $taxonomy );
299
+ $parents[] = '<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a></span>';
300
+ $parent_id = $parent->parent;
301
+ }
302
+
303
+ if ( $parents )
304
+ $parents = array_reverse( $parents );
305
+
306
+ return $parents;
307
+ }
308
+
309
+ /**
310
+ * Try to add automatically to Hybrid, Thematic, Thesis and Genesis
311
+ *
312
+ * @since 0.1
313
+ * @return string
314
+ */
315
+ function setup_bsf_breadcrumb() {
316
+
317
+ /* Hybrid */
318
+ remove_action( 'hybrid_before_content', 'hybrid_breadcrumb' );
319
+ add_action( 'hybrid_before_content', 'bsf_breadcrumb' );
320
+
321
+ /* Thematic */
322
+ add_action( 'thematic_belowheader','bsf_breadcrumb' );
323
+
324
+ /* Thesis */
325
+ add_action( 'thesis_hook_before_content','bsf_breadcrumb' );
326
+
327
+ /* Genesis */
328
+ remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
329
+ add_action( 'genesis_before_loop', 'bsf_breadcrumb' );
330
+ }
331
+
332
+ function rdfa_admin_styles() {
333
+ wp_enqueue_style( 'jquery_style' );
334
+
335
+ wp_enqueue_script( 'rdfa-jquery' );
336
+ wp_enqueue_script( 'rdfa-jquery-ui' );
337
+ wp_enqueue_script( 'rdfa-jquery-accord' );
338
+ }
339
+ add_action( 'init', 'setup_bsf_breadcrumb' );
340
+ ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.brainstormforce.com
4
  Tags: Review, Event, Organization, People, Product, Recipe, Software Application, Video, rdfa, rich snippet, schema.org, schema, microdata, microformat, SERP, Google, Yahoo, Bing
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
- Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -18,7 +18,6 @@ It is basically a short summary of your page in the search results of Google, Ya
18
 
19
  [See Examples of Rich Snippets Here.](http://www.seomoz.org/blog/schema-examples/ "Rich Snippets Examples")
20
 
21
-
22
  How does a Rich Snippet help?
23
 
24
  - It gives search engines only the important & precise information to display in search result snippets.
@@ -36,7 +35,6 @@ Review, Event, Organization, People, Product, Recipe, Software Application, Vide
36
 
37
  Future release would include -
38
 
39
- * Breadcrumb
40
  * Author
41
 
42
  == Installation ==
@@ -86,6 +84,11 @@ Review, Event, Organization, People, Product, Recipe, Software Application, Vide
86
  4. Test the post or page URL in Google Rich Snippets Testing
87
 
88
  == Changelog ==
 
 
 
 
 
89
 
90
  = 1.0.1 =
91
  * Minor Bugs Fixes
@@ -94,4 +97,4 @@ Review, Event, Organization, People, Product, Recipe, Software Application, Vide
94
  * Initial Release.
95
 
96
  == Upgrade Notice ==
97
- Please update your plugin, new release contains some minor bugs fixes.
4
  Tags: Review, Event, Organization, People, Product, Recipe, Software Application, Video, rdfa, rich snippet, schema.org, schema, microdata, microformat, SERP, Google, Yahoo, Bing
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
18
 
19
  [See Examples of Rich Snippets Here.](http://www.seomoz.org/blog/schema-examples/ "Rich Snippets Examples")
20
 
 
21
  How does a Rich Snippet help?
22
 
23
  - It gives search engines only the important & precise information to display in search result snippets.
35
 
36
  Future release would include -
37
 
 
38
  * Author
39
 
40
  == Installation ==
84
  4. Test the post or page URL in Google Rich Snippets Testing
85
 
86
  == Changelog ==
87
+ = 1.0.2 =
88
+ * Added: RDFa Breadcrumbs Plugin is now a part of All in One Schema.org Rich Snippets !
89
+ * Added: Star rating and review for recipe
90
+ * Bug fixes for recipe type
91
+ * Bug fix on post update
92
 
93
  = 1.0.1 =
94
  * Minor Bugs Fixes
97
  * Initial Release.
98
 
99
  == Upgrade Notice ==
100
+ Please update your plugin, to keep your site updated and secured !