So far, all plugin examples that have been covered in this chapter have been written using the procedural PHP programming style, with all the functions declared directly in the main body of the plugin and the hook registration functions having direct access to these functions.
WordPress can also be written using an object-oriented PHP approach. This recipe explains how to convert the code from the previous recipe into a class-based version of the same functionality.
You should have already followed the Loading a style sheet to format plugin output recipe to have a starting point for this recipe. Alternatively, you can download the resulting code (Chapter 2/ch2-private-item-text/ch2-private-item-text-v2.php
) for that recipe from the Packt Publishing website (https://www.packtpub.com/support).