[Resolved] How to create an entirely new hook location?

Home Forums Support [Resolved] How to create an entirely new hook location?

Home Forums Support How to create an entirely new hook location?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2007702
    Lewis

    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,

    #2007707
    Lewis

    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?

    #2007710
    David
    Staff
    Customer Support

    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'); ?>

    #2008177
    Lewis

    Thanks, David. Just what I was after. 🙂

    #2008284
    David
    Staff
    Customer Support

    You’re welcome

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.