• Resolved rahulapc

    (@rahulapc)


    Hey,
    First of all, thanks for the plugin, it’s pretty awesome.

    We already have the PRO subscription, but opening a support here could be helpful to others as well.
    In our website, we do have some option that needs to be changed before simply static export, and after too.

    For the AFTER action, we’re able to use some function into ‘ss_after_cleanup’ action as suggested in your snippets and worked fine. Using this will ignore the action made by plugin, the native one? “delete_option( ‘simply-static-use-build’ );”
    Should we include this option deletion in our custom function too?

    But the main question is: Does exist any hook/filter to use custom function BEFORE simply static instance/generator is started?

    We just need to update an option before the whole thing starts, and tried to hook in first “ss_static_pages”, but seems that we got couple errors.

    Many thanks in advance, and feel free to ask anything.


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author patrickposner

    (@patrickposner)

    Hey @rahulapc,

    I’m happy to help!

    First off, an action that runs before the static export:

    You have a couple of options within Simply Static, but probably the best is this hook:

    add_action('ss_archive_creation_job_before_start', function( $blog_id, $archive_job ) {
    	//do something.
    });

    This one is executed before the job is scheduled as a background process and, thus, the perfect point in time to set up or save an option.

    Action after: I would use the exact same hook for that, so

    ss_after_cleanup

    is the way to go because it gets executed, no matter which deployment option you choose.

    simply-static-use-build and simply-static-use-single

    These are native options outside the general “simply-static” option and are implemented that way to avoid being cached.

    We could use transients for that (We did that in the past), but we ran into a couple of problems when Redis was used, so we implemented our own clearing mechanism.

    I would suggest deleting these in your own implementation if you use “Builds” or “Single” exports in any way.

    If we look into the implementation within Simply Static Pro, you’ll see that these options get deleted in the same hook (ss_after_cleanup), so replicating that in your own script is recommended ??

    Cheers,
    Patrick

    Thread Starter rahulapc

    (@rahulapc)

    Excellent, Patrick. Thank you for the prompt response, understood, and that’s exactly what I needed.

    I’ll use the hook that starts before as suggested, and continue using ss_after_cleanup that executes afterwards.

    Thanks, and have a great week!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hook before start’ is closed to new replies.