PluginProbe ʕ •ᴥ•ʔ
PiWeb Product Enquiry or product catalog for WooCommerce / 2.2.34.43
PiWeb Product Enquiry or product catalog for WooCommerce v2.2.34.43
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 3 days ago ARIAL.TTF 3 days ago background.png 3 days ago banner-sample.php 3 days ago class-php-captcha.php 3 days ago class-pisol-enquiry-quotation-woocommerce-activator.php 3 days ago class-pisol-enquiry-quotation-woocommerce-deactivator.php 3 days ago class-pisol-enquiry-quotation-woocommerce-i18n.php 3 days ago class-pisol-enquiry-quotation-woocommerce-loader.php 3 days ago class-pisol-enquiry-quotation-woocommerce.php 3 days ago conflict-fixer.php 3 days ago includes.php 3 days ago index.php 3 days ago pisol.class.form.php 3 days ago pisol.class.promotion.php 3 days ago review-icon.svg 3 days ago review.php 3 days ago
review.php
224 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3 /*
4 v1.0.2
5 */
6 if(!class_exists('pisol_enq_product_enquiry_review')){
7 class pisol_enq_product_enquiry_review{
8
9 public $title;
10 public $slug;
11 public $activation_date;
12 public $saved_value;
13 public $review_url;
14 public $review_after;
15 public $buy_url;
16 public $price;
17 public $allowed_tags = array();
18
19 function __construct($title, $slug, $buy_url = '', $price = '' ){
20 if(function_exists('is_admin') && is_admin()){
21 $this->title = $title;
22 $this->slug = $slug;
23 $this->activation_date = "pi_review_activation_date_{$this->slug}";
24 $this->saved_value = "pi_review_saved_value_{$this->slug}";
25 $this->review_url = "https://wordpress.org/support/plugin/{$this->slug}/reviews/#wp-bbp_topic_content-wrap";
26 $this->review_after = 6;
27 $this->buy_url = $buy_url;
28 $this->price = $price;
29
30 $allowed_atts = array(
31 'align' => array(),
32 'class' => array(),
33 'selected' => array(),
34 'multiple' => array(),
35 'checked' => array(),
36 'type' => array(),
37 'id' => array(),
38 'dir' => array(),
39 'lang' => array(),
40 'style' => array(),
41 'xml:lang' => array(),
42 'src' => array(),
43 'alt' => array(),
44 'href' => array(),
45 'rel' => array(),
46 'rev' => array(),
47 'target' => array(),
48 'novalidate' => array(),
49 'type' => array(),
50 'value' => array(),
51 'name' => array(),
52 'tabindex' => array(),
53 'action' => array(),
54 'method' => array(),
55 'for' => array(),
56 'width' => array(),
57 'height' => array(),
58 'data' => array(),
59 'title' => array(),
60 'min' => array(),
61 'max' => array(),
62 'step' => array(),
63 'required' => array(),
64 'readonly' => array(),
65 );
66 $this->allowed_tags['form'] = $allowed_atts;
67 $this->allowed_tags['br'] = $allowed_atts;
68 $this->allowed_tags['label'] = $allowed_atts;
69 $this->allowed_tags['input'] = $allowed_atts;
70 $this->allowed_tags['select'] = $allowed_atts;
71 $this->allowed_tags['option'] = $allowed_atts;
72 $this->allowed_tags['textarea'] = $allowed_atts;
73 $this->allowed_tags['iframe'] = $allowed_atts;
74 $this->allowed_tags['script'] = $allowed_atts;
75 $this->allowed_tags['style'] = $allowed_atts;
76 $this->allowed_tags['strong'] = $allowed_atts;
77 $this->allowed_tags['small'] = $allowed_atts;
78 $this->allowed_tags['table'] = $allowed_atts;
79 $this->allowed_tags['span'] = $allowed_atts;
80 $this->allowed_tags['abbr'] = $allowed_atts;
81 $this->allowed_tags['code'] = $allowed_atts;
82 $this->allowed_tags['pre'] = $allowed_atts;
83 $this->allowed_tags['div'] = $allowed_atts;
84 $this->allowed_tags['img'] = $allowed_atts;
85 $this->allowed_tags['h1'] = $allowed_atts;
86 $this->allowed_tags['h2'] = $allowed_atts;
87 $this->allowed_tags['h3'] = $allowed_atts;
88 $this->allowed_tags['h4'] = $allowed_atts;
89 $this->allowed_tags['h5'] = $allowed_atts;
90 $this->allowed_tags['h6'] = $allowed_atts;
91 $this->allowed_tags['ol'] = $allowed_atts;
92 $this->allowed_tags['ul'] = $allowed_atts;
93 $this->allowed_tags['li'] = $allowed_atts;
94 $this->allowed_tags['em'] = $allowed_atts;
95 $this->allowed_tags['hr'] = $allowed_atts;
96 $this->allowed_tags['br'] = $allowed_atts;
97 $this->allowed_tags['tr'] = $allowed_atts;
98 $this->allowed_tags['td'] = $allowed_atts;
99 $this->allowed_tags['p'] = $allowed_atts;
100 $this->allowed_tags['a'] = $allowed_atts;
101 $this->allowed_tags['b'] = $allowed_atts;
102 $this->allowed_tags['i'] = $allowed_atts;
103
104 //update_option($this->saved_value, array('preference'=> 'later', 'update_at'=>'2021/06/10'));
105 //delete_option($this->saved_value);
106
107 add_action( 'admin_notices', array($this, 'display_admin_notice'),20 );
108 add_action( "admin_post_pi_save_review_preference_{$this->slug}", array($this, 'savePreference'),20 );
109 }
110 }
111
112 function display_admin_notice() {
113
114 $options = get_option($this->saved_value);
115
116 $activation_time = $this->getInstallationDate();
117
118 $notice = '<div class="notice notice-error is-dismissible">';
119 $notice .= '<style>.pisol-review-btn {
120 display: block;
121 padding: 10px 15px;
122 color: #FFF;
123 text-decoration: none;
124 border-radius: 2px;
125 }
126
127 .pi-active-btn {
128 background-color: #00adb5;
129 }
130
131 .pi-passive-btn {
132 background-color: #ccc;
133 }
134
135 .pi-buy-now-btn {
136 background-color: #ee6443;
137 }
138
139 .pi-flex{
140 display:flex;
141 align-items:center;
142 }
143 </style>';
144 $notice .= '<div class="pi-flex">';
145 $notice .= '<img style="max-width:90px; height:auto;" src="'.plugin_dir_url( __FILE__ ).'review-icon.svg" alt="pi web solution">';
146 $notice .= '<div style="margin-left:20px;">';
147 $notice .= '<p>'.sprintf(__("Is handling enquiries and quotes easier with this plugin?", 'pisol-enquiry-quotation-woocommerce'), esc_html($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 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">'.__("Yes", 'pisol-enquiry-quotation-woocommerce').'</a></li>';
153 $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')).'">'.__("No", 'pisol-enquiry-quotation-woocommerce').'</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", 'pisol-enquiry-quotation-woocommerce').'</a></li>';
155 if($this->buy_url && $this->price){
156 // translators: %s: 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", 'pisol-enquiry-quotation-woocommerce'), $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']) ? sanitize_text_field( wp_unslash($_GET['_wpnonce']) ) : '' ;
177 $preference = isset($_GET['preference']) ? sanitize_text_field( wp_unslash($_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_enq_product_enquiry_review('Product Enquiry Quotation for WooCommerce plugin', 'enquiry-quotation-for-woocommerce', PI_EQW_BUY_URL, PI_EQW_PRICE);
224 }