Skip to content

Commit ece68d7

Browse files
author
Luca
committed
v1.14
Improved compatibility with WP v4
1 parent acc14b7 commit ece68d7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

lc_update_notifier.php

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
/**
33
* Codecanyon plugin updates notificator *
4-
* version 1.13 *
4+
* version 1.14 *
55
* fully compatible from WP 3.5 *
66
* *
77
* Author: Luca Montanari (LCweb) *
8-
* Site: http://www.projects.lcweb.it/ *
8+
* Site: http://www.lcweb.it/ *
99
* *
1010
**/
1111

@@ -224,7 +224,7 @@ public function upgrade_core_message() {
224224
<table class="update-premium-plugins-table widefat" cellspacing="0">
225225
<tbody class="plugins">
226226
';
227-
227+
228228
foreach($GLOBALS['lcun_to_update'] as $pid => $data) {
229229
echo '
230230
<tr style="box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;">
@@ -259,7 +259,7 @@ public function upgrade_core_message() {
259259
e.preventDefault();
260260
tb_show('Plugin Information: '+ jQuery(this).attr('pcun_name') , '#TB_inline?height=600&width=640&inlineId='+ jQuery(this).attr('rel'));
261261
setTimeout(function() {
262-
jQuery('#TB_window').css('background-color', '#fff');
262+
jQuery('#TB_window').css('background-color', '#fff').css('background-image', 'none');
263263
}, 50);
264264
});
265265
});
@@ -269,7 +269,7 @@ public function upgrade_core_message() {
269269
}
270270

271271

272-
// dinamically add code to show updates
272+
// dinamically add code to show updates in plugins list
273273
public function plugin_list_message() {
274274
global $current_screen;
275275
if(isset($current_screen->base) && $current_screen->base == 'plugins' && is_array($GLOBALS['lcun_to_update'])) {
@@ -287,19 +287,19 @@ public function plugin_list_message() {
287287
$new_ver[] = $data['new_ver'];
288288
$notes[] = addslashes($data['note']);
289289
}
290-
290+
291291
wp_enqueue_script('jquery');
292292
?>
293293
<script type="text/javascript">
294294
var id = ['<?php echo implode("','", $id) ?>'];
295-
var name = ['<?php echo implode("','", $name) ?>'];
295+
var lcun_name = ['<?php echo implode("','", $name) ?>']; // safe name with prefix
296296
var new_ver = ['<?php echo implode("','", $new_ver) ?>'];
297297
var notes = ['<?php echo implode("','", $notes) ?>'];
298298

299299
jQuery(document).ready(function(e) {
300300
jQuery.each(id, function(i, v) {
301301
if(notes[i] != '') {
302-
var pl_note = ' or <a class="lcun_update_note" pcun_name="'+ name[i] +'" rel="pcunh_'+ v +'" href="">view update notes</a>';
302+
var pl_note = ' or <a class="lcun_update_note" pcun_name="'+ lcun_name[i] +'" rel="pcunh_'+ v +'" href="">view update notes</a>';
303303
jQuery('body').append('<div id="pcunh_'+ v +'" style="display: none;">'+ notes[i] +'</div>');
304304
}
305305
else {var pl_note = '';}
@@ -308,19 +308,31 @@ public function plugin_list_message() {
308308
<tr class="plugin-update-tr">\
309309
<td colspan="3" class="plugin-update colspanchange">\
310310
<div class="update-message">\
311-
There is a new version of '+ name[i] +' available. \
312-
<a href="http://codecanyon.net/downloads" title="'+ name[i] +'" target="_blank">Download version '+ new_ver[i] +'</a>'+ pl_note +'.</div>\
311+
There is a new version of '+ lcun_name[i] +' available. \
312+
<a href="http://codecanyon.net/downloads" title="'+ lcun_name[i] +'" target="_blank">Download version '+ new_ver[i] +'</a>'+ pl_note +'.</div>\
313313
</td>\
314314
</tr>';
315315
jQuery('#'+v).addClass('update');
316316
jQuery('#'+v).after(code);
317+
318+
<?php
319+
// if WP 4 - hide "view details" link
320+
if((float)substr(get_bloginfo('version'), 0, 3) >= 4) {
321+
?>
322+
jQuery('#'+v).find('a.thickbox').remove();
323+
var v4_txt = jQuery('#'+v).find('.plugin-version-author-uri').html();
324+
jQuery('#'+v).find('.plugin-version-author-uri').html( v4_txt.slice(0,-2) );
325+
<?php
326+
}
327+
?>
317328
});
318329

330+
// show thickbox
319331
jQuery('body').delegate('.lcun_update_note', "click", function (e) {
320332
e.preventDefault();
321333
tb_show('Plugin Information: '+ jQuery(this).attr('pcun_name') , '#TB_inline?height=600&width=640&inlineId='+ jQuery(this).attr('rel'));
322334
setTimeout(function() {
323-
jQuery('#TB_window').css('background-color', '#fff');
335+
jQuery('#TB_window').css('background-color', '#fff').css('background-image', 'none');
324336
}, 50);
325337
});
326338
});

0 commit comments

Comments
 (0)