PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 3.1.1
Admin Columns v3.1.1
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Admin / Promo.php
codepress-admin-columns / classes / Admin Last commit date
Addon 8 years ago Help 8 years ago Page 8 years ago Promo 8 years ago Addon.php 8 years ago Addons.php 8 years ago Help.php 8 years ago Page.php 8 years ago Pages.php 8 years ago Promo.php 8 years ago
Promo.php
143 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 abstract class AC_Admin_Promo {
8
9 /**
10 * @var array
11 */
12 private $date_ranges;
13
14 /**
15 * @var string
16 */
17 private $title;
18
19 /**
20 * @var int
21 */
22 private $discount;
23
24 /**
25 * @var string
26 */
27 private $url;
28
29 /**
30 * @return string
31 */
32 public function get_title() {
33 return $this->title;
34 }
35
36 /**
37 * @param string $title
38 */
39 public function set_title( $title ) {
40 $this->title = $title;
41 }
42
43 /**
44 * @return int
45 */
46 public function get_discount() {
47 return $this->discount;
48 }
49
50 /**
51 * @param int $discount
52 */
53 public function set_discount( $discount ) {
54 $this->discount = $discount;
55 }
56
57 /**
58 * @return int
59 */
60 public function get_url() {
61 if ( null === $this->url ) {
62
63 $campaign = str_replace( get_parent_class( $this ) . '_', '', get_class( $this ) );
64
65 $this->set_url( ac_get_site_utm_url( 'pricing-purchase', 'promo', null, $campaign ) );
66 }
67
68 return $this->url;
69 }
70
71 /**
72 * @param int $url
73 */
74 public function set_url( $url ) {
75 $this->url = $url;
76 }
77
78 /**
79 * @param string $start_date
80 * @param string $end_date
81 */
82 public function add_date_range( $start_date, $end_date ) {
83 if ( ! $start_date || ! $end_date ) {
84 return;
85 }
86
87 $this->date_ranges[] = array(
88 'start' => $start_date,
89 'end' => $end_date,
90 );
91 }
92
93 /**
94 * @return bool True when promo is active
95 */
96 public function is_active() {
97 return $this->get_active_date_range() ? true : false;
98 }
99
100 /**
101 * Active date range
102 *
103 * @return array|false
104 */
105 private function get_active_date_range() {
106 $today = date( 'Y-m-d' );
107
108 foreach ( $this->date_ranges as $date_range ) {
109 if ( $today >= $date_range['start'] && $today <= $date_range['end'] ) {
110 return $date_range;
111 }
112 }
113
114 return false;
115 }
116
117 /**
118 * @return bool|string
119 */
120 public function end_date() {
121 $date_range = $this->get_active_date_range();
122
123 return $date_range ? date_i18n( get_option( 'date_format' ), strtotime( $date_range['end'] ) ) : false;
124 }
125
126 /**
127 * Render HTML
128 */
129 public function display() { ?>
130 <h3>
131 <?php echo esc_html( $this->get_title() ); ?>
132 </h3>
133 <a target="_blank" href="<?php echo esc_url( $this->get_url() ); ?>" class="acp-button">
134 <?php echo esc_html( sprintf( __( 'Get %s Off', 'codepress-admin-columns' ), $this->get_discount() . '%' ) ); ?>
135 </a>
136 <p class="nomargin">
137 <?php echo esc_html( sprintf( __( "Discount is valid until %s", 'codepress-admin-columns' ), $this->end_date() ) ); ?>
138 </p>
139 <?php
140 }
141
142 }
143