In my last article for Torque, I gave an introduction to using the JavaScript framework VueJS with the WordPress REST API. In that post, you learned how to combine the WordPress REST API with VueJS and jQuery AJAX to show and edit single posts. It was also an introduction to the Vue constructor and template syntax. This week, I want to introduce components and some additional data attributes. Components allow for greater code reuse throughout the application. As a practical example, this article will show how to create a post list and a single post component. Since this is VueJS, […]
Introduction To VueJS With The WordPress REST API
I’ve covered using the WordPress REST API with AngularJS in the past for Torque because I like it and have used it quite a bit. However, I have been using Laravel a lot lately, and the Laravel ecosystem has embraced VueJS as the front-end framework. That encouraged me to try it out and I’ve been impressed by its simplicity. My first real experience using VueJS was for the Caldera Forms front-end entry viewer. I had been experimenting with new ways of handling UI and I found VueJS to be the fastest to learn and loved the results. In this article, I’m going […]
Creating Incentivized Optins With Easy Digital Downloads Discount Codes
A lot of WordPress plugins, including Easy Digital Downloads and WordPress SEO offer discount codes in exchange for allowing anonymous usage tracking. It’s a smart offer to make as the data is valuable. But, it’s also a great option for users of the plugin. This article is based on my experience setting up such a system for my plugin Caldera Forms. I will show you how I set up Easy Digital Downloads (EDD) on our site to dynamically generate the discount codes. I will also show how I set up the emails that provide the codes. This should be a […]
Using Automatic Dependency Injection For WordPress Development
A common design pattern for WordPress plugins is to have one “main class” that implements the singleton pattern. This pattern is called the “God Class” and it loads all of the other classes the plugin needs as well as instances of those classes in properties of that class. I’ve utilized this anti-pattern, because it accomplishes a job and often is the best option for codebases that support PHP 5.2. But it’s not nearly as efficient as dependency injection to achieve a similar outcome. The advantage of an implementation of the “God Class” anti-pattern is that you only need one singleton. […]
Unit Testing Custom WordPress REST API Endpoints
I’ve written a lot about the WordPress REST API for Torque, but one thing I have not covered is unit testing custom APIs. That is exactly what this article is. I used a PHP program run the code and compare the results to an expected value. If you want to learn more, I would recommend reading Pippin Williamson’s series on WordPress unit testing. It’s quite excellent and covers how to setup your local environment for testing and how to write tests. For example here is a very simple test: <?php function answer(){ return 42; } class Test_42 extends WP_UnitTestCase { […]
Comparing The Developer Experience Of WordPress eCommerce To Laravel Cashier
Last week I wrote about using Laravel’s Cashier package to create a subscription-based site. It was based on my experience creating a small SaaS site that serves Caldera Forms users. If you read that article, you might have wondered why I didn’t use Easy Digital Downloads or WooCommerce, or even my own plugin Caldera Forms. All of those have plenty of tools for creating and managing recurring subscriptions. One answer is that I wanted to learn something new, but I actually found it easier for what I wanted to do. My last article was very technical. In this post, without […]
Using Laravel Cashier With BrainTree For Your SaaS
I recently created my first subscription-based SaaS service, a form to PDF service for users of my plugin Caldera Forms. I built the application using the PHP framework Laravel, making use of their Cashier package for the subscription billing. In this article, I want to show you how I did this on a technical level. SaaS options are becoming more and more prominent in the WordPress community, and the only tutorial I could find out there was using Stripe, not BrainTree. Those were useful, but I wanted to use Braintree as it offers both credit card and PayPal. I figured it […]
Using Forge To Provision And Manage WordPress Sites
I used to claim I didn’t know anything about servers. And, while I’m not an expert, I have learned quite a bit in by time as a web developer. I use Ubuntu every day, both as my desktop computer’s OS and as the OS for the virtual machine I host my WordPress sites. Though I’ve learned a lot, I couldn’t set up my own server — or really a Virtual Private Server (VPS) without help. However, I’ve become familiar Laravel Forge, a server provisioning and deployment tool created by the Laravel project that is easy to learn. While it is […]
AngularJS Translations In A WordPress Environment
Lot’s of people, myself included, have been extolling the virtues of using a JavaScript MVC framework, instead of a traditional PHP templating system as a WordPress front-end. While I’m pretty down on how WordPress traditionally handles templating, the one thing it does well is translation strings. WordPress is full of great functions for making text translatable. While angular-translate and other modules are available for localization, they all feel clunky and redundant when WordPress already has great localization built in. In this article, I want to share a simple way to use WordPress to manage localization and avoid using untranslatable strings […]
Understanding Copies & References in PHP
I like to think I’ve gotten pretty good at PHP, but I’ll admit there are plenty of times I feel like I know nothing. One thing that has tripped me up recently is the difference between variable copies and variable references. Often, this difference comes into play with function or method properties, but it is more than that. I hope by reading this article you will be better equipped to deal with this tricky subtilty in the language when it affects you. References vs Copies When we create a variable by passing an argument to a function or method, we […]
1 Comment