Last active
March 30, 2024 08:30
-
-
Save diggeddy/ef3dc0315a73c0caad839c5348b89aa6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function make_star_bar( $atts ) { | |
$value = shortcode_atts( array( | |
'stars' =>5, | |
'color' => '#f00' | |
),$atts); | |
$prefix = 'star-bar-'; | |
$uniqueClass = uniqid($prefix); | |
$percentage = 100 * $value['stars'] / 5; | |
$html = '<span class="'.$uniqueClass.'">★★★★★</span> | |
<style> | |
.'.$uniqueClass.' { | |
background: linear-gradient(90deg, '. $value['color'] . ' ' . $percentage .'%, rgba(0,0,0,0) '. $percentage.'%); | |
color: rgba(0,0,0,.2); | |
background-clip: text; | |
-webkit-background-clip: text; | |
color: rgba(0,0,0,.2); | |
} | |
</style> | |
'; | |
return $html; | |
} | |
add_shortcode('star_bar', 'make_star_bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey guys, one question. so i need to use shortcode with star value on every of my post? Because the data input from ACF is not showing