Commits

simplemediacode committed 4a022e3

+Content loading multiple times. patch by sirene http://simplemediacode.org/forums/topic/schema-display-3-times/#post-97
+Now, the $ipwp_contentx is loading just one time and not multiple time if you have more than one the_content(); in your page
author: sirene

  • Participants
  • Parent commits c5f8ab3

Comments (0)

Files changed (2)

 <?php 
 /**
 Plugin Name: itemprop WP for SERP (and 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.3.3-itempropWP_load_widgets
+Plugin URI: http://simplemediacode.com/wordpress-pugins/itemprop-wp/?utm_source=wordpress&utm_medium=wpplugin&utm_campaign=itempropWP&utm_content=v-3.3.4-itempropWP_load_widgets
 Description: Add human invisible schema.org code to conent
-Version: 3.3.3
+Version: 3.3.4
 Requires at least: 3.3
 Tested up to: 3.5
 Author: Rolands Umbrovskis
 Copyright (C) 2008-2013, Rolands Umbrovskis - rolands@simplemediacode.com
 
 */
-	define('SMCIPWPV','3.3.3'); // location general @since 1.0
+	define('SMCIPWPV','3.3.4'); // 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
 			return apply_filters('ipwp_post_imguri', $theimage);
 		}
 		public function ipwp_the_content_filter($content) {
+
+/*
+Content loading multiple times. patch by sirene http://simplemediacode.org/forums/topic/schema-display-3-times/#post-97
+Now, the $ipwp_contentx is loading just one time and not multiple time if you have more than one the_content(); in your page
+@author sirene
+@date 2013-02-18
+@version 1.0.0
+@since 3.3.4
+*/
+			static $done_ipwp_post = FALSE; /* @since 3.3.4 */
+			
 			if (is_singular() && !is_feed()){
 				global $post;
 				$post_id = $post->ID;
 					if ( has_post_thumbnail($post_id)) {
 						$itempropwpimg = new itempropwp;
 						$ipwp_posth = $itempropwpimg->itempropwp_get_image_path($post_id);
-						// removed @since 3.3.2 replaced with  itemprop_get_image_path()
-						//$ipwp_post_imga = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full'); // all other sizes are not permanent :| 
-						//$ipwp_posth = apply_filters('ipwp_post_imguri', $ipwp_post_imga[0]); // image link + Extending @since 3.1
 					}
 				}
-				
-				
+
 				if($ipwp_posth){
 					$ipwp_image = '<meta itemprop="image" content="'.esc_url($ipwp_posth).'" />';
 				}
 	.$ipwp_datemodified
 	.$showcommcount.'<!-- ItemProp WP '.SMCIPWPV.' by Rolands Umbrovskis http://umbrovskis.com/ end --></span>');
 
-				$content = $content.$ipwp_contentx;
-				$content = apply_filters('itempropwp_article_content', $content);
-				
+				if ( $done_ipwp_post ){ /* @since 3.3.4 */
+					return $content;
+				}else{
+					$content = $content.$ipwp_contentx;
+					$content = apply_filters('itempropwp_article_content', $content);
+					$done_ipwp_post = TRUE;
+				}
 				return $content;
 			}
+			
+			$done_ipwp_post = TRUE; /* @since 3.3.4 */
 			return $content;
 		}
 	
 Tags: SEO, schema, schema.org, itemprop, schema.org itemprop, images, microdata, rich snippets, richsnippets, SERP, html5, structured data
 Requires at least: 3.3
 Tested up to: 3.5
-Stable tag: 3.3.3
+Stable tag: 3.3.4
 License: simplemediacode
 License URI: http://simplemediacode.com/license/gpl/
 
 
 This plugin is very simple. Using WordPress built in function to filter element attributes and adding < meta > tags with schema.org item properties.
 
-Coming soon: **itempropWP theme** (free and paid versions)! [itempropWP WordPress theme feature requests](http://simplemediacode.org/forums/forum/itempropwp-wordpress-theme-support/itempropwp-wordpress-theme-feature-requests/?utm_source=http://wordpress.org/extend/plugins/itempropwp/&utm_medium=link&utm_campaign=itempropWP-WordPress-theme-feature-requests-3.3.3&utm_content=WordPress-plugin-itempropwp-3.3.3)
+Coming soon: **itempropWP theme** (free and paid versions)! [itempropWP WordPress theme feature requests](http://simplemediacode.org/forums/forum/itempropwp-wordpress-theme-support/itempropwp-wordpress-theme-feature-requests/?utm_source=http://wordpress.org/extend/plugins/itempropwp/&utm_medium=link&utm_campaign=itempropWP-WordPress-theme-feature-requests-3.3.4&utm_content=WordPress-plugin-itempropwp-3.3.4)
 
 Example output:
 
 `
 <span itemscope itemtype="http://schema.org/Article" class="itempropwp-wrap">
-<!-- Itemprop WP 3.3.3 by Rolands Umbrovskis http://umbrovskis.com -->
+<!-- Itemprop WP 3.3.4 by Rolands Umbrovskis http://umbrovskis.com -->
  <meta itemprop="name" content="Title of the Article" />
  <meta itemprop="url" content="http://example.com/seo-optimized-article/" />
  <meta itemprop="image" content="http://example.com/images/example.jpg" />
  <meta itemprop="datePublished" content="2012-09-13 19:17:21" />
  <meta itemprop="dateModified" content="2012-09-29 13:33:25" />
  <meta itemprop="interactionCount" content="UserComments:356" />
-<!-- Itemprop WP 3.3.3 by Rolands Umbrovskis http://umbrovskis.com end -->
+<!-- Itemprop WP 3.3.4 by Rolands Umbrovskis http://umbrovskis.com end -->
 </span>
 `
 
 
 == Changelog ==
 
+= 3.3.4 = 
+
+* small bugfix in rare cases: "loading content multiple times", thanks to [sirene's commit on SimpleMediaCode.org](http://simplemediacode.org/forums/topic/schema-display-3-times/#post-97) 
+
 = 3.3.3 = 
 
 * small bugfix "Fixing undeclared variables", thanks to [semplon's commit on github](https://github.com/rolandinsh/itempropwp/commit/d4e18904329faabb84f6c47a7011a261c973b6bf) 
 
 == Upgrade Notice ==
 
+= 3.3.4 = 
+
+* small bugfix in rare cases: "loading content multiple times if more than one the_content()", thanks to [sirene's commit on SimpleMediaCode.org](http://simplemediacode.org/forums/topic/schema-display-3-times/#post-97) 
+
+
 = 3.3.3 = 
 
 * small bugfix "Fixing undeclared variables", thanks to [semplon's commit on github](https://github.com/rolandinsh/itempropwp/commit/d4e18904329faabb84f6c47a7011a261c973b6bf)