PluginProbe
Maps Plugin using Google Maps for WordPress – WP Google Map / trunk
Maps Plugin using Google Maps for WordPress – WP Google Map vtrunk
1.9.7 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 All 96 releases
gmap-embed / includes / traits / Notice.php

Notice.php in Maps Plugin using Google Maps for WordPress – WP Google Map trunk, at includes/traits/Notice.php

200 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WGMSRM\Traits;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 /**
10 * Trait Notice
11 */
12 trait Notice
13 {
14
15 /**
16 * Generate Different types of notices
17 */
18 public function gmap_embed_notice_generate()
19 {
20 // Review admin notice
21 $this->gmap_embed_generate_admin_review_notice();
22
23 // No API key admin notice
24 $this->wgm_no_api_key_added_notice();
25 }
26
27
28 public function wgm_no_api_key_added_notice()
29 {
30 if (get_option('wpgmap_api_key', 'none') === 'none') {
31 ?>
32 <div class="notice notice-info is-dismissible" style="border: 1px #db1c1c solid;">
33 <p>
34 <?php
35 echo wp_kses(
36 sprintf(
37 /* translators: 1: Quick Setup URL, 2: Documentation URL */
38 __('You must generate your own <b>API Key</b> to use Google Map, Now it\'s <b>Super Easy</b>, Please go to <span style="font-weight: bold;">WP Google Map</span><i class="dashicons dashicons-arrow-right-alt2"></i><a href="%1$s" style="text-decoration: none;font-weight: bold;">Quick Setup</a> and follow easy steps, <i class="dashicons dashicons-external"></i><a href="%2$s" target="_blank" style="text-decoration: none;font-weight: bold;">Documentation</a>', 'gmap-embed'),
39 esc_url(admin_url('admin.php?page=wgm_setup_wizard')),
40 esc_url('https://wpgooglemap.com/documentation/wp-google-map-quick-installation?utm_source=wp_admin&utm_medium=admin_link&utm_campaign=header_notice')
41 ),
42 array(
43 'b' => array(),
44 'span' => array('style' => array()),
45 'i' => array('class' => array()),
46 'a' => array(
47 'href' => array(),
48 'style' => array(),
49 'target' => array(),
50 ),
51 )
52 );
53 ?>
54 </p>
55 </div>
56 <?php
57 }
58 }
59
60 /**
61 * Do something on review already button click
62 */
63 public function review_already_did()
64 {
65 // Nonce verification for dismiss review
66 if (!isset($_GET['wgm_review_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['wgm_review_nonce'])), 'wgm_review_action')) {
67 wp_die(esc_html__('Security check failed.', 'gmap-embed'));
68 }
69 update_option('gmap_embed_is_review_done', true);
70 }
71
72 /**
73 * Do something on review later button click
74 */
75 public function review_later()
76 {
77 // Nonce verification for later review
78 if (!isset($_GET['wgm_review_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['wgm_review_nonce'])), 'wgm_review_action')) {
79 wp_die(esc_html__('Security check failed.', 'gmap-embed'));
80 }
81 update_option('gmap_embed_is_review_snoozed', true);
82 update_option('gmap_embed_review_snoozed_at', time());
83 }
84
85 /**
86 * Redirect to URL generate
87 *
88 * @return string
89 */
90 public function redirect_to()
91 {
92 $request_uri_raw = '';
93 if (isset($_SERVER['REQUEST_URI'])) {
94 $request_uri_raw = filter_var(wp_unslash($_SERVER['REQUEST_URI']), FILTER_SANITIZE_URL);
95 }
96 $request_uri = wp_parse_url(sanitize_text_field($request_uri_raw), PHP_URL_PATH);
97 $query_string = wp_parse_url(sanitize_text_field($request_uri_raw), PHP_URL_QUERY);
98 parse_str($query_string, $current_url);
99 $unset_array = array('dismiss', 'plugin', 'wgm_review_nonce', 'later');
100
101 foreach ($unset_array as $value) {
102 if (isset($current_url[$value])) {
103 unset($current_url[$value]);
104 }
105 }
106 $current_url = http_build_query($current_url);
107 $redirect_url = $request_uri . ($current_url ? '?' . $current_url : '');
108 return esc_url($redirect_url);
109 }
110
111 /**
112 * Generate admin panel review notice for WP Google Map plugin
113 */
114 public function gmap_embed_generate_admin_review_notice()
115 {
116 $activation_time = get_option('gmap_embed_activation_time', false);
117 $is_review_snoozed = get_option('gmap_embed_is_review_snoozed');
118 $snoozed_time = get_option('gmap_embed_review_snoozed_at');
119
120 // How may day's passed after activation
121 $seconds_diff = time() - $activation_time;
122 $passed_days = ($seconds_diff / 3600) / 24;
123
124 // Snoozed how many day's before
125 $seconds_diff = time() - $snoozed_time;
126 $snoozed_before = ($seconds_diff / 3600) / 24;
127 $is_review_done = get_option('gmap_embed_is_review_done');
128
129 /**
130 *
131 * Review section will shows based on following cases
132 * Case 1: Passed three(3) days and not snoozed
133 * Case 2: Snoozed before 7 day's
134 */
135 if ($is_review_done == false && (($passed_days >= 3 && $is_review_snoozed == false) || ($is_review_snoozed == true && $snoozed_before >= 7))) {
136 $request_uri_raw = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '';
137 $scheme = (wp_parse_url(sanitize_text_field($request_uri_raw), PHP_URL_QUERY)) ? '&' : '?';
138 $url = esc_url_raw(sanitize_text_field($request_uri_raw) . $scheme);
139 $nonce = wp_create_nonce('wgm_review_action');
140 $dismiss_link = add_query_arg(
141 array(
142 'plugin' => 'gmap-embed',
143 'dismiss' => true,
144 // Use a unique action name for nonce
145 'wgm_review_nonce' => $nonce,
146 ),
147 $url
148 );
149 $later_link = add_query_arg(
150 array(
151 'plugin' => 'gmap-embed',
152 'later' => true,
153 'wgm_review_nonce' => $nonce
154 ),
155 $url
156 );
157 ?>
158 <div class="gmap_embed_review_section notice notice-success">
159 <?php //phpscs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?>
160 <img src="<?php echo esc_url(WGM_PLUGIN_URL . 'admin/assets/images/gmap_embed_logo.jpg'); ?>" width="60"
161 style="float: left;margin: 9px 9px 0 5px !important" />
162 <p>
163 <?php
164 echo wp_kses(
165 sprintf(
166 /* translators: %1$s: Plugin name */
167 __("<span style='color:green;'>We hope you're enjoying using <b style='color:#007cba'>%1\$s</b> plugin. Could you please give us a BIG favour and give it a 5-star rating on WordPress to help us spread the word and boost our motivation!</span>", 'gmap-embed'),
168 'WP Google Map'
169 ),
170 array(
171 'span' => array('style' => array()),
172 'b' => array('style' => array()),
173 )
174 );
175 ?>
176 </p>
177 <ul>
178 <li style="display: inline;margin-right:15px;"><a style="text-decoration: none"
179 href="<?php echo esc_url('https://wpgooglemap.com/wp-review-forum?utm_source=wp_admin&utm_medium=admin_link&utm_campaign=review_notice'); ?>"
180 target="_blank"><span class="dashicons dashicons-external"></span> Ok, you deserve it!</a></li>
181 <li style="display: inline;margin-right:15px;"><a style="text-decoration: none"
182 href="<?php echo esc_url($dismiss_link); ?>"><span class="dashicons dashicons-smiley"></span> I
183 already did</a></li>
184 <li style="display: inline;margin-right:15px;"><a style="text-decoration: none"
185 href="<?php echo esc_url($later_link); ?>"><span class="dashicons dashicons-calendar-alt"></span>
186 <?php esc_html_e('Maybe Later', 'gmap-embed'); ?></a></li>
187 <li style="display: inline;margin-right:15px;"><a style="text-decoration: none"
188 href="<?php echo esc_url('https://wpgooglemap.com/wp-support-forum?utm_source=wp_admin&utm_medium=admin_link&utm_campaign=review_notice'); ?>"
189 target="_blank"><span class="dashicons dashicons-external"></span>
190 <?php esc_html_e('I need help', 'gmap-embed'); ?></a></li>
191 <li style="display: inline;margin-right:15px;"><a style="text-decoration: none"
192 href="<?php echo esc_url($dismiss_link); ?>"><span class="dashicons dashicons-dismiss"></span>
193 <?php esc_html_e('Never show again', 'gmap-embed'); ?></a></li>
194 </ul>
195 </div>
196 <?php
197 }
198 }
199 }
200