Added check to ensure WP is loaded before initializing.