PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 2.6.2
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v2.6.2
2.15.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 All 62 releases
hurrytimer / includes / Placeholders / Time_Placeholder.php

Time_Placeholder.php in HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce 2.6.2, at includes/Placeholders/Time_Placeholder.php

39 lines 891 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hurrytimer\Placeholders;
4
5 use Hurrytimer\C;
6 use Hurrytimer\Dependencies\Carbon\Carbon;
7
8
9 class Time_Placeholder extends Placeholder
10 {
11
12 /**
13 * @var \Hurrytimer\Campaign
14 */
15 protected $campaign;
16
17 public function __construct( $campaign )
18 {
19 $this->campaign = $campaign;
20 }
21
22 public function get_format()
23 {
24 return apply_filters( 'hurryt_time_format', get_option( 'time_format' ) );
25 }
26
27 public function get_value( $options = [])
28 {
29 switch ( $this->campaign->mode ) {
30 case C::MODE_REGULAR:
31 return Carbon::parse( $this->campaign->getEndDatetime() )->format( $this->get_format() );
32 case C::MODE_RECURRING:
33 return $this->campaign->getRecurrenceEndDate()->format( $this->get_format() );
34 default:
35 return '{{time}}';
36 }
37 }
38
39 }