|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Store the time when the float bar was hidden so it won't show again for 14 days. |
|
4
|
|
|
*/ |
|
5
|
|
|
function monsterinsights_mark_floatbar_hidden() { |
|
6
|
|
|
check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
7
|
|
|
update_option( 'monsterinsights_float_bar_hidden', time() ); |
|
8
|
|
|
wp_send_json_success(); |
|
9
|
|
|
} |
|
10
|
|
|
|
|
11
|
|
|
add_action( 'wp_ajax_monsterinsights_hide_floatbar', 'monsterinsights_mark_floatbar_hidden' ); |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Store the time when the float bar was hidden so it won't show again for 14 days. |
|
15
|
|
|
*/ |
|
16
|
|
|
function monsterinsights_get_floatbar() { |
|
17
|
|
|
check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
18
|
|
|
|
|
19
|
|
|
$show_floatbar = get_option( 'monsterinsights_float_bar_hidden', 0 ); |
|
20
|
|
|
if ( time() - $show_floatbar > 14 * DAY_IN_SECONDS ) { |
|
21
|
|
|
$show_floatbar = true; |
|
22
|
|
|
} else { |
|
23
|
|
|
$show_floatbar = false; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
wp_send_json( array( |
|
27
|
|
|
'show' => $show_floatbar, |
|
28
|
|
|
) ); |
|
29
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
add_action( 'wp_ajax_monsterinsights_get_floatbar', 'monsterinsights_get_floatbar' ); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Admin menu tooltip. |
|
36
|
|
|
*/ |
|
37
|
|
|
function monsterinsights_get_admin_menu_tooltip() { |
|
38
|
|
|
|
|
39
|
|
|
$show_tooltip = get_option( 'monsterinsights_admin_menu_tooltip', 0 ); |
|
40
|
|
|
$activated = get_option( 'monsterinsights_over_time', array() ); |
|
41
|
|
|
$ua_code = monsterinsights_get_ua(); |
|
42
|
|
|
|
|
43
|
|
|
if ( monsterinsights_is_reports_page() || monsterinsights_is_settings_page() ) { |
|
44
|
|
|
// Don't show on MI pages. |
|
45
|
|
|
return; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if ( $show_tooltip && $show_tooltip + 30 * DAY_IN_SECONDS > time() ) { |
|
49
|
|
|
// Dismissed less than 30 days ago. |
|
50
|
|
|
return; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
if ( empty( $activated['installed_date'] ) || ( $activated['installed_date'] + 30 * DAY_IN_SECONDS > time() ) || empty( $ua_code ) ) { |
|
54
|
|
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
// More than 30 days since it was installed & is tracking. |
|
57
|
|
|
$url = monsterinsights_get_upgrade_link( 'menu-tooltip', 'upgrade' ); |
|
58
|
|
|
?> |
|
59
|
|
|
<div id="monterinsights-admin-menu-tooltip" class="monterinsights-admin-menu-tooltip-hide"> |
|
60
|
|
|
<div class="monsterinsights-admin-menu-tooltip-header"> |
|
61
|
|
|
<span class="monsterinsights-admin-menu-tooltip-icon"><span |
|
62
|
|
|
class="dashicons dashicons-megaphone"></span></span> |
|
63
|
|
|
<?php esc_html_e( 'Get Better Insights. Grow FASTER!', 'google-analytics-for-wordpress' ); ?> |
|
64
|
|
|
<a href="#" class="monsterinsights-admin-menu-tooltip-close"><span |
|
65
|
|
|
class="dashicons dashicons-dismiss"></span></a> |
|
66
|
|
|
</div> |
|
67
|
|
|
<div class="monsterinsights-admin-menu-tooltip-content"> |
|
68
|
|
|
<strong><?php esc_html_e( 'Grow Your Business with MonsterInsights Pro', 'google-analytics-for-wordpress' ); ?></strong> |
|
69
|
|
|
<p><?php esc_html_e( 'It\'s easy to double your traffic and sales when you know exactly how people find and use your website.', 'google-analytics-for-wordpress' ); ?></p> |
|
70
|
|
|
<p><?php esc_html_e( 'MonsterInsights Pro shows you the stats that matter, so you can boost your business growth!', 'google-analytics-for-wordpress' ); ?></p> |
|
71
|
|
|
<p> |
|
72
|
|
|
<?php |
|
73
|
|
|
// Translators: makes text bold. |
|
74
|
|
|
printf( esc_html__( '%1$sBonus:%2$s You also get 50%% off discount for being a loyal MonsterInsights Lite user.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>' ); |
|
75
|
|
|
?> |
|
76
|
|
|
</p> |
|
77
|
|
|
<p> |
|
78
|
|
|
<a href="<?php echo esc_url( $url ); ?>" |
|
79
|
|
|
class="button button-primary"><?php esc_html_e( 'Upgrade to MonsterInsights Pro', 'google-analytics-for-wordpress' ); ?></a> |
|
80
|
|
|
</p> |
|
81
|
|
|
</div> |
|
82
|
|
|
</div> |
|
83
|
|
|
<style type="text/css"> |
|
84
|
|
|
#monterinsights-admin-menu-tooltip { |
|
85
|
|
|
position: absolute; |
|
86
|
|
|
left: 100%; |
|
87
|
|
|
top: 100%; |
|
88
|
|
|
background: #fff; |
|
89
|
|
|
margin-left: 16px; |
|
90
|
|
|
width: 350px; |
|
91
|
|
|
box-shadow: 0px 4px 7px 0px #ccc; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
#monterinsights-admin-menu-tooltip:before { |
|
95
|
|
|
content: ''; |
|
96
|
|
|
width: 0; |
|
97
|
|
|
height: 0; |
|
98
|
|
|
border-style: solid; |
|
99
|
|
|
border-width: 12px 12px 12px 0; |
|
100
|
|
|
border-color: transparent #fff transparent transparent; |
|
101
|
|
|
position: absolute; |
|
102
|
|
|
right: 100%; |
|
103
|
|
|
top: 130px; |
|
104
|
|
|
z-index: 10; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
#monterinsights-admin-menu-tooltip:after { |
|
108
|
|
|
content: ''; |
|
109
|
|
|
width: 0; |
|
110
|
|
|
height: 0; |
|
111
|
|
|
border-style: solid; |
|
112
|
|
|
border-width: 13px 13px 13px 0; |
|
113
|
|
|
border-color: transparent #ccc transparent transparent; |
|
114
|
|
|
position: absolute; |
|
115
|
|
|
right: 100%; |
|
116
|
|
|
margin-left: -1px; |
|
117
|
|
|
top: 129px; |
|
118
|
|
|
z-index: 5; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
#monterinsights-admin-menu-tooltip.monsterinsights-tooltip-arrow-top:before { |
|
122
|
|
|
top: 254px; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
#monterinsights-admin-menu-tooltip.monsterinsights-tooltip-arrow-top:after { |
|
126
|
|
|
top: 253px; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
.monsterinsights-admin-menu-tooltip-header { |
|
130
|
|
|
background: #03a0d2; |
|
131
|
|
|
padding: 5px 12px; |
|
132
|
|
|
font-size: 14px; |
|
133
|
|
|
font-weight: 700; |
|
134
|
|
|
font-family: Arial, Helvetica, "Trebuchet MS", sans-serif; |
|
135
|
|
|
color: #fff; |
|
136
|
|
|
line-height: 1.6; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
.monsterinsights-admin-menu-tooltip-icon { |
|
140
|
|
|
background: #fff; |
|
141
|
|
|
border-radius: 50%; |
|
142
|
|
|
width: 28px; |
|
143
|
|
|
height: 25px; |
|
144
|
|
|
display: inline-block; |
|
145
|
|
|
color: #03a0d2; |
|
146
|
|
|
text-align: center; |
|
147
|
|
|
padding: 3px 0 0; |
|
148
|
|
|
margin-right: 6px; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
.monterinsights-admin-menu-tooltip-hide { |
|
152
|
|
|
display: none; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
.monsterinsights-admin-menu-tooltip-content { |
|
156
|
|
|
padding: 20px 15px 7px; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
.monsterinsights-admin-menu-tooltip-content strong { |
|
160
|
|
|
font-size: 14px; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
.monsterinsights-admin-menu-tooltip-content p strong { |
|
164
|
|
|
font-size: 13px; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
.monsterinsights-admin-menu-tooltip-close { |
|
168
|
|
|
color: #fff; |
|
169
|
|
|
text-decoration: none; |
|
170
|
|
|
position: absolute; |
|
171
|
|
|
right: 10px; |
|
172
|
|
|
top: 12px; |
|
173
|
|
|
display: block; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
.monsterinsights-admin-menu-tooltip-close:hover { |
|
177
|
|
|
color: #fff; |
|
178
|
|
|
text-decoration: none; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
.monsterinsights-admin-menu-tooltip-close .dashicons { |
|
182
|
|
|
font-size: 14px; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
@media ( max-width: 782px ) { |
|
186
|
|
|
#monterinsights-admin-menu-tooltip { |
|
187
|
|
|
display: none; |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
</style> |
|
191
|
|
|
<script type="text/javascript"> |
|
192
|
|
|
if ( 'undefined' !== typeof jQuery ) { |
|
193
|
|
|
jQuery( function ( $ ) { |
|
194
|
|
|
var $tooltip = $( document.getElementById( 'monterinsights-admin-menu-tooltip' ) ); |
|
195
|
|
|
var $menuwrapper = $( document.getElementById( 'adminmenuwrap' ) ); |
|
196
|
|
|
var $menuitem = $( document.getElementById( 'toplevel_page_monsterinsights_reports' ) ); |
|
197
|
|
|
if ( 0 === $menuitem.length ) { |
|
198
|
|
|
$menuitem = $( document.getElementById( 'toplevel_page_monsterinsights_network' ) ); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
if ( $menuitem.length ) { |
|
202
|
|
|
$menuwrapper.append( $tooltip ); |
|
203
|
|
|
$tooltip.removeClass( 'monterinsights-admin-menu-tooltip-hide' ); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
function alignTooltip() { |
|
207
|
|
|
var sticky = $( 'body' ).hasClass( 'sticky-menu' ); |
|
208
|
|
|
|
|
209
|
|
|
var menuitem_pos = $menuitem.position(); |
|
210
|
|
|
var tooltip_top = menuitem_pos.top - 124; |
|
211
|
|
|
if ( sticky && $( window ).height() > $menuwrapper.height() + 150 ) { |
|
212
|
|
|
$tooltip.removeClass( 'monsterinsights-tooltip-arrow-top' ); |
|
213
|
|
|
} else { |
|
214
|
|
|
tooltip_top = menuitem_pos.top - 250; |
|
215
|
|
|
$tooltip.addClass( 'monsterinsights-tooltip-arrow-top' ); |
|
216
|
|
|
} |
|
217
|
|
|
$tooltip.css( { |
|
218
|
|
|
top: tooltip_top + 'px' |
|
219
|
|
|
} ); |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
var $document = $( document ); |
|
223
|
|
|
var timeout = setTimeout( alignTooltip, 10 ); |
|
224
|
|
|
$document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', function () { |
|
225
|
|
|
if ( timeout ) { |
|
226
|
|
|
clearTimeout( timeout ); |
|
227
|
|
|
} |
|
228
|
|
|
timeout = setTimeout( alignTooltip, 10 ); |
|
229
|
|
|
} ); |
|
230
|
|
|
|
|
231
|
|
|
$( '.monsterinsights-admin-menu-tooltip-close' ).on( 'click', function ( e ) { |
|
232
|
|
|
e.preventDefault(); |
|
233
|
|
|
hideTooltip(); |
|
234
|
|
|
} ); |
|
235
|
|
|
|
|
236
|
|
|
function hideTooltip() { |
|
237
|
|
|
$tooltip.addClass( 'monterinsights-admin-menu-tooltip-hide' ); |
|
238
|
|
|
$.post( ajaxurl, { |
|
239
|
|
|
action: 'monsterinsights_hide_admin_menu_tooltip', |
|
240
|
|
|
nonce: '<?php echo esc_js( wp_create_nonce( 'mi-admin-nonce' ) ); ?>', |
|
241
|
|
|
} ); |
|
242
|
|
|
} |
|
243
|
|
|
} ); |
|
244
|
|
|
} |
|
245
|
|
|
</script> |
|
246
|
|
|
<?php |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
add_action( 'adminmenu', 'monsterinsights_get_admin_menu_tooltip' ); |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* Store the time when the float bar was hidden so it won't show again for 14 days. |
|
253
|
|
|
*/ |
|
254
|
|
|
function monsterinsights_mark_admin_menu_tooltip_hidden() { |
|
255
|
|
|
check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
|
256
|
|
|
update_option( 'monsterinsights_admin_menu_tooltip', time() ); |
|
257
|
|
|
wp_send_json_success(); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
add_action( 'wp_ajax_monsterinsights_hide_admin_menu_tooltip', 'monsterinsights_mark_admin_menu_tooltip_hidden' ); |
|
261
|
|
|
|