Pixels Starter Plugin
This is the starter plugin for Pixels website projects that are built on WordPress.
Issues, improvements and these instructions.
Please read the documentation below before using. If things are not clear or you find a mistake, or simply a way to improve the theme, please submit an issue or pull request.
Tools and Technologies
This plugin uses the following:
- Composer for PHP dependencies
- PSR-4 autoloading
To install this plugin the server instance must have the following setup:
- WordPress >= 4.7
- PHP >= 7.1
- Advanced Custom Fields if you use meta fields.
- If you're using options pages, then ACF Pro
To develop this theme you must also have the following:
Hopefully in a future update this will be automated in some way
- Download this repository as a ZIP (don't clone!).
- Drop it into the plugins folder of your WordPress installation and rename the folder to
<client or project name>-plugin.
- Open the theme in your favourite text editor.
pixels-starter-pluginand replace with
<client or project>-pluginthrough the entire theme directory. This should be the same as the theme folder name name from step 2.
ProjectNameand replace with PascalCased name of project through the entire theme directory. This ensures your plugin is using correct PHP namespacing.
composer installin the folder. Even if you don't have Composer dependencies, this will handle Composer autoloading
To start developing do the following:
- Remove the parts you don't need. If you don't have crons, remove Cron files from
/lib. Same with RestAPI
- Insert Custom Post Types, Taxonomies and custom meta in
/lib/Model.php. There are folders / namespaces for each of them with examples. You might want to use examples as base and just replace them.
- Create helpers and services you need. Avoid fat controllers in Rest & Cron. Instead implement Service classes that you can utilize for providing and editing data.
Post Types and Taxonomies
Plugins contains examples on Post Type and Taxonomy creations. Both extend abstract parent classes that do all the heavy lifting.
- For Post Types, use
/lib/Model/PostTypes/Example.phpas starting point.
- For Taxonomies, use
/lib/Model/Taxonomies/ExampleTaxonomy.phpas starting point
Minimal implementation: just replace "Example" with your post type or taxonomy. The classes have couple of options for creating labels:
- Default: just add CPT / Tax slug & name. Labels are automatically generated based on that. Uses Symony Inflector for handling singular / plural forms of name.
- Semimanual: enable constant
TRANSLATE_LABELS, manually insert gettext() wrapped singular and plural names of CPT / Tax. Labels will be geneted in translatable form using these two words.
- Completely manual: use define_labels() method to write all labels by hand. Disable the label checks in constructor.