Number sign causes syntax error in shortcode function
-
Hi, all. I can’t figure out why I can’t use the number sign (#) inside a shortcode function (for hex color).
Here’s the code:
function box_shortcode( $atts, $content = null ) {
extract(shortcode_atts(array(
'color' => white,
'background' => red,
'border' => gray,
'width' => 200,
'float' => none
), $atts));
return '<div class="shoutbox" style="color: ' . $color . ';
background: ' . $background . '; border-color: ' . $border . '; width: ' . $width . 'px;
float: ' .$float . ';">' . $content . '</div>';
}
add_shortcode( 'box', 'box_shortcode' );
If I try to use a hex color value, like “#888”, instead of the word “gray” I get the error, and WP disables the plugin.
The error says: Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ‘)’
- The topic ‘Number sign causes syntax error in shortcode function’ is closed to new replies.