Created
June 27, 2019 23:04
-
-
Save shrinkray/21c53f5e55387bf32a747b4f741d54a3 to your computer and use it in GitHub Desktop.
Given production URL, display code otherwise don't.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Comparison adds script if site URL is same as production URL | |
| * | |
| * @returns inline script | |
| */ | |
| $site_url = get_site_url(); | |
| $prod_url = 'add-prod-url.com'; | |
| if ( $site_url === $prod_url ) { ?> | |
| // this was Google Analytics script but could be anything | |
| <script async src="..."></script> | |
| <script> | |
| window.dataLayer = window.dataLayer || []; | |
| function gtag(){dataLayer.push(arguments);} | |
| gtag('js', new Date()); | |
| gtag('config', 'UA-671633-51'); | |
| </script> | |
| <?php | |
| } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment