diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index dccb8e4..b845f58 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -762,6 +762,35 @@ is_wordpress_directory() { [ -d "$path" ] && [ -f "$path/$WP_CRON_FILENAME" ] } +# OPTIMIZATION: Regex Pattern Library (OPT-12) +# Consolidates 3+ repeated grep patterns used throughout script +# Provides consistent pattern matching and reduces duplication +grep_wp_config_define() { + local wp_config="$1" + local define_name="$2" + grep -q "define.*$define_name" "$wp_config" +} + +grep_disabled_wp_cron() { + local wp_config="$1" + grep -q "define.*$WP_CRON_DISABLED_VAR.*true" "$wp_config" +} + +grep_enabled_wp_cron() { + local wp_config="$1" + grep -q "define.*$WP_CRON_DISABLED_VAR.*false\|^[[:space:]]*#.*$WP_CRON_DISABLED_VAR" "$wp_config" +} + +grep_in_crontab() { + local pattern="$1" + crontab -l 2>/dev/null | grep -qF "$pattern" +} + +grep_wordpress_path() { + local path="$1" + [ -d "$path" ] && [ -f "$path/$WP_CRON_FILENAME" ] +} + # OPTIMIZATION: Build cron command consistently # Centralizes cron command format (appears 4 times throughout script) # Returns: cron command string for wp-cron.php execution