It’s time to write the code to turn on the editor in the back-end for the Posts Page. You’ll walk through the steps, step-by-step, and discuss how to write the code.
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Convert the Basic WordPress Plugin into a Blog Intro Plugin
Let’s convert the basic plugin you built in Let’s Build a Basic WordPress Plugin lab into a new custom plugin called Blog Intro.
Plugin Architecture
Let’s talk about the architecture and intent. While you could build a home.php or page_blog.php template, this plugin is portable and modular. It allows you to move it from project-to-project without having to change the theme. It uses the built-in WordPress editor, which your client is used to using. We are not using a widget because widgets are cumbersome for clients. A widget does not have the editor interface. It’s not as intuitive for the site owner to figure out where to put content when you use widgets instead of the page itself.
Let’s Build a Blog Intro Custom Plugin
Out-of-the-box WordPress does not provide a way to introduce the Posts Page (Blog), as the editor is turned off and there is no automatic rendering of the content before the posts. In this lab, you will build a Blog Intro real-world, custom plugin which provides an introduction or welcome feature for your clients. As you build this plugin, you are learning about fetching content from the database, sanitizing, the Genesis framework, views, and more.
Wrap it Up
Congratulations! You just built a custom real-world WordPress plugin. You did from scratch. While you can use this plugin for all of your projects and even extend it, this lab gave you so much more. You learned some of these valuable coding knowledge: Custom plugin – writing it from scratch Unregister callbacks Investigate a theme Genesis Sanitizing Views Database Clean code Software principles All of these, especially the last two, are essential to you as a software developer. This lab gave you knowledge and skills that you will use in everything you do. It is adaptable then to all of […]
Master Tip: How Did I Know to Use after_theme_setup
?
Let’s talk about how I knew to use after_setup_theme. You will look at in WordPress Core.
Remove Genesis Page Title
In this episode, you will unregister the Genesis page title. Remember, you need to unregister it after it has been registered. Huh, what does that mean? It means after the theme is called. In this episode, you will learn about how to unregister callbacks and the WordPress event after_setup_theme. WordPress Events (Hooks) Psst, events, unregistering, and registering is fuzzy for you, make sure you take the Introduction & Registering Events hands-on lab. [/infoxbox]
Master Tip: Why Use a View?
Let’s talk about why you want to not intermingle your business logic with the HTML. Why do you use a view? It’s based upon the proven software principles such as Separation of Concerns and Single Responsibility. APIs, frameworks, tools, and apps come and go. But these principles remain. More importantly you will learn about intent. Intent is important in all of the code that you will ever build.
Building the HTML View File
It’s time to build out the HTML structure and put it into the view. What is a view? Why do you want to use it? Let’s talk about the qualities of clean, quality code. You will also learn about how to load the view as well as the variable scope. To learn more about variable scope and including files, go to the PHP Variables Bootcamp.
Prepare the Contents for the Browser
Let’s finish preparing the content for rendering out to the browser. How about if there are shortcodes in the code? How do we process those? How about using auto-formatting the paragraph HTML elements? In this episode, you will add in the do_shortcode and then wpautop.