Category: WordPress Code Techniques
post_class() and get_post_class() – Performance Killers for WordPress and WooCommerce
The get_post_class() function is a WordPress function commonly used within post “rivers”. For example, if I had a list of posts, WooCommerce products, or any content type really, I might have some code like this: <div > Note: post_class() just calls get_post_class() and outputs it to the browser. post_class() will output something like class=”post has-post-thumbnail…
Syncing Backbone Models and Collections to admin-ajax.php
Backbone is framed around the assumption that your models and collections are backed by RESTful API’s. If this isn’t the case, life becomes difficult. WordPress provides an AJAX API for backend AJAX requests. These requests are sent through admin-ajax.php which is not RESTful. I’ve written some code to force Backbone models and collections to play nicely…
WP_UnitTestCase: The Hidden API
Background: Unit testing is the automated testing of units of source code against assumptions. The goal of unit testing is to write test cases with assumptions that test if a unit of code is truly working as intended. If an assumption fails, a potential issue is exposed, and code needs to be revised. By definition…