Advertisement
geminilabs

[site-reviews] Revert selectize.js and rebuild star rating

Sep 16th, 2020 (edited)
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. /*
  2.  * Fixes the Star Rating control when the theme uses selectize.js to style all SELECT elements on the page
  3.  * Note: this assumes that the theme uses jQuery with selectize.js
  4.  * @return void
  5.  * @see https://github.com/selectize/selectize.js
  6.  */
  7. add_action('wp_footer', function () {
  8.     echo "<script>
  9. jQuery(function() {
  10.    var stars = jQuery('select.glsr-star-rating');
  11.    if (stars) {
  12.        stars[0].selectize.destroy();
  13.        stars[0].value = '';
  14.        jQuery.each(GLSR.forms, function (index, form) {
  15.            form.initStarRatings();
  16.        });
  17.    }
  18. });
  19. </script>";
  20. }, 1000);
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement