I’m in the process of learning php, but this piece of code needs to go in asap. Can someone please help? I’m trying to add this to my wordpress function file.
I have two pop up codes from our ad platform (Flite) to display on our homepage.
this is for the mobile ad
//mobile campaign
/* <!-- Campaign: pop up -->
<!-- Site: Seniorstyleguide.com -->
<!-- Placement: Seniorstyleguide.com #3 -->
<!-- Placement ID: 26e3aedf-e0bf-4389-a5d0-2b23bfbb3797 -->
<!-- Placement Size: 300x250 --> */
<div style="display:none !important;" id="flite-click-macro-26e3aedf-e0bf-4389-a5d0-2b23bfbb3797">ENTER_UNENCODED_CLICK_MACRO_HERE</div>
<script>
(function() {
var guid = "26e3aedf-e0bf-4389-a5d0-2b23bfbb3797", o = window, r = "", m, s = "http:", e = encodeURIComponent, x = 0, f = document.createElement("script");
o.FLITE=o.FLITE || {};
o.FLITE.config = o.FLITE.config || {};
o.FLITE.config[guid] = o.FLITE.config[guid] || {};
o.FLITE.config[guid].cb = Math.random();
o.FLITE.config[guid].ts = (+ new Date());
try{ r = (top===self && top.location) ? top.location.href : document.referrer || (top.location && top.location.href) || "";}catch(er){x=1}
try{ s = o.location && o.location.protocol === "https:"? o.location.protocol : s;}catch(er){x+=2}
try{ m = r.match(new RegExp("[A-Za-z]+:[/][/][A-Za-z0-9.-]+")); } catch(er) {x+=4}
try{ var fm = document.getElementById("flite-click-macro-" + guid); var c = (fm && (fm.innerText || fm.textContent || fm.innerHTML)) || ""; c = c.replace(/^\s+|\s+$/g, ""); o.FLITE.config[guid].ct = c; } catch(err) {x+=8}
f.src = [s,"//r.flite.com/syndication/uscript.js?i=",e(guid),"&v=3","&x=us",x,"&cb=",o.FLITE.config[guid].cb,"&d=",e((m && m[0]) || r), "&tz=", (new Date()).getTimezoneOffset()].join("");
document.write(f.outerHTML);
})();
</script>
<noscript>
<a style="text-decoration:none;display:block;border:0;" href="//r.flite.com/syndication/backuplink/i/26e3aedf-e0bf-4389-a5d0-2b23bfbb3797?ct=ENTER_ENCODED_CLICK_MACRO_HERE" target="_blank">
<img border="0" src="//r.flite.com/syndication/backupimage/i/26e3aedf-e0bf-4389-a5d0-2b23bfbb3797?at="/>
</a>
</noscript>
This is for our desktop ad
//desktop campaign
/*
<!-- Campaign: pop up -->
<!-- Site: Seniorstyleguide.com -->
<!-- Placement: Seniorstyleguide.com #4 -->
<!-- Placement ID: 68a18a5d-9b38-4a28-bd29-71f0fbe9d407 -->
<!-- Placement Size: 750x600 -->*/
<div style="display:none !important;" id="flite-click-macro-68a18a5d-9b38-4a28-bd29-71f0fbe9d407">ENTER_UNENCODED_CLICK_MACRO_HERE</div>
<script>
(function() {
var guid = "68a18a5d-9b38-4a28-bd29-71f0fbe9d407", o = window, r = "", m, s = "http:", e = encodeURIComponent, x = 0, f = document.createElement("script");
o.FLITE=o.FLITE || {};
o.FLITE.config = o.FLITE.config || {};
o.FLITE.config[guid] = o.FLITE.config[guid] || {};
o.FLITE.config[guid].cb = Math.random();
o.FLITE.config[guid].ts = (+ new Date());
try{ r = (top===self && top.location) ? top.location.href : document.referrer || (top.location && top.location.href) || "";}catch(er){x=1}
try{ s = o.location && o.location.protocol === "https:"? o.location.protocol : s;}catch(er){x+=2}
try{ m = r.match(new RegExp("[A-Za-z]+:[/][/][A-Za-z0-9.-]+")); } catch(er) {x+=4}
try{ var fm = document.getElementById("flite-click-macro-" + guid); var c = (fm && (fm.innerText || fm.textContent || fm.innerHTML)) || ""; c = c.replace(/^\s+|\s+$/g, ""); o.FLITE.config[guid].ct = c; } catch(err) {x+=8}
f.src = [s,"//r.flite.com/syndication/uscript.js?i=",e(guid),"&v=3","&x=us",x,"&cb=",o.FLITE.config[guid].cb,"&d=",e((m && m[0]) || r), "&tz=", (new Date()).getTimezoneOffset()].join("");
document.write(f.outerHTML);
})();
</script>
<noscript>
<a style="text-decoration:none;display:block;border:0;" href="//r.flite.com/syndication/backuplink/i/68a18a5d-9b38-4a28-bd29-71f0fbe9d407?ct=ENTER_ENCODED_CLICK_MACRO_HERE" target="_blank">
<img border="0" src="//r.flite.com/syndication/backupimage/i/68a18a5d-9b38-4a28-bd29-71f0fbe9d407?at="/>
</a>
</noscript>
I found this piece to check for mobile
/* USER-AGENTS
================================================== */
function check_user_agent ( $type = NULL ) {
$user_agent = strtolower ( $_SERVER['HTTP_USER_AGENT'] );
if ( $type == 'bot' ) {
// matches popular bots
if ( preg_match ( "/googlebot|adsbot|yahooseeker|yahoobot|msnbot|watchmouse|pingdom\.com|feedfetcher-google/", $user_agent ) ) {
return true;
// watchmouse|pingdom\.com are "uptime services"
}
} else if ( $type == 'browser' ) {
// matches core browser types
if ( preg_match ( "/mozilla\/|opera\//", $user_agent ) ) {
return true;
}
} else if ( $type == 'mobile' ) {
// matches popular mobile devices that have small screens and/or touch inputs
// mobile devices have regional trends; some of these will have varying popularity in Europe, Asia, and America
// detailed demographics are unknown, and South America, the Pacific Islands, and Africa trends might not be represented, here
if ( preg_match ( "/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\/|samsung|sonyericsson|^sie-|nintendo/", $user_agent ) ) {
// these are the most common
return true;
} else if ( preg_match ( "/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /", $user_agent ) ) {
// these are less common, and might not be worth checking
return true;
}
}
return false;
}
$ismobile = check_user_agent('mobile');
if($ismobile) {
return 'yes';
} else {
return 'no';
}
I’m using the function is_home(){} now I just need to integrate them all.