PluginProbe ʕ •ᴥ•ʔ
Advanced 301 and 302 Redirect / 1.7.0
Advanced 301 and 302 Redirect v1.7.0
1.7.0 trunk 1.0.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.7 1.6.8 1.6.9
advanced-301-and-302-redirect / notices.php
advanced-301-and-302-redirect Last commit date
images 4 weeks ago include 4 weeks ago index.php 4 weeks ago notices.php 4 weeks ago readme.txt 2 days ago
notices.php
278 lines
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <?php
3
4 // ============================================================
5 // replace the prefix when adding to new plugin "yydev_redirect_"
6 // ============================================================
7
8 $yydev_redirect_notice_info_array = array(
9 'plugin_name' => "Advanced 301/302 Redirect", // the name of the plugin
10 'developer_website' => "https://www.yydevelopment.com", // link to the developer website page
11 'plugin_review_page' => "https://wordpress.org/plugins/advanced-301-and-302-redirect/#reviews", // link to the plugin support page
12 'plugin_support_link' => "https://wordpress.org/support/plugin/advanced-301-and-302-redirect/", // link to the plugin review page
13 'plugin_donate_link' => "https://www.yydevelopment.com/coffee-break/?plugin=advanced-301-and-302-redirect", // link to the plugin donate page
14 'company_plugins_page' => "https://www.yydevelopment.com/yydevelopment-wordpress-plugins/", // link to the main company plugins page
15 'icon_image_path' => plugins_url() . "/" . basename( dirname( __FILE__ ) ) . "/images/icon.png", // link to the plugin icon
16 'save_database_time_stamp_name' => "yydev_redirect_timestamp", // database input name to save data
17 'send_mail_in_days' => (30 * 60 * 60 * 24) + strtotime("now"), // the amount of time after we show the notice (4 months)
18 );
19
20 // ================================================
21 // creating time stamp if it doesn't exists
22 // ================================================
23
24 // loading the plugin version from the database
25 $plugin_db_timestamp = get_option($yydev_redirect_notice_info_array['save_database_time_stamp_name']);
26
27 // checking if the plugin version exists on the dabase
28 // and checking if the database version equal to the plugin version $plugin_version
29 if( empty($plugin_db_timestamp) ) {
30
31 // update the plugin version in the database
32 update_option($yydev_redirect_notice_info_array['save_database_time_stamp_name'], $yydev_redirect_notice_info_array['send_mail_in_days']);
33 $plugin_db_timestamp = get_option($yydev_redirect_notice_info_array['save_database_time_stamp_name']);
34
35 } // if( empty($plugin_db_timestamp) ) {
36
37 // add_action('plugins_loaded', 'my_awesome_plugin_check_version');
38
39 // ================================================
40 // ajax function for when the visitor click on the buttons
41 // ================================================
42
43 // when the visitor want to stop getting the messages
44 function yydev_redirect_stop_notice_forever() {
45
46 // Verify nonce for security
47 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'yydev_redirect_nonce')) {
48 wp_die('Security check failed');
49 }
50
51 // Check if user has proper capabilities
52 if (!current_user_can('manage_options')) {
53 wp_die('Insufficient permissions');
54 }
55
56 global $yydev_redirect_notice_info_array;
57 update_option($yydev_redirect_notice_info_array['save_database_time_stamp_name'], 'stop');
58 wp_die(); // Use wp_die() instead of die() for WordPress AJAX
59
60 } // function yydev_redirect_stop_notice_forever() {
61
62 add_action( 'wp_ajax_yydev_redirect_stop_notice_forever', 'yydev_redirect_stop_notice_forever' );
63
64
65 // when the visitor ask to get the message in the future
66 function yydev_redirect_stop_notice_for_now() {
67
68 // Verify nonce for security
69 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'yydev_redirect_nonce')) {
70 wp_die('Security check failed');
71 }
72
73 // Check if user has proper capabilities
74 if (!current_user_can('manage_options')) {
75 wp_die('Insufficient permissions');
76 }
77
78 global $yydev_redirect_notice_info_array;
79 update_option($yydev_redirect_notice_info_array['save_database_time_stamp_name'], $yydev_redirect_notice_info_array['send_mail_in_days']);
80 wp_die(); // Use wp_die() instead of die() for WordPress AJAX
81
82 } // function yydev_redirect_stop_notice_for_now() {
83
84 add_action( 'wp_ajax_yydev_redirect_stop_notice_for_now', 'yydev_redirect_stop_notice_for_now' );
85
86 // ================================================
87 // update the time stamp if the user click on one of the button
88 // ================================================
89
90 // creating a function with admin notice output
91 function yydev_redirect_admin_notice($notice_info_array) {
92
93 global $yydev_redirect_notice_info_array;
94
95 $plugin_name = $yydev_redirect_notice_info_array['plugin_name'];
96 $developer_website = $yydev_redirect_notice_info_array['developer_website'];
97 $plugin_review_page = $yydev_redirect_notice_info_array['plugin_review_page'];
98 $plugin_support_link = $yydev_redirect_notice_info_array['plugin_support_link'];
99 $plugin_donate_link = $yydev_redirect_notice_info_array['plugin_donate_link'];
100 $company_plugins_page = $yydev_redirect_notice_info_array['company_plugins_page'];
101 $icon_image_path = $yydev_redirect_notice_info_array['icon_image_path'];
102 $save_database_time_stamp_name = $yydev_redirect_notice_info_array['save_database_time_stamp_name'];
103
104 ?>
105
106 <script>
107
108 jQuery(document).ready(function($){
109
110 // if the user click on the right close button or ask to stop showing message
111 $(document).on('click', '.yydev_redirect_notice_style .yy-plugin-dismiss-forever', function() {
112 $(this).parent().parent().animate({opacity: "0"}, 200, function() {
113
114 $(this).css("display", "none");
115
116 // use the function and update value using ajax
117 var data = {
118 'action': 'yydev_redirect_stop_notice_forever',
119 'nonce': '<?php echo wp_create_nonce('yydev_redirect_nonce'); ?>'
120 };
121 jQuery.post(ajaxurl, data, function(response) {});
122
123 }); // $( relatedPostBox ).animate({opacity: "0"}, 1000, function() {
124 return false;
125 }); // $(document).on('click', '.yydev_redirect_notice_style notice-dismiss', function() {
126
127 // if the user click on ask me later
128 $(document).on('click', '.yydev_redirect_notice_style .yy-plugin-dismiss-for-now', function() {
129 $(this).parent().parent().animate({opacity: "0"}, 200, function() {
130
131 $(this).css("display", "none");
132
133 // use the function and update value using ajax
134 var data = {
135 'action': 'yydev_redirect_stop_notice_for_now',
136 'nonce': '<?php echo wp_create_nonce('yydev_redirect_nonce'); ?>'
137 };
138 jQuery.post(ajaxurl, data, function(response) {});
139
140 }); // $( relatedPostBox ).animate({opacity: "0"}, 1000, function() {
141 return false;
142 }); // $(document).on('click', '.yydev_redirect_notice_style notice-dismiss', function() {
143
144
145 // if the user click on the right close button or ask to stop showing message
146 $(document).on('click', '.yydev_redirect_notice_style .yy-review-plugin', function() {
147 $(this).parent().parent().animate({opacity: "0"}, 200, function() {
148
149 $(this).css("display", "none");
150
151 // use the function and update value using ajax
152 var data = {
153 'action': 'yydev_redirect_stop_notice_forever',
154 'nonce': '<?php echo wp_create_nonce('yydev_redirect_nonce'); ?>'
155 };
156 jQuery.post(ajaxurl, data, function(response) {});
157
158 }); // $( relatedPostBox ).animate({opacity: "0"}, 1000, function() {
159 }); // $(document).on('click', '.yydev_redirect_notice_style notice-dismiss', function() {
160
161 }); // jQuery(document).ready(function($){
162
163 </script>
164
165 <style>
166
167 .yydev_redirect_notice_style {
168 direction: ltr;
169 text-align: left;
170 position: relative;
171 background: #fff;
172 box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
173 margin: 5px 0px 35px 0px !important;
174 padding: 1px 12px;
175 padding: 15px 30px 15px 35px;
176 opacity: 1;
177 }
178
179 .yydev_redirect_notice_style .yy-bottom-plugin-name {
180 color: #fff;
181 padding: 3px 10px;
182 position: absolute;
183 bottom: -20px;
184 right: 10px;
185 z-index: 999;
186 -moz-border-radius: 0 0 3px 3px;
187 -webkit-border-radius: 0 0 3px 3px;
188 border-radius: 0 0 3px 3px;
189 font-size: 12px;
190 font-weight: bold;
191 cursor: auto;
192 background: #8f8f8f;
193 text-decoration: none;
194 box-shadow: 0 1px 0 #006799;
195 }
196
197 .yydev_redirect_notice_style .notice-buttons {
198 margin: 10px 0px 10px 0px;
199 }
200
201 .yydev_redirect_notice_style .notice-buttons a {
202 max-width: 100%;
203 white-space: normal;
204 margin: 4px 0px 4px 2px;
205 }
206
207 .yydev_redirect_notice_style .yy-notice-dismiss {
208 position: absolute;
209 top: 0;
210 left: auto;
211 right: 1px;
212 border: none;
213 margin: 0;
214 padding: 9px;
215 background: 0 0;
216 color: #72777c;
217 cursor: pointer;
218 }
219
220 .yydev_redirect_notice_style .yy-notice-dismiss::before {
221 background: 0 0;
222 color: #72777c;
223 content: "\f153";
224 display: block;
225 font: normal 16px/20px dashicons;
226 speak: none;
227 height: 20px;
228 text-align: center;
229 width: 20px;
230 -webkit-font-smoothing: antialiased;
231 -moz-osx-font-smoothing: grayscale;
232 }
233
234 .yydev_redirect_notice_style .yy-plugin-icon {
235 max-width: 85px;
236 float: left;
237 margin: 4px 15px 0px -20px;
238 }
239
240 </style>
241
242 <div class="yydev_redirect_notice_style notice notice-info">
243
244 <div class="yy-plugin-icon">
245 <img src="<?php echo esc_url($icon_image_path); ?>" alt="<?php echo esc_attr($plugin_name); ?>" />
246 </div><!--yy-plugin-icon-->
247
248 We are happy to see that you are using our <b><?php echo esc_html($plugin_name); ?></b> plugin for some time now.
249 We at <a href="<?php echo esc_url($developer_website); ?>" target="_blank">YYDevelopment</a> share our plugin for free under GPLv2 license and the only thing we ask in return is that you give a <a href="<?php echo esc_url($plugin_review_page); ?>" target="_blank">positive review</a> if you liked it.
250
251 <div class="notice-buttons">
252 <a class="button button-primary yy-review-plugin" href="<?php echo esc_url($plugin_review_page); ?>" target="_blank">Yes!!! This plugin saved my life I love it and I will be happy to give it 5 stars review :)</a>
253 <a class="button yy-plugin-dismiss-for-now" href="#" target="_blank">I am busy dude ask me again later</a>
254 <a class="button button-secondary yy-plugin-dismiss-forever" href="#" target="_blank">Never show this message again :(</a>
255 </div><!--notice-buttons-->
256
257 If you have problems with the plugin you can submit a ticket at our <a href="<?php echo esc_url($plugin_support_link); ?>" target="_blank">plugin support page</a>.
258 You are also welcome to check our other <a href="<?php echo esc_url($company_plugins_page); ?>" target="_blank">free wordpress plugins</a>. And if you want to help support this FREE plugins <a target="_blank" href="<?php echo esc_url($plugin_donate_link); ?>">buy us a coffee</a>.
259
260 <div class="yy-bottom-plugin-name "><?php echo esc_html($plugin_name); ?> Plugin</div>
261
262 </div><!--yydev_redirect_notice_style-->
263
264 <?php
265
266 } // function yydev_redirect_admin_notice() {
267
268 // checking for global value that stop all plugins notices
269 $yydev_stop_plugins_notice = get_option('yydev_stop_plugins_notice');
270
271 if( !empty($plugin_db_timestamp) && ($plugin_db_timestamp != "stop") && ($plugin_db_timestamp < strtotime("now")) && ($yydev_stop_plugins_notice != 1) ) {
272
273 // output the admin notice on the wordpress pages
274 add_action( 'admin_notices', 'yydev_redirect_admin_notice' );
275
276 } // if( !empty($plugin_db_timestamp) && ($plugin_db_timestamp != "stop") && ($plugin_db_timestamp < strtotime("now")) && ($yydev_stop_plugins_notice != 1) ) {
277
278 ?>