PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.13
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.13
3.0.63 3.0.62 3.0.61 3.0.60 3.0.49.49 3.0.49.6 3.0.49.60 3.0.49.61 3.0.49.62 3.0.49.63 3.0.49.64 3.0.49.66 3.0.49.67 3.0.49.69 3.0.49.7 3.0.49.70 3.0.49.72 3.0.49.73 3.0.49.74 3.0.49.76 3.0.49.77 3.0.49.79 3.0.49.9 3.0.49.90 3.0.49.91 3.0.49.92 3.0.49.93 3.0.49.94 3.0.49.96 3.0.49.97 3.0.49.99 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 2.9.17 3.0.47 3.0.49 3.0.49.1 3.0.49.10 3.0.49.11 3.0.49.12 3.0.49.13 3.0.49.16 3.0.49.17 3.0.49.19 3.0.49.2 3.0.49.20 3.0.49.21 3.0.49.22 3.0.49.23 3.0.49.24 3.0.49.26 3.0.49.27 3.0.49.29 3.0.49.3 3.0.49.30 3.0.49.31 3.0.49.32 3.0.49.33 3.0.49.34 3.0.49.36 3.0.49.37 3.0.49.39 3.0.49.4 3.0.49.40 3.0.49.41 3.0.49.42 3.0.49.43 3.0.49.44 3.0.49.46 3.0.49.47
pi-woocommerce-order-date-time-and-type / include / review.php
pi-woocommerce-order-date-time-and-type / include Last commit date
background.png 1 year ago banner-sample.php 1 year ago class-get-values.php 1 year ago includes.php 1 year ago pisol.class.form.php 1 year ago pisol.class.promotion.php 1 year ago review-icon.svg 1 year ago review.php 1 year ago
review.php
224 lines
1 <?php
2 /*
3 v1.0.3
4 */
5 if(!class_exists('pisol_dtt_delivery_date_time_review')){
6 class pisol_dtt_delivery_date_time_review{
7
8 public $title;
9 public $slug;
10 public $activation_date;
11 public $saved_value;
12 public $review_url;
13 public $review_after;
14 public $buy_url;
15 public $price;
16 public $allowed_tags = array();
17
18 function __construct($title, $slug, $buy_url = '', $price = '' ){
19 if(function_exists('is_admin') && is_admin()){
20 $this->title = $title;
21 $this->slug = $slug;
22 $this->activation_date = "pi_review_activation_date_{$this->slug}";
23 $this->saved_value = "pi_review_saved_value_{$this->slug}";
24 $this->review_url = "https://wordpress.org/support/plugin/{$this->slug}/reviews/?rate=5#new-post";
25 $this->review_after = 6;
26 $this->buy_url = $buy_url;
27 $this->price = $price;
28
29 $allowed_atts = array(
30 'align' => array(),
31 'class' => array(),
32 'selected' => array(),
33 'multiple' => array(),
34 'checked' => array(),
35 'type' => array(),
36 'id' => array(),
37 'dir' => array(),
38 'lang' => array(),
39 'style' => array(),
40 'xml:lang' => array(),
41 'src' => array(),
42 'alt' => array(),
43 'href' => array(),
44 'rel' => array(),
45 'rev' => array(),
46 'target' => array(),
47 'novalidate' => array(),
48 'type' => array(),
49 'value' => array(),
50 'name' => array(),
51 'tabindex' => array(),
52 'action' => array(),
53 'method' => array(),
54 'for' => array(),
55 'width' => array(),
56 'height' => array(),
57 'data' => array(),
58 'title' => array(),
59 'min' => array(),
60 'max' => array(),
61 'step' => array(),
62 'required' => array(),
63 'readonly' => array(),
64 );
65 $this->allowed_tags['form'] = $allowed_atts;
66 $this->allowed_tags['br'] = $allowed_atts;
67 $this->allowed_tags['label'] = $allowed_atts;
68 $this->allowed_tags['input'] = $allowed_atts;
69 $this->allowed_tags['select'] = $allowed_atts;
70 $this->allowed_tags['option'] = $allowed_atts;
71 $this->allowed_tags['textarea'] = $allowed_atts;
72 $this->allowed_tags['iframe'] = $allowed_atts;
73 $this->allowed_tags['script'] = $allowed_atts;
74 $this->allowed_tags['style'] = $allowed_atts;
75 $this->allowed_tags['strong'] = $allowed_atts;
76 $this->allowed_tags['small'] = $allowed_atts;
77 $this->allowed_tags['table'] = $allowed_atts;
78 $this->allowed_tags['span'] = $allowed_atts;
79 $this->allowed_tags['abbr'] = $allowed_atts;
80 $this->allowed_tags['code'] = $allowed_atts;
81 $this->allowed_tags['pre'] = $allowed_atts;
82 $this->allowed_tags['div'] = $allowed_atts;
83 $this->allowed_tags['img'] = $allowed_atts;
84 $this->allowed_tags['h1'] = $allowed_atts;
85 $this->allowed_tags['h2'] = $allowed_atts;
86 $this->allowed_tags['h3'] = $allowed_atts;
87 $this->allowed_tags['h4'] = $allowed_atts;
88 $this->allowed_tags['h5'] = $allowed_atts;
89 $this->allowed_tags['h6'] = $allowed_atts;
90 $this->allowed_tags['ol'] = $allowed_atts;
91 $this->allowed_tags['ul'] = $allowed_atts;
92 $this->allowed_tags['li'] = $allowed_atts;
93 $this->allowed_tags['em'] = $allowed_atts;
94 $this->allowed_tags['hr'] = $allowed_atts;
95 $this->allowed_tags['br'] = $allowed_atts;
96 $this->allowed_tags['tr'] = $allowed_atts;
97 $this->allowed_tags['td'] = $allowed_atts;
98 $this->allowed_tags['p'] = $allowed_atts;
99 $this->allowed_tags['a'] = $allowed_atts;
100 $this->allowed_tags['b'] = $allowed_atts;
101 $this->allowed_tags['i'] = $allowed_atts;
102
103 //update_option($this->saved_value, array('preference'=> 'later', 'update_at'=>'2021/06/10'));
104 //delete_option($this->saved_value);
105
106 add_action( 'admin_notices', array($this, 'display_admin_notice'),20 );
107 add_action( "admin_post_pi_save_review_preference_{$this->slug}", array($this, 'savePreference'),20 );
108 }
109 }
110
111 function display_admin_notice() {
112
113 $options = get_option($this->saved_value);
114
115 $activation_time = $this->getInstallationDate();
116
117 $notice = '<div class="notice notice-error is-dismissible">';
118 $notice .= '<style>.pisol-review-btn {
119 display: block;
120 padding: 10px 15px;
121 color: #FFF;
122 text-decoration: none;
123 border-radius: 2px;
124 }
125
126 .pi-active-btn {
127 background-color: #00adb5;
128 }
129
130 .pi-passive-btn {
131 background-color: #ccc;
132 }
133
134 .pi-buy-now-btn {
135 background-color: #ee6443;
136 }
137
138 .pi-flex{
139 display:flex;
140 align-items:center;
141 }
142 </style>';
143 $notice .= '<div class="pi-flex">';
144 $notice .= '<img style="max-width:90px; height:auto;" src="'.plugin_dir_url( __FILE__ ).'review-icon.svg" alt="pi web solution">';
145 $notice .= '<div style="margin-left:20px;">';
146 /* translators: Plugin title */
147 $notice .= '<p>'.sprintf(__("Hi there, You've been using <strong>%s</strong> on your site for a few days <br>- I hope it's been helpful. If you're enjoying my plugin, would you mind rating it 5-stars to help spread the word?"), $this->title).'</p>';
148 $notice .= '<ul class="pi-flex" style="margin-top:15px;
149 grid-template-columns: 1fr 1fr 1fr;
150 grid-column-gap: 20px;
151 text-align: center;">';
152 $notice .= '<li><a val="later" class="pi-active-btn pisol-review-btn" href="'.add_query_arg(array('action' => "pi_save_review_preference_{$this->slug}", 'preference'=>'later', '_wpnonce'=>wp_create_nonce( "pi_save_review_preference_{$this->slug}" )), admin_url('admin-post.php')).'">'.__("Remind me later").'</a></li>';
153 $notice .= '<li><a class="pi-active-btn pisol-review-btn" style="font-weight:bold;" val="given" href="'.add_query_arg(array('action' => "pi_save_review_preference_{$this->slug}", 'preference'=>'now','_wpnonce'=>wp_create_nonce( "pi_save_review_preference_{$this->slug}" )), admin_url('admin-post.php')).'" target="_blank">'.__("Review Here").'</a></li>';
154 $notice .= '<li><a class="pi-passive-btn pisol-review-btn" val="never" href="'.add_query_arg(array('action' => "pi_save_review_preference_{$this->slug}", 'preference'=>'never', '_wpnonce'=>wp_create_nonce( "pi_save_review_preference_{$this->slug}" )), admin_url('admin-post.php')).'">'.__("I would not").'</a></li>';
155 if($this->buy_url && $this->price){
156 /* translators: Price */
157 $notice .= '<li><a target="_blank" class="pi-buy-now-btn pisol-review-btn" val="never" href="'.esc_url($this->buy_url).'&utm_ref=review_reminder">'.sprintf(__("BUY PRO FOR %s"), $this->price).'</a></li>';
158 }
159 $notice .= '</ul>';
160 $notice .= '</div>';
161 $notice .= '</div>';
162 $notice .= '</div>';
163
164 if(!$options && current_time('timestamp') >= strtotime($activation_time." +{$this->review_after} days")){
165 echo wp_kses($notice, $this->allowed_tags);
166 } else if(is_array($options)) {
167 if( array_key_exists('preference', $options) && array_key_exists('update_at', $options) && $options['preference'] =='later'){
168 if($this->validateDate($options['update_at']) && current_time('timestamp') >= strtotime($options['update_at']." +{$this->review_after} days")){
169 echo wp_kses($notice, $this->allowed_tags);
170 }
171 }
172 }
173 }
174
175 function savePreference(){
176 $nonce = isset($_GET['_wpnonce']) ? $_GET['_wpnonce'] : '' ;
177 $preference = isset($_GET['preference']) ? $_GET['preference'] : 'later';
178
179 if(!isset($_GET['_wpnonce']) || !wp_verify_nonce($nonce,"pi_save_review_preference_{$this->slug}")){
180 wp_die(esc_html('Link has expired'), '', array('response' => 403));
181 }
182
183 $values['update_at'] = current_time('Y/m/d');
184 switch($preference){
185 case 'later':
186 $values['preference'] = 'later';
187 $redirect = admin_url('index.php');
188 break;
189
190 case 'now':
191 $values['preference'] = 'now';
192 $redirect = $this->review_url;
193 break;
194
195 case 'never':
196 $values['preference'] = 'never';
197 $redirect = admin_url('index.php');
198 break;
199 }
200 update_option($this->saved_value, $values);
201 wp_redirect($redirect);
202 }
203
204 function getInstallationDate(){
205 $get_install_date = get_option($this->activation_date);
206 if(empty($get_install_date) || !$this->validateDate($get_install_date)){
207 $now = current_time( "Y/m/d" );
208 add_option( $this->activation_date, $now );
209 return $now;
210 }
211 return $get_install_date;
212 }
213
214 function validateDate($date, $format = 'Y/m/d'){
215 if ( empty($date) ) return false;
216
217 $d = DateTime::createFromFormat($format, $date);
218 // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
219 return $d && $d->format($format) === $date;
220 }
221 }
222
223 new pisol_dtt_delivery_date_time_review('Delivery date and time pickup location plugin', 'pi-woocommerce-order-date-time-and-type', PISOL_DTT_BUY_URL, PISOL_DTT_PRICE);
224 }