Dynamic text with shortcode

<?php

//Text Shortcode
/** Print Text **/
function wco_print_text($shortcode = false,$term = '',$poss = false){
if($shortcode) ob_start();
if($poss) $extra_text = '&#8217;s'; //Possessive ('s)
$option = get_blog_option(1,'wco_text_' . $term); //Use get_option() for non-multisite
if($option) echo $option . $extra_text;
else echo '**' . strtoupper($term) . $extra_text;
if($shortcode){
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}
/** Shortcode Print Text [wco_text term="location" poss="1"] **/
function wco_shortcode_print_text($atts){
extract(shortcode_atts(array('term' => '','poss' => false),$atts));
return wco_print_text(true,$term,$poss);
}
add_shortcode('wco_text','wco_shortcode_print_text');

?>

0 Comments

You must be logged in to post a comment.