In general, a sovereign state can regulate what is or isn't allowed within its borders in any way it wants - that is a part of the whole "sovereignty" thing. But international agreements and organisations can influence what an independent state is actually willing to do.
WTO is one such organisation. It can't actually do anything but expel a member from organisation - it only provides a framework for negotiation and dispute resolution. But it is usually in a member country's interests to comply with advised agreements, as otherwise it would lose the protection from arbitrary tariffs and bans the membership provides.
Generally, WTO is against any and all trade restrictions and bans between members, but there are exceptions to that rule for environmental protection causes. Such policies do have to fit certain requirements, and they will be rejected by WTO if they do not pass scrutiny. These policies are required to be necessary (in other words, no other reasonable way to achieve the same results) and be fair to other WTO members (no discrimination).
An example of a policy discriminating by process would be the 1989 USA shrimp import restriction (your first example). This policy was rejected by WTO - not because it judged that WTO members couldn't impose bans to protect vulnerable species, but because the policy discriminated between WTO members, allowing for certain advantages for countries in the Caribbean, but without such boon for other potential importers. There are also examples of such policies being accepted (for example, EU asbestos ban).
On your other examples - WTO does not have labor on its agenda at the moment, so any tariffs or bans citing labor conditions as the reason would not be upheld by the organisation. But this is a hotly discussed question since the organisation's creation, so this might still change in the future.
Note that WTO only regulates trade relations between member states, so all bets are off if the target or the imposer of the ban is not a member of WTO. Another important point - WTO is not a trade police. They cannot make countries do something, and only act as an assessor - i.e. they can tell the involved parties whether the deal is fair or not according to the guidelines, but any actions taken to actually make the deal fair would be a result of negotiations between the affected countries.
Thus, for your last example, if you are a member of WTO, you would have to first provide a compelling reason on why, for example, cane sugar is impacting your country's ecology, demonstrate how nothing but a blanket ban on all imported cane sugar would help the problem, and to prove that no members of WTO would be discriminated by such ban. But if you wanted to ban import from, say, North Korea (who is not a member of WTO) - you would be free to do it without WTO having any say in the matter.