integrations
7 years ago
class-strong-form.php
7 years ago
class-strong-log.php
7 years ago
class-strong-mail.php
7 years ago
class-strong-templates.php
7 years ago
class-strong-testimonials-order.php
7 years ago
class-strong-testimonials-privacy.php
7 years ago
class-strong-testimonials-render.php
7 years ago
class-strong-testimonials-shortcode-average.php
7 years ago
class-strong-testimonials-shortcode-count.php
7 years ago
class-strong-testimonials-shortcode.php
7 years ago
class-strong-view-display.php
7 years ago
class-strong-view-form.php
7 years ago
class-strong-view-slideshow.php
7 years ago
class-strong-view.php
7 years ago
class-walker-strong-category-checklist-front.php
7 years ago
deprecated.php
7 years ago
filters.php
7 years ago
functions-activation.php
7 years ago
functions-content.php
7 years ago
functions-image.php
7 years ago
functions-rating.php
7 years ago
functions-template-form.php
7 years ago
functions-template.php
7 years ago
functions-views.php
7 years ago
functions.php
7 years ago
l10n-polylang.php
7 years ago
l10n-wpml.php
7 years ago
post-types.php
7 years ago
retro.php
7 years ago
scripts.php
7 years ago
widget2.php
7 years ago
functions-rating.php
101 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Print the star rating form. |
| 5 | * |
| 6 | * @since 2.12.0 |
| 7 | * @since 2.23.2 $field_array |
| 8 | * |
| 9 | * @param array|string $field |
| 10 | * @param int $value |
| 11 | * @param string $class |
| 12 | * @param bool $echo |
| 13 | * @param string $field_array If included, set field name in array. In post editor meta box. |
| 14 | * |
| 15 | * @return string |
| 16 | */ |
| 17 | function wpmtst_star_rating_form( $field, $value = 0, $class, $echo = true, $field_array = '' ) { |
| 18 | $value = (int) $value; |
| 19 | if ( $field && is_array( $field ) && isset( $field['name'] ) ) { |
| 20 | $name = $field['name']; |
| 21 | if ( $field_array ) { |
| 22 | $name = $field_array . '[' . $name . ']'; |
| 23 | } |
| 24 | } else { |
| 25 | $name = 'rating'; |
| 26 | } |
| 27 | ob_start(); ?> |
| 28 | <div class="strong-rating-wrapper field-wrap <?php echo $class; ?>"><!-- cheap trick to collapse whitespace around inline-blocks |
| 29 | --><fieldset contenteditable=false |
| 30 | id="wpmtst_<?php echo $field['name']; ?>" |
| 31 | name="<?php echo $field['name']; ?>" |
| 32 | class="strong-rating" |
| 33 | data-field-type="rating" |
| 34 | tabindex="0"><!-- |
| 35 | |
| 36 | --><input type="radio" id="<?php echo $field['name']; ?>-star0" name="<?php echo $name; ?>" value="0" <?php checked( $value, 0 ); ?> /><!-- |
| 37 | --><label for="<?php echo $field['name']; ?>-star0" title="No stars"></label><!-- |
| 38 | |
| 39 | --><input type="radio" id="<?php echo $field['name']; ?>-star1" name="<?php echo $name; ?>" value="1" <?php checked( $value, 1 ); ?> /><!-- |
| 40 | --><label for="<?php echo $field['name']; ?>-star1" title="1 star"></label><!-- |
| 41 | |
| 42 | --><input type="radio" id="<?php echo $field['name']; ?>-star2" name="<?php echo $name; ?>" value="2" <?php checked( $value, 2 ); ?> /><!-- |
| 43 | --><label for="<?php echo $field['name']; ?>-star2" title="2 stars"></label><!-- |
| 44 | |
| 45 | --><input type="radio" id="<?php echo $field['name']; ?>-star3" name="<?php echo $name; ?>" value="3" <?php checked( $value, 3 ); ?> /><!-- |
| 46 | --><label for="<?php echo $field['name']; ?>-star3" title="3 stars"></label><!-- |
| 47 | |
| 48 | --><input type="radio" id="<?php echo $field['name']; ?>-star4" name="<?php echo $name; ?>" value="4" <?php checked( $value, 4 ); ?> /><!-- |
| 49 | --><label for="<?php echo $field['name']; ?>-star4" title="4 stars"></label><!-- |
| 50 | |
| 51 | --><input type="radio" id="<?php echo $field['name']; ?>-star5" name="<?php echo $name; ?>" value="5" <?php checked( $value, 5 ); ?> /><!-- |
| 52 | --><label for="<?php echo $field['name']; ?>-star5" title="5 stars"></label><!-- |
| 53 | |
| 54 | --></fieldset><!-- |
| 55 | --></div> |
| 56 | <?php |
| 57 | $html = ob_get_contents(); |
| 58 | ob_end_clean(); |
| 59 | $html = preg_replace( '/<!--(.|\s)*?-->/', '', $html ); |
| 60 | |
| 61 | if ( $echo ) { |
| 62 | echo $html; |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | return $html; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @param int $value |
| 71 | * @param $class |
| 72 | * @param bool $echo |
| 73 | * |
| 74 | * @return bool|string |
| 75 | */ |
| 76 | function wpmtst_star_rating_display( $value = 0, $class = 'in-view', $echo = true ) { |
| 77 | $value = (int) $value; |
| 78 | ob_start(); ?> |
| 79 | <span class="strong-rating-wrapper <?php echo $class; ?>"> |
| 80 | <span class="strong-rating"><!-- cheap trick to collapse whitespace around inline-blocks |
| 81 | --><span class="star<?php echo ( 0 == $value ) ? ' current' : '' ; ?>" style="display: none;"></span><!-- |
| 82 | --><span class="star<?php echo ( 1 == $value ) ? ' current' : '' ; ?>"></span><!-- |
| 83 | --><span class="star<?php echo ( 2 == $value ) ? ' current' : '' ; ?>"></span><!-- |
| 84 | --><span class="star<?php echo ( 3 == $value ) ? ' current' : '' ; ?>"></span><!-- |
| 85 | --><span class="star<?php echo ( 4 == $value ) ? ' current' : '' ; ?>"></span><!-- |
| 86 | --><span class="star<?php echo ( 5 == $value ) ? ' current' : '' ; ?>"></span><!-- |
| 87 | --></span> |
| 88 | </span> |
| 89 | <?php |
| 90 | $html = ob_get_contents(); |
| 91 | ob_end_clean(); |
| 92 | $html = preg_replace( '/<!--(.|\s)*?-->/', '', $html ); |
| 93 | |
| 94 | if ( $echo ) { |
| 95 | echo $html; |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | return $html; |
| 100 | } |
| 101 |