President Trump's first executive order concerning immigration was rightly condemned as discriminating based on religious grounds. Not only were the president's statements and tweets evidence, but so were the comments of Rudy Giuliani, who boasted that he helped write the executive order as a "legal" way to ban all Muslims from entering the country. Thankfully, the federal courts did not agree that this was a legal way.
Now the president has issued a subsequent order, attempting to deal with some of the legal issues. It no longer gives preference to non-Muslims, although the order only applies to six Muslim-majority countries. The courts have long held that if it is apparent the intent of a governmental action was unconstitutional, then they will look past the "four corners" of the document under question to determine if it is unconstitutional. If this is not enough for the courts, I can suggest another alternative.
According to Article VI of the US Constitution, all treaties in which the United States is a party shall be treated as part of the "supreme law of the land."
The International Covenant on Civil and Political Rights is a treaty to which the United States is a party. The first paragraph of Article 2 of that treaty states:
Each State Party to the present Covenant undertakes to respect and to ensure to all individuals within its territory and subject to its jurisdiction the rights recognized in the present Covenant, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. (emphasis added).
In addition, Article 26 of that treaty states:
All persons are equal before the law and are entitled without any discrimination to the equal protection of the law. In this respect, the law shall prohibit any discrimination and guarantee to all persons equal and effective protection against discrimination on any ground such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. (emphasis added).
The new order, while not differentiating between religious beliefs on its face (the courts must determine intent), does differentiate between immigrants and visitors based on national origin in direct violation of this treaty and, therefore, must be struck down as illegal.