move enqueue script inside isset( $post ) call