Working on each plugin I always want to create a simpler and clean folders and files structure which everyone can understand in just one glance. It’s a main goal for all developers — creating simply and reusable code which doing some amazing work inside your products. Isn’t it?
I’ve been going a long way in attempts to create a solid files structure which perfect fits for every product I’m working on. It’s a good idea to write just a simply fancy code in single project. Even better to write a code using certain standards.
Unfortunately now WordPress doesn’t have established recommendations for plugins structure. The themes have a better equipment. Usually the themes shouldn’t have any hardcoded logic. I think that themes should be just a templates which defines a views, not a business logic or something. Or maybe not. Every single product have different purposes and environment. I don’t think that this world have just a one single solution which is right.
Now we have many plugins with absolutely different files structure. And understanding the logic of that plugin is like the conquest of Everest. 🙂
In my projects I have come to the conclusion that a folder called
wp-admin is the best name for the folder with files which relates to WordPress wp-admin pages (admin screens). But it’s not the best name for this type of folder.
After running a
wp core verify-checksums I was surpised with output in console.
wp core verify-checksums ... Warning: File should not exist: wp-content/plugins/setka-editor/twig-templates/wp-admin/settings/auth/token.html.twig Warning: File should not exist: wp-content/plugins/setka-editor/twig-templates/wp-admin/settings/common/checkboxes-in-fieldset.html.twig Warning: File should not exist: wp-content/plugins/setka-editor/twig-templates/wp-admin/settings/common/template.html.twig Success: WordPress install verifies against checksums.
Ow! It looked not as I expected. In trying to understand and explain this behaviour I’m stuck in WP-CLI source code. And the answer in
Core_Command->get_wp_core_files(). So I’ve just renamed my folder from
Also be avoid name your folders as
wp-includes or any other WordPress “reserved” names. Other products may confused with this names.
P. S. It seems that I need more to write about plugin structure in next posts.