Let’s go into WordPress Core to understand if we can use get_post to sanitize fields when in display filter mode. You will reverse engineer Core to discover for yourself. You will use has_filter to see if there is a filter event that does the sanitizing for the data post_content. You’ll also learn about foreach.
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.
Sanitize with
Sanitize the Contents
Anything out of the database is not safe. It has to be sanitized before it is rendered out to the browser. Let’s talk about how to sanitize and which sanitizing function to use for the plugin. In this episode, you will see some nefarious code in action. Then you’ll try out two different sanitizing functions: esc_html wp_kses_post
Let’s Look in Core at get_post
– Part 2
This episode continues reverse engineering get_post in WordPress Core. Now that you understand the database, or at least have a basic understanding of it and SQL, you will continue looking at get_post. You’ll see how each column in the database populates a property in the object that you get back when calling this function.
Let’s Look in Core at get_post
– Part 1
Let’s go deeper and head into Core to look at get_post. This function is going to either pull the post content from the database or cache. In this episode, you will learn about both and reverse engineer the function to discover when it’s pulling from one or the other. As the function is dealing with the database, it’s time to teach you some SQL. You will play around with the database to see how to pull records. I use Sequel Pro, but you can use phpMyAdmin to do the same exploring of the database. Here are additional resources about PHP […]
Refactor Getting the Posts Page
Let’s refactor how you are getting the posts page object by abstracting it into a separate, reusable function. Then you’ll add in protection to ensure an object is received back from the database before continuing the processing. You will be learning about clean, quality code in this episode too. You will learn about the Falsey Conditional Expression.
Let’s Look in Core at is_home
Let’s go into WordPress Core and talk about how is_home() works. You will also learn about objects and OOP in this episode, as is_home() is a wrapper around the instance of WP_Query. You can also see this hands-on lab to learn the differences between is_home and is_front_page:
How to Ensure It’s Posts Page?
You only want the contents to display (render) on the Posts Page and that’s it. In this episode, you’ll learn how to ensure you are on that page. If no, then return early and stop processing; else continue with the rendering. You will learn about clean, quality code too. You will learn about is_home.
Render (Display) the Contents
Let’s get the contents out of the database and then display (render) it onto the page in the browser. You’ll walk step-by-step through the process. You will learn about get_post.
Genesis Before Loop Event genesis_before_loop
From the previous episodes, you identified genesis_before_loop as the event you need to register your callback in the plugin in order to render out the content into the right spot on the page. Let’s talk about this event. In this episode, you’ll walk through the basic structure of Genesis, looking at the function genesis(). You will also look at the Loop in Genesis in order to gain a general understanding of where this event places your content into the HTML structure.
Genesis Posts Page Archive
Let’s dive deeper into the Genesis framework by StudioPress. You will learn about: the posts page archive rendering Genesis markup and genesis_attr – overview and intent HTML attributes