Tutorial on how to leverage Varying Vagrant Vagrants, Codeception and wp-browser to write acceptance tests for WordPress plugins.
Ever anxious about pushing new release of WordPress plugin causing the white screen of death on your clients’ sites? You should write some acceptance tests! I will demonstrate how to leverage Varying Vagrant Vagrants, Codeception and wp-browser to write acceptance tests for WordPress plugins. Codeception is a PHP testing framework built on PHPUnit that automates acceptance testing. It does functional and unit tests also.
wp-browser is a WordPress specific set of extensions for Codeception written by theAverageDev.
The package includes a class extending Codeception PhpBrowser module that adds WordPress related assertions for cest and cept tests, an extension of Codeception own Db module meant to allow for more comfortable WordPress specific database handling and testing and a class taking care of installing and loading a WordPress installation relying on WordPress automated testing suite.
We’ll run our tests from within VVV because WP CLI, Node, and Composer are already installed for us there.
Before we actually writing the tests, we need a WordPress installation and a plugin to test. I use my plugin Remove Medium Cross Links as an example. All it does is remove the medium
Syndicating content to third-party sites may not be safe. If don’t support the use of the rel=”canonical” tag. Chance are they outrank you on SEO and makes Google thinks they are the original authors. Worse still, Google penalise you on duplicate content. Good news is Medium do support canonical tags. Thus, you can trust Medium to repost your articles without hurting Google rankings.
Syndicating content to third-party sites may not be safe. If don’t support the use of the rel="canonical" tag. Chance are they outrank you on SEO and makes Google thinks they are the original authors. Worse still, Google penalise you on duplicate content. Good news is Medium do support canonical tags. Thus, you can trust Medium to repost your articles without hurting Google rankings. First thing first, why re-posting WordPress content to Medium at all? The answer is simple: Get more readers that actually read! Medium has an algorithm to predict what type of articles one might want to read. Publishing on Medium almost guarantees your content will get seen by the targeted audience and its network effect is powerful.
No! Copy and paste is not a solution. Medium has already make a plugin for you. Install the official Medium plugin from wordpress.org
Upon activating, you can find Medium settings on WordPress’ user profile.
The integration token can be found on Medium settings page. From now on, your WordPress articles will also be posted to Medium automatically.
Does Medium hurting my SEO?
Short answer: No.
Long answer: The Medium plugin adds a rel="canonical"
Having downtime without noticing it is the worst kind of downtime. Here come Uptime Robot, a free service let you create 50 monitors that checks every 5 minutes, not to mention email alert, mobile apps, API support and public status pages.
What is worst than having downtime? Answer: Having downtime without noticing it. Here come Uptime Robot, a free service let you create 50 monitors that checks every 5 minutes, not to mention email alert, mobile apps, API support and public status pages. Uptime Robot homepage
Head to Uptime Robot’s website and create an account. You have to verify your email address before continue. This is probably the hardest part in this tutorial.
Upon logging into the dashboard, add a new HTTP monitor using the button on the top left corner. Enter a human-readable name and the URL you want to monitor. I use Typist Tech’s homepage as an example. Make sure you also selected “Alert Contacts To Notify”.
Uptime Robot will check this URL every 5 minutes, if 4xx or 5xx response is returned, it makes several more checks from other locations in the next 30 seconds. If the URL is still down, it sends an alert.
Click To Tweet
Let’s add a keyword monitor. Uptime Robot checks my site tagline and alerts me if tagline not found.
Which Pages Should I Monitor?
It’s totally up to you. For a typical WordPress blog, I would suggest:
How to configure WP Cron to work properly via Linux crontab and Uptime Robot. Ensure WP Cron runs on time.
WP Corn is the schedule system implementation of WordPress. Unlike linux cron, it doesn’t guarantee jobs are performed on time. Ever wondered why your scheduled posts not posted at specific time but suddenly published when you log in to WordPress dashboard to check out what’s wrong? You are the victim of WP cron. Scheduled jobs are saved into database and wait for WP Cron to perform them. However, unlike traditional corn systems, it’s doesn’t watch the clock periodically.
Click To Tweet
On a low-traffic WordPress site, WP Cron often perform the scheduled jobs beyond their specific time because nobody visits WordPress. Thus, nobody triggers WP Corn to check for scheduled jobs. Finally, someone visit WordPress and fires too many jobs, causing PHP timeouts.
On the other hand, high-traffic sites trigger WP Cron too often. As jobs are saved in database, querying for cron jobs become a waste of resource. Worse still, multiple WP Corn instances might performing the same job at the same time. This could be problem if the jobs are not idempotent (safely execute multiple times). Lucky for you, WordPress has a better locking system and much less issues about this is reported
Because no developer should ever cowboy coding, it’s important to have a local development WordPress environment. Varying Vagrant Vagrants lets you create and remove testing WordPress sites on local machine with ease.
Because no developer should ever cowboy coding, it’s important to have a local development WordPress environment. Varying Vagrant Vagrants lets you create and remove testing WordPress sites on local machine with ease. Learn more about why you should have a development envirement. Watch Tom McFarlin‘s talk on The Truth About the Environment at WordCamp Atlanta 2016.
What is Varying Vagrant Vagrants?
The primary goal of Varying Vagrant Vagrants (VVV) is to provide an approachable development environment with a modern server configuration. VVV is ideal for developing themes and plugins as well as for contributing to WordPress core.
Being said, VVV is a WordPress development environment on your local computer, including:
Install Varying Vagrant Vagrants
1. Vagrant and VirtualBox
First, make sure you have homebrew installed correctly.
Then, install homebrew cask, vagrant and virtual box.
2. Install Vagrant Plugins
These vagrant plugins are optional, but they do make your life easier.
3. Clone the VVV repo
4. Booting Up the VM
Have a coffee break! The first time boot up needs to download the whole LEMP box plus tons of development tools come with VVV. It might takes 20 minutes
By no doubt putting a nice set of eye-catching social share buttons on your pages is the first step to seduce visitors to share your content. Negligible difference when benchmarking WP Font Awesome Share Icons plugin. Making it the fastest social share WordPress plugin I ever seen.
By no doubt putting a nice set of eye-catching social share buttons on your pages is the first step to seduce visitors to share your content. There are thousands of share button plugins on the WordPress plugins repository makes choosing the right one become difficult than ever. The Requirement
Responsive Social Share Buttons
According to We Are Social, mobile traffic increased by 39% from 2014 to 2015 with one-third of all web pages now visited on mobile devices.
Click To Tweet
Fast Social Share Buttons
WP Font Awesome Share Icons
Here comes our weapon of choice WP Font Awesome Share Icons available on WordPress.org for free. Supporting 16 different networks:
W3C Validation Link
Easy enabling or disabling
Ever think about hosting WordPress sites on Heroku? Think again. It’s not as easy as deploying Rails applications. In fact, it’s a headache. Besides the limits you find in the official document, I am showing you some of my thoughts on Heroku WordPress hosting.
Ever think about hosting WordPress sites on Heroku? Think again. It’s not as easy as deploying Rails applications. In fact, it’s a headache. Besides the limits you find in the official document, I am showing you some of my thoughts on Heroku WordPress hosting. Heroku’s Ephemeral Filesystem
Each dyno(Heroku’s term on its servers) gets its own ephemeral file system. When you uploaded an image, the image is stored on one of the dyno only. The images will be erased after dyno restart. Worse still, Dynos crash if you try to write to its file systems.
Here comes the solution: Offload media files to Amazon S3. Delicious Brains have written an excellent plugin for hooking S3 into WordPress’ media library seamlessly.
Besides, you need to stop editing the source code from WP admin. Add these two lines intowp-config.php
Also, auto WordPress core / theme / plugin updates should be disabled. This handy plugin does the job. Managing the updates by Git or Dropbox is necessary.
Moreover, the ephemeral filesystem might break your caching and minifying plugins. You have to Batcache with the Memcachier add-on, or plugins that write to an external server.