This project is based on Themosis framework and customized by Webikon. It is used to jump start working on the project without the need to setup all necessary things over and over again.
Steps below are only quick guide how to start working with the project, for additional Themosis documentation please look here.
This starter project includes:
- Themosis core
- Predefined set of plugins
- Theme with predefined files structure, Bootstrap, Laravel Mix, etc.
- Linters config files - PHPCS, ESLint, SASS-Lint, .editor-config
- GrumPHP
- BladeSVG Provider
- Basic Controllers examples
- Basic routing examples
- Basic Models examples
- Basic Admin Pages, Metaboxes and Gutenberg Blocks registration examples (Metabox.io)
- Basic CPTs and Taxonomies registration examples
- Global data passing example
- ...
- Download repo:
git clone https://gitlab.com/webikon/internal/themosis-starter-project my-project-name
wheremy-project-name
is directory name where repo would be downloaded. - Run
composer install
in project root to download all dependencies including WP and plugins. - Configure your
.env
file. (When it is missing, you can duplicate it from.env.sample
file) - When project is already configured and initialized, skip to next step. Otherwise see section How to initialize project
- Run
npm install
in theme to download frontend dependencies.
How to initialize project
- Configure global variables like WP Salts, APP_NAME, APP_TD, WP_DEFAULT_THEME, etc.
- Replace all strings
'themosis-starter-project'
(including apostrophes) with project slug. - Replace all strings
Themosis Starter Project
with project name. - Rename theme and replace all strings
'themosis-starter-theme'
andthemosis-starter-theme
with theme slug.
No application encryption key has been specified.
- To fix this, you need to generate APP_KEY with php console key:generate --ansi
command and make sure your .env
file is updated.
Key should look like this base64:Bq7CN4nOW0+TTwbx59jPnuHILi47nymagcQtg2WiEZk=
For more info go to https://framework.themosis.com/docs/2.0/structure/.
Below, there are short explanations of the most important folders and our customizations.
Stores all our classes in order to extend or customize our application.
https://framework.themosis.com/docs/2.0/hooks/
This is where we extend WP functionality.
E.g. register CPTs, Taxonomies, Admin Pages, Widgets, pass Global data, etc.
Name new CPT & Taxonomy file in singular, e.g. Book.php, Product.php, Project.php.
Don't forget to add register new class in config/app.php
This is where all custom fields registration take place.
There should be different subfolders. Also add suffix based on where we are adding those custom fields.
E.g. CPT (Custom Post Type), TAX (Taxonomy), TMP (Custom Template), AP (Admin Page).
We also register Gutenberg blocks in app/Hooks/Metaboxes/Blocks
.
Add suffix Block to each file for better file recognition.
Also don't forget to register new classes in config/app.php
.
https://framework.themosis.com/docs/2.0/controllers/
This is where we add all our controllers.
We are not necessarily following WP Template Hierarchy and we can add more "high level" controllers and group related views together e.g. like BlogController, which can be controlling Blog page (Archive), Single Post and Search.
Data shouldn't be manipulated here. If we need to manipulate data, we should use or create helper in theme's inc/helpers
folder.
This will keep our controllers clean and move bussiness logic outside - this also means, that we would be more ready to transition into using Models or "Services" (similar to helpers) classes.
As mentioned before, we need to register all custom Hookable classes here.
This is where all routes are defined.
Register new image sizes, menus, sidebars, custom templates, etc. here.
This is main folder for extending and adding more functionality to WP.
Each functionality block should be in separate file or subfolder for better readability.
Simple rules to add functionality:
-
Single file - If there is simple functionality, which can be added to one file - put it into
inc/
root.
E.g.favorites.php
,pagination.php
,wp-query-hooks.php
, ... -
Subfolder - If there is more complex functionality, which requires more than one file, or we can group two functionalities into one group - put it into
inc/subfolder
.
E.g.wc-dpd-export/wc-dpd-countries.php
,wc-dpd-export/wc-dpd-export.php
, ...
If using WC, create subfolder namedwoocommerce
and each file in this folder should be prefixed withwc-
for better file recognition. -
Separate plugin - If there is really complex functionality, which we can reuse on other projects and/or possibly sell - put this functionality in custom WP plugin.
E.g.woocommerce-wholesale
,woocommerce-product-bundles
, etc.
If you are not sure, what type particular functionality is and it is not specified in technical specification, consult with your teammate.
Important: All these files should be namespaced App/Theme
.
The Themosis framework is open-source software licensed under GPL-2+ license.