forked from Benunc/better-click-to-tweet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-nags.php
237 lines (189 loc) · 8.08 KB
/
admin-nags.php
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
function bctt_alerts() {
if (is_plugin_active('better-click-to-tweet-premium-styles/better-click-to-tweet-premium-styles.php')) {
return;
}
$screen = get_current_screen();
$screenparent = $screen->parent_file;
if ( $screenparent == 'plugins.php' && current_user_can( 'install_plugins' ) ) {
$user_id = wp_get_current_user()->ID;
$has_dismissed = get_user_meta( $user_id, 'bctt_has_dismissed_nag', true );
if ( ! $has_dismissed && ! bctt_add_custom_style_option() ) {
//add style inline so that it isn't enqueued if not used
?>
<style>
span.bctt-addon-nag-header {
font-size: large;
font-weight: bold;
}
.updated.bctt-addon-nag {
padding: 1em;
}
p.bctt-addon-nag-copy {
}
ul.bctt-addon-nag-list {
list-style-type: none;
margin-left: 2em;
}
.bctt-addon-nag-list li:before {
content: "\f155";
display: inline-block;
-webkit-font-smoothing: antialiased;
font: normal 16px/1 'dashicons';
color: #46b450;
margin-right: 10px;
word-wrap: break-word;
}
.bctt-addon-nag-dismiss {
float: right;
text-decoration: none;
}
.bctt-nag-photo {
float: right;
margin:0;
max-height:105px;
max-width:98%;
}
@media screen and (max-width: 782px) {
.bctt-nag-photo {
float:none;
}
}
.bctt-nag-purchase-link {
font-size: large;
}
</style>
<div class="updated bctt-addon-nag">
<a href="<?php
//The Dismiss Button.
$nag_meta_key = 'bctt_has_dismissed_nag';
$nag_admin_dismiss_url = 'plugins.php?' . $nag_meta_key . '=0';
echo esc_url( admin_url( $nag_admin_dismiss_url ) ); ?>" class="dismiss bctt-addon-nag-dismiss">Dismiss this <span
class="dashicons dashicons-dismiss"></span></a>
<h3
class="bctt-addon-nag-header"><?php esc_html_e( 'Add Premium Style to your Better Click To Tweet boxes!', 'better-click-to-tweet' ) ?></h3>
<a href="http://benlikes.us/bcttnag"
target="_blank"><img class="bctt-nag-photo" src="<?php echo esc_url( plugins_url() . '/better-click-to-tweet/assets/img/premium_style.png' ); ?>"/></a>
<p class="bctt-addon-nag-copy"><?php esc_attr_e( 'Choose from multiple options when styling your Better Click To Tweet boxes, with no code.', 'better-click-to-tweet' ) ?></p>
<ul class="bctt-addon-nag-list">
<li><?php esc_html_e( 'Make your Better Click To Tweet boxes stand out.', 'better-click-to-tweet' ) ?></li>
<li><?php esc_html_e( 'Get more clicks and tweets.', 'better-click-to-tweet' ) ?></li>
<li><?php esc_html_e( 'Support the development of Better Click To Tweet!', 'better-click-to-tweet' ) ?></li>
</ul>
<p class="bctt-addon-nag-copy">
<a class="bctt-nag-purchase-link" href="http://benlikes.us/bcttnag"
target="_blank"><?php esc_html_e( 'Purchase it today', 'better-click-to-tweet' ) ?></a> <?php esc_html_e( 'Save 8% with the code NAGSareTHEbest', 'better-click-to-tweet') ?></p>
</div>
<?php
}
}
}
// Commented out in 5.8.1 to try the other new nag for a bit.
// add_action( 'admin_notices', 'bctt_alerts' );
function bctt_addon_notice_ignore() {
/**
* If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
* See here: http://codex.wordpress.org/Function_Reference/add_user_meta
*/
if ( isset( $_GET['bctt_has_dismissed_nag'] ) && '0' == $_GET['bctt_has_dismissed_nag'] ) {
//Get the global user
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
add_user_meta( $user_id, 'bctt_has_dismissed_nag', 'true', true );
}
}
// Commented out in 5.8.1 to try the other new nag for a bit.
// add_action( 'current_screen', 'bctt_addon_notice_ignore' );
function bctt_more_alerts() {
if (is_plugin_active('better-click-to-tweet-utm-tags/better-click-to-tweet-utm-tags.php')) {
return;
}
$screen = get_current_screen();
$screenparent = $screen->parent_file;
if ( $screenparent == 'plugins.php' && current_user_can( 'install_plugins' ) ) {
$user_id = wp_get_current_user()->ID;
$has_dismissed = get_user_meta( $user_id, 'bctt_has_dismissed_utm_nag', true );
if ( ! $has_dismissed && ! defined( 'BCTTUTM_VERSION' ) ) {
//add style inline so that it isn't enqueued if not used
?>
<style>
span.bctt-more-addon-nag-header {
font-size: large;
font-weight: bold;
}
.updated.bctt-more-addon-nag {
padding: 1em;
}
p.bctt-more-addon-nag-copy {
}
ul.bctt-more-addon-nag-list {
list-style-type: none;
margin-left: 2em;
}
.bctt-more-addon-nag-list li:before {
content: "\f155";
display: inline-block;
-webkit-font-smoothing: antialiased;
font: normal 16px/1 'dashicons';
color: #46b450;
margin-right: 10px;
word-wrap: break-word;
}
.bctt-more-addon-nag-dismiss {
float: right;
text-decoration: none;
}
.bctt-nag-photo {
float: right;
margin:0;
max-height:105px;
max-width:98%;
}
@media screen and (max-width: 782px) {
.bctt-nag-photo {
float:none;
}
}
.bctt-more-nag-purchase-link {
font-size: large;
}
</style>
<div class="updated bctt-more-addon-nag">
<a href="<?php
//The Dismiss Button.
$nag_meta_key = 'bctt_has_dismissed_utm_nag';
$nag_admin_dismiss_url = 'plugins.php?' . $nag_meta_key . '=0';
echo esc_url( admin_url( $nag_admin_dismiss_url ) ); ?>" class="dismiss bctt-more-addon-nag-dismiss">Dismiss this <span
class="dashicons dashicons-dismiss"></span></a>
<h3
class="bctt-more-addon-nag-header"><?php esc_html_e( 'NEW: Track how well your Better Click To Tweets are performing!', 'better-click-to-tweet' ) ?></h3>
<a href="http://benlikes.us/bcttutmnag"
target="_blank"><img class="bctt-nag-photo" src="<?php echo esc_url( plugins_url() . '/better-click-to-tweet/assets/img/utm-tags.jpg' ); ?>"/></a>
<p class="bctt-more-addon-nag-copy"><?php esc_attr_e( 'Add UTM Codes to the URL that twitter users use to click back to your site!', 'better-click-to-tweet' ) ?></p>
<ul class="bctt-more-addon-nag-list">
<li><?php esc_html_e( 'Determine which BCTT boxes are converting best.', 'better-click-to-tweet' ) ?></li>
<li><?php esc_html_e( 'Configurable site-wide and on individual boxes.', 'better-click-to-tweet' ) ?></li>
<li><?php esc_html_e( 'Works with the block editor and with shortcodes.', 'better-click-to-tweet' ) ?></li>
</ul>
<p class="bctt-more-addon-nag-copy">
<a class="bctt-more-nag-purchase-link" href="http://benlikes.us/bcttutmnag"
target="_blank"><?php esc_html_e( 'Purchase it today', 'better-click-to-tweet' ) ?></a> <?php esc_html_e( 'Save 8% with the code NAGSareTHEbest', 'better-click-to-tweet') ?></p>
</div>
<?php
}
}
}
add_action( 'admin_notices', 'bctt_more_alerts' );
function bctt_more_addon_notice_ignore() {
/**
* If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
* See here: http://codex.wordpress.org/Function_Reference/add_user_meta
*/
if ( isset( $_GET['bctt_has_dismissed_utm_nag'] ) && '0' == $_GET['bctt_has_dismissed_utm_nag'] ) {
//Get the global user
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
add_user_meta( $user_id, 'bctt_has_dismissed_utm_nag', 'true', true );
}
}
add_action( 'current_screen', 'bctt_more_addon_notice_ignore' );