Archived topic
How to create an entirely new hook location?
4 replies · Started by Lewis on November 17, 2021
So, I'm using the Simple Maintenance plugin by naa986. This plugin is awesomely lightweight, much like GP. However, I'd like to be able to use a Block Element in the Elements section, to build a sleeker maintenance page.
I have created my maintenance block element in the Elements section.
Element, (Block - Hook 503-redirect)
The plugin is loading a basic HTML template, via;
function load_sm_page() {
header('HTTP/1.0 503 Service Unavailable');
include_once("sm-template.php");
exit();
}
The sm-template.php file is currently loading a full. <html>...</html> page. I'm thinking I can hook in here by removing all the content here and simply add my hook element. I can't figure out how I add a hook location though. Is it possible to add a new hook location for GP to use? If so how would I go about it?
Thanks,
Also, on a side note, it would be awesome to be able to create elements, as shortcodes. That way I could have just used <?php do_shortcode(); ?>. Would it be possible to request this feature?
Hi there,
Hooks are a WP thing... so you can add them inside your own template using the do_action function:
https://developer.wordpress.org/reference/functions/do_action/
So a simple example to include within a HTML template is:
<?php do_action('my_custom_hook_name'); ?>
Thanks, David. Just what I was after. :)
You're welcome