In this hands-on lab, you and I will walk through the entire process of adding a new feature to an existing WordPress plugin. You’ll start with the Collapsible Content plugin and then add a FAQ feature to it. This feature will require you to plan, think, and execute building a custom post type, custom taxonomy, advanced SQL queries, custom archive, and shortcode.
WordPress identifies each plugin by the bootstrap file’s header, i.e. when it complies with the minimum requirement. The header is a PHP file DocBlock. WordPress searches in the root of each plugin’s folder, opens each file, and then reads each file’s header (DocBlock). When it finds the right one, then it adds that plugin. In this episode, you will learn about and fill out your new plugin’s header, i.e. DocBlock. Then you’ll add in the PHP namespace. We’ll talk about why you want to use namespacing instead of prefixing.
Let’s get you started building custom (from scratch) WordPress plugins. In Part 1 of this series, you are going to build the basics of the Collapsible Content plugin. As you are building it with Tonya, you’ll learn deeply about custom plugin development, file structures, jQuery, PHP, WordPress core, shortcodes, Gulp, and much more.
In this episode, you will continue adding files to your new Genesis developer’s starter theme. You will be adding in the file PHP DocBlocks including the package name. You’ll learn about how to name your packages for the namespacing, which I show as YourCompanyName\ThemeName. Upon the completion of this episode, you will have the baseline theme file/folder architecture completed. This is now the shell of your theme, ready for you to start adding in the code into the appropriate buckets.
In this episode, let’s go into the code and clean everything up. You need to remove the temporary debug code as well as add in the PHP DocBlocks to ensure your code is fully documented. You’ll learn more about why you document your code as part of the code construction.
What is a DocBlock? In this video, I’ll take you to phpDocumentor and discuss what a DocBlock is, as well as why you want to follow this PHP documenting standard. Then you’ll go to the WordPress PHP coding standard for contributing to core. The reasons why you want to learn how to properly document your code using PHP DocBlock are: Human readability – you and anyone else can read your code. You are able to read other people’s code. You know what it requires and what to expect from it when you call that function or method. Code – the […]
WordPress needs the file level PHP DocBlock filled out per its standard header format. In this video, you will enter in each required header metadata, line-by-line, and see what each does.