#content .aps_container { float: left; }'; } elseif ($aps_float_option == 'center') { echo ''; } elseif ($aps_float_option == 'right') { echo ''; } else { } } add_action('wp_head', 'aps_float_func', 10, 1); /** * * Add width * *********/ function aps_width_func() { $aps_width_option_all = get_option( '_ap-schema--options' ); $aps_width_option = $aps_width_option_all['aps_width']; if ($aps_width_option !== '') { echo ''; } } add_action('wp_head', 'aps_width_func', 10, 1); /* * shortcodes * ******************************************************************/ function aps_pretty_date($date) { $aps_users_date_format = get_option('date_format'); $newDate = date($aps_users_date_format, strtotime($date)); return $newDate; } function aps_schema_shortcodes( $atts, $content = null) { $aps_style_option_all = get_option( '_ap-schema--options' ); $aps_google_id = $aps_style_option_all['aps_google_id']; global $wpdb; extract( shortcode_atts( array( 'type' => '', 'name' => '' ), $atts ) ); $tablename = $wpdb->prefix . "aps_" . "$type"; $save_name = $type . "_save_name"; $name = addslashes($name); //$aps_get_schema_data = $wpdb->get_row("SELECT * FROM $tablename WHERE $save_name = '$name'"); $aps_get_schema_data = $wpdb->get_row( $wpdb->prepare( " SELECT * FROM $tablename WHERE $save_name = %s ", $name ) ); //convert to array so can stripslashes $aps_get_schema_data = (array)$aps_get_schema_data; //strip slashes foreach ($aps_get_schema_data as $key=>$value) { $aps_get_schema_data[$key] = stripslashes($value); } //convert back to object as cant be arsed going through the code and swapping the ouputs to array versions $aps_get_schema_data = (object)$aps_get_schema_data; //var_dump($aps_get_schema_data); if ($type == "book") { $originalDate = $aps_get_schema_data->book_pub_date; $aps_new_pretty_date = aps_pretty_date($originalDate); $aps_book_return = '
'; $aps_book_return .= '

' . $aps_get_schema_data->book_name . '

'; $aps_book_return .= ''; $aps_book_return .= '

' . $aps_get_schema_data->book_genre .' ' . $aps_get_schema_data->book_format . '

'; $aps_book_return .= ''; $aps_book_return .= '

' . $aps_get_schema_data->book_desc . '

'; $aps_book_return .= '

' . $aps_get_schema_data->book_publisher .'' . $aps_get_schema_data->book_isbn .'' . $aps_get_schema_data->book_edition . ''; $aps_book_return .= '

' . $aps_get_schema_data->book_review_by . '

'; $aps_book_return .= '
'; return $aps_book_return; } // end if book if ($type == "event") { $aps_new_pretty_date_start = aps_pretty_date($aps_get_schema_data->event_start_date); $aps_new_pretty_date_end = aps_pretty_date($aps_get_schema_data->event_end_date); $aps_event_type_header = str_replace(' ', '', $aps_get_schema_data->event_type); $aps_event_return = '
'; $aps_event_return .= '

' . $aps_get_schema_data->event_name . '

'; $aps_event_return .= ''; $aps_event_return .= '

Type: ' . $aps_get_schema_data->event_type .'Date: ' . $aps_new_pretty_date_start .'' . $aps_new_pretty_date_end . ' Time: ' . $aps_get_schema_data->event_start_time . ' - ' . $aps_get_schema_data->event_end_time . ' Duration: ' . $aps_get_schema_data->event_duration . '

'; $aps_event_return .= '

' . $aps_get_schema_data->event_desc . '

'; $aps_event_return .= '

' . $aps_get_schema_data->event_address .', '. $aps_get_schema_data->event_pobox .', '. $aps_get_schema_data->event_city .', '. $aps_get_schema_data->event_region .', '. $aps_get_schema_data->event_postalcode .', '. $aps_get_schema_data->event_country .' '. '

'; $aps_event_return .= '

' . $aps_get_schema_data->event_email . ' ' . $aps_get_schema_data->event_phone . '

'; $aps_event_return .= '

' . $aps_get_schema_data->event_review_by . '

