Actually all I had to do is, run theme options inside the function, like this:
function mytheme_under_construction(){
global $mytheme;
if(!empty($mytheme['offline_id'])){
// if user is logged in, don't show the construction page
if ( is_user_logged_in() ) {
return;
}
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
$protocol="HTTP/1.0";
// 503 is recommended : http://bit.ly/YdGkXl
header( "$protocol 503 Service Unavailable", true, 503 );
// or header( "$protocol 200 Ok", true, 200 );
header( 'Content-Type: text/html; charset=utf-8' );
// adjust the Retry-After value (in seconds)
header( 'Retry-After: 3600' );
?>
<?php get_template_part('maintanance'); ?>
<?php
die();
}
}
add_action( 'template_redirect', 'amytheme_under_construction' );