fix for legend not displaying after AJAX call
update for WP Coding guidelines