Created
December 3, 2017 09:41
-
-
Save Jon007/911dba9e4b24d72413e11f3e0ef79922 to your computer and use it in GitHub Desktop.
user_alert shortcode sample
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
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