Last active
March 30, 2023 18:59
-
-
Save devwax/6777216d165db91c52afbcfb4379873c to your computer and use it in GitHub Desktop.
WordPress Snippets
This file contains 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
<?php | |
// Frontend memory limit | |
define('WP_MEMORY_LIMIT', '64M'); // Default for WooCommerce: https://github.com/WordPress/WordPress/blob/master/wp-includes/default-constants.php#L50 | |
// /wp-admin/ memory limit | |
define('WP_MAX_MEMORY_LIMIT', '256M'); // Default: https://github.com/WordPress/WordPress/blob/master/wp-includes/default-constants.php#L62 | |
// WordPress memory limits deep dive: https://www.saotn.org/increase-wordpress-memory-limit-wp-config-php/ | |
// Force WordPress to use requested domain as SITEURL and HOME overriding wp_options | |
@define('SP_REQUEST_URL', ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']); | |
define('WP_SITEURL', SP_REQUEST_URL); | |
define('WP_HOME', SP_REQUEST_URL); | |
define('WP_DEBUG', false); | |
define('WP_DEBUG_LOG', false); | |
@ini_set( 'display_errors', 0 ); | |
/** | |
System Cron instead of WP Cron | |
wp-config.php | |
define('DISABLE_WP_CRON', true); | |
Server Crontab | |
*/5 * * * * wget -q -O - 'https://yourdomain.com/wp-cron.php?doing_wp_cron' >/dev/null 2>&1 | |
*/ | |
/** | |
.htaccess | |
# ------------------------------------------------------ | |
# Block all IP addresses exept defined list of IPs | |
# Place or update .htaccess in root directory. | |
order deny,allow | |
deny from all | |
allow from 123.456.789.100 | |
allow from 127.0.0.1 | |
# ------------------------------------------------------ | |
# ------------------------------------------------------ | |
# Domain masking /wp-content/uploads/ | |
# Add to .htaccess in /wp-content/uploads/ directory. | |
# Troubleshooting: | |
# - Make sure the file is in the "/wp-content/uploads" directory. | |
# - Make sure the redirect URL is correct (subdomains, protocol, etc... copy it to be sure.) | |
# Attempt to load files from production if they're not in our non-prod version | |
<IfModule mod_rewrite.c> | |
Options +FollowSymLinks | |
RewriteEngine on | |
# RewriteOptions Inherit | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule (.*) https://original-domain.com/wp-content/uploads/$1 | |
</IfModule> | |
# ------------------------------------------------------ | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment