Skip to content

Commit a192cdf

Browse files
authored
Merge pull request #5 from jamiebergen/update/1.2.0
Update/1.2.0
2 parents f678145 + e7a5487 commit a192cdf

File tree

8 files changed

+172
-49
lines changed

8 files changed

+172
-49
lines changed

README.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Contributors: jamiebergen
33
Tags: plugins, plugin notes, memo
44
Donate link: https://jamiebergen.com/donate/
55
Requires at least: 4.0
6-
Tested up to: 5.0
6+
Tested up to: 5.2.2
77
Requires PHP: 5.5.24
8-
Stable tag: 1.1.2
8+
Stable tag: 1.2.0
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -22,6 +22,7 @@ Features
2222
* Format notes using basic HTML tags if desired.
2323
* Any links included in the note will be automatically converted to `target="_blank"`
2424
* Notes are added and updated via Ajax, avoiding slow page reloads.
25+
* Notes also display on the WordPress Updates page for any plugins that need to be updated.
2526

2627
== Installation ==
2728
1. You can either install the plugin via the Plugins directory from within your WordPress install, or you can upload the files manually to your server by extracting the .zip file and placing its contents in the /wp-content/plugins/ directory.
@@ -79,6 +80,10 @@ Each site within a multisite install maintains its own plugin notes. Additionall
7980

8081
== Changelog ==
8182

83+
= 1.2.0 =
84+
* Added: Plugin notes now display in a read-only format on the WordPress Updates page (update-core.php). Thanks to @douglsmith for the suggestion.
85+
* Fixed: Removed unnecessary multisite hook. Thanks to @foomagoo for pointing this out.
86+
8287
= 1.1.2 =
8388
* Fixed: Bug that prevented user from adding or updating notes after an ajax response. Thanks to @anticosti for helping to identify this bug.
8489
* Added: Spinning icon to indicate that a note is in the process of being deleted.
@@ -97,6 +102,9 @@ Each site within a multisite install maintains its own plugin notes. Additionall
97102

98103
== Upgrade Notice ==
99104

105+
= 1.2.0 =
106+
This version adds a feature to display plugin notes on the WordPress Updates page.
107+
100108
= 1.1.2 =
101109
This version fixes a bug where plugin notes couldn't be updated if the user had previously filtered the list of plugins.
102110

admin/class-plugin-notes-plus-admin.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ public function enqueue_scripts() {
9898
wp_enqueue_script( 'pnp_ajax_handle', plugin_dir_url( __FILE__ ) . 'js/plugin-notes-plus-admin.js', array( 'jquery' ), $this->plugin->get_version(), false );
9999
wp_localize_script( 'pnp_ajax_handle', 'params', $params );
100100

101+
/**
102+
* Retrieve notes for plugins on updates page and send to JavaScript file
103+
*
104+
* @since 1.2.0
105+
*/
106+
107+
// Only run this code on update-core.php admin page
108+
global $hook_suffix;
109+
110+
if ( $hook_suffix == 'update-core.php' ) {
111+
$updates = $this->get_notes_for_plugin_updates_page();
112+
$labels = array (
113+
'col_title' => esc_html__( 'Plugin Notes', $this->plugin->get_plugin_name() ),
114+
'no_note' => esc_html__( 'No Plugin Notes', $this->plugin->get_plugin_name() ),
115+
);
116+
wp_enqueue_script( 'pnp_updates_script', plugin_dir_url( __FILE__ ) . 'js/plugin-notes-plus-updates.js', array( 'jquery' ), $this->plugin->get_version(), false );
117+
wp_localize_script( 'pnp_updates_script', 'updates', $updates );
118+
wp_localize_script( 'pnp_updates_script', 'labels', $labels );
119+
}
101120
}
102121

103122
/**
@@ -225,6 +244,33 @@ public function pnp_delete_response() {
225244
die();
226245
}
227246

247+
/**
248+
* Function that retrieves plugin notes for plugins that need updating
249+
*
250+
* @since 1.2.0
251+
*/
252+
public function get_notes_for_plugin_updates_page() {
253+
254+
$notes_array = array();
255+
256+
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
257+
$plugins = get_plugin_updates();
258+
259+
if ( empty( $plugins ) ) {
260+
return $notes_array;
261+
}
262+
263+
foreach ( $plugins as $plugin_file => $plugin_data ) {
264+
265+
$plugin_unique_id = $this->get_plugin_unique_id( $plugin_file );
266+
$plugin_note_obj = new Plugin_Notes_Plus_The_Note( $plugin_unique_id );
267+
$the_plugin_notes = $plugin_note_obj->get_plugin_notes();
268+
269+
array_push( $notes_array, $the_plugin_notes );
270+
}
271+
272+
return $notes_array;
273+
}
228274
}
229275

