From c78ff2ccd7c354dd7c089faf74d235cb60b2a16f 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 /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 "