PluginProbe
Phone Button / 1.0.0
Phone Button v1.0.0
trunk 1.0.0 1.0.1 1.0.3 1.1.0 1.1.1 2.0.0 2.1.0 2.1.1 2.1.2
phone-button / notices.php

notices.php in Phone Button 1.0.0, at notices.php

244 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <?php
3
4 // ============================================================
5 // replace the prefix when adding to new plugin "yydev_phone_btn_"
6 // ============================================================
7
8 $yydev_phone_btn_notice_info_array = array(
9 'plugin_name' => "Phone Button", // 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/phone-button/#reviews", // link to the plugin support page
12 'plugin_support_link' => "https://wordpress.org/support/plugin/phone-button/", // link to the plugin review page
13 'company_plugins_page' => "https://www.yydevelopment.com/yydevelopment-wordpress-plugins/", // link to the main company plugins page
14 'icon_image_path' => plugins_url() . "/" . basename( dirname( __FILE__ ) ) . "/images/icon.png", // link to the plugin icon
15 'save_database_time_stamp_name' => "yydev_phone_btn_timestamp", // database input name to save data
16 'send_mail_in_days' => (4 * 30 * 60 * 60 * 24) + strtotime("now"), // the amount of time after we show the notice (4 months)
17 );
18
19 // ================================================
20 // creating time stamp if it doesn't exists
21 // ================================================
22
23 // loading the plugin version from the database
24 $plugin_db_timestamp = get_option($yydev_phone_btn_notice_info_array['save_database_time_stamp_name']);
25
26 // checking if the plugin version exists on the dabase
27 // and checking if the database version equal to the plugin version $plugin_version
28 if( empty($plugin_db_timestamp) ) {
29
30 // update the plugin version in the database
31 update_option($yydev_phone_btn_notice_info_array['save_database_time_stamp_name'], $yydev_phone_btn_notice_info_array['send_mail_in_days']);
32 $plugin_db_timestamp = get_option($yydev_phone_btn_notice_info_array['save_database_time_stamp_name']);
33
34 } // if( empty($plugin_db_timestamp) ) {
35
36 // add_action('plugins_loaded', 'my_awesome_plugin_check_version');
37
38 // ================================================
39 // ajax function for when the visitor click on the buttons
40 // ================================================
41
42 // when the visitor want to stop getting the messages
43 function yydev_phone_btn_stop_notice_forever() {
44
45 global $yydev_phone_btn_notice_info_array;
46 update_option($yydev_phone_btn_notice_info_array['save_database_time_stamp_name'], 'stop');
47 die(); // we have to end ajax functions with die();
48
49 } // function yydev_phone_btn_stop_notice_forever() {
50
51 add_action( 'wp_ajax_yydev_phone_btn_stop_notice_forever', 'yydev_phone_btn_stop_notice_forever' );
52
53
54 // when the visitor ask to get the message in the future
55 function yydev_phone_btn_stop_notice_for_now() {
56
57 global $yydev_phone_btn_notice_info_array;
58 update_option($yydev_phone_btn_notice_info_array['save_database_time_stamp_name'], $yydev_phone_btn_notice_info_array['send_mail_in_days']);
59 die(); // we have to end ajax functions with die();
60
61 } // function yydev_phone_btn_stop_notice_for_now() {
62
63 add_action( 'wp_ajax_yydev_phone_btn_stop_notice_for_now', 'yydev_phone_btn_stop_notice_for_now' );
64
65 // ================================================
66 // update the time stamp if the user click on one of the button
67 // ================================================
68
69 // creating a function with admin notice output
70 function yydev_phone_btn_admin_notice($notice_info_array) {
71
72 global $yydev_phone_btn_notice_info_array;
73
74 $plugin_name = $yydev_phone_btn_notice_info_array['plugin_name'];
75 $developer_website = $yydev_phone_btn_notice_info_array['developer_website'];
76 $plugin_review_page = $yydev_phone_btn_notice_info_array['plugin_review_page'];
77 $plugin_support_link = $yydev_phone_btn_notice_info_array['plugin_support_link'];
78 $company_plugins_page = $yydev_phone_btn_notice_info_array['company_plugins_page'];
79 $icon_image_path = $yydev_phone_btn_notice_info_array['icon_image_path'];
80 $save_database_time_stamp_name = $yydev_phone_btn_notice_info_array['save_database_time_stamp_name'];
81
82 ?>
83
84 <script>
85
86 jQuery(document).ready(function($){
87
88 // if the user click on the right close button or ask to stop showing message
89 $(document).on('click', '.yydev_phone_btn_notice_style .yy-plugin-dismiss-forever', function() {
90 $(this).parent().parent().animate({opacity: "0"}, 200, function() {
91
92 $(this).css("display", "none");
93
94 // use the function and update value using ajax
95 var data = {'action': 'yydev_phone_btn_stop_notice_forever'}; // var data = {
96 jQuery.post(ajaxurl, data, function(response) {});
97
98 }); // $( relatedPostBox ).animate({opacity: "0"}, 1000, function() {
99 return false;
100 }); // $(document).on('click', '.yydev_phone_btn_notice_style notice-dismiss', function() {
101
102 // if the user click on ask me later
103 $(document).on('click', '.yydev_phone_btn_notice_style .yy-plugin-dismiss-for-now', function() {
104 $(this).parent().parent().animate({opacity: "0"}, 200, function() {
105
106 $(this).css("display", "none");
107
108 // use the function and update value using ajax
109 var data = {'action': 'yydev_phone_btn_stop_notice_for_now'}; // var data = {
110 jQuery.post(ajaxurl, data, function(response) {});
111
112 }); // $( relatedPostBox ).animate({opacity: "0"}, 1000, function() {
113 return false;
114 }); // $(document).on('click', '.yydev_phone_btn_notice_style notice-dismiss', function() {
115
116
117 // if the user click on the right close button or ask to stop showing message
118 $(document).on('click', '.yydev_phone_btn_notice_style .yy-review-plugin', function() {
119 $(this).parent().parent().animate({opacity: "0"}, 200, function() {
120
121 $(this).css("display", "none");
122
123 // use the function and update value using ajax
124 var data = {'action': 'yydev_phone_btn_stop_notice_forever'}; // var data = {
125 jQuery.post(ajaxurl, data, function(response) {});
126
127 }); // $( relatedPostBox ).animate({opacity: "0"}, 1000, function() {
128 }); // $(document).on('click', '.yydev_phone_btn_notice_style notice-dismiss', function() {
129
130 }); // jQuery(document).ready(function($){
131
132 </script>
133
134 <style>
135
136 .yydev_phone_btn_notice_style {
137 direction: ltr;
138 text-align: left;
139 position: relative;
140 background: #fff;
141 box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
142 margin: 5px 0px 35px 0px !important;
143 padding: 1px 12px;
144 padding: 15px 30px 15px 35px;
145 opacity: 1;
146 }
147
148 .yydev_phone_btn_notice_style .yy-bottom-plugin-name {
149 color: #fff;
150 padding: 3px 10px;
151 position: absolute;
152 bottom: -20px;
153 right: 10px;
154 z-index: 999;
155 -moz-border-radius: 0 0 3px 3px;
156 -webkit-border-radius: 0 0 3px 3px;
157 border-radius: 0 0 3px 3px;
158 font-size: 12px;
159 font-weight: bold;
160 cursor: auto;
161 background: #8f8f8f;
162 text-decoration: none;
163 box-shadow: 0 1px 0 #006799;
164 }
165
166 .yydev_phone_btn_notice_style .notice-buttons {
167 margin: 10px 0px 10px 0px;
168 }
169
170 .yydev_phone_btn_notice_style .notice-buttons a {
171 max-width: 100%;
172 white-space: normal;
173 margin: 4px 0px 4px 2px;
174 }
175
176 .yydev_phone_btn_notice_style .yy-notice-dismiss {
177 position: absolute;
178 top: 0;
179 left: auto;
180 right: 1px;
181 border: none;
182 margin: 0;
183 padding: 9px;
184 background: 0 0;
185 color: #72777c;
186 cursor: pointer;
187 }
188
189 .yydev_phone_btn_notice_style .yy-notice-dismiss::before {
190 background: 0 0;
191 color: #72777c;
192 content: "\f153";
193 display: block;
194 font: normal 16px/20px dashicons;
195 speak: none;
196 height: 20px;
197 text-align: center;
198 width: 20px;
199 -webkit-font-smoothing: antialiased;
200 -moz-osx-font-smoothing: grayscale;
201 }
202
203 .yydev_phone_btn_notice_style .yy-plugin-icon {
204 max-width: 85px;
205 float: left;
206 margin: 4px 15px 0px -20px;
207 }
208
209 </style>
210
211 <div class="yydev_phone_btn_notice_style notice notice-info">
212
213 <div class="yy-plugin-icon">
214 <img src="<?php echo $icon_image_path; ?>" alt="<?php echo $plugin_name; ?>" />
215 </div><!--yy-plugin-icon-->
216
217 We are happy to see that you are using our <b><?php echo $plugin_name; ?></b> plugin for some time now.
218 We at <a href="<?php echo $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 $plugin_review_page; ?>" target="_blank">positive review</a> if you liked it.
219
220 <div class="notice-buttons">
221 <a class="button button-primary yy-review-plugin" href="<?php echo $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>
222 <a class="button yy-plugin-dismiss-for-now" href="#" target="_blank">I am busy dude ask me again later</a>
223 <a class="button button-secondary yy-plugin-dismiss-forever" href="#" target="_blank">Never show this message again :(</a>
224 </div><!--notice-buttons-->
225
226 If you have problems with the plugin you can submit a ticket at our <a href="<?php echo $plugin_support_link; ?>" target="_blank">plugin support page</a> and we will be happy to help.
227 You are also welcome to check <a href="<?php echo $company_plugins_page; ?>" target="_blank">our other free wordpress plugins</a>.
228
229 <div class="yy-bottom-plugin-name "><?php echo $plugin_name; ?> Plugin</div>
230
231 </div><!--yydev_phone_btn_notice_style-->
232
233 <?php
234
235 } // function yydev_phone_btn_admin_notice() {
236
237 if( !empty($plugin_db_timestamp) && ($plugin_db_timestamp != "stop") && ($plugin_db_timestamp < strtotime("now")) ) {
238
239 // output the admin notice on the wordpress pages
240 add_action( 'admin_notices', 'yydev_phone_btn_admin_notice' );
241
242 } // if( !empty($plugin_db_timestamp) && ($plugin_db_timestamp != "stop") && ($plugin_db_timestamp < strtotime("now")) ) {
243
244 ?>