ID ) ) { return; } $type = get_post_meta($post->ID, '_bsf_post_type', true); if($type){ add_action('wp_enqueue_scripts', 'aiosrs_enque'); } } function aiosrs_enque( ) { wp_enqueue_style('rating_style', plugin_dir_url(__FILE__) . 'css/jquery.rating.css'); wp_enqueue_script('jquery_rating', plugin_dir_url(__FILE__) . 'js/jquery.rating.min.js', array('jquery')); wp_register_style( 'bsf_style', plugins_url('/css/style.css', __FILE__) ); wp_enqueue_style('bsf_style'); } function bsf_initialize_bsf_meta_boxes() { if ( ! class_exists( 'bsf_Meta_Box' ) ) require_once plugin_dir_path( __FILE__ ).'init.php'; } //Function to display the rich snippet output below the content function display_rich_snippet($content) { global $post; $args_color = get_option('bsf_custom'); $id = $post->ID; $type = get_post_meta($id, '_bsf_post_type', true); if($type == '1') { global $post; $args_review = get_option('bsf_review'); $review = ''; $review .= '
'; if($args_review['review_title'] != "") $review .= '
'.esc_attr(stripslashes( $args_review['review_title'] ) ).'
'; $review .= '
'; $item = get_post_meta( $post->ID, '_bsf_item_name', true ); $rating = get_post_meta( $post->ID, '_bsf_rating', true ); $reviewer = get_post_meta( $post->ID, '_bsf_item_reviewer', true); $post_date = get_the_date('Y-m-d'); if(trim($reviewer) != "") { if($args_review['item_reviewer'] != "") $review .= '"; } if(isset($args_review['review_date'])) { if( $args_review['review_date'] != "") $review .= "
".esc_attr(stripslashes( $args_review['review_date'] ) ) ."
"; $review .= "
"; } if(trim($item) != "") { if( $args_review['item_name'] != "") $review .= "
".esc_attr(stripslashes( $args_review['item_name'] ) )."
"; $review .= "
".esc_attr($item )."
"; } if(trim($rating) != "") { if( $args_review['item_rating'] != "") $review .= "
".esc_attr(stripslashes( $args_review['item_rating'] ) )."
"; $review .= "
".esc_attr( $rating ).""; for($i = 1; $i<=ceil($rating); $i++) { $review .= '1star'; } for($j = 0; $j<=5-ceil($rating); $j++) { if($j) $review .= 'gray'; } $review .= '
'; } $review .= "
"; return ( is_single() || is_page() ) ? $content.$review : $content; } else if($type == '2') { global $post; $args_event = get_option('bsf_event'); $event = ''; $event .= '
'; if($args_event['snippet_title'] != "") $event .= '
'.esc_attr( stripslashes( $args_event['snippet_title'] ) ).'
'; $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_postal_code = get_post_meta( $post->ID, '_bsf_event_postal_code', true ); $event_image = get_post_meta($post->ID, '_bsf_event_image', true); //$event_performer = get_post_meta( $post->ID, '_bsf_event_performer', 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_description = get_post_meta( $post->ID, '_bsf_event_desc', true ); $event_ticket_url = get_post_meta( $post->ID, '_bsf_event_ticket_url', true ); $event_price = get_post_meta( $post->ID, '_bsf_event_price', true ); $event_cur = get_post_meta( $post->ID, '_bsf_event_cur', true ); if(trim($event_image) != "") { $event .= '
event
'; } else { $event .= ''; } $event .= '
'; if(trim($event_title) != "") { if( $args_event['event_title']) $event .= '
'.esc_attr(stripslashes( $args_event['event_title']) ).'
'; $event .='
'.esc_attr( $event_title ).'
'; } if(trim($event_org) != "") { if( $args_event['event_location'] != "") $event .= '
'.esc_attr( stripslashes( $args_event['event_location'] ) ).'
'; $event .='
'.esc_attr( $event_org ).','; } if(trim($event_street) != "") $event .= ' '.esc_attr( $event_street ).','; if(trim($event_local) != "") $event .= ''.esc_attr( $event_local ).','; if(trim($event_region) != "") $event .= ''.esc_attr( $event_region ).''; if(trim($event_postal_code) != "") $event .= '-'.esc_attr( $event_postal_code ).''; $event .= ''; $event .='
'; if(trim($event_start_date) != "") { if( $args_event['start_time'] != "") $event .= '
'.esc_attr( stripslashes( $args_event['start_time'] ) ).'
'; $event .= '
'.esc_attr( $event_start_date ).'
'; } if(trim($event_end_date) != "") { if( $args_event['end_time'] != "") $event .= '
'.esc_attr( stripslashes( $args_event['end_time'] ) ).'
'; $event .= '
'.esc_attr( $event_end_date ).'
'; } if(trim($event_description) != "") { if( $args_event['event_desc'] != "") $event .= '
'.esc_attr( stripslashes( $args_event['event_desc'] ) ).'
'; $event .= '
'.esc_attr( htmlspecialchars_decode( $event_description ) ).'
'; } if(trim($event_price) != "") { if($args_event['events_price'] != "") $event .= '
'.esc_attr( stripslashes( $args_event['events_price'] ) ).'
'; $event .= '
'.esc_attr( $event_cur ).''.' '.esc_attr( $event_price ).'
'; } $event .= '
'; return ( is_single() || is_page() ) ? $content.$event : $content; } else if($type == '4') { global $post; $organization = ''; $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 .= 'Organization Name : '.esc_attr( $org_nam ).'
'; if(trim($org_url) != "") $organization .= 'Website : '.esc_attr( $org_url ).''; if(trim($org_tel) != "") $organization .= 'Telephone No. : '.esc_attr( $org_tel ).''; if(trim($org_street) != "") $organization .= 'Address : '.esc_attr( $org_street ).''; if(trim($org_local) != "") $organization .= ''.esc_attr( $org_local ).''; if(trim($org_region) != "") $organization .= ''.esc_attr( $org_region ).''; if(trim($org_zip) != "") $organization .= ''.esc_attr( $org_zip ).''; if(trim($org_country) != "") $organization .= ''.esc_attr( $org_country ).' '; if(trim($org_latitude) != "") $organization .= 'GEO Location : '.esc_attr( $org_latitude ).' - '; if(trim($org_longitude) != "") $organization .= ''.esc_attr( $org_longitude ).' '; $organization .= '
'; return ( is_single() || is_page() ) ? $content.$organization : $content; } else if($type == '5') { global $post; $args_person = get_option('bsf_person'); $people = ''; $people .= '
'; if($args_person['snippet_title'] != "") $people .= '
'.esc_attr( stripslashes( $args_person['snippet_title'] ) ).'
'; $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 ); $people_street = get_post_meta( $post->ID, '_bsf_people_street', true ); $people_postal = get_post_meta( $post->ID, '_bsf_people_postal', true ); if(trim($people_photo) != "") { $people .= '
Photo of'.esc_attr( $people_fn ).'
'; } else { $people .= ''; } $people .= '
'; if(trim($people_fn) != "") { if($args_person['person_name'] != "") $people .= '
'.esc_attr( stripslashes( $args_person['person_name'] ) ).'
'; $people .= '
'.esc_attr( $people_fn ).'
'; } if(trim($people_nickname) != "") { if($args_person['person_nickname'] != "") $people .= '
'.esc_attr( stripslashes( $args_person['person_nickname'] ) ).'
'; $people .= '
('.esc_attr( $people_nickname ).')
'; } if(trim($people_website) != "") { if($args_person['person_website'] != "") $people .= '
'.esc_attr( stripslashes( $args_person['person_website'] ) ).'
'; $people .= '
'; } if(trim($people_job_title) != "") { if($args_person['person_job_title'] != "") $people .= '
'.esc_attr( stripslashes( $args_person['person_job_title'] ) ).'
'; $people .= '
'.esc_attr( $people_job_title ).'
'; } if(trim($people_company) != "") { if($args_person['person_company'] != "") $people .= '
'; $people .= '
'.esc_attr( stripslashes( $args_person['person_company'] ) ).'
'; $people .= '
'.esc_attr( $people_company ).'
'; $people .= '
'; } if(trim($people_street) != "") { if($args_person['person_address'] != "") $people .= '
'.esc_attr( stripslashes( $args_person['person_address'] ) ).'
'; $people .= '
'; $people .= ''; $people .= ''.esc_attr( $people_street ).',
'; if(trim($people_local) != "") { $people .= ''.esc_attr( $people_local ).', '; } if(trim($people_region) != "") { $people .= ''.esc_attr( $people_region ).', '; } if(trim($people_postal) != "") { $people .= ''.esc_attr( $people_postal ).''; } $people .= '
'; $people .= '
'; $people .= '
'; } $people .= '
'; return ( is_single() || is_page() ) ? $content.$people : $content; } else if($type == '6') { global $post; $args_product = get_option('bsf_product'); $product = ''; $product .= '
'; if($args_product['snippet_title'] != "") $product .= '
'.esc_attr( stripslashes( $args_product['snippet_title'] ) ); $product .= bsf_do_rating(); $product .= '
'; $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_cur = get_post_meta($post->ID, '_bsf_product_cur', true); $product_status = get_post_meta($post->ID, '_bsf_product_status', true); if(trim($product_status) == "out_of_stock"){ $product_status = 'OutOfStock'; $availability = "Out of Stock"; } else if(trim($product_status) == "in_stock"){ $product_status = 'InStock'; $availability = "Available in Stock"; } else if(trim($product_status) == "instore_only"){ $product_status = 'InStoreOnly'; $availability = "Available in Store Only"; } else if(trim($product_status) == "preorder"){ $availability = "Pre-Order Only"; } if(trim($product_image) != "") { $product .= '
product image
'; } else { $product .= ''; } $product .= '
'; if(trim($product_rating) != "") { if($args_product['product_brand'] != "") $product .= '
'.$args_product['product_rating'].'
'; $product .= '
'; for($i = 1; $i<=ceil($product_rating); $i++) { $product .= '1star'; } for($j = 0; $j<=5-ceil($product_rating); $j++) { if($j) $product .= 'gray'; } $product .= '
'; } $product .= '
'; if($args_product['product_agr'] != "") { $product .= '
'.esc_attr( stripslashes( $args_product['product_agr'] ) ).'
'; } $product .= '
'; $product .= ''.average_rating().''; $product .= ' based on '.rating_count().' votes
'; if(trim($product_brand) != "") { if($args_product['product_brand'] != "") $product .= '
'.esc_attr( stripslashes( $args_product['product_brand'] ) ).'
'; $product .= '
'.esc_attr( $product_brand ).'
'; } if(trim($product_name) != "") { if($args_product['product_name'] != "") $product .= '
'.esc_attr( stripslashes( $args_product['product_name'] ) ).'
'; $product .= '
'.esc_attr( $product_name ).'
'; } if(trim($product_price) != "") { if($args_product['product_price'] != "") $product .= '
'.esc_attr( stripslashes( $args_product['product_price'] ) ).'
'; $product .= '
'.esc_attr( $product_cur ).''.' '.esc_attr( $product_price ).'
'; if(trim($product_status) != "") { if($args_product['product_avail'] != "") $product .= '
'.esc_attr( stripslashes( $args_product['product_avail'] ) ).'
'; $product .= '
'.esc_attr( $availability ).'
'; } $product .= '
'; } $product .= '
'; return ( is_single() || is_page() ) ? $content.$product : $content; } else if($type == '7') { global $post; $recipe = ''; $recipe .= '
'; $args_recipe = get_option('bsf_recipe'); if($args_recipe['snippet_title'] != "" ) { $recipe .= '
'.esc_attr( stripslashes( $args_recipe['snippet_title'] ) ); $recipe .= bsf_do_rating(); } $recipe .= '
'; $recipe .= '
'; $recipes_name = get_post_meta( $post->ID, '_bsf_recipes_name', true ); $authors_name = get_post_meta( $post->ID, '_bsf_authors_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_nutrition = get_post_meta( $post->ID, '_bsf_recipes_nutrition', true ); $recipes_ingredient = get_post_meta( $post->ID, '_bsf_recipes_ingredient', true ); $count = rating_count(); $agregate = average_rating(); if(trim($recipes_photo) != "") { $recipe .= '
recipe image
'; } else { $recipe .= ''; } $recipe .= '
'; if(trim($recipes_name) != "") { if($args_recipe['recipe_name'] != "") $recipe .= '
'.esc_attr( stripslashes( $args_recipe['recipe_name'] ) ).'
'; $recipe .= '
'.esc_attr( $recipes_name ).'
'; } if(trim($authors_name) != "") { if($args_recipe['author_name'] != "") $recipe .= '
'.esc_attr( stripslashes( $args_recipe['author_name'] ) ).'
'; $recipe .= '
'; } $recipe .= '
'.esc_attr( stripslashes( $args_recipe['recipe_pub'] ) ).'
'; if(trim($recipes_preptime) != "") { if($args_recipe['recipe_prep'] != "") $recipe .= '
'.esc_attr( stripslashes( $args_recipe['recipe_prep'] ) ).'
'; $recipe .= '
'; } if(trim($recipes_cooktime) != "") { if($args_recipe['recipe_cook'] != "") $recipe .= '
'.esc_attr( stripslashes( $args_recipe['recipe_cook'] ) ).'
'; $recipe .= '
'; } if(trim($recipes_totaltime) != "") { if($args_recipe['recipe_time'] != "") $recipe .= '
'.esc_attr( stripslashes( $args_recipe['recipe_time'] ) ).'
'; $recipe .= '
'; } if($args_recipe['recipe_rating'] != "" && $count > 0) { $recipe .= '
'.esc_attr( stripslashes( $args_recipe['recipe_rating'] ) ).'
'; $recipe .= '
'.esc_attr( $agregate ).''; for($i = 1; $i<=ceil($agregate); $i++) { $recipe .= '1star'; } for($j = 0; $j<=5-ceil($agregate); $j++) { if($j) $recipe .= 'gray'; } $recipe .= ' Based on '.esc_attr( $count ).' Review(s)
'; } $recipe .= '
'; return ( is_single() || is_page() ) ? $content.$recipe : $content; } else if($type == '8') { global $post; $args_soft = get_option('bsf_software'); $software = ''; $software .= '
'; if($args_soft['snippet_title'] != "" ) $software .= '
'.esc_attr( stripslashes( $args_soft['snippet_title'] ) ); $software .= bsf_do_rating(); $software .= '
'; $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_cur = get_post_meta($post->ID, '_bsf_software_cur', true); $software_os = get_post_meta( $post->ID, '_bsf_software_os', true ); $software_cat = get_post_meta( $post->ID, '_bsf_software_cat', true ); if(trim($software_image) != "") { $software .= '
software image
'; } else { $software .= ''; } $software .= '
'; if(trim($software_rating) != "") { $software .= '
'.esc_attr( stripslashes( $args_soft['software_rating'] ) ).'
'; $software .= '
'; for($i = 1; $i<=ceil($software_rating); $i++) { $software .= '1star'; } for($j = 0; $j<=5-ceil($software_rating); $j++) { if($j) $software .= 'gray'; } $software .= '
'; } $software .= '
'; $software .= '
'.esc_attr( stripslashes( $args_soft['software_agr'] ) ).'
'; $software .= '
'; $software .= ''.average_rating().''; $software .= ' based on '.rating_count().' votes
'; if(trim($software_name) != "") { if($args_soft['software_name'] != "") $software .= '
'.esc_attr( stripslashes( $args_soft['software_name'] ) ).'
'; $software .= '
'.esc_attr( $software_name ).'
'; } if(trim($software_os) != "") { if($args_soft['software_os'] != "") $software .= '
'.esc_attr( stripslashes( $args_soft['software_os'] ) ).'
'; $software .= '
'.esc_attr( $software_os ).'
'; } if(trim($software_cat) != "") { $software .= '
Software Category
'; $software .= '
'.esc_attr( $software_cat ).'
'; } if(trim($software_price) != "") { if($args_soft['software_price'] != "") $software .= '
'.esc_attr( stripslashes( $args_soft['software_price'] ) ).'
'; $software .= '
'.esc_attr( $software_cur ).' '.esc_attr( $software_price ).'
'; } if(trim($software_desc) != "") { if($args_soft['software_desc'] != "") $software .= '
'.esc_attr( stripslashes( $args_soft['software_desc'] ) ).'
'; $software .= '
'.esc_attr( htmlspecialchars_decode( $software_desc ) ).'
'; } if(trim($software_landing) != "") { if($args_soft['software_website'] != "") $software .= '
'.esc_attr( stripslashes( $args_soft['software_website'] ) ).'
'; $software .= '
'; } $software .= '
'; return ( is_single() || is_page() ) ? $content.$software : $content; } else if($type == '9') { global $post; $args_video = get_option('bsf_video'); $video = ''; $video .= '
'; if($args_video['snippet_title'] != "" ) $video .= '
'.esc_attr( stripslashes( $args_video['snippet_title'] ) ).'
'; $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_emb_url = get_post_meta( $post->ID, '_bsf_video_emb_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 .= '
'.esc_attr( $video_title ).'
'; } elseif (trim($video_emb_url) != "") { $video .= '
'.esc_attr( $video_title ).'
'; } else { $video .= ''; } $video .= '
'; if(trim($video_title) != "") { if($args_video['video_title'] != "" ) $video .= '
'.esc_attr( stripslashes( $args_video['video_title'] ) ).'
'; $video .= '
'.esc_attr( $video_title ).'
'; } if(trim($video_desc) != "") { if($args_video['video_desc'] != "" ) $video .= '
'.esc_attr( stripslashes( $args_video['video_desc'] ) ).'
'; $video .= '

'.esc_attr( htmlspecialchars_decode( $video_desc ) ).'

'; } if(trim($video_thumb) != "") $video .= ''; if(trim($video_url) != ""){ $video .= ''; } elseif(trim($video_emb_url) != ""){ $video .= ''; } if(trim($video_duration) != "") $video .= ''; if(trim($video_date) != "") $video .= ''; $video .= '
'; return ( is_single() || is_page() ) ? $content.$video : $content; } else if($type == '10') { global $post; $article = ''; $args_article = get_option('bsf_article'); $article_title = get_post_meta( $post->ID, '_bsf_article_title', true ); $article_name = get_post_meta( $post->ID, '_bsf_article_name', true ); $article_desc = get_post_meta( $post->ID, '_bsf_article_desc', true ); $article_image = get_post_meta( $post->ID, '_bsf_article_image', true ); $article_author = get_post_meta( $post->ID, '_bsf_article_author', true ); $article_publisher = get_post_meta( $post->ID, '_bsf_article_publisher', true ); $article_publisher_logo = get_post_meta( $post->ID, '_bsf_article_publisher_logo', true ); $article .= '
'; if($args_article['snippet_title'] != "" ) { $article .= '
'.esc_attr( stripslashes( $args_article['snippet_title'] ) ); $article .= '
'; } $article .= '
'; if(trim($article_image) != "") { $article .= '
'; $article .= ''.esc_attr( $article_name ).''; $article .= ''; $article .= '
'; } else { $article .= ''; } $article .= '
'; if(trim($article_name) != "") { if($args_article['article_name'] != "") $article .= '
'.esc_attr( stripslashes( $args_article['article_name'] ) ).'
'; $article .= '
'.esc_attr( $article_name ).'
'; } if(trim($article_desc) != "") { if($args_article['article_desc'] != "") $article .= '
'.esc_attr( stripslashes( $args_article['article_desc'] ) ).'
'; $article .= '
'.esc_attr( htmlspecialchars_decode( $article_desc ) ).'
'; } if(trim($article_author) != "") { if($args_article['article_author'] != "") $article .= '
'.esc_attr( stripslashes( $args_article['article_author'] ) ).'
'; $article .= '
'; } if(trim($article_publisher) != "") { if($args_article['article_publisher'] != "") $article .= '
'; $article .= '
'.esc_attr( stripslashes( $args_article['article_publisher'] ) ).'
'; $article .= '
'.esc_attr( $article_publisher ).'
'; if(trim($article_publisher_logo) != "") { if($args_article['article_publisher_logo'] != "") $article .= '
'.esc_attr( stripslashes( $args_article['article_publisher_logo'] ) ).'
'; $article .= ''; } $article .= '
'; } $article .= ''; $article .= ''; $article .= ''; $article .= '
'; return ( is_single() || is_page() ) ? $content.$article : $content; }else if($type == '11') { global $post; $service = ''; $args_service = get_option('bsf_service'); $service_type = get_post_meta( $post->ID, '_bsf_service_type', true ); $service_area = get_post_meta( $post->ID, '_bsf_service_area', true ); $service_desc = get_post_meta( $post->ID, '_bsf_service_desc', true ); $service_image = get_post_meta( $post->ID, '_bsf_service_image', true ); $service_provider_name = get_post_meta( $post->ID, '_bsf_service_provider', true ); $service_street = get_post_meta( $post->ID, '_bsf_service_street', true ); $service_local = get_post_meta( $post->ID, '_bsf_service_local', true ); $service_region = get_post_meta( $post->ID, '_bsf_service_region', true ); $service_postal_code = get_post_meta( $post->ID, '_bsf_service_postal_code', true ); $service_provider_location_image = get_post_meta( $post->ID, '_bsf_provider_location_image', true ); $service_telephone = get_post_meta( $post->ID, '_bsf_service_telephone', true ); $service_price = get_post_meta( $post->ID, '_bsf_service_price', true ); $service_cur = get_post_meta( $post->ID, '_bsf_service_cur', true ); $service_rating = get_post_meta( $post->ID, '_bsf_service_rating', true ); $service_rating_switch = get_post_meta( $post->ID, '_bsf_service_rating_switch', true ); $service_channel = get_permalink( $post->ID ); $service_url_link = $args_service['service_url_link'] != ''? $args_service['service_url_link'] : "Click Here For More Info"; $service .= '
'; if($args_service['snippet_title'] != "" ) { $service .= '
'.esc_attr( stripslashes( $args_service['snippet_title'] ) ); if ( $service_rating_switch == 'enable' ) { $service .= bsf_do_rating(); } $service .= '
'; } $service .= '
'; if(trim($service_image) != "") { $service .= '
'; $service .= ''.esc_attr( $service_type ).''; $service .= '
'; } else { $service .= ''; } $service .= '
'; if( average_rating() > 0 ){ if($args_service['service_rating'] != "") { $service .= '
'; $service .= '
'.esc_attr( stripslashes( $args_service['service_rating'] ) ).'
'; $service .= '
'; $service .= ''.average_rating().''; $service .= ' based on '.rating_count().' votes
'; } } if(trim($service_type) != "") { if($args_service['service_type'] != "") $service .= '
'.esc_attr( stripslashes( $args_service['service_type'] ) ).'
'; $service .= '
'.esc_attr( $service_type ).'
'; } if(trim($service_provider_name) != "") { if($args_service['service_provider_name'] != "") $service .= '
'.esc_attr( stripslashes( $args_service['service_provider_name'] ) ).'
'; $service .= '
'.esc_attr( $service_provider_name ).','; if(trim($service_street) != "") $service .= '
'.esc_attr( $service_street ).','; if(trim($service_local) != "") $service .= ''.esc_attr( $service_local ).','; if(trim($service_region) != "") $service .= ''.esc_attr( $service_region ).'-'; if(trim($service_postal_code) != "") $service .= ''.esc_attr( $service_postal_code ).',
'; if(trim($service_telephone) != "") $service .= ' Telephone No.'.esc_attr( $service_telephone ).''; $service .= '
'; $service .= '
'; } if(trim($service_area) != "") { if($args_service['service_area'] != "") $service .= '
'.esc_attr( stripslashes( $args_service['service_area'] ) ).'
'; $service .= '
'.esc_attr( $service_area ).'
'; } if(trim($service_desc) != "") { if($args_service['service_desc'] != "") $service .= '
'.esc_attr( stripslashes( $args_service['service_desc'] ) ).'
'; $service .= '
'.esc_attr( htmlspecialchars_decode( $service_desc ) ).'
'; } if(trim($service_channel) != "") { if($args_service['service_channel'] != "") $service .= '
'; } $service .= '
'; return ( is_single() || is_page() ) ? $content.$service : $content; } else { return $content; } } add_filter('the_content','display_rich_snippet', 90); require_once(plugin_dir_path( __FILE__ ).'meta-boxes.php'); function get_the_ip() { if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { return $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) { return $_SERVER["HTTP_CLIENT_IP"]; } else { return $_SERVER["REMOTE_ADDR"]; } } function average_rating() { global $post; $data = get_post_meta($post->ID, 'post-rating', false); $post_id = $post->ID; if( !empty($data) ) { $counter = 0; $average_rating = 0; foreach($data as $d) { $rating = $d['user_rating']; $average_rating = $average_rating + $rating; $counter++; } //round the average to the nearast 1/2 point return (round(($average_rating/$counter)*2,0)/2); } else { //no ratings return 'no rating'; } } function rating_count() { global $post; $data = get_post_meta($post->ID, 'post-rating', false); return count($data); } function bsf_do_rating() { global $post; $ip = get_the_ip(); $ip_array = array(); $data = get_post_meta($post->ID, 'post-rating', false); if( !empty($data)) { foreach($data as $d) { array_push($ip_array,$d['user_ip']); } if(!in_array($ip,$ip_array) ) { return display_rating(); } else if(in_array($ip,$ip_array) ) { $rating = get_previous_rating($ip, $data); $stars = bsf_display_rating($rating); return $stars; } } else { return display_rating(); } } function get_previous_rating($needle, $haystack, $strict = false) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && get_previous_rating($needle, $item, $strict))) { return !empty($item['user_rating']) ? esc_attr( $item['user_rating'] ) : ''; } } return false; } function add_ajax_library() { $html = ''; echo $html; } function bsf_add_rating() { if(isset($_POST['star-review'])) $stars = esc_attr( $_POST['star-review'] ); else $stars = '0'; $ip = esc_attr( $_POST['ip'] ); $postid = esc_attr( $_POST['post_id'] ); $user_rating = array('post_id' => $postid, 'user_ip' => $ip, 'user_rating' => $stars); echo false == add_post_meta($postid, 'post-rating', $user_rating) ? _e('Error adding your rating') : _e('Ratings added successfully !'); die(); } function bsf_update_rating() { if(isset($_POST['star-review'])) $stars = esc_attr( $_POST['star-review'] ); else $stars = '0'; $ip = esc_attr( $_POST['ip'] ); $postid = esc_attr( $_POST['post_id'] ); $prev_data = get_post_meta($postid,'post-rating',true); $user_rating = array('post_id' => $postid, 'user_ip' => $ip, 'user_rating' => $stars); echo false == update_post_meta($postid, 'post-rating', $user_rating, $prev_data) ? _e('Error updating your rating') : _e('Ratings updated successfully !'); die(); } function display_rating() { global $post; $rating = '
'; $rating .= '
'; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= ''; $rating .= '
'; $rating .= '
'; $script = ' '; $rating .= $script; return $rating; } function bsf_display_rating($n) { global $post; $rating = '
'; $rating .= '
'; $rating .= ''; $rating .= ''; $rating .= '
'; $rating .= '
'; $script = ' '; $rating .= $script; return $rating; }