ID; $type = get_post_meta($id, '_bsf_post_type', true); if($type == '1') { global $post; // echo $post->ID; $review = $content; $review .= '

Review Summary :

'; $review .= '
'; $item = get_post_meta( $post->ID, '_bsf_item_name', true ); $rating = get_post_meta( $post->ID, '_bsf_rating', true ); $desc = get_post_meta( $post->ID, '_bsf_item_desc', true ); $reviewer = get_post_meta( $post->ID, '_bsf_item_reviewer', true); $post_date = get_the_date('Y-m-d'); if(trim($reviewer) != "") $review .= ""; $review .= ""; if(trim($item) != "") $review .= ""; if(trim($rating) != "") $review .= ""; if(trim($desc) != "") $review .= ""; $review .= "
Reviewer : ".$reviewer."
Review Date :
Item Name : ".$item."
Author Rating: ".$rating."
Item Description: ".$desc."
"; return $review; } else if($type == '2') { global $post; $event = $content; $event .= '

Event Summary :

'; $event .= '
'; $event_title = get_post_meta( $post->ID, '_bsf_event_title', true ); $event_org = get_post_meta( $post->ID, '_bsf_event_organization', true ); $event_street = get_post_meta( $post->ID, '_bsf_event_street', true ); $event_local = get_post_meta( $post->ID, '_bsf_event_local', true ); $event_region = get_post_meta( $post->ID, '_bsf_event_region', true ); $event_desc = get_post_meta( $post->ID, '_bsf_event_desc', true ); $event_start_date = get_post_meta( $post->ID, '_bsf_event_start_date', true ); $event_end_date = get_post_meta( $post->ID, '_bsf_event_end_date', true ); $event_geo_latitude = get_post_meta( $post->ID, '_bsf_event_geo_latitude', true ); $event_geo_longitude = get_post_meta( $post->ID, '_bsf_event_geo_longitude', true ); $event_photo = get_post_meta( $post->ID, '_bsf_event_photo', true ); if(trim($event_photo) != "") $event .= ''; if(trim($event_title) != "") $event .= ''; if(trim($event_desc) != "") $event .= ''; if(trim($event_org) != "") $event .= ''; if(trim($event_street) != "") $event .= ''; if(trim($event_local) != "") $event .= ''; if(trim($event_region) != "") $event .= ''; if(trim($event_geo_latitude) != "") $event .= ''; if(trim($event_start_date) != "") $event .= ''; if(trim($event_end_date) != "") $event .= ''; $event .= '
Event : '.$event_title.'
Event Description : '.$event_desc.'
Location : '.$event_org.',
'.$event_street.',
'.$event_local.',
'.$event_region.'
GEO : '.$event_geo_latitude.' - '; if(trim($event_geo_longitude) != "") $event .= ''.$event_geo_longitude.'
Start Date : '.$event_start_date.'
End Date : '.$event_end_date.'
'; return $event; } else if($type == '4') { global $post; $organization = $content; $organization .= '

Organization Brief :

'; $organization .= '
'; $org_name = get_post_meta( $post->ID,'_bsf_organization_name', true ); $org_url = get_post_meta( $post->ID,'_bsf_organization_url', true ); $org_tel = get_post_meta( $post->ID,'_bsf_organization_tel', true ); $org_street = get_post_meta( $post->ID,'_bsf_organization_street', true ); $org_local = get_post_meta( $post->ID,'_bsf_organization_local', true ); $org_region = get_post_meta( $post->ID,'_bsf_organization_region', true ); $org_zip = get_post_meta( $post->ID,'_bsf_organization_zip', true ); $org_country = get_post_meta( $post->ID,'_bsf_organization_country', true ); $org_latitude = get_post_meta( $post->ID,'_bsf_organization_latitude', true ); $org_longitude = get_post_meta( $post->ID,'_bsf_organization_longitude', true ); if(trim($org_name) != "") $organization .= ''; if(trim($org_url) != "") $organization .= ''; if(trim($org_tel) != "") $organization .= ''; if(trim($org_street) != "") $organization .= ''; if(trim($org_local) != "") $organization .= ''; if(trim($org_region) != "") $organization .= ''; if(trim($org_zip) != "") $organization .= ''; if(trim($org_country) != "") $organization .= ''; if(trim($org_latitude) != "") $organization .= ''; $organization .= '
Organization Name : '.$org_name.'
Website : '.$org_url.'
Telephone No. : '.$org_tel.'
Address : '.$org_street.'
'.$org_local.'
'.$org_region.'
'.$org_zip.'
'.$org_country.'
GEO Location : '.$org_latitude.' - '; if(trim($org_longitude) != "") $organization .= ''.$org_longitude.'
'; return $organization; } else if($type == '5') { global $post; $people = $content; $people .= '

Short Bio:

'; $people .= '
'; $people_fn = get_post_meta( $post->ID, '_bsf_people_fn', true ); $people_nickname = get_post_meta( $post->ID, '_bsf_people_nickname', true ); $people_photo = get_post_meta( $post->ID, '_bsf_people_photo', true ); $people_job_title = get_post_meta( $post->ID, '_bsf_people_job_title', true ); $people_website = get_post_meta( $post->ID, '_bsf_people_website', true ); $people_company = get_post_meta( $post->ID, '_bsf_people_company', true ); $people_local = get_post_meta( $post->ID, '_bsf_people_local', true ); $people_region = get_post_meta( $post->ID, '_bsf_people_region', true ); if(trim($people_photo) != "") $people .= ''; if(trim($people_fn) != "") $people .= ''; if(trim($people_website) != "") $people .= ''; if(trim($people_job_title) != "") $people .= ''; if(trim($people_company) != "") $people .= ''; if(trim($people_local) != "") $people .= ''; $people .= '
'.$people_fn.''; if(trim($people_nickname) != "") $people .= ' ('.$people_nickname.')
'.$people_website.'
'.$people_job_title.'
'.$people_company.'
'.$people_local.', '; if(trim($people_region) != "") $people .= ''.$people_region.'
'; return $people; } else if($type == '6') { global $post; $product = $content; $product .= '

Product Summary :

'; $product .= '
'; $product_rating = get_post_meta( $post->ID, '_bsf_product_rating', true); $product_brand = get_post_meta( $post->ID, '_bsf_product_brand', true); $product_name = get_post_meta( $post->ID, '_bsf_product_name', true); $product_image = get_post_meta($post->ID, '_bsf_product_image', true); $product_cat = get_post_meta($post->ID, '_bsf_product_cat', true); $product_price = get_post_meta($post->ID, '_bsf_product_price', true); $product_status = get_post_meta($post->ID, '_bsf_product_status', true); if(trim($product_status) == "out_of_stock") $availability = "Out of Stock"; else if(trim($product_status) == "in_stock") $availability = "Available in Stock"; else if(trim($product_status) == "instore_only") $availability = "Available in Store Only"; else if(trim($product_status) == "preorder") $availability = "Pre-Order Only"; if(trim($product_rating) != "") $product .= ''; if(trim($product_brand) != "") $product .= ''; if(trim($product_name) != "") $product .= ''; if(trim($product_cat) != "") $product .= ''; if(trim($product_image) != "") $product .= ''; if(trim($product_status) != "") $product .= ''; if(trim($product_image) != "") $product .= ''; $product .= '
Rating : '.$product_rating.'
Brand Name : '.$product_brand.'
Product Name : '.$product_name.'
Category : '.$product_cat.'
Price : '.$product_price.'
Availability : '.$availability.'
'; return $product; } else if($type == '7') { global $post; $recipe = $content; $recipe .= '

Recipe in Short :

'; $recipe .= '
'; $recipes_name = get_post_meta( $post->ID, '_bsf_recipes_name', true ); $recipes_preptime = get_post_meta( $post->ID, '_bsf_recipes_preptime', true ); $recipes_cooktime = get_post_meta( $post->ID, '_bsf_recipes_cooktime', true ); $recipes_totaltime = get_post_meta( $post->ID, '_bsf_recipes_totaltime', true ); $recipes_photo = get_post_meta( $post->ID, '_bsf_recipes_photo', true ); $recipes_desc = get_post_meta( $post->ID, '_bsf_recipes_desc', true ); $recipes_ingredient = get_post_meta( $post->ID, '_bsf_recipes_ingredient', true ); $comments = wp_count_comments(); $count = $comments->approved; $agregate = average_rating(); if(trim($recipes_photo) != "") $recipe .= ''; if(trim($recipes_name) != "") $recipe .= 'Recipe Name: '.$recipes_name.'
'; $recipe .= 'Published on :
'; if(trim($recipes_preptime) != "") $recipe .= 'Prep. Time :
'; if(trim($recipes_cooktime) != "") $recipe .= 'Cook Time :
'; // $recipe .= display_rating(); return $recipe; } else if($type == '8') { global $post; $software = $content; $software .= '

Software Overview :

'; $software .= '
'; $software_rating = get_post_meta( $post->ID, '_bsf_software_rating', true); $software_name = get_post_meta( $post->ID, '_bsf_software_name', true ); $software_desc = get_post_meta( $post->ID, '_bsf_software_desc', true ); $software_landing = get_post_meta( $post->ID, '_bsf_software_landing', true ); $software_image = get_post_meta( $post->ID, '_bsf_software_image', true ); $software_price = get_post_meta( $post->ID, '_bsf_software_price', true ); $software_os = get_post_meta( $post->ID, '_bsf_software_os', true ); if(trim($software_image) != "") $software .= ''; if(trim($software_rating) != "") $software .= ''; if(trim($software_name) != "") $software .= ''; if(trim($software_os) != "") $software .= ''; if(trim($software_price) != "") $software .= ''; if(trim($software_desc) != "") $software .= ''; if(trim($software_landing) != "") $software .= ''; $software .= '
Rating :
'.$software_rating.'
Name : '.$software_name.'
Operating System : '.$software_os.'
Price :
'.$software_price.'
Description : '.$software_desc.'
Landing Page :
'; return $software; } else if($type == '9') { global $post; $video = $content; $video .= '

Video Summary :

'; $video .= '
'; $video_title = get_post_meta( $post->ID, '_bsf_video_title', true ); $video_desc = get_post_meta( $post->ID, '_bsf_video_desc', true ); $video_thumb = get_post_meta( $post->ID, '_bsf_video_thumb', true ); $video_url = get_post_meta( $post->ID, '_bsf_video_url', true ); $video_duration = get_post_meta( $post->ID, '_bsf_video_duration', true ); $video_date = get_post_meta( $post->ID, '_bsf_video_date', true ); if(trim($video_url) != "") $video .= ''; if(trim($video_title) != "") $video .= ''; if(trim($video_desc) != "") $video .= ''; if(trim($video_thumb) != "") $video .= ''; if(trim($video_duration) != "") $video .= ''; if(trim($video_date) != "") $video .= ''; $video .= '

'.$video_title.'

'.$video_desc.'

'; return $video; } else { return $content; } } //Filter the content and return with rich snippet output add_filter('the_content','display_rich_snippet'); require_once('meta-boxes.php'); wp_enqueue_style('rating.css', plugin_dir_url(__FILE__) . 'css/jquery.rating.css'); wp_enqueue_script('jquery'); wp_enqueue_script('jquery.rating', plugin_dir_url(__FILE__) . 'js/jquery.rating.min.js', array('jquery')); function display_rating() { $rating .= '
Your Rating:
'; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= '
'; return $rating; } function average_rating() { global $wpdb; $post_id = get_the_ID(); $ratings = $wpdb->get_results(" SELECT $wpdb->commentmeta.meta_value FROM $wpdb->commentmeta INNER JOIN $wpdb->comments on $wpdb->comments.comment_id=$wpdb->commentmeta.comment_id WHERE $wpdb->commentmeta.meta_key='rating' AND $wpdb->comments.comment_post_id=$post_id AND $wpdb->comments.comment_approved =1 "); $counter = 0; $average_rating = 0; if ($ratings) { foreach ($ratings as $rating) { $average_rating = $average_rating + $rating->meta_value; $counter++; } //round the average to the nearast 1/2 point return (round(($average_rating/$counter)*2,0)/2); } else { //no ratings return 'no rating'; } }