230276
Plugin_Notes_Plus_Admin::$icon_options = array(
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* This file is enqueued from admin/class-plugin-notes-plus-admin.php
3+
* on the update-core.php page only.
4+
*/
5+
6+
(function($) {
7+
$(document).ready(function () {
8+
9+
$('#update-plugins-table thead tr, #update-plugins-table tfoot tr').append( '<td id="pnp_plugin_notes_col">'+ labels.col_title +'</td>' );
10+
11+
var i = 0;
12+
13+
$('#update-plugins-table .plugins tr').each(function() {
14+
15+
const values = Object.values(updates[i]);
16+
17+
if (values === undefined || values.length === 0) {
18+
19+
$(this).append( '<td>'+ labels.no_note +'</td>' );
20+
21+
} else {
22+
23+
var noteMarkup = '<div class="pnp-wrapper">';
24+
25+
for (const value of values) {
26+
27+
// Convert time to readable format
28+
var d = new Date(value.time * 1000);
29+
var month = ("0" + (d.getMonth() + 1)).slice(-2);
30+
var date = ("0" + d.getDate()).slice(-2);
31+
var year = d.getFullYear();
32+
var formattedDate = year + '-' + month + '-' + date;
33+
34+
noteMarkup += '<div class="pnp-plugin-note">';
35+
noteMarkup += '<span class="dashicons '+ value.icon +'"></span>';
36+
noteMarkup += value.note;
37+
noteMarkup += '<p class="pnp-note-meta">'+ value.user +' | <span class="pnp-note-time">'+ formattedDate +'</span></p>';
38+
noteMarkup += '</div>';
39+
40+
}
41+
noteMarkup += '</div>';
42+
43+
$(this).append( '<td>'+ noteMarkup +'</td>' );
44+
}
45+
46+
i++;
47+
});
48+
49+
// Add target="_blank" to all links
50+
$('.pnp-plugin-note a').each(function(){
51+
$(this).attr( 'target', '_blank' );
52+
});
53+
54+
});
55+
})(jQuery);

includes/class-plugin-notes-plus.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ private function define_admin_hooks() {
150150
$this->loader->add_filter( 'manage_plugins_columns', $plugin_admin, 'add_plugin_notes_column' );
151151
$this->loader->add_action( 'manage_plugins_custom_column', $plugin_admin, 'display_plugin_note',10, 3 );
152152

153-
// Separate hooks for multisite admin plugins page
153+
// Separate hook for multisite admin plugins page
154154
$this->loader->add_filter( 'manage_plugins-network_columns', $plugin_admin, 'add_plugin_notes_column' );
155-
$this->loader->add_action( 'manage_plugins-network_custom_column', $plugin_admin, 'display_plugin_note',10, 3 );
156155

156+
// Ajax responses for adding and deleting notes
157157
$this->loader->add_action( 'wp_ajax_pnp_add_response', $plugin_admin, 'pnp_add_response');
158158
$this->loader->add_action( 'wp_ajax_pnp_delete_response', $plugin_admin, 'pnp_delete_response');
159159
}

languages/plugin-notes-plus-es_ES.mo

100644100755
69 Bytes
Binary file not shown.

languages/plugin-notes-plus-es_ES.po

100644100755
Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,84 +5,92 @@ msgid ""
55
msgstr ""
66
"Project-Id-Version: Plugin Notes Plus 1.0.0\n"
77
"Report-Msgid-Bugs-To: Translator Name <translations@example.com>\n"
8-
"POT-Creation-Date: 2018-02-03 15:10-0800\n"
8+
"POT-Creation-Date: 2019-07-09 20:57-0700\n"
99
"PO-Revision-Date: \n"
10+
"Last-Translator: \n"
1011
"Language-Team: Jamie Bergen <jamie.bergen@gmail.com>\n"
12+
"Language: es\n"
1113
"MIME-Version: 1.0\n"
1214
"Content-Type: text/plain; charset=UTF-8\n"
1315
"Content-Transfer-Encoding: 8bit\n"
1416
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
1517
"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n"
1618
"X-Poedit-SourceCharset: UTF-8\n"
17-
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
19+
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
20+
"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;"
21+
"_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;"
22+
"__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
1823
"X-Poedit-Basepath: ..\n"
19-
"X-Generator: Poedit 2.0.6\n"
20-
"Last-Translator: \n"
21-
"Language: es\n"
24+
"X-Generator: Poedit 2.2.3\n"
2225
"X-Poedit-SearchPath-0: .\n"
2326

24-
#: admin/class-plugin-notes-plus-admin.php:109
25-
#: admin/partials/plugin-note-markup.php:26
27+
#: admin/class-plugin-notes-plus-admin.php:93
28+
#: admin/partials/plugin-note-markup.php:27
2629
msgid "edit"
2730
msgstr "editar"
2831

29-
#: admin/class-plugin-notes-plus-admin.php:110
30-
#: admin/partials/plugin-note-markup.php:27
32+
#: admin/class-plugin-notes-plus-admin.php:94
33+
#: admin/partials/plugin-note-markup.php:28
3134
msgid "delete"
3235
msgstr "borrar"
3336

34-
#: admin/class-plugin-notes-plus-admin.php:111
37+
#: admin/class-plugin-notes-plus-admin.php:95
3538
msgid "Are you sure you want to delete this note?"
3639
msgstr "¿Está seguro/a de que desea eliminar esta nota?"
3740

38-
#: admin/class-plugin-notes-plus-admin.php:112
41+
#: admin/class-plugin-notes-plus-admin.php:96
3942
msgid "The note must contain content."
4043
msgstr "La nota debe contener contenido."
4144

42-
#: admin/class-plugin-notes-plus-admin.php:120
45+
#: admin/class-plugin-notes-plus-admin.php:113
46+
#: admin/class-plugin-notes-plus-admin.php:128
4347
msgid "Plugin Notes"
4448
msgstr "Notas de plugin"
4549

46-
#: admin/class-plugin-notes-plus-admin.php:209
50+
#: admin/class-plugin-notes-plus-admin.php:114
51+
msgid "No Plugin Notes"
52+
msgstr "No hay notas"
53+
54+
#: admin/class-plugin-notes-plus-admin.php:277
4755
msgid "Note"
4856
msgstr "Nota"
4957

50-
#: admin/class-plugin-notes-plus-admin.php:210
58+
#: admin/class-plugin-notes-plus-admin.php:278
5159
msgid "Info"
5260
msgstr "Información"
5361

54-
#: admin/class-plugin-notes-plus-admin.php:211
62+
#: admin/class-plugin-notes-plus-admin.php:279
5563
msgid "Link"
5664
msgstr "Link"
5765

58-
#: admin/class-plugin-notes-plus-admin.php:212
66+
#: admin/class-plugin-notes-plus-admin.php:280
5967
msgid "Warning"
6068
msgstr "Advertencia"
6169

62-
#: admin/class-plugin-notes-plus-admin.php:213
70+
#: admin/class-plugin-notes-plus-admin.php:281
6371
msgid "Key"
6472
msgstr "Llave"
6573

66-
#: admin/class-plugin-notes-plus-admin.php:214
74+
#: admin/class-plugin-notes-plus-admin.php:282
6775
msgid "Checkmark"
6876
msgstr "Marca de verificación"
6977

70-
#: admin/partials/plugin-note-markup.php:42
78+
#: admin/partials/plugin-note-markup.php:45
7179
msgid "+ Add plugin note"
7280
msgstr "+ Añadir la nota"
7381

74-
#: admin/partials/plugin-note-markup.php:46
82+
#: admin/partials/plugin-note-markup.php:49
7583
msgid "Note type:"
7684
msgstr "Tipo de nota:"
7785

78-
#: admin/partials/plugin-note-markup.php:55
86+
#: admin/partials/plugin-note-markup.php:58
7987
msgid "Save note"
8088
msgstr "Guardar nota"
8189

82-
#: admin/partials/plugin-note-markup.php:58
90+
#: admin/partials/plugin-note-markup.php:61
8391
msgid "Cancel"
8492
msgstr "Cancelar"
8593

86-
#: admin/partials/plugin-note-markup.php:69
94+
#: admin/partials/plugin-note-markup.php:72
8795
msgid "You are not authorized to perform this operation."
8896
msgstr "Usted no está autorizado para realizar esta operación."

languages/plugin-notes-plus.pot

100644100755
Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# WordPress Blank Pot
22
# Copyright (C) 2014 ...
33
# This file is distributed under the GNU General Public License v2 or later.
4+
#, fuzzy
45
msgid ""
56
msgstr ""
67
"Project-Id-Version: Plugin Notes Plus 1.0.0\n"
78
"Report-Msgid-Bugs-To: Translator Name <translations@example.com>\n"
8-
"POT-Creation-Date: 2018-02-03 15:10-0800\n"
9+
"POT-Creation-Date: 2019-07-09 20:56-0700\n"
910
"PO-Revision-Date: \n"
1011
"Last-Translator: \n"
1112
"Language-Team: Jamie Bergen <jamie.bergen@gmail.com>\n"
@@ -21,71 +22,76 @@ msgstr ""
2122
"_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;"
2223
"__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
2324
"X-Poedit-Basepath: ..\n"
24-
"X-Generator: Poedit 2.0.6\n"
25+
"X-Generator: Poedit 2.2.3\n"
2526
"X-Poedit-SearchPath-0: .\n"
2627

27-
#: admin/class-plugin-notes-plus-admin.php:109
28-
#: admin/partials/plugin-note-markup.php:26
28+
#: admin/class-plugin-notes-plus-admin.php:93
29+
#: admin/partials/plugin-note-markup.php:27
2930
msgid "edit"
3031
msgstr ""
3132

32-
#: admin/class-plugin-notes-plus-admin.php:110
33-
#: admin/partials/plugin-note-markup.php:27
33+
#: admin/class-plugin-notes-plus-admin.php:94
34+
#: admin/partials/plugin-note-markup.php:28
3435
msgid "delete"
3536
msgstr ""
3637

37-
#: admin/class-plugin-notes-plus-admin.php:111
38+
#: admin/class-plugin-notes-plus-admin.php:95
3839
msgid "Are you sure you want to delete this note?"
3940
msgstr ""
4041

41-
#: admin/class-plugin-notes-plus-admin.php:112
42+
#: admin/class-plugin-notes-plus-admin.php:96
4243
msgid "The note must contain content."
4344
msgstr ""
4445

45-
#: admin/class-plugin-notes-plus-admin.php:120
46+
#: admin/class-plugin-notes-plus-admin.php:113
47+
#: admin/class-plugin-notes-plus-admin.php:128
4648
msgid "Plugin Notes"
4749
msgstr ""
4850

49-
#: admin/class-plugin-notes-plus-admin.php:209
51+
#: admin/class-plugin-notes-plus-admin.php:114
52+
msgid "No Plugin Notes"
53+
msgstr ""
54+
55+
#: admin/class-plugin-notes-plus-admin.php:277
5056
msgid "Note"
5157
msgstr ""
5258

53-
#: admin/class-plugin-notes-plus-admin.php:210
59+
#: admin/class-plugin-notes-plus-admin.php:278
5460
msgid "Info"
5561
msgstr ""
5662

57-
#: admin/class-plugin-notes-plus-admin.php:211
63+
#: admin/class-plugin-notes-plus-admin.php:279
5864
msgid "Link"
5965
msgstr ""
6066

61-
#: admin/class-plugin-notes-plus-admin.php:212
67+
#: admin/class-plugin-notes-plus-admin.php:280
6268
msgid "Warning"
6369
msgstr ""
6470

65-
#: admin/class-plugin-notes-plus-admin.php:213
71+
#: admin/class-plugin-notes-plus-admin.php:281
6672
msgid "Key"
6773
msgstr ""
6874

69-
#: admin/class-plugin-notes-plus-admin.php:214
75+
#: admin/class-plugin-notes-plus-admin.php:282
7076
msgid "Checkmark"
7177
msgstr ""
7278

73-
#: admin/partials/plugin-note-markup.php:42
79+
#: admin/partials/plugin-note-markup.php:45
7480
msgid "+ Add plugin note"
7581
msgstr ""
7682

77-
#: admin/partials/plugin-note-markup.php:46
83+
#: admin/partials/plugin-note-markup.php:49
7884
msgid "Note type:"
7985
msgstr ""
8086

81-
#: admin/partials/plugin-note-markup.php:55
87+
#: admin/partials/plugin-note-markup.php:58
8288
msgid "Save note"
8389
msgstr ""
8490

85-
#: admin/partials/plugin-note-markup.php:58
91+
#: admin/partials/plugin-note-markup.php:61
8692
msgid "Cancel"
8793
msgstr ""
8894

89-
#: admin/partials/plugin-note-markup.php:69
95+
#: admin/partials/plugin-note-markup.php:72
9096
msgid "You are not authorized to perform this operation."
9197
msgstr ""

0 commit comments

Comments
 (0)