'; $aps_event_return .= '
'; return $aps_event_return; } //end if event if ($type == "movie") { //$aps_movie_actors = explode(',', $aps_movie_actors); $aps_show_actors = ""; $aps_show_actors_get_data = unserialize($aps_get_schema_data->movie_actors); foreach ($aps_show_actors_get_data as $actors) { if($actors['value'] != '') { $aps_show_actors .= '' . $actors['value'] . '
'; } } $aps_movie_return = '
'; $aps_movie_return .= '

' . $aps_get_schema_data->movie_name . '

'; //add in genre? $aps_movie_return .= ''; $aps_movie_return .= '

' . $aps_get_schema_data->movie_desc . '

'; $aps_movie_return .= '

' . __('Director:', 'ap-schema') . ' ' . $aps_get_schema_data->movie_director .'' . __("Producer:", "ap-schema") . ' ' . $aps_get_schema_data->movie_producer . '

'; $aps_movie_return .= '

' . __("Actors", "ap-schema") . '
' . $aps_show_actors . '

'; $aps_movie_return .= '

' . $aps_get_schema_data->movie_review_by . '

'; $aps_movie_return .= '
'; return $aps_movie_return; } //end if movie if ($type == "organisation") { $aps_org_type_header = str_replace(' ', '', $aps_get_schema_data->organisation_type); $aps_organisation_return = '
'; $aps_organisation_return .= '

' . $aps_get_schema_data->organisation_name . '

'; $aps_organisation_return .= ''; $aps_organisation_return .= ''; $aps_organisation_return .= '

' . $aps_get_schema_data->organisation_type . '

'; $aps_organisation_return .= '

' . $aps_get_schema_data->organisation_desc . '

'; $aps_organisation_return .= '

' . $aps_get_schema_data->organisation_address .', '. $aps_get_schema_data->organisation_pobox .', '. $aps_get_schema_data->organisation_city .', '. $aps_get_schema_data->organisation_region .', '. $aps_get_schema_data->organisation_postalcode .', '. $aps_get_schema_data->organisation_country .'

'; $aps_organisation_return .= '

' . __("Email:", "ap-schema") . ' ' . $aps_get_schema_data->organisation_email . ' ' . __("Phone:", "ap-schema") . ' ' . $aps_get_schema_data->organisation_phone . ' ' . __("Fax:", "ap-schema") . ' ' . $aps_get_schema_data->organisation_fax . '

'; $aps_organisation_return .= '

' . $aps_get_schema_data->organisation_review_by . '

'; $aps_organisation_return .= '
'; return $aps_organisation_return; } // end if organisation if ($type == "person") { $aps_person_return = '
'; // create a default image, in case neither email nor url are added - in this case a 1x1 px transparent png //get image location $aps_gravatar_default = APSCHEMA_URLPATH . "/images/gravatar_dot.png"; $aps_gravatar_default = urlencode( $aps_gravatar_default ); $aps_new_pretty_date_birth = aps_pretty_date($aps_get_schema_data->person_birthday); // only one can rule! in this case url trumps email if($aps_get_schema_data->person_photo_url != '' && $aps_get_schema_data->person_email != '') { $aps_get_schema_data->person_email = ""; } else { $aps_get_schema_data->person_email = $aps_get_schema_data->person_email; } //now depending on what source we have show that as image or if no source, show nothing. if($aps_get_schema_data->person_photo_url != '' && $aps_get_schema_data->person_email == '') { $aps_person_return .= ''; } elseif ($aps_get_schema_data->person_email != '' && $aps_get_schema_data->person_photo_url == '') { $aps_gravatar_email = md5( strtolower( trim( $aps_get_schema_data->person_email ) ) ); $aps_person_return .= ''; } else { echo ''; } $aps_person_return .= '

' . $aps_get_schema_data->person_name . '

'; $aps_person_return .= '

' . __("Works for:", "ap-schema") . ' ' . $aps_get_schema_data->person_org . '

'; $aps_person_return .= '

' . __("Role:", "ap-schema") . ' ' . $aps_get_schema_data->person_job_title . '

'; $aps_person_return .= ''; $aps_person_return .= '

' . sanitize_text_field($aps_get_schema_data->person_desc) . '

'; $aps_person_return .= '

' . __("Birthday:", "ap-schema") . ' ' . $aps_new_pretty_date_birth . '

'; $aps_person_return .= '

' . $aps_get_schema_data->person_address .', '. $aps_get_schema_data->person_pobox .', '. $aps_get_schema_data->person_city .', '. $aps_get_schema_data->person_region .', '. $aps_get_schema_data->person_postalcode .', '. $aps_get_schema_data->person_country .', '. '

'; $aps_person_return .= '

' . __("Email:", "ap-schema") . ' ' . $aps_get_schema_data->person_email . ' ' . __("Phone:", "ap-schema") . ' ' . $aps_get_schema_data->person_phone . '' . __("Fax:", "ap-schema") . ' ' . $aps_get_schema_data->person_fax . '

'; $aps_person_return .= '

' . $aps_get_schema_data->person_review_by . '

'; $aps_person_return .= '
'; return $aps_person_return; } // end if person if ($type == "product") { //get the star option $aps_star_option = get_option( '_ap-schema--options' ); $aps_star_option = $aps_star_option['reviewicons']; if($aps_get_schema_data->product_startype == '') { $aps_get_schema_data->product_startype = $aps_star_option;} //get the currency symbol $aps_price_option = get_option( '_ap-schema--options' ); $aps_price_option = $aps_price_option['aps_price']; //get the star size $aps_starsize_option = get_option( '_ap-schema--options' ); $aps_starsize_option = $aps_starsize_option['reviewicons_size']; if ($aps_starsize_option == '') {$aps_starsize_option = '32';} /*********************** * * Star generation * **********************/ //set defaults $aps_product_avg_rating = $aps_get_schema_data->product_avg_rating; $aps_nearest_half = ''; $aps_decimal = ''; //round to neareast half //https://forums.digitalpoint.com/threads/round-number-to-nearest-half.943055/ if($aps_product_avg_rating >= ($half = ($ceil = ceil($aps_product_avg_rating))- 0.5) + 0.25) { $aps_nearest_half = $ceil; } else if($aps_product_avg_rating < $half - 0.25) { $aps_nearest_half = floor($aps_product_avg_rating); } else {$aps_nearest_half = $half; } //get the decimal check variable set $aps_decimal = $aps_nearest_half; //floor the nearest half variable $aps_floored_nearest_half = floor($aps_nearest_half); //generate stars based on floored value $star_list = ""; //set variable $star_url = ''; $i = 0; $max_count = $aps_floored_nearest_half; //// Lets max the count out at 100 so people dont add in stupid numbers and crash their site //// if ( $max_count > 100 ) { $max_count = 100; } ///////////////////////////////////////////////////////////////////////////////////////////////// while ($i < $max_count ) { $star_list .= $star_url . ''; ++$i; } //check if there is a decimal place - not that fucking easy as the ceil/floor return a float, even if the actual number is a whole number! //http://stackoverflow.com/questions/11041590/whole-number-or-decimal-number if ( is_numeric( $aps_decimal ) && strpos( $aps_decimal, '.' ) === false ) { $aps_decimal = "false";} else { $aps_decimal = "true";} if($aps_decimal === "true") { $star_list .= ''; } //top score possible //need a new setting for products i think! $aps_product_top_score = $aps_get_schema_data->product_max_score; //get the empty star count $aps_empty_starcount = $aps_product_top_score - $aps_nearest_half; $aps_empty_starcount = floor($aps_empty_starcount); //// Lets max the count out at 100 so people dont add in stupid numbers and crash their site //// if ( $aps_empty_starcount > 100 ) { $aps_empty_starcount = 100; } ///////////////////////////////////////////////////////////////////////////////////////////////// //add emtpy stars $empty_star_url = ''; $i = 0; $empty_max_count = $aps_empty_starcount; while ($i < $empty_max_count ) { $star_list .= $empty_star_url . ''; ++$i; } // END OF STAR GENERATION $aps_product_return = '
'; $aps_product_return .= '

' . $aps_get_schema_data->product_name . ' ' . $aps_get_schema_data->product_model . '

'; $aps_product_return .= '

