When WP-CLI commands mysteriously return no output, it’s often due to a misbehaving plugin. Here’s a quick script that helped me identify the culprit:
bash
for plugin in $(wp plugin list --field=name --skip-plugins); do
echo -e "\033[1;34m-----------------------------------------\033[0m"
echo -e "\033[1;33mTesting with --skip-plugins=$plugin...\033[0m"
output=$(wp eval 'echo "test";' --skip-plugins="$plugin")
if [ ! -z "$output" ]; then
echo -e "\033[1;32mSuccess! Output: $output\033[0m"
echo -e "\033[1;31mProblem likely caused by: $plugin\033[0m"
echo -e "\033[1;34m-----------------------------------------\033[0m"
break
else
echo -e "\033[1;31mNo output. Moving to the next plugin.\033[0m"
fi
done
This script iterates through each plugin, disabling them one at a time until WP-CLI output is restored. When output appears, you’ve found your problematic plugin.
The script uses color coding for better visibility:
- Blue: Separators
- Yellow: Current test
- Green: Success
- Red: Issues/problematic plugin
Save this as debug-wpcli.sh
and run it from your WordPress root directory.
Happy debugging!
Leave a Reply