How to Create Reusable Components for WordPress, Using PHP
Make it WorkPress
0:00 / 0:00
How to Create Reusable Components for WordPress, Using PHP
4 454 просмотра · 4 года назад
Make it WorkPress
340 подписчиков
4 454 просмотра · 4 года назад
If you are developing your own theme or plugin, it is useful to structure anything that is displayed on the front-end as a component.
In this video, I will explain a useful architecture that can be used to develop PHP based components. This architecture is very useful for developing any custom component, such as buttons, post grids, or anything else.
You will learn about:
A proper file and folder structure for your code
Using object oriented programming practices to create modular code
Separate logic from templates
Using modern bundles to bundle your assets (JavaScript and CSS)
00:00 Start
00:29 Prerequisites
01:52 Plugin Setup
03:49 OOP & Autoloading Setup
11:19 The Plugin Main Class
15:27 Autoloading Explained
17:47 The Component Class
31:21 Example Component Class
35:37 The Component Template
37:37 Implementing Components
42:53 Bundling Assets with ESBuild
47:16 Enqueueing Assets
50:26 Conclusion
This video is aimed at plugin and theme developers. You can read the article here: https://makeitwork.press/reusable-com...
The code is also available on Github:
https://github.com/makeitworkpress/wp...
Check me out at:
https://makeitwork.press
Follow me on social media:
Twitter: / makeitworkpress
LinkedIn: / make-it-workpress
Github: https://github.com/makeitworkpress/
My videos may contain affiliate links to fund the time spent on creating, testing and, reviewing. This won't cost you anything extra, but brings me some extra bread to the table.