Skip to content

Commit

Permalink
Boot Enhancements (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luehrsen authored Oct 10, 2023
1 parent f48aec2 commit 75dec54
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"plugins": [
"./plugin"
],
"phpVersion": "8.1",
"mappings": {
"php.ini": "./bin/php.ini"
"./../.htaccess": "./htaccess.txt",
"lifecycleScripts": "./bin/lifecycleScripts/",
"wp-cli.yml": "./wp-cli.yml",
"required-plugins": "./required-plugins/"
},
"env": {
"development": {
Expand Down
47 changes: 47 additions & 0 deletions bin/lifecycleScripts/initialize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# This script is used to initialize the WordPress system. WP-CLI is available.
# We use it to install plugins, themes and set options as needed.

# Check if WordPress is installed, if not, exit.
if ! $(wp core is-installed); then
echo "WordPress is not installed. Exiting."
exit 1
fi

# Check if this is a clean install, if not, exit.
# We check this by looking for a set option. If it's not set, it will throw an error.
if wp option get lh_is_installed; then
echo "This is not a clean install. Exiting."
exit 1
fi

# Set the option to indicate that this is a clean install.
wp option set lh_is_installed true

# Set the permalink structure.
echo "----- Setting permalink structure."
wp rewrite structure '/%postname%/' --hard

## Remove all plugins.
echo "----- Removing unwanted plugins."
wp plugin delete --all --exclude=plugin

## Install plugins.
echo "----- Installing plugins."

# From the WordPress plugin repository.
wp plugin install wordpress-seo wordpress-importer --activate

# From a local file.
# wp plugin install ./required-plugins/advanced-custom-fields-pro.zip ./required-plugins/gravityforms.zip --activate

# Activate the theme we want to use.
echo "----- Activating working theme."
wp theme activate theme

## Import Demo Content.
echo "----- Importing demo content."

wget https://raw.githubusercontent.com/WPTT/theme-unit-test/master/themeunittestdata.wordpress.xml
wp import themeunittestdata.wordpress.xml --authors=create
3 changes: 0 additions & 3 deletions bin/php.ini

This file was deleted.

3 changes: 3 additions & 0 deletions htaccess.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
php_value post_max_size 2G
php_value upload_max_filesize 2G
php_value memory_limit 2G
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"stop": "npx wp-env stop",
"watch": "webpack --watch",
"env:clean": "npx wp-env clean all",
"env:init": "npx wp-env run cli sh ./lifecycleScripts/initialize.sh",
"env:reset": "npm run env:clean && npm run env:init",
"update:schemas": "node bin/updateThemeJsonSchema.js",
"update:versions": "node bin/updatePluginVersion.js && node bin/updateThemeVersion.js",
"lint:php": "composer run lint",
Expand Down
Empty file added required-plugins/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions wp-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apache_modules:
- mod_rewrite

0 comments on commit 75dec54

Please sign in to comment.