This task will help you get up to speed on our wordpress theme boilerplate
- Create a developer folder under user
- Download, install & configure Trae, Laravel Herd & TablePlus
- Install the following extensions for Trae/VSCode: Tailwind CSS IntelliSense, Twig Language 2, PHP Intelephense, Auto Close Tag & Auto Rename Tag
-
Clone this theme into your project folder and rename it
git clone https://github.com/StartDigitalAU/boilerroom introductorytask -
Run
composer install -
Create a new database and name it the same as your project
-
Copy the ENV hashes from the Roots website and paste is into your
.envfile -
Visit your site in the browser and complete the installation steps
-
Start the development server by navigating to the wp-content/themes/startdigital theme and running
npm run dev -
Create a new github repository & set the set the remote URL to it
git remote set-url origin https://github.com/StartDigitalAU/introductory-task& verify the new remote URL withgit remote -v -
Push to the new origin
Timber is essentially a templating engine that splits the HTML and display away from the PHP logic & data. Thus, allowing our PHP files to prepare the data to be added to the timber context to be retrieved & outputted in our TWIG files eg. <h1>{{ post.title }}</h1>
- Create the files
template-admin-only.phpin the theme root, andtemplate-admin-only.twigin/templates - In the
template-admin-only.phpensure you have the following to render out the template:
use Timber\Timber;
global $post;
$context = Timber::context();
$timberPost = Timber::get_post($post->ID);
$context['post'] = $timberPost;
// Check if admin & redirect if not logic
$templates = array("template-admin-only.twig");
Timber::render($templates, $context);- In the
template-admin-only.twigensure you have the following to be able to build out the pages using the page builder:
{% extends 'base.twig' %}
{% block content %}
{% for block in post.meta('page_builder') %}
<div data-block="{{ block.acf_fc_layout }}">
{{ include('blocks/' ~ block.acf_fc_layout ~ '.twig', ignore_missing = true) }}
</div>
{% endfor %}
{% endblock %}- Test & ensure it works when logged in & not logged in
-
Install ACF Pro & sync the page builder fields JSON
-
Create a layout within the page builder field group & name it
Image text, be sure to add aWYSIWYG field&image fieldto that layout block -
In
/templates/blockscreate a file calledimage_text.twig, ensuring it matches the name of the layout within the page builder ACF field group -
Within
image_text.twigcreate a simple text image 2-column layout & demonstrate retrieving the text & image within twig by using:
<>
<div>{{ block.name_of_wysiwyg_field }}</div>
<img src="{{ get_image(block.name_of_image_field).src }}" alt="{{ block.name_of_image_field.alt }}" />
</>-
Login to ventraip & navigate to the cpanel for
perth.agency -
Create a new domain eg.
intro.startdigital.com.au, untickShare document rootand change the document root to something simple likeintro -
Login to cloudflare, navigate to the DNS for startdigital.com.au & create an A record that points to the servers IP address, ensure the name is the same as the domain created within cpanel
-
Go in to
MySQL® Databaseswithin cpanel and create a new database, database user & add that user to the database -
Go in to the
File Managerwithin cpanel and find theintrofolder and extract the wordpress core within the folder -
Navigate to the domain eg.
intro.startdigital.com.auand set up wordpress as per normal -
Install the plugin WP Migrate on both the local site and development site
-
Click Migrate, Find & Replace 'http://' with 'https://'
-
Select all besides themes and migrate across
-
Edit the
deploy.yamlWithin your.github/workflows, by changing the server-dir to the domain document root we created before egintro/ -
Within ventraip click manage on the
perth.agencyand find the username and password, enter the username in to thedeploy.yamland then in the girhub repo, go to settings > Secrets & Variables > Repository Secret & create aDEV_FTP_PASSsecret containing the ftps password -
Push the changes to github and monitor the action to see if it built on the server