update theme
This commit is contained in:
53
wp/wp-content/themes/medicalalert/helpers/Ratings.php
Normal file
53
wp/wp-content/themes/medicalalert/helpers/Ratings.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Helpers;
|
||||
|
||||
class Ratings
|
||||
{
|
||||
public static function ratingsStars()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
$numberOfStars = $context->get($args);
|
||||
if (!is_numeric($numberOfStars)) {
|
||||
return "The value you passed to this helper is not a number.";
|
||||
}
|
||||
|
||||
$output = "";
|
||||
for ($i=1; $i <= 5; $i++) {
|
||||
if ($i <= $numberOfStars) {
|
||||
$output .= "<i class='bi bi-star-fill'></i>";
|
||||
} else {
|
||||
$output .= "<i class='bi bi-star'></i>";
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
};
|
||||
}
|
||||
|
||||
public static function numberFormatter()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
$totalCount = $context->get($args);
|
||||
if (!is_numeric($totalCount)) {
|
||||
return "The value you passed to this helper is not a number.";
|
||||
}
|
||||
|
||||
return number_format($totalCount);
|
||||
};
|
||||
}
|
||||
|
||||
public static function currencyFormatter()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
$totalCount = $context->get($args);
|
||||
if ($totalCount === "Free") {
|
||||
return "Free";
|
||||
}
|
||||
|
||||
if (!is_numeric($totalCount)) {
|
||||
return "The value you passed to this helper is not a number.";
|
||||
}
|
||||
return "$" . number_format($totalCount, 2);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user