Concatenating esc_attr_e() to a variable issue in WordPress Concatenating esc_attr_e() to a variable issue in WordPress wordpress wordpress

Concatenating esc_attr_e() to a variable issue in WordPress


The function esc_attr_e() echoes (display) translated text that has been escaped, so that's why you get an issue as you are at the same time trying to concatenate it in a variable.

Instead use simply esc_attr__()function that can be concatenated without issues as it returns a translated text that has been escaped.

<?php$search = '<button type="submit" title="'.esc_attr_e('Search', 'woocommerce'). '" class="search"><span>';$search .= ''.esc_attr__('Search','woocommerce').'</span></button></form>';?>