Here are the steps that should be performed when initializing a new WordPress project.
- Clone the starter repository:
git clone [email protected]:pragmatedev/vilare.git vilare.com - Prepare the local environment:
- Create local server with PHP 8.4 and MySQL 8.4.
- Create a new database for the project:
vilare.com - Assign a new domain to the project with SSL:
https://vilare.test
- In the terminal, go to the project root and run
./init.sh.
🎥 https://youtu.be/38ppFXgkIRk
Here are the steps that should be performed when initializing an ongoing WordPress project.
- Clone the project repository:
git clone [email protected]:pragmatedev/vilare.com.git - Prepare the local environment:
- Create local server with PHP 8.4 and MySQL 8.4.
- Create a new database for the project:
vilare.com - Assign a new domain to the project with SSL:
https://vilare.test
- In the terminal, go to the project root and run
./init.sh. - Download the
wp-content/uploadsto your local environment from the remote.
🎥 https://youtu.be/BP8Aw5ZMn1A
The project uses Vite as a bundler and development server with HMR and Hot Reload features.
yarn dev- Starts the development server [🔗].yarn build- Builds theme assets in production mode [🔗] [🔗].yarn lint- Checks codebase for meeting defined coding standards.yarn format- Formats codebase to meet defined coding standards.yarn translate- Generateslang.potfile in the theme resources.yarn vilare- Runs theme CLI tools.
The project uses vilare CLI tool to enhance development operations.
yarn vilare --help- Displays help for a CLI tool.yarn vilare database- Manages database operations.yarn vilare component- Manages components operations.yarn vilare test- Manages testing operations.yarn vilare release- Creates production package.yarn vilare deploy- Deploys release package.
🎥 https://youtu.be/1CXuoyRYb98
- The project uses Object Oriented approach.
- The project uses Singleton for managing modules.
- The project uses DocHooks syntax for handling filters and actions.
- The project uses Laravel Blade for creating components HTML structure.
- The project uses Alpine JS for creating user interactions.
- The project uses SASS for creating user interfaces.
- The project defines coding standards for PHP, SCSS, JS that must be met.
- The project uses Gutenberg to build the visual layer with ACF Blocks.
- The project should limit plugins usage as much as possible.
- The project should split the responsibilities as much as possible.
- The project uses GitFlow as a branching workflow.
- Server details, passwords and other sensitive data are stored in 1Password.
- Single components should be developed on the /playground/ template.
- Before approaching Pull Requests, Lighthouse tests should be performed using the
yarn vilare test psicommand, which checks the/playground/page with component and highlights any issues. Any problems directly related to the component must be addressed before proceeding to the next steps. - After approving Pull Requests, the staging server should be updated, and the new block should be added to the /demo/ template that lists all the custom blocks, allowing the team to access them in one place.
- Each
featurebranch must be merged todevelopbranch only via the Pull Request. - Each Pull Request must meet the following requirements before merging:
- It must pass the coding standard checks defined in Github Actions / Bitbucket Pipelines.
- It should include Toggl, Basecamp, Preview links in the description.
- It should include screenshots from Lighthouse tests performed by
yarn vilare test psicommand.- There should be not not any accessibility issues related to the specific feature.
- There should be not not any performance issues related to the specific feature.
- It should have at least one approval from the project leader.
- Pull requests must be assigned for review only when all the previous requirements are met.
- After approving pull request by the project leader, developer takes care of the merging process.
The project is created using a component-driven approach. It consists of components, blocks, and templates. Although each of them serve different role they share a similar style.
Components are the smallest units used to build websites supported by Laravel Blade. They are available throughout the website and should include only the most basic functionalities to maintain simplicity.
- Creation:
yarn vilare component create --type=component --id=button - Usage:
<x-button />
Blocks are larger units integrated with ACF and Gutenberg, used to define the layout of the website. They can include more complex functionalities and utilize granular components. When possible, blocks should use InnerBlocks to provide flexibility for clients and should utilize container queries instead of traditional media queries.
- Creation:
yarn vilare component create --type=block --id=newsletter - Usage:
{!! block('newsletter')->render(['title' => 'custom title']) !!}
Templates are the largest components. Those defined in the theme are automatically resolved and rendered by WordPress.
- Creation:
yarn vilare component create --type=template --id=article - Usage: Choose page template from WordPress admin panel.
- Block Structure:
- Controller: Used for defining the block schema, default data and any backend mechanisms.
- Template: Used for displaying the data that has been defined in the block.
- Scripts: Used for defining user interactivity.
- Styles: Used for defining visual layer.
- ACF Fields: Block fields saved with Local JSON implementing block schema for Gutenberg.
- Block Creation
- Use the
yarn vilare component create --type=block --id=newslettercommand in the theme's root. The command will create a new block and automatically load it into the system. You might need to restart your development server. - Define the block schema and fill it with the default values when needed. Block schema uses the Laravel Validation component, but if you're not familiar with this yet, please at least define the simplest typing schema to check if the passed is a string, array, boolean, or required.
- Go to the ACF Field Groups, clone the
Block: Basegroup, and adjust to the newly created block while keeping the same naming conventions. The field naming and validation rules should reflect the ones defined in the schema.
- Use the
- Block Rendering
- Use the
{!! block('newsletter')->render(['title' => 'custom title']) !!}function in Blade templates. To fill the block with values, pass the data array to therenderfunction based on the defined schema. - Choose the block in the Gutenberg and fill with the data.
- Use the