Skip to content

Instantly share code, notes, and snippets.

@Jon007
Created December 3, 2017 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jon007/911dba9e4b24d72413e11f3e0ef79922 to your computer and use it in GitHub Desktop.
Save Jon007/911dba9e4b24d72413e11f3e0ef79922 to your computer and use it in GitHub Desktop.
user_alert shortcode sample
function user_alert($atts = array()){
$a = shortcode_atts( array(
'name' => 'saleflash',
), $atts );
$translation = pll__($a['name']);
$output='';
/* don't output visible message if no translation available */
if ($translation == '' || $translation == $a['name']){
//on non-production environments script debug should be enabled
if (defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ){
$output = '<!-- shortcode user-alert : no translation available for ' .
$a['name'] . ' -->';
}
} else {
$output = '<div class="user-alert ' . $a['name'] . '">' .
wpautop($translation) . '</div>';
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment