<?php

if ( ! class_exists( 'Bw_Redirection' ) ) {
	
	class Bw_Redirection {
		function __construct() {
			add_action( 'template_redirect', array( $this, 'redirect' ) );
		}

		public function redirect() {
			if ( $url = get_field( 'redirect_url' ) ) {
				header("HTTP/1.1 301 Moved Permanently");
				header("Location: $url");
				exit();
			}
		}
	}

	new Bw_Redirection();
}
