Adding Google Number w/ Adwords tracking to OptimizePress WordPress Theme

Recently I was tasked with adding number tracking w/ Adwords to a client’s website. They are using OptimizePress which isn’t very friendly for any user editing (no child themes, very confusing theme layout for modifications etc).

Anyway, I figured it out and thought others might need to know this, if nothing else, at least on how to edit the <body></body> tag to include an onload(); function 🙂

So, here’s what you do;

Edit the main theme’s ‘functions.php’, which, will be replaced upon an upgrade, so take note of that if you plan on upgrading OptimizePress at a later date (you should!).

function add_body_onload($c) {
 $c[] = ' onload="_googWcmGet(\'number\', \'+1-555-222-3333\')"';
 return $c;
}
add_filter('body_class','add_body_onload');

Then, you’re going to want to edit the header file and add the following code at around line 344 of /lib/functions/page.php;

} else {
 $logo = '<div class="op-logo">test'.$logoH1Start.'<a href="'.esc_url( $header_link ).'"'.$title_str.' rel="home"><img src="'.$logoimg.'" alt="'.$alt.'" /></a>'.$logoH1End.'</div>';
 }

changes to

} else {
 $logo = '<div class="op-logo"><a href="tel:+1-555-222-3333" id="number">555-222-3333</a></div>';
 }

Then, login to the wordpress backend, and add these changes.

First, go to ‘optimizepress -> dashboard -> global settings -> custom css’ and add this

#number {
 font-weight: bold;
 font-size: 50px;
 color: #fff;
 line-height: 55px;
}

Now, save your changes.

Then, go to ‘optimizepress -> blog settings -> modules -> other scripts’ and add the script you got from Adwords, changing the YOUR_ID_HERE portion. Add this to one of the ‘header scripts’ boxes (or, create a new one);

<script type="text/javascript">
(function(a,e,c,f,g,h,b,d){var k={ak:"YOUR_ID_HERE",cl:"P8GfCKfi9mgQ6tz9oQM"};a[c]=a[c]||function(){(a[c].q=a[c].q||[]).push(arguments)};a[g]||(a[g]=k.ak);b=e.createElement(h);b.async=1;b.src="//www.gstatic.com/wcm/loader.js";d=e.getElementsByTagName(h)[0];d.parentNode.insertBefore(b,d);a[f]=function(b,d,e){a[c](2,b,k,d,null,new Date,e)};a[f]()})(window,document,"_googWcmImpl","_googWcmGet","_googWcmAk","script");
</script>

<script type="text/javascript">
var callback = function(formatted_number, mobile_number)
 var e = document.getElementById("number");
 e.href = "tel:" + mobile_number;
 e.innerHTML = "";
 e.appendChild(document.createTextNode(formatted_number));
};
</script>

And, that should be it. Now you’re going to want to test the site, by finding one of your ads, clicking it, and going to the page to make sure the number has changed to to one of your call extensions.

Compiling R1Soft Backup Agent on Ubuntu 16.x or 14.x

If, like us, you use R1Soft backups, you may have recently encountered an error trying to get it to compile on your Ubuntu 14.x or 16.x machines.

This is because they are nearly a year out of date on compiling for the latest kernels, the newest one currently supported is actually 3.16, so, the agent will fail on anything newer than that. You can view all the available module versions from the R1soft repository, by clicking here.

Their support is basically useless [unless you pay], so, we had to find our own solution.

This isn’t the most elegant way to fix things, but, it works, so there’s that. [I guess]. Basically, 16.x comes with kernel 4.4, which won’t work, so what did we end up having to do? Downgrade the kernel!  

Well, not literally downgrade, we just used the older, supported kernel that was already installed.

To make this work for you, you’ll have to edit the grub configuration, by doing this.

# cp /etc/default/grub /etc/default/grub.bak

# nano /etc/default/grub

and make these changes

GRUB_DEFAULT=saved 
GRUB_TIMEOUT=2

then exit and save the file.

Now, we’re going to have to find out which kernels you have installed, for us, we simply did the following;

# grep menuentry /boot/grub/grub.cfg

Which, will give you output similar to the following;

menuentry 'Ubuntu, with Linux 4.4.0-31-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 4.4.0-31-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-init-upstart-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 4.4.0-31-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-recovery-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 3.16.0-77-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-77-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 3.16.0-77-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-77-generic-init-upstart-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 3.16.0-77-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-77-generic-recovery-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {

In our case, we want to use the 3.16.0.77 version of the kernel, so, we simply issue these commands;

# grub-set-default "gnulinux-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825>gnulinux-3.16.0-77-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825"
# grub-reboot "gnulinux-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825>gnulinux-3.16.0-77-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825"
# update-grub

then, you’re ready to reboot into your shiny old kernel

# reboot

now, you can verify that the R1Soft agent is working again, using this;

# hcp -v

Idera Hot Copy 5.14.4 build 433 (http://www.r1soft.com)
Documentation http://wiki.r1soft.com
Forums http://forum.r1soft.com

Thank you for using Hot Copy!
Idera makes the only Continuous Data Protection software for Linux.

hcp driver module: 4.6.1 build: 41

and

# /usr/sbin/r1soft/bin/cdp -v
(R1Soft CDP Agent) version 5.14.4 build 433 2016/07/18 16:41:16

That’s it! you’ve got working backups again!

 

Upgrading your Google Nexus 5x to the latest Pure Nexus release

Mainly putting this here for myself, but if anyone else can be helped, then cool!

GET FACTORY BOOTLOADER AND RADIO (if needed):

  1. get for your device from https://developers.google.com/android/nexus/images
  2. unzip
  3. copy bootloader and radio to a directory
  4. update it using next instructions

UPDATE BOOTLOADER AND RADIO:

# ./adb devices
# ./adb reboot bootloader
# ./fastboot flash bootloader [bootloader file].img
# ./fastboot reboot-bootloader
# ./fastboot flash radio [radio file].img
# ./fastboot reboot-bootloader

DOWNLOAD LATEST ELEMENTALX:

PURENEXUS DOWNLOADS:

HOW TO FLASH PURENEXUS 5X:

  1. Download the latest Pure Nexus zip, latest GApps (recommended ones linked, use others at your own risk), SuperSU (if you want root), and your custom kernel if you have one onto your phone.
  2. Backup any important data.
  3. Boot into TWRP and make a backup (optional but HIGHLY recommended).
  4. Wipe system, data, cache, and dalvik cache in Wipe > Advanced Wipe.
  5. Flash Pure Nexus zip.
  6. Flash GApps zip.
  7. Flash your custom kernel (optional).
  8. Flash SuperSU (optional).
  9. Flash new boot animation.zip (optional)
  10. Reboot and profit.