Support » Plugin: Donation Thermometer » Feature Request: Shortcode or PHP Function for Raised Amount

  • It would be awesome if we could use a shortcode or php function as the raised amount. I’m looking to have it dynamically pull that number from my database so it is automatically updated every time someone fills out a Caldera Form entry. I’ve got the shortcode and php function ready to go, but when I try to use the shortcode nested in your shortcode, it doesn’t work.

    Thanks!!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author rhewlif

    (@henryp)

    Hi,
    Sounds feasible – it looks like you would just need to make a small modification to the plugin code to read the raised amount as a shortcode e.g., https://slewis.org/nested-wordpress-shortcodes/

    Thanks. I tried changing line 88 in therm_shortcode.php
    from:
    $thermProperties[‘raised’] = strval($atts[‘raised’]);
    to:
    $thermProperties[‘raised’] = strval(do_shortcode($atts[‘raised’]));

    My shortcode looks like this:
    [thermometer raised=[get_total_donations field=”fld_9181836″]]

    But it didn’t work. I’ll have to look at it later. Hoping it’s something really simple!
    Thanks!

    • This reply was modified 3 months, 3 weeks ago by mjtwebsites.

    I had the same question fixed it by adding

    if (strpos($atts['raised'], '[') !== false) {
    	$shortcode = strval($atts['raised'])."]";
    	$atts['raised'] = do_shortcode( $shortcode);
    }

    to therm_shortcode.php on line 92.

    Please add this to the next release

    better code:

    	//raised value
    	if ($atts['raised'] == '' && !empty($options['raised_string'])){
    	    $thermProperties['raised'] = $options['raised_string'];
    	}
    	else{
    		if (!is_numeric($atts['raised'])) {
    			$shortcode = "[".strval($atts['raised'])."]";
    			$atts['raised'] = do_shortcode( $shortcode);
    		}
    	    $thermProperties['raised'] = strval($atts['raised']);
    	}
    Plugin Author rhewlif

    (@henryp)

    Thanks for this. I will look into this in a bit more detail for the next release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.