Added logic to help prevent the 'wp is not defined' JS error

Signed-off-by: Elliot Condon <e@elliotcondon.com>