Changed all $wpdb->escape() calls to esc_sql() to fix notice.