Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

NetTuts.com:
Using Namespaces and Autoloading in WordPress Plugins, Part 4
Jan 19, 2017 @ 10:24:36

The TutsPlus.com site has posted the fourth part of their series covering the use of namespacing and autoloading in WordPress plugins. In this latest tutorial they take everything they've shared (and made) previously and put it all together into a cohesive whole plugin.

At this point, we've laid the foundation for our plugin, written the plugin, and defined and explored namespaces and autoloaders. All that's left is to apply what we've learned.

So in this tutorial, we're going to put all of the pieces together. Specifically, we're going to revisit the source code of our plugin, namespace all relevant classes, and write an autoloader so that we can remove all of our include statements.

He starts off talking about namespacing and how it relates to directory structure and the code you'll need for each of the plugin files for put them in the correct namespace. With just these in place, however, errors are thrown. This requires the setup of a custom autoloader and PHP's own spl_autoload_register handling. He includes the code for the autoloader, taking in the class name and splitting it up to locate the correct directory, making it easier to replace the loading of all plugin scripts.

tagged: namespacing tutorial series part4 wordpress plugin autoloading namespace

Link: https://code.tutsplus.com/tutorials/using-namespaces-and-autoloading-in-wordpress-plugins-4--cms-27342

Stoyan Stefanov:
HTTPS migration: a WordPress blog hosted on Dreamhost
Jan 09, 2017 @ 09:17:27

Stoyan Stefanov has written up a post sharing the process he followed to migrate a WordPress blog to HTTPS on the Dreamhost hosting service.

Now some folks reminded me recently that the Perf calendar was not yet migrated to HTTPS... True enough. I have to do it. Eventually. In any normal situation I'll procrastinate indefinitely, but since I had more pressing things to do and "Anyone can do any amount of work, provided it isn’t the work he is supposed to be doing at that moment"... I bit the bullet.

Below are the steps that worked for me with a WordPress blog, hosted on DreamHost. The steps are still relevant to any WordPress site, just using Dreamhost as an example and since Dreamhost makes many of the steps easy.

He breaks the process down into six parts, including a bit of testing at the end:

  • Setup free SSL certificate thanks to Let's Encrypt
  • Backup all the things (or just the blog's database or just the table with the posts)
  • Search and replace internal references (images and links) WP settings
  • Redirect http to https permanently in .htaccess
  • Test/tweak?

Each step comes with the code or configuration you'll need to set up HTTPS and some screenshots where necessary, like with the Let's Encrypt setup.

tagged: wordpress migrate https blog dreamhost letsencrypt tutorial

Link: http://www.phpied.com/https-migration-wordpress-blog-dreamhost/

DeliciousBrains.com:
Writing Functional Tests for WP-CLI Packages
Jan 05, 2017 @ 12:57:25

On the Delicious Brains blog there's a post sharing some of their knowledge about building tests for WP-CLI packages, a set of command line tools for administering a WordPress installation. Their testing makes use of the Behat testing tool (already in use on WP-CLI's own tests).

My last article was part of a short series on automating local WordPress site setup. In that series, we created a WP-CLI package that helps with installing and uninstalling WordPress development environments, and we even got it submitted to the WP-CLI Package Index.

[...] In this post we’re going to take a bit of a break from automating WordPress installs and start writing some functional tests to make sure that everything works as expected. While I’ll be writing the tests for the wp installer command, the same concepts should apply for any WP-CLI package.

They start by clarifying the difference between functional and unit tests and how to get your environment all set up and ready to use for testing. They help you get the wp_scaffold_package installed and how to confirm that everything is working as expected. From there it's all about the tests: ensuring that a package is active, creating a custom step to use in testing and an example of what the output should look like.

tagged: functional test wordpress wpcli package behat tutorial

Link: https://deliciousbrains.com/writing-functional-tests-wp-cli-packages/

Toptal.com:
Don't Hate WordPress: 5 Common Biases Debunked
Dec 29, 2016 @ 12:10:30

On the Toptal.com site author Donald Mudenge has written up a post that wants to help debunk the top 5 WordPress myths that are still floating around about this popular and common tool.

In the early days, people used WordPress only as a blogging tool. However, today WordPress covers more than 50 percent of the market share for CMSs, supporting nearly 60 million websites worldwide.

As a commonly used platform for building websites and other online applications, misconceptions have spread like a forest fire, keeping people away from WordPress. In this article, I outline and explain the five most common WordPress taboos and myths, clarify them and offer solutions on how to overcome them.

The five myths he tries to dispel are:

  • WordPress is significantly more likely to be hacked.
  • WordPress is just blogging software.
  • WordPress professionals are designers.
  • WordPress isn’t an enterprise solution.
  • One WordPress requires one database.

For each item on the list he includes a brief summary of what's usually said about the myth and corrects it with his own description and links to other resources helping to prove his point.

tagged: wordpress myths debunk top5 common hacked blog enterprise database

Link: https://www.toptal.com/wordpress/debunking-wordpress-myths

Toptal.com:
The Ultimate Guide to Building a WordPress Plugin
Dec 23, 2016 @ 12:07:41

For those newer to the world of WordPress, you might only be casually familiar with WordPress plugins and their use. You might have only installed them and used them before but have you wondered what it would take to make your own? In this new tutorial from Toptal.com Ratko Solaja gives you a "ultimate guide" to getting started down the road of custom WordPress plugin development.

Plugins are a vital part of WordPress websites that need specific functionalities. While the official WordPress repository has more than 45,000 plugins from you to choose from, many of these plugins miss the mark.

Just because a plugin is in the repository doesn’t mean it won’t hinder its performance or compromise its security. So what can you do? Well, you can build your own.

He starts with the planning stages of his example plugin (a real-world project helps when learning new things) - one that allows users to save content for later reading. He outlines the goals of the settings screen, how saving will work, messages to the user and what the "saved" screen will do. He recommends starting with a boilerplate plugin and working from there. He then goes through each step of the development process:

  • Handle activation and deactivation
  • Create a plugin settings page
  • Create the plugin functionality
  • Make the plugin modular
  • Generate translation files

The end result is a complete plugin with both the required frontend and backend functionality to make the "save content" feature work. All code is provided and plenty of links to more information and other resources are sprinkled throughout the article.

tagged: toptal wordpress plugin guide tutorial content example

Link: https://www.toptal.com/wordpress/ultimate-guide-building-wordpress-plugin

TutsPlus.com:
Object-Oriented Autoloading in WordPress, Part 3
Dec 01, 2016 @ 11:15:35

TutsPlus.com has continued their series covering object-oriented development practices in WordPress (plugins) with this third tutorial. In previous parts they set up the environment and introduced some of the basic concepts of OOP programming and getting the first classes and files defined.

In the last tutorial, we reviewed the original state of our autoloader and then went through a process of object-oriented analysis and design. The purpose of doing this is so that we can tie together everything that we've covered in this series and the introductory series.

Secondly, the purpose of doing this in its own tutorial is so we can spend the rest of this time walking through our class, seeing how each part fits together, implementing it in our plugin, and then seeing how applying object-oriented programming and the single responsibility principle can lead to a more focused, maintainable solution.

They start with a brief review of what they've covered so far and begin to build on the changes suggested in the previous part of the series. They've already broken it down into the different functional classes (according to the single-responsibility principle) and take the next step of including them and calling some example code to prove all is working as expected.

tagged: oop wordpress tutorial series objectoriented programming plugin part3

Link: https://code.tutsplus.com/tutorials/object-oriented-autoloading-in-wordpress-part-3--cms-27515

TutsPlus.com:
Object-Oriented Autoloading in WordPress, Part 2
Nov 30, 2016 @ 09:33:08

The TutsPlus.com site has posted the next tutorial in their "Object-Oriented Autoloading in WordPress" series - part two - expanding on the basics presented in the previous part of the series.

In the previous tutorial, we covered a handful of concepts, all of which are going to be necessary to fully understand what we're doing in this tutorial. Specifically, we covered the following topics: object-oriented interfaces, the single responsibility principle, how these look in PHP [and] where we're headed with our plugin.

[...] Ultimately, we won't be writing much code in this tutorial, but we'll be writing some. It is, however, a practical tutorial in that we're performing object-oriented analysis and design. This is a necessary phase for many large-scale projects (and something that should happen for small-scale projects).

First they briefly cover the environment you'll need to follow along (already set up if you followed along with part one). They then get back into the code, evaluating the current state of the custom autoloader and investigating how it can be broken down into a class and a set of methods instead of procedural code. They work through the different functional parts of the autoloader and how to break it down into classes with only one job (the "single responsibility principle"). They end up with the autoloader that uses NamespaceValidator, FileInvestigator and FileRegistry instances to get the job done.

tagged: oop objectoriented wordpress part2 series refactor singleresponsibility principle

Link: https://code.tutsplus.com/tutorials/object-oriented-autoloading-in-wordpress-part-2--cms-27431

TutsPlus.com:
Object-Oriented Autoloading in WordPress, Part 1
Nov 18, 2016 @ 13:57:08

The TutsPlus.com site has posted the next part of their series looking at autoloading in WordPress plugins. In this latest post the most from just the namespacing and setup into the actual code - creating some simple object-oriented classes that can be easily autoloaded.

I recently wrapped up a series in which I covered namespaces and autoloading in WordPress. If you're not familiar with either of the above terms, then I recommend checking out the series. [...] While working on the series, specifically that of the autoloader, I couldn't help but recognize a number of code smells that were being introduced as I was sharing the code with you.

This isn't to say the autoloader is bad or that it doesn't work. If you've downloaded the plugin, run it, or followed along and written your own autoloader, then you know that it does in fact work. But in a series that focuses on namespaces—something that's part and parcel of object-oriented programming—I couldn't help but feel uncomfortable leaving the autoloader in its final state at the end of the series.

They move away from just autoloading and namespacing quickly and move into OOP concepts like interfaces, implementing them, the "single-responsibility principle" and a few other helpful principles. They define the goals for the work ahead and move into the code, updating the current state of the plugin to use these new ideas.

tagged: oop objectoriented wordpress part1 series interface singleresponsibility principle

Link: https://code.tutsplus.com/tutorials/object-oriented-autoloading-in-wordpress-part-1--cms-27381

TutsPlus.com:
Using Namespaces and Autoloading in WordPress Plugins, Part 3
Nov 15, 2016 @ 10:23:30

On the TutsPlus.com site they've continued their WordPress series showing you how to integrate class autoloading into your plugin development.

In this tutorial, we're going to take a break from writing code and look at what PHP namespaces and autoloaders are, how they work, and why they are beneficial. Then we'll prepare to wrap up this series by implementing them in code.

In the previous part of the series they built up the environment and some of the basic structure of the plugin (you'll need this to follow along with this new tutorial) and continue on, starting with the basics of namespacing and autoloading. They then move over and start applying this functionality to the plugin classes and what happens in the autoloader when they're referenced.

tagged: wordpress autoload namespace tutorial part3 series

Link: https://code.tutsplus.com/tutorials/using-namespaces-and-autoloading-in-wordpress-plugins-3--cms-27332

Zend Developer Zone:
WordPress updates Plugin Guidelines
Nov 11, 2016 @ 12:55:11

The Zend Developer Zone has a new post with information about some updates from the WordPress project about what plugin authors must do to be compliant with the rules of the WordPress Plugin Directory.

After five years, the WordPress plugin team has updated the Plugin Guidelines. These are the guidelines that WordPress plugin authors must comply with to be included in the WordPress Plugin Directory.

The guidelines were soft-launched last month so that they could be vetted by the larger plugin developer community community. On November 1st, 2017, they were officially announced “Revised Guidelines Are Live” by Mika Epstein.

Overall, these guidelines are good. They are solid, well communicated and clear to anyone who reads them.

The ZDZ post focuses in on just two of the guidelines that were updated with a few brief thoughts in each:

  • #4. Keep your code (mostly) human readable
  • #9, The plugin and its developers must not do anything illegal, dishonest, or morally offensive

They point out that, while the intent is good for #9, the term "morally offensive" is very broad and could be interpreted in many ways by many different groups.

tagged: wordpress plugin update directory official guidelines

Link: https://devzone.zend.com/7331/wordpress-updates-plugin-guidelines/