• Resolved dishpit

    (@dishpit)


    First of all, thanks so much for writing this plugin. It’s almost exactly what I was looking for, but I think there are two small features that would make it even better (and just perfect for my needs). Or maybe these things are already possible, and I’m just not reading the documentation right?

    1. I’d like to be able to set my date to Thanksgiving, which is on a different day of the month each year, in most countries. In America, it’s the fourth Thursday in November, so it would be great if I could set up a shortcode like:

    [time-restrict-repeat type=”annually” onmonth=”November” ondate=”4thThursday” offmonth=”December” offdate=”01″]

    Similarly, I think it would be useful to be able target the last day of the month, which changes monthly.

    2. I’m also hoping to be able to add or subtract days from my target dates. Obviously, this doesn’t make sense when using static days of the month – I wouldn’t need to say “5 days before the 15th”, I’d just say “the 10th”. But using the above Thanksgiving setting, for example, I’d like to be able to show a form 2 weeks before Thanksgiving, and hide it again the day before. Something like:

    [time-restrict-repeat type=”annually” onmonth=”November” ondate=”4thThursday” onoffset=”-14″ offmonth=”November” offdate=”4thThursday” offoffset=”-2″]

    or perhaps even:

    [time-restrict-repeat type=”annually” onmonth=”November” ondate=”4thThursday-14″ offmonth=”November” offdate=”4thThursday-2″]

    I’m sure the syntax could be a lot more intuitive – “onoffset” and “offoffset” and “4thThursday” are pretty awkward, but those the first things that came to my mind, to illustrate the example.

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

    (@thewanderingbrit)

    Hi there,

    Actually, since the plugin uses strtotime() to calculate the dates, you can do some pretty creative stuff (including exactly what you’re requesting). For example, you can do the fourth Thursday of November this year to get Thanksgiving Day. strtotime() also supports calculations, so you can get 2 weeks before Thanksgiving, either by saying second Thursday of November this year or fourth Thursday of November this year - 2 weeks. I believe that you would do this using the [time-restrict] shortcode instead of [time-restrict-repeat], because it says this year in the string, so as soon as the next year rools around, it will start looking towards the coming November, rather than the one that just passed.

    A really useful tool for testing your inputs is PHP strtotime() Testing tool.

    I hope that helps ?? Do some testing and let me know your results.

    • This reply was modified 8 years, 2 months ago by Dave Clements. Reason: Added missing backticks for code blocks
    • This reply was modified 8 years, 2 months ago by Dave Clements. Reason: Syntax for strtotime requires fourth, not 4th
    Thread Starter dishpit

    (@dishpit)

    Whoa, that’s great! I saw the link to PHP date/time formats, but I had no idea they were so versatile. My only suggestion now would be to add these examples to the documentation, in case others who aren’t familiar with PHP functions run into the same problem (and aren’t savvy enough to read the support forum).

    Thanks so much for the quick reply, and the great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Request for additional options’ is closed to new replies.