Lance Cleveland

Profile WordPress Cron Jobs With VVV

I recently found that I needed to Profile WordPress Cron to figure out the best way to improve the processing time on background file imports.

In an effort to better handle on large location imports in Store Locator Plus, I re-architected the Power add on to split the process into 3 steps.   The first step uploads the file to the server; something that is typically fairly fast and only ties up a user’s web browser for a few minutes as most people are no longer on dial-up.   The second step, the reason WordPress Cron is now in play, is to fire off a background process via WP Cron to then parse the CSV file.     This second process is the one I want to profile.

Luckily I am using a typical VVV setup as part of my development environment.   It has Webgrind, a PHP cache grind file reporting tool, already enabled “out of the box”.   I only need to run the debug_on command from the Virtualbox command line and then add &XDEBUG_PROFILE to the end of any URL request to get a view into what functions are called and how much CPU time they are eating up.

Things get tricky if you want to profile WordPress Cron processes though.    Since they are fired off from WordPress automatically, how do you add a GET variable?
Read More

Should The WordPress PHP Version Be Updated?

WordPress LOVES backwards compatibility as can be witnessed by the minimum-allowed WordPress PHP version remaining at 5.2.4 a decade after its end-of-life date.  It  may be  one of the reasons they have continued to garner market share.  Don’t require people to do anything to improve their site and they’ll wallow in complacency.  It makes sense.  Inertia is a big thing to overcome.  If you are a business focused on writing content, selling widgets, or doing just about anything else other than managing websites, upgrading software is way at the bottom of the priority list.

This backwards compatibility is one of the reasons why WordPress continues to RECOMMEND PHP 7 for performance and security reasons but allows the minimum WordPress PHP version to remain 5.2.4 without breaking the core application.    It is the reason why so many plugins, including Store Locator Plus, continue to do some convoluted things to reach that PHP 5.2 audience and keep their potential market as big as possible.
Read More

My First Technical Writing Gig – Writing for Jetpack

A few months ago an acquaintance of mine put out a public post on a message board over at Codeable asking if anyone would be interested in writing articles for Jetpack.   I was looking to improve my personal cash flow and that sure as heck sounded like a better fit for me than driving Uber.    I already shoot videos and write articles about all kinds of tech stuff.  A technical writing gig should be easy.   Or so I thought.

My first technical writing gig

My first technical writing gig

Now that my first two articles, Four Jetpack Features Worth Exploring and How Often Should You Back Up Your Site?, have been published on Jetpack I can share what I’ve learned thus far.
Read More

Uncovering A WordPress Walker Class Inconsistency

Took an hour tonight to figure out why the new Store Locator Plus Premier Button Bar is not working properly.   The odd thing is this WAS working properly two weeks ago but both our own code for the base plugin and Premier add on changed as well as a new WordPress release.    Maybe something changed in WP Core to trigger the problem in our add on or maybe something we fixed elsewhere in the code exposed this weak spot.

The real issue here is undocumented parameters in a documented WP Core function and the use of a non-standard call to PHP’s func_get_args() to bypass a defined PHP class method’s parameters.   That’s not nice but as someone maintaining a legacy PHP app with tens-of-thousands of user, I get it.

Here is what I found , why it is “not nice” and how I fixed it.   Maybe it will help other plugin/theme devs with their custom Walker classes.
Read More

wp_enqueue_scripts Deep Dive

While trying to figure out why the footer-loaded scripts in Store Locator Plus are not being output on some admin page, I went deep down the rabbit hole of the WordPress wp_enqueue_scripts function.   Here are my notes from an analysis of WordPress (5.0-alpha-42191) .

wp_enqueue_scripts

/Users/lancecleveland/vagrant-local/www/wpslp/public_html/wp-includes/functions.wp-scripts.php

This is a PHP inline function.

The local $wp_scripts variable is set as a copy of the global $wp_scripts variable which is an instantiation of the WP_Scripts class.
Read More

%d bloggers like this: