Replaced all instances of '$wpdb->escape' with 'esc_sql'

As '$wpdb->escape' has been deprecated in WP 3.6, all instances have
been replaced with the safer 'esc_sql'