Last active
August 28, 2019 04:34
-
-
Save rafaehlers/85638ed8179984aa833b1b14a1b68e7c to your computer and use it in GitHub Desktop.
Display a progress bar using the Math extension
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
| <?php // DO NOT COPY THIS LINE | |
| // usage inside a Custom Content field on a View: [gv_math_percentage field="{field Merge tag here:x}"] | |
| add_shortcode("gv_math_percentage", "gv_math_custom_shortcode"); | |
| function gv_math_custom_shortcode( $atts ){ | |
| extract( shortcode_atts( | |
| array( | |
| 'field' => '', | |
| ), $atts ) | |
| ); | |
| $value = do_shortcode('[gv_math scope="entry"] ('.$field.' / 34 ) * 100[/gv_math]'); | |
| $text = '<progress value='.$value.' max="100"></progress>'; | |
| return $text; | |
| } | |
| add_filter( 'gravityview/math/suppress_errors', '__return_true' ); // this is needed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment