WP_User_Query Inverse (NOT) Search

It took a LOT longer than it should have to build an efficient query for WordPress users today. The query — an WP_User_Query INVERSE search.

The list I was trying to generate was based on two things:
– All users with a meta_key field ‘account_status’ containing the status ‘active’
– EXCLUDE all users with a nicename ending with “at_slp_dot_guru”

Turns out this is a LOT more difficult than it should be due to shortcomings in the WP_User_Query class. The solution that created the least amount of data queries , and thus improved performance over other “post filter” methods was to make use of the pre_user_query action hook that is part of WP_User_Query.

The Patch

The short version of the patch — use the pre_user_query to change an “INCLUDE all users with this search value” to an EXCLUDE for those same users. This is done by using the INCLUDE search filter than “flipping the logic” by replacing the field comparison in the WordPress-generated query to NOT LIKE instead of LIKE.

/**
 * Filter out SLP dot Guru accounts.
 *
 * @param WP_User_Query $wpUserQuery
 */
public function filterOutSLPDotGuru( $wpUserQuery ) {
   $new_query_where = str_replace( "(user_nicename LIKE '" , "(user_nicename NOT LIKE '" , $wpUserQuery->query_where);
   $wpUserQuery->query_where = $new_query_where;
}
Read More

Ubuntu Trusty: PHP 7.2 MIA

Working with Varying Vagrant Vagrants today and having problems spinning up a new box? Don’t blame yourself. It appears that the PHP 7.2 libs… in fact ALL of the PHP libs for Ubuntu Trusty have gone away.

The ppa:ondrej/php repository that is cited everywhere has decided it is not going to serve up any PHP code to your Vagrant boxes today.

Maybe they’ll fix it soon. Maybe not. If anyone has a workaround please comment here.

Read More

Vue – JavaScript Library Outside Google/Facebook Control

River Siene Paris Aug 2018

Vue is running on several projects to create a better admin user experience. Vuetify is layered on top and baked into WordPress themes and plugins.

You will need to add a little custom CSS to stop WordPress from stomping on the UX. You’ll also add a small localize script to seed Vue with relevant data from WordPress. A little REST applet to serve Vue requests and you get a fast good looking responsive app with far less effort than custom code, WordPress skeleton apps, React, or Angular.

Vue + Vuetify is my new go-to tool for plugins and themes.   I am happier with my choice knowing that was created and is supported by small independent developers.

Read the article: www.wired.com/story/the-solo-javascript-developer-challenging-google-facebook

WordPress Needs To Abandon PHP 5.2 Compatibility

As PHP continues its march into the future with improved support for objects, better memory management, and notable performance boosts WordPress seems to be dead-set in sticking to the “must support old technology no matter how bad it is”.    As of this writing, on the verge of the much-anticipated WordPress 5.0 release with the almost-modern reactive components interface — the past continues to hamper the technology by insisting on clinging to PHP 5.2 as the baseline version that plugins and themes should support.

PHP 5.2 Is Dead

Not recently dead.  Long deceased.  PHP 5.2 support officially ended OVER SEVEN YEARS AGO in January of 2011.    That is about 3,000 years ago in human-time.

Read More

How To Hire A Programmer

Businesses have been hiring programmers for decades now.    Back in the 70s it was something only Fortune 100 companies did.  Today everyone from your local cafe to full-fledged software companies do it.   Unfortunately few now how to hire a programmer.

Nearly every-single business outside of the tech sector gets screwed when paying an outside agency to write their apps. If you’ve hired a programmer recently it is very likely you are on that list.   If you don’t think you’ve been screwed, you are likely just wallowing in a pool of naivety as your coder-for-hire laughs all the way to the bank.

Read More

%d bloggers like this: