Gwolle Guestbook - Version 4.2.0

Version Description

  • 2021-11-18
  • Security fix for CSRF, use 'sanitize_text_field' for user_email on author search.
  • Thanks Erwan from wpscan.
  • Use more 'esc_attr' when appropriate.
  • Add option for character limit in content of entry.
  • Add function 'gwolle_gb_check_maxlength'.
  • Add function 'gwolle_gb_count_characters'.
  • Load markitup.js in footer.
  • Run update hook in 'init' instead of 'admin_init' to support background updates.
  • No need to check if function 'current_user_can', 'user_can', 'is_multisite' and 'has_shortcode' exist.
  • Drop support for WP 3.4 and using 'get_current_theme'.
  • Some updates from phpcs and wpcs.
Download this release

Release Info

Developer mpol
Plugin Icon 128x128 Gwolle Guestbook
Version 4.2.0
Comparing to
See all releases

Code changes from version 4.1.2 to 4.2.0

Files changed (64) hide show
  1. admin/gb-ajax-management.php +33 -24
  2. admin/gb-dashboard-widget.php +11 -11
  3. admin/gb-page-add-on.php +23 -23
  4. admin/gb-page-editor.php +91 -87
  5. admin/gb-page-entries.php +169 -159
  6. admin/gb-page-export.php +30 -30
  7. admin/gb-page-gwolle-gb.php +43 -43
  8. admin/gb-page-import.php +76 -74
  9. admin/gb-page-settings.php +84 -79
  10. admin/gb-pagination.php +41 -35
  11. admin/gb-upgrade.php +49 -49
  12. admin/gwolle-gb-hooks.php +7 -9
  13. admin/js/gwolle-gb-admin.js +3 -3
  14. admin/tabs/gb-admintab.php +7 -6
  15. admin/tabs/gb-antispamtab.php +14 -14
  16. admin/tabs/gb-debugtab.php +5 -5
  17. admin/tabs/gb-emailtab.php +62 -62
  18. admin/tabs/gb-formtab.php +47 -22
  19. admin/tabs/gb-readingtab.php +28 -27
  20. admin/tabs/gb-uninstalltab.php +3 -3
  21. docs/actions/gwolle_gb_save_entry_frontend.txt +21 -2
  22. docs/filters/gwolle_gb_entry_metabox_lines.txt +1 -1
  23. docs/filters/gwolle_gb_get_entries_sql.txt +14 -4
  24. docs/filters/{gwolle_gb_mail_moderator_body.txt → gwolle_gb_mail_moderators_body.txt} +0 -0
  25. docs/filters/{gwolle_gb_mail_moderator_subject.txt → gwolle_gb_mail_moderators_subject.txt} +0 -0
  26. frontend/gb-ajax-infinite-scroll.php +98 -98
  27. frontend/gb-blocklist.php +1 -1
  28. frontend/gb-form-ajax.php +46 -46
  29. frontend/gb-form-posthandling.php +94 -61
  30. frontend/gb-form.php +81 -73
  31. frontend/gb-pagination.php +30 -30
  32. frontend/gb-read.php +29 -28
  33. frontend/gb-rss.php +18 -18
  34. frontend/gb-shortcode-widget.php +1 -1
  35. frontend/gb-total.php +5 -2
  36. frontend/gb-widget-search.php +15 -13
  37. frontend/gb-widget.php +40 -29
  38. frontend/gwolle_gb-entry.php +23 -22
  39. frontend/js/gwolle-gb-frontend.js +39 -16
  40. frontend/js/sss/index.html +0 -0
  41. functions/gb-akismet.php +13 -9
  42. functions/gb-bbcode_emoji.php +2 -2
  43. functions/gb-book_id.php +19 -13
  44. functions/gb-cache.php +4 -4
  45. functions/gb-class-entry.php +42 -43
  46. functions/gb-debug.php +20 -18
  47. functions/gb-fields.php +1 -0
  48. functions/gb-formatting.php +42 -6
  49. functions/gb-get_entries.php +46 -43
  50. functions/gb-get_entries_from_search.php +17 -16
  51. functions/gb-log.php +29 -20
  52. functions/gb-mail.php +44 -40
  53. functions/gb-messages.php +3 -1
  54. functions/gb-metabox.php +6 -2
  55. functions/gb-post-meta.php +35 -35
  56. functions/gb-privacy.php +22 -11
  57. functions/gb-settings.php +14 -10
  58. functions/gb-single-view.php +3 -2
  59. functions/gb-stop-forum-spam.php +17 -10
  60. functions/gb-user-ip.php +4 -4
  61. functions/gb-user.php +16 -15
  62. gwolle-gb-hooks.php +15 -15
  63. gwolle-gb.php +64 -61
  64. readme.txt +15 -1
admin/gb-ajax-management.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  * ajax.php
4
- * Processes AJAX requests.
5
  */
6
 
7
 
@@ -16,7 +16,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
16
  */
17
  add_action( 'admin_footer', 'gwolle_gb_ajax_javascript' );
18
  function gwolle_gb_ajax_javascript() {
19
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
20
  return;
21
  }
22
 
