Commits

simplemediacode committed 89d5d58

3.1.3 ready
fixed: description

  • Participants
  • Parent commits 8c24f4b

Comments (0)

Files changed (3)

 * 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.4.2
-* Stable tag: 3.1.2
+* Stable tag: 3.1.3
 * License URI: http://simplemediacode.com/license/gpl/
 
 ## Description
 ### Example:
 
 	<span itemscope itemtype="http://schema.org/Article">
-	<!-- Itemprop WP 3.1.2 by Rolands Umbrovskis http://umbrovskis.com -->
+	<!-- Itemprop WP 3.1.3 by Rolands Umbrovskis http://umbrovskis.com -->
 	 <meta itemprop="name" content="Title of the Article" />
 	 <meta itemprop="url" content="http://fulllink.example.com/seo-optimized-article/" />
 	 <meta itemprop="image" content="http://fulllink.example.com/seo-optimized-article/example.jpg" />
 	 <meta itemprop="description" content="excerpt from post OR first 128 symbols (with full word), ..." />
 	 <meta itemprop="datePublished" content="2012-09-13 19:17:21"/>
 	 <meta itemprop="interactionCount" content="UserComments:356"/>
-	<!-- Itemprop WP 3.1.2 by Rolands Umbrovskis http://umbrovskis.com end -->
+	<!-- Itemprop WP 3.1.3 by Rolands Umbrovskis http://umbrovskis.com end -->
 	</span>
 
+### How does it work?
+
+There are no options. yet!
+
+This asumes that Yout page is not fully integrated with HTML5's data properties for microdata. This plugin will create small code inside Your full content, with extra microdata from schema.org. This will be ONLY on singular pages - post, page or your custom post type.
+
+Once we are on singular page:
+
+# we will extract from it EXCERPT.
+# If You haven't provided excerpt, plugin will look-up for post content, and downsize it to 170 symbols up to full word.
+# If your content consist ONLY of shortcode, it will strip it out, and leave empty content. :(
+# If we have empty content, from previous step, we will use post title. Not best choise, but at least we have some `description`.
+# If Your post do not have even title, plugin will giveup and your description will be ampty. (This ir very bad :') )
+
+Other options, like `datePublished`, `UserComments`, `url` are taken from post
+
 ### Features
 
 * itemprop="description" (since 3.1.1)

File itempropwp.php

 /*
  * Starting itempropwp
 */
-itempropwp::init();
+new itempropwp;
 /*
  * itempropwp class
  * @since 2.0
 */
 
 	class itempropwp {
+		public function __construct(){
+			add_filter('the_content', array( 'itempropwp', 'ipwp_the_content_filter' ), 10, 2 );
+		} 
 		// Initialize
 		public function init() {
 			// add_filter('wp_get_attachment_image_attributes', array( 'itempropwp', 'ipwp_img_attr' ), 10, 2 ); // Adding itemprop=image to thumbnails  @since 2.0
 	 * @Todo rewrite
 	 * @since 3.1
 	*/
-		public function ipwp_excerpt_maxchr($charlength,$ipwp_content='') {
+		public function ipwp_excerpt_maxchr($charlength=170,$ipwp_content='') {
+			/* did we get content? No, let's make it from post */
 			if($ipwp_content==''){
 				global $post;  
-				
 				$ipwp_content = apply_filters('ipwp_excmc_filter_content', $post->post_excerpt);  // Extending @since 3.1.2
-				
 				if(!$ipwp_content||$ipwp_content==''){
 					$ipwp_content = apply_filters('ipwp_excmc_filter_content', strip_shortcodes( $post->post_content ));  // Extending @since 3.1
 				}
 			}
+			
 			$charlength++;
 			
 			if ( mb_strlen( $ipwp_content ) > $charlength ) {
 					return apply_filters('ipwp_excmc_filter1', $subex); // Extending @since 3.1
 				}
 				return apply_filters('ipwp_excmc_filter_more', '[...]'); // Extending @since 3.1
-			} else {
+			}elseif(!$ipwp_content||$ipwp_content==''){
+				 // Extending @since 3.1.3
+				/* heeeeey! We still have no content! OK, let's tray get post title */
+				// rare cases where post content is ONLY shortcode
+				global $post;
+				$ipwp_content = $post->post_title;
 				return $ipwp_content;
 			}
+			else{
+				/* I give up! Some very rare,rare cases where we do not have content AND we do not have title. That's weird!*/
+				return $ipwp_content;
+			}
+
 		}
 		
 		public function ipwp_the_content_filter($content) {
 					$ipwp_image = "\n\t".'<meta itemprop="image" content="'.esc_url($ipwp_posth).'" />'."\n\t";
 				}
 	
-				
 				if(!$ipwp_post_dsc){
 					$ipwp_n = new itempropwp;
-					$ipwp_post_dsc = apply_filters('ipwp_post_dsc', $ipwp_n->ipwp_excerpt_maxchr(128, strip_shortcodes($thisipwp_post->post_content) )); // Extending @since 3.1
+					$ipwp_post_dsc = apply_filters('ipwp_post_dsc', $ipwp_n->ipwp_excerpt_maxchr(170, strip_shortcodes($thisipwp_post->post_content) )); // Extending @since 3.1
 					//$ipwp_post_dsc = apply_filters('ipwp_post_dsc', $thisipwp_post->post_title); // Extending @since 3.1.2
 				}
 				
 	<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="author" content="'.get_author_posts_url($thisipwp_post-> post_author).'" />
 	<meta itemprop="description" content="'.strip_tags($ipwp_post_dsc).'"/>
 	<meta itemprop="datePublished" content="'.esc_attr($thisipwp_post->post_date).'" />
 	<meta itemprop="interactionCount" content="UserComments:'.esc_attr($thisipwp_post->comment_count).'" />
 </span>
 `
 
-NEW in 3.1.2
+= How does it work? =
+
+There are no options. yet!
+
+This asumes that Yout page is not fully integrated with HTML5's data properties for microdata. This plugin will create small code inside Your full content, with extra microdata from schema.org. This will be ONLY on singular pages - post, page or your custom post type.
+
+Once we are on singular page:
+
+# we will extract from it EXCERPT.
+# If You haven't provided excerpt, plugin will look-up for post content, and downsize it to 170 symbols up to full word.
+# If your content consist ONLY of shortcode, it will strip it out, and leave empty content. :(
+# If we have empty content, from previous step, we will use post title. Not best choise, but at least we have some `description`.
+# If Your post do not have even title, plugin will giveup and your description will be ampty. (This ir very bad :') )
+
+Other options, like `datePublished`, `UserComments`, `url` are taken from post
+
 
-* itemprop="description" fix
-* todo: finish fix for description part
 
 NEW in 3.1
 
 
 == Changelog ==
 
+= 3.1.3 =
+
+* fixed: itemprop="description"
+
 = 3.1.2 =
 
 * fix: itemprop="description"
 
 == Upgrade Notice ==
 
+= 3.1.3 =
+
+* new: itemprop="description"
+
 = 2.0 =
 * new: as extendable class function
 * new: using WordPress filter for image attributed on thumbnails