Support » Plugins and Hacks » [Resolved] [Plugin: Public Post Preview] Link expiration

[Resolved] [Plugin: Public Post Preview] Link expiration

Viewing 11 replies - 1 through 11 (of 11 total)
  • By default the link is available for 24 hours. It based on the WordPress Nonces API and exists for security reasons.

    If a link (the nonce code) has been expired you can copy the link again.

    If you really want to extend the time to can use the filter in wp_nonce_tick().
    For example:

    add_filter( 'nonce_life', 'ds_nonce_life' );
    function ds_nonce_life( $seconds ) {
    	return 60 * 60 * 24 * 50; // 50 days

    Hello Dominik,

    first thanks for your quick reply!

    If I would apply this filter as you wrote, wouldn’t this affect all WordPress plug-ins?

    If that’s the case, this obviously would not be a very good idea, because maybe some plug-ins really need this for security reasons.

    But I absolutely don’t see why this public preview link needs to expire as I
    1. explicitly enable the link (and I can disable it again at any time) and
    2. this is not a public link, but I only send it to few people directly (that should review my post) and I want it to be active till I disable it again or I just publish my post.

    Therefore there is no need for automatic expiration – at least there should be an option to disable it.

    Best regards and thanks again

    Hey Andreas,
    yes, it doesn’t affect only plugins, also the core. So I agree, not a nice solution.

    I just did a new commit to the plugin repo.
    It introduces the new filter ppp_nonce_life. With it you can adjust the lifetime of a link.

    To get the version with this filter you can download the development version of the plugin.

    Hello Dominik,

    thanks again for your fast reply and support!

    I’ve updated now to your developer version and added this function to my theme template:

    add_filter( 'ppp_nonce_life', 'ds_nonce_life' );
    function ds_nonce_life( $seconds ) {
    	return PHP_INT_MAX;

    This should fix it now.

    Anyway, I still think a simple checkbox on a plug-in option page would be much better and easier to use.

    Additionally I would suggest to warn the user that this link will expire by default: as I never would have thought that this preview link expires (as it makes no sense in my opinion), I was very surprised when I got a complaint from my reviewer that the link I sent to him one day before did not work anymore…

    Best regards and thanks again for your support


    yes, the functions looks good. Nice way with PHP_INT_MAX.

    An option for a single checkbox is too overloaded. Since this is the main feature of the plugin it shouldn’t be easily to disable. Also from the WordPress Philosophy Decisions not Options.

    Your note about a warning – It already exists:

    This plugin takes care of that by generating a URL with an expiring nonce that can be given out for public preview.

    Thanks for using the plugin,

    I agree with ab-tools. The link should not expire by default. If anything, it should be a checkbox option with a field for number of days.

    I’m now trying to make it not expire and I’m struggling as I’m not a programmer.

    I have to say I also agree that some expiration choices in the GUI would be highly preferrable. A drop down that defaults to 24hrs but also offers 1week, 1month, 1year and never would be ideal to me. Followed below by a date showing me when the link will or did expire.

    It’s the idea that a check box is enabled but my link has actually expired (and there’s no indication of when it expired or whether it’s still valid) that’s a very confusing user experience for me. “Preview Link” is “enabled” but it may not be valid – that’s just counterintuitive for me.

    I personally will use the plugin not to expire the previews (so I’ve applied the filter). But it would be nice to be able to decide on a post by post basis.

    That being said, I do understand that most will appreciate the security of an expiring link. 24hrs is pretty short though. I don’t feel I can depend on people to respond that quickly. So I made mine non-expiring and I added a column in my tables to show me where I had enabled links so that I could disable them when I was done — now that I think of it, I haven’t tested if that does invalidate the link. I’ll have to check.

    hello.. where should I add the code (in which file)?

    I see the code in the FAQ :

    add_filter( 'ppp_nonce_life', 'my_nonce_life' );
    function my_nonce_life() {
        return 60 * 60 * 24 * 5; // 5 days

    is it the correct code, as I see other different codes in the forum?



    Is there anyway to make the expire date forever?

    I still have this expired links problem. I can’t see where to put the above code for the “ppp_nonce_life” filter. I tried to put it in my header template, but it still appears not to be working.


Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] [Plugin: Public Post Preview] Link expiration’ is closed to new replies.