Skip to content

Add a new {timezone} placeholder #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added

* Added "hourly" as a default interval for stores ([#20]).
* Added new placeholders to user-facing messaging ([#20]):
* Added new placeholders to user-facing messaging ([#20], [#26]):
- `{current_interval:date}` (alias of `{current_interval}`)
- `{current_interval:time}`
- `{next_interval:date}` (alias of `{next_interval}`)
- `{next_interval:time}`
- `{timezone}`
* Added documentation for adding custom intervals, placeholders ([#23]).

### Updated
Expand Down Expand Up @@ -62,3 +63,4 @@ Initial plugin release.
[#13]: https://github.com/nexcess/limit-orders/pull/13
[#20]: https://github.com/nexcess/limit-orders/pull/20
[#23]: https://github.com/nexcess/limit-orders/pull/23
[#26]: https://github.com/nexcess/limit-orders/pull/26
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ In any of these messages, you may also use the following variables:
<dd>An alias of <var>{next_interval}</var></dd>
<dt>{next_interval:time}</dt>
<dd>The time the next interval will begin.</dd>
<dt>{timezone}</dt>
<dd>The store's timezone, e.g. "PST", "EDT", etc. This will automatically update based on Daylight Saving Time.</dd>
</dl>

Dates and times will be formatted [according to the "date format" and "time format" settings for your store](https://wordpress.org/support/article/settings-general-screen/#date-format), respectively.
Expand Down
1 change: 1 addition & 0 deletions src/OrderLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public function get_placeholders( $setting = '', $message = '' ) {
'{next_interval}' => $next->format( $date_format ),
'{next_interval:date}' => $next->format( $date_format ),
'{next_interval:time}' => $next->format( $time_format ),
'{timezone}' => $next->format( 'T' ),
];

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/OrderLimiterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ public function get_message_should_replace_next_interval_time_placeholder() {
/**
* @test
* @group Placeholders
* @ticket https://github.com/nexcess/limit-orders/issues/18
* @ticket https://github.com/nexcess/limit-orders/issues/22
*/
public function get_placeholders_should_return_an_array_of_default_placeholders() {
update_option( 'date_format', 'F j, Y' );
Expand All @@ -243,6 +245,7 @@ public function get_placeholders_should_return_an_array_of_default_placeholders(
$this->assertSame( $next->format( 'F j, Y' ), $placeholders['{next_interval}'] );
$this->assertSame( $next->format( 'F j, Y' ), $placeholders['{next_interval:date}'] );
$this->assertSame( $next->format( 'g:ia' ), $placeholders['{next_interval:time}'] );
$this->assertSame( $next->format( 'T' ), $placeholders['{timezone}'] );
}

/**
Expand Down