-
Couldn't load subscription status.
- Fork 36
Cheat Guide
Kevin Ruscoe edited this page May 16, 2020
·
2 revisions
/**
* Upgrade to FA5
*/
add_action('admin_print_styles', function() {
// Remove FA4
wp_dequeue_style('font-awesome');
// Add FA5
wp_enqueue_style(
'font-awesome-5',
'//cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css'
);
}, 1);
// Add classes
add_filter('star_rating_field_admin_star_classes', function($classes) {
return array('far fa-fw fa-star', 'fas fa-fw fa-star-half-alt', 'fas fa-fw fa-star');
});/**
* Add own stars
*/
add_action('admin_print_styles', function() {
// Remove FA4
wp_dequeue_style('font-awesome');
}, 1);
// Add new CSS
add_action('admin_head', function() {
?>
<style>
i.empty-star,
i.half-star,
i.full-star {
width: 20px;
height: 20px;
background-size: contain;
display: block;
}
i.empty-star {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 278.457 278.457"><path d="M277.478 106.28a19.998 19.998 0 00-16.146-13.611l-71.979-10.46-32.19-65.224a20 20 0 00-35.87 0l-32.19 65.224-71.979 10.46a19.998 19.998 0 00-11.083 34.113l52.084 50.77L45.83 249.24a20.001 20.001 0 0029.019 21.084l64.38-33.847 64.38 33.847a19.997 19.997 0 0029.019-21.084l-12.295-71.688 52.084-50.77a20.002 20.002 0 005.061-20.502zm-92.595 49.967a19.997 19.997 0 00-5.752 17.702l7.222 42.11-37.817-19.882a19.994 19.994 0 00-18.614 0L92.104 216.06l7.222-42.11a19.997 19.997 0 00-5.752-17.702l-30.595-29.822 42.281-6.145a19.998 19.998 0 0015.059-10.94l18.909-38.313 18.909 38.313a19.998 19.998 0 0015.059 10.94l42.281 6.145-30.594 29.821z"/></svg>')
}
i.half-star {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 276.901 276.901"><path d="M275.922 105.676a20 20 0 00-16.146-13.611l-71.441-10.381-31.95-64.737a20 20 0 00-35.87 0L88.566 81.684 17.125 92.065a19.996 19.996 0 00-11.084 34.113l51.695 50.391-12.203 71.153a19.997 19.997 0 0029.019 21.083l63.898-33.594 63.899 33.594a19.997 19.997 0 0029.019-21.083l-12.204-71.153 51.696-50.39a20.003 20.003 0 005.062-20.503zm-92.207 49.588a20 20 0 00-5.752 17.703l7.131 41.575-37.337-19.629a19.985 19.985 0 00-9.306-2.298V70.99l18.669 37.826a20 20 0 0015.059 10.94l41.743 6.065-30.207 29.443z"/></svg>');
}
i.full-star {
background-image: url('data:image/svg+xml,<svg width="278.457" height="278.457" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M-1-1h582v402H-1z"/><g><path d="M277.478 106.28a19.998 19.998 0 00-16.146-13.611l-71.979-10.46-32.19-65.224a20 20 0 00-35.87 0l-32.19 65.224-71.979 10.46a19.998 19.998 0 00-11.083 34.113l52.084 50.77L45.83 249.24a20.001 20.001 0 0029.019 21.084l64.38-33.847 64.38 33.847a19.997 19.997 0 0029.019-21.084l-12.295-71.688 52.084-50.77a20.002 20.002 0 005.061-20.502zm-92.595 49.967a19.997 19.997 0 00-5.752 17.702l7.222 42.11-37.817-19.882a19.994 19.994 0 00-18.614 0L92.104 216.06l7.222-42.11a19.997 19.997 0 00-5.752-17.702l-30.595-29.822 42.281-6.145a19.998 19.998 0 0015.059-10.94l18.909-38.313 18.909 38.313a19.998 19.998 0 0015.059 10.94l42.281 6.145-30.594 29.821z"/><path d="M128.729 52.682c-2 3-40 53-42 53s-31 10-31 10l9 40s5 34 5 35 7 37 8 37 35 5 40 1 25-19 26-18 25 24 27 24 32-4 32-6-1-44-1.729-44.682c.729.682-7.271-18.318-5.271-20.318s43-36 43-36" fill-opacity="null" stroke-opacity="null" stroke-width="null" stroke="null" fill="null"/></g></svg>')
}
</style>
<?php
});
// Add classes
add_filter('star_rating_field_admin_star_classes', function($classes) {
return array('empty-star', 'half-star', 'full-star');
});Get ACF to return Number and write your own logic, or List (unstyled) and write your own CSS.