PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.3
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.3
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
115 lines
1 <?php
2 /*
3 v1.0.0
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
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-success is-dismissible">';
39 $notice .= '<div style="display:flex;">';
40 $notice .= '<img style="max-width:90px; height:auto;" src="'.plugin_dir_url( __FILE__ ).'review-icon.svg" alt="pi web solution">';
41 $notice .= '<div style="margin-left:20px;">';
42 $notice .= '<p><b>'.__("We have worked hard to develop the plugin and it would really appreciate us if you dropped a short review about the plugin. Your review means a lot to us and we are working to make the plugin more awesome. Thanks for using {$this->title}").'</b></p>';
43 $notice .= '<ul style="display: inline-grid;
44 grid-template-columns: 1fr 1fr 1fr;
45 grid-column-gap: 20px;
46 text-align: center;">';
47 $notice .= '<li><a val="later" 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>';
48 $notice .= '<li><a 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>';
49 $notice .= '<li><a 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>';
50 $notice .= '</ul>';
51 $notice .= '</div>';
52 $notice .= '</div>';
53 $notice .= '</div>';
54
55 if(!$options && current_time('timestamp') >= strtotime($activation_time." +{$this->review_after} days")){
56 echo $notice;
57 } else if(is_array($options)) {
58 if( array_key_exists('preference', $options) && array_key_exists('update_at', $options) && $options['preference'] =='later'){
59 if($this->validateDate($options['update_at']) && current_time('timestamp') >= strtotime($options['update_at']." +{$this->review_after} days")){
60 echo $notice;
61 }
62 }
63 }
64 }
65
66 function savePreference(){
67 $nonce = isset($_GET['_wpnonce']) ? sanitize_text_field($_GET['_wpnonce']) : '' ;
68 $preference = isset($_GET['preference']) ? sanitize_text_field($_GET['preference']) : 'later';
69
70 if(!isset($_GET['_wpnonce']) || !wp_verify_nonce($nonce,"pi_save_review_preference_{$this->slug}")){
71 wp_die(__('Link has expired'), '', array('response' => 403));
72 }
73
74 $values['update_at'] = current_time('Y/m/d');
75 switch($preference){
76 case 'later':
77 $values['preference'] = 'later';
78 $redirect = admin_url('index.php');
79 break;
80
81 case 'now':
82 $values['preference'] = 'now';
83 $redirect = $this->review_url;
84 break;
85
86 case 'never':
87 $values['preference'] = 'never';
88 $redirect = admin_url('index.php');
89 break;
90 }
91 update_option($this->saved_value, $values);
92 wp_redirect($redirect);
93 }
94
95 function getInstallationDate(){
96 $get_install_date = get_option($this->activation_date);
97 if(empty($get_install_date) || !$this->validateDate($get_install_date)){
98 $now = current_time( "Y/m/d" );
99 add_option( $this->activation_date, $now );
100 return $now;
101 }
102 return $get_install_date;
103 }
104
105 function validateDate($date, $format = 'Y/m/d'){
106 if ( empty($date) ) return false;
107
108 $d = DateTime::createFromFormat($format, $date);
109 // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
110 return $d && $d->format($format) === $date;
111 }
112 }
113
114 new pisol_dtt_delivery_date_time_review('Delivery date and time pickup location plugin', 'pi-woocommerce-order-date-time-and-type');
115 }