Commits

simplemediacode  committed 1f9196a

review HTML correct

  • Participants
  • Parent commits 80a9bff

Comments (0)

Files changed (3)

File itemprop_review.php

 <?php 
 /*
 itempropwp itemprom review
-
 <div itemprop="review" itemscope itemtype="http://schema.org/Review">
 	<meta itemprop="name" content="Item Title is greate!" />
 	<meta itemprop="author" content="Rolands Umbrovskis" />
 	<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">
 		<meta itemprop="name" content="Item Title" />
 	</span>
-
+	
 	<div itemscope itemtype="http://schema.org/Product">
 		<meta itemprop="name" content="Item Title" />
 		<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
 	</div>
 	<meta itemprop="description" content="Great Item Title for the price." />
 </div>
+
 */
+
+class itempropwp_review extends itempropwp  {  
+	public function __construct(){
+		parent::__construct();
+		add_action('init', array( 'itempropwp_review', 'reviewinit' ),10);	
+	}
+	
+	public function reviewinit() {
+		add_filter('article_content_before', array( 'itempropwp_review', 'review' ), 11); // Adding context @since 3.0
+	}
+	
+	public function review($content){
+		if (is_singular() && !is_feed()){
+			global $post;
+			//$ipwprprefix = 'ipwp_';
+			$reviewid = $post->ID;
+			$reviewpost = get_post($post->ID);
+			$reviewname = get_post_meta($reviewid, $ipwprprefix.'product_name', true);
+			$reviewprice = get_post_meta($reviewid, $ipwprprefix.'product_price', true);
+			$reviewcurrency = get_post_meta($reviewid, $ipwprprefix.'currency', true);
+			$reviewrating = (float)get_post_meta($reviewid, $ipwprprefix.'rating', true);
+			$newcontent = '';
+			$pricerows='';
+			$reviewratingrow='';
+			
+			if(!$reviewname){$reviewname = $reviewpost->post_title;}
+			if($reviewprice && $reviewcurrency){
+				$pricerows = '<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><meta itemprop="price" content="'.$reviewprice.'" /><meta itemprop="priceCurrency" content="'.$reviewcurrency.'" /><link itemprop="availability" href="http://schema.org/InStock" /></span>';
+			}
+			
+			if($reviewrating){
+				$reviewratingrow = '<span itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"><meta itemprop="worstRating" content = "1"/><meta itemprop="ratingValue" content="4.5" /><meta itemprop="bestRating" content="5" /></span>';
+			}
+			/*
+			$newcontent .= '<span itemprop="review" itemscope itemtype="http://schema.org/Review"><meta itemprop="name" content="'.esc_attr($reviewpost->post_title).'" /><meta itemprop="author" content="'.esc_attr(get_the_author_meta( 'display_name', $reviewpost->post_author )).'" /><meta itemprop="datePublished" content="'.esc_attr($reviewpost->post_date).'" />'
+			.$reviewratingrow.'<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product"><meta itemprop="name" content="'.esc_attr($reviewname).'" />'
+			.$pricerows.'</span><meta itemprop="description" content="'.esc_attr($reviewpost->post_excerpt).'" /></span>';
+			*/
+			
+			$newcontent .= '<span itemprop="review" itemscope itemtype="http://schema.org/Review"><meta itemprop="name" content="'.esc_attr($reviewpost->post_title).'" /><meta itemprop="author" content="'.esc_attr(get_the_author_meta( 'display_name', $reviewpost->post_author )).'" /><meta itemprop="datePublished" content="'.esc_attr($reviewpost->post_date).'" />'
+			.'<span itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"><meta itemprop="worstRating" content = "1"/><meta itemprop="ratingValue" content="4.5" /><meta itemprop="bestRating" content="5" /></span>'.'<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product"><meta itemprop="name" content="'.esc_attr($reviewname).'" />'
+			.'<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><meta itemprop="price" content="56.25" /><meta itemprop="priceCurrency" content="EUR" /><link itemprop="availability" href="http://schema.org/InStock" /></span>'.'</span><meta itemprop="description" content="'.esc_attr($reviewpost->post_excerpt).'" /></span>';
+
+			//$content = $content."\n".'<!-- review -->'.$newcontent.'<!-- review end -->'."\n";
+			$content = "\n".'<!-- review -->'.$newcontent.'<!-- review end -->'."\n";
+				return $content;
+			}
+			return $content;
+	}
+}
+
+new itempropwp_review;

