Recursion and How to Get All the records from a paginated API

I was recently working with an API that limited the max number of items it let you call at once. This was frustrating, because I needed everything. The solution, thankfully was recursion. Recursion is really fun when you get to use it. I needed to use this solution in both JavaScript and Python, so I had the opportunity to build it out in both. Since this is now a solved problem, I decided to share it for others.

Continue reading...

How to see if a class was added to an element using JavaScript

If you need to see if a class has been added to an element the easiest way is to trigger a new event when you add the class. $(this).addClass(‘someClass’); $(mySelector).trigger(‘cssClassChanged’); The problem with this solution is what happens if you do not have control over the function where this happens. Like if it happens in the WordPress core, and you know that you should never ever change code in the core.

Continue reading...