My plugin implements a shortcode respecting wp best practices, but a strange behavior appears. First, the shortcode works perfectly on the test site, but not in production, with the exact same plugin code, but a slightly different environnement. On production site, the problem is the following: If i add a parameter to the shorcode, the shortcode seems not being interpreted and parsed at all. So adding this to my post body:
[my_shortcode_tag category=who]
[my_shortcode_tag category="who"]
[my_shortcode_tag category='who']
[my_shortcode_tag category=]
results in front-end with the same display, no shortocde is parsed and interpreted. As soon as i add another one without parameter, like this:
[my_shortcode_tag category=who]
[my_shortcode_tag category="who"]
[my_shortcode_tag category='who']
[my_shortcode_tag category=]
[my_shortcode_tag]
All shortcode start to work!... Everyone is interpreted and the display is correct.
Here is the shortcode function code:
function my_shortcode_tag($atts = [], $content = null, $tag = '')
{
// normalize attribute keys, lowercase
$atts = array_change_key_case((array)$atts, CASE_LOWER);
// override default attributes with user attributes
$sc_atts = shortcode_atts([
'height' => '400px',
'category' => 'all'
], $atts, $tag);
$result = 'nothing';
$category = $sc_atts['category'];
$height = 'height="' . $sc_atts['height'] . '"';
DOFF_Utils::getLogger()->info("doff_show_office_stats_fn");
// here some code to change result, based on $category and $height values
$result .= '[gfchartsreports gf_form_id="9" type="total" maxentries="10000" custom_search_criteria=\'{"status":"active","field_filters":{"0":{"key":"24","value":"user:dental_office_id"}}}\']';
$result .= ' ' . __('questionnaires envoyés');
$result .= '<br/>';
$result .= '[gfchartsreports gf_form_id="8" type="total" maxentries="10000" custom_search_criteria=\'{"status":"active","field_filters":{"0":{"key":"295","value":"user:dental_office_id"}}}\']';
return do_shortcode($result);
}
Any idea what could be wrong here ?