PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 4.0.8
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v4.0.8
4.2.5 4.2.4 trunk 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.2 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8 3.8.1 3.8.10 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.9.1 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.5.1 4.0.6 4.0.6.1 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.2.1 4.2.2 4.2.3
widget-options / includes / admin / notices.php
widget-options / includes / admin Last commit date
settings 1 year ago globals.php 2 years ago import-export.php 2 years ago notices.php 1 year ago welcome.php 2 years ago
notices.php
247 lines
1 <?php
2
3 /**
4 * Handles additional widget tab options
5 * run on __construct function
6 */
7
8 // Exit if accessed directly
9 if (!defined('ABSPATH')) exit;
10
11
12 /**
13 * Admin Messages
14 * @return void
15 */
16 if (!function_exists('widgetopts_admin_notices')) :
17 function widgetopts_admin_notices()
18 {
19 if (!current_user_can('update_plugins'))
20 return;
21
22 //show rating notice to page that matters most
23 global $pagenow;
24 if (!in_array($pagenow, array('widgets.php', 'options-general.php'))) {
25 return;
26 }
27
28 if ($pagenow == 'options-general.php' && function_exists('get_current_screen')) {
29 $screen = get_current_screen();
30 if (isset($screen->base) && $screen->base != 'settings_page_widgetopts_plugin_settings') {
31 return;
32 }
33 }
34
35 $install_date = get_option('widgetopts_installDate');
36 $saved = get_option('widgetopts_RatingDiv');
37 $display_date = date('Y-m-d h:i:s');
38 $datetime1 = new DateTime($install_date);
39 $datetime2 = new DateTime($display_date);
40 $diff_intrval = round(($datetime2->format('U') - $datetime1->format('U')) / (60 * 60 * 24));
41 if ('yes' != $saved && $diff_intrval >= 7) {
42 echo '<div class="widgetopts_notice updated" style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);">
43 <p>Well done! You have been enjoying <strong>Widget Options</strong> for more than a week.
44 <br>
45 Do you love it? Are you over the moon? Will you give us a <a href="https://wordpress.org/support/view/plugin-reviews/widget-options" class="thankyou" target="_blank" title="Ok, you deserved it" style="font-weight:bold;"><strong>5-star rating</strong></a> on WordPress?
46 </br>
47 Your review is essential to the Widget Options community and our ongoing succes.
48 <br><br>
49 Thank you so much! � Your Widget Options Team
50 <ul>
51 <li><a href="https://wordpress.org/support/view/plugin-reviews/widget-options" class="thankyou" target="_blank" title="Ok, you deserved it" style="font-weight:bold;">' . __('Definitely. Widget Options is the best!', 'widget-options') . '</a></li>
52 <li><a href="javascript:void(0);" class="widgetopts_bHideRating" title="I already did" style="font-weight:bold;">' . __('Already done!', 'widget-options') . '</a></li>
53 <li><a href="https://widget-options.com/contact/" class="thankyou" target="_blank" title="Ok, you deserved it" style="font-weight:bold;">' . __("Not convinced yet. Still think about it.", 'widget-options') . '</a></li>
54 <li><a href="javascript:void(0);" class="widgetopts_bHideRating" title="No, not good enough" style="font-weight:bold;">' . __("Dismiss", 'widget-options') . '</a></li>
55 </ul>
56 </div>
57 <script>
58 jQuery( document ).ready(function( $ ) {
59
60 jQuery(\'.widgetopts_bHideRating\').click(function(){
61 var data={\'action\':\'widgetopts_hideRating\'}
62 jQuery.ajax({
63
64 url: "' . admin_url('admin-ajax.php') . '",
65 type: "post",
66 data: data,
67 dataType: "json",
68 async: !0,
69 success: function(e) {
70 if (e=="success") {
71 jQuery(\'.widgetopts_notice\').slideUp(\'slow\');
72
73 }
74 }
75 });
76 })
77
78 });
79 </script>
80 ';
81 }
82 }
83 add_action('admin_notices', 'widgetopts_admin_notices');
84 endif;
85
86 if (!function_exists('widgetopts_display_free_liecnse_admin_notice')) {
87 /**
88 * Show a notice to subscribe to newsletter
89 */
90 function widgetopts_display_free_liecnse_admin_notice()
91 {
92 $license_key = get_option('widgetopts_free_license');
93 if (!current_user_can('update_plugins') || !empty($license_key))
94 return;
95
96 //show rating notice to page that matters most
97 global $pagenow;
98 if (!in_array($pagenow, array('options-general.php'))) {
99 return;
100 }
101
102 if ($pagenow == 'options-general.php' && function_exists('get_current_screen')) {
103 $screen = get_current_screen();
104 if (isset($screen->base) && $screen->base != 'settings_page_widgetopts_plugin_settings') {
105 return;
106 }
107 }
108
109 $htmlNotice = '
110 <div class="notice widgetopts-notice" style="border-left-color: #064466">
111 <form method="post">
112 <h3>' . __( 'Free License', 'widget-options' ) .'</h3>
113 <p>' . __( "You're currently using the free version of Widget Options. To register a free license for the plugin, please fill in your email below. This is not required but helps us support you better.", 'widget-options' ) . '</p>
114 <input type="text" name="email" placeholder="' . __( 'Email Address', 'widget-options' ) . '" />
115 ' . wp_nonce_field( 'wo_free_license_action', 'wo_free_license_field' ) . '
116 <input type="submit" name="wo_free_license_activator" value="Register Free License" class="button button-primary" />
117 <input type="button" name="wo_free_license_dismiss" value="Dismiss" class="button button-secondary" /><br><br>
118 <input type="checkbox" name="wo_free_license_subscribe" value="1" checked /> Add me to your newsletter and keep me updated whenever you release news, updates and promos.
119 <p><small>* ' . __( 'Your email is secure with us! We will keep you updated on new feature releases and major announcements about Widget Options.', 'widget-options' ) . '</small></p>
120 </form>
121 <form method="post" id="wo_free_license_dismiss_form">
122 ' . wp_nonce_field( 'wo_free_license_dismiss', 'wo_free_license_dismiss_field' ) . '
123 <input type="hidden" name="wo_free_dismiss" value="1" />
124 </form>
125 </div>
126 <script>
127 jQuery( document ).ready(function( $ ) {
128
129 jQuery(\'input[name="wo_free_license_dismiss"]\').on("click", function(e){
130 e.preventDefault();
131 jQuery("#wo_free_license_dismiss_form").submit();
132 });
133
134 });
135 </script>
136 ';
137
138 echo $htmlNotice;
139 }
140 add_action('admin_notices', 'widgetopts_display_free_liecnse_admin_notice');
141
142 function widgetopts_activate_free_liecnse () {
143 if ( ! empty( $_POST['wo_free_license_activator'] ) ) {
144 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'wo_free_license_field' ] ) ), 'wo_free_license_action' ) ) {
145 return;
146 }
147
148 $email = sanitize_email( wp_unslash( $_POST['email'] ) );
149
150 if ( is_email( $email ) ) {
151 $user = get_user_by( 'email', $email );
152 $first_name = '';
153 $last_name = '';
154 $url = rawurlencode( home_url() );
155
156 if ( is_a( $user, 'WP_User' ) ) {
157 $first_name = $user->first_name;
158 $last_name = $user->last_name;
159 }
160
161 if ( ! empty( $_POST['wo_free_license_subscribe'] ) ) {
162 // Make request, save key.
163 $request = wp_remote_post(
164 'https://widget-options.com/wp-admin/admin-ajax.php',
165 array(
166 'body' =>
167 array(
168 'action' => 'wo_free_license',
169 'email_address' => $email,
170 'fname' => $first_name,
171 'lname' => $last_name,
172 'url' => $url,
173 )
174 )
175 );
176
177 if ( ! is_wp_error( $request ) ) {
178 $license = $email;
179
180 if ( ! empty( $license ) ) {
181 update_option( 'widgetopts_free_license', sanitize_text_field( $license ) );
182
183 add_action(
184 'admin_notices',
185 function() {
186 ?>
187 <div class="notice notice-success">
188 <p><?php esc_html_e( 'Free license activated!', 'widget-options' ); ?></p>
189 </div>
190 <?php
191 }
192 );
193 }
194 } else {
195 add_action(
196 'admin_notices',
197 function() {
198 ?>
199 <div class="notice notice-error">
200 <p><?php esc_html_e( 'Something went wrong! Try again later.', 'widget-options' ); ?></p>
201 </div>
202 <?php
203 }
204 );
205 }
206 } else {
207 $license = $email;
208
209 if ( ! empty( $license ) ) {
210 update_option( 'widgetopts_free_license', sanitize_text_field( $license ) );
211
212 add_action(
213 'admin_notices',
214 function() {
215 ?>
216 <div class="notice notice-success">
217 <p><?php esc_html_e( 'Free license activated!', 'widget-options' ); ?></p>
218 </div>
219 <?php
220 }
221 );
222 }
223 }
224 } else {
225 add_action(
226 'admin_notices',
227 function() {
228 ?>
229 <div class="notice notice-error">
230 <p><?php esc_html_e( 'Invalid email address!', 'widget-options' ); ?></p>
231 </div>
232 <?php
233 }
234 );
235 }
236 }
237 if ( ! empty( $_POST['wo_free_dismiss'] ) ) {
238 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'wo_free_license_dismiss_field' ] ) ), 'wo_free_license_dismiss' ) ) {
239 return;
240 }
241
242 update_option( 'widgetopts_free_license', sanitize_text_field( 'NA' ) );
243 }
244 }
245 add_action( 'admin_init', 'widgetopts_activate_free_liecnse' );
246 }
247