Code updated from WordPress conversion