@@ -55,9 +55,9 @@ function gwolle_gb_ajax_javascript() {
55
 
56
  var data = {
57
  action: 'gwolle_gb_ajax',
58
- security: '<?php echo $ajax_nonce; ?>',
59
  id: entry_id,
60
- setter: setter
61
  };
62
 
63
 
@@ -164,9 +164,9 @@ function gwolle_gb_ajax_javascript() {
164
 
165
  var data = {
166
  action: 'gwolle_gb_ajax',
167
- security: '<?php echo $ajax_nonce; ?>',
168
  id: entry_id,
169
- setter: setter
170
  };
171
 
172
 
@@ -179,13 +179,13 @@ function gwolle_gb_ajax_javascript() {
179
  response = response.trim();
180
 
181
  // Set classes accordingly
182
- if ( response == setter ) { // We got what we wanted
183
 
184
  // Countdown counter in admin menu, toolbar
185
  if ( jQuery( '.gwolle_gb_actions' ).hasClass('unchecked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
186
  var gwolle_gb_menu_counter = jQuery('li#toplevel_page_gwolle-gb-gwolle-gb a.menu-top span.awaiting-mod span').text();
187
- var old_gwolle_gb_menu_counter = new Number( gwolle_gb_menu_counter );
188
- var new_gwolle_gb_menu_counter = old_gwolle_gb_menu_counter - 1;
189
 
190
  jQuery('li#toplevel_page_gwolle-gb-gwolle-gb span.awaiting-mod span').text( new_gwolle_gb_menu_counter );
191
  jQuery('li#wp-admin-bar-gwolle-gb span.awaiting-mod.pending-count').text( new_gwolle_gb_menu_counter );
@@ -246,8 +246,8 @@ function gwolle_gb_ajax_javascript() {
246
  // Countup counter in admin menu, toolbar
247
  if ( jQuery( '.gwolle_gb_actions' ).hasClass('unchecked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
248
  var gwolle_gb_menu_counter = jQuery('li#toplevel_page_gwolle-gb-gwolle-gb a.menu-top span.awaiting-mod span').text();
249
- var old_gwolle_gb_menu_counter = new Number( gwolle_gb_menu_counter );
250
- var new_gwolle_gb_menu_counter = old_gwolle_gb_menu_counter + 1;
251
 
252
  jQuery('li#toplevel_page_gwolle-gb-gwolle-gb span.awaiting-mod span').text( new_gwolle_gb_menu_counter );
253
  jQuery('li#wp-admin-bar-gwolle-gb span.awaiting-mod.pending-count').text( new_gwolle_gb_menu_counter );
@@ -294,9 +294,9 @@ function gwolle_gb_ajax_javascript() {
294
 
295
  var data = {
296
  action: 'gwolle_gb_ajax',
297
- security: '<?php echo $ajax_nonce; ?>',
298
  id: entry_id,
299
- setter: setter
300
  };
301
 
302
 
@@ -308,7 +308,7 @@ function gwolle_gb_ajax_javascript() {
308
  jQuery.post( ajaxurl, data, function( response ) {
309
  response = response.trim();
310
 
311
- if ( response == setter ) { // We got what we wanted
312
  // Remove entry from widget
313
  jQuery( '.gwolle-gb-dashboard div#entry_' + entry_id ).slideUp();
314
  } else {
@@ -332,7 +332,7 @@ function gwolle_gb_ajax_javascript() {
332
  add_action( 'wp_ajax_gwolle_gb_ajax', 'gwolle_gb_ajax_callback' );
333
  function gwolle_gb_ajax_callback() {
334
 
335
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
336
  echo 'error';
337
  die();
338
  }
@@ -344,9 +344,9 @@ function gwolle_gb_ajax_callback() {
344
  if ( isset($_POST['security']) ) {
345
  $verified = wp_verify_nonce( $_POST['security'], 'gwolle_gb_ajax' );
346
  }
347
- if ( $verified == false ) {
348
  // Nonce is invalid.
349
- _e('Nonce check failed. Please go back and try again.', 'gwolle-gb');
350
  die();
351
  }
352
 
@@ -361,7 +361,7 @@ function gwolle_gb_ajax_callback() {
361
  if ( isset($id) && $id > 0 && isset($setter) && strlen($setter) > 0) {
362
  $entry = new gwolle_gb_entry();
363
  $result = $entry->load( $id );
364
- if ( !$result ) {
365
  echo 'error, no such entry.';
366
  die();
367
  }
@@ -369,7 +369,7 @@ function gwolle_gb_ajax_callback() {
369
 
370
  switch ($setter) {
371
  case 'uncheck':
372
- if ( $entry->get_ischecked() == 1 ) {
373
  $entry->set_ischecked( false );
374
  $result = $entry->save();
375
  if ($result ) {
@@ -382,8 +382,9 @@ function gwolle_gb_ajax_callback() {
382
  $response = 'nochange';
383
  }
384
  break;
 
385
  case 'check':
386
- if ( $entry->get_ischecked() == 0 ) {
387
  $entry->set_ischecked( true );
388
  $user_id = get_current_user_id(); // returns 0 if no current user
389
  $entry->set_checkedby( $user_id );
@@ -399,8 +400,9 @@ function gwolle_gb_ajax_callback() {
399
  $response = 'nochange';
400
  }
401
  break;
 
402
  case 'unspam':
403
- if ( $entry->get_isspam() == 1 ) {
404
  $entry->set_isspam( false );
405
  $result = $entry->save();
406
  if ($result ) {
@@ -415,8 +417,9 @@ function gwolle_gb_ajax_callback() {
415
  $response = 'nochange';
416
  }
417
  break;
 
418
  case 'spam':
419
- if ( $entry->get_isspam() == 0 ) {
420
  $entry->set_isspam( true );
421
  $result = $entry->save();
422
  if ($result ) {
@@ -430,8 +433,9 @@ function gwolle_gb_ajax_callback() {
430
  $response = 'nochange';
431
  }
432
  break;
 
433
  case 'untrash':
434
- if ( $entry->get_istrash() == 1 ) {
435
  $entry->set_istrash( false );
436
  $result = $entry->save();
437
  if ($result ) {
@@ -445,8 +449,9 @@ function gwolle_gb_ajax_callback() {
445
  $response = 'nochange';
446
  }
447
  break;
 
448
  case 'trash':
449
- if ( $entry->get_istrash() == 0 ) {
450
  $entry->set_istrash( true );
451
  $result = $entry->save();
452
  if ($result ) {
@@ -459,6 +464,10 @@ function gwolle_gb_ajax_callback() {
459
  $response = 'nochange';
460
  }
461
  break;
 
 
 
 
462
  }
463
 
464
  do_action( 'gwolle_gb_save_entry_admin', $entry );
1
  <?php
2
  /*
3
  * ajax.php
4
+ * Processes AJAX requests on admin pages.
5
  */
6
 
7
 
16
  */
17
  add_action( 'admin_footer', 'gwolle_gb_ajax_javascript' );
18
  function gwolle_gb_ajax_javascript() {
19
+ if ( ! current_user_can('moderate_comments') ) {
20
  return;
21
  }
22
 
55
 
56
  var data = {
57
  action: 'gwolle_gb_ajax',
58
+ security: '<?php echo esc_attr( $ajax_nonce ); ?>',
59
  id: entry_id,
60
+ setter: setter,
61
  };
62
 
63
 
164
 
165
  var data = {
166
  action: 'gwolle_gb_ajax',
167
+ security: '<?php echo esc_attr( $ajax_nonce ); ?>',
168
  id: entry_id,
169
+ setter: setter,
170
  };
171
 
172
 
179
  response = response.trim();
180
 
181
  // Set classes accordingly
182
+ if ( response === setter ) { // We got what we wanted
183
 
184
  // Countdown counter in admin menu, toolbar
185
  if ( jQuery( '.gwolle_gb_actions' ).hasClass('unchecked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
186
  var gwolle_gb_menu_counter = jQuery('li#toplevel_page_gwolle-gb-gwolle-gb a.menu-top span.awaiting-mod span').text();
187
+ var old_gwolle_gb_menu_counter = new Number( gwolle_gb_menu_counter );
188
+ var new_gwolle_gb_menu_counter = old_gwolle_gb_menu_counter - 1;
189
 
190
  jQuery('li#toplevel_page_gwolle-gb-gwolle-gb span.awaiting-mod span').text( new_gwolle_gb_menu_counter );
191
  jQuery('li#wp-admin-bar-gwolle-gb span.awaiting-mod.pending-count').text( new_gwolle_gb_menu_counter );
246
  // Countup counter in admin menu, toolbar
247
  if ( jQuery( '.gwolle_gb_actions' ).hasClass('unchecked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
248
  var gwolle_gb_menu_counter = jQuery('li#toplevel_page_gwolle-gb-gwolle-gb a.menu-top span.awaiting-mod span').text();
249
+ var old_gwolle_gb_menu_counter = new Number( gwolle_gb_menu_counter );
250
+ var new_gwolle_gb_menu_counter = old_gwolle_gb_menu_counter + 1;
251
 
252
  jQuery('li#toplevel_page_gwolle-gb-gwolle-gb span.awaiting-mod span').text( new_gwolle_gb_menu_counter );
253
  jQuery('li#wp-admin-bar-gwolle-gb span.awaiting-mod.pending-count').text( new_gwolle_gb_menu_counter );
294
 
295
  var data = {
296
  action: 'gwolle_gb_ajax',
297
+ security: '<?php echo esc_attr( $ajax_nonce ); ?>',
298
  id: entry_id,
299
+ setter: setter,
300
  };
301
 
302
 
308
  jQuery.post( ajaxurl, data, function( response ) {
309
  response = response.trim();
310
 
311
+ if ( response === setter ) { // We got what we wanted
312
  // Remove entry from widget
313
  jQuery( '.gwolle-gb-dashboard div#entry_' + entry_id ).slideUp();
314
  } else {
332
  add_action( 'wp_ajax_gwolle_gb_ajax', 'gwolle_gb_ajax_callback' );
333
  function gwolle_gb_ajax_callback() {
334
 
335
+ if ( ! current_user_can('moderate_comments') ) {
336
  echo 'error';
337
  die();
338
  }
344
  if ( isset($_POST['security']) ) {
345
  $verified = wp_verify_nonce( $_POST['security'], 'gwolle_gb_ajax' );
346
  }
347
+ if ( $verified === false ) {
348
  // Nonce is invalid.
349
+ esc_html_e('Nonce check failed. Please go back and try again.', 'gwolle-gb');
350
  die();
351
  }
352
 
361
  if ( isset($id) && $id > 0 && isset($setter) && strlen($setter) > 0) {
362
  $entry = new gwolle_gb_entry();
363
  $result = $entry->load( $id );
364
+ if ( ! $result ) {
365
  echo 'error, no such entry.';
366
  die();
367
  }
369
 
370
  switch ($setter) {
371
  case 'uncheck':
372
+ if ( $entry->get_ischecked() === 1 ) {
373
  $entry->set_ischecked( false );
374
  $result = $entry->save();
375
  if ($result ) {
382
  $response = 'nochange';
383
  }
384
  break;
385
+
386
  case 'check':
387
+ if ( $entry->get_ischecked() === 0 ) {
388
  $entry->set_ischecked( true );
389
  $user_id = get_current_user_id(); // returns 0 if no current user
390
  $entry->set_checkedby( $user_id );
400
  $response = 'nochange';
401
  }
402
  break;
403
+
404
  case 'unspam':
405
+ if ( $entry->get_isspam() === 1 ) {
406
  $entry->set_isspam( false );
407
  $result = $entry->save();
408
  if ($result ) {
417
  $response = 'nochange';
418
  }
419
  break;
420
+
421
  case 'spam':
422
+ if ( $entry->get_isspam() === 0 ) {
423
  $entry->set_isspam( true );
424
  $result = $entry->save();
425
  if ($result ) {
433
  $response = 'nochange';
434
  }
435
  break;
436
+
437
  case 'untrash':
438
+ if ( $entry->get_istrash() === 1 ) {
439
  $entry->set_istrash( false );
440
  $result = $entry->save();
441
  if ($result ) {
449
  $response = 'nochange';
450
  }
451
  break;
452
+
453
  case 'trash':
454
+ if ( $entry->get_istrash() === 0 ) {
455
  $entry->set_istrash( true );
456
  $result = $entry->save();
457
  if ($result ) {
464
  $response = 'nochange';
465
  }
466
  break;
467
+
468
+ default:
469
+ $response = 'nochange';
470
+ break;
471
  }
472
 
473
  do_action( 'gwolle_gb_save_entry_admin', $entry );
admin/gb-dashboard-widget.php CHANGED
@@ -12,7 +12,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
12
  */
13
  function gwolle_gb_dashboard() {
14
 
15
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
16
  return;
17
  }
18
 
@@ -23,7 +23,7 @@ function gwolle_gb_dashboard() {
23
  'num_entries' => 5,
24
  'checked' => 'unchecked',
25
  'trash' => 'notrash',
26
- 'spam' => 'nospam'
27
  ));
28
 
29
  if ( is_array($entries) && ! empty($entries) ) {
@@ -78,7 +78,7 @@ function gwolle_gb_dashboard() {
78
  } ?>
79
 
80
 
81
- <div id="entry_<?php echo $entry->get_id(); ?>" class="comment depth-1 comment-item <?php echo $class; ?>">
82
  <div class="dashboard-comment-wrap">
83
  <h4 class="comment-meta">
84
  <?php // Author info ?>
@@ -112,31 +112,31 @@ function gwolle_gb_dashboard() {
112
  </span>
113
  <span class="gwolle_gb_check">
114
  &nbsp;|&nbsp;
115
- <a id="check_<?php echo $entry->get_id(); ?>" href="#" class="vim-a" title="<?php esc_attr_e('Check entry', 'gwolle-gb'); ?>"><?php esc_html_e('Check', 'gwolle-gb'); ?></a>
116
  </span>
117
  <span class="gwolle_gb_uncheck">
118
  &nbsp;|&nbsp;
119
- <a id="uncheck_<?php echo $entry->get_id(); ?>" href="#" class="vim-u" title="<?php esc_attr_e('Uncheck entry', 'gwolle-gb'); ?>"><?php esc_html_e('Uncheck', 'gwolle-gb'); ?></a>
120
  </span>
121
  <span class="gwolle_gb_spam">
122
  &nbsp;|&nbsp;
123
- <a id="spam_<?php echo $entry->get_id(); ?>" href="#" class="vim-s vim-destructive" title="<?php esc_attr_e('Mark entry as spam.', 'gwolle-gb'); ?>"><?php esc_html_e('Spam', 'gwolle-gb'); ?></a>
124
  </span>
125
  <span class="gwolle_gb_unspam">
126
  &nbsp;|&nbsp;
127
- <a id="unspam_<?php echo $entry->get_id(); ?>" href="#" class="vim-a" title="<?php esc_attr_e('Mark entry as not-spam.', 'gwolle-gb'); ?>"><?php esc_html_e('Not spam', 'gwolle-gb'); ?></a>
128
  </span>
129
  <span class="gwolle_gb_trash">
130
  &nbsp;|&nbsp;
131
- <a id="trash_<?php echo $entry->get_id(); ?>" href="#" class="vim-d vim-destructive" title="<?php esc_attr_e('Move entry to trash.', 'gwolle-gb'); ?>"><?php /* translators: Move to Trashcan */ esc_html_e('Trash', 'gwolle-gb'); ?></a>
132
  </span>
133
  <span class="gwolle_gb_untrash">
134
  &nbsp;|&nbsp;
135
- <a id="untrash_<?php echo $entry->get_id(); ?>" href="#" class="vim-d" title="<?php esc_attr_e('Recover entry from trash.', 'gwolle-gb'); ?>"><?php esc_html_e('Untrash', 'gwolle-gb'); ?></a>
136
  </span>
137
  <span class="gwolle_gb_ajax">
138
  &nbsp;|&nbsp;
139
- <a id="ajax_<?php echo $entry->get_id(); ?>" href="#" class="ajax vim-d vim-destructive" title="<?php esc_attr_e('Please wait...', 'gwolle-gb'); ?>"><?php esc_html_e('Wait...', 'gwolle-gb'); ?></a>
140
  </span>
141
  </p>
142
  </div>
@@ -162,7 +162,7 @@ function gwolle_gb_dashboard() {
162
  */
163
  function gwolle_gb_dashboard_setup() {
164
 
165
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
166
  return;
167
  }
168
 
12
  */
13
  function gwolle_gb_dashboard() {
14
 
15
+ if ( ! current_user_can('moderate_comments') ) {
16
  return;
17
  }
18
 
23
  'num_entries' => 5,
24
  'checked' => 'unchecked',
25
  'trash' => 'notrash',
26
+ 'spam' => 'nospam',
27
  ));
28
 
29
  if ( is_array($entries) && ! empty($entries) ) {
78
  } ?>
79
 
80
 
81
+ <div id="entry_<?php echo (int) $entry->get_id(); ?>" class="comment depth-1 comment-item <?php echo esc_attr( $class ); ?>">
82
  <div class="dashboard-comment-wrap">
83
  <h4 class="comment-meta">
84
  <?php // Author info ?>
112
  </span>
113
  <span class="gwolle_gb_check">
114
  &nbsp;|&nbsp;
115
+ <a id="check_<?php echo (int) $entry->get_id(); ?>" href="#" class="vim-a" title="<?php esc_attr_e('Check entry', 'gwolle-gb'); ?>"><?php esc_html_e('Check', 'gwolle-gb'); ?></a>
116
  </span>
117
  <span class="gwolle_gb_uncheck">
118
  &nbsp;|&nbsp;
119
+ <a id="uncheck_<?php echo (int) $entry->get_id(); ?>" href="#" class="vim-u" title="<?php esc_attr_e('Uncheck entry', 'gwolle-gb'); ?>"><?php esc_html_e('Uncheck', 'gwolle-gb'); ?></a>
120
  </span>
121
  <span class="gwolle_gb_spam">
122
  &nbsp;|&nbsp;
123
+ <a id="spam_<?php echo (int) $entry->get_id(); ?>" href="#" class="vim-s vim-destructive" title="<?php esc_attr_e('Mark entry as spam.', 'gwolle-gb'); ?>"><?php esc_html_e('Spam', 'gwolle-gb'); ?></a>
124
  </span>
125
  <span class="gwolle_gb_unspam">
126
  &nbsp;|&nbsp;
127
+ <a id="unspam_<?php echo (int) $entry->get_id(); ?>" href="#" class="vim-a" title="<?php esc_attr_e('Mark entry as not-spam.', 'gwolle-gb'); ?>"><?php esc_html_e('Not spam', 'gwolle-gb'); ?></a>
128
  </span>
129
  <span class="gwolle_gb_trash">
130
  &nbsp;|&nbsp;
131
+ <a id="trash_<?php echo (int) $entry->get_id(); ?>" href="#" class="vim-d vim-destructive" title="<?php esc_attr_e('Move entry to trash.', 'gwolle-gb'); ?>"><?php /* translators: Move to Trashcan */ esc_html_e('Trash', 'gwolle-gb'); ?></a>
132
  </span>
133
  <span class="gwolle_gb_untrash">
134
  &nbsp;|&nbsp;
135
+ <a id="untrash_<?php echo (int) $entry->get_id(); ?>" href="#" class="vim-d" title="<?php esc_attr_e('Recover entry from trash.', 'gwolle-gb'); ?>"><?php esc_html_e('Untrash', 'gwolle-gb'); ?></a>
136
  </span>
137
  <span class="gwolle_gb_ajax">
138
  &nbsp;|&nbsp;
139
+ <a id="ajax_<?php echo (int) $entry->get_id(); ?>" href="#" class="ajax vim-d vim-destructive" title="<?php esc_attr_e('Please wait...', 'gwolle-gb'); ?>"><?php esc_html_e('Wait...', 'gwolle-gb'); ?></a>
140
  </span>
141
  </p>
142
  </div>
162
  */
163
  function gwolle_gb_dashboard_setup() {
164
 
165
+ if ( ! current_user_can('moderate_comments') ) {
166
  return;
167
  }
168
 
admin/gb-page-add-on.php CHANGED
@@ -26,13 +26,13 @@ add_action( 'admin_menu', 'gwolle_gb_addon_menu_advertisement', 11 );
26
  */
27
  function gwolle_gb_addon_page_advertisement() {
28
 
29
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
30
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
31
  }
32
 
33
  gwolle_gb_admin_enqueue();
34
 
35
- add_meta_box('gwolle_gb_addon_description', esc_html__('Gwolle Guestbook: The Add-On','gwolle-gb'), 'gwolle_gb_addon_description', 'gwolle_gb_addon', 'normal');
36
  add_meta_box('gwolle_gb_addon_features', esc_html__('Features', 'gwolle-gb'), 'gwolle_gb_addon_features', 'gwolle_gb_addon', 'normal');
37
 
38
  add_meta_box('gwolle_gb_addon_buy', esc_html__('Buy Now', 'gwolle-gb'), 'gwolle_gb_addon_buy', 'gwolle_gb_addon', 'right');
@@ -62,10 +62,10 @@ function gwolle_gb_addon_page_advertisement() {
62
  /*
63
  * Metabox with the main description of the add-on.
64
  */
65
- function gwolle_gb_addon_description(){
66
  ?>
67
  <div class="table table_content gwolle_gb">
68
- <p><?php esc_html_e('Gwolle Guestbook: The Add-On is a commercial add-on for Gwolle Guestbook that gives extra functionality for your guestbook.','gwolle-gb'); ?></p>
69
  </div>
70
  <div id="gwolle-gb-addon-screenshot"><br /></div>
71
  <?php
@@ -77,25 +77,25 @@ function gwolle_gb_addon_description(){
77
  */
78
  function gwolle_gb_addon_features() {
79
  echo '<h3>
80
- ' . esc_html__('Current features include:', 'gwolle-gb').'</h3>
81
  <ul class="ul-disc">
82
- <li>' . esc_html__('Meta Fields. Add any field you want; company, phone number, you name it.', 'gwolle-gb').'</li>
83
- <li>' . esc_html__('Social Media Sharing (optional).', 'gwolle-gb').'</li>
84
- <li>' . esc_html__('Star Ratings, with voting and display and Rich Snippets for SEO (optional).','gwolle-gb').'</li>
85
- <li>' . esc_html__('Average star rating per guestbook, including a widget.','gwolle-gb').'</li>
86
- <li>' . esc_html__('Like an entry and view likes for each entry.','gwolle-gb').'</li>
87
- <li>' . esc_html__('Preview for the frontend form.','gwolle-gb').'</li>
88
- <li>' . esc_html__('Preview for the admin editor form.','gwolle-gb').'</li>
89
- <li>' . esc_html__('Admin reply on the frontend with AJAX.','gwolle-gb').'</li>
90
- <li>' . esc_html__('Edit content/author/origin of entry on the frontend with AJAX.','gwolle-gb').'</li>
91
- <li>' . esc_html__('Report Abuse.','gwolle-gb').'</li>
92
- <li>' . esc_html__('Easy String Replacement in the default text so you can make this guestbook into a review section or anything you want.','gwolle-gb').'</li>
93
- <li>' . esc_html__('Delete button in each entry for the moderator and author (optional).','gwolle-gb').'</li>
94
- <li>' . esc_html__('Permalink button in each entry for easy access (optional).','gwolle-gb').'</li>
95
- <li>' . esc_html__('Email button to contact each author (optional).','gwolle-gb').'</li>
96
- <li>' . esc_html__('Sitemap support for popular SEO/Sitemap plugins.','gwolle-gb').'</li>
97
- <li>' . esc_html__('Auto Anonymize timer (optional).','gwolle-gb').'</li>
98
- <li>' . esc_html__('Auto Delete timer (optional).','gwolle-gb').'</li>
99
  </ul>';
100
  }
101
 
@@ -113,7 +113,7 @@ function gwolle_gb_addon_buy() {
113
  <?php
114
  $link = '<a href="https://zenoweb.nl/forums/forum/guestbook-add-on/" target="_blank">';
115
  /* translators: %s is a link */
116
- echo sprintf( esc_html__('Support for the add-on is also at the %sZenoWeb Support Forum%s.','gwolle-gb'), $link, '</a>' ); ?>
117
  </p>
118
  <?php
119
  }
26
  */
27
  function gwolle_gb_addon_page_advertisement() {
28
 
29
+ if ( ! current_user_can('moderate_comments') ) {
30
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
31
  }
32
 
33
  gwolle_gb_admin_enqueue();
34
 
35
+ add_meta_box('gwolle_gb_addon_description', esc_html__('Gwolle Guestbook: The Add-On', 'gwolle-gb'), 'gwolle_gb_addon_description', 'gwolle_gb_addon', 'normal');
36
  add_meta_box('gwolle_gb_addon_features', esc_html__('Features', 'gwolle-gb'), 'gwolle_gb_addon_features', 'gwolle_gb_addon', 'normal');
37
 
38
  add_meta_box('gwolle_gb_addon_buy', esc_html__('Buy Now', 'gwolle-gb'), 'gwolle_gb_addon_buy', 'gwolle_gb_addon', 'right');
62
  /*
63
  * Metabox with the main description of the add-on.
64
  */
65
+ function gwolle_gb_addon_description() {
66
  ?>
67
  <div class="table table_content gwolle_gb">
68
+ <p><?php esc_html_e('Gwolle Guestbook: The Add-On is a commercial add-on for Gwolle Guestbook that gives extra functionality for your guestbook.', 'gwolle-gb'); ?></p>
69
  </div>
70
  <div id="gwolle-gb-addon-screenshot"><br /></div>
71
  <?php
77
  */
78
  function gwolle_gb_addon_features() {
79
  echo '<h3>
80
+ ' . esc_html__('Current features include:', 'gwolle-gb') . '</h3>
81
  <ul class="ul-disc">
82
+ <li>' . esc_html__('Meta Fields. Add any field you want; company, phone number, you name it.', 'gwolle-gb') . '</li>
83
+ <li>' . esc_html__('Social Media Sharing (optional).', 'gwolle-gb') . '</li>
84
+ <li>' . esc_html__('Star Ratings, with voting and display and Rich Snippets for SEO (optional).', 'gwolle-gb') . '</li>
85
+ <li>' . esc_html__('Average star rating per guestbook, including a widget.', 'gwolle-gb') . '</li>
86
+ <li>' . esc_html__('Like an entry and view likes for each entry.', 'gwolle-gb') . '</li>
87
+ <li>' . esc_html__('Preview for the frontend form.', 'gwolle-gb') . '</li>
88
+ <li>' . esc_html__('Preview for the admin editor form.', 'gwolle-gb') . '</li>
89
+ <li>' . esc_html__('Admin reply on the frontend with AJAX.', 'gwolle-gb') . '</li>
90
+ <li>' . esc_html__('Edit content/author/origin of entry on the frontend with AJAX.', 'gwolle-gb') . '</li>
91
+ <li>' . esc_html__('Report Abuse.', 'gwolle-gb') . '</li>
92
+ <li>' . esc_html__('Easy String Replacement in the default text so you can make this guestbook into a review section or anything you want.', 'gwolle-gb') . '</li>
93
+ <li>' . esc_html__('Delete button in each entry for the moderator and author (optional).', 'gwolle-gb') . '</li>
94
+ <li>' . esc_html__('Permalink button in each entry for easy access (optional).', 'gwolle-gb') . '</li>
95
+ <li>' . esc_html__('Email button to contact each author (optional).', 'gwolle-gb') . '</li>
96
+ <li>' . esc_html__('Sitemap support for popular SEO/Sitemap plugins.', 'gwolle-gb') . '</li>
97
+ <li>' . esc_html__('Auto Anonymize timer (optional).', 'gwolle-gb') . '</li>
98
+ <li>' . esc_html__('Auto Delete timer (optional).', 'gwolle-gb') . '</li>
99
  </ul>';
100
  }
101
 
113
  <?php
114
  $link = '<a href="https://zenoweb.nl/forums/forum/guestbook-add-on/" target="_blank">';
115
  /* translators: %s is a link */
116
+ echo sprintf( esc_html__('Support for the add-on is also at the %sZenoWeb Support Forum%s.', 'gwolle-gb'), $link, '</a>' ); ?>
117
  </p>
118
  <?php
119
  }
admin/gb-page-editor.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_editor() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
@@ -22,7 +22,7 @@ function gwolle_gb_page_editor() {
22
  gwolle_gb_register();
23
 
24
  $gwolle_gb_errors = false;
25
- $sectionHeading = esc_html__('Edit guestbook entry', 'gwolle-gb');
26
 
27
  // Always fetch the requested entry, so we can compare the $entry and the $_POST.
28
  $entry = new gwolle_gb_entry();
@@ -37,16 +37,16 @@ function gwolle_gb_page_editor() {
37
  if ( ! $result ) {
38
  gwolle_gb_add_message( '<p>' . esc_html__('Entry could not be found.', 'gwolle-gb') . '</p>', true, false);
39
  $gwolle_gb_errors = true;
40
- $sectionHeading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
41
  }
42
  } else {
43
- $sectionHeading = esc_html__('New guestbook entry', 'gwolle-gb');
44
  }
45
 
46
  /*
47
  * Handle the $_POST
48
  */
49
- if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'editor' && $gwolle_gb_errors === false ) {
50
  $entry = gwolle_gb_page_editor_update( $entry );
51
  }
52
  $gwolle_gb_messages = gwolle_gb_get_messages();
@@ -62,7 +62,7 @@ function gwolle_gb_page_editor() {
62
  ?>
63
  <div class="wrap gwolle_gb">
64
  <div id="icon-gwolle-gb"><br /></div>
65
- <h1><?php echo $sectionHeading; ?> (Gwolle Guestbook) - v<?php echo GWOLLE_GB_VER; ?></h1>
66
 
67
  <?php
68
  if ( $gwolle_gb_messages ) {
@@ -75,19 +75,19 @@ function gwolle_gb_page_editor() {
75
 
76
  <form name="gwolle_gb_editor" id="gwolle_gb_editor" method="POST" action="#" accept-charset="UTF-8">
77
  <input type="hidden" name="gwolle_gb_page" value="editor" />
78
- <input type="hidden" name="entry_id" value="<?php echo $entry->get_id(); ?>" />
79
 
80
  <?php
81
  /* Nonce */
82
  $nonce = wp_create_nonce( 'gwolle_gb_page_editor' );
83
- echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
84
  ?>
85
 
86
  <div id="poststuff" class="gwolle_gb_editor">
87
  <div id="post-body" class="metabox-holder columns-2">
88
  <div id="post-body-content">
89
  <?php
90
- add_meta_box('gwolle_gb_editor_postbox_content', esc_html__('Guestbook entry','gwolle-gb'), 'gwolle_gb_editor_postbox_content', 'gwolle_gb_editor', 'normal');
91
  add_meta_box('gwolle_gb_editor_postbox_website', esc_html__('Website', 'gwolle-gb'), 'gwolle_gb_editor_postbox_website', 'gwolle_gb_editor', 'normal');
92
  add_meta_box('gwolle_gb_editor_postbox_author', esc_html__('City', 'gwolle-gb'), 'gwolle_gb_editor_postbox_author_origin', 'gwolle_gb_editor', 'normal');
93
  add_meta_box('gwolle_gb_editor_postbox_admin_reply', esc_html__('Admin Reply', 'gwolle-gb'), 'gwolle_gb_editor_postbox_admin_reply', 'gwolle_gb_editor', 'normal');
@@ -95,10 +95,10 @@ function gwolle_gb_page_editor() {
95
  $active = is_plugin_active( 'gwolle-gb-addon/gwolle-gb-addon.php' ); // true or false
96
  $entry_id = $entry->get_id();
97
  if ( $active && function_exists( 'gwolle_gb_addon_editor_postbox_preview' ) && $entry_id > 0 ) {
98
- add_meta_box('gwolle_gb_editor_postbox_preview', esc_html__('Preview','gwolle-gb'), 'gwolle_gb_addon_editor_postbox_preview', 'gwolle_gb_editor', 'normal');
99
  }
100
  if ( $active && function_exists( 'gwolle_gb_addon_editor_metabox_meta' ) ) {
101
- add_meta_box('gwolle_gb_addon_editor_metabox_meta', esc_html__('The Add-On','gwolle-gb'), 'gwolle_gb_addon_editor_metabox_meta', 'gwolle_gb_editor', 'normal');
102
  }
103
 
104
  do_meta_boxes( 'gwolle_gb_editor', 'normal', $entry );
@@ -108,8 +108,8 @@ function gwolle_gb_page_editor() {
108
  <?php
109
  add_meta_box('gwolle_gb_editor_postbox_icons', esc_html__('Visibility', 'gwolle-gb'), 'gwolle_gb_editor_postbox_icons', 'gwolle_gb_editor', 'side');
110
  add_meta_box('gwolle_gb_editor_postbox_actions', esc_html__('Actions', 'gwolle-gb'), 'gwolle_gb_editor_postbox_actions', 'gwolle_gb_editor', 'side');
111
- add_meta_box('gwolle_gb_editor_postbox_details', esc_html__('Details','gwolle-gb'), 'gwolle_gb_editor_postbox_details', 'gwolle_gb_editor', 'side');
112
- add_meta_box('gwolle_gb_editor_postbox_logs', esc_html__('Log','gwolle-gb'), 'gwolle_gb_editor_postbox_logs', 'gwolle_gb_editor', 'side');
113
 
114
  do_meta_boxes( 'gwolle_gb_editor', 'side', $entry );
115
  ?>
@@ -127,16 +127,16 @@ function gwolle_gb_page_editor() {
127
  */
128
  function gwolle_gb_editor_postbox_content( $entry ) {
129
  ?>
130
- <textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji"><?php echo gwolle_gb_sanitize_output( $entry->get_content(), 'content' ); ?></textarea>
131
  <?php
132
- if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
133
  $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
134
  /* translators: %s is a link */
135
  echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), $settingslink, '</a>' ) . '</p>';
136
  }
137
  $form_setting = gwolle_gb_get_setting( 'form' );
138
 
139
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
140
  gwolle_gb_enqueue_markitup();
141
 
142
  // Emoji symbols
@@ -157,7 +157,7 @@ function gwolle_gb_editor_postbox_content( $entry ) {
157
  */
158
  function gwolle_gb_editor_postbox_website( $entry ) {
159
  ?>
160
- <input type="url" name="gwolle_gb_author_website" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_website() ); ?>" id="author_website" />
161
  <p><?php
162
  /* translators: %s is a code element */
163
  echo sprintf( esc_html__('Example: %shttps://www.example.com/%s', 'gwolle-gb'), '<code>', '</code>' ); ?>
@@ -171,7 +171,7 @@ function gwolle_gb_editor_postbox_website( $entry ) {
171
  */
172
  function gwolle_gb_editor_postbox_author_origin( $entry ) {
173
  ?>
174
- <input type="text" name="gwolle_gb_author_origin" class="wp-exclude-emoji" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_origin() ); ?>" id="author_origin" />
175
  <?php
176
  }
177
 
@@ -183,10 +183,10 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
183
  $form_setting = gwolle_gb_get_setting( 'form' );
184
  ?>
185
 
186
- <textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" class="wp-exclude-emoji"><?php echo gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ); ?></textarea>
187
 
188
  <?php
189
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
190
  echo '<div class="gwolle_gb_admin_reply_emoji gwolle-gb-hide">';
191
  // Emoji symbols
192
  $emoji = gwolle_gb_get_emoji();
@@ -202,6 +202,7 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
202
  $admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
203
  if ( $admin_reply_name ) { ?>
204
  <p class="gb-admin_reply_uid"><?php
 
205
  $admin_reply_header = '<em>' . sprintf( esc_html__('Admin Reply by: %s', 'gwolle-gb'), $admin_reply_name ) . '</em>';
206
  echo apply_filters( 'gwolle_gb_admin_reply_header', $admin_reply_header, $entry );
207
  ?>
@@ -216,7 +217,7 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
216
  </p>
217
 
218
  <?php
219
- if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
220
  $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
221
  /* translators: %s is a link */
222
  echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), $settingslink, '</a>' ) . '</p>';
@@ -236,7 +237,7 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
236
  $permalink = gwolle_gb_get_permalink( $postid );
237
  ?>
238
  <div id="gwolle_gb_frontend">
239
- <a class="button rbutton button" href="<?php echo $permalink; ?>"><?php esc_attr_e('View Guestbook','gwolle-gb'); ?></a>
240
  </div>
241
  <?php
242
  }
@@ -258,10 +259,10 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
258
  <?php
259
  }
260
 
261
- if ( $entry->get_id() == 0 ) {
262
  echo '<h3 class="h3-invisible">' . esc_html__('This entry is not yet visible.', 'gwolle-gb') . '</h3>';
263
  } else {
264
- if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
265
  echo '
266
  <h3 class="h3-visible">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
267
  <h3 class="h3-invisible" style="display:none;">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
@@ -275,7 +276,7 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
275
 
276
  <label for="ischecked" class="selectit">
277
  <input id="ischecked" name="ischecked" type="checkbox" <?php
278
- if ($entry->get_ischecked() == '1' || $entry->get_id() == 0) {
279
  echo 'checked="checked"';
280
  }
281
  ?> />
@@ -285,7 +286,7 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
285
  <br />
286
  <label for="isspam" class="selectit">
287
  <input id="isspam" name="isspam" type="checkbox" <?php
288
- if ($entry->get_isspam() == '1') {
289
  echo 'checked="checked"';
290
  }
291
  ?> />
@@ -295,7 +296,7 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
295
  <br />
296
  <label for="istrash" class="selectit">
297
  <input id="istrash" name="istrash" type="checkbox" <?php
298
- if ($entry->get_istrash() == '1') {
299
  echo 'checked="checked"';
300
  }
301
  ?> />
@@ -304,7 +305,9 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
304
 
305
  <?php
306
  $trashclass = '';
307
- if ( $entry->get_istrash() == '0' ) { $trashclass = 'gwolle-gb-hide'; } ?>
 
 
308
  <br />
309
  <label for="remove" class="selectit gwolle_gb_remove <?php echo $trashclass; ?>">
310
  <input id="remove" name="remove" type="checkbox" />
@@ -425,34 +428,6 @@ function gwolle_gb_editor_postbox_details( $entry ) {
425
  }
426
 
427
 
428
- /*
429
- * Metabox with the log of the entry.
430
- */
431
- function gwolle_gb_editor_postbox_logs( $entry ) {
432
- ?>
433
- <ul>
434
- <?php
435
- if ($entry->get_datetime() > 0) {
436
- echo '<li>';
437
- echo date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
438
- echo date_i18n( get_option('time_format'), $entry->get_datetime() );
439
- echo ': ' . /* translators: Log on Editor */ esc_html__('Written', 'gwolle-gb') . '</li>';
440
-
441
- $log_entries = gwolle_gb_get_log_entries( $entry->get_id() );
442
- if ( is_array($log_entries) && !empty($log_entries) ) {
443
- foreach ($log_entries as $log_entry) {
444
- echo '<li class="log_id_' . $log_entry['id'] . '">' . $log_entry['msg_html'] . '</li>';
445
- }
446
- }
447
- } else {
448
- echo '<li>(' . esc_html__('No log yet.', 'gwolle-gb') . ')</li>';
449
- }
450
- ?>
451
- </ul>
452
- <?php
453
- }
454
-
455
-
456
  /*
457
  * Taken from wp-admin/includes/template.php touch_time()
458
  * Adapted for simplicity.
@@ -463,11 +438,11 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
463
  global $wp_locale;
464
  ?>
465
  <label for="gwolle_gb_author_name"><?php esc_html_e('Author', 'gwolle-gb'); ?></label><br />
466
- <input type="text" name="gwolle_gb_author_name" size="24" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_name() ); ?>" id="gwolle_gb_author_name" class="wp-exclude-emoji" /><br />
467
 
468
  <label for="gwolle_gb_author_id"><?php esc_html_e('Author ID', 'gwolle-gb');
469
  // Get user ID from email address.
470
- $user = new WP_User;
471
  $user_object = $user->get_data_by( 'email', gwolle_gb_sanitize_output( $entry->get_author_email() ) );
472
  if ( is_object( $user_object ) && isset( $user_object->ID ) ) {
473
  /* translators: %s is the user ID that is suggested. */
@@ -491,15 +466,15 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
491
  $mn = date_i18n( 'i', $date );
492
 
493
  // Day
494
- echo '<label><span class="screen-reader-text">' . esc_html__( 'Day', 'gwolle-gb' ) . '</span><input type="text" id="dd" name="dd" value="' . $dd . '" size="2" maxlength="2" autocomplete="off" /></label>';
495
 
496
  // Month
497
  echo '<label for="mm"><span class="screen-reader-text">' . esc_html__( 'Month', 'gwolle-gb' ) . '</span>
498
  <select id="mm" name="mm">';
499
- for ( $i = 1; $i < 13; $i = $i +1 ) {
500
  $monthnum = zeroise($i, 2);
501
  echo '
502
- <option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
503
  /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
504
  echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . '</option>';
505
  }
@@ -507,12 +482,12 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
507
  </select></label>';
508
 
509
  // Year
510
- echo '<label for="yy"><span class="screen-reader-text">' . esc_html__( 'Year', 'gwolle-gb' ) . '</span><input type="text" id="yy" name="yy" value="' . $yy . '" size="4" maxlength="4" autocomplete="off" /></label>';
511
  echo '<br />';
512
  // Hour
513
- echo '<label for="hh"><span class="screen-reader-text">' . esc_html__( 'Hour', 'gwolle-gb' ) . '</span><input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2" autocomplete="off" /></label>:';
514
  // Minute
515
- echo '<label for="mn"><span class="screen-reader-text">' . esc_html__( 'Minute', 'gwolle-gb' ) . '</span><input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2" autocomplete="off" /></label>';
516
  ?>
517
 
518
  <div class="gwolle_gb_timestamp">
@@ -537,6 +512,35 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
537
  }
538
 
539
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  /*
541
  * Update admin page with the entry editor. Used for new and existing entries.
542
  *
@@ -544,7 +548,7 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
544
  */
545
  function gwolle_gb_page_editor_update( $entry ) {
546
 
547
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
548
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
549
  }
550
 
@@ -564,14 +568,14 @@ function gwolle_gb_page_editor_update( $entry ) {
564
  return $entry;
565
  }
566
 
567
- if ( ! isset($_POST['entry_id']) || $_POST['entry_id'] != $entry->get_id() ) {
568
  gwolle_gb_add_message( '<p>' . esc_html__('Something strange happened.', 'gwolle-gb') . '</p>', true, false);
569
  return $entry;
570
  } else if ( $_POST['entry_id'] > 0 && $entry->get_id() > 0 ) {
571
 
572
  /* Remove permanently and return early. */
573
- if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' && isset($_POST['remove']) && $_POST['remove'] == 'on' ) {
574
- if ( $entry->get_istrash() == 1 ) {
575
  $entry->delete();
576
  $entry->set_id(0);
577
  $changed = true;
@@ -583,27 +587,27 @@ function gwolle_gb_page_editor_update( $entry ) {
583
 
584
  /* Check if it was visible or not. We need to check this, because multiple changes are possible and we don't want multiple emails. */
585
  $was_visible = false;
586
- if ( $entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
587
  $was_visible = true;
588
  }
589
 
590
  /* Set as checked or unchecked, and by whom */
591
- if ( isset($_POST['ischecked']) && $_POST['ischecked'] == 'on' ) {
592
- if ( $_POST['ischecked'] == 'on' && $entry->get_ischecked() == 0 ) {
593
  $entry->set_ischecked( true );
594
  $user_id = get_current_user_id(); // returns 0 if no current user
595
  $entry->set_checkedby( $user_id );
596
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
597
  gwolle_gb_clear_cache( $entry );
598
  }
599
- } else if ( $entry->get_ischecked() == 1 ) {
600
  $entry->set_ischecked( false );
601
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
602
  }
603
 
604
  /* Set as spam or not, and submit as ham or spam to Akismet service */
605
- if ( isset($_POST['isspam']) && $_POST['isspam'] == 'on' ) {
606
- if ( $_POST['isspam'] == 'on' && $entry->get_isspam() == 0 ) {
607
  $entry->set_isspam( true );
608
  $result = gwolle_gb_akismet( $entry, 'submit-spam' );
609
  if ( $result ) {
@@ -611,7 +615,7 @@ function gwolle_gb_page_editor_update( $entry ) {
611
  }
612
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
613
  }
614
- } else if ( $entry->get_isspam() == 1 ) {
615
  $entry->set_isspam( false );
616
  $result = gwolle_gb_akismet( $entry, 'submit-ham' );
617
  if ( $result ) {
@@ -621,12 +625,12 @@ function gwolle_gb_page_editor_update( $entry ) {
621
  }
622
 
623
  /* Set as trash or not */
624
- if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' ) {
625
- if ( $_POST['istrash'] == 'on' && $entry->get_istrash() == 0 ) {
626
  $entry->set_istrash( true );
627
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
628
  }
629
- } else if ( $entry->get_istrash() == 1 ) {
630
  $entry->set_istrash( false );
631
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
632
  }
@@ -645,7 +649,7 @@ function gwolle_gb_page_editor_update( $entry ) {
645
  } else {
646
  $website = '';
647
  }
648
- if ( $website != $entry->get_author_website() ) {
649
  $entry->set_author_website( $website );
650
  }
651
 
@@ -659,7 +663,7 @@ function gwolle_gb_page_editor_update( $entry ) {
659
 
660
  /* Check if the admin_reply changed, and update and log accordingly */
661
  if ( isset($_POST['gwolle_gb_admin_reply']) ) {
662
- if ( trim($_POST['gwolle_gb_admin_reply']) != $entry->get_admin_reply() ) {
663
  $gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
664
  if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
665
  $entry->set_admin_reply_uid( get_current_user_id() );
@@ -676,7 +680,7 @@ function gwolle_gb_page_editor_update( $entry ) {
676
 
677
  /* Mail the author about the Admin Reply, if so requested */
678
  if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
679
- if ( $_POST['gwolle_gb_admin_reply_mail_author'] == 'on' ) {
680
  gwolle_gb_mail_author_on_admin_reply( $entry );
681
  }
682
  }
@@ -715,7 +719,7 @@ function gwolle_gb_page_editor_update( $entry ) {
715
  if ($result ) {
716
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
717
  gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
718
- if ( $was_visible == false && $entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
719
  gwolle_gb_mail_author_on_moderation( $entry );
720
  }
721
  do_action( 'gwolle_gb_save_entry_admin', $entry );
@@ -723,17 +727,17 @@ function gwolle_gb_page_editor_update( $entry ) {
723
  gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
724
  }
725
 
726
- } else if ( $_POST['entry_id'] == 0 && $entry->get_id() == 0 ) {
727
 
728
  /*
729
  * Check for input, and save accordingly. This is on a New Entry! (So no logging)
730
  */
731
 
732
- $data = Array();
733
 
734
  /* Set as checked anyway, new entry is always by an admin */
735
  $data['ischecked'] = true;
736
- $user_id = get_current_user_id(); // returns 0 if no current user
737
  $data['checkedby'] = $user_id;
738
  $data['author_id'] = $user_id;
739
 
@@ -764,7 +768,7 @@ function gwolle_gb_page_editor_update( $entry ) {
764
  $data['content'] = gwolle_gb_maybe_encode_emoji( $data['content'], 'content' );
765
  } else {
766
  $form_setting = gwolle_gb_get_setting( 'form' );
767
- if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' && isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
768
  gwolle_gb_add_message( '<p>' . esc_html__('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>', true, false);
769
  } else {
770
  $data['content'] = '';
@@ -805,7 +809,7 @@ function gwolle_gb_page_editor_update( $entry ) {
805
  /* Network Information */
806
  $set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
807
  $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
808
- if ( $set_author_ip && ($set_author_ip2 == 'true') ) {
809
  $entry->set_author_ip( gwolle_gb_get_user_ip() );
810
  $entry->set_author_host( gethostbyaddr( gwolle_gb_get_user_ip() ) );
811
  }
14
  */
15
  function gwolle_gb_page_editor() {
16
 
17
+ if ( ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
22
  gwolle_gb_register();
23
 
24
  $gwolle_gb_errors = false;
25
+ $section_heading = esc_html__('Edit guestbook entry', 'gwolle-gb');
26
 
27
  // Always fetch the requested entry, so we can compare the $entry and the $_POST.
28
  $entry = new gwolle_gb_entry();
37
  if ( ! $result ) {
38
  gwolle_gb_add_message( '<p>' . esc_html__('Entry could not be found.', 'gwolle-gb') . '</p>', true, false);
39
  $gwolle_gb_errors = true;
40
+ $section_heading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
41
  }
42
  } else {
43
+ $section_heading = esc_html__('New guestbook entry', 'gwolle-gb');
44
  }
45
 
46
  /*
47
  * Handle the $_POST
48
  */
49
+ if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'editor' && $gwolle_gb_errors === false ) {
50
  $entry = gwolle_gb_page_editor_update( $entry );
51
  }
52
  $gwolle_gb_messages = gwolle_gb_get_messages();
62
  ?>
63
  <div class="wrap gwolle_gb">
64
  <div id="icon-gwolle-gb"><br /></div>
65
+ <h1><?php echo $section_heading; ?> (Gwolle Guestbook) - v<?php echo GWOLLE_GB_VER; ?></h1>
66
 
67
  <?php
68
  if ( $gwolle_gb_messages ) {
75
 
76
  <form name="gwolle_gb_editor" id="gwolle_gb_editor" method="POST" action="#" accept-charset="UTF-8">
77
  <input type="hidden" name="gwolle_gb_page" value="editor" />
78
+ <input type="hidden" name="entry_id" value="<?php echo (int) $entry->get_id(); ?>" />
79
 
80
  <?php
81
  /* Nonce */
82
  $nonce = wp_create_nonce( 'gwolle_gb_page_editor' );
83
+ echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . esc_attr( $nonce ) . '" />';
84
  ?>
85
 
86
  <div id="poststuff" class="gwolle_gb_editor">
87
  <div id="post-body" class="metabox-holder columns-2">
88
  <div id="post-body-content">
89
  <?php
90
+ add_meta_box('gwolle_gb_editor_postbox_content', esc_html__('Guestbook entry', 'gwolle-gb'), 'gwolle_gb_editor_postbox_content', 'gwolle_gb_editor', 'normal');
91
  add_meta_box('gwolle_gb_editor_postbox_website', esc_html__('Website', 'gwolle-gb'), 'gwolle_gb_editor_postbox_website', 'gwolle_gb_editor', 'normal');
92
  add_meta_box('gwolle_gb_editor_postbox_author', esc_html__('City', 'gwolle-gb'), 'gwolle_gb_editor_postbox_author_origin', 'gwolle_gb_editor', 'normal');
93
  add_meta_box('gwolle_gb_editor_postbox_admin_reply', esc_html__('Admin Reply', 'gwolle-gb'), 'gwolle_gb_editor_postbox_admin_reply', 'gwolle_gb_editor', 'normal');
95
  $active = is_plugin_active( 'gwolle-gb-addon/gwolle-gb-addon.php' ); // true or false
96
  $entry_id = $entry->get_id();
97
  if ( $active && function_exists( 'gwolle_gb_addon_editor_postbox_preview' ) && $entry_id > 0 ) {
98
+ add_meta_box('gwolle_gb_editor_postbox_preview', esc_html__('Preview', 'gwolle-gb'), 'gwolle_gb_addon_editor_postbox_preview', 'gwolle_gb_editor', 'normal');
99
  }
100
  if ( $active && function_exists( 'gwolle_gb_addon_editor_metabox_meta' ) ) {
101
+ add_meta_box('gwolle_gb_addon_editor_metabox_meta', esc_html__('The Add-On', 'gwolle-gb'), 'gwolle_gb_addon_editor_metabox_meta', 'gwolle_gb_editor', 'normal');
102
  }
103
 
104
  do_meta_boxes( 'gwolle_gb_editor', 'normal', $entry );
108
  <?php
109
  add_meta_box('gwolle_gb_editor_postbox_icons', esc_html__('Visibility', 'gwolle-gb'), 'gwolle_gb_editor_postbox_icons', 'gwolle_gb_editor', 'side');
110
  add_meta_box('gwolle_gb_editor_postbox_actions', esc_html__('Actions', 'gwolle-gb'), 'gwolle_gb_editor_postbox_actions', 'gwolle_gb_editor', 'side');
111
+ add_meta_box('gwolle_gb_editor_postbox_details', esc_html__('Details', 'gwolle-gb'), 'gwolle_gb_editor_postbox_details', 'gwolle_gb_editor', 'side');
112
+ add_meta_box('gwolle_gb_editor_postbox_logs', esc_html__('Log', 'gwolle-gb'), 'gwolle_gb_editor_postbox_logs', 'gwolle_gb_editor', 'side');
113
 
114
  do_meta_boxes( 'gwolle_gb_editor', 'side', $entry );
115
  ?>
127
  */
128
  function gwolle_gb_editor_postbox_content( $entry ) {
129
  ?>
130
+ <textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji"><?php echo esc_textarea( gwolle_gb_sanitize_output( $entry->get_content(), 'content' ) ); ?></textarea>
131
  <?php
132
+ if (get_option('gwolle_gb-showLineBreaks', 'false') === 'false') {
133
  $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
134
  /* translators: %s is a link */
135
  echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), $settingslink, '</a>' ) . '</p>';
136
  }
137
  $form_setting = gwolle_gb_get_setting( 'form' );
138
 
139
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
140
  gwolle_gb_enqueue_markitup();
141
 
142
  // Emoji symbols
157
  */
158
  function gwolle_gb_editor_postbox_website( $entry ) {
159
  ?>
160
+ <input type="url" name="gwolle_gb_author_website" value="<?php echo esc_attr( gwolle_gb_sanitize_output( $entry->get_author_website() ) ); ?>" id="author_website" />
161
  <p><?php
162
  /* translators: %s is a code element */
163
  echo sprintf( esc_html__('Example: %shttps://www.example.com/%s', 'gwolle-gb'), '<code>', '</code>' ); ?>
171
  */
172
  function gwolle_gb_editor_postbox_author_origin( $entry ) {
173
  ?>
174
+ <input type="text" name="gwolle_gb_author_origin" class="wp-exclude-emoji" value="<?php echo esc_attr( gwolle_gb_sanitize_output( $entry->get_author_origin() ) ); ?>" id="author_origin" />
175
  <?php
176
  }
177
 
183
  $form_setting = gwolle_gb_get_setting( 'form' );
184
  ?>
185
 
186
+ <textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" class="wp-exclude-emoji"><?php echo esc_textarea( gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ) ); ?></textarea>
187
 
188
  <?php
189
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
190
  echo '<div class="gwolle_gb_admin_reply_emoji gwolle-gb-hide">';
191
  // Emoji symbols
192
  $emoji = gwolle_gb_get_emoji();
202
  $admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
203
  if ( $admin_reply_name ) { ?>
204
  <p class="gb-admin_reply_uid"><?php
205
+ /* translators: %s is the name of the admin author */
206
  $admin_reply_header = '<em>' . sprintf( esc_html__('Admin Reply by: %s', 'gwolle-gb'), $admin_reply_name ) . '</em>';
207
  echo apply_filters( 'gwolle_gb_admin_reply_header', $admin_reply_header, $entry );
208
  ?>
217
  </p>
218
 
219
  <?php
220
+ if (get_option('gwolle_gb-showLineBreaks', 'false') === 'false') {
221
  $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
222
  /* translators: %s is a link */
223
  echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), $settingslink, '</a>' ) . '</p>';
237
  $permalink = gwolle_gb_get_permalink( $postid );
238
  ?>
239
  <div id="gwolle_gb_frontend">
240
+ <a class="button rbutton button" href="<?php echo $permalink; ?>"><?php esc_attr_e('View Guestbook', 'gwolle-gb'); ?></a>
241
  </div>
242
  <?php
243
  }
259
  <?php
260
  }
261
 
262
+ if ( $entry->get_id() === 0 ) {
263
  echo '<h3 class="h3-invisible">' . esc_html__('This entry is not yet visible.', 'gwolle-gb') . '</h3>';
264
  } else {
265
+ if ($entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 ) {
266
  echo '
267
  <h3 class="h3-visible">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
268
  <h3 class="h3-invisible" style="display:none;">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
276
 
277
  <label for="ischecked" class="selectit">
278
  <input id="ischecked" name="ischecked" type="checkbox" <?php
279
+ if ($entry->get_ischecked() === '1' || $entry->get_id() === 0) {
280
  echo 'checked="checked"';
281
  }
282
  ?> />
286
  <br />
287
  <label for="isspam" class="selectit">
288
  <input id="isspam" name="isspam" type="checkbox" <?php
289
+ if ($entry->get_isspam() === '1') {
290
  echo 'checked="checked"';
291
  }
292
  ?> />
296
  <br />
297
  <label for="istrash" class="selectit">
298
  <input id="istrash" name="istrash" type="checkbox" <?php
299
+ if ($entry->get_istrash() === '1') {
300
  echo 'checked="checked"';
301
  }
302
  ?> />
305
 
306
  <?php
307
  $trashclass = '';
308
+ if ( $entry->get_istrash() === '0' ) {
309
+ $trashclass = 'gwolle-gb-hide';
310
+ } ?>
311
  <br />
312
  <label for="remove" class="selectit gwolle_gb_remove <?php echo $trashclass; ?>">
313
  <input id="remove" name="remove" type="checkbox" />
428
  }
429
 
430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  /*
432
  * Taken from wp-admin/includes/template.php touch_time()
433
  * Adapted for simplicity.
438
  global $wp_locale;
439
  ?>
440
  <label for="gwolle_gb_author_name"><?php esc_html_e('Author', 'gwolle-gb'); ?></label><br />
441
+ <input type="text" name="gwolle_gb_author_name" size="24" value="<?php echo esc_attr( gwolle_gb_sanitize_output( $entry->get_author_name() ) ); ?>" id="gwolle_gb_author_name" class="wp-exclude-emoji" /><br />
442
 
443
  <label for="gwolle_gb_author_id"><?php esc_html_e('Author ID', 'gwolle-gb');
444
  // Get user ID from email address.
445
+ $user = new WP_User();
446
  $user_object = $user->get_data_by( 'email', gwolle_gb_sanitize_output( $entry->get_author_email() ) );
447
  if ( is_object( $user_object ) && isset( $user_object->ID ) ) {
448
  /* translators: %s is the user ID that is suggested. */
466
  $mn = date_i18n( 'i', $date );
467
 
468
  // Day
469
+ echo '<label><span class="screen-reader-text">' . esc_html__( 'Day', 'gwolle-gb' ) . '</span><input type="text" id="dd" name="dd" value="' . esc_attr( $dd ) . '" size="2" maxlength="2" autocomplete="off" /></label>';
470
 
471
  // Month
472
  echo '<label for="mm"><span class="screen-reader-text">' . esc_html__( 'Month', 'gwolle-gb' ) . '</span>
473
  <select id="mm" name="mm">';
474
+ for ( $i = 1; $i < 13; $i++ ) {
475
  $monthnum = zeroise($i, 2);
476
  echo '
477
+ <option value="' . esc_attr( $monthnum ) . '" ' . selected( $monthnum, $mm, false ) . '>';
478
  /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
479
  echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . '</option>';
480
  }
482
  </select></label>';
483
 
484
  // Year
485
+ echo '<label for="yy"><span class="screen-reader-text">' . esc_html__( 'Year', 'gwolle-gb' ) . '</span><input type="text" id="yy" name="yy" value="' . esc_attr( $yy ) . '" size="4" maxlength="4" autocomplete="off" /></label>';
486
  echo '<br />';
487
  // Hour
488
+ echo '<label for="hh"><span class="screen-reader-text">' . esc_html__( 'Hour', 'gwolle-gb' ) . '</span><input type="text" id="hh" name="hh" value="' . esc_attr( $hh ) . '" size="2" maxlength="2" autocomplete="off" /></label>:';
489
  // Minute
490
+ echo '<label for="mn"><span class="screen-reader-text">' . esc_html__( 'Minute', 'gwolle-gb' ) . '</span><input type="text" id="mn" name="mn" value="' . esc_attr( $mn ) . '" size="2" maxlength="2" autocomplete="off" /></label>';
491
  ?>
492
 
493
  <div class="gwolle_gb_timestamp">
512
  }
513
 
514
 
515
+ /*
516
+ * Metabox with the log of the entry.
517
+ */
518
+ function gwolle_gb_editor_postbox_logs( $entry ) {
519
+ ?>
520
+ <ul>
521
+ <?php
522
+ if ($entry->get_datetime() > 0) {
523
+ echo '<li>';
524
+ echo date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
525
+ echo date_i18n( get_option('time_format'), $entry->get_datetime() );
526
+ /* translators: In log on Editor page */
527
+ echo ': ' . esc_html__('Written', 'gwolle-gb') . '</li>';
528
+
529
+ $log_entries = gwolle_gb_get_log_entries( $entry->get_id() );
530
+ if ( is_array($log_entries) && ! empty($log_entries) ) {
531
+ foreach ($log_entries as $log_entry) {
532
+ echo '<li class="log_id_' . $log_entry['id'] . '">' . $log_entry['msg_html'] . '</li>';
533
+ }
534
+ }
535
+ } else {
536
+ echo '<li>(' . esc_html__('No log yet.', 'gwolle-gb') . ')</li>';
537
+ }
538
+ ?>
539
+ </ul>
540
+ <?php
541
+ }
542
+
543
+
544
  /*
545
  * Update admin page with the entry editor. Used for new and existing entries.
546
  *
548
  */
549
  function gwolle_gb_page_editor_update( $entry ) {
550
 
551
+ if ( ! current_user_can('moderate_comments') ) {
552
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
553
  }
554
 
568
  return $entry;
569
  }
570
 
571
+ if ( ! isset($_POST['entry_id']) || (int) $_POST['entry_id'] !== $entry->get_id() ) {
572
  gwolle_gb_add_message( '<p>' . esc_html__('Something strange happened.', 'gwolle-gb') . '</p>', true, false);
573
  return $entry;
574
  } else if ( $_POST['entry_id'] > 0 && $entry->get_id() > 0 ) {
575
 
576
  /* Remove permanently and return early. */
577
+ if ( isset($_POST['istrash']) && $_POST['istrash'] === 'on' && isset($_POST['remove']) && $_POST['remove'] === 'on' ) {
578
+ if ( $entry->get_istrash() === 1 ) {
579
  $entry->delete();
580
  $entry->set_id(0);
581
  $changed = true;
587
 
588
  /* Check if it was visible or not. We need to check this, because multiple changes are possible and we don't want multiple emails. */
589
  $was_visible = false;
590
+ if ( $entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 ) {
591
  $was_visible = true;
592
  }
593
 
594
  /* Set as checked or unchecked, and by whom */
595
+ if ( isset($_POST['ischecked']) && $_POST['ischecked'] === 'on' ) {
596
+ if ( $_POST['ischecked'] === 'on' && $entry->get_ischecked() === 0 ) {
597
  $entry->set_ischecked( true );
598
  $user_id = get_current_user_id(); // returns 0 if no current user
599
  $entry->set_checkedby( $user_id );
600
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
601
  gwolle_gb_clear_cache( $entry );
602
  }
603
+ } else if ( $entry->get_ischecked() === 1 ) {
604
  $entry->set_ischecked( false );
605
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
606
  }
607
 
608
  /* Set as spam or not, and submit as ham or spam to Akismet service */
609
+ if ( isset($_POST['isspam']) && $_POST['isspam'] === 'on' ) {
610
+ if ( $_POST['isspam'] === 'on' && $entry->get_isspam() === 0 ) {
611
  $entry->set_isspam( true );
612
  $result = gwolle_gb_akismet( $entry, 'submit-spam' );
613
  if ( $result ) {
615
  }
616
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
617
  }
618
+ } else if ( $entry->get_isspam() === 1 ) {
619
  $entry->set_isspam( false );
620
  $result = gwolle_gb_akismet( $entry, 'submit-ham' );
621
  if ( $result ) {
625
  }
626
 
627
  /* Set as trash or not */
628
+ if ( isset($_POST['istrash']) && $_POST['istrash'] === 'on' ) {
629
+ if ( $_POST['istrash'] === 'on' && $entry->get_istrash() === 0 ) {
630
  $entry->set_istrash( true );
631
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
632
  }
633
+ } else if ( $entry->get_istrash() === 1 ) {
634
  $entry->set_istrash( false );
635
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
636
  }
649
  } else {
650
  $website = '';
651
  }
652
+ if ( $website !== $entry->get_author_website() ) {
653
  $entry->set_author_website( $website );
654
  }
655
 
663
 
664
  /* Check if the admin_reply changed, and update and log accordingly */
665
  if ( isset($_POST['gwolle_gb_admin_reply']) ) {
666
+ if ( trim($_POST['gwolle_gb_admin_reply']) !== $entry->get_admin_reply() ) {
667
  $gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
668
  if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
669
  $entry->set_admin_reply_uid( get_current_user_id() );
680
 
681
  /* Mail the author about the Admin Reply, if so requested */
682
  if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
683
+ if ( $_POST['gwolle_gb_admin_reply_mail_author'] === 'on' ) {
684
  gwolle_gb_mail_author_on_admin_reply( $entry );
685
  }
686
  }
719
  if ($result ) {
720
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
721
  gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
722
+ if ( $was_visible === false && $entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 ) {
723
  gwolle_gb_mail_author_on_moderation( $entry );
724
  }
725
  do_action( 'gwolle_gb_save_entry_admin', $entry );
727
  gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
728
  }
729
 
730
+ } else if ( (int) $_POST['entry_id'] === 0 && $entry->get_id() === 0 ) {
731
 
732
  /*
733
  * Check for input, and save accordingly. This is on a New Entry! (So no logging)
734
  */
735
 
736
+ $data = array();
737
 
738
  /* Set as checked anyway, new entry is always by an admin */
739
  $data['ischecked'] = true;
740
+ $user_id = get_current_user_id(); // returns 0 if no current user
741
  $data['checkedby'] = $user_id;
742
  $data['author_id'] = $user_id;
743
 
768
  $data['content'] = gwolle_gb_maybe_encode_emoji( $data['content'], 'content' );
769
  } else {
770
  $form_setting = gwolle_gb_get_setting( 'form' );
771
+ if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' && isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
772
  gwolle_gb_add_message( '<p>' . esc_html__('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>', true, false);
773
  } else {
774
  $data['content'] = '';
809
  /* Network Information */
810
  $set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
811
  $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
812
+ if ( $set_author_ip && ( $set_author_ip2 === 'true' ) ) {
813
  $entry->set_author_ip( gwolle_gb_get_user_ip() );
814
  $entry->set_author_host( gethostbyaddr( gwolle_gb_get_user_ip() ) );
815
  }
admin/gb-page-entries.php CHANGED
@@ -14,15 +14,18 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_entries() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  gwolle_gb_admin_enqueue();
22
 
23
- $show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
 
 
 
24
 
25
- if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
26
  gwolle_gb_page_entries_update();
27
  }
28
  $gwolle_gb_messages = gwolle_gb_get_messages();
@@ -33,39 +36,41 @@ function gwolle_gb_page_entries() {
33
  }
34
 
35
  // Get entry counts
36
- $count = Array();
37
  $count['checked'] = gwolle_gb_get_entry_count(array(
38
  'checked' => 'checked',
39
  'trash' => 'notrash',
40
- 'spam' => 'nospam'
41
  ));
42
  $count['unchecked'] = gwolle_gb_get_entry_count(array(
43
  'checked' => 'unchecked',
44
  'trash' => 'notrash',
45
- 'spam' => 'nospam'
46
  ));
47
  $count['spam'] = gwolle_gb_get_entry_count(array( 'spam' => 'spam' ));
48
  $count['trash'] = gwolle_gb_get_entry_count(array( 'trash'=> 'trash' ));
49
  $count['all'] = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
50
- $count['user'] = 0; // dummy data, there is no pagination here.
51
 
52
  $num_entries = (int) get_option('gwolle_gb-entries_per_page', 20);
53
 
54
- // Check if the requested page number is an integer > 0
55
- $pageNum = (isset($_REQUEST['pageNum']) && $_REQUEST['pageNum'] && (int) $_REQUEST['pageNum'] > 0) ? (int) $_REQUEST['pageNum'] : 1;
 
 
56
 
57
- $pages_total = ceil( $count[$show] / $num_entries );
58
- if ($pageNum > $pages_total) {
59
- $pageNum = 1; // page does not exist, return to first page.
60
  }
61
 
62
  // Calculate query.
63
- if ($pageNum == 1 && $count[$show] > 0) {
64
  $offset = 0;
65
- } elseif ($count[$show] == 0) {
66
  $offset = 0;
67
  } else {
68
- $offset = ($pageNum - 1) * $num_entries;
69
  }
70
 
71
  $book_id = 0;
@@ -74,73 +79,73 @@ function gwolle_gb_page_entries() {
74
  }
75
 
76
  // Get the entries.
77
- if ( $show == 'checked' ) {
78
  $entries = gwolle_gb_get_entries(array(
79
  'num_entries' => $num_entries,
80
  'offset' => $offset,
81
  'checked' => 'checked',
82
  'trash' => 'notrash',
83
  'spam' => 'nospam',
84
- 'book_id' => $book_id
85
  ));
86
  $count_entries = gwolle_gb_get_entry_count(array(
87
  'checked' => 'checked',
88
  'trash' => 'notrash',
89
  'spam' => 'nospam',
90
- 'book_id' => $book_id
91
  ));
92
- } else if ( $show == 'unchecked' ) {
93
  $entries = gwolle_gb_get_entries(array(
94
  'num_entries' => $num_entries,
95
  'offset' => $offset,
96
  'checked' => 'unchecked',
97
  'trash' => 'notrash',
98
  'spam' => 'nospam',
99
- 'book_id' => $book_id
100
  ));
101
  $count_entries = gwolle_gb_get_entry_count(array(
102
  'checked' => 'unchecked',
103
  'trash' => 'notrash',
104
  'spam' => 'nospam',
105
- 'book_id' => $book_id
106
  ));
107
- } else if ( $show == 'spam' ) {
108
  $entries = gwolle_gb_get_entries(array(
109
  'num_entries' => $num_entries,
110
  'offset' => $offset,
111
  'spam' => 'spam',
112
- 'book_id' => $book_id
113
  ));
114
  $count_entries = gwolle_gb_get_entry_count(array(
115
  'spam' => 'spam',
116
- 'book_id' => $book_id
117
  ));
118
- } else if ( $show == 'trash' ) {
119
  $entries = gwolle_gb_get_entries(array(
120
  'num_entries' => $num_entries,
121
  'offset' => $offset,
122
  'trash' => 'trash',
123
- 'book_id' => $book_id
124
  ));
125
  $count_entries = gwolle_gb_get_entry_count(array(
126
  'trash' => 'trash',
127
- 'book_id' => $book_id
128
  ));
129
- } else if ( $show == 'user' ) {
130
  $entries = array();
131
  if ( isset( $_POST['gwolle_gb_user_id']) && ( (int) $_POST['gwolle_gb_user_id'] > 0 ) ) {
132
  $user_id = (int) $_POST['gwolle_gb_user_id'];
133
  $entries = gwolle_gb_get_entries(array(
134
  'author_id' => $user_id,
135
  'num_entries' => -1,
136
- 'all' => 'all'
137
  ));
138
  } else if ( isset( $_POST['gwolle_gb_user_email']) && strlen($_POST['gwolle_gb_user_email']) > 0 ) {
139
- $user_email = $_POST['gwolle_gb_user_email'];
140
  $entries = gwolle_gb_get_entries(array(
141
  'email' => $user_email,
142
  'num_entries' => -1,
143
- 'all' => 'all'
144
  ));
145
  }
146
  if ( empty( $entries ) ) {
@@ -153,11 +158,11 @@ function gwolle_gb_page_entries() {
153
  'num_entries' => $num_entries,
154
  'offset' => $offset,
155
  'all' => 'all',
156
- 'book_id' => $book_id
157
  ));
158
  $count_entries = gwolle_gb_get_entry_count(array(
159
  'all' => 'all',
160
- 'book_id' => $book_id
161
  ));
162
  }
163
  $count_entrypages = ceil( $count_entries / $num_entries );
@@ -186,57 +191,57 @@ function gwolle_gb_page_entries() {
186
 
187
  <input type="hidden" name="gwolle_gb_page" value="entries" />
188
  <!-- the following fields give us some information used for processing the mass edit -->
189
- <input type="hidden" name="pageNum" value="<?php echo $pageNum; ?>">
190
- <input type="hidden" name="entriesOnThisPage" value="<?php echo $entries_on_page; ?>">
191
- <input type="hidden" name="show" value="<?php echo $show; ?>">
192
 
193
  <?php
194
  /* Nonce */
195
  $nonce = wp_create_nonce( 'gwolle_gb_page_entries' );
196
- echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
197
  ?>
198
 
199
  <ul class="subsubsub">
200
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=all' ); ?>" <?php
201
- if ($show == 'all') { echo 'class="current"'; }
202
  ?>>
203
  <?php esc_html_e('All', 'gwolle-gb'); ?> <span class="count gwolle_gb_all">(<?php echo $count['all']; ?>)</span></a> |
204
  </li>
205
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=checked' ); ?>" <?php
206
- if ($show == 'checked') { echo 'class="current"'; }
207
  ?>>
208
  <?php esc_html_e('Unlocked', 'gwolle-gb'); ?> <span class="count gwolle_gb_unlocked">(<?php echo $count['checked']; ?>)</span></a> |
209
  </li>
210
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=unchecked' ); ?>" <?php
211
- if ($show == 'unchecked') { echo 'class="current"'; }
212
  ?>><?php esc_html_e('New', 'gwolle-gb'); ?> <span class="count gwolle_gb_new">(<?php echo $count['unchecked']; ?>)</span></a> |
213
  </li>
214
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=spam' ); ?>" <?php
215
- if ($show == 'spam') { echo 'class="current"'; }
216
  ?>><?php esc_html_e('Spam', 'gwolle-gb'); ?> <span class="count gwolle_gb_spam_">(<?php echo $count['spam']; ?>)</span></a> |
217
  </li>
218
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=trash' ); ?>" <?php
219
- if ($show == 'trash') { echo 'class="current"'; }
220
  ?>><?php /* translators: Is in Trashcan */ esc_html_e('In Trash', 'gwolle-gb'); ?> <span class="count gwolle_gb_trash_">(<?php echo $count['trash']; ?>)</span></a> |
221
  </li>
222
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=user' ); ?>" <?php
223
- if ($show == 'user') { echo 'class="current"'; }
224
  ?>><?php esc_html_e('Author', 'gwolle-gb'); ?></a>
225
  </li>
226
  </ul>
227
 
228
  <div class="tablenav">
229
- <?php if ( $show == 'user' ) {
230
  if ( empty( $user_id ) ) { $user_id = ''; }
231
  if ( empty( $user_email ) ) { $user_email = ''; }
232
  ?>
233
  <h3><?php esc_html_e('Select one option below, either User ID or Email address', 'gwolle-gb'); ?></h3>
234
  <p>
235
  <label for="gwolle_gb_user_id" class="text-info"><?php esc_html_e('User ID', 'gwolle-gb'); ?>:<br />
236
- <input type="text" name="gwolle_gb_user_id" value="<?php echo $user_id; ?>" placeholder="<?php esc_html_e('User ID', 'gwolle-gb'); ?>" />
237
  </label><br />
238
  <label for="gwolle_gb_user_email" class="text-info"><?php esc_html_e('User Email', 'gwolle-gb'); ?>:<br />
239
- <input type="text" name="gwolle_gb_user_email" value="<?php echo $user_email; ?>" placeholder="<?php esc_html_e('User Email', 'gwolle-gb'); ?>" />
240
  </label><br />
241
  <input type="submit" name="gb_search_user" id="gb_search_user" class="button button-primary" value="<?php esc_attr_e('Search entries', 'gwolle-gb'); ?>" />
242
  </p><?php
@@ -244,56 +249,56 @@ function gwolle_gb_page_entries() {
244
 
245
  <div class="alignleft actions">
246
  <?php
247
- $massEditControls_select = '<select name="massEditAction1">';
248
- $massEditControls = '<option value="-1" selected="selected">' . esc_html__('Mass edit actions', 'gwolle-gb') . '</option>';
249
- if ($show == 'trash') {
250
- $massEditControls .= '
251
  <option value="untrash">' . esc_html__('Recover from trash', 'gwolle-gb') . '</option>
252
  <option value="remove">' . esc_html__('Remove permanently', 'gwolle-gb') . '</option>';
253
  } else {
254
- if ($show != 'checked') {
255
- $massEditControls .= '<option value="check">' . esc_html__('Mark as checked', 'gwolle-gb') . '</option>';
256
  }
257
- if ($show != 'unchecked') {
258
- $massEditControls .= '<option value="uncheck">' . esc_html__('Mark as not checked', 'gwolle-gb') . '</option>';
259
  }
260
- if ($show != 'spam') {
261
- $massEditControls .= '<option value="spam">' . esc_html__('Mark as spam', 'gwolle-gb') . '</option>';
262
  }
263
- $massEditControls .= '<option value="no-spam">' . esc_html__('Mark as not spam', 'gwolle-gb') . '</option>';
264
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
265
- $massEditControls .= '<option value="akismet">' . esc_html__('Check with Akismet', 'gwolle-gb') . '</option>';
266
  }
267
- $massEditControls .= '<option value="trash">' . esc_html__('Move to trash', 'gwolle-gb') . '</option>';
268
- if ( $show == 'spam' ) {
269
- $massEditControls .= '<option value="remove">' . esc_html__('Remove permanently', 'gwolle-gb') . '</option>';
270
  }
271
- $massEditControls .= '<option value="anon">' . esc_html__('Anonymize', 'gwolle-gb') . '</option>';
272
 
273
  }
274
- $massEditControls .= '</select>';
275
- $massEditControls .= '<input type="submit" value="' . esc_attr__('Apply', 'gwolle-gb') . '" name="doaction" id="doaction" class="button-secondary action" />';
276
  $empty_button = '';
277
- if ( $show == 'spam' ) {
278
- $empty_button = '<input type="submit" name="delete_all" id="delete_all" class="button apply" value="' . esc_attr__('Empty Spam', 'gwolle-gb') . '" />';
279
- } else if ( $show == 'trash' ) {
280
- $empty_button = '<input type="submit" name="delete_all" id="delete_all" class="button apply" value="' . esc_attr__('Empty Trash', 'gwolle-gb') . '" />';
281
  }
282
 
283
  // Only show controls when there are entries
284
  if ( is_array($entries) && ! empty($entries) ) {
285
- echo $massEditControls_select . $massEditControls . $empty_button;
286
  } ?>
287
  </div>
288
 
289
  <?php
290
- if ( $show == 'user' ) {
291
  echo '<div class="tablenav-pages">
292
  <span class="displaying-num">' . esc_html__('Showing:', 'gwolle-gb') . ' ' . $count_entries . '</span>
293
  </div>';
294
 
295
  } else {
296
- $pagination = gwolle_gb_pagination_admin( $pageNum, $count_entrypages, $count_entries, $show );
297
  echo $pagination;
298
  }
299
  ?>
@@ -339,13 +344,16 @@ function gwolle_gb_page_entries() {
339
  <tbody>
340
  <?php
341
  $request_uri = $_SERVER['REQUEST_URI'];
342
- $rowOdd = true;
343
  $html_output = '';
344
  if ( ! is_array( $entries ) || empty( $entries ) ) {
345
- $colspan = (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') ? 8 : 7;
 
 
 
346
  $html_output .= '
347
  <tr>
348
- <td colspan="' . $colspan . '" align="center">
349
  <strong>' . esc_html__('No entries found.', 'gwolle-gb') . '</strong>
350
  </td>
351
  </tr>';
@@ -353,11 +361,11 @@ function gwolle_gb_page_entries() {
353
  foreach ($entries as $entry) {
354
 
355
  // rows have a different color.
356
- if ($rowOdd) {
357
- $rowOdd = false;
358
  $class = ' alternate';
359
  } else {
360
- $rowOdd = true;
361
  $class = '';
362
  }
363
 
@@ -403,10 +411,10 @@ function gwolle_gb_page_entries() {
403
  <input name="check-' . $entry->get_id() . '" id="check-' . $entry->get_id() . '" type="checkbox">
404
  </td>
405
  <td class="book">
406
- <span class="book-icon" title="' . esc_html__('Book ID', 'gwolle-gb') . ' ' . $entry->get_book_id() . '">
407
  <a href="' . add_query_arg( 'book_id', $entry->get_book_id(), $request_uri ) . '"
408
- title="' . esc_html__('Book ID', 'gwolle-gb') . ' ' . $entry->get_book_id() . '">
409
- ' . $entry->get_book_id() . '
410
  </a>
411
  </span>
412
  </td>
@@ -420,17 +428,17 @@ function gwolle_gb_page_entries() {
420
  if ( get_option('gwolle_gb-showEntryIcons', 'true') === 'true' ) {
421
  $html_output .= '
422
  <td class="entry-icons">
423
- <span class="visible-icon" title="' . esc_html__('Visible', 'gwolle-gb') . '"></span>
424
- <span class="invisible-icon" title="' . esc_html__('Invisible', 'gwolle-gb') . '"></span>
425
- <span class="spam-icon" title="' . esc_html__('Spam', 'gwolle-gb') . '"></span>
426
- <span class="trash-icon" title="' . /* translators: Is in Trashcan */ esc_html__('In Trash', 'gwolle-gb') . '"></span>';
427
  $admin_reply = gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' );
428
  if ( strlen( trim($admin_reply) ) > 0 ) {
429
  $html_output .= '
430
- <span class="admin_reply-icon" title="' . esc_html__('Admin Replied', 'gwolle-gb') . '"></span>';
431
  }
432
  $html_output .= '
433
- <span class="gwolle_gb_ajax" title="' . esc_html__('Wait...', 'gwolle-gb') . '"></span>
434
  </td>';
435
  }
436
 
@@ -499,21 +507,21 @@ function gwolle_gb_page_entries() {
499
  <div class="tablenav">
500
  <div class="alignleft actions">
501
  <?php
502
- $massEditControls_select = '<select name="massEditAction2">';
503
  $empty_button = '';
504
- if ( $show == 'spam' ) {
505
  $empty_button = '<input type="submit" name="delete_all2" id="delete_all2" class="button apply" value="' . esc_attr__('Empty Spam', 'gwolle-gb') . '" />';
506
- } else if ( $show == 'trash' ) {
507
  $empty_button = '<input type="submit" name="delete_all2" id="delete_all2" class="button apply" value="' . esc_attr__('Empty Trash', 'gwolle-gb') . '" />';
508
  }
509
 
510
  // Only show controls when there are entries
511
  if ( is_array($entries) && ! empty($entries) ) {
512
- echo $massEditControls_select . $massEditControls . $empty_button;
513
  } ?>
514
  </div>
515
  <?php
516
- if ( $show != 'user' ) {
517
  echo $pagination;
518
  } ?>
519
  </div>
@@ -533,16 +541,19 @@ function gwolle_gb_page_entries() {
533
  */
534
  function gwolle_gb_page_entries_update() {
535
 
536
- if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
537
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
538
  }
539
 
540
- $show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
 
 
 
541
 
542
  /* Check Nonce */
543
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
544
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_entries' );
545
- if ( $verified == false ) {
546
  // Nonce is invalid, so considered spam.
547
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
548
  return;
@@ -556,15 +567,15 @@ function gwolle_gb_page_entries_update() {
556
  /* Check if we are not sending in more entries than were even listed. */
557
  $entries_checked = 0;
558
  $num_entries = (int) get_option('gwolle_gb-entries_per_page', 20);
559
- foreach( array_keys($_POST) as $postElementName ) {
560
- if (strpos($postElementName, 'check') > -1 && ! strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
561
  $entries_checked++;
562
  }
563
  }
564
  if ( $entries_checked < ( $num_entries + 1 ) ) {
565
- // number of entries checked is less or equal to the number listed on the page.
566
- } else if ( $show == 'user' ) {
567
- // special case for mass edit all entries from user.
568
  } else {
569
  gwolle_gb_add_message( '<p>' . esc_html__('It seems you checked more entries then were even listed on the page.', 'gwolle-gb') . '</p>', true, false);
570
  return;
@@ -572,28 +583,28 @@ function gwolle_gb_page_entries_update() {
572
  /* End of security checks. */
573
 
574
 
575
- if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
576
  $action = '';
577
- if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'check' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'check' ) ) {
578
  $action = 'check';
579
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'uncheck' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'uncheck' ) ) {
580
  $action = 'uncheck';
581
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'spam' ) ) {
582
  $action = 'spam';
583
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'no-spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'no-spam' ) ) {
584
  $action = 'no-spam';
585
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'akismet' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'akismet' ) ) {
586
  $action = 'akismet';
587
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'trash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'trash' ) ) {
588
  $action = 'trash';
589
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'untrash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'untrash' ) ) {
590
  $action = 'untrash';
591
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'remove' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'remove' ) ) {
592
  $action = 'remove';
593
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'anon' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'anon' ) ) {
594
  $action = 'anon';
595
  }
596
- if ( $action == '' && $show != 'user' && ! isset( $_POST['delete_all'] ) && ! isset( $_POST['delete_all2'] ) ) {
597
  gwolle_gb_add_message( '<p>' . esc_html__('Something went wrong. Please try again.', 'gwolle-gb') . '</p>', true, false);
598
  return;
599
  }
@@ -606,17 +617,17 @@ function gwolle_gb_page_entries_update() {
606
  $akismet_already_spam = 0;
607
  $akismet_already_not_spam = 0;
608
 
609
- foreach( array_keys($_POST) as $postElementName ) {
610
- if (strpos($postElementName, 'check') > -1 && ! strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
611
- $entry_id = str_replace('check-','',$postElementName);
612
  $entry_id = (int) $entry_id;
613
  if ( isset($entry_id) && $entry_id > 0 ) {
614
  $entry = new gwolle_gb_entry();
615
  $result = $entry->load( $entry_id );
616
  if ( $result ) {
617
 
618
- if ( $action == 'check' ) {
619
- if ( $entry->get_ischecked() == 0 ) {
620
  $entry->set_ischecked( true );
621
  $user_id = get_current_user_id(); // returns 0 if no current user
622
  $entry->set_checkedby( $user_id );
@@ -632,8 +643,8 @@ function gwolle_gb_page_entries_update() {
632
  } else {
633
  $entries_not_handled++;
634
  }
635
- } else if ( $action == 'uncheck' ) {
636
- if ( $entry->get_ischecked() == 1 ) {
637
  $entry->set_ischecked( false );
638
  $user_id = get_current_user_id(); // returns 0 if no current user
639
  $entry->set_checkedby( $user_id );
@@ -648,11 +659,11 @@ function gwolle_gb_page_entries_update() {
648
  } else {
649
  $entries_not_handled++;
650
  }
651
- } else if ( $action == 'spam' ) {
652
 
653
- if ( $entry->get_isspam() == 0 ) {
654
  $entry->set_isspam( true );
655
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
656
  gwolle_gb_akismet( $entry, 'submit-spam' );
657
  }
658
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
@@ -666,10 +677,10 @@ function gwolle_gb_page_entries_update() {
666
  } else {
667
  $entries_not_handled++;
668
  }
669
- } else if ( $action == 'no-spam' ) {
670
- if ( $entry->get_isspam() == 1 ) {
671
  $entry->set_isspam( false );
672
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
673
  gwolle_gb_akismet( $entry, 'submit-ham' );
674
  }
675
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
@@ -684,13 +695,13 @@ function gwolle_gb_page_entries_update() {
684
  } else {
685
  $entries_not_handled++;
686
  }
687
- } else if ( $action == 'akismet' ) {
688
  /* Check for spam and set accordingly */
689
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
690
  $isspam = gwolle_gb_akismet( $entry, 'comment-check' );
691
  if ( $isspam ) {
692
  // Returned true, so considered spam
693
- if ( $entry->get_isspam() == 0 ) {
694
  $entry->set_isspam( true );
695
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
696
  $result = $entry->save();
@@ -704,7 +715,7 @@ function gwolle_gb_page_entries_update() {
704
  $akismet_already_spam++;
705
  }
706
  } else {
707
- if ( $entry->get_isspam() == 1 ) {
708
  $entry->set_isspam( false );
709
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
710
  $result = $entry->save();
@@ -719,8 +730,8 @@ function gwolle_gb_page_entries_update() {
719
  }
720
  }
721
  }
722
- } else if ( $action == 'trash' ) {
723
- if ( $entry->get_istrash() == 0 ) {
724
  $entry->set_istrash( true );
725
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
726
  $result = $entry->save();
@@ -733,8 +744,8 @@ function gwolle_gb_page_entries_update() {
733
  } else {
734
  $entries_not_handled++;
735
  }
736
- } else if ( $action == 'untrash' ) {
737
- if ( $entry->get_istrash() == 1 ) {
738
  $entry->set_istrash( false );
739
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
740
  $result = $entry->save();
@@ -748,7 +759,7 @@ function gwolle_gb_page_entries_update() {
748
  } else {
749
  $entries_not_handled++;
750
  }
751
- } else if ( $action == 'remove' ) {
752
  $result = $entry->delete();
753
  if ( $result ) {
754
  $entries_handled++;
@@ -756,7 +767,7 @@ function gwolle_gb_page_entries_update() {
756
  } else {
757
  $entries_not_handled++;
758
  }
759
- } else if ( $action == 'anon' ) {
760
  $entry = gwolle_gb_privacy_anonymize_entry( $entry );
761
  $result = $entry->save();
762
  if ( $result ) {
@@ -778,56 +789,55 @@ function gwolle_gb_page_entries_update() {
778
 
779
 
780
  /* Construct Message */
781
- if ( $action == 'check' ) {
782
  /* translators: %s is the number of entries */
783
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry checked.','%s entries checked.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
784
- } else if ( $action == 'uncheck' ) {
785
  /* translators: %s is the number of entries */
786
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry unchecked.','%s entries unchecked.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
787
- } else if ( $action == 'spam' ) {
788
  /* translators: %s is the number of entries */
789
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry marked as spam and submitted to Akismet as spam (if Akismet was enabled).','%s entries marked as spam and submitted to Akismet as spam (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
790
- } else if ( $action == 'no-spam' ) {
791
  /* translators: %s is the number of entries */
792
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry marked as not spam and submitted to Akismet as ham (if Akismet was enabled).','%s entries marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
793
- } else if ( $action == 'akismet' ) {
794
  if ( $akismet_spam > 0 ) {
795
  /* translators: %s is the number of entries */
796
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry considered spam and marked as such.','%s entries considered spam and marked as such.', $akismet_spam, 'gwolle-gb'), $akismet_spam ) . '</p>', false, false);
797
  }
798
  if ( $akismet_not_spam > 0 ) {
799
  /* translators: %s is the number of entries */
800
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry considered not spam and marked as such.','%s entries considered not spam and marked as such.', $akismet_not_spam, 'gwolle-gb'), $akismet_not_spam ) . '</p>', false, false);
801
  }
802
  if ( $akismet_already_spam > 0 ) {
803
  /* translators: %s is the number of entries */
804
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry already considered spam and not changed.','%s entries already considered spam and not changed.', $akismet_already_spam, 'gwolle-gb'), $akismet_already_spam ) . '</p>', false, false);
805
  }
806
  if ( $akismet_already_not_spam > 0 ) {
807
  /* translators: %s is the number of entries */
808
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry already considered not spam and not changed.','%s entries already considered not spam and not changed.', $akismet_already_not_spam, 'gwolle-gb'), $akismet_already_not_spam ) . '</p>', false, false);
809
  }
810
- } else if ( $action == 'trash' ) {
811
  /* translators: %s is the number of entries */
812
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry moved to trash.','%s entries moved to trash.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
813
- } else if ( $action == 'untrash' ) {
814
  /* translators: %s is the number of entries */
815
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry recovered from trash.','%s entries recovered from trash.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
816
- } else if ( $action == 'remove' ) {
817
  /* translators: %s is the number of entries */
818
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
819
- } else if ( $action == 'anon' ) {
820
  /* translators: %s is the number of entries */
821
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry anonymized.','%s entries anonymized.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
822
  }
823
 
824
  if ( isset( $_POST['delete_all'] ) || isset( $_POST['delete_all2'] ) ) {
825
  // Delete all entries in spam or trash.
826
- if ( isset($_POST['show']) && in_array($_POST['show'], array('spam', 'trash')) ) {
827
- $status = $_POST['show'];
828
- $deleted = gwolle_gb_del_entries( $status );
829
  /* translators: %s is the number of entries */
830
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $deleted, 'gwolle-gb'), $deleted ) . '</p>', false, false);
831
  }
832
  }
833
  }
14
  */
15
  function gwolle_gb_page_entries() {
16
 
17
+ if ( ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  gwolle_gb_admin_enqueue();
22
 
23
+ $show = 'all';
24
+ if ( isset($_GET['show']) && in_array($_GET['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ), true ) ) {
25
+ $show = $_GET['show'];
26
+ }
27
 
28
+ if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'entries' ) {
29
  gwolle_gb_page_entries_update();
30
  }
31
  $gwolle_gb_messages = gwolle_gb_get_messages();
36
  }
37
 
38
  // Get entry counts
39
+ $count = array();
40
  $count['checked'] = gwolle_gb_get_entry_count(array(
41
  'checked' => 'checked',
42
  'trash' => 'notrash',
43
+ 'spam' => 'nospam',
44
  ));
45
  $count['unchecked'] = gwolle_gb_get_entry_count(array(
46
  'checked' => 'unchecked',
47
  'trash' => 'notrash',
48
+ 'spam' => 'nospam',
49
  ));
50
  $count['spam'] = gwolle_gb_get_entry_count(array( 'spam' => 'spam' ));
51
  $count['trash'] = gwolle_gb_get_entry_count(array( 'trash'=> 'trash' ));
52
  $count['all'] = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
53
+ $count['user'] = 0; // dummy data, there is no pagination on user tab.
54
 
55
  $num_entries = (int) get_option('gwolle_gb-entries_per_page', 20);
56
 
57
+ $page_num = 1;
58
+ if ( isset($_GET['pageNum']) && (int) $_GET['pageNum'] > 0) {
59
+ $page_num = (int) $_GET['pageNum'];
60
+ }
61
 
62
+ $pages_total = ceil( $count["$show"] / $num_entries );
63
+ if ($page_num > $pages_total) {
64
+ $page_num = 1; // page does not exist, return to first page.
65
  }
66
 
67
  // Calculate query.
68
+ if ($page_num === 1 && $count["$show"] > 0) {
69
  $offset = 0;
70
+ } else if ($count["$show"] === 0) {
71
  $offset = 0;
72
  } else {
73
+ $offset = ( $page_num - 1 ) * $num_entries;
74
  }
75
 
76
  $book_id = 0;
79
  }
80
 
81
  // Get the entries.
82
+ if ( $show === 'checked' ) {
83
  $entries = gwolle_gb_get_entries(array(
84
  'num_entries' => $num_entries,
85
  'offset' => $offset,
86
  'checked' => 'checked',
87
  'trash' => 'notrash',
88
  'spam' => 'nospam',
89
+ 'book_id' => $book_id,
90
  ));
91
  $count_entries = gwolle_gb_get_entry_count(array(
92
  'checked' => 'checked',
93
  'trash' => 'notrash',
94
  'spam' => 'nospam',
95
+ 'book_id' => $book_id,
96
  ));
97
+ } else if ( $show === 'unchecked' ) {
98
  $entries = gwolle_gb_get_entries(array(
99
  'num_entries' => $num_entries,
100
  'offset' => $offset,
101
  'checked' => 'unchecked',
102
  'trash' => 'notrash',
103
  'spam' => 'nospam',
104
+ 'book_id' => $book_id,
105
  ));
106
  $count_entries = gwolle_gb_get_entry_count(array(
107
  'checked' => 'unchecked',
108
  'trash' => 'notrash',
109
  'spam' => 'nospam',
110
+ 'book_id' => $book_id,
111
  ));
112
+ } else if ( $show === 'spam' ) {
113
  $entries = gwolle_gb_get_entries(array(
114
  'num_entries' => $num_entries,
115
  'offset' => $offset,
116
  'spam' => 'spam',
117
+ 'book_id' => $book_id,
118
  ));
119
  $count_entries = gwolle_gb_get_entry_count(array(
120
  'spam' => 'spam',
121
+ 'book_id' => $book_id,
122
  ));
123
+ } else if ( $show === 'trash' ) {
124
  $entries = gwolle_gb_get_entries(array(
125
  'num_entries' => $num_entries,
126
  'offset' => $offset,
127
  'trash' => 'trash',
128
+ 'book_id' => $book_id,
129
  ));
130
  $count_entries = gwolle_gb_get_entry_count(array(
131
  'trash' => 'trash',
132
+ 'book_id' => $book_id,
133
  ));
134
+ } else if ( $show === 'user' ) {
135
  $entries = array();
136
  if ( isset( $_POST['gwolle_gb_user_id']) && ( (int) $_POST['gwolle_gb_user_id'] > 0 ) ) {
137
  $user_id = (int) $_POST['gwolle_gb_user_id'];
138
  $entries = gwolle_gb_get_entries(array(
139
  'author_id' => $user_id,
140
  'num_entries' => -1,
141
+ 'all' => 'all',
142
  ));
143
  } else if ( isset( $_POST['gwolle_gb_user_email']) && strlen($_POST['gwolle_gb_user_email']) > 0 ) {
144
+ $user_email = sanitize_text_field( $_POST['gwolle_gb_user_email'] );
145
  $entries = gwolle_gb_get_entries(array(
146
  'email' => $user_email,
147
  'num_entries' => -1,
148
+ 'all' => 'all',
149
  ));
150
  }
151
  if ( empty( $entries ) ) {
158
  'num_entries' => $num_entries,
159
  'offset' => $offset,
160
  'all' => 'all',
161
+ 'book_id' => $book_id,
162
  ));
163
  $count_entries = gwolle_gb_get_entry_count(array(
164
  'all' => 'all',
165
+ 'book_id' => $book_id,
166
  ));
167
  }
168
  $count_entrypages = ceil( $count_entries / $num_entries );
191
 
192
  <input type="hidden" name="gwolle_gb_page" value="entries" />
193
  <!-- the following fields give us some information used for processing the mass edit -->
194
+ <input type="hidden" name="pageNum" value="<?php echo esc_attr( $page_num ); ?>">
195
+ <input type="hidden" name="entriesOnThisPage" value="<?php echo esc_attr( $entries_on_page ); ?>">
196
+ <input type="hidden" name="show" value="<?php echo esc_attr( $show ); ?>">
197
 
198
  <?php
199
  /* Nonce */
200
  $nonce = wp_create_nonce( 'gwolle_gb_page_entries' );
201
+ echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . esc_attr( $nonce ) . '" />';
202
  ?>
203
 
204
  <ul class="subsubsub">
205
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=all' ); ?>" <?php
206
+ if ($show === 'all') { echo 'class="current"'; }
207
  ?>>
208
  <?php esc_html_e('All', 'gwolle-gb'); ?> <span class="count gwolle_gb_all">(<?php echo $count['all']; ?>)</span></a> |
209
  </li>
210
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=checked' ); ?>" <?php
211
+ if ($show === 'checked') { echo 'class="current"'; }
212
  ?>>
213
  <?php esc_html_e('Unlocked', 'gwolle-gb'); ?> <span class="count gwolle_gb_unlocked">(<?php echo $count['checked']; ?>)</span></a> |
214
  </li>
215
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=unchecked' ); ?>" <?php
216
+ if ($show === 'unchecked') { echo 'class="current"'; }
217
  ?>><?php esc_html_e('New', 'gwolle-gb'); ?> <span class="count gwolle_gb_new">(<?php echo $count['unchecked']; ?>)</span></a> |
218
  </li>
219
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=spam' ); ?>" <?php
220
+ if ($show === 'spam') { echo 'class="current"'; }
221
  ?>><?php esc_html_e('Spam', 'gwolle-gb'); ?> <span class="count gwolle_gb_spam_">(<?php echo $count['spam']; ?>)</span></a> |
222
  </li>
223
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=trash' ); ?>" <?php
224
+ if ($show === 'trash') { echo 'class="current"'; }
225
  ?>><?php /* translators: Is in Trashcan */ esc_html_e('In Trash', 'gwolle-gb'); ?> <span class="count gwolle_gb_trash_">(<?php echo $count['trash']; ?>)</span></a> |
226
  </li>
227
  <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=user' ); ?>" <?php
228
+ if ($show === 'user') { echo 'class="current"'; }
229
  ?>><?php esc_html_e('Author', 'gwolle-gb'); ?></a>
230
  </li>
231
  </ul>
232
 
233
  <div class="tablenav">
234
+ <?php if ( $show === 'user' ) {
235
  if ( empty( $user_id ) ) { $user_id = ''; }
236
  if ( empty( $user_email ) ) { $user_email = ''; }
237
  ?>
238
  <h3><?php esc_html_e('Select one option below, either User ID or Email address', 'gwolle-gb'); ?></h3>
239
  <p>
240
  <label for="gwolle_gb_user_id" class="text-info"><?php esc_html_e('User ID', 'gwolle-gb'); ?>:<br />
241
+ <input type="text" name="gwolle_gb_user_id" value="<?php echo esc_attr( $user_id ); ?>" placeholder="<?php esc_html_e('User ID', 'gwolle-gb'); ?>" />
242
  </label><br />
243
  <label for="gwolle_gb_user_email" class="text-info"><?php esc_html_e('User Email', 'gwolle-gb'); ?>:<br />
244
+ <input type="text" name="gwolle_gb_user_email" value="<?php echo esc_attr( $user_email ); ?>" placeholder="<?php esc_html_e('User Email', 'gwolle-gb'); ?>" />
245
  </label><br />
246
  <input type="submit" name="gb_search_user" id="gb_search_user" class="button button-primary" value="<?php esc_attr_e('Search entries', 'gwolle-gb'); ?>" />
247
  </p><?php
249
 
250
  <div class="alignleft actions">
251
  <?php
252
+ $mass_edit_controls_select = '<select name="massEditAction1">';
253
+ $mass_edit_controls = '<option value="-1" selected="selected">' . esc_html__('Mass edit actions', 'gwolle-gb') . '</option>';
254
+ if ($show === 'trash') {
255
+ $mass_edit_controls .= '
256
  <option value="untrash">' . esc_html__('Recover from trash', 'gwolle-gb') . '</option>
257
  <option value="remove">' . esc_html__('Remove permanently', 'gwolle-gb') . '</option>';
258
  } else {
259
+ if ($show !== 'checked') {
260
+ $mass_edit_controls .= '<option value="check">' . esc_html__('Mark as checked', 'gwolle-gb') . '</option>';
261
  }
262
+ if ($show !== 'unchecked') {
263
+ $mass_edit_controls .= '<option value="uncheck">' . esc_html__('Mark as not checked', 'gwolle-gb') . '</option>';
264
  }
265
+ if ($show !== 'spam') {
266
+ $mass_edit_controls .= '<option value="spam">' . esc_html__('Mark as spam', 'gwolle-gb') . '</option>';
267
  }
268
+ $mass_edit_controls .= '<option value="no-spam">' . esc_html__('Mark as not spam', 'gwolle-gb') . '</option>';
269
+ if ( get_option('gwolle_gb-akismet-active', 'false') === 'true' ) {
270
+ $mass_edit_controls .= '<option value="akismet">' . esc_html__('Check with Akismet', 'gwolle-gb') . '</option>';
271
  }
272
+ $mass_edit_controls .= '<option value="trash">' . esc_html__('Move to trash', 'gwolle-gb') . '</option>';
273
+ if ( $show === 'spam' ) {
274
+ $mass_edit_controls .= '<option value="remove">' . esc_html__('Remove permanently', 'gwolle-gb') . '</option>';
275
  }
276
+ $mass_edit_controls .= '<option value="anon">' . esc_html__('Anonymize', 'gwolle-gb') . '</option>';
277
 
278
  }
279
+ $mass_edit_controls .= '</select>';
280
+ $mass_edit_controls .= '<input type="submit" value="' . esc_attr__('Apply', 'gwolle-gb') . '" name="doaction" id="doaction" class="button-secondary action" />';
281
  $empty_button = '';
282
+ if ( $show === 'spam' ) {
283
+ $empty_button = '<input type="submit" name="delete_all" id="delete_all" class="button apply" value="' . esc_attr__('Empty Spam', 'gwolle-gb') . '" />';
284
+ } else if ( $show === 'trash' ) {
285
+ $empty_button = '<input type="submit" name="delete_all" id="delete_all" class="button apply" value="' . esc_attr__('Empty Trash', 'gwolle-gb') . '" />';
286
  }
287
 
288
  // Only show controls when there are entries
289
  if ( is_array($entries) && ! empty($entries) ) {
290
+ echo $mass_edit_controls_select . $mass_edit_controls . $empty_button;
291
  } ?>
292
  </div>
293
 
294
  <?php
295
+ if ( $show === 'user' ) {
296
  echo '<div class="tablenav-pages">
297
  <span class="displaying-num">' . esc_html__('Showing:', 'gwolle-gb') . ' ' . $count_entries . '</span>
298
  </div>';
299
 
300
  } else {
301
+ $pagination = gwolle_gb_pagination_admin( $page_num, $count_entrypages, $count_entries, $show );
302
  echo $pagination;
303
  }
304
  ?>
344
  <tbody>
345
  <?php
346
  $request_uri = $_SERVER['REQUEST_URI'];
347
+ $row_odd = true;
348
  $html_output = '';
349
  if ( ! is_array( $entries ) || empty( $entries ) ) {
350
+ $colspan = 7;
351
+ if ( get_option('gwolle_gb-showEntryIcons', 'true') === 'true') {
352
+ $colspan = 8;
353
+ }
354
  $html_output .= '
355
  <tr>
356
+ <td colspan="' . esc_attr( $colspan ) . '" align="center">
357
  <strong>' . esc_html__('No entries found.', 'gwolle-gb') . '</strong>
358
  </td>
359
  </tr>';
361
  foreach ($entries as $entry) {
362
 
363
  // rows have a different color.
364
+ if ($row_odd) {
365
+ $row_odd = false;
366
  $class = ' alternate';
367
  } else {
368
+ $row_odd = true;
369
  $class = '';
370
  }
371
 
411
  <input name="check-' . $entry->get_id() . '" id="check-' . $entry->get_id() . '" type="checkbox">
412
  </td>
413
  <td class="book">
414
+ <span class="book-icon" title="' . esc_html__('Book ID', 'gwolle-gb') . ' ' . $entry->get_book_id() . '">
415
  <a href="' . add_query_arg( 'book_id', $entry->get_book_id(), $request_uri ) . '"
416
+ title="' . esc_attr__('Book ID', 'gwolle-gb') . ' ' . $entry->get_book_id() . '">
417
+ ' . $entry->get_book_id() . '
418
  </a>
419
  </span>
420
  </td>
428
  if ( get_option('gwolle_gb-showEntryIcons', 'true') === 'true' ) {
429
  $html_output .= '
430
  <td class="entry-icons">
431
+ <span class="visible-icon" title="' . esc_attr__('Visible', 'gwolle-gb') . '"></span>
432
+ <span class="invisible-icon" title="' . esc_attr__('Invisible', 'gwolle-gb') . '"></span>
433
+ <span class="spam-icon" title="' . esc_attr__('Spam', 'gwolle-gb') . '"></span>
434
+ <span class="trash-icon" title="' . /* translators: Is in Trashcan */ esc_attr__('In Trash', 'gwolle-gb') . '"></span>';
435
  $admin_reply = gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' );
436
  if ( strlen( trim($admin_reply) ) > 0 ) {
437
  $html_output .= '
438
+ <span class="admin_reply-icon" title="' . esc_attr__('Admin Replied', 'gwolle-gb') . '"></span>';
439
  }
440
  $html_output .= '
441
+ <span class="gwolle_gb_ajax" title="' . esc_attr__('Wait...', 'gwolle-gb') . '"></span>
442
  </td>';
443
  }
444
 
507
  <div class="tablenav">
508
  <div class="alignleft actions">
509
  <?php
510
+ $mass_edit_controls_select = '<select name="massEditAction2">';
511
  $empty_button = '';
512
+ if ( $show === 'spam' ) {
513
  $empty_button = '<input type="submit" name="delete_all2" id="delete_all2" class="button apply" value="' . esc_attr__('Empty Spam', 'gwolle-gb') . '" />';
514
+ } else if ( $show === 'trash' ) {
515
  $empty_button = '<input type="submit" name="delete_all2" id="delete_all2" class="button apply" value="' . esc_attr__('Empty Trash', 'gwolle-gb') . '" />';
516
  }
517
 
518
  // Only show controls when there are entries
519
  if ( is_array($entries) && ! empty($entries) ) {
520
+ echo $mass_edit_controls_select . $mass_edit_controls . $empty_button;
521
  } ?>
522
  </div>
523
  <?php
524
+ if ( $show !== 'user' ) {
525
  echo $pagination;
526
  } ?>
527
  </div>
541
  */
542
  function gwolle_gb_page_entries_update() {
543
 
544
+ if ( ! current_user_can('moderate_comments') ) {
545
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
546
  }
547
 
548
+ $show = 'all';
549
+ if ( isset($_GET['show']) && in_array($_GET['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ), true ) ) {
550
+ $show = $_GET['show'];
551
+ }
552
 
553
  /* Check Nonce */
554
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
555
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_entries' );
556
+ if ( $verified === false ) {
557
  // Nonce is invalid, so considered spam.
558
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
559
  return;
567
  /* Check if we are not sending in more entries than were even listed. */
568
  $entries_checked = 0;
569
  $num_entries = (int) get_option('gwolle_gb-entries_per_page', 20);
570
+ foreach ( array_keys($_POST) as $post_element_name ) {
571
+ if (strpos($post_element_name, 'check') > -1 && ! strpos($post_element_name, '-all-') && $_POST["$post_element_name"] === 'on') {
572
  $entries_checked++;
573
  }
574
  }
575
  if ( $entries_checked < ( $num_entries + 1 ) ) {
576
+ // OK: number of entries checked is less or equal to the number listed on the page.
577
+ } else if ( $show === 'user' ) {
578
+ // OK: special case for mass edit all entries from user.
579
  } else {
580
  gwolle_gb_add_message( '<p>' . esc_html__('It seems you checked more entries then were even listed on the page.', 'gwolle-gb') . '</p>', true, false);
581
  return;
583
  /* End of security checks. */
584
 
585
 
586
+ if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'entries' ) {
587
  $action = '';
588
+ if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'check' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'check' ) ) {
589
  $action = 'check';
590
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'uncheck' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'uncheck' ) ) {
591
  $action = 'uncheck';
592
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'spam' ) ) {
593
  $action = 'spam';
594
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'no-spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'no-spam' ) ) {
595
  $action = 'no-spam';
596
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'akismet' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'akismet' ) ) {
597
  $action = 'akismet';
598
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'trash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'trash' ) ) {
599
  $action = 'trash';
600
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'untrash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'untrash' ) ) {
601
  $action = 'untrash';
602
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'remove' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'remove' ) ) {
603
  $action = 'remove';
604
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] === 'anon' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] === 'anon' ) ) {
605
  $action = 'anon';
606
  }
607
+ if ( $action === '' && $show !== 'user' && ! isset( $_POST['delete_all'] ) && ! isset( $_POST['delete_all2'] ) ) {
608
  gwolle_gb_add_message( '<p>' . esc_html__('Something went wrong. Please try again.', 'gwolle-gb') . '</p>', true, false);
609
  return;
610
  }
617
  $akismet_already_spam = 0;
618
  $akismet_already_not_spam = 0;
619
 
620
+ foreach ( array_keys($_POST) as $post_element_name ) {
621
+ if (strpos($post_element_name, 'check') > -1 && ! strpos($post_element_name, '-all-') && $_POST["$post_element_name"] === 'on') {
622
+ $entry_id = str_replace('check-', '', $post_element_name);
623
  $entry_id = (int) $entry_id;
624
  if ( isset($entry_id) && $entry_id > 0 ) {
625
  $entry = new gwolle_gb_entry();
626
  $result = $entry->load( $entry_id );
627
  if ( $result ) {
628
 
629
+ if ( $action === 'check' ) {
630
+ if ( $entry->get_ischecked() === 0 ) {
631
  $entry->set_ischecked( true );
632
  $user_id = get_current_user_id(); // returns 0 if no current user
633
  $entry->set_checkedby( $user_id );
643
  } else {
644
  $entries_not_handled++;
645
  }
646
+ } else if ( $action === 'uncheck' ) {
647
+ if ( $entry->get_ischecked() === 1 ) {
648
  $entry->set_ischecked( false );
649
  $user_id = get_current_user_id(); // returns 0 if no current user
650
  $entry->set_checkedby( $user_id );
659
  } else {
660
  $entries_not_handled++;
661
  }
662
+ } else if ( $action === 'spam' ) {
663
 
664
+ if ( $entry->get_isspam() === 0 ) {
665
  $entry->set_isspam( true );
666
+ if ( get_option('gwolle_gb-akismet-active', 'false') === 'true' ) {
667
  gwolle_gb_akismet( $entry, 'submit-spam' );
668
  }
669
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
677
  } else {
678
  $entries_not_handled++;
679
  }
680
+ } else if ( $action === 'no-spam' ) {
681
+ if ( $entry->get_isspam() === 1 ) {
682
  $entry->set_isspam( false );
683
+ if ( get_option('gwolle_gb-akismet-active', 'false') === 'true' ) {
684
  gwolle_gb_akismet( $entry, 'submit-ham' );
685
  }
686
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
695
  } else {
696
  $entries_not_handled++;
697
  }
698
+ } else if ( $action === 'akismet' ) {
699
  /* Check for spam and set accordingly */
700
+ if ( get_option('gwolle_gb-akismet-active', 'false') === 'true' ) {
701
  $isspam = gwolle_gb_akismet( $entry, 'comment-check' );
702
  if ( $isspam ) {
703
  // Returned true, so considered spam
704
+ if ( $entry->get_isspam() === 0 ) {
705
  $entry->set_isspam( true );
706
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
707
  $result = $entry->save();
715
  $akismet_already_spam++;
716
  }
717
  } else {
718
+ if ( $entry->get_isspam() === 1 ) {
719
  $entry->set_isspam( false );
720
  gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
721
  $result = $entry->save();
730
  }
731
  }
732
  }
733
+ } else if ( $action === 'trash' ) {
734
+ if ( $entry->get_istrash() === 0 ) {
735
  $entry->set_istrash( true );
736
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
737
  $result = $entry->save();
744
  } else {
745
  $entries_not_handled++;
746
  }
747
+ } else if ( $action === 'untrash' ) {
748
+ if ( $entry->get_istrash() === 1 ) {
749
  $entry->set_istrash( false );
750
  gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
751
  $result = $entry->save();
759
  } else {
760
  $entries_not_handled++;
761
  }
762
+ } else if ( $action === 'remove' ) {
763
  $result = $entry->delete();
764
  if ( $result ) {
765
  $entries_handled++;
767
  } else {
768
  $entries_not_handled++;
769
  }
770
+ } else if ( $action === 'anon' ) {
771
  $entry = gwolle_gb_privacy_anonymize_entry( $entry );
772
  $result = $entry->save();
773
  if ( $result ) {
789
 
790
 
791
  /* Construct Message */
792
+ if ( $action === 'check' ) {
793
  /* translators: %s is the number of entries */
794
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry checked.', '%s entries checked.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
795
+ } else if ( $action === 'uncheck' ) {
796
  /* translators: %s is the number of entries */
797
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry unchecked.', '%s entries unchecked.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
798
+ } else if ( $action === 'spam' ) {
799
  /* translators: %s is the number of entries */
800
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry marked as spam and submitted to Akismet as spam (if Akismet was enabled).', '%s entries marked as spam and submitted to Akismet as spam (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
801
+ } else if ( $action === 'no-spam' ) {
802
  /* translators: %s is the number of entries */
803
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', '%s entries marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
804
+ } else if ( $action === 'akismet' ) {
805
  if ( $akismet_spam > 0 ) {
806
  /* translators: %s is the number of entries */
807
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry considered spam and marked as such.', '%s entries considered spam and marked as such.', $akismet_spam, 'gwolle-gb'), $akismet_spam ) . '</p>', false, false);
808
  }
809
  if ( $akismet_not_spam > 0 ) {
810
  /* translators: %s is the number of entries */
811
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry considered not spam and marked as such.', '%s entries considered not spam and marked as such.', $akismet_not_spam, 'gwolle-gb'), $akismet_not_spam ) . '</p>', false, false);
812
  }
813
  if ( $akismet_already_spam > 0 ) {
814
  /* translators: %s is the number of entries */
815
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry already considered spam and not changed.', '%s entries already considered spam and not changed.', $akismet_already_spam, 'gwolle-gb'), $akismet_already_spam ) . '</p>', false, false);
816
  }
817
  if ( $akismet_already_not_spam > 0 ) {
818
  /* translators: %s is the number of entries */
819
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry already considered not spam and not changed.', '%s entries already considered not spam and not changed.', $akismet_already_not_spam, 'gwolle-gb'), $akismet_already_not_spam ) . '</p>', false, false);
820
  }
821
+ } else if ( $action === 'trash' ) {
822
  /* translators: %s is the number of entries */
823
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry moved to trash.', '%s entries moved to trash.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
824
+ } else if ( $action === 'untrash' ) {
825
  /* translators: %s is the number of entries */
826
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry recovered from trash.', '%s entries recovered from trash.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
827
+ } else if ( $action === 'remove' ) {
828
  /* translators: %s is the number of entries */
829
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry removed permanently.', '%s entries removed permanently.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
830
+ } else if ( $action === 'anon' ) {
831
  /* translators: %s is the number of entries */
832
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry anonymized.', '%s entries anonymized.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
833
  }
834
 
835
  if ( isset( $_POST['delete_all'] ) || isset( $_POST['delete_all2'] ) ) {
836
  // Delete all entries in spam or trash.
837
+ if ( in_array( $show, array( 'spam', 'trash' ), true ) ) {
838
+ $deleted = gwolle_gb_del_entries( $show );
 
839
  /* translators: %s is the number of entries */
840
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry removed permanently.', '%s entries removed permanently.', $deleted, 'gwolle-gb'), $deleted ) . '</p>', false, false);
841
  }
842
  }
843
  }
admin/gb-page-export.php CHANGED
@@ -16,7 +16,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
16
  */
17
  function gwolle_gb_page_export() {
18
 
19
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
20
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
21
  }
22
 
@@ -33,8 +33,8 @@ function gwolle_gb_page_export() {
33
  <div id="poststuff" class="gwolle_gb_export metabox-holder">
34
  <div class="postbox-container">
35
  <?php
36
- add_meta_box('gwolle_gb_export_postbox', esc_html__('Export guestbook entries from Gwolle-GB','gwolle-gb'), 'gwolle_gb_export_postbox', 'gwolle_gb_export', 'normal');
37
- add_meta_box('gwolle_gb_export_postbox_user', esc_html__('Export guestbook entries for a user','gwolle-gb'), 'gwolle_gb_export_postbox_user', 'gwolle_gb_export', 'normal');
38
  do_meta_boxes( 'gwolle_gb_export', 'normal', '' );
39
  ?>
40
  </div>
@@ -47,7 +47,7 @@ function gwolle_gb_page_export() {
47
 
48
  function gwolle_gb_export_postbox() {
49
 
50
- $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
51
  $num_entries = 2000;
52
  $parts = ceil( $count / $num_entries );
53
  ?>
@@ -55,14 +55,14 @@ function gwolle_gb_export_postbox() {
55
  <form name="gwolle_gb_export" id="gwolle_gb_export" method="POST" action="#" accept-charset="UTF-8">
56
  <input type="hidden" name="gwolle_gb_page" value="gwolle_gb_export" />
57
  <input type="hidden" name="gwolle_gb_export_part" id="gwolle_gb_export_part" value="1" />
58
- <input type="hidden" name="gwolle_gb_export_parts" id="gwolle_gb_export_parts" value="<?php echo $parts; ?>" />
59
 
60
  <?php
61
  /* Nonce */
62
  $nonce = wp_create_nonce( 'gwolle_gb_page_export' );
63
- echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
64
 
65
- if ( $count == 0 ) { ?>
66
  <p><?php esc_html_e('No entries were found.', 'gwolle-gb'); ?></p><?php
67
  } else {
68
  ?>
@@ -110,7 +110,7 @@ function gwolle_gb_export_postbox() {
110
 
111
  function gwolle_gb_export_action() {
112
  if ( is_admin() ) {
113
- if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'gwolle_gb_export' ) {
114
  gwolle_gb_export_callback();
115
  }
116
  }
@@ -123,7 +123,7 @@ add_action('admin_init', 'gwolle_gb_export_action');
123
  */
124
  function gwolle_gb_export_callback() {
125
 
126
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
127
  echo 'error, no permission.';
128
  die();
129
  }
@@ -133,27 +133,27 @@ function gwolle_gb_export_callback() {
133
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
134
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_export' );
135
  }
136
- if ( $verified == false ) {
137
  // Nonce is invalid.
138
  esc_html_e('Nonce check failed. Please go back and try again.', 'gwolle-gb');
139
  die();
140
  }
141
 
142
- $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
143
  $num_entries = 2000;
144
  $parts = ceil( $count / $num_entries );
145
- if ( isset( $_POST['gwolle_gb_export_part']) && ( (int) $_POST['gwolle_gb_export_part'] < ($parts + 1) ) ) {
146
  $part = (int) $_POST['gwolle_gb_export_part'];
147
  } else {
148
  echo '(Gwolle-GB) Wrong part requested.';
149
  die();
150
  }
151
- $offset = ($part * $num_entries) - $num_entries;
152
 
153
- $entries = gwolle_gb_get_entries(array(
154
  'num_entries' => $num_entries,
155
  'offset' => $offset,
156
- 'all' => 'all'
157
  ));
158
 
159
  if ( is_array($entries) && ! empty($entries) ) {
@@ -164,7 +164,7 @@ function gwolle_gb_export_callback() {
164
  // Output headers so that the file is downloaded rather than displayed
165
  $filename = 'gwolle_gb_export_' . GWOLLE_GB_VER . '_' . date('Y-m-d_H-i') . '-part_' . $part . '_of_' . $parts . '.csv';
166
  header( 'Content-Type: text/csv; charset=utf-8' );
167
- header( 'Content-Disposition: attachment; filename=' . $filename );
168
 
169
  // Create a file pointer connected to the output stream
170
  $output = fopen('php://output', 'w');
@@ -185,12 +185,12 @@ function gwolle_gb_export_callback() {
185
  'istrash',
186
  'admin_reply',
187
  'book_id',
188
- 'meta_fields'
189
  ));
190
 
191
  foreach ( $entries as $entry ) {
192
 
193
- $row = Array();
194
 
195
  $row[] = $entry->get_id();
196
  $row[] = addslashes($entry->get_author_name());
@@ -243,20 +243,20 @@ function gwolle_gb_export_postbox_user() {
243
  <?php
244
  /* Nonce */
245
  $nonce = wp_create_nonce( 'gwolle_gb_page_export_user' );
246
- echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
247
 
248
  $count = gwolle_gb_get_entry_count( array( 'all' => 'all' ) );
249
- if ( $count == 0 ) { ?>
250
  <p><?php esc_html_e('No entries were found.', 'gwolle-gb'); ?></p><?php
251
  } else {
252
  ?>
253
  <p><?php esc_html_e('Select one option below, either User ID or Email address', 'gwolle-gb'); ?></p>
254
  <p>
255
  <label for="gwolle_gb_user_id" class="text-info"><?php esc_html_e('User ID', 'gwolle-gb'); ?>:<br />
256
- <input type="text" name="gwolle_gb_user_id" id="gwolle_gb_user_id" value="" placeholder="<?php esc_html_e('User ID', 'gwolle-gb'); ?>" />
257
  </label><br />
258
  <label for="gwolle_gb_user_email" class="text-info"><?php esc_html_e('User Email', 'gwolle-gb'); ?>:<br />
259
- <input type="text" name="gwolle_gb_user_email" id="gwolle_gb_user_email" value="" placeholder="<?php esc_html_e('User Email', 'gwolle-gb'); ?>" />
260
  </label>
261
  </p>
262
 
@@ -275,7 +275,7 @@ function gwolle_gb_export_postbox_user() {
275
 
276
  function gwolle_gb_export_user_action() {
277
  if ( is_admin() ) {
278
- if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'gwolle_gb_export_user' ) {
279
  gwolle_gb_export_user_callback();
280
  }
281
  }
@@ -288,7 +288,7 @@ add_action('admin_init', 'gwolle_gb_export_user_action');
288
  */
289
  function gwolle_gb_export_user_callback() {
290
 
291
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
292
  echo 'error, no permission.';
293
  die();
294
  }
@@ -298,7 +298,7 @@ function gwolle_gb_export_user_callback() {
298
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
299
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_export_user' );
300
  }
301
- if ( $verified == false ) {
302
  // Nonce is invalid.
303
  esc_html_e('Nonce check failed. Please go back and try again.', 'gwolle-gb');
304
  die();
@@ -309,14 +309,14 @@ function gwolle_gb_export_user_callback() {
309
  $entries = gwolle_gb_get_entries(array(
310
  'author_id' => $user_id,
311
  'num_entries' => -1,
312
- 'all' => 'all'
313
  ));
314
  } else if ( isset( $_POST['gwolle_gb_user_email']) && strlen($_POST['gwolle_gb_user_email']) > 0 ) {
315
- $user_id = $_POST['gwolle_gb_user_email'];
316
  $entries = gwolle_gb_get_entries(array(
317
  'email' => $user_id,
318
  'num_entries' => -1,
319
- 'all' => 'all'
320
  ));
321
  }
322
 
@@ -349,12 +349,12 @@ function gwolle_gb_export_user_callback() {
349
  'istrash',
350
  'admin_reply',
351
  'book_id',
352
- 'meta_fields'
353
  ));
354
 
355
  foreach ( $entries as $entry ) {
356
 
357
- $row = Array();
358
 
359
  $row[] = $entry->get_id();
360
  $row[] = addslashes($entry->get_author_name());
16
  */
17
  function gwolle_gb_page_export() {
18
 
19
+ if ( ! current_user_can('manage_options') ) {
20
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
21
  }
22
 
33
  <div id="poststuff" class="gwolle_gb_export metabox-holder">
34
  <div class="postbox-container">
35
  <?php
36
+ add_meta_box( 'gwolle_gb_export_postbox', esc_html__('Export guestbook entries from Gwolle-GB', 'gwolle-gb'), 'gwolle_gb_export_postbox', 'gwolle_gb_export', 'normal' );
37
+ add_meta_box( 'gwolle_gb_export_postbox_user', esc_html__('Export guestbook entries for a user', 'gwolle-gb'), 'gwolle_gb_export_postbox_user', 'gwolle_gb_export', 'normal' );
38
  do_meta_boxes( 'gwolle_gb_export', 'normal', '' );
39
  ?>
40
  </div>
47
 
48
  function gwolle_gb_export_postbox() {
49
 
50
+ $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
51
  $num_entries = 2000;
52
  $parts = ceil( $count / $num_entries );
53
  ?>
55
  <form name="gwolle_gb_export" id="gwolle_gb_export" method="POST" action="#" accept-charset="UTF-8">
56
  <input type="hidden" name="gwolle_gb_page" value="gwolle_gb_export" />
57
  <input type="hidden" name="gwolle_gb_export_part" id="gwolle_gb_export_part" value="1" />
58
+ <input type="hidden" name="gwolle_gb_export_parts" id="gwolle_gb_export_parts" value="<?php echo esc_attr( $parts ); ?>" />
59
 
60
  <?php
61
  /* Nonce */
62
  $nonce = wp_create_nonce( 'gwolle_gb_page_export' );
63
+ echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . esc_attr( $nonce ) . '" />';
64
 
65
+ if ( $count === 0 ) { ?>
66
  <p><?php esc_html_e('No entries were found.', 'gwolle-gb'); ?></p><?php
67
  } else {
68
  ?>
110
 
111
  function gwolle_gb_export_action() {
112
  if ( is_admin() ) {
113
+ if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'gwolle_gb_export' ) {
114
  gwolle_gb_export_callback();
115
  }
116
  }
123
  */
124
  function gwolle_gb_export_callback() {
125
 
126
+ if ( ! current_user_can('manage_options') ) {
127
  echo 'error, no permission.';
128
  die();
129
  }
133
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
134
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_export' );
135
  }
136
+ if ( $verified === false ) {
137
  // Nonce is invalid.
138
  esc_html_e('Nonce check failed. Please go back and try again.', 'gwolle-gb');
139
  die();
140
  }
141
 
142
+ $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
143
  $num_entries = 2000;
144
  $parts = ceil( $count / $num_entries );
145
+ if ( isset( $_POST['gwolle_gb_export_part'] ) && ( (int) $_POST['gwolle_gb_export_part'] < ( $parts + 1 ) ) ) {
146
  $part = (int) $_POST['gwolle_gb_export_part'];
147
  } else {
148
  echo '(Gwolle-GB) Wrong part requested.';
149
  die();
150
  }
151
+ $offset = ( $part * $num_entries ) - $num_entries;
152
 
153
+ $entries = gwolle_gb_get_entries( array(
154
  'num_entries' => $num_entries,
155
  'offset' => $offset,
156
+ 'all' => 'all',
157
  ));
158
 
159
  if ( is_array($entries) && ! empty($entries) ) {
164
  // Output headers so that the file is downloaded rather than displayed
165
  $filename = 'gwolle_gb_export_' . GWOLLE_GB_VER . '_' . date('Y-m-d_H-i') . '-part_' . $part . '_of_' . $parts . '.csv';
166
  header( 'Content-Type: text/csv; charset=utf-8' );
167
+ header( 'Content-Disposition: attachment; filename=' . esc_attr( $filename ) );
168
 
169
  // Create a file pointer connected to the output stream
170
  $output = fopen('php://output', 'w');
185
  'istrash',
186
  'admin_reply',
187
  'book_id',
188
+ 'meta_fields',
189
  ));
190
 
191
  foreach ( $entries as $entry ) {
192
 
193
+ $row = array();
194
 
195
  $row[] = $entry->get_id();
196
  $row[] = addslashes($entry->get_author_name());
243
  <?php
244
  /* Nonce */
245
  $nonce = wp_create_nonce( 'gwolle_gb_page_export_user' );
246
+ echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . esc_attr( $nonce ) . '" />';
247
 
248
  $count = gwolle_gb_get_entry_count( array( 'all' => 'all' ) );
249
+ if ( $count === 0 ) { ?>
250
  <p><?php esc_html_e('No entries were found.', 'gwolle-gb'); ?></p><?php
251
  } else {
252
  ?>
253
  <p><?php esc_html_e('Select one option below, either User ID or Email address', 'gwolle-gb'); ?></p>
254
  <p>
255
  <label for="gwolle_gb_user_id" class="text-info"><?php esc_html_e('User ID', 'gwolle-gb'); ?>:<br />
256
+ <input type="text" name="gwolle_gb_user_id" id="gwolle_gb_user_id" value="" placeholder="<?php esc_attr_e('User ID', 'gwolle-gb'); ?>" />
257
  </label><br />
258
  <label for="gwolle_gb_user_email" class="text-info"><?php esc_html_e('User Email', 'gwolle-gb'); ?>:<br />
259
+ <input type="text" name="gwolle_gb_user_email" id="gwolle_gb_user_email" value="" placeholder="<?php esc_attr_e('User Email', 'gwolle-gb'); ?>" />
260
  </label>
261
  </p>
262
 
275
 
276
  function gwolle_gb_export_user_action() {
277
  if ( is_admin() ) {
278
+ if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'gwolle_gb_export_user' ) {
279
  gwolle_gb_export_user_callback();
280
  }
281
  }
288
  */
289
  function gwolle_gb_export_user_callback() {
290
 
291
+ if ( ! current_user_can('manage_options') ) {
292
  echo 'error, no permission.';
293
  die();
294
  }
298
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
299
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_export_user' );
300
  }
301
+ if ( $verified === false ) {
302
  // Nonce is invalid.
303
  esc_html_e('Nonce check failed. Please go back and try again.', 'gwolle-gb');
304
  die();
309
  $entries = gwolle_gb_get_entries(array(
310
  'author_id' => $user_id,
311
  'num_entries' => -1,
312
+ 'all' => 'all',
313
  ));
314
  } else if ( isset( $_POST['gwolle_gb_user_email']) && strlen($_POST['gwolle_gb_user_email']) > 0 ) {
315
+ $user_id = sanitize_text_field( $_POST['gwolle_gb_user_email'] );
316
  $entries = gwolle_gb_get_entries(array(
317
  'email' => $user_id,
318
  'num_entries' => -1,
319
+ 'all' => 'all',