Under Construction Mode is one of the most used modules of the BigScoots Helper plugin. Though the module works right out of the box, it does allow you to fine-tune the final user experience programmatically by leveraging numerous actions and filters provided by it.
In this article, we will show you all the actions and filters provided by the Under Construction Mode module and how you can use them to change the under-construction page programmatically.
Just so you know, all actions and filters have $under_construction_page_type
additional arguments passed to them. Which you can use to check which type of under-construction page is being used.
The possible values of this argument are:
coming_soon
under_maintenance
Actions
Let's look at all the actions provided by the under-construction mode module.
Add code inside the <head>
section
Leverage bigscoots/helper/under-construction-mode/page/header
action to add code inside the header. Here is an example code:
add_action('bigscoots/helper/under-construction-mode/page/header', function(string $under_construction_page_type) : void {
if ($under_construction_page_type === 'under_maintenance') {
// execute your code logic here
} else {
// execute your code logic here
}
});
Add code below the opening of <body>
tag
Leverage bigscoots/helper/under-construction-mode/page/body
action to add code below the opening of <body>
tag. Here is an example code:
add_action('bigscoots/helper/under-construction-mode/page/body', function(string $under_construction_page_type) : void {
if ($under_construction_page_type === 'under_maintenance') {
// execute your code logic here
} else {
// execute your code logic here
}
});
Add code above the closing of </body>
tag
Leverage bigscoots/helper/under-construction-mode/page/footer
action to add code above the closing of <body>
tag. Here is an example code:
add_action('bigscoots/helper/under-construction-mode/page/footer', function(string $under_construction_page_type) : void {
if ($under_construction_page_type === 'under_maintenance') {
// execute your code logic here
} else {
// execute your code logic here
}
});
Filters
Let's look at all the filters provided by the under-construction mode module.
Exclude user from seeing the under-construction mode page
Leverage bigscoots/helper/under-construction-mode/user/excluded
filter to modify the logic of users excluded from seeing the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/user/excluded', function(bool $is_user_excluded, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
// execute your logic here
}
return $is_user_excluded;
}, 10, 2);
Choose when to show the under-construction page
Leverage bigscoots/helper/under-construction-mode/show
filter to modify the logic of when the under-construction mode is shown. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/show', function(bool $should_we_show_under_construction_page, string $under_construction_page_type) : bool {
if ($under_construction_page_type === 'under_maintenance') {
// execute your logic here
}
return $should_we_show_under_construction_page;
}, 10, 2);
Change the text of the <title>
tag
Leverage bigscoots/helper/under-construction-mode/page/title
filter to modify the text of the <title>
tag. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/title', function(string $title_text, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$title_text = 'Foo';
} elseif ($under_construction_page_type === 'coming_soon') {
$title_text = 'Bar';
}
return $title_text;
}, 10, 2);
Change the under-construction mode page heading
Leverage bigscoots/helper/under-construction-mode/page/heading
filter to modify the heading of the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/heading', function(string $heading, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$heading = 'Foo Heading';
} elseif ($under_construction_page_type === 'coming_soon') {
$heading = 'Bar Heading';
}
return $heading;
}, 10, 2);
Change the under-construction mode page sub-heading
Leverage bigscoots/helper/under-construction-mode/page/sub-heading
filter to modify the sub-heading of the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/sub-heading', function(string $sub_heading, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$sub_heading = 'Foo Sub Heading';
} elseif ($under_construction_page_type === 'coming_soon') {
$sub_heading = 'Bar Sub Heading';
}
return $sub_heading;
}, 10, 2);
Change the stylesheet URL of the under-construction mode page
Leverage bigscoots/helper/under-construction-mode/page/stylesheet/url
filter to modify the stylesheet URL of the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/stylesheet/url', function(string $stylesheet_url, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$stylesheet_url = 'https://example.com/stylesheet.css';
} elseif ($under_construction_page_type === 'coming_soon') {
$stylesheet_url = 'https://another-example.com/stylesheet.css';
}
return $stylesheet_url;
}, 10, 2);
Change the image URL of the under-construction mode page
Leverage bigscoots/helper/under-construction-mode/page/image/url
filter to modify the image URL of the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/image/url', function(string $image_url, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$image_url = 'https://example.com/example.png';
} elseif ($under_construction_page_type === 'coming_soon') {
$image_url = 'https://another-example.com/example.png';
}
return $image_url;
}, 10, 2);
Change the image width of the under-construction mode page
Leverage bigscoots/helper/under-construction-mode/page/image/width
filter to modify the image width of the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/image/width', function(string $image_width, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$image_width = '600';
} elseif ($under_construction_page_type === 'coming_soon') {
$image_width = '700';
}
return $image_width;
}, 10, 2);
Change the image height of the under-construction mode page
Leverage bigscoots/helper/under-construction-mode/page/image/height
filter to modify the image width of the under-construction mode page. Here is an example code:
add_filter('bigscoots/helper/under-construction-mode/page/image/height', function(string $image_height, string $under_construction_page_type) : string {
if ($under_construction_page_type === 'under_maintenance') {
$image_height = '300';
} elseif ($under_construction_page_type === 'coming_soon') {
$image_height = '350';
}
return $image_height;
}, 10, 2);