Walker Sands Base Wordpress Theme (ws)
- Install NPM/Node and Docker
- In a terminal in the root of the application, run
docker-compose pullto get the latest docker images. - Start the docker containers
docker-compose up -d- If there are docker containers already running, then run the command
docker stop $(docker ps -aq) && docker container prune -f && docker network prune -ffirst to kill all containers regardless of your location in the terminal. Save this command as an alias to save yourself time in the future.
- If there are docker containers already running, then run the command
- Install dependencies
npm install - Install WordPress and populate new install with placeholder data
sh init.sh "SITE_NAME" "USER_NAME" "EMAIL" "PASSWORD" - Start the development task to start building files and watch for changes
npm run dev- Site should now be available at localhost
- If you get an error that certain files are not known to Docker, confirm that your folder is listed as a directory or subdirectory of the "File Sharing" section of Docker preferences.
- If you get an error that ports are already being used, make sure your native apache and/or mysql is not running by using this command
sudo apachectl stop && sudo service mysqld stop - Make sure you don't have any overlapping Docker containers running. This can be checked with
docker ps - If you need to access the bash shell of the wordpress docker container, use command
docker exec -ti CONTAINER_NAME bash - If you want to change the project folder name, but don't want to lose any work that you've already done (because changing the project folder name will create new docker containers/volumes), use the command
docker-compose -p OLD_FOLDER_NAME up -dto reference the old containers/volumes. - To see the php error logs, use this command
docker logs -f CONTAINER_NAME >/dev/null - Do not run
docker prune. It does not do what you think it does.
You can use Bitbucket Pipelines to build and deploy the theme when a new commit is pushed to the repository. If the site is hosted on WP Engine we can use rsync to transfer files.
- Start a new project with a clone of the Walker Sands Base
git clone [email protected]:walkersandsdigital/walkersands_base_wp-theme.git FOLDER_NAMEcd FOLDER_NAMErm -r .gitgit init
- Create new Bitbucket repo
- Owner: Walker Sands Digital
- Project: Clients
- Setup Pipelines
- Enable Pipelines
- Generate SSH key
- Fetch and add the WP Engine SSH host name as a known host (ENV_NAME.ssh.wpengine.net)
- Update "Deployments" to these 3 environments: Development, Staging, Production
- Add the following secured repository variables to each deployment: SSH_USER, SSH_HOST
- Add newly generated Bitbucket SSH public key to the WP Engine account (not to the "git push" options)
- Make first commit to master
git add .git commit -m 'First commit'git remote add origin [email protected]:walkersandsdigital/REPO_NAME.gitgit push -u origin master
- Run pipeline in Bitbucket to deploy to WP Engine (may have to wait a couple minutes for WP Engine to add SSH key)
If the client is on a host other than WP Engine, try to setup the ssh/rsync first. If it is not available/possible, use this SFTP fallback.
- Copy Walker Sands Base and start new project
git clone [email protected]:walkersandsdigital/walkersands_base_wp-theme.git FOLDER_NAMEcd FOLDER_NAMErm -r .gitgit init
- Create new Bitbucket repo
- Owner: Walker Sands Digital
- Project: Clients
- Setup Pipelines
- Enable Pipelines
- Fetch and add the SFTP hostname with port number as a known host (HOSTNAME:PORT)
- Update "Deployments" to these 3 environments: Development, Staging, Production
- Add the following secured repository variables to each deployment: SFTP_HOST, SFTP_PORT, SFTP_PATH, SFTP_USER, SFTP_PASSWORD
- Path should be the remote path to the ws theme directory. May have to create the ws folder first before deploying.
- Modify
bitbucket-pipelines.ymlto utilize the commented code correctly
- Make first commit to master
git add .git commit -m 'First commit'git remote add origin [email protected]:walkersandsdigital/REPO_NAME.gitgit push -u origin master
- Run pipeline in Bitbucket to deploy to WP Engine (may have to wait a couple minutes for WP Engine to add SSH key)
If the client requires the theme repository be GitHub, you can use these steps to setup GitHub Actions, which is the GitHub equivalent of Bitbucket Pipelines.
- Start a new project with a clone of the Walker Sands Base
git clone [email protected]:walkersandsdigital/walkersands_base_wp-theme.git FOLDER_NAMEcd FOLDER_NAMErm -r .gitgit init
- Generate a SSH key pair
- Run
ssh-keygenand save the key pair. After we put both private and public keys into GitHub and WP Engine (respectively), you can delete the key pair from your machine.
- Run
- Setup GitHub
- Create new GitHub repo
- Add the private key that we generated earlier as a secret named PRIVATE_KEY
- Add the following relevant secret variables: STAG_SSH_USER, STAG_SSH_HOST, PROD_SSH_USER, PROD_SSH_HOST
- Add the public key that we generated earlier to the WP Engine account (not to the "git push" options)
- Make first commit to master
git add .git commit -m 'First commit'git remote add origin [email protected]:REPO_NAME.gitgit push -u origin master
- Run the Action in GitHub to deploy to WP Engine (may have to wait a couple minutes for WP Engine to add SSH key)
For all of these steps, I would recommend either duplicating an existing block or at least referencing one when creating a new block.
- Create a folder in the blocks directory.
- Create a block.json file with appropriate fields.
- Create an admin.tsx file with how the block should render in the editor.
- Create a render.php file with how the block should render on the frontend.
- Create a front.css and/or admin.css for styles. Ideally, the editor and frontend blocks should have the same structure, so we load front.css on both sides. However, if additional styles are needed for the editor, they can be included in the admin.css file. The admin.css file is optional.
- If the block requires javascript functionality on the frontend, you can include a front.ts file. Both the front.ts and front.css file will only be loaded if the block is present on the page.
- Add the export to /ws/blocks/index.ts
- If your dev npm script is already running, you may need to restart it.
- To add styles to existing blocks, add a folder to the blocks directory with the name of the block, and then add a front.css file to that folder. Some are already included in the theme.
- To remove a core block, add it to the list in the theme.json file.
- assets: Static images and fonts used by the theme
- blocks: Theme's block library
- inc: PHP files that don't fit anywhere else
- languages: Multilingual files (not used)
- parts: Single views, archive views, and password protected page layout
- post-types: Register post types and any logic related to them
- src: All source JavaScript and CSS files
- src/js/admin/components: Theme React component library
- src/js/admin/filters: Filters for modifying core functionality
- src/js/admin/formats: Inline text formats
- src/js/admin/hooks: Custom React hooks
- src/js/admin/options: JSX for option pages
- src/js/admin/plugins: Modify core functionality sections (sidebar)
- src/js/admin/stores: Custom Redux stores
- src/js/admin/styles: Register and unregister core block styles