Hi All:
I have been developing several shortcodes for a plugin I am working on, and one particular shortcode has been giving me trouble. One of my shortcodes should be able to handle inequalities like "2>0" as their attributes. Unfortunately, when I pass this as an attribute the quotes remain inside. Even worse is that when I pass a similar attribute with spaces inside the quotes, e.g. "5 > 0", it splits the the attribute into multiple attributes.
I have tried many tests with the shortcode_parse_atts() function to understand why the quotes are being passed into the $atts variable and why spaces are causing problems. It appears that Wordpress converts the quotes into curly quotes before the running the do_shortcode() command. The atts parser would then have trouble parsing the atts from the shortcode to this conversion. I have tested multiple themes (responsive and twenty-eleven) and I do not believe that it has anything to do with my configuration. Therefore it may be a bug in the wptexturize() function.
I have a MWE for those interested. The shortcode implementation in php is done in my main plugin php file. As an example, below is a shortcode function in which I use to observe this problem.
function my_code_function( $atts=null, $content=null ) {
echo var_dump($atts);
}
add_shortcode('my_code','my_code_function');
The shortcode that appears to have problems is:
[my_code "1 > 0"]
The code gave me the output:
array(3) { [0]=> string(8) "“1" [1]=> string(1) ">" [2]=> string(8) "0″" }
However, the shortcode atts parser works correctly for the following variation
[my_code "1 GT 0"]
which gave me the output array(1) { [0]=> string(6) "1 GT 0" }
Thanks!