PluginProbe ʕ •ᴥ•ʔ
PiWeb Product Enquiry or product catalog for WooCommerce / 2.2.33.21
PiWeb Product Enquiry or product catalog for WooCommerce v2.2.33.21
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
background.png 2 years ago banner-sample.php 2 years ago class-pisol-enquiry-quotation-woocommerce-activator.php 2 years ago class-pisol-enquiry-quotation-woocommerce-deactivator.php 2 years ago class-pisol-enquiry-quotation-woocommerce-i18n.php 2 years ago class-pisol-enquiry-quotation-woocommerce-loader.php 2 years ago class-pisol-enquiry-quotation-woocommerce.php 2 years ago conflict-fixer.php 2 years ago includes.php 2 years ago index.php 2 years ago pisol.class.form.php 2 years ago pisol.class.promotion.php 2 years ago review-icon.svg 2 years ago review.php 2 years ago
review.php
131 lines
1 <?php
2 /*
3 v1.0.1
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
15 function __construct($title, $slug ){
16 if(function_exists('is_admin') && is_admin()){
17 $this->title = $title;
18 $this->slug = $slug;
19 $this->activation_date = "pi_review_activation_date_{$this->slug}";
20 $this->saved_value = "pi_review_saved_value_{$this->slug}";
21 $this->review_url = "https://wordpress.org/support/plugin/{$this->slug}/reviews/?rate=5#new-post";
22 $this->review_after = 6;
23
24 //update_option($this->saved_value, array('preference'=> 'later', 'update_at'=>'2021/06/10'));
25 //delete_option($this->saved_value);
26
27 add_action( 'admin_notices', array($this, 'display_admin_notice'),20 );
28 add_action( "admin_post_pi_save_review_preference_{$this->slug}", array($this, 'savePreference'),20 );
29 }
30 }
31
32 function display_admin_notice() {
33
34 $options = get_option($this->saved_value);
35
36 $activation_time = $this->getInstallationDate();
37
38 $notice = '<div class="notice notice-error is-dismissible">';
39 $notice .= '<style>.pisol-review-btn {
40 display: block;
41 padding: 10px 15px;
42 color: #FFF;
43 text-decoration: none;
44 border-radius: 2px;
45 }
46
47 .pi-active-btn {
48 background-color: #00adb5;
49 }
50
51 .pi-passive-btn {
52 background-color: #ccc;
53 }
54 </style>';
55 $notice .= '<div style="display:flex;">';
56 $notice .= '<img style="max-width:90px; height:auto;" src="'.plugin_dir_url( __FILE__ ).'review-icon.svg" alt="pi web solution">';
57 $notice .= '<div style="margin-left:20px;">';
58 $notice .= '<p>'.__("Hi there, You've been using <strong>{$this->title}</strong> on your site for a few days - 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>';
59 $notice .= '<ul style="margin-top:15px; display: flex;
60 grid-template-columns: 1fr 1fr 1fr;
61 grid-column-gap: 20px;
62 text-align: center;">';
63 $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>';
64 $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>';
65 $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>';
66 $notice .= '</ul>';
67 $notice .= '</div>';
68 $notice .= '</div>';
69 $notice .= '</div>';
70
71 if(!$options && current_time('timestamp') >= strtotime($activation_time." +{$this->review_after} days")){
72 echo $notice;
73 } else if(is_array($options)) {
74 if( array_key_exists('preference', $options) && array_key_exists('update_at', $options) && $options['preference'] =='later'){
75 if($this->validateDate($options['update_at']) && current_time('timestamp') >= strtotime($options['update_at']." +{$this->review_after} days")){
76 echo $notice;
77 }
78 }
79 }
80 }
81
82 function savePreference(){
83 $nonce = isset($_GET['_wpnonce']) ? $_GET['_wpnonce'] : '' ;
84 $preference = isset($_GET['preference']) ? $_GET['preference'] : 'later';
85
86 if(!isset($_GET['_wpnonce']) || !wp_verify_nonce($nonce,"pi_save_review_preference_{$this->slug}")){
87 wp_die(__('Link has expired'), '', array('response' => 403));
88 }
89
90 $values['update_at'] = current_time('Y/m/d');
91 switch($preference){
92 case 'later':
93 $values['preference'] = 'later';
94 $redirect = admin_url('index.php');
95 break;
96
97 case 'now':
98 $values['preference'] = 'now';
99 $redirect = $this->review_url;
100 break;
101
102 case 'never':
103 $values['preference'] = 'never';
104 $redirect = admin_url('index.php');
105 break;
106 }
107 update_option($this->saved_value, $values);
108 wp_redirect($redirect);
109 }
110
111 function getInstallationDate(){
112 $get_install_date = get_option($this->activation_date);
113 if(empty($get_install_date) || !$this->validateDate($get_install_date)){
114 $now = current_time( "Y/m/d" );
115 add_option( $this->activation_date, $now );
116 return $now;
117 }
118 return $get_install_date;
119 }
120
121 function validateDate($date, $format = 'Y/m/d'){
122 if ( empty($date) ) return false;
123
124 $d = DateTime::createFromFormat($format, $date);
125 // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
126 return $d && $d->format($format) === $date;
127 }
128 }
129
130 new pisol_enq_product_enquiry_review('Product Enquiry Quotation for WooCommerce plugin', 'enquiry-quotation-for-woocommerce');
131 }