Replaced deprecated $wpdb->escape

$wpdb->escape has been deprecated and should be replaced with esc_sql to avoid notice messages in log file. 
https://www.webniraj.com/2013/08/05/wordpress-3-6-fixing-wpdbescape-deprecation-errors/