File itempropwp.php

 Plugin Name: itemprop WP for SERP/SEO Rich snippets
 Plugin URI: http://simplemediacode.com/wordpress-pugins/itemprop-wp/?utm_source=wordpress&utm_medium=wpplugin&utm_campaign=itempropWP&utm_content=v-3.2.1-itempropWP_load_widgets
 Description: Add human invisible schema.org itemprop code to images
-Version: 3.2.1
+Version: 3.2.2
 Requires at least: 3.3
 Tested up to: 3.5
 Author: Rolands Umbrovskis
 Copyright (C) 2008-2012, Rolands Umbrovskis - rolands@simplemediacode.com
 
 */
-	define('SMCIPWPV','3.2.1'); // location general @since 1.0
+	define('SMCIPWPV','3.2.2'); // location general @since 1.0
 	define('SMCIPWPM',dirname(__FILE__)); // location general @since 1.0
 	define('SMCIPWPF','itempropwp'); // location folder @since 1.0 
 	define('IPWPT',__('itemprop WP for SERP/SEO Rich snippets','itempropwp')); // Name @since 1.1
 				if($ipwpdatemodified=='on'){
 					$ipwp_datemodified= '<meta itemprop="dateModified" content="'.esc_attr($thisipwp_post->post_modified).'" />';
 				}
-
-				$content = $content.'<span itemscope itemtype="http://schema.org/Article" class="itempropwp-wrap"><!-- ItemProp WP '.SMCIPWPV.' by Rolands Umbrovskis http://umbrovskis.com -->
+				
+				//$xfactorer = apply_filters('article_content_before');
+				$xfactorer = apply_filters('article_content_before','<span itemscope itemtype="http://schema.org/Article" class="itempropwp-wrap"><!-- ItemProp WP '.SMCIPWPV.' by Rolands Umbrovskis http://umbrovskis.com -->
 	<meta itemprop="name" content="'.esc_attr($thisipwp_post->post_title).'" /><meta itemprop="url" content="'.esc_url(get_permalink()).'" />'
-	.$ipwp_image.'<meta itemprop="author" content="'.get_author_posts_url($thisipwp_post-> post_author).'" /><meta itemprop="description" content="'.strip_tags(str_replace(array("\r\n", "\n", "\r", "\t"), "", $ipwp_post_dsc)).'"/><meta itemprop="datePublished" content="'.esc_attr($thisipwp_post->post_date).'" />'
+	.$ipwp_image.'<meta itemprop="author" content="'.get_author_posts_url($thisipwp_post->post_author).'" /><meta itemprop="description" content="'.strip_tags(str_replace(array("\r\n", "\n", "\r", "\t"), "", $ipwp_post_dsc)).'"/><meta itemprop="datePublished" content="'.esc_attr($thisipwp_post->post_date).'" />'
 	.$ipwp_datemodified
-	.$showcommcount.'<!-- ItemProp WP '.SMCIPWPV.' by Rolands Umbrovskis http://umbrovskis.com end --></span>';
+	.$showcommcount.'<!-- ItemProp WP '.SMCIPWPV.' by Rolands Umbrovskis http://umbrovskis.com end --></span>');
+				
+				
+
+				$content = $content.$xfactorer;
+	
+	//$content = $content.$xfactorer;
+
+				$content = apply_filters('article_content', $content);
+				
 				return $content;
 			}
 			return $content;
 		}
 	
 	}
-//}
+//}
+
+include_once(SMCIPWPM.'/itemprop_review.php');

File screenshot-2.jpg

Added
New image