WP Dashboard Notes - Version 1.0.8.1

Version Description

  • 21/03/2016 =

  • Fix - Check in checkbox sometimes don't save

Download this release

Release Info

Developer sormano
Plugin Icon 128x128 WP Dashboard Notes
Version 1.0.8.1
Comparing to
See all releases

Code changes from version 1.0.1 to 1.0.8.1

assets/css/wp-dashboard-notes-admin.min.css ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ input[type=text].add-list-item {
2
+ line-height: normal;
3
+ border-radius: 3px;
4
+ height: 35px;
5
+ padding: 5px 10px;
6
+ width: 75%;
7
+ border-color: #555;
8
+ background-color: rgba(255, 255, 255, 0.6); }
9
+
10
+ input[type=text].add-list-item::-webkit-input-placeholder {
11
+ color: #555; }
12
+
13
+ input[type=text].add-list-item:-moz-placeholder {
14
+ color: #555; }
15
+
16
+ input[type=text].add-list-item::-moz-placeholder {
17
+ color: #555; }
18
+
19
+ input[type=text].add-list-item:-ms-input-placeholder {
20
+ color: #555; }
21
+
22
+ .wp-dashboard-note {
23
+ line-height: 1.5;
24
+ font-size: 14px;
25
+ min-height: 30px; }
26
+
27
+ .wp-dashboard-note-wrap {
28
+ padding-bottom: 40px; }
29
+
30
+ .wp-dashboard-note-options {
31
+ text-align: left; }
32
+
33
+ .list-note .wp-dashboard-note-options {
34
+ margin-top: 15px; }
35
+
36
+ .wp-dashboard-note .list-item {
37
+ min-height: 30px;
38
+ line-height: 30px;
39
+ width: 100%;
40
+ display: block; }
41
+
42
+ .wp-dashboard-note div:last-child {
43
+ border-bottom: 0; }
44
+
45
+ /* Sortable */
46
+ .wpdn-note-sortable {
47
+ color: #6f6f6f;
48
+ margin-right: 5px;
49
+ cursor: move;
50
+ line-height: inherit;
51
+ opacity: 0; }
52
+
53
+ .list-item:hover .wpdn-note-sortable {
54
+ opacity: 1; }
55
+
56
+ .list-item .dashicons-no-alt {
57
+ color: rgba(0, 0, 0, 0.3);
58
+ text-align: right;
59
+ float: right;
60
+ cursor: pointer;
61
+ line-height: inherit; }
62
+
63
+ .list-item input[type=checkbox] {
64
+ margin-right: 15px;
65
+ background: transparent;
66
+ border-color: #555; }
67
+
68
+ .list-item input[type=checkbox]:checked:before {
69
+ color: #555; }
70
+
71
+ .list-item input[type=checkbox]:checked ~ span {
72
+ text-decoration: line-through;
73
+ color: #6f6f6f; }
74
+
75
+ .list-item .dashicons-no-alt:hover {
76
+ color: #999; }
77
+
78
+ .list-item:hover .dashicons-no-alt {
79
+ visibility: visible; }
80
+
81
+ .list-item .dashicons-no-alt {
82
+ visibility: hidden; }
83
+
84
+ .wp-dashboard-note-wrap .wpdn-add-item {
85
+ line-height: 2; }
86
+
87
+ .list-item .wpdn-add-item {
88
+ color: #ccc;
89
+ margin-right: 8px; }
90
+
91
+ .list-item-content {
92
+ line-height: 1; }
93
+
94
+ .wp-dashboard-note-wrap:hover .wpdn-extra {
95
+ opacity: 1; }
96
+
97
+ .wpdn-extra {
98
+ background: rgba(76, 76, 76, 0.9);
99
+ position: absolute;
100
+ opacity: 0;
101
+ width: 100%;
102
+ left: 0;
103
+ bottom: 0;
104
+ height: 40px;
105
+ padding-left: 12px;
106
+ box-sizing: border-box;
107
+ -webkit-transition: opacity 0.3s ease-in-out;
108
+ transition: opacity 0.2s ease-in-out; }
109
+
110
+ .wpdn-extra * {
111
+ color: #fff; }
112
+
113
+ .wpdn-extra .dashicons:hover {
114
+ color: #ccc;
115
+ cursor: pointer; }
116
+
117
+ [data-note-type=list] .saved-icon .dashicons,
118
+ .wpdn-extra .dashicons {
119
+ line-height: 2; }
120
+
121
+ .wpdn-extra .dashicons {
122
+ margin-left: 5px; }
123
+
124
+ [data-note-type=regular] .saved-icon .dashicons {
125
+ line-height: 1; }
126
+
127
+ .hndle span {
128
+ cursor: text;
129
+ -webkit-user-select: text;
130
+ -moz-user-select: text;
131
+ -ms-user-select: text;
132
+ -o-user-select: text;
133
+ user-select: text; }
134
+
135
+ .hndle .wpdn-edit-title {
136
+ display: none;
137
+ height: 19px;
138
+ color: #222;
139
+ cursor: pointer;
140
+ margin-left: 5px; }
141
+
142
+ .hndle:hover .dashicons {
143
+ display: inline-block; }
144
+
145
+ [id^=note_] .handlediv {
146
+ color: #222;
147
+ color: transparent; }
148
+
149
+ /* Open Link */
150
+ .wp-dashboard-note-wrap a {
151
+ position: relative; }
152
+
153
+ .wp-dashboard-note-wrap :focus {
154
+ outline: none; }
155
+
156
+ .link-hover {
157
+ background: rgba(76, 76, 76, 0.9);
158
+ position: absolute;
159
+ left: 0px;
160
+ top: 1.6em;
161
+ padding: 5px;
162
+ border-radius: 4px;
163
+ font-size: 12px;
164
+ z-index: 99;
165
+ min-width: 55px;
166
+ text-align: center; }
167
+
168
+ .link-hover a {
169
+ color: white; }
170
+
171
+ /* Saving */
172
+ .hndle .status {
173
+ float: right; }
174
+
175
+ .saving-icon img {
176
+ vertical-align: middle; }
177
+
178
+ .saved-icon,
179
+ .saving-icon {
180
+ color: #222;
181
+ font-weight: normal;
182
+ font-size: 13px; }
183
+
184
+ /* Hide pencil at screen options titles */
185
+ .metabox-prefs .wpdn-edit-title.dashicons-edit {
186
+ display: none; }
187
+
188
+ /****************************
189
+ * Colors
190
+ ****************************/
191
+ span.wpdn-color-note:hover .wpdn-color-palette {
192
+ display: inline-block; }
193
+
194
+ .wpdn-color-palette {
195
+ min-width: 50px;
196
+ width: auto;
197
+ padding: 4px 8px 2px 8px;
198
+ margin-left: -8px;
199
+ position: absolute;
200
+ top: -24px;
201
+ background-color: rgba(76, 76, 76, 0.9);
202
+ height: 18px;
203
+ display: none; }
204
+
205
+ .color {
206
+ width: 10px;
207
+ height: 10px;
208
+ border: 1px solid transparent;
209
+ margin: 2.5px;
210
+ display: inline-block; }
211
+
212
+ .color:hover {
213
+ border: 1px solid #ccc;
214
+ cursor: pointer; }
215
+
216
+ .color-white {
217
+ background-color: #ffffff; }
218
+
219
+ .color-red {
220
+ background-color: #f7846a; }
221
+
222
+ .color-orange {
223
+ background-color: #ffbd22; }
224
+
225
+ .color-yellow {
226
+ background-color: #eeee22; }
227
+
228
+ .color-blue {
229
+ background-color: #66ccdd; }
230
+
231
+ .color-green {
232
+ background-color: #bbe535; }
233
+
234
+ .color-black {
235
+ background-color: #777777; }
236
+
237
+ /****************************
238
+ * Black
239
+ ****************************/
240
+ [data-color-text=black] {
241
+ color: white; }
242
+
243
+ [data-color-text=black] .wpdn-note-sortable {
244
+ color: white; }
245
+
246
+ [data-color-text=black] .wpdn-add-item {
247
+ color: white; }
248
+
249
+ [data-color-text=black] .wp-dashboard-note .list-item {
250
+ border-color: white; }
251
+
252
+ [data-color-text=black] input[type=checkbox] {
253
+ border: 1px solid white; }
254
+
255
+ [data-color-text=black] .list-item input[type=checkbox]:checked ~ span {
256
+ color: white; }
257
+
258
+ [data-color-text=black] [id^=note] .handlediv {
259
+ color: white; }
260
+
261
+ [data-color-text=black] input[type=text].add-list-item {
262
+ border-color: #FFF;
263
+ color: #FFF;
264
+ background: rgba(255, 255, 255, 0.3); }
265
+
266
+ [data-color-text=black] input[type=text].add-list-item::-webkit-input-placeholder {
267
+ color: white; }
268
+
269
+ [data-color-text=black] input[type=text].add-list-item:-moz-placeholder {
270
+ color: white; }
271
+
272
+ [data-color-text=black] input[type=text].add-list-item::-moz-placeholder {
273
+ color: white; }
274
+
275
+ [data-color-text=black] input[type=text].add-list-item:-ms-input-placeholder {
276
+ color: white; }
277
+
278
+ [data-color-text=black] .saved-icon,
279
+ [data-color-text=black] .saving-icon {
280
+ color: white; }
281
+
282
+ /****************************
283
+ * Template
284
+ ****************************/
285
+ [data-color-text=template] {
286
+ color: inherit; }
287
+
288
+ [data-color-text=template] .wpdn-note-sortable {
289
+ color: inherit; }
290
+
291
+ [data-color-text=template] .wpdn-add-item {
292
+ color: inherit; }
293
+
294
+ [data-color-text=template] .wp-dashboard-note .list-item {
295
+ border-color: inherit; }
296
+
297
+ [data-color-text=template] input[type=checkbox] {
298
+ border: 1px solid inherit; }
299
+
300
+ [data-color-text=template] .list-item input[type=checkbox]:checked ~ span {
301
+ color: inherit; }
302
+
303
+ [data-color-text=template] [id^=note] .handlediv {
304
+ color: inherit; }
305
+
306
+ [data-color-text=template] input[type=text].add-list-item {
307
+ border-color: inherit;
308
+ color: inherit;
309
+ background: inherit; }
310
+
311
+ [data-color-text=template] input[type=text].add-list-item::-webkit-input-placeholder {
312
+ color: inherit; }
313
+
314
+ [data-color-text=template] input[type=text].add-list-item:-moz-placeholder {
315
+ color: inherit; }
316
+
317
+ [data-color-text=template] input[type=text].add-list-item::-moz-placeholder {
318
+ color: inherit; }
319
+
320
+ [data-color-text=template] input[type=text].add-list-item:-ms-input-placeholder {
321
+ color: inherit; }
322
+
323
+ [data-color-text=template] .saved-icon,
324
+ [data-color-text=template] .saving-icon {
325
+ color: inherit; }
326
+
327
+ /****************************
328
+ * Mobile Adjustments
329
+ ****************************/
330
+ @media only screen and (max-device-width: 1024px) {
331
+ .wpdn-extra {
332
+ opacity: 1; }
333
+
334
+ .wpdn-edit-title {
335
+ display: inline-block !important; } }
assets/css/{wpdn_admin.css → wp-dashboard-notes-admin.scss} RENAMED
@@ -24,6 +24,7 @@ input[type=text].add-list-item:-ms-input-placeholder {
24
  .wp-dashboard-note {
25
  line-height: 1.5;
26
  font-size: 14px;
 
27
  }
28
  .wp-dashboard-note-wrap {
29
  padding-bottom: 40px;
@@ -58,7 +59,7 @@ input[type=text].add-list-item:-ms-input-placeholder {
58
  opacity: 1;
59
  }
60
  .list-item .dashicons-no-alt {
61
- color: #ccc;
62
  text-align: right;
63
  float: right;
64
  cursor: pointer;
@@ -80,10 +81,10 @@ input[type=text].add-list-item:-ms-input-placeholder {
80
  color: #999;
81
  }
82
  .list-item:hover .dashicons-no-alt {
83
- display: block;
84
  }
85
  .list-item .dashicons-no-alt {
86
- display: none;
87
  }
88
  .wp-dashboard-note-wrap .wpdn-add-item {
89
  line-height: 2;
@@ -129,25 +130,22 @@ input[type=text].add-list-item:-ms-input-placeholder {
129
  [data-note-type=regular] .saved-icon .dashicons {
130
  line-height: 1;
131
  }
132
- .wp-dashboard-note-wrap * {
133
- -webkit-user-select: none;
134
- -moz-user-select: none;
135
- -ms-user-select: none;
136
- -o-user-select: none;
137
- user-select: none;
138
- }
139
-
140
  .hndle span {
141
  cursor: text;
 
 
 
 
 
142
  }
143
- h3.hndle .dashicons {
144
  display: none;
145
  height: 19px;
146
  color: #222;
147
  cursor: pointer;
148
  margin-left: 5px;
149
  }
150
- h3.hndle:hover .dashicons {
151
  display: inline-block;
152
  }
153
  [id^=note_] .handlediv {
@@ -155,35 +153,43 @@ h3.hndle:hover .dashicons {
155
  color: transparent;
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  /* Saving */
 
 
 
159
  .saving-icon img {
160
  vertical-align: middle;
161
  }
162
  .saved-icon,
163
  .saving-icon {
164
  color: #222;
 
 
165
  }
166
 
167
- /* Add button screen options */
168
- [for=add_note-hide] {
169
- float: right;
170
- padding-left: 10px;
171
- margin-left: 2px;
172
- }
173
- [for=add_note-hide] input {
174
- display: none;
175
- }
176
- [for=add_note-hide]::before {
177
- content: "\f132";
178
- font-family: dashicons;
179
- vertical-align: middle;
180
- font-size: 18px;
181
- margin-right: 5px;
182
- }
183
- [for=add_note-hide]:hover {
184
- color: #fff;
185
- background: #333;
186
- }
187
  /* Hide pencil at screen options titles */
188
  .metabox-prefs .wpdn-edit-title.dashicons-edit {
189
  display: none;
@@ -213,11 +219,6 @@ span.wpdn-color-note:hover .wpdn-color-palette {
213
  border: 1px solid transparent;
214
  margin: 2.5px;
215
  display: inline-block;
216
- -webkit-user-select: none;
217
- -moz-user-select: none;
218
- -ms-user-select: none;
219
- -o-user-select: none;
220
- user-select: none;
221
  }
222
  .color:hover {
223
  border: 1px solid #ccc;
@@ -282,10 +283,10 @@ span.wpdn-color-note:hover .wpdn-color-palette {
282
  /****************************
283
  * Template
284
  ****************************/
285
- [data-color-text=template] {
286
  color: inherit;
287
  }
288
- [data-color-text=template] .wpdn-note-sortable {
289
  color: inherit;
290
  }
291
  [data-color-text=template] .wpdn-add-item {
@@ -323,4 +324,16 @@ span.wpdn-color-note:hover .wpdn-color-palette {
323
  [data-color-text=template] .saved-icon,
324
  [data-color-text=template] .saving-icon {
325
  color: inherit;
326
- }
 
 
 
 
 
 
 
 
 
 
 
 
24
  .wp-dashboard-note {
25
  line-height: 1.5;
26
  font-size: 14px;
27
+ min-height: 30px;
28
  }
29
  .wp-dashboard-note-wrap {
30
  padding-bottom: 40px;
59
  opacity: 1;
60
  }
61
  .list-item .dashicons-no-alt {
62
+ color: rgba( 0, 0, 0, 0.3 );
63
  text-align: right;
64
  float: right;
65
  cursor: pointer;
81
  color: #999;
82
  }
83
  .list-item:hover .dashicons-no-alt {
84
+ visibility: visible;
85
  }
86
  .list-item .dashicons-no-alt {
87
+ visibility: hidden;
88
  }
89
  .wp-dashboard-note-wrap .wpdn-add-item {
90
  line-height: 2;
130
  [data-note-type=regular] .saved-icon .dashicons {
131
  line-height: 1;
132
  }
 
 
 
 
 
 
 
 
133
  .hndle span {
134
  cursor: text;
135
+ -webkit-user-select: text;
136
+ -moz-user-select: text;
137
+ -ms-user-select: text;
138
+ -o-user-select: text;
139
+ user-select: text;
140
  }
141
+ .hndle .wpdn-edit-title {
142
  display: none;
143
  height: 19px;
144
  color: #222;
145
  cursor: pointer;
146
  margin-left: 5px;
147
  }
148
+ .hndle:hover .dashicons {
149
  display: inline-block;
150
  }
151
  [id^=note_] .handlediv {
153
  color: transparent;
154
  }
155
 
156
+ /* Open Link */
157
+ .wp-dashboard-note-wrap a {
158
+ position: relative;
159
+ }
160
+ .wp-dashboard-note-wrap :focus {
161
+ outline: none;
162
+ }
163
+ .link-hover {
164
+ background: rgba(76, 76, 76, 0.9);
165
+ position: absolute;
166
+ left: 0px;
167
+ top: 1.6em;
168
+ padding: 5px;
169
+ border-radius: 4px;
170
+ font-size: 12px;
171
+ z-index: 99;
172
+ min-width: 55px;
173
+ text-align: center;
174
+ }
175
+ .link-hover a {
176
+ color: white;
177
+ }
178
+
179
  /* Saving */
180
+ .hndle .status {
181
+ float: right;
182
+ }
183
  .saving-icon img {
184
  vertical-align: middle;
185
  }
186
  .saved-icon,
187
  .saving-icon {
188
  color: #222;
189
+ font-weight: normal;
190
+ font-size: 13px;
191
  }
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  /* Hide pencil at screen options titles */
194
  .metabox-prefs .wpdn-edit-title.dashicons-edit {
195
  display: none;
219
  border: 1px solid transparent;
220
  margin: 2.5px;
221
  display: inline-block;
 
 
 
 
 
222
  }
223
  .color:hover {
224
  border: 1px solid #ccc;
283
  /****************************
284
  * Template
285
  ****************************/
286
+ [data-color-text=template] {
287
  color: inherit;
288
  }
289
+ [data-color-text=template] .wpdn-note-sortable {
290
  color: inherit;
291
  }
292
  [data-color-text=template] .wpdn-add-item {
324
  [data-color-text=template] .saved-icon,
325
  [data-color-text=template] .saving-icon {
326
  color: inherit;
327
+ }
328
+
329
+ /****************************
330
+ * Mobile Adjustments
331
+ ****************************/
332
+ @media only screen and (max-device-width : 1024px) {
333
+ .wpdn-extra{
334
+ opacity:1
335
+ }
336
+ .wpdn-edit-title {
337
+ display: inline-block !important;
338
+ }
339
+ }
assets/js/{wpdn_admin.js → wp-dashboard-notes-admin.js} RENAMED
@@ -4,7 +4,7 @@ jQuery( document ).ready( function($) {
4
  var saved_icon = '<span class="saved-icon"><div class="dashicons dashicons-yes"></div> saved!</span>';
5
 
6
 
7
- // Add todo item
8
  $( 'body, .list-item-content' ).on( 'keydown', '.add-list-item', function( e ) {
9
 
10
  if( e.keyCode == 13 && $( this ).val() != '' ) {
@@ -23,21 +23,21 @@ jQuery( document ).ready( function($) {
23
  });
24
 
25
 
26
- // Delete todo item
27
- $( 'body' ).on( 'click', '.delete-item', function() {
28
 
29
  var post_id = $( this ).closest( ".postbox" ).attr( 'id' );
30
 
31
  $( this ).parent( '.list-item' ).remove();
32
- $( 'body' ).trigger( 'wpdn-update', ['', post_id] );
33
 
34
  });
35
 
36
 
37
  // Toggle visibility
38
- $( 'body' ).on( 'click', '.wpdn-visibility', function() {
39
 
40
- $( this ).toggleClass( 'dashicons-lock dashicons-groups' );
41
 
42
  var visibility = $( this ).parent().attr( 'data-visibility' );
43
  if ( 'public' == visibility ) {
@@ -54,7 +54,7 @@ jQuery( document ).ready( function($) {
54
 
55
 
56
  // Toggle note type
57
- $( 'body' ).on( 'click', '.wpdn-note-type', function() {
58
 
59
  $( this ).toggleClass( 'dashicons-list-view dashicons-welcome-write-blog' );
60
 
@@ -68,7 +68,8 @@ jQuery( document ).ready( function($) {
68
  var data = {
69
  action: 'wpdn_toggle_note',
70
  post_id: $( this ).closest( ".postbox" ).attr( 'id' ).replace( 'note_', '' ),
71
- note_type: ( note_type == 'regular' ? 'list' : 'regular' )
 
72
  };
73
 
74
  $.post( ajaxurl, data, function( response ) {
@@ -81,59 +82,58 @@ jQuery( document ).ready( function($) {
81
 
82
 
83
  // Update note trigger
84
- $( 'body' ).on( 'wpdn-update', function( event, t, post_id ) {
85
 
86
  if ( t != '' ) {
87
  post_id = $( t ).closest( ".postbox" ).attr( 'id' );
88
  }
89
-
90
  if ( ! post_id ) {
91
  return;
92
  }
93
 
94
- $( '#' + post_id + ' .wp-dashboard-note-options .status' ).html( loading_icon );
95
  var data = {
96
  action: 'wpdn_update_note',
97
  post_id: post_id.replace( 'note_', '' ),
98
  post_content: $( '#' + post_id + ' div.wp-dashboard-note' ).html(),
99
- post_title: $( '#' + post_id + ' > h3 .wpdn-title' ).html(),
100
  note_visibility: $( '#' + post_id + ' [data-visibility]' ).attr( 'data-visibility' ),
101
  note_color_text: $( '#' + post_id + ' [data-color-text]' ).attr( 'data-color-text' ),
102
  note_color: $( '#' + post_id + ' [data-note-color]' ).attr( 'data-note-color' ),
103
- note_type: $( '#' + post_id + ' [data-note-type]' ).attr( 'data-note-type' )
 
104
  };
105
 
106
  $.post( ajaxurl, data, function( response ) {
107
- $( '#' + post_id + ' .wp-dashboard-note-options .status' ).html( saved_icon );
108
- $( '#' + post_id + ' .wp-dashboard-note-options .status *' ).fadeOut( 1000, function() { $( this ).html( '' ) });
109
  });
110
 
111
  });
112
 
113
 
114
  // Delete note
115
- $( 'body' ).on( 'click', '.wpdn-delete-note', function() {
116
 
117
  var post_id = $( this ).closest( ".postbox" ).attr( 'id' );
118
 
119
- $( '#' + post_id ).fadeOut( 500, function() { $( this ).remove() } );
120
 
121
  var data = {
122
- action: 'wpdn_delete_note',
123
  post_id: post_id.replace( 'note_', '' ),
 
124
  };
125
-
126
- $.post( ajaxurl, data, function( response ) {
127
-
128
- });
129
 
130
  });
131
 
132
 
133
  // Add note
134
- $( 'body' ).on( 'click', '.wpdn-add-note, #add_note-hide', function() {
135
 
136
- var data = { action: 'wpdn_add_note' };
137
 
138
  $.post( ajaxurl, data, function( response ) {
139
  response = jQuery.parseJSON( response );
@@ -142,7 +142,6 @@ jQuery( document ).ready( function($) {
142
  jQuery( '#note_' + response.post_id + ' .add-list-item' ).focus();
143
  });
144
 
145
-
146
  // Stop scrollTop animation on user scroll
147
  $( 'html, body' ).bind("scroll mousedown DOMMouseScroll mousewheel keyup", function( e ){
148
  if ( e.which > 0 || e.type === "mousedown" || e.type === "mousewheel") {
@@ -150,10 +149,12 @@ jQuery( document ).ready( function($) {
150
  }
151
  });
152
 
 
 
153
  });
154
 
155
  // Change color
156
- $( 'body' ).on( 'click', '.color', function() {
157
 
158
  // Set variables
159
  var color = $( this ).attr( 'data-select-color' );
@@ -164,21 +165,22 @@ jQuery( document ).ready( function($) {
164
  $( this ).closest( '.wp-dashboard-note-wrap' ).attr( 'data-color-text', color_text );
165
 
166
  // Set saving attributes
167
- $( '[data-note-color]' ).attr( 'data-note-color', color );
168
  $( this ).closest( '[data-color-text]' ).attr( 'data-color-text', color_text );
169
 
170
  // Update note
171
  $( this ).trigger( 'wpdn-update', this );
 
172
  });
173
 
174
 
175
  // Edit/update note
176
- $( 'body' ).on( 'blur', '.list-item-content, [contenteditable=true]', function() {
177
  $( this ).trigger( 'wpdn-update', this );
178
  });
179
 
180
  // Save on enter (list note)
181
- $( 'body' ).on( 'keydown', '[data-note-type=list], .wpdn-title, .list-item-content', function( e ) {
182
  if ( e.keyCode == 13 ) {
183
  $( this ).trigger( 'wpdn-update', this );
184
  $( this ).blur();
@@ -186,7 +188,7 @@ jQuery( document ).ready( function($) {
186
  }
187
  });
188
  // Save on CMD|CTRL + enter (regular note)
189
- $( 'body' ).on( 'keydown', '[data-note-type=regular] .wp-dashboard-note', function( e ) {
190
  if ( e.keyCode == 13 && ( e.ctrlKey || e.metaKey ) ) {
191
  $( this ).trigger( 'wpdn-update', this );
192
  $( this ).blur();
@@ -196,7 +198,7 @@ jQuery( document ).ready( function($) {
196
 
197
 
198
  // Edit title
199
- $( 'body, .postbox h3' ).on( 'click', '.wpdn-edit-title', function( e ) {
200
  $( this ).prev().focus();
201
  document.execCommand( 'selectAll', false, null );
202
  e.stopPropagation();
@@ -215,15 +217,31 @@ jQuery( document ).ready( function($) {
215
 
216
 
217
  // Make list sortable
218
- $( 'body' ).on( 'note-sortable', function() {
219
  $( '.wp-dashboard-note' ).sortable({
220
  handle: '.wpdn-note-sortable',
221
  update: function( event, ui ) {
222
  $( this ).trigger( 'wpdn-update', this );
223
- }
 
 
224
  });
225
  })
226
  .trigger( 'note-sortable' );
227
 
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  });
4
  var saved_icon = '<span class="saved-icon"><div class="dashicons dashicons-yes"></div> saved!</span>';
5
 
6
 
7
+ // Add list item
8
  $( 'body, .list-item-content' ).on( 'keydown', '.add-list-item', function( e ) {
9
 
10
  if( e.keyCode == 13 && $( this ).val() != '' ) {
23
  });
24
 
25
 
26
+ // Delete list item
27
+ $( document.body ).on( 'click', '.delete-item', function() {
28
 
29
  var post_id = $( this ).closest( ".postbox" ).attr( 'id' );
30
 
31
  $( this ).parent( '.list-item' ).remove();
32
+ $( document.body ).trigger( 'wpdn-update', ['', post_id] );
33
 
34
  });
35
 
36
 
37
  // Toggle visibility
38
+ $( document.body ).on( 'click', '.wpdn-visibility', function() {
39
 
40
+ $( this ).toggleClass( 'dashicons-admin-users dashicons-groups' );
41
 
42
  var visibility = $( this ).parent().attr( 'data-visibility' );
43
  if ( 'public' == visibility ) {
54
 
55
 
56
  // Toggle note type
57
+ $( document.body ).on( 'click', '.wpdn-note-type', function() {
58
 
59
  $( this ).toggleClass( 'dashicons-list-view dashicons-welcome-write-blog' );
60
 
68
  var data = {
69
  action: 'wpdn_toggle_note',
70
  post_id: $( this ).closest( ".postbox" ).attr( 'id' ).replace( 'note_', '' ),
71
+ note_type: ( note_type == 'regular' ? 'list' : 'regular' ),
72
+ nonce: wpdn.nonce
73
  };
74
 
75
  $.post( ajaxurl, data, function( response ) {
82
 
83
 
84
  // Update note trigger
85
+ $( document.body ).on( 'wpdn-update', function( event, t, post_id ) {
86
 
87
  if ( t != '' ) {
88
  post_id = $( t ).closest( ".postbox" ).attr( 'id' );
89
  }
90
+
91
  if ( ! post_id ) {
92
  return;
93
  }
94
 
95
+ $( '#' + post_id + ' .hndle .status' ).html( loading_icon );
96
  var data = {
97
  action: 'wpdn_update_note',
98
  post_id: post_id.replace( 'note_', '' ),
99
  post_content: $( '#' + post_id + ' div.wp-dashboard-note' ).html(),
100
+ post_title: $( '#' + post_id + ' > .hndle .wpdn-title' ).html(),
101
  note_visibility: $( '#' + post_id + ' [data-visibility]' ).attr( 'data-visibility' ),
102
  note_color_text: $( '#' + post_id + ' [data-color-text]' ).attr( 'data-color-text' ),
103
  note_color: $( '#' + post_id + ' [data-note-color]' ).attr( 'data-note-color' ),
104
+ note_type: $( '#' + post_id + ' [data-note-type]' ).attr( 'data-note-type' ),
105
+ nonce: wpdn.nonce
106
  };
107
 
108
  $.post( ajaxurl, data, function( response ) {
109
+ $( '#' + post_id + ' .hndle .status' ).html( saved_icon );
110
+ $( '#' + post_id + ' .hndle .status *' ).fadeOut( 1000, function() { $( this ).html( '' ) });
111
  });
112
 
113
  });
114
 
115
 
116
  // Delete note
117
+ $( document.body ).on( 'click', '.wpdn-delete-note', function() {
118
 
119
  var post_id = $( this ).closest( ".postbox" ).attr( 'id' );
120
 
121
+ $( '#' + post_id ).slideUp( 500, function() { $( this ).remove() } );
122
 
123
  var data = {
124
+ action: 'wpdn_delete_note',
125
  post_id: post_id.replace( 'note_', '' ),
126
+ nonce: wpdn.nonce
127
  };
128
+ $.post( ajaxurl, data );
 
 
 
129
 
130
  });
131
 
132
 
133
  // Add note
134
+ $( document.body ).on( 'click', '.wpdn-add-note, #wp-admin-bar-wpdn-add-note a', function( e ) {
135
 
136
+ var data = { action: 'wpdn_add_note', nonce: wpdn.nonce };
137
 
138
  $.post( ajaxurl, data, function( response ) {
139
  response = jQuery.parseJSON( response );
142
  jQuery( '#note_' + response.post_id + ' .add-list-item' ).focus();
143
  });
144
 
 
145
  // Stop scrollTop animation on user scroll
146
  $( 'html, body' ).bind("scroll mousedown DOMMouseScroll mousewheel keyup", function( e ){
147
  if ( e.which > 0 || e.type === "mousedown" || e.type === "mousewheel") {
149
  }
150
  });
151
 
152
+ e.preventDefault();
153
+
154
  });
155
 
156
  // Change color
157
+ $( document.body ).on( 'click', '.color', function() {
158
 
159
  // Set variables
160
  var color = $( this ).attr( 'data-select-color' );
165
  $( this ).closest( '.wp-dashboard-note-wrap' ).attr( 'data-color-text', color_text );
166
 
167
  // Set saving attributes
168
+ $( this ).closest( '[data-note-color]' ).attr( 'data-note-color', color );
169
  $( this ).closest( '[data-color-text]' ).attr( 'data-color-text', color_text );
170
 
171
  // Update note
172
  $( this ).trigger( 'wpdn-update', this );
173
+
174
  });
175
 
176
 
177
  // Edit/update note
178
+ $( document.body ).on( 'blur', '.list-item-content, [contenteditable=true]', function() {
179
  $( this ).trigger( 'wpdn-update', this );
180
  });
181
 
182
  // Save on enter (list note)
183
+ $( document.body ).on( 'keydown', '[data-note-type=list], .wpdn-title, .list-item-content', function( e ) {
184
  if ( e.keyCode == 13 ) {
185
  $( this ).trigger( 'wpdn-update', this );
186
  $( this ).blur();
188
  }
189
  });
190
  // Save on CMD|CTRL + enter (regular note)
191
+ $( document.body ).on( 'keydown', '[data-note-type=regular] .wp-dashboard-note', function( e ) {
192
  if ( e.keyCode == 13 && ( e.ctrlKey || e.metaKey ) ) {
193
  $( this ).trigger( 'wpdn-update', this );
194
  $( this ).blur();
198
 
199
 
200
  // Edit title
201
+ $( 'body, .postbox .hndle' ).on( 'click', '.wpdn-edit-title', function( e ) {
202
  $( this ).prev().focus();
203
  document.execCommand( 'selectAll', false, null );
204
  e.stopPropagation();
217
 
218
 
219
  // Make list sortable
220
+ $( document.body ).on( 'note-sortable', function() {
221
  $( '.wp-dashboard-note' ).sortable({
222
  handle: '.wpdn-note-sortable',
223
  update: function( event, ui ) {
224
  $( this ).trigger( 'wpdn-update', this );
225
+ },
226
+ connectWith: ['.wp-dashboard-note'],
227
+ axis: 'y'
228
  });
229
  })
230
  .trigger( 'note-sortable' );
231
 
232
 
233
+ // Open link box when hovering a link
234
+ $( '.wp-dashboard-note-wrap a' ).hover( function() {
235
+ $( this ).append( '<span class="link-hover" contenteditable="false"><a href="' + $( this ).attr( 'href' ) + '" target="_blank" contenteditable="false">Open link</a></span>' );
236
+ }, function() {
237
+ $( '.link-hover' ).remove();
238
+ });
239
+
240
+ // Prevent background color and other style from copying from one note to the other
241
+ $( document.body ).on('paste', '[contenteditable]', function (e) {
242
+ e.preventDefault();
243
+ var text = (e.originalEvent || e).clipboardData.getData('text/plain');
244
+ document.execCommand('insertText', false, text);
245
+ });
246
+
247
  });
assets/js/wp-dashboard-notes-admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function($){var t='<span class="saving-icon"><img src="images/wpspin_light.gif"/> saving...</span>',e='<span class="saved-icon"><div class="dashicons dashicons-yes"></div> saved!</span>';$("body, .list-item-content").on("keydown",".add-list-item",function(t){if(13==t.keyCode&&""!=$(this).val()){var e=$(this).closest(".postbox").attr("id"),o='<div class="list-item"><div class="dashicons dashicons-menu wpdn-note-sortable"></div><input type="checkbox"><span class="list-item-content" contenteditable="true">'+$(this).val()+'</span><div class="delete-item dashicons dashicons-no-alt"></div></div>';$("#"+e+" div.wp-dashboard-note").append(o),$(this).val(""),$(this).trigger("note-sortable"),$(this).trigger("wpdn-update",this)}}),$(document.body).on("click",".delete-item",function(){var t=$(this).closest(".postbox").attr("id");$(this).parent(".list-item").remove(),$(document.body).trigger("wpdn-update",["",t])}),$(document.body).on("click",".wpdn-visibility",function(){$(this).toggleClass("dashicons-admin-users dashicons-groups");var t=$(this).parent().attr("data-visibility");"public"==t?($(this).parent(".wpdn-toggle-visibility").attr("data-visibility","private"),$(this).parent(".wpdn-toggle-visibility").attr("title","Visibility: Just me")):($(this).parent(".wpdn-toggle-visibility").attr("data-visibility","public"),$(this).parent(".wpdn-toggle-visibility").attr("title","Visibility: Everyone")),$(this).trigger("wpdn-update",this)}),$(document.body).on("click",".wpdn-note-type",function(){$(this).toggleClass("dashicons-list-view dashicons-welcome-write-blog");var t=$(this).closest("[data-note-type]").attr("data-note-type");"regular"==t?$(this).closest("[data-note-type]").attr("data-note-type","list"):$(this).closest("[data-note-type]").attr("data-note-type","regular");var e={action:"wpdn_toggle_note",post_id:$(this).closest(".postbox").attr("id").replace("note_",""),note_type:"regular"==t?"list":"regular",nonce:wpdn.nonce};$.post(ajaxurl,e,function(t){$("#note_"+e.post_id+" .inside").html(t).trigger("note-sortable")}),$(this).trigger("wpdn-update",this)}),$(document.body).on("wpdn-update",function(o,n,i){if(""!=n&&(i=$(n).closest(".postbox").attr("id")),i){$("#"+i+" .hndle .status").html(t);var a={action:"wpdn_update_note",post_id:i.replace("note_",""),post_content:$("#"+i+" div.wp-dashboard-note").html(),post_title:$("#"+i+" > .hndle .wpdn-title").html(),note_visibility:$("#"+i+" [data-visibility]").attr("data-visibility"),note_color_text:$("#"+i+" [data-color-text]").attr("data-color-text"),note_color:$("#"+i+" [data-note-color]").attr("data-note-color"),note_type:$("#"+i+" [data-note-type]").attr("data-note-type"),nonce:wpdn.nonce};$.post(ajaxurl,a,function(t){$("#"+i+" .hndle .status").html(e),$("#"+i+" .hndle .status *").fadeOut(1e3,function(){$(this).html("")})})}}),$(document.body).on("click",".wpdn-delete-note",function(){var t=$(this).closest(".postbox").attr("id");$("#"+t).slideUp(500,function(){$(this).remove()});var e={action:"wpdn_delete_note",post_id:t.replace("note_",""),nonce:wpdn.nonce};$.post(ajaxurl,e)}),$(document.body).on("click",".wpdn-add-note, #wp-admin-bar-wpdn-add-note a",function(t){var e={action:"wpdn_add_note",nonce:wpdn.nonce};$.post(ajaxurl,e,function(t){t=jQuery.parseJSON(t),jQuery("#postbox-container-1 #normal-sortables").append(t.note),jQuery("body, html").animate({scrollTop:$("#note_"+t.post_id).offset().top-50},750),jQuery("#note_"+t.post_id+" .add-list-item").focus()}),$("html, body").bind("scroll mousedown DOMMouseScroll mousewheel keyup",function(t){(t.which>0||"mousedown"===t.type||"mousewheel"===t.type)&&$("html, body").stop().unbind("scroll mousedown DOMMouseScroll mousewheel keyup")}),t.preventDefault()}),$(document.body).on("click",".color",function(){var t=$(this).attr("data-select-color"),e=$(this).attr("data-select-color-text");$(this).closest(".postbox").css("background-color",t),$(this).closest(".wp-dashboard-note-wrap").attr("data-color-text",e),$(this).closest("[data-note-color]").attr("data-note-color",t),$(this).closest("[data-color-text]").attr("data-color-text",e),$(this).trigger("wpdn-update",this)}),$(document.body).on("blur",".list-item-content, [contenteditable=true]",function(){$(this).trigger("wpdn-update",this)}),$(document.body).on("keydown","[data-note-type=list], .wpdn-title, .list-item-content",function(t){return 13==t.keyCode?($(this).trigger("wpdn-update",this),$(this).blur(),!1):void 0}),$(document.body).on("keydown","[data-note-type=regular] .wp-dashboard-note",function(t){return 13==t.keyCode&&(t.ctrlKey||t.metaKey)?($(this).trigger("wpdn-update",this),$(this).blur(),!1):void 0}),$("body, .postbox .hndle").on("click",".wpdn-edit-title",function(t){$(this).prev().focus(),document.execCommand("selectAll",!1,null),t.stopPropagation()}),$("input[type=checkbox]").change(function(){this.checked?$(this).attr("checked","checked"):$(this).removeAttr("checked"),$(this).trigger("wpdn-update",this)}),$(document.body).on("note-sortable",function(){$(".wp-dashboard-note").sortable({handle:".wpdn-note-sortable",update:function(t,e){$(this).trigger("wpdn-update",this)},connectWith:[".wp-dashboard-note"],axis:"y"})}).trigger("note-sortable"),$(".wp-dashboard-note-wrap a").hover(function(){$(this).append('<span class="link-hover" contenteditable="false"><a href="'+$(this).attr("href")+'" target="_blank" contenteditable="false">Open link</a></span>')},function(){$(".link-hover").remove()}),$(document.body).on("paste","[contenteditable]",function(t){t.preventDefault();var e=(t.originalEvent||t).clipboardData.getData("text/plain");document.execCommand("insertText",!1,e)})});
includes/class-note-post-type.php CHANGED
@@ -2,28 +2,29 @@
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
  /**
5
- * Class Note_Post_Type
6
  *
7
  * Register and handle post type registration.
8
  *
9
- * @class Note_Post_Type
10
- * @version 1.0.0
11
  * @package WP Dashboard Notes
12
- * @author Jeroen Sormani
13
  */
14
  class Note_Post_Type {
15
 
16
 
17
  /**
18
- * __construct function.
19
  *
20
  * @since 1.0.0
21
  */
22
  public function __construct() {
23
 
24
- $this->note_register_post_type();
 
25
 
26
- }
27
 
28
 
29
  /**
@@ -33,37 +34,38 @@ class Note_Post_Type {
33
  *
34
  * @since 1.0.0
35
  */
36
- public function note_register_post_type() {
37
 
38
  $labels = array(
39
- 'name' => __( 'Notes', 'wp-dashboard-notes' ),
40
- 'singular_name' => __( 'Note', 'wp-dashboard-notes' ),
41
- 'add_new' => __( 'Add New', 'wp-dashboard-notes' ),
42
- 'add_new_item' => __( 'Add New Note' , 'wp-dashboard-notes' ),
43
- 'edit_item' => __( 'Edit Note' , 'wp-dashboard-notes' ),
44
- 'new_item' => __( 'New Note' , 'wp-dashboard-notes' ),
45
- 'view_item' => __( 'View Note', 'wp-dashboard-notes' ),
46
- 'search_items' => __( 'Search Notes', 'wp-dashboard-notes' ),
47
- 'not_found' => __( 'No Notes', 'wp-dashboard-notes' ),
48
- 'not_found_in_trash' => __( 'No Notes found in Trash', 'wp-dashboard-notes' ),
49
  );
50
 
51
  register_post_type( 'note', array(
52
- 'label' => 'note',
53
- 'show_ui' => false,
54
- 'show_in_menu' => false,
55
- 'capability_type' => 'post',
56
- 'map_meta_cap' => true,
57
- 'rewrite' => array( 'slug' => 'notes' ),
58
- '_builtin' => false,
59
- 'query_var' => true,
60
- 'supports' => array( 'title', 'editor' ),
61
- 'labels' => $labels,
62
  ) );
63
 
64
  }
65
 
 
66
  }
67
 
68
- global $wpdn_post_type;
69
- $wpdn_post_type = new Note_Post_Type();
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
  /**
5
+ * Class Note_Post_Type.
6
  *
7
  * Register and handle post type registration.
8
  *
9
+ * @class Note_Post_Type
10
+ * @version 1.0.0
11
  * @package WP Dashboard Notes
12
+ * @author Jeroen Sormani
13
  */
14
  class Note_Post_Type {
15
 
16
 
17
  /**
18
+ * Constructor.
19
  *
20
  * @since 1.0.0
21
  */
22
  public function __construct() {
23
 
24
+ // Register post type
25
+ add_action( 'init', array( $this, 'register_post_type' ) );
26
 
27
+ }
28
 
29
 
30
  /**
34
  *
35
  * @since 1.0.0
36
  */
37
+ public function register_post_type() {
38
 
39
  $labels = array(
40
+ 'name' => __( 'Notes', 'wp-dashboard-notes' ),
41
+ 'singular_name' => __( 'Note', 'wp-dashboard-notes' ),
42
+ 'add_new' => __( 'Add New', 'wp-dashboard-notes' ),
43
+ 'add_new_item' => __( 'Add New Note', 'wp-dashboard-notes' ),
44
+ 'edit_item' => __( 'Edit Note', 'wp-dashboard-notes' ),
45
+ 'new_item' => __( 'New Note', 'wp-dashboard-notes' ),
46
+ 'view_item' => __( 'View Note', 'wp-dashboard-notes' ),
47
+ 'search_items' => __( 'Search Notes', 'wp-dashboard-notes' ),
48
+ 'not_found' => __( 'No Notes', 'wp-dashboard-notes' ),
49
+ 'not_found_in_trash' => __( 'No Notes found in Trash', 'wp-dashboard-notes' ),
50
  );
51
 
52
  register_post_type( 'note', array(
53
+ 'label' => 'note',
54
+ 'show_ui' => false,
55
+ 'show_in_menu' => false,
56
+ 'capability_type' => 'post',
57
+ 'map_meta_cap' => true,
58
+ 'rewrite' => array( 'slug' => 'notes' ),
59
+ '_builtin' => false,
60
+ 'query_var' => true,
61
+ 'supports' => array( 'title', 'editor' ),
62
+ 'labels' => $labels,
63
  ) );
64
 
65
  }
66
 
67
+
68
  }
69
 
70
+ // Backwards compatibility
71
+ $GLOBALS['wpdn_post_type'] = WP_Dashboard_Notes()->post_type;
includes/class-wpdn-admin.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ /**
5
+ * Class WPDN_Admin.
6
+ *
7
+ * Admin class holds all admin related functions.
8
+ *
9
+ * @class WPDN_Admin
10
+ * @version 1.0.0
11
+ * @author Jeroen Sormani
12
+ */
13
+ class WPDN_Admin {
14
+
15
+
16
+ /**
17
+ * Constructor.
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+ public function __construct() {
22
+
23
+ // Admin bar 'add note' button
24
+ add_action( 'admin_bar_menu', array( $this, 'admin_bar_add_note' ) );
25
+
26
+ }
27
+
28
+
29
+ /**
30
+ * Admin bar add note.
31
+ *
32
+ * Add a item to the admin bar to add a new note.
33
+ *
34
+ * @since 1.0.7
35
+ *
36
+ * @param $wp_admin_bar Arg that will allow one to add new items.
37
+ */
38
+ public function admin_bar_add_note( &$wp_admin_bar ) {
39
+
40
+ $screen = get_current_screen();
41
+
42
+ // Only show on dashboard
43
+ if ( 'dashboard' !== $screen->id ) {
44
+ return;
45
+ }
46
+
47
+ $wp_admin_bar->add_menu( array(
48
+ 'id' => 'wpdn-add-note',
49
+ 'parent' => 'top-secondary',
50
+ 'title' => '+ ' . __( 'Add note', 'wp-dashboard-notes' ),
51
+ 'href' => 'javascript:void(0);',
52
+ ) );
53
+
54
+ }
55
+
56
+
57
+ }
includes/class-wpdn-ajax.php CHANGED
@@ -2,12 +2,12 @@
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
  /**
5
- * Class WPDN_Ajax
6
  *
7
  * Class to handle all AJAX calls.
8
  *
9
  * @class WPDN_Ajax
10
- * @version 1.0.0
11
  * @package WP Dashboard Notes
12
  * @author Jeroen Sormani
13
  */
@@ -15,7 +15,7 @@ class WPDN_Ajax {
15
 
16
 
17
  /**
18
- * Construct function.
19
  *
20
  * Add ajax actions.
21
  *
@@ -41,23 +41,45 @@ class WPDN_Ajax {
41
  *
42
  * @since 1.0.0
43
  */
44
- public function wpdn_update_note() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  $post = array(
47
- 'ID' => $_POST['post_id'],
48
- 'post_title' => $_POST['post_title'],
49
- 'post_content' => $_POST['post_content'],
50
  );
51
 
52
  wp_update_post( $post );
53
 
54
  $note_meta = array(
55
- 'color' => $_POST['note_color'],
56
- 'color_text' => $_POST['note_color_text'],
57
- 'visibility' => $_POST['note_visibility'],
58
- 'note_type' => $_POST['note_type'],
59
  );
60
- update_post_meta( $_POST['post_id'], '_note', $note_meta );
61
 
62
  die();
63
 
@@ -73,8 +95,29 @@ class WPDN_Ajax {
73
  */
74
  public function wpdn_toggle_note() {
75
 
76
- $note = get_post( $_POST['post_id'] );
77
- $note_meta = WP_Dashboard_Notes::wpdn_get_note_meta( $note->ID );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  ?>
80
  <style>
@@ -102,52 +145,68 @@ class WPDN_Ajax {
102
  */
103
  public function wpdn_add_note() {
104
 
 
 
105
  $args = array(
106
- 'post_status' => 'publish',
107
- 'post_type' => 'note',
108
- 'post_title' => __( 'New note', 'wp-dashboard-notes' ),
109
  );
110
  $post_id = wp_insert_post( $args );
111
-
112
- $note = (object) array( 'post_content' => '' );
113
- $note_meta = array(
114
- 'color' => '#ffffff',
115
- 'color_text' => 'white',
116
- 'visibility' => 'Everyone',
117
- 'note_type' => 'list',
118
- );
 
 
 
 
 
 
 
 
 
 
119
  $note_meta = apply_filters( 'wpdn_new_note_meta', $note_meta );
120
  update_post_meta( $post_id, '_note', $note_meta );
121
 
 
 
122
  ob_start(); ?>
123
-
124
  <div id='note_<?php echo $post_id; ?>' class='postbox'>
125
  <div class='handlediv' title='Click to toggle'><br></div>
126
- <h3 class="hndle">
127
  <span>
128
  <span contenteditable="true" class="wpdn-title"><?php _e( 'New note', 'wp-dashboard-notes' ); ?></span>
129
  <div class="wpdn-edit-title dashicons dashicons-edit"></div>
 
130
  </span>
131
- </h3>
132
 
133
  <div class='inside'>
134
-
135
  <style>
 
136
  #note_<?php echo $post_id; ?> .hndle { border: none; }
137
  </style>
138
-
139
  <?php if ( 'regular' == $note_meta['note_type'] ) :
140
  require plugin_dir_path( __FILE__ ) . 'templates/note.php';
141
  else :
142
  require plugin_dir_path( __FILE__ ) . 'templates/note-list.php';
143
  endif; ?>
144
-
145
  </div> <!-- .inside -->
146
  </div> <!-- .postbox -->
147
 
148
  <?php
149
- $return['note'] = ob_get_clean();
150
- $return['post_id'] = $post_id;
151
 
152
  echo json_encode( $return );
153
 
@@ -165,7 +224,21 @@ class WPDN_Ajax {
165
  */
166
  public function wpdn_delete_note() {
167
 
168
- $post_id = (int) $_POST['post_id'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  wp_trash_post( $post_id );
170
  die();
171
 
@@ -173,5 +246,3 @@ class WPDN_Ajax {
173
 
174
 
175
  }
176
- new WPDN_Ajax();
177
- ?>
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
  /**
5
+ * Class WPDN_Ajax.
6
  *
7
  * Class to handle all AJAX calls.
8
  *
9
  * @class WPDN_Ajax
10
+ * @version 1.0.0
11
  * @package WP Dashboard Notes
12
  * @author Jeroen Sormani
13
  */
15
 
16
 
17
  /**
18
+ * Constructor.
19
  *
20
  * Add ajax actions.
21
  *
41
  *
42
  * @since 1.0.0
43
  */
44
+ public function wpdn_update_note() {
45
+
46
+ check_ajax_referer( 'wpdn-ajax-nonce', 'nonce' );
47
+
48
+ $post_id = absint( $_POST['post_id'] );
49
+
50
+ $curr_note_meta = get_post_meta( $post_id, '_note', true );
51
+ $curr_note_visibility = $curr_note_meta['visibility'];
52
+
53
+ if ( $curr_note_visibility != 'public' && ! current_user_can( 'edit_posts' ) ) {
54
+ die();
55
+ }
56
+
57
+ if ( get_post_type( $post_id ) != 'note' ) {
58
+ die();
59
+ }
60
+
61
+ global $allowedposttags;
62
+ $allowed_html_tags = $allowedposttags;
63
+ $allowed_html_tags['input'] = array(
64
+ 'type' => 1,
65
+ 'checked' => 1,
66
+ );
67
 
68
  $post = array(
69
+ 'ID' => $post_id,
70
+ 'post_title' => sanitize_text_field( $_POST['post_title'] ),
71
+ 'post_content' => wp_kses( $_POST['post_content'], $allowed_html_tags ),
72
  );
73
 
74
  wp_update_post( $post );
75
 
76
  $note_meta = array(
77
+ 'color' => sanitize_text_field( $_POST['note_color'] ),
78
+ 'color_text' => sanitize_text_field( $_POST['note_color_text'] ),
79
+ 'visibility' => sanitize_text_field( $_POST['note_visibility'] ),
80
+ 'note_type' => sanitize_text_field( $_POST['note_type'] ),
81
  );
82
+ update_post_meta( $post_id, '_note', $note_meta );
83
 
84
  die();
85
 
95
  */
96
  public function wpdn_toggle_note() {
97
 
98
+ check_ajax_referer( 'wpdn-ajax-nonce', 'nonce' );
99
+
100
+ $post_id = absint( $_POST['post_id'] );
101
+
102
+ $curr_note_meta = get_post_meta( $post_id, '_note', true );
103
+ $curr_note_visibility = $curr_note_meta['visibility'];
104
+
105
+ if ( $curr_note_visibility != 'public' && ! current_user_can( 'edit_posts' ) ) {
106
+ die();
107
+ }
108
+
109
+ $note = get_post( $post_id );
110
+ $content = apply_filters( 'wpdn_content', $note->post_content );
111
+ $colors = apply_filters( 'wpdn_colors', array(
112
+ 'white' => '#fff',
113
+ 'red' => '#f7846a',
114
+ 'orange' => '#ffbd22',
115
+ 'yellow' => '#eeee22',
116
+ 'green' => '#bbe535',
117
+ 'blue' => '#66ccdd',
118
+ 'black' => '#777777',
119
+ ) );
120
+ $note_meta = WP_Dashboard_Notes::wpdn_get_note_meta( $note->ID );
121
 
122
  ?>
123
  <style>
145
  */
146
  public function wpdn_add_note() {
147
 
148
+ check_ajax_referer( 'wpdn-ajax-nonce', 'nonce' );
149
+
150
  $args = array(
151
+ 'post_status' => 'publish',
152
+ 'post_type' => 'note',
153
+ 'post_title' => __( 'New note', 'wp-dashboard-notes' ),
154
  );
155
  $post_id = wp_insert_post( $args );
156
+
157
+ $note = (object) array( 'ID' => $post_id, 'post_content' => '' );
158
+ $note_meta = apply_filters( 'wpdn_new_note_meta', array(
159
+ 'color' => '#ffffff',
160
+ 'color_text' => 'white',
161
+ 'visibility' => 'public',
162
+ 'note_type' => 'list',
163
+ ) );
164
+ $content = apply_filters( 'wpdn_content', $note->post_content );
165
+ $colors = apply_filters( 'wpdn_colors', array(
166
+ 'white' => '#fff',
167
+ 'red' => '#f7846a',
168
+ 'orange' => '#ffbd22',
169
+ 'yellow' => '#eeee22',
170
+ 'green' => '#bbe535',
171
+ 'blue' => '#66ccdd',
172
+ 'black' => '#777777',
173
+ ) );
174
  $note_meta = apply_filters( 'wpdn_new_note_meta', $note_meta );
175
  update_post_meta( $post_id, '_note', $note_meta );
176
 
177
+ $title_tag = version_compare( get_bloginfo( 'version' ), '4.4', '>=' ) ? 'h2' : 'h3';
178
+
179
  ob_start(); ?>
180
+
181
  <div id='note_<?php echo $post_id; ?>' class='postbox'>
182
  <div class='handlediv' title='Click to toggle'><br></div>
183
+ <<?php echo $title_tag; ?> class="hndle">
184
  <span>
185
  <span contenteditable="true" class="wpdn-title"><?php _e( 'New note', 'wp-dashboard-notes' ); ?></span>
186
  <div class="wpdn-edit-title dashicons dashicons-edit"></div>
187
+ <span class="status"></span>
188
  </span>
189
+ </<?php echo $title_tag; ?>>
190
 
191
  <div class='inside'>
192
+
193
  <style>
194
+ #note_<?php echo $post_id; ?> { background-color: <?php echo $note_meta['color']; ?>; }
195
  #note_<?php echo $post_id; ?> .hndle { border: none; }
196
  </style>
197
+
198
  <?php if ( 'regular' == $note_meta['note_type'] ) :
199
  require plugin_dir_path( __FILE__ ) . 'templates/note.php';
200
  else :
201
  require plugin_dir_path( __FILE__ ) . 'templates/note-list.php';
202
  endif; ?>
203
+
204
  </div> <!-- .inside -->
205
  </div> <!-- .postbox -->
206
 
207
  <?php
208
+ $return['note'] = ob_get_clean();
209
+ $return['post_id'] = $post_id;
210
 
211
  echo json_encode( $return );
212
 
224
  */
225
  public function wpdn_delete_note() {
226
 
227
+ check_ajax_referer( 'wpdn-ajax-nonce', 'nonce' );
228
+
229
+ $post_id = absint( $_POST['post_id'] );
230
+
231
+ $curr_note_meta = get_post_meta( $post_id, '_note', true );
232
+ $curr_note_visibility = $curr_note_meta['visibility'];
233
+
234
+ if ( $curr_note_visibility != 'public' && ! current_user_can( 'edit_posts' ) ) {
235
+ die();
236
+ }
237
+
238
+ if ( get_post_type( $post_id ) != 'note' ) {
239
+ die();
240
+ }
241
+
242
  wp_trash_post( $post_id );
243
  die();
244
 
246
 
247
 
248
  }
 
 
includes/templates/note-list.php CHANGED
@@ -1,24 +1,24 @@
1
- <div class='wp-dashboard-note-wrap list-note' data-note-type='list' data-color-text='<?php echo $note_meta['color_text']; ?>'>
2
 
3
  <div class='wp-dashboard-note'>
4
- <?php echo $note->post_content; ?>
5
  </div>
6
 
7
  <div class='wp-dashboard-note-options'>
8
  <div class='dashicons dashicons-plus wpdn-add-item'></div>
9
- <input type='text' name='list_item' class='add-list-item' data-id='<?php echo $note->ID; ?>' placeholder='<?php _e( 'List item', 'wp-dashboard-notes' ); ?>' value=''>
10
  <span class='status'></span>
11
  <div class='wpdn-extra'>
12
  <span class='wpdn-option-visibility'>
13
  <?php
14
  if ( 'private' == $note_meta['visibility'] && $note_meta ) :
15
- $status['icon'] = 'dashicons-lock';
16
- $status['title'] = __( 'Just me', 'wp-dashboard-notes' );
17
- $status['visibility'] = 'private';
18
  else :
19
- $status['icon'] = 'dashicons-groups';
20
- $status['title'] = __( 'Everyone', 'wp-dashboard-notes' );
21
- $status['visibility'] = 'public';
22
  endif; ?>
23
 
24
  <span class='wpdn-toggle-visibility' title='<?php _e( 'Visibility:', 'wp-dashboard-notes' ); ?> <?php echo $status['title']; ?>' data-visibility='<?php echo $status['visibility']; ?>'>
@@ -27,15 +27,13 @@
27
 
28
  <span class='wpdn-color-note' title='<?php _e( 'Give me a color!', 'wp-dashboard-notes' ); ?>'>
29
  <span class='wpdn-color-palette'>
30
- <span class='color color-white' data-select-color-text='white' data-select-color='#ffffff'></span>
31
- <span class='color color-red' data-select-color-text='red' data-select-color='#f7846a'></span>
32
- <span class='color color-orange' data-select-color-text='orange' data-select-color='#ffbd22'></span>
33
- <span class='color color-yellow' data-select-color-text='yellow' data-select-color='#eeee22'></span>
34
- <span class='color color-green' data-select-color-text='green' data-select-color='#bbe535'></span>
35
- <span class='color color-blue' data-select-color-text='blue' data-select-color='#66ccdd'></span>
36
- <span class='color color-black' data-select-color-text='black' data-select-color='#777777'></span>
37
  </span>
38
- <div class='dashicons dashicons-art wpdn-note-color' data-note-color='<?php echo $note_meta['color']; ?>'></div>
39
  </span>
40
 
41
  <span title='<?php _e( 'Convert to regular note', 'wp-dashboard-notes'); ?>'>
1
+ <div class='wp-dashboard-note-wrap list-note' data-note-type='list' data-color-text='<?php echo $note_meta['color_text']; ?>' data-note-color='<?php echo $note_meta['color']; ?>'>
2
 
3
  <div class='wp-dashboard-note'>
4
+ <?php echo $content; ?>
5
  </div>
6
 
7
  <div class='wp-dashboard-note-options'>
8
  <div class='dashicons dashicons-plus wpdn-add-item'></div>
9
+ <input type='text' name='list_item' class='add-list-item' data-id='<?php echo $note->ID; ?>' placeholder='<?php _e( 'List item', 'wp-dashboard-notes' ); ?>'>
10
  <span class='status'></span>
11
  <div class='wpdn-extra'>
12
  <span class='wpdn-option-visibility'>
13
  <?php
14
  if ( 'private' == $note_meta['visibility'] && $note_meta ) :
15
+ $status['icon'] = 'dashicons-admin-users';
16
+ $status['title'] = __( 'Just me', 'wp-dashboard-notes' );
17
+ $status['visibility'] = 'private';
18
  else :
19
+ $status['icon'] = 'dashicons-groups';
20
+ $status['title'] = __( 'Everyone', 'wp-dashboard-notes' );
21
+ $status['visibility'] = 'public';
22
  endif; ?>
23
 
24
  <span class='wpdn-toggle-visibility' title='<?php _e( 'Visibility:', 'wp-dashboard-notes' ); ?> <?php echo $status['title']; ?>' data-visibility='<?php echo $status['visibility']; ?>'>
27
 
28
  <span class='wpdn-color-note' title='<?php _e( 'Give me a color!', 'wp-dashboard-notes' ); ?>'>
29
  <span class='wpdn-color-palette'>
30
+
31
+ <?php foreach ( $colors as $name => $color ) : ?>
32
+ <span class='color color-<?php echo $name;?>' data-select-color-text='<?php echo $name; ?>' data-select-color='<?php echo $color; ?>' style='background-color: <?php echo $color; ?>'></span>
33
+ <?php endforeach; ?>
34
+
 
 
35
  </span>
36
+ <div class='dashicons dashicons-art wpdn-note-color'></div>
37
  </span>
38
 
39
  <span title='<?php _e( 'Convert to regular note', 'wp-dashboard-notes'); ?>'>
includes/templates/note.php CHANGED
@@ -1,7 +1,7 @@
1
- <div class='wp-dashboard-note-wrap regular-note' data-note-type='regular' data-color-text='<?php echo $note_meta['color_text']; ?>'>
2
 
3
  <div class='wp-dashboard-note' contenteditable='true'>
4
- <?php echo $note->post_content; ?>
5
  </div>
6
 
7
  <div class='wp-dashboard-note-options'>
@@ -11,13 +11,13 @@
11
  <span class='wpdn-option-visibility'>
12
  <?php
13
  if ( 'private' == $note_meta['visibility'] && $note_meta ) :
14
- $status['icon'] = 'dashicons-lock';
15
- $status['title'] = __( 'Just me', 'wp-dashboard-notes' );
16
- $status['visibility'] = 'private';
17
  else :
18
- $status['icon'] = 'dashicons-groups';
19
- $status['title'] = __( 'Everyone', 'wp-dashboard-notes' );
20
- $status['visibility'] = 'public';
21
  endif; ?>
22
 
23
  <span class='wpdn-toggle-visibility' title='<?php _e( 'Visibility:', 'wp-dashboard-notes' ); ?> <?php echo $status['title']; ?>' data-visibility='<?php echo $status['visibility']; ?>'>
@@ -26,15 +26,13 @@
26
 
27
  <span class='wpdn-color-note' title='<?php _e( 'Give me a color!', 'wp-dashboard-notes' ); ?>'>
28
  <span class='wpdn-color-palette'>
29
- <span class='color color-white' data-select-color-text='white' data-select-color='#ffffff'></span>
30
- <span class='color color-red' data-select-color-text='red' data-select-color='#f7846a'></span>
31
- <span class='color color-orange' data-select-color-text='orange' data-select-color='#ffbd22'></span>
32
- <span class='color color-yellow' data-select-color-text='yellow' data-select-color='#eeee22'></span>
33
- <span class='color color-green' data-select-color-text='green' data-select-color='#bbe535'></span>
34
- <span class='color color-blue' data-select-color-text='blue' data-select-color='#66ccdd'></span>
35
- <span class='color color-black' data-select-color-text='black' data-select-color='#777777'></span>
36
  </span>
37
- <div class='dashicons dashicons-art wpdn-note-color' data-note-color='<?php echo $note_meta['color']; ?>'></div>
38
  </span>
39
 
40
  <span title='<?php _e( 'Convert to list note', 'wp-dashboard-notes'); ?>'>
1
+ <div class='wp-dashboard-note-wrap regular-note' data-note-type='regular' data-color-text='<?php echo $note_meta['color_text']; ?>' data-note-color='<?php echo $note_meta['color']; ?>'>
2
 
3
  <div class='wp-dashboard-note' contenteditable='true'>
4
+ <?php echo $content; ?>
5
  </div>
6
 
7
  <div class='wp-dashboard-note-options'>
11
  <span class='wpdn-option-visibility'>
12
  <?php
13
  if ( 'private' == $note_meta['visibility'] && $note_meta ) :
14
+ $status['icon'] = 'dashicons-admin-users';
15
+ $status['title'] = __( 'Just me', 'wp-dashboard-notes' );
16
+ $status['visibility'] = 'private';
17
  else :
18
+ $status['icon'] = 'dashicons-groups';
19
+ $status['title'] = __( 'Everyone', 'wp-dashboard-notes' );
20
+ $status['visibility'] = 'public';
21
  endif; ?>
22
 
23
  <span class='wpdn-toggle-visibility' title='<?php _e( 'Visibility:', 'wp-dashboard-notes' ); ?> <?php echo $status['title']; ?>' data-visibility='<?php echo $status['visibility']; ?>'>
26
 
27
  <span class='wpdn-color-note' title='<?php _e( 'Give me a color!', 'wp-dashboard-notes' ); ?>'>
28
  <span class='wpdn-color-palette'>
29
+
30
+ <?php foreach ( $colors as $name => $color ) : ?>
31
+ <span class='color color-<?php echo $name;?>' data-select-color-text='<?php echo $name; ?>' data-select-color='<?php echo $color; ?>' style='background-color: <?php echo $color; ?>'></span>
32
+ <?php endforeach; ?>
33
+
 
 
34
  </span>
35
+ <div class='dashicons dashicons-art wpdn-note-color'></div>
36
  </span>
37
 
38
  <span title='<?php _e( 'Convert to list note', 'wp-dashboard-notes'); ?>'>
languages/wp-dashboard-notes-ru_RU.mo ADDED
Binary file
languages/wp-dashboard-notes-ru_RU.po ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Dashboard Notes v1.0.4\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2015-01-19 18:05:27+0000\n"
7
+ "Last-Translator: administrator <admin@vsevyazemy.ru>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=3; plural=n%100/10==1 ? 2 : n%10==1 ? 0 : (n+9)%10>3 ? 2 : 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: Russian\n"
15
+ "X-Poedit-Country: RUSSIA\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
+ "X-Poedit-Basepath: ../\n"
19
+ "X-Poedit-Bookmarks: \n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
+
23
+ #: includes/class-note-post-type.php:39
24
+ #@ wp-dashboard-notes
25
+ msgid "Notes"
26
+ msgstr "Заметки"
27
+
28
+ #: includes/class-note-post-type.php:40
29
+ #@ wp-dashboard-notes
30
+ msgid "Note"
31
+ msgstr "Заметка"
32
+
33
+ #: includes/class-note-post-type.php:41
34
+ #@ wp-dashboard-notes
35
+ msgid "Add New"
36
+ msgstr "Добавить"
37
+
38
+ #: includes/class-note-post-type.php:42
39
+ #@ wp-dashboard-notes
40
+ msgid "Add New Note"
41
+ msgstr "Добавить"
42
+
43
+ #: includes/class-note-post-type.php:43
44
+ #@ wp-dashboard-notes
45
+ msgid "Edit Note"
46
+ msgstr "Изменить"
47
+
48
+ #: includes/class-note-post-type.php:44
49
+ #@ wp-dashboard-notes
50
+ msgid "New Note"
51
+ msgstr "Создать"
52
+
53
+ #: includes/class-note-post-type.php:45
54
+ #@ wp-dashboard-notes
55
+ msgid "View Note"
56
+ msgstr "Смотреть"
57
+
58
+ #: includes/class-note-post-type.php:46
59
+ #@ wp-dashboard-notes
60
+ msgid "Search Notes"
61
+ msgstr "Искать"
62
+
63
+ #: includes/class-note-post-type.php:47
64
+ #@ wp-dashboard-notes
65
+ msgid "No Notes"
66
+ msgstr "Нет заметок"
67
+
68
+ #: includes/class-note-post-type.php:48
69
+ #@ wp-dashboard-notes
70
+ msgid "No Notes found in Trash"
71
+ msgstr "В мусоре нет заметок"
72
+
73
+ #: includes/class-wpdn-ajax.php:118
74
+ #: includes/class-wpdn-ajax.php:148
75
+ #@ wp-dashboard-notes
76
+ msgid "New note"
77
+ msgstr "Создать"
78
+
79
+ #: includes/templates/note-list.php:9
80
+ #@ wp-dashboard-notes
81
+ msgid "List item"
82
+ msgstr "Список"
83
+
84
+ #: includes/templates/note-list.php:16
85
+ #: includes/templates/note.php:15
86
+ #@ wp-dashboard-notes
87
+ msgid "Just me"
88
+ msgstr "Приватно"
89
+
90
+ #: includes/templates/note-list.php:20
91
+ #: includes/templates/note.php:19
92
+ #@ wp-dashboard-notes
93
+ msgid "Everyone"
94
+ msgstr "Общедоступно"
95
+
96
+ #: includes/templates/note-list.php:24
97
+ #: includes/templates/note.php:23
98
+ #@ wp-dashboard-notes
99
+ msgid "Visibility:"
100
+ msgstr "Видимость:"
101
+
102
+ #: includes/templates/note-list.php:28
103
+ #: includes/templates/note.php:27
104
+ #@ wp-dashboard-notes
105
+ msgid "Give me a color!"
106
+ msgstr "Выбрать цвет"
107
+
108
+ #: includes/templates/note-list.php:39
109
+ #@ wp-dashboard-notes
110
+ msgid "Convert to regular note"
111
+ msgstr "Список > в текст"
112
+
113
+ #: includes/templates/note-list.php:43
114
+ #: includes/templates/note.php:42
115
+ #@ wp-dashboard-notes
116
+ msgid "Add a new note"
117
+ msgstr "Добавить"
118
+
119
+ #: includes/templates/note-list.php:48
120
+ #: includes/templates/note.php:46
121
+ #@ wp-dashboard-notes
122
+ msgid "Delete note"
123
+ msgstr "Удалить"
124
+
125
+ #: includes/templates/note.php:38
126
+ #@ wp-dashboard-notes
127
+ msgid "Convert to list note"
128
+ msgstr "Текст > в список"
129
+
130
+ #: wp-dashboard-notes.php:249
131
+ #@ wp-dashboard-notes
132
+ msgid "Add note"
133
+ msgstr "Добавить"
134
+
readme.txt CHANGED
@@ -1,26 +1,27 @@
1
  === WP Dashboard Notes ===
2
  Contributors: sormano
3
- Donate link: http://www.jeroensormani.com/donate/
4
- Tags: note, notes, dashboard notes, wordpress notes, admin note, private note, notification, admin notification, collaboratin, workflow
5
  Requires at least: 3.8
6
- Tested up to: 3.9.2
7
- Stable tag: 1.0.1
8
  License: GPLv3 or later
9
- License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Working with multiple persons on a website? Want to make notes? You can do just that with WP Dashboard Notes. Create beautiful notes with a nice user experience.
12
 
13
  == Description ==
14
  Working with multiple persons on a website? Want to make notes? You can do just that with WP Dashboard Notes. Create beautiful notes with a nice user experience.
15
 
16
- Features:
 
17
  * Colored notes
18
  * List notes or regular notes
19
  * Public or private notes
20
  * Edit on dashboard
21
  * Add as many notes as you like
22
  * Drag & drop list items
23
- * No save button!
24
 
25
  **Feature requests, ratings and donations are welcome and appreciated!**
26
 
@@ -30,18 +31,106 @@ Features:
30
 
31
  A new note can be added in two ways.
32
 
33
- - Open 'Screen Options' on your dashboard, in the right corner you'll find a button called 'Add note'.
34
  - Or you can add a new note from within an existing note. When hovering over a note there will show an black bar at the bottom of that note. There is an '+' within that bar where you can add a new note.
35
 
36
  = Can I change the colors =
37
 
38
  You could change the colors by overriding the style from another stylesheet. If you need help with this, ask in the support forums.
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  == Installation ==
41
 
42
  1. Upload the folder `wp-dashboard-notes` to the `/wp-content/plugins/` directory.
43
  2. Activate the plugin through the 'Plugins' menu in WordPress.
44
- 3. Add your first note via the 'Add note' button in the 'Screen Options'.
45
 
46
  == Screenshots ==
47
 
@@ -51,12 +140,66 @@ You could change the colors by overriding the style from another stylesheet. If
51
 
52
  == Changelog ==
53
 
54
- = 1.0.1 = 28/08/2014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  * Added ‚jquery-ui-sortable’ dependency
56
- * Fixed sub-menu not showing up
57
  * Add check at js update note function
58
- * Added NL translation + loading translation files
59
 
 
60
 
61
- = 1.0.0 = 18/08/2014
62
- * Initial release
1
  === WP Dashboard Notes ===
2
  Contributors: sormano
3
+ Donate link: http://jeroensormani.com/donate/
4
+ Tags: note, notes, dashboard notes, wordpress notes, admin note, private note, notification, collaboration, workflow, to do list, note list, note widget
5
  Requires at least: 3.8
6
+ Tested up to: 4.5
7
+ Stable tag: 1.0.8.2
8
  License: GPLv3 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-3.0.html ``
10
 
11
  Working with multiple persons on a website? Want to make notes? You can do just that with WP Dashboard Notes. Create beautiful notes with a nice user experience.
12
 
13
  == Description ==
14
  Working with multiple persons on a website? Want to make notes? You can do just that with WP Dashboard Notes. Create beautiful notes with a nice user experience.
15
 
16
+ **Features:**
17
+
18
  * Colored notes
19
  * List notes or regular notes
20
  * Public or private notes
21
  * Edit on dashboard
22
  * Add as many notes as you like
23
  * Drag & drop list items
24
+ * No save button needed!
25
 
26
  **Feature requests, ratings and donations are welcome and appreciated!**
27
 
31
 
32
  A new note can be added in two ways.
33
 
34
+ - There is a 'Add note' button is located in the top admin bar
35
  - Or you can add a new note from within an existing note. When hovering over a note there will show an black bar at the bottom of that note. There is an '+' within that bar where you can add a new note.
36
 
37
  = Can I change the colors =
38
 
39
  You could change the colors by overriding the style from another stylesheet. If you need help with this, ask in the support forums.
40
 
41
+ = How can I add my own colors? =
42
+
43
+ Add the following code to your functions.php, you can change the values of course to your own colors.
44
+
45
+ Required:
46
+ `
47
+ add_filter( 'wpdn_colors', 'wpdn_add_purple' );
48
+ function wpdn_add_purple( $colors ) {
49
+
50
+ $colors['purple'] = '#5236A0';
51
+
52
+ return $colors;
53
+
54
+ }
55
+ `
56
+
57
+ *Optional:*
58
+ You can add the following code for extra styling (e.g. light text instead of dark)
59
+ `
60
+ add_action( 'admin_head', 'wpdn_add_style' );
61
+ function wpdn_add_style() {
62
+
63
+ ?><style>
64
+
65
+ /****************************
66
+ * purple
67
+ ****************************/
68
+ [data-color-text=purple] {
69
+ color: white;
70
+ }
71
+ [data-color-text=purple] .wpdn-note-sortable {
72
+ color: inherit;
73
+ }
74
+ [data-color-text=purple] .wpdn-add-item {
75
+ color: inherit;
76
+ }
77
+ [data-color-text=purple] .wp-dashboard-note .list-item {
78
+ border-color: inherit;
79
+ }
80
+
81
+ [data-color-text=purple] .list-item input[type=checkbox] {
82
+ border: 1px solid white !important;
83
+ }
84
+
85
+ [data-color-text=purple] .list-item input[type=checkbox]:checked ~ span {
86
+ color: white;
87
+ }
88
+ /* Unused for now */
89
+ [data-color-text=purple] [id^=note] .handlediv {
90
+ color: inherit;
91
+ }
92
+ /* Add list item input colors */
93
+ [data-color-text=purple] input[type=text].add-list-item {
94
+ border-color: white;
95
+ color: inherit;
96
+ background: inherit;
97
+ }
98
+ /* Placeholder text color */
99
+ [data-color-text=purple] input[type=text].add-list-item::-webkit-input-placeholder {
100
+ color: white;
101
+ }
102
+ [data-color-text=purple] input[type=text].add-list-item:-moz-placeholder {
103
+ color: white;
104
+ }
105
+ [data-color-text=purple] input[type=text].add-list-item::-moz-placeholder {
106
+ color: white;
107
+ }
108
+ [data-color-text=purple] input[type=text].add-list-item:-ms-input-placeholder {
109
+ color: white;
110
+ }
111
+ /* Saved/saving text color */
112
+ [data-color-text=purple] .saved-icon,
113
+ [data-color-text=purple] .saving-icon {
114
+ color: inherit;
115
+ }
116
+ /* Delete icon */
117
+ [data-color-text=purple] .list-item .dashicons-no-alt {
118
+ color: white;
119
+ }
120
+ /* Sort icon */
121
+ [data-color-text=purple] .wpdn-note-sortable {
122
+ color: white;
123
+ }
124
+ </style><?php
125
+
126
+ }
127
+ `
128
+
129
  == Installation ==
130
 
131
  1. Upload the folder `wp-dashboard-notes` to the `/wp-content/plugins/` directory.
132
  2. Activate the plugin through the 'Plugins' menu in WordPress.
133
+ 3. Add your first note via the 'Add note' button by clicking on the 'Add note' button in the top admin bar on your admin dashboard.
134
 
135
  == Screenshots ==
136
 
140
 
141
  == Changelog ==
142
 
143
+
144
+ = 1.0.8.2 - 11/04/2016 =
145
+
146
+ * Fix - Old existing list items not editable in rare cases
147
+
148
+ = 1.0.8.1 - 21/03/2016 =
149
+
150
+ * Fix - Check in checkbox sometimes don't save
151
+
152
+ = 1.0.8 - 10/03/2016 =
153
+
154
+ * Improvement - Always show toolbar on mobile devices (credits to ClearPathDigital)
155
+ * Fix - Check nonce + user capabilities for AJAX calls (credits to Paul Gibbs for noting)
156
+
157
+
158
+ = 1.0.7 - 11/12/2015 =
159
+
160
+ * Fix/Improvement - Move 'Add note' button to the admin bar
161
+ * Add - Full WP 4.4 compatibility
162
+ * Improvement - Improve some JS
163
+
164
+ = 1.0.6 - 26/08/2015 =
165
+
166
+ * Improvement - Optimize JavaScripts and stylesheets
167
+ * Fix - Firefox users not able to use new regular note
168
+
169
+ = 1.0.5 - 24/01/2015 =
170
+
171
+ * Improvement - Use singleton instead of global
172
+ * Fix - Notice in the background when getting data
173
+ * Fix - Delete not working when having double lined items
174
+ * Fix - Bug in changing background colors
175
+ * Fix - Prevent copying the text background color (or any other styles)
176
+ * Add - Russian translation
177
+
178
+ = 1.0.4 - 19/10/2014 =
179
+
180
+ * Fix - Notice on WP_DEBUG mode when creating new note
181
+ * Fix - Wrong visibility icon when switching
182
+ * Fix - Displaying colors on new notes/after switching
183
+ * Improvement - Drag list items only vertically
184
+ * Improvement - Move savig/saved icon to title bar
185
+
186
+ = 1.0.3 - 12/10/2014 =
187
+
188
+ * Add - *beta* URLs are automatically clickable (after page refresh)
189
+ * Improvement - Add filters to add your own colors
190
+ * Improvement - Small improvements for coloring
191
+ * Improvement - New icon for Personal visibility
192
+
193
+ = 1.0.2 - 29/08/2014 =
194
+
195
+ * Fix - Safari compatibility issues
196
+
197
+ = 1.0.1 - 28/08/2014 =
198
+
199
  * Added ‚jquery-ui-sortable’ dependency
200
+ * Fixed sub-menu not showing up
201
  * Add check at js update note function
 
202
 
203
+ = 1.0.0 - 18/08/2014 =
204
 
205
+ * Initial release
 
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
wp-dashboard-notes.php CHANGED
@@ -1,65 +1,144 @@
1
  <?php
2
- /*
3
- Plugin Name: WP Dashboard Notes
4
- Plugin URI: http://www.jeroensormani.com
5
- Description: Working with multiple persons on a website? Want to make notes? You can do just that with WP Dashboard Notes. Create beautiful notes with a nice user experience.
6
- Version: 1.0.1
7
- Author: Jeroen Sormani
8
- Author URI: http://www.jeroensormani.com
9
- Text Domain: wp-dashboard-notes
10
- */
 
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
  if ( ! is_admin() ) return; // Only load plugin when user is in admin
14
 
15
  /**
16
- * Class WP_Dashboard_Notes
17
  *
18
- * Main WPDN class initializes the plugin
19
  *
20
- * @class WP_Dashboard_Notes
21
- * @version 1.0.0
22
- * @author Jeroen Sormani
23
  */
24
  class WP_Dashboard_Notes {
25
 
26
 
27
  /**
28
- * __construct function.
 
 
 
 
 
 
 
 
 
29
  *
30
  * @since 1.0.0
 
31
  */
32
- public function __construct() {
33
 
34
- // Add dashboard widget
35
- add_action( 'wp_dashboard_setup', array( $this, 'wpdn_init_dashboard_widget' ) );
36
 
37
- // Register post type
38
- add_action( 'init', array( $this, 'wpdn_register_post_type' ) );
 
 
 
 
 
 
39
 
40
- // Enqueue scripts
41
- add_action( 'admin_enqueue_scripts', array( $this, 'wpdn_admin_enqueue_scripts' ) );
42
 
43
- // Add note button
44
- add_filter( 'manage_dashboard_columns', array( $this, 'wpdn_dashboard_columns' ) );
 
 
 
 
 
 
 
45
 
46
- // Load textdomain
47
- load_plugin_textdomain( 'wp-dashboard-notes', false, basename( dirname( __FILE__ ) ) . '/languages' );
48
 
49
  }
50
 
51
 
52
  /**
53
- * Register post type.
 
 
 
54
  *
55
  * @since 1.0.0
 
 
56
  */
57
- public function wpdn_register_post_type() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  /**
60
  * Post type class.
61
  */
62
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-note-post-type.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  }
65
 
@@ -71,13 +150,16 @@ class WP_Dashboard_Notes {
71
  *
72
  * @since 1.0.0
73
  */
74
- public function wpdn_admin_enqueue_scripts() {
75
 
76
  // Javascript
77
- wp_enqueue_script( 'wpdn_admin_js', plugin_dir_url( __FILE__ ) . 'assets/js/wpdn_admin.js', array( 'jquery', 'jquery-ui-sortable' ) );
 
 
 
78
 
79
  // Stylesheet
80
- wp_enqueue_style( 'wpdn_admin_css', plugin_dir_url( __FILE__ ) . 'assets/css/wpdn_admin.css', array( 'dashicons' ) );
81
 
82
  }
83
 
@@ -89,12 +171,12 @@ class WP_Dashboard_Notes {
89
  *
90
  * @since 1.0.0
91
  *
92
- * @return Array of all published notes.
93
  */
94
  public function wpdn_get_notes() {
95
 
96
  $notes = get_posts( array( 'posts_per_page' => '-1', 'post_type' => 'note' ) );
97
-
98
  return apply_filters( 'wpdn_notes', $notes );
99
 
100
  }
@@ -107,17 +189,19 @@ class WP_Dashboard_Notes {
107
  *
108
  * @since 1.0.0
109
  *
110
- * @param int $note_id ID of the note.
111
- * @return array Note meta.
112
  */
113
  public static function wpdn_get_note_meta( $note_id ) {
114
 
115
  $note_meta = get_post_meta( $note_id, '_note', true );
116
 
117
- if ( ! isset( $note_meta['note_type'] ) ) { $note_meta['note_type'] = 'regular'; }
118
- if ( ! isset( $note_meta['color'] ) ) { $note_meta['color'] = '#ffffff'; }
119
- if ( ! isset( $note_meta['visibility'] ) ) { $note_meta['visibility'] = 'public'; }
120
- if ( ! isset( $note_meta['color_text'] ) ) { $note_meta['color_text'] = 'white'; }
 
 
121
 
122
  return apply_filters( 'wpdn_note_meta', $note_meta );
123
 
@@ -137,8 +221,8 @@ class WP_Dashboard_Notes {
137
 
138
  foreach ( $notes as $note ) :
139
 
140
- $note_meta = $this->wpdn_get_note_meta( $note->ID );
141
- $user = wp_get_current_user();
142
 
143
  // Skip if private
144
  if ( 'private' == $note_meta['visibility'] && $user->ID != $note->post_author ) :
@@ -148,7 +232,7 @@ class WP_Dashboard_Notes {
148
  // Add widget
149
  wp_add_dashboard_widget(
150
  'note_' . $note->ID,
151
- '<span contenteditable="true" class="wpdn-title">' . $note->post_title . '</span><div class="wpdn-edit-title dashicons dashicons-edit"></div>',
152
  array( $this, 'wpdn_render_dashboard_widget' ),
153
  '',
154
  $note
@@ -166,13 +250,23 @@ class WP_Dashboard_Notes {
166
  *
167
  * @since 1.0.0
168
  *
169
- * @param object $post Post object.
170
- * @param array $args Extra arguments.
171
  */
172
  public function wpdn_render_dashboard_widget( $post, $args ) {
173
 
174
- $note = $args['args'];
175
- $note_meta = $this->wpdn_get_note_meta( $note->ID );
 
 
 
 
 
 
 
 
 
 
176
 
177
  // Inline styling required for note depending colors.
178
  ?><style>
@@ -190,36 +284,49 @@ class WP_Dashboard_Notes {
190
 
191
 
192
  /**
193
- * Add button.
194
  *
195
- * Adds a 'Add note' button to the 'Screen Options' tab.
196
- * Triggered via jQuery.
197
  *
198
  * @since 1.0.0
199
  *
200
- * @global object $current_screen Information about current screen.
201
- *
202
- * @param array $columns Array of columns within the screen options tab.
203
- * @return array Array of columns within the screen options tab.
204
  */
205
- public function wpdn_dashboard_columns( $columns ) {
206
 
207
- global $current_screen;
208
-
209
- if ( $current_screen->id ) :
210
- $columns['add_note'] = __( 'Add note', 'wp-dashboard-notes' );
211
- endif;
212
- return $columns;
213
 
214
  }
215
 
216
 
217
  }
 
 
218
  /**
219
- * AJAX class.
 
 
 
 
 
 
 
 
220
  */
221
- require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpdn-ajax.php';
 
 
 
 
 
 
 
 
 
 
 
222
 
223
 
224
- global $wp_dashboard_notes;
225
- $wp_dashboard_notes = new WP_Dashboard_Notes();
1
  <?php
2
+ /**
3
+ * Plugin Name: WP Dashboard Notes
4
+ * Plugin URI: https://wordpress.org/plugins/wp-dashboard-notes/
5
+ * Donate link: http://jeroensormani.com/donate/
6
+ * Description: Working in a team? Want to make notes? You can do just that with WP Dashboard Notes. Create beautiful notes with a nice user experience.
7
+ * Version: 1.0.8.1
8
+ * Author: Jeroen Sormani
9
+ * Author URI: http://jeroensormani.com/
10
+ * Text Domain: wp-dashboard-notes
11
+ */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
  if ( ! is_admin() ) return; // Only load plugin when user is in admin
15
 
16
  /**
17
+ * Class WP_Dashboard_Notes.
18
  *
19
+ * Main WPDN class initializes the plugin.
20
  *
21
+ * @class WP_Dashboard_Notes
22
+ * @version 1.0.0
23
+ * @author Jeroen Sormani
24
  */
25
  class WP_Dashboard_Notes {
26
 
27
 
28
  /**
29
+ * Plugin version number
30
+ *
31
+ * @since 1.0.3
32
+ * @var string $version Plugin version number.
33
+ */
34
+ public $version = '1.0.8.1';
35
+
36
+
37
+ /**
38
+ * Plugin file.
39
  *
40
  * @since 1.0.0
41
+ * @var string $file Plugin file path.
42
  */
43
+ public $file = __FILE__;
44
 
 
 
45
 
46
+ /**
47
+ * Instace of WP_Dashboard_Notes.
48
+ *
49
+ * @since 1.0.0
50
+ * @access private
51
+ * @var object $instance The instance of WP_Dashboard_Notes.
52
+ */
53
+ private static $instance;
54
 
 
 
55
 
56
+ /**
57
+ * Constructor.
58
+ *
59
+ * @since 1.0.0
60
+ */
61
+ public function __construct() {
62
+
63
+ // Init plugin parts
64
+ $this->init();
65
 
66
+ $this->hooks();
 
67
 
68
  }
69
 
70
 
71
  /**
72
+ * Instance.
73
+ *
74
+ * An global instance of the class. Used to retrieve the instance
75
+ * to use on other files/plugins/themes.
76
  *
77
  * @since 1.0.0
78
+ *
79
+ * @return object Instance of the class.
80
  */
81
+ public static function instance() {
82
+
83
+ if ( is_null( self::$instance ) ) :
84
+ self::$instance = new self();
85
+ endif;
86
+
87
+ return self::$instance;
88
+
89
+ }
90
+
91
+
92
+ /**
93
+ * Init.
94
+ *
95
+ * Initiate plugin parts.
96
+ *
97
+ * @since 1.0.5
98
+ */
99
+ public function init() {
100
 
101
  /**
102
  * Post type class.
103
  */
104
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-note-post-type.php';
105
+ $this->post_type = new Note_Post_Type();
106
+
107
+ /**
108
+ * AJAX class.
109
+ */
110
+ require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpdn-ajax.php';
111
+ $this->ajax = new WPDN_Ajax();
112
+
113
+ /**
114
+ * Admin class.
115
+ */
116
+ require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpdn-admin.php';
117
+ $this->admin = new WPDN_Admin();
118
+
119
+ }
120
+
121
+
122
+ /**
123
+ * Hooks.
124
+ *
125
+ * Init actions and filters.
126
+ *
127
+ * @since 1.0.5
128
+ */
129
+ public function hooks() {
130
+
131
+ // Add dashboard widget
132
+ add_action( 'wp_dashboard_setup', array( $this, 'wpdn_init_dashboard_widget' ) );
133
+
134
+ // Enqueue scripts
135
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
136
+
137
+ // Make URLs clickable
138
+ add_action( 'wpdn_content', array( $this, 'wpdn_clickable_url' ) );
139
+
140
+ // Load textdomain
141
+ load_plugin_textdomain( 'wp-dashboard-notes', false, basename( dirname( __FILE__ ) ) . '/languages' );
142
 
143
  }
144
 
150
  *
151
  * @since 1.0.0
152
  */
153
+ public function admin_enqueue_scripts() {
154
 
155
  // Javascript
156
+ wp_localize_script( 'wpdn_admin_js', 'wpdn', array(
157
+ 'nonce' => wp_create_nonce( 'wpdn-ajax-nonce' ),
158
+ ) );
159
+ wp_enqueue_script( 'wpdn_admin_js', plugin_dir_url( __FILE__ ) . 'assets/js/wp-dashboard-notes-admin.min.js', array( 'jquery', 'jquery-ui-sortable' ), $this->version );
160
 
161
  // Stylesheet
162
+ wp_enqueue_style( 'wpdn_admin_css', plugin_dir_url( __FILE__ ) . 'assets/css/wp-dashboard-notes-admin.min.css', array( 'dashicons' ), $this->version );
163
 
164
  }
165
 
171
  *
172
  * @since 1.0.0
173
  *
174
+ * @return array Array List of all published notes.
175
  */
176
  public function wpdn_get_notes() {
177
 
178
  $notes = get_posts( array( 'posts_per_page' => '-1', 'post_type' => 'note' ) );
179
+
180
  return apply_filters( 'wpdn_notes', $notes );
181
 
182
  }
189
  *
190
  * @since 1.0.0
191
  *
192
+ * @param int $note_id ID of the note.
193
+ * @return array Note meta.
194
  */
195
  public static function wpdn_get_note_meta( $note_id ) {
196
 
197
  $note_meta = get_post_meta( $note_id, '_note', true );
198
 
199
+ $note_meta = wp_parse_args( $note_meta, array(
200
+ 'note_type' => 'regular',
201
+ 'color' => '#ffffff',
202
+ 'visibility' => 'public',
203
+ 'color_text' => 'white',
204
+ ) );
205
 
206
  return apply_filters( 'wpdn_note_meta', $note_meta );
207
 
221
 
222
  foreach ( $notes as $note ) :
223
 
224
+ $note_meta = $this->wpdn_get_note_meta( $note->ID );
225
+ $user = wp_get_current_user();
226
 
227
  // Skip if private
228
  if ( 'private' == $note_meta['visibility'] && $user->ID != $note->post_author ) :
232
  // Add widget
233
  wp_add_dashboard_widget(
234
  'note_' . $note->ID,
235
+ '<span contenteditable="true" class="wpdn-title">' . $note->post_title . '</span><div class="wpdn-edit-title dashicons dashicons-edit"></div><span class="status"></span>',
236
  array( $this, 'wpdn_render_dashboard_widget' ),
237
  '',
238
  $note
250
  *
251
  * @since 1.0.0
252
  *
253
+ * @param object $post Post object.
254
+ * @param array $args Extra arguments.
255
  */
256
  public function wpdn_render_dashboard_widget( $post, $args ) {
257
 
258
+ $note = $args['args'];
259
+ $note_meta = $this->wpdn_get_note_meta( $note->ID );
260
+ $content = apply_filters( 'wpdn_content', $note->post_content );
261
+ $colors = apply_filters( 'wpdn_colors', array(
262
+ 'white' => '#fff',
263
+ 'red' => '#f7846a',
264
+ 'orange' => '#ffbd22',
265
+ 'yellow' => '#eeee22',
266
+ 'green' => '#bbe535',
267
+ 'blue' => '#66ccdd',
268
+ 'black' => '#777777',
269
+ ) );
270
 
271
  // Inline styling required for note depending colors.
272
  ?><style>
284
 
285
 
286
  /**
287
+ * Clickable URL.
288
  *
289
+ * Filter note content to make links clickable.
 
290
  *
291
  * @since 1.0.0
292
  *
293
+ * @param string $content Original content.
294
+ * @return string Edited content.
 
 
295
  */
296
+ public function wpdn_clickable_url( $content ) {
297
 
298
+ return make_clickable( $content );
 
 
 
 
 
299
 
300
  }
301
 
302
 
303
  }
304
+
305
+
306
  /**
307
+ * The main function responsible for returning the WP_Dashboard_Notes object.
308
+ *
309
+ * Use this function like you would a global variable, except without needing to declare the global.
310
+ *
311
+ * Example: <?php WP_Dashboard_Notes()->method_name(); ?>
312
+ *
313
+ * @since 1.0.0
314
+ *
315
+ * @return object WP_Dashboard_Notes class object.
316
  */
317
+ if ( ! function_exists( 'WP_Dashboard_Notes' ) ) :
318
+
319
+ function WP_Dashboard_Notes() {
320
+
321
+ return WP_Dashboard_Notes::instance();
322
+
323
+ }
324
+
325
+
326
+ endif;
327
+
328
+ WP_Dashboard_Notes();
329
 
330
 
331
+ // Backwards compatibility
332
+ $GLOBALS['wp_dashboard_notes'] = WP_Dashboard_Notes();