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