PluginProbe ʕ •ᴥ•ʔ
PiWeb Product Enquiry or product catalog for WooCommerce / 2.2.33.49
PiWeb Product Enquiry or product catalog for WooCommerce v2.2.33.49
2.2.34.43 2.2.34.42 2.2.34.41 2.2.34.40 2.2.34.39 trunk 2.2.22 2.2.26 2.2.33.16 2.2.33.17 2.2.33.19 2.2.33.20 2.2.33.21 2.2.33.22 2.2.33.23 2.2.33.24 2.2.33.26 2.2.33.27 2.2.33.29 2.2.33.30 2.2.33.31 2.2.33.32 2.2.33.33 2.2.33.34 2.2.33.36 2.2.33.37 2.2.33.39 2.2.33.40 2.2.33.41 2.2.33.42 2.2.33.43 2.2.33.44 2.2.33.46 2.2.33.47 2.2.33.49 2.2.34.0 2.2.34.1 2.2.34.10 2.2.34.11 2.2.34.12 2.2.34.13 2.2.34.14 2.2.34.16 2.2.34.17 2.2.34.19 2.2.34.2 2.2.34.20 2.2.34.21 2.2.34.22 2.2.34.23 2.2.34.24 2.2.34.26 2.2.34.27 2.2.34.29 2.2.34.3 2.2.34.30 2.2.34.31 2.2.34.32 2.2.34.33 2.2.34.34 2.2.34.36 2.2.34.37 2.2.34.4 2.2.34.6 2.2.34.7 2.2.34.9
enquiry-quotation-for-woocommerce / includes / review.php
enquiry-quotation-for-woocommerce / includes Last commit date
img 1 year ago ARIAL.TTF 1 year ago background.png 1 year ago banner-sample.php 1 year ago class-php-captcha.php 1 year ago class-pisol-enquiry-quotation-woocommerce-activator.php 1 year ago class-pisol-enquiry-quotation-woocommerce-deactivator.php 1 year ago class-pisol-enquiry-quotation-woocommerce-i18n.php 1 year ago class-pisol-enquiry-quotation-woocommerce-loader.php 1 year ago class-pisol-enquiry-quotation-woocommerce.php 1 year ago conflict-fixer.php 1 year ago includes.php 1 year ago index.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
222 lines
1 <?php
2 /*
3 v1.0.2
4 */
5 if(!class_exists('pisol_enq_product_enquiry_review')){
6 class pisol_enq_product_enquiry_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 $notice .= '<p>'.__("Hi there, You've been using <strong>{$this->title}</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?").'</p>';
147 $notice .= '<ul class="pi-flex" style="margin-top:15px;
148 grid-template-columns: 1fr 1fr 1fr;
149 grid-column-gap: 20px;
150 text-align: center;">';
151 $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>';
152 $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>';
153 $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>';
154 if($this->buy_url && $this->price){
155 $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>';
156 }
157 $notice .= '</ul>';
158 $notice .= '</div>';
159 $notice .= '</div>';
160 $notice .= '</div>';
161
162 if(!$options && current_time('timestamp') >= strtotime($activation_time." +{$this->review_after} days")){
163 echo wp_kses($notice, $this->allowed_tags);
164 } else if(is_array($options)) {
165 if( array_key_exists('preference', $options) && array_key_exists('update_at', $options) && $options['preference'] =='later'){
166 if($this->validateDate($options['update_at']) && current_time('timestamp') >= strtotime($options['update_at']." +{$this->review_after} days")){
167 echo wp_kses($notice, $this->allowed_tags);
168 }
169 }
170 }
171 }
172
173 function savePreference(){
174 $nonce = isset($_GET['_wpnonce']) ? $_GET['_wpnonce'] : '' ;
175 $preference = isset($_GET['preference']) ? $_GET['preference'] : 'later';
176
177 if(!isset($_GET['_wpnonce']) || !wp_verify_nonce($nonce,"pi_save_review_preference_{$this->slug}")){
178 wp_die(esc_html('Link has expired'), '', array('response' => 403));
179 }
180
181 $values['update_at'] = current_time('Y/m/d');
182 switch($preference){
183 case 'later':
184 $values['preference'] = 'later';
185 $redirect = admin_url('index.php');
186 break;
187
188 case 'now':
189 $values['preference'] = 'now';
190 $redirect = $this->review_url;
191 break;
192
193 case 'never':
194 $values['preference'] = 'never';
195 $redirect = admin_url('index.php');
196 break;
197 }
198 update_option($this->saved_value, $values);
199 wp_redirect($redirect);
200 }
201
202 function getInstallationDate(){
203 $get_install_date = get_option($this->activation_date);
204 if(empty($get_install_date) || !$this->validateDate($get_install_date)){
205 $now = current_time( "Y/m/d" );
206 add_option( $this->activation_date, $now );
207 return $now;
208 }
209 return $get_install_date;
210 }
211
212 function validateDate($date, $format = 'Y/m/d'){
213 if ( empty($date) ) return false;
214
215 $d = DateTime::createFromFormat($format, $date);
216 // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
217 return $d && $d->format($format) === $date;
218 }
219 }
220
221 new pisol_enq_product_enquiry_review('Product Enquiry Quotation for WooCommerce plugin', 'enquiry-quotation-for-woocommerce', PI_EQW_BUY_URL, PI_EQW_PRICE);
222 }