added support for WP 3.9+ by checking if the mysql resource is mysqli

If mysqli then use wpdb->dbh->real_escape_string()
otherwise, if wpdb->dbh is a resource, pass it to mysql_real_escape_string
if not, just return the unescaped string