Category: Wordpress

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;

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="//";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 type="text/javascript">
var callback = function(formatted_number, mobile_number)
 var e = document.getElementById("number");
 e.href = "tel:" + mobile_number;
 e.innerHTML = "";

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.

Woocommerce and W3 Total Cache and APC

If you’re like me and have Apache (or, possibly Nginx) running with PHP5-FPM and Woocommerce you might want to go a step beyond and setup W3 Cache as well.

This is great, but up until now there’s been some issues with it which seem to have all been fixed, but I’m putting it in here so I can refer to it later and who knows it may help someone else since these were buried in various forums 🙂

First, setup everything, then install w3 cache.

In the database settings you’ll want to make sure;


Is in the ‘database stem exclusion’ listing on the configuration page.

Then make sure you’re disabling the cart, and checkout on the page cache page by entering the following on the exclude stems list (this may not be required, but it can’t hurt now can it)


Then, finally go to the minify settings screen and make sure you have

mfunc’ to the ‘Ignored comment stems’ option in the settings.

There you have it, w3 cache should be working great and now you can check your speed.


WordPress 3.5 ‘Add Media’ button not working? Here’s a fix

For some reason WordPress 3.5 stopped allowing the ‘add media’ button to work. Even after using multiple browsers, deactivating all plugins, re-uploading the core wordpress files and reverting themes we still couldn’t get it to work.

Buried in the forums, we found a solution.

In your wp-config.php , add the line ‘define(‘CONCATENATE_SCRIPTS’, false );’

In other words, it used to look like;

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
 define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Now it should look like this;

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
 define('ABSPATH', dirname(__FILE__) . '/');
define('CONCATENATE_SCRIPTS', false );
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Then just refresh your page, and add media button should work again.

Good luck!