From 1b926be3ff987875ef128268a6deed1cd8a6968e Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 7 Nov 2025 18:03:58 -0500 Subject: [PATCH] Improve DISABLE_WP_CRON placement in wp-config.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Modified disable_wpcron_in_config() to place DISABLE_WP_CRON before "stop editing" comment - This follows WordPress convention for custom constants - Removes any existing DISABLE_WP_CRON lines first (clean placement) - Falls back to after --- .../wordpress/wordpress-cron-manager.sh | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index 5eb8c8e..1f7026b 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -55,22 +55,30 @@ disable_wpcron_in_config() { return 1 fi - # Check if DISABLE_WP_CRON already exists (not commented) - if grep -E "^[^/]*define\s*\(\s*['\"]DISABLE_WP_CRON['\"]" "$wp_config" >/dev/null 2>&1; then - # Line exists, modify it to set true - sed -i.wpbak "s/^\([^/]*\)define\s*(\s*['\"]DISABLE_WP_CRON['\"]\s*,\s*[^)]*)/\1define('DISABLE_WP_CRON', true)/" "$wp_config" + # First, remove any existing DISABLE_WP_CRON lines (anywhere in file) + # This ensures clean placement even if previously added in wrong location + if grep -q "DISABLE_WP_CRON" "$wp_config" 2>/dev/null; then + sed -i.wpbak "/define\s*(\s*['\"]DISABLE_WP_CRON['\"]/d" "$wp_config" else - # Line doesn't exist, add it after /dev/null; then + # Add before "stop editing" line (proper WordPress convention) + sed -i "/stop editing/i \\ define('DISABLE_WP_CRON', true);" "$wp_config" + elif grep -q "