Skip to content

Instantly share code, notes, and snippets.

View alexmangini's full-sized avatar

Alex Mangini alexmangini

View GitHub Profile
@alexmangini
alexmangini / star-rating.php
Created March 1, 2019 19:58 — forked from robertdevore/star-rating.php
The PHP file that's called as $ajax_url in the star-rating.js file
<?php
function my_function_name() {
$postid = $_POST['postid'];
$rating = $_POST['rating'];
update_post_meta( $postid, 'delivery_rating', $rating );
wp_die();
}
add_action( 'wp_ajax_my_function_name', 'my_function_name' );
@alexmangini
alexmangini / star-rating.js
Created March 1, 2019 19:56 — forked from robertdevore/star-rating.js
Star rating script code example.
$(function() {
$('.driver-rating').barrating({
theme: 'fontawesome-stars',
initialRating: "<?php echo $averageRating; ?>",
showSelectedRating: true,
// onSelect is what triggers the saving of the rating.
onSelect: function(value, text, event) {
// Get element id by data-id attribute
var el = this;