Skip to content

Instantly share code, notes, and snippets.

@wbeem
wbeem / .gitignore
Created May 6, 2025 17:07
A .gitignore file for WordPress projects using environment variables. Excludes config files, secrets, logs, OS clutter, IDE files, cache, and build artifacts from version control.
# WordPress Core
wp-config.php
wp-config-local.php
.htaccess
web.config
license.txt
readme.html
# Environment Variables
.env
@wbeem
wbeem / .env.example
Created May 6, 2025 17:04
Example environment variable file for WordPress. Used with wp-config.php to securely set database credentials, site URLs, and secret keys without hardcoding sensitive data into your codebase.
############################################################
# .env.example – WordPress Environment Configuration
#
# Rename this to `.env` and fill in your values.
# NEVER commit your `.env` file to version control.
#
# Used by wp-config.php to securely inject config data.
############################################################
# --------------------------------------------------------
@wbeem
wbeem / wp-config.php
Last active May 6, 2025 17:01
A secure, modern wp-config.php for WordPress using environment variables. Supports multiple environments, disables risky features, and optimizes performance for production-ready deployments.
<?php
/** ------------------------------------------------------------
* WordPress Configuration File
* Secure, flexible, and environment-aware
* ------------------------------------------------------------ */
/** MySQL Settings */
define( 'DB_NAME', getenv('DB_NAME') ?: 'database_name_here' );
define( 'DB_USER', getenv('DB_USER') ?: 'username_here' );