morethemesbaby / wp-best-practices

WordPress best practices - Boilerplate code for WordPress plugins and themes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WordPress best practices

Boilerplate code for WordPress plugins and themes based on best practices.

What's inside

  1. A WordPress.org compatible theme: Mo Theme.
  2. A WordPress.org 'compatible' plugin: Mo Plugin.
  3. A child theme using the plugin: Mo Pro Theme.

How it works

  • Mo Theme simply displays posts and comments as required by the WordPress.org theme store without styling.
  • Mo Plugin adds a custom post type together with a shortcode.
  • Mo Pro Theme extends Mo Theme and uses Mo Plugin:
    • Displays the shortcode added by the Mo Plugin.
    • Extends the homepage from Mo Theme by adding a sidebar.
    • Displays a widget in the sidebar with custom post types added by the Mo Plugin.
    • Displays a settings menu in the admin dashboard where all the above features can be disabled or enabled.

Why another boilerplate?

The answer is two fold.

There is no official alternative

WordPress has no such thing like this. They provide boilerplate for themes only. There is no boilerplate for plugins, child themes, and how to integrate them.

And, the WordPress boilerplate theme is not class based, in contrast with their recommendation in the Theme Developer Handbook.

Others perhaps have such a combo or maybe not. One of the best WordPress agencies 10up has nothing like this in their public Github repository.

Even if other shops have it, or have parts of it — finding, learning, mixing it into a whole might be more time consuming than this learning by doing approach.

Components

Components are a web development best practice (see Google Material Design) not yet adapted by WordPress.

More Theme Baby has an award winning framework-agnostic component set which should work with WordPress too when WordPress follows the component model.

Best practices

  • Default WordPress files organization
  • Class based namespaces
  • Components
  • Loose coupling
  • Single responsibility principle
  • Optimized database operations
  • Documentation
  • Testing (Work in progress)

For details please check each theme's and the plugin's README.md.

Inspiration

Change log

See CHANGELOG.md.

About

WordPress best practices - Boilerplate code for WordPress plugins and themes

License:GNU General Public License v3.0


Languages

Language:PHP 85.3%Language:CSS 14.3%Language:JavaScript 0.4%