-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnapppt-notice.php
More file actions
60 lines (44 loc) · 2.21 KB
/
Copy pathsnapppt-notice.php
File metadata and controls
60 lines (44 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
if(!defined( 'ABSPATH' )) exit; // Exit if accessed directly
function snapppt_show_review_notice() {
global $snapppt_options;
if(!snapppt_is_setup()) { return false; }
$current_page = get_current_screen()->id;
if($current_page != 'plugins') { return false; }
if(isset($snapppt_options['snapppt_notice_never'])) { return false; }
// when maybe later is selected, we store the date at which it should show again - here we check if that time has elapsed
if(isset($snapppt_options['snapppt_notice_later']) && $snapppt_options['snapppt_notice_later'] > time()) { return false; }
return true;
}
function snapppt_render_review_notice() {
// only showing the review notice on the plugins page
if(!snapppt_show_review_notice()) { return; }
$maybe_later_url = add_query_arg('snapppt-notice-later', '1');
$never_url = add_query_arg('snapppt-notice-never', '1');
$snapppt_notice = <<<EOT
<div class="snapppt-notice notice is-dismissible">
<p class="snapppt-notice-first-line">Get more features! - Would you consider supporting us with a review?</p>
<p class="snapppt-notice-second-line">We promise to <b>return the favour</b> with the latest updates. <a href="http://help.snapppt.com/faq-and-troubleshooting/whats-new" target="_blank">What's New?</a></p>
<p class="snapppt-notice-link-line">
<a href="https://wordpress.org/support/plugin/shop-feed-for-instagram-by-snapppt/reviews/" target="_blank">Yes, I'll leave a review</a>
<a href="$never_url">I've already left one</a>
<a href="$maybe_later_url">Maybe later</a>
<a href="$never_url">Never show again</a>
</p>
</div>
EOT;
echo $snapppt_notice;
}
add_action('admin_notices', 'snapppt_render_review_notice');
function snapppt_handle_notice_action() {
global $snapppt_options;
if(isset($_GET['snapppt-notice-never']) && $_GET['snapppt-notice-never'] == '1') {
$snapppt_options['snapppt_notice_never'] = true;
update_option('snapppt', $snapppt_options);
} elseif(isset($_GET['snapppt-notice-never']) && $_GET['snapppt-notice-later'] == '1') {
$snapppt_options['snapppt_notice_later'] = strtotime("+7 day");
update_option('snapppt', $snapppt_options);
}
}
add_action('admin_init', 'snapppt_handle_notice_action');
?>