Created
November 16, 2025 02:23
-
-
Save BluePraise/8dcb8b6de4b9aa54f5d3a3c34dc348a7 to your computer and use it in GitHub Desktop.
WordPress Local Development Symlink Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| # WordPress Local Development Symlink Helper | |
| # | |
| # This script automates the process of: | |
| # 1. Creating project folder structure | |
| # 2. Cloning WordPress themes/plugins from GitHub | |
| # 3. Creating symlinks to Local by Flywheel installations | |
| # | |
| # CONFIGURATION REQUIRED: | |
| # Update the following variables to match your setup: | |
| # Your GitHub username (line 48) | |
| GITHUB_USERNAME="your-github-username" | |
| # Your projects folder path (line 26, 51, 53) | |
| # Default: ~/Projects | |
| # Change if you keep projects elsewhere | |
| # Your Local by Flywheel path (line 54) | |
| # Default: ~/Local Sites | |
| # Change if Local uses a different location | |
| # Function to symlink WordPress projects to Local by Flywheel | |
| wplink() { | |
| echo "π WordPress Project Symlink Helper" | |
| echo "==================================\n" | |
| # Get project name | |
| echo "What is the project name?" | |
| read project_name | |
| if [[ -z "$project_name" ]]; then | |
| echo "β Project name cannot be empty" | |
| return 1 | |
| fi | |
| # Create project folder if it doesn't exist | |
| # CUSTOMIZE: Change ~/Projects to your projects folder path | |
| project_base="$HOME/Projects/$project_name" | |
| if [[ ! -d "$project_base" ]]; then | |
| echo "π Creating project folder: $project_base" | |
| mkdir -p "$project_base" | |
| else | |
| echo "β Project folder exists: $project_base" | |
| fi | |
| # Get project type | |
| echo "\nIs this:" | |
| echo " 1. A theme" | |
| echo " 2. A plugin" | |
| read -k 1 project_type | |
| echo "\n" | |
| case $project_type in | |
| 1) | |
| type_folder="theme" | |
| local_subfolder="themes" | |
| ;; | |
| 2) | |
| type_folder="plugin" | |
| local_subfolder="plugins" | |
| ;; | |
| *) | |
| echo "β Invalid selection. Please choose 1 or 2" | |
| return 1 | |
| ;; | |
| esac | |
| # Create theme or plugin folder if it doesn't exist | |
| type_base="$project_base/$type_folder" | |
| if [[ ! -d "$type_base" ]]; then | |
| echo "π Creating $type_folder folder: $type_base" | |
| mkdir -p "$type_base" | |
| else | |
| echo "β $type_folder folder exists: $type_base" | |
| fi | |
| # Get repo name | |
| echo "\nWhat is the name of the repo in GitHub?" | |
| read repo_name | |
| if [[ -z "$repo_name" ]]; then | |
| echo "β Repo name cannot be empty" | |
| return 1 | |
| fi | |
| # Build GitHub URL | |
| # CUSTOMIZE: Change GITHUB_USERNAME to your GitHub username | |
| repo_url="[email protected]:${GITHUB_USERNAME}/${repo_name}.git" | |
| # Build paths | |
| # CUSTOMIZE: Change ~/Projects if you use a different projects folder | |
| source_path="$type_base/$repo_name" | |
| # CUSTOMIZE: Change ~/Local Sites if Local by Flywheel uses a different path | |
| local_path="$HOME/Local Sites/$project_name/app/public/wp-content/$local_subfolder/$repo_name" | |
| # Check if repo already exists | |
| if [[ -d "$source_path" ]]; then | |
| echo "\nβ Repo already exists at: $source_path" | |
| else | |
| # Clone the repo | |
| echo "\nπ¦ Cloning repository from: $repo_url" | |
| echo " Into: $type_base" | |
| cd "$type_base" | |
| git clone "$repo_url" "$repo_name" | |
| if [[ $? -eq 0 ]]; then | |
| echo "β Repository cloned successfully!" | |
| else | |
| echo "β Failed to clone repository" | |
| echo " Make sure the repo exists at: $repo_url" | |
| return 1 | |
| fi | |
| fi | |
| # Check if Local site exists | |
| if [[ ! -d "$HOME/Local Sites/$project_name" ]]; then | |
| echo "β οΈ Warning: Local site '$project_name' not found" | |
| echo " Make sure the Local site name matches exactly: $project_name" | |
| fi | |
| # Show the command that will be executed | |
| echo "\nπ This command will be executed:" | |
| echo " ln -s \"$source_path\" \"$local_path\"" | |
| echo "\nβ Create this symlink? (y/n)" | |
| read -k 1 confirm | |
| echo "\n" | |
| if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then | |
| # Create the parent directory if it doesn't exist | |
| mkdir -p "$(dirname "$local_path")" | |
| # Create the symlink | |
| ln -s "$source_path" "$local_path" | |
| if [[ $? -eq 0 ]]; then | |
| echo "β¨ Symlink created successfully!" | |
| echo "\nSource: $source_path" | |
| echo "Link: $local_path" | |
| else | |
| echo "β Failed to create symlink" | |
| return 1 | |
| fi | |
| else | |
| echo "β Cancelled" | |
| return 0 | |
| fi | |
| } | |
| # Make the function available | |
| wplink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment