• Resolved luckyelementmedia

    (@luckyelementmedia)


    Looking for a way to use a shortcode in the default raised value of the plugin settings, so that I can then use [therm_r] in a text field to pull the dynamic value from the database. Or maybe there is a better way to do this?

Viewing 1 replies (of 1 total)
  • Plugin Author rhewlif

    (@henryp)

    It’s possible in theory with some manual editing of the plugin, but it seems a bit convoluted. Can you not use the original dynamic shortcode in the text field instead of [therm_r]?

    Nevertheless, you can save a shortcode in the settings page, then get the [thermometer] shortcode to parse it by amending around line 120 of therm_shortcode.php with something like this:

    //raised value
    if ($atts['raised'] == '' && !empty($options['raised_string'])){
    	if (!is_numeric(str_replace(",", ".",  $options['raised_string'])) && (strpos( $options['raised_string'], ';') === false) && !is_numeric(str_replace(',','', $options['raised_string']))) {
    		$shortcode = strval($options['raised_string']);
    		$thermProperties['raised'] = do_shortcode( $shortcode);
    	}
    	else{
    	    $thermProperties['raised'] = $options['raised_string'];
    	}
    }
    else{
    // if shortcode present
    	if (!is_numeric(str_replace(",", ".", $atts['raised'])) && (strpos($atts['raised'], ';') === false) && !is_numeric(str_replace(',','',$atts['raised']))) {
    		$shortcode = "[".strval($atts['raised'])."]";
    		$atts['raised'] = do_shortcode( $shortcode);
    	}
            $thermProperties['raised'] = strval($atts['raised']);
    }

    You will also need to amend the therm_raised() function at the bottom of the same file since you now want the [therm_r] shortcode to parse this saved shortcode too. Inserting something like this should work:

    if (!is_numeric(str_replace(",", ".",  $options['raised_string'])) && (strpos( $options['raised_string'], ';') === false) && !is_numeric(str_replace(',','', $options['raised_string']))) {
    	$shortcode = strval($options['raised_string']);
    	$raisedA = array(do_shortcode( $shortcode));
    }
    else{
            $raisedA = explode(';',$options['raised_string']);
    }
    • This reply was modified 2 years, 6 months ago by rhewlif.
Viewing 1 replies (of 1 total)
  • The topic ‘Use shortcode in default raised value’ is closed to new replies.