Ordinances passed by cities or towns must be posted or published in a newspaper as required by their respective charters or the general laws: PROVIDED, That ordinances may by reference adopt Washington state statutes and codes, including fire codes and ordinances relating to the construction of buildings, the installation of plumbing, the installation of electric wiring, health and sanitation, the slaughtering, processing and selling of meats and meat products for human consumption, the production, pasteurizing and sale of milk and milk products, or other subjects, may adopt by reference, any printed code or compilation, or portions thereof, together with amendments thereof or additions thereto, on the subject of the ordinance; and where publications of ordinances in a newspaper is required, such Washington state statutes or codes or other codes or compilations so adopted need not be published therein: PROVIDED, HOWEVER, That not less than one copy of such statute, code or compilation and amendments and additions thereto adopted by reference shall be filed for use and examination by the public, in the office of the city or town clerk of said city, or town prior to adoption thereof. Any city or town ordinance heretofore adopting any state law or any such codes or compilations by reference are hereby ratified and validated.