' . $aps_get_schema_data->product_brand . ' ' . $aps_get_schema_data->product_manufacturer . '

'; $aps_product_return .= ''; $aps_product_return .= ''; $aps_product_return .= '

' . $aps_get_schema_data->product_desc . '

'; //if number show number wording, else images if($aps_get_schema_data->product_startype == 'numeric') { $aps_product_return .= '

' . __("Rating:", "ap-schema") . ' ' . $aps_get_schema_data->product_avg_rating . ' ' . $aps_get_schema_data->product_no_reviews . ' ' . __(" votes cast", "ap-schema") . '

'; } else { $aps_product_return .= '

' . $star_list . ' ' . __("Rating:", "ap-schema") . ' ' . $aps_get_schema_data->product_avg_rating . ' ' . __("Reviews:", "ap-schema") . ' ' . $aps_get_schema_data->product_no_reviews . '

'; } $aps_product_return .= '

' . $aps_price_option . $aps_get_schema_data->product_price . '

'; $aps_product_return .= '

' . $aps_get_schema_data->product_condition . ' ' . $aps_get_schema_data->product_prod_id . '

'; $aps_product_return .= '

' . $aps_get_schema_data->product_review_by . '

'; $aps_product_return .= '
'; return $aps_product_return; } // end if product if ($type == "recipe") { $aps_new_pretty_date_recipe_pub_date = aps_pretty_date($aps_get_schema_data->recipe_pub_date); //get the star option $aps_star_option = get_option( '_ap-schema--options' ); $aps_star_option = $aps_star_option['reviewicons']; if($aps_get_schema_data->recipe_startype == '') { $aps_get_schema_data->recipe_startype = $aps_star_option;} //get the star size $aps_starsize_option = get_option( '_ap-schema--options' ); $aps_starsize_option = $aps_starsize_option['reviewicons_size']; if ($aps_starsize_option == '') {$aps_starsize_option = '32';} /*********************** * Star generation **********************/ //set defaults $aps_recipe_rating = $aps_get_schema_data->recipe_rating; $aps_nearest_half = ''; $aps_decimal = ''; //round to neareast half //https://forums.digitalpoint.com/threads/round-number-to-nearest-half.943055/ if($aps_recipe_rating >= ($half = ($ceil = ceil($aps_recipe_rating))- 0.5) + 0.25) { $aps_nearest_half = $ceil; } else if($aps_recipe_rating < $half - 0.25) { $aps_nearest_half = floor($aps_recipe_rating); } else {$aps_nearest_half = $half; } //get the decimal check variable set $aps_decimal = $aps_nearest_half; //floor the nearest half variable $aps_floored_nearest_half = floor($aps_nearest_half); //generate stars based on floored value $star_list = ""; //set variable $star_url = ''; $i = 0; $max_count = $aps_floored_nearest_half; //// Lets max the count out at 100 so people dont add in stupid numbers and crash their site //// if ( $max_count > 100 ) { $max_count = 100; } ///////////////////////////////////////////////////////////////////////////////////////////////// while ($i < $max_count ) { $star_list .= $star_url . ''; ++$i; } //check if there is a decimal place - not that fucking easy as the ceil/floor return a float, even if the actual number is a whole number! //http://stackoverflow.com/questions/11041590/whole-number-or-decimal-number if ( is_numeric( $aps_decimal ) && strpos( $aps_decimal, '.' ) === false ) { $aps_decimal = "false";} else { $aps_decimal = "true";} if($aps_decimal === "true") { $star_list .= ''; } //top score possible //need a new setting for recipes i think! $aps_recipe_top_score = $aps_get_schema_data->recipe_rating_max; //get the empty star count $aps_empty_starcount = $aps_recipe_top_score - $aps_nearest_half; $aps_empty_starcount = floor($aps_empty_starcount); //add emtpy stars $empty_star_url = ''; $i = 0; $empty_max_count = $aps_empty_starcount; //// Lets max the count out at 100 so people dont add in stupid numbers and crash their site //// if ( $empty_max_count > 100 ) { $empty_max_count = 100; } ///////////////////////////////////////////////////////////////////////////////////////////////// while ($i < $empty_max_count ) { $star_list .= $empty_star_url . ''; ++$i; } // END OF STAR GENERATION //variable is comma separated string, grab it, explode and list each via for each. //$aps_recipe_ingredients = explode(',', $aps_get_schema_data->recipe_ingredients); $aps_recipe_ingredients = unserialize($aps_get_schema_data->recipe_ingredients); $aps_show_ingredients = ""; foreach ($aps_recipe_ingredients as $ingredients) { if($ingredients['value'] != '' ) { $aps_show_ingredients .= '
  • ' . $ingredients['value'] . '
  • '; } } $aps_recipe_return = '
    '; $aps_recipe_return .= '

    ' . $aps_get_schema_data->recipe_name . '

    '; /* RECIPE rating */ if($aps_get_schema_data->recipe_startype == 'numeric') { $aps_recipe_return .= '

    ' . __("Rating:", "ap-schema") . ' ' . $aps_get_schema_data->recipe_avg_rating . ' ' . $aps_get_schema_data->recipe_number_recipes . ' ' . __(" votes cast", "ap-schema") . '

    '; } else { $aps_recipe_return .= '
    ' . $star_list . '' . $aps_get_schema_data->recipe_rating_min . '' . $aps_get_schema_data->recipe_rating . ' out of '. $aps_get_schema_data->recipe_rating_max .'
    '; } /* end recipe rating */ $aps_recipe_return .= '

    '; $aps_recipe_return .= '

    '; $aps_recipe_return .= ''; $aps_recipe_return .= '

    ' . $aps_get_schema_data->recipe_desc . '

    '; $aps_recipe_return .= '
    '; $aps_recipe_return .= '

    ' . __("Prep Time:", "ap-schema"); $aps_recipe_return .= '' . $aps_get_schema_data->recipe_prep_hours .'' . __(" hours", "ap-schema") . ''; $aps_recipe_return .= '' . $aps_get_schema_data->recipe_prep_mins . '' . __(" minutes", "ap-schema") . ''; $aps_recipe_return .= '

    ' . __("Cook Time:", "ap-schema"); $aps_recipe_return .= '' . $aps_get_schema_data->recipe_cook_hours . '' . __(" hours", "ap-schema") . ''; $aps_recipe_return .= '' . $aps_get_schema_data->recipe_cook_mins . '' . __(" minutes", "ap-schema") . ''; $aps_recipe_return .= '

    '; $aps_recipe_return .= '
    '; $aps_recipe_return .= '

    ' . __("Yield:", "ap-schema") . '
    ' . $aps_get_schema_data->recipe_yield . '' . __(" portions", "ap-schema") . ''; $aps_recipe_return .= '

    ' . __("Nutrition:", "ap-schema") . '
    ' . __("Calories:", "ap-schema") . ' ' . $aps_get_schema_data->recipe_calories . '
    ' . __("Fat:", "ap-schema") . ' ' . $aps_get_schema_data->recipe_fat . '
    ' . __("Sugar:", "ap-schema") . ' ' . $aps_get_schema_data->recipe_sugar . '
    ' . __("Salt:", "ap-schema") . ' ' . $aps_get_schema_data->recipe_salt . ''; $aps_recipe_return .= '

    '; $aps_recipe_return .= '
    '; $aps_recipe_return .= '' . __("Ingredients:", "ap-schema") . ''; $aps_recipe_return .= ''; $aps_recipe_return .= '
    '; $aps_recipe_return .= '

    ' . __("Instructions:", "ap-schema") . '
    ' . $aps_get_schema_data->recipe_instructions . '

    '; $aps_recipe_return .= '

    ' . $aps_get_schema_data->recipe_review_by . '

    '; $aps_recipe_return .= '
    '; return $aps_recipe_return; } // end if recipe if ($type == "review") { $aps_new_pretty_date_review = aps_pretty_date($aps_get_schema_data->review_pub_date); //get the star option $aps_star_option = get_option( '_ap-schema--options' ); $aps_star_option = $aps_star_option['reviewicons']; if($aps_get_schema_data->review_startype == '') { $aps_get_schema_data->review_startype = $aps_star_option;} //get the currency symbol $aps_price_option = get_option( '_ap-schema--options' ); $aps_price_option = $aps_price_option['aps_price']; //get the star size $aps_starsize_option = get_option( '_ap-schema--options' ); $aps_starsize_option = $aps_starsize_option['reviewicons_size']; if ($aps_starsize_option == '') {$aps_starsize_option = '32';} //get the Google ID $aps_googleid_option = get_option( '_ap-schema--options' ); $aps_googleid_option = $aps_googleid_option['aps_google_id']; /*********************** * Star generation **********************/ //set defaults $aps_review_rating = $aps_get_schema_data->review_rating; $aps_nearest_half = ''; $aps_decimal = ''; //round to neareast half //https://forums.digitalpoint.com/threads/round-number-to-nearest-half.943055/ if($aps_review_rating >= ($half = ($ceil = ceil($aps_review_rating))- 0.5) + 0.25) { $aps_nearest_half = $ceil; } else if($aps_review_rating < $half - 0.25) { $aps_nearest_half = floor($aps_review_rating); } else {$aps_nearest_half = $half; } //get the decimal check variable set $aps_decimal = $aps_nearest_half; //floor the nearest half variable $aps_floored_nearest_half = floor($aps_nearest_half); //generate stars based on floored value $star_list = ""; //set variable $star_url = ''; $i = 0; $max_count = $aps_floored_nearest_half; //// Lets max the count out at 100 so people dont add in stupid numbers and crash their site //// if ( $max_count > 100 ) { $max_count = 100; } ///////////////////////////////////////////////////////////////////////////////////////////////// while ($i < $max_count ) { $star_list .= $star_url . ''; ++$i; } //check if there is a decimal place - not that fucking easy as the ceil/floor return a float, even if the actual number is a whole number! //http://stackoverflow.com/questions/11041590/whole-number-or-decimal-number if ( is_numeric( $aps_decimal ) && strpos( $aps_decimal, '.' ) === false ) { $aps_decimal = "false";} else { $aps_decimal = "true";} if($aps_decimal === "true") { $star_list .= ''; } //top score possible //need a new setting for reviews i think! $aps_review_top_score = $aps_get_schema_data->review_rating_max; //get the empty star count $aps_empty_starcount = $aps_review_top_score - $aps_nearest_half; $aps_empty_starcount = floor($aps_empty_starcount); //add emtpy stars $empty_star_url = ''; $i = 0; $empty_max_count = $aps_empty_starcount; //// Lets max the count out at 100 so people dont add in stupid numbers and crash their site //// if ( $empty_max_count > 100 ) { $empty_max_count = 100; } ///////////////////////////////////////////////////////////////////////////////////////////////// while ($i < $empty_max_count ) { $star_list .= $empty_star_url . ''; ++$i; } // END OF STAR GENERATION $aps_review_return = '
    '; $aps_review_return .= '

    ' . $aps_get_schema_data->review_name . '

    '; //$aps_review_return .= ''; $aps_review_return .= ''; $aps_review_return .= '

    '; $aps_review_return .= ' '; $aps_review_return .= '

    '; $aps_review_return .= '

    ' . $aps_get_schema_data->review_desc . '

    '; $aps_review_return .= '

    ' . $aps_get_schema_data->review_item_name . '

    '; $aps_review_return .= '

    ' . $aps_get_schema_data->review_item_review . '

    '; //if number show number wording, else images if($aps_get_schema_data->review_startype == 'numeric') { $aps_review_return .= '

    ' . __("Rating:", "ap-schema") . ' ' . $aps_get_schema_data->review_avg_rating . ' ' . $aps_get_schema_data->review_number_reviews . ' ' . __(" votes cast", "ap-schema") . '

    '; } else { /* $aps_review_return .= '

    ' . $star_list . '' . $aps_review_rating . ' / '. $aps_review_rating_max .'1000Out of s reviews' . $aps_review_rating_min . '

    '; */ $aps_review_return .= '' . $star_list . '' . $aps_get_schema_data->review_rating_min . '' . $aps_get_schema_data->review_rating . ' out of '. $aps_get_schema_data->review_rating_max .''; } $aps_review_return .= '
    '; return $aps_review_return; } // end if review } add_shortcode('ap_schema', 'aps_schema_shortcodes');