functions.php check for subdomain in array as conditional
-
So, for Compliance reasons, I need to inject a statement onto certain subsites. I figure the best way to do this is from the backend, checking an array for subdomains (only for sites which require this particular statement), then enqueueing a .js file if there is a match.
I have checked for typos and syntax errors, but nothing is standing out to me. PHP Lint doesn’t find anything either. However, it doesn’t seem to work. Is anyone willing to take a look and let me know if I’m missing something?
Thanks! Code below.
function georgia_compliance() { $galos = array('christinabarth', 'thomasbroadbent','sallybucciero', 'billclayton', 'glendicken', 'brianelkins', 'tiffanygarrard', 'brandyharrison', 'wendyhollon', 'nathankerpan', 'shandyking', 'laurenkitts', 'stevelake', 'paulparker', 'susanpryor', 'stevereed', 'scottshubert', 'jonathantipton', 'connievaun', 'whitneywelch'); $url = get_home_url(); $parsedUrl = parse_url($url); $host = explode('.', $parsedUrl['host']); $sub = $host[0]; if (in_array($sub, $galos) == true) { wp_enqueue_script( 'georgiaCompliance', get_home_url() . '/wp-content/themes/make-child-lo/disclaimers/georgia.js', array('jquery'), '1.0', true ); } } add_action('wp-enqueue-scripts', 'georgia_compliance');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘functions.php check for subdomain in array as conditional’ is closed to new replies.