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',
320
  ));
321
  }
322
 
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());
admin/gb-page-gwolle-gb.php CHANGED
@@ -14,21 +14,21 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_welcome() {
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
  /* Post Handling: Save notification setting */
22
- if ( isset( $_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options' ) {
23
  gwolle_gb_welcome_post();
24
  }
25
 
26
  gwolle_gb_admin_enqueue();
27
 
28
- add_meta_box('gwolle_gb_right_now', esc_html__('Welcome to the Guestbook!','gwolle-gb'), 'gwolle_gb_overview', 'gwolle_gb_welcome', 'normal');
29
  add_meta_box('gwolle_gb_visibility', esc_html__('Visibility', 'gwolle-gb'), 'gwolle_gb_overview_visibility', 'gwolle_gb_welcome', 'normal');
30
  add_meta_box('gwolle_gb_notification', esc_html__('E-mail Notifications', 'gwolle-gb'), 'gwolle_gb_overview_notification', 'gwolle_gb_welcome', 'normal');
31
- add_meta_box('gwolle_gb_thanks', esc_html__('Third Party','gwolle-gb'), 'gwolle_gb_overview_thanks', 'gwolle_gb_welcome', 'normal');
32
 
33
  add_meta_box('gwolle_gb_help', esc_html__('Help', 'gwolle-gb'), 'gwolle_gb_overview_help', 'gwolle_gb_welcome', 'right');
34
  add_meta_box('gwolle_gb_support', esc_html__('Support and Translations', 'gwolle-gb'), 'gwolle_gb_overview_support', 'gwolle_gb_welcome', 'right');
@@ -42,10 +42,10 @@ function gwolle_gb_welcome() {
42
  <div id="icon-gwolle-gb"><br /></div>
43
  <?php
44
  $heading = esc_html__('Gwolle Guestbook', 'gwolle-gb');
45
- if ( $heading != 'Gwolle Guestbook' ) { // translated, so we add the real name.
46
  $heading .= ' (Gwolle Guestbook)';
47
  } ?>
48
- <h1><?php echo $heading . ' - v' . GWOLLE_GB_VER; ?></h1>
49
 
50
  <?php
51
  $gwolle_gb_messages = gwolle_gb_get_messages();
@@ -57,7 +57,7 @@ function gwolle_gb_welcome() {
57
 
58
  if ( $gwolle_gb_messages ) {
59
  echo '
60
- <div id="message" class="updated fade notice is-dismissible ' . $messageclass . ' ">' .
61
  $gwolle_gb_messages .
62
  '</div>';
63
  } ?>
@@ -80,27 +80,27 @@ function gwolle_gb_welcome() {
80
  /*
81
  * Metabox with overview.
82
  */
83
- function gwolle_gb_overview(){
84
 
85
  // Calculate the number of entries
86
- $count = Array();
87
- $count['checked'] = gwolle_gb_get_entry_count(array(
88
  'checked' => 'checked',
89
  'trash' => 'notrash',
90
- 'spam' => 'nospam'
91
  ));
92
- $count['unchecked'] = gwolle_gb_get_entry_count(array(
93
  'checked' => 'unchecked',
94
  'trash' => 'notrash',
95
- 'spam' => 'nospam'
96
  ));
97
- $count['spam'] = gwolle_gb_get_entry_count(array( 'spam' => 'spam' ));
98
- $count['trash'] = gwolle_gb_get_entry_count(array( 'trash' => 'trash' ));
99
- $count['all'] = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
100
  ?>
101
 
102
  <div class="table table_content gwolle_gb gwolle-gb-overview">
103
- <h3><?php esc_html_e('Overview','gwolle-gb'); ?></h3>
104
 
105
  <table>
106
  <tbody>
@@ -165,10 +165,10 @@ function gwolle_gb_overview(){
165
  if ( $postid ) {
166
  $permalink = gwolle_gb_get_permalink( $postid );
167
  ?>
168
- <a class="button rbutton button button-primary" href="<?php echo $permalink; ?>"><?php esc_html_e('View Guestbook','gwolle-gb'); ?></a>
169
  <?php
170
  } ?>
171
- <a class="button rbutton button button-primary" href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php' ); ?>"><?php esc_html_e('Write admin entry','gwolle-gb'); ?></a>
172
  </p>
173
  <p>
174
  <?php
@@ -197,17 +197,17 @@ function gwolle_gb_overview_notification() {
197
  if ( ! function_exists('mail') ) {
198
  /* translators: %s is for the code element */
199
  echo '<p class="setting-description">' .
200
- sprintf( esc_html__('Sorry, but the function %smail()%s required to notify you by mail is not enabled in your PHP configuration. You might want to install a WordPress plugin that uses SMTP instead of %smail()%s. Or you can contact your hosting provider.','gwolle-gb'), '<code>', '</code>', '<code>', '</code>' )
201
  . '</p>';
202
  }
203
- $current_user_id = get_current_user_id();;
204
- $currentUserNotification = false;
205
  $user_ids = get_option('gwolle_gb-notifyByMail' );
206
  if ( strlen($user_ids) > 0 ) {
207
- $user_ids = explode( ",", $user_ids );
208
- if ( is_array($user_ids) && !empty($user_ids) ) {
209
  if ( in_array( $current_user_id, $user_ids ) ) {
210
- $currentUserNotification = true;
211
  }
212
  }
213
  } ?>
@@ -218,10 +218,10 @@ function gwolle_gb_overview_notification() {
218
 
219
  /* Nonce */
220
  $nonce = wp_create_nonce( 'gwolle_gb_page_gwolle' );
221
- echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
222
  ?>
223
  <input name="notify_by_mail" type="checkbox" id="notify_by_mail" <?php
224
- if ( $currentUserNotification ) {
225
  echo 'checked="checked"';
226
  } ?> >
227
  <label for="notify_by_mail" class="setting-description"><?php esc_html_e('Send me an e-mail when a new entry has been posted.', 'gwolle-gb'); ?></label>
@@ -241,12 +241,12 @@ function gwolle_gb_overview_notification() {
241
  continue;
242
  }
243
  echo '<li>';
244
- if ( $user_info->ID == get_current_user_id() ) {
245
  echo '<strong>' . esc_html__('You', 'gwolle-gb') . '</strong>';
246
  } else {
247
- echo $user_info->first_name . ' ' . $user_info->last_name;
248
  }
249
- echo ' (' . $user_info->user_email . ')';
250
  echo '</li>';
251
  }
252
  echo '</ul>';
@@ -290,11 +290,11 @@ function gwolle_gb_overview_help() {
290
  * Metabox with quick help text.
291
  */
292
  function gwolle_gb_overview_visibility() {
293
- echo '<h3>' . esc_html__('These entries will be visible for your visitors:', 'gwolle-gb').'</h3>
294
  <ul class="ul-disc">
295
- <li>' . esc_html__('Marked as Checked.', 'gwolle-gb').'</li>
296
- <li>' . esc_html__('Not marked as Spam.', 'gwolle-gb').'</li>
297
- <li>' . esc_html__('Not marked as Trash.','gwolle-gb').'</li>
298
  </ul>';
299
  }
300
 
@@ -376,20 +376,20 @@ function gwolle_gb_welcome_post() {
376
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
377
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_gwolle' );
378
  }
379
- if ( $verified == false ) {
380
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
381
  return;
382
  }
383
 
384
  /* E-mail notification option. */
385
- if ( isset($_POST['notify_by_mail']) && $_POST['notify_by_mail'] == 'on' ) {
386
  // Turn the notification ON for the current user.
387
  $user_id = get_current_user_id();
388
- $user_ids = Array();
389
 
390
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
391
  if ( strlen($user_ids_old) > 0 ) {
392
- $user_ids_old = explode( ",", $user_ids_old );
393
  foreach ( $user_ids_old as $user_id_old ) {
394
  if ( (int) $user_id_old === (int) $user_id ) {
395
  continue; // will be added again below the loop
@@ -401,18 +401,18 @@ function gwolle_gb_welcome_post() {
401
  }
402
  $user_ids[] = (int) $user_id; // Really add it.
403
 
404
- $user_ids = implode(",", $user_ids);
405
  update_option('gwolle_gb-notifyByMail', $user_ids);
406
 
407
  gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
408
- } elseif ( ! isset($_POST['notify_by_mail'] ) ) {
409
  // Turn the notification OFF for the current user
410
  $user_id = get_current_user_id();
411
- $user_ids = Array();
412
 
413
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
414
  if ( strlen($user_ids_old) > 0 ) {
415
- $user_ids_old = explode( ",", $user_ids_old );
416
  foreach ( $user_ids_old as $user_id_old ) {
417
  if ( (int) $user_id_old === (int) $user_id ) {
418
  continue;
@@ -423,7 +423,7 @@ function gwolle_gb_welcome_post() {
423
  }
424
  }
425
 
426
- $user_ids = implode(",", $user_ids);
427
  update_option('gwolle_gb-notifyByMail', $user_ids);
428
  gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
429
  }
14
  */
15
  function gwolle_gb_welcome() {
16
 
17
+ if ( ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  /* Post Handling: Save notification setting */
22
+ if ( isset( $_POST['option_page']) && $_POST['option_page'] === 'gwolle_gb_options' ) {
23
  gwolle_gb_welcome_post();
24
  }
25
 
26
  gwolle_gb_admin_enqueue();
27
 
28
+ add_meta_box('gwolle_gb_right_now', esc_html__('Welcome to the Guestbook!', 'gwolle-gb'), 'gwolle_gb_overview', 'gwolle_gb_welcome', 'normal');
29
  add_meta_box('gwolle_gb_visibility', esc_html__('Visibility', 'gwolle-gb'), 'gwolle_gb_overview_visibility', 'gwolle_gb_welcome', 'normal');
30
  add_meta_box('gwolle_gb_notification', esc_html__('E-mail Notifications', 'gwolle-gb'), 'gwolle_gb_overview_notification', 'gwolle_gb_welcome', 'normal');
31
+ add_meta_box('gwolle_gb_thanks', esc_html__('Third Party', 'gwolle-gb'), 'gwolle_gb_overview_thanks', 'gwolle_gb_welcome', 'normal');
32
 
33
  add_meta_box('gwolle_gb_help', esc_html__('Help', 'gwolle-gb'), 'gwolle_gb_overview_help', 'gwolle_gb_welcome', 'right');
34
  add_meta_box('gwolle_gb_support', esc_html__('Support and Translations', 'gwolle-gb'), 'gwolle_gb_overview_support', 'gwolle_gb_welcome', 'right');
42
  <div id="icon-gwolle-gb"><br /></div>
43
  <?php
44
  $heading = esc_html__('Gwolle Guestbook', 'gwolle-gb');
45
+ if ( $heading !== 'Gwolle Guestbook' ) { // translated, so we add the real name.
46
  $heading .= ' (Gwolle Guestbook)';
47
  } ?>
48
+ <h1><?php echo $heading . ' - v' . GWOLLE_GB_VER; ?></h1>
49
 
50
  <?php
51
  $gwolle_gb_messages = gwolle_gb_get_messages();
57
 
58
  if ( $gwolle_gb_messages ) {
59
  echo '
60
+ <div id="message" class="updated fade notice is-dismissible ' . esc_attr( $messageclass ) . ' ">' .
61
  $gwolle_gb_messages .
62
  '</div>';
63
  } ?>
80
  /*
81
  * Metabox with overview.
82
  */
83
+ function gwolle_gb_overview() {
84
 
85
  // Calculate the number of entries
86
+ $count = array();
87
+ $count['checked'] = gwolle_gb_get_entry_count( array(
88
  'checked' => 'checked',
89
  'trash' => 'notrash',
90
+ 'spam' => 'nospam',
91
  ));
92
+ $count['unchecked'] = gwolle_gb_get_entry_count( array(
93
  'checked' => 'unchecked',
94
  'trash' => 'notrash',
95
+ 'spam' => 'nospam',
96
  ));
97
+ $count['spam'] = gwolle_gb_get_entry_count( array( 'spam' => 'spam' ) );
98
+ $count['trash'] = gwolle_gb_get_entry_count( array( 'trash' => 'trash' ) );
99
+ $count['all'] = gwolle_gb_get_entry_count( array( 'all' => 'all' ) );
100
  ?>
101
 
102
  <div class="table table_content gwolle_gb gwolle-gb-overview">
103
+ <h3><?php esc_html_e('Overview', 'gwolle-gb'); ?></h3>
104
 
105
  <table>
106
  <tbody>
165
  if ( $postid ) {
166
  $permalink = gwolle_gb_get_permalink( $postid );
167
  ?>
168
+ <a class="button rbutton button button-primary" href="<?php echo esc_attr( $permalink ); ?>"><?php esc_html_e('View Guestbook', 'gwolle-gb'); ?></a>
169
  <?php
170
  } ?>
171
+ <a class="button rbutton button button-primary" href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php' ); ?>"><?php esc_html_e('Write admin entry', 'gwolle-gb'); ?></a>
172
  </p>
173
  <p>
174
  <?php
197
  if ( ! function_exists('mail') ) {
198
  /* translators: %s is for the code element */
199
  echo '<p class="setting-description">' .
200
+ sprintf( esc_html__('Sorry, but the function %smail()%s required to notify you by mail is not enabled in your PHP configuration. You might want to install a WordPress plugin that uses SMTP instead of %smail()%s. Or you can contact your hosting provider.', 'gwolle-gb'), '<code>', '</code>', '<code>', '</code>' )
201
  . '</p>';
202
  }
203
+ $current_user_id = get_current_user_id();
204
+ $current_user_notification = false;
205
  $user_ids = get_option('gwolle_gb-notifyByMail' );
206
  if ( strlen($user_ids) > 0 ) {
207
+ $user_ids = explode( ',', $user_ids );
208
+ if ( is_array($user_ids) && ! empty($user_ids) ) {
209
  if ( in_array( $current_user_id, $user_ids ) ) {
210
+ $current_user_notification = true;
211
  }
212
  }
213
  } ?>
218
 
219
  /* Nonce */
220
  $nonce = wp_create_nonce( 'gwolle_gb_page_gwolle' );
221
+ echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . esc_attr( $nonce ) . '" />';
222
  ?>
223
  <input name="notify_by_mail" type="checkbox" id="notify_by_mail" <?php
224
+ if ( $current_user_notification ) {
225
  echo 'checked="checked"';
226
  } ?> >
227
  <label for="notify_by_mail" class="setting-description"><?php esc_html_e('Send me an e-mail when a new entry has been posted.', 'gwolle-gb'); ?></label>
241
  continue;
242
  }
243
  echo '<li>';
244
+ if ( $user_info->ID === get_current_user_id() ) {
245
  echo '<strong>' . esc_html__('You', 'gwolle-gb') . '</strong>';
246
  } else {
247
+ echo esc_html( $user_info->first_name . ' ' . $user_info->last_name );
248
  }
249
+ echo esc_html( ' (' . $user_info->user_email . ')' );
250
  echo '</li>';
251
  }
252
  echo '</ul>';
290
  * Metabox with quick help text.
291
  */
292
  function gwolle_gb_overview_visibility() {
293
+ echo '<h3>' . esc_html__('These entries will be visible for your visitors:', 'gwolle-gb') . '</h3>
294
  <ul class="ul-disc">
295
+ <li>' . esc_html__('Marked as Checked.', 'gwolle-gb') . '</li>
296
+ <li>' . esc_html__('Not marked as Spam.', 'gwolle-gb') . '</li>
297
+ <li>' . esc_html__('Not marked as Trash.', 'gwolle-gb') . '</li>
298
  </ul>';
299
  }
300
 
376
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
377
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_gwolle' );
378
  }
379
+ if ( $verified === false ) {
380
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
381
  return;
382
  }
383
 
384
  /* E-mail notification option. */
385
+ if ( isset($_POST['notify_by_mail']) && $_POST['notify_by_mail'] === 'on' ) {
386
  // Turn the notification ON for the current user.
387
  $user_id = get_current_user_id();
388
+ $user_ids = array();
389
 
390
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
391
  if ( strlen($user_ids_old) > 0 ) {
392
+ $user_ids_old = explode( ',', $user_ids_old );
393
  foreach ( $user_ids_old as $user_id_old ) {
394
  if ( (int) $user_id_old === (int) $user_id ) {
395
  continue; // will be added again below the loop
401
  }
402
  $user_ids[] = (int) $user_id; // Really add it.
403
 
404
+ $user_ids = implode( ',', $user_ids );
405
  update_option('gwolle_gb-notifyByMail', $user_ids);
406
 
407
  gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
408
+ } else if ( ! isset($_POST['notify_by_mail'] ) ) {
409
  // Turn the notification OFF for the current user
410
  $user_id = get_current_user_id();
411
+ $user_ids = array();
412
 
413
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
414
  if ( strlen($user_ids_old) > 0 ) {
415
+ $user_ids_old = explode( ',', $user_ids_old );
416
  foreach ( $user_ids_old as $user_id_old ) {
417
  if ( (int) $user_id_old === (int) $user_id ) {
418
  continue;
423
  }
424
  }
425
 
426
+ $user_ids = implode( ',', $user_ids );
427
  update_option('gwolle_gb-notifyByMail', $user_ids);
428
  gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
429
  }
admin/gb-page-import.php CHANGED
@@ -21,11 +21,11 @@ function gwolle_gb_page_import() {
21
 
22
  gwolle_gb_admin_enqueue();
23
 
24
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
25
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
26
  }
27
 
28
- if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'gwolle_gb_import' ) {
29
  gwolle_gb_page_import_post();
30
  }
31
 
@@ -52,9 +52,9 @@ function gwolle_gb_page_import() {
52
  <div id="poststuff" class="gwolle_gb_import metabox-holder">
53
  <div class="postbox-container">
54
  <?php
55
- add_meta_box('gwolle_gb_import_postbox_dms', esc_html__('Import guestbook entries from DMSGuestbook','gwolle-gb'), 'gwolle_gb_import_postbox_dms', 'gwolle_gb_import', 'normal');
56
- add_meta_box('gwolle_gb_import_postbox_wp', esc_html__('Import guestbook entries from WordPress comments','gwolle-gb'), 'gwolle_gb_import_postbox_wp', 'gwolle_gb_import', 'normal');
57
- add_meta_box('gwolle_gb_import_postbox_gwolle', esc_html__('Import guestbook entries from Gwolle-GB','gwolle-gb'), 'gwolle_gb_import_postbox_gwolle', 'gwolle_gb_import', 'normal');
58
 
59
  do_meta_boxes( 'gwolle_gb_import', 'normal', '' );
60
  ?>
@@ -77,17 +77,17 @@ function gwolle_gb_import_postbox_dms() {
77
  <?php
78
  /* Nonce */
79
  $nonce = wp_create_nonce( 'gwolle_gb_page_import_dms' );
80
- echo '<input type="hidden" id="gwolle_gb_wpnonce_dms" name="gwolle_gb_wpnonce_dms" value="' . $nonce . '" />';
81
 
82
  // Does the table of DMSGuestbook exist?
83
  $sql = "
84
  SHOW
85
  TABLES
86
  LIKE '" . $wpdb->prefix . "dmsguestbook'";
87
- $foundTables = $wpdb->get_results( $sql, ARRAY_A );
88
 
89
  $count = 0;
90
- if ( isset($foundTables[0]) && in_array( $wpdb->prefix . 'dmsguestbook', $foundTables[0] ) ) {
91
  // Get entry count
92
  $sql = "
93
  SELECT
@@ -100,9 +100,9 @@ function gwolle_gb_import_postbox_dms() {
100
  $count = (int) $data[0]['count'];
101
  }
102
 
103
- if ( isset($foundTables[0]) && in_array( $wpdb->prefix . 'dmsguestbook', $foundTables[0] ) ) { ?>
104
  <div>
105
- <?php /* translators: %s is the number of entries */ echo sprintf( _n('%s entry was found and will be imported.',' %s entries were found and will be imported.', $count, 'gwolle-gb'), $count ); ?>
106
  </div>
107
  <div>
108
  <?php esc_html_e('The importer will preserve the following data per entry:', 'gwolle-gb'); ?>
@@ -149,7 +149,7 @@ function gwolle_gb_import_postbox_wp() {
149
  <?php
150
  /* Nonce */
151
  $nonce = wp_create_nonce( 'gwolle_gb_page_import_wp' );
152
- echo '<input type="hidden" id="gwolle_gb_wpnonce_wp" name="gwolle_gb_wpnonce_wp" value="' . $nonce . '" />';
153
  ?>
154
 
155
  <div>
@@ -181,29 +181,30 @@ function gwolle_gb_import_postbox_wp() {
181
  'order' => 'ASC',
182
  'orderby' => 'title',
183
  'update_post_term_cache' => false,
184
- 'update_post_meta_cache' => false
185
  );
186
 
187
  $sel_query = new WP_Query( $args );
188
  if ( $sel_query->have_posts() ) {
189
- while ( $sel_query->have_posts() ) : $sel_query->the_post();
 
190
  $args = array(
191
  'status' => 'all',
192
  'post_id' => get_the_ID(),
193
- 'count' => true
194
  );
195
- $num_comments = get_comments($args);
196
  // get_comments_number returns only approved comments, and wp_count_comments seems to list spam too?
197
 
198
- if ( $num_comments == 0 ) {
199
  continue;
200
  } else {
201
  /* translators: %s is the number of comments */
202
- $comments = sprintf( _n('%s Comment','%s Comments', $num_comments, 'gwolle-gb'), $num_comments );
203
  }
204
 
205
- echo '<option value="' . get_the_ID() . '">'. get_the_title() . ' (' . $comments . ')</option>';
206
- endwhile;
207
  }
208
  wp_reset_postdata(); ?>
209
  </select>
@@ -219,28 +220,29 @@ function gwolle_gb_import_postbox_wp() {
219
  'order' => 'ASC',
220
  'orderby' => 'title',
221
  'update_post_term_cache' => false,
222
- 'update_post_meta_cache' => false
223
  );
224
 
225
  $sel_query = new WP_Query( $args );
226
  if ( $sel_query->have_posts() ) {
227
- while ( $sel_query->have_posts() ) : $sel_query->the_post();
 
228
  $args = array(
229
  'status' => 'all',
230
  'post_id' => get_the_ID(),
231
- 'count' => true
232
  );
233
- $num_comments = get_comments($args);
234
 
235
- if ( $num_comments == 0 ) {
236
  continue;
237
  } else {
238
  /* translators: %s is the number of comments */
239
  $comments = sprintf( _n('%s Comment', '%s Comments', $num_comments, 'gwolle-gb'), $num_comments );
240
  }
241
 
242
- echo '<option value="' . get_the_ID() . '">'. get_the_title() . ' (' . $comments . ')</option>';
243
- endwhile;
244
  }
245
  wp_reset_postdata(); ?>
246
  </select>
@@ -249,14 +251,14 @@ function gwolle_gb_import_postbox_wp() {
249
  <?php
250
  $args = array(
251
  'status' => 'all',
252
- 'count' => true
253
  );
254
- $num_comments = get_comments($args); ?>
255
 
256
  <p><label for="gwolle_gb_importfrom"><?php esc_html_e('Select where to import the comments from:', 'gwolle-gb'); ?></label><br />
257
  <label><input type="radio" name="gwolle_gb_importfrom" id="gwolle_gb_importfrom" value="page" /><?php esc_html_e('Comments from selected page.', 'gwolle-gb'); ?></label><br />
258
  <label><input type="radio" name="gwolle_gb_importfrom" id="gwolle_gb_importfrom" value="post" /><?php esc_html_e('Comments from selected post.', 'gwolle-gb'); ?></label><br />
259
- <label><input type="radio" name="gwolle_gb_importfrom" id="gwolle_gb_importfrom" value="all" /><?php esc_html_e('All Comments', 'gwolle-gb'); echo " (" . $num_comments . ")."; ?></label><br />
260
  </p>
261
 
262
  <p>
@@ -278,7 +280,7 @@ function gwolle_gb_import_postbox_gwolle() {
278
  <?php
279
  /* Nonce */
280
  $nonce = wp_create_nonce( 'gwolle_gb_page_import_gwolle' );
281
- echo '<input type="hidden" id="gwolle_gb_wpnonce_gwolle" name="gwolle_gb_wpnonce_gwolle" value="' . $nonce . '" />';
282
  ?>
283
 
284
  <p>
@@ -306,7 +308,7 @@ function gwolle_gb_page_import_post() {
306
 
307
  //if ( WP_DEBUG ) { echo "_POST: "; var_dump($_POST); }
308
 
309
- if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'gwolle_gb_import' ) {
310
 
311
  if (isset($_POST['start_import_dms'])) {
312
 
@@ -315,7 +317,7 @@ function gwolle_gb_page_import_post() {
315
  if ( isset($_POST['gwolle_gb_wpnonce_dms']) ) {
316
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce_dms'], 'gwolle_gb_page_import_dms' );
317
  }
318
- if ( $verified == false ) {
319
  // Nonce is invalid.
320
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
321
  return;
@@ -327,9 +329,9 @@ function gwolle_gb_page_import_post() {
327
  SHOW
328
  TABLES
329
  LIKE '" . $wpdb->prefix . "dmsguestbook'";
330
- $foundTables = $wpdb->get_results( $sql, ARRAY_A );
331
 
332
- if ( isset($foundTables[0]) && in_array( $wpdb->prefix . 'dmsguestbook', $foundTables[0] ) ) {
333
  $result = $wpdb->get_results("
334
  SELECT
335
  `name`,
@@ -347,7 +349,7 @@ function gwolle_gb_page_import_post() {
347
  date ASC
348
  ", ARRAY_A);
349
 
350
- if ( is_array($result) && !empty($result) ) {
351
 
352
  $saved = 0;
353
  foreach ($result as $entry_data) {
@@ -356,15 +358,15 @@ function gwolle_gb_page_import_post() {
356
  $entry = new gwolle_gb_entry();
357
 
358
  /* Set the data in the instance */
359
- $entry->set_isspam( $entry_data["spam"] );
360
  $entry->set_ischecked( true );
361
- $entry->set_istrash( $entry_data["flag"] );
362
- $entry->set_content( $entry_data["message"] );
363
- $entry->set_datetime( $entry_data["date"] );
364
- $entry->set_author_name( $entry_data["name"] );
365
- $entry->set_author_email( $entry_data["email"] );
366
- $entry->set_author_ip( $entry_data["ip"] );
367
- $entry->set_author_website( $entry_data["url"] );
368
 
369
  /* Save the instance */
370
  $save = $entry->save();
@@ -374,12 +376,12 @@ function gwolle_gb_page_import_post() {
374
  $saved++;
375
  }
376
  }
377
- if ( $saved == 0 ) {
378
  gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import entries from DMSGuestbook successfully.", 'gwolle-gb') . '</p>', true, false);
379
- } else if ( $saved == 1 || $saved > 1 ) {
380
  do_action( 'gwolle_gb_save_entry_admin', $entry );
381
  /* translators: %s is the number of entries */
382
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from DMSGuestbook.','%s entries imported successfully from DMSGuestbook.', $saved, 'gwolle-gb'), $saved ) . '</p>', false, false);
383
  }
384
  } else {
385
  /* translators: %s is for bold text */
@@ -396,7 +398,7 @@ function gwolle_gb_page_import_post() {
396
  if ( isset($_POST['gwolle_gb_wpnonce_wp']) ) {
397
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce_wp'], 'gwolle_gb_page_import_wp' );
398
  }
399
- if ( $verified == false ) {
400
  // Nonce is invalid.
401
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
402
  return;
@@ -404,19 +406,19 @@ function gwolle_gb_page_import_post() {
404
 
405
  $args = array();
406
 
407
- if ( isset($_POST['gwolle_gb_importfrom']) && $_POST['gwolle_gb_importfrom'] == 'page' && isset($_POST['gwolle_gb_pageid']) && (int) $_POST['gwolle_gb_pageid'] > 0 ) {
408
  $page_id = (int) $_POST['gwolle_gb_pageid'];
409
  $args = array(
410
  'status' => 'all',
411
- 'post_id' => $page_id
412
  );
413
- } else if ( isset($_POST['gwolle_gb_importfrom']) && $_POST['gwolle_gb_importfrom'] == 'post' && isset($_POST['gwolle_gb_postid']) && (int) $_POST['gwolle_gb_postid'] > 0 ) {
414
  $post_id = (int) $_POST['gwolle_gb_postid'];
415
  $args = array(
416
  'status' => 'all',
417
- 'post_id' => $post_id
418
  );
419
- } else if ( isset($_POST['gwolle_gb_importfrom']) && $_POST['gwolle_gb_importfrom'] == 'all' ) {
420
  $args = array(
421
  'status' => 'all',
422
  );
@@ -424,10 +426,10 @@ function gwolle_gb_page_import_post() {
424
  gwolle_gb_add_message( '<p>' . esc_html__("You haven't chosen how to import from WordPress comments. Please choose and try again.", 'gwolle-gb') . '</p>', true, false);
425
  }
426
 
427
- if ( is_array($args) && !empty($args) ) {
428
  $comments = get_comments( $args );
429
 
430
- if ( is_array($comments) && !empty($comments) ) {
431
 
432
  $saved = 0;
433
  foreach ( $comments as $comment ) {
@@ -454,12 +456,12 @@ function gwolle_gb_page_import_post() {
454
  $saved++;
455
  }
456
  }
457
- if ( $saved == 0 ) {
458
  gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import comments from that page successfully.", 'gwolle-gb') . '</p>', true, false);
459
- } else if ( $saved == 1 || $saved > 1 ) {
460
  do_action( 'gwolle_gb_save_entry_admin', $entry );
461
  /* translators: %s is the number of entries */
462
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from WordPress comments.','%s entries imported successfully from WordPress comments.', $saved, 'gwolle-gb'), $saved ) . '</p>', false, false);
463
  }
464
  } else {
465
  /* translators: %s is for bold text */
@@ -476,18 +478,18 @@ function gwolle_gb_page_import_post() {
476
  if ( isset($_POST['gwolle_gb_wpnonce_gwolle']) ) {
477
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce_gwolle'], 'gwolle_gb_page_import_gwolle' );
478
  }
479
- if ( $verified == false ) {
480
  // Nonce is invalid.
481
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
482
  return;
483
  }
484
 
485
  // if they DID upload a file...
486
- if($_FILES['start_import_gwolle_file']['name']) {
487
- if( !$_FILES['start_import_gwolle_file']['error'] ) { // if no errors...
488
  //now is the time to modify the future file name and validate the file
489
  // $new_file_name = strtolower( $_FILES['gwolle_gb_gwolle']['tmp_name'] ); //rename file
490
- if( $_FILES['start_import_gwolle_file']['size'] > ( 4096000 ) ) { // Can't be larger than 4 MB
491
  $valid_file = false;
492
  gwolle_gb_add_message( '<p>' . esc_html__('Your file is too large.', 'gwolle-gb') . '</p>', true, false);
493
  } else {
@@ -496,12 +498,12 @@ function gwolle_gb_page_import_post() {
496
  }
497
 
498
  ini_set('auto_detect_line_endings', true);
499
- $handle = fopen($_FILES['start_import_gwolle_file']['tmp_name'], "r");
500
  $row = 0;
501
 
502
  while ( ( $data = fgetcsv( $handle, 2000, ',', '"' ) ) !== FALSE ) {
503
  $num = count($data);
504
- if ($row == 0) {
505
  // Check the headerrow. $testrow_old is version 1.4.1 and older.
506
  $testrow_1_0 = array(
507
  'id',
@@ -515,7 +517,7 @@ function gwolle_gb_page_import_post() {
515
  'date',
516
  'isspam',
517
  'ischecked',
518
- 'istrash'
519
  );
520
  $testrow_1_4_1 = array(
521
  'id',
@@ -529,7 +531,7 @@ function gwolle_gb_page_import_post() {
529
  'datetime',
530
  'isspam',
531
  'ischecked',
532
- 'istrash'
533
  );
534
  $testrow_1_4_8 = array(
535
  'id',
@@ -544,7 +546,7 @@ function gwolle_gb_page_import_post() {
544
  'isspam',
545
  'ischecked',
546
  'istrash',
547
- 'admin_reply'
548
  );
549
  $testrow_2_3_9 = array(
550
  'id',
@@ -560,7 +562,7 @@ function gwolle_gb_page_import_post() {
560
  'ischecked',
561
  'istrash',
562
  'admin_reply',
563
- 'book_id'
564
  );
565
  $testrow_2_4_0 = array(
566
  'id',
@@ -577,9 +579,9 @@ function gwolle_gb_page_import_post() {
577
  'istrash',
578
  'admin_reply',
579
  'book_id',
580
- 'meta_fields'
581
  );
582
- if ( $data != $testrow_1_0 && $data != $testrow_1_4_1 && $data != $testrow_1_4_8 && $data != $testrow_2_3_9 && $data != $testrow_2_4_0 ) {
583
  gwolle_gb_add_message( '<p>' . esc_html__('It seems your CSV file is from an export that is not compatible with this version of Gwolle-GB.', 'gwolle-gb') . '</p>', true, false);
584
  break;
585
  }
@@ -587,7 +589,7 @@ function gwolle_gb_page_import_post() {
587
  continue;
588
  }
589
 
590
- if ( $num != 12 && $num != 13 && $num != 14 && $num != 15 ) {
591
  gwolle_gb_add_message( '<p>' . esc_html__('Your data seems to be corrupt. Import failed.', 'gwolle-gb') . '</p>', true, false);
592
  break;
593
  }
@@ -625,7 +627,7 @@ function gwolle_gb_page_import_post() {
625
  }
626
 
627
  // Support author ID, based on email address.
628
- $user = new WP_User;
629
  $user_object = $user->get_data_by( 'email', $data[2] );
630
  if ( is_object( $user_object ) && isset( $user_object->ID ) ) {
631
  $entry->set_author_id( $user_object->ID );
@@ -654,12 +656,12 @@ function gwolle_gb_page_import_post() {
654
  }
655
  $row--; // minus the header
656
 
657
- if ( $row == 0 ) {
658
  gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import entries from the CSV file.", 'gwolle-gb') . '</p>', true, false);
659
- } else if ( $row == 1 || $row > 1 ) {
660
  do_action( 'gwolle_gb_save_entry_admin', $entry );
661
  /* translators: %s is the number of entries */
662
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from the CSV file.','%s entries imported successfully from the CSV file.', $row, 'gwolle-gb'), $row ) . '</p>', false, false);
663
  }
664
 
665
  fclose($handle);
21
 
22
  gwolle_gb_admin_enqueue();
23
 
24
+ if ( ! current_user_can('manage_options') ) {
25
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
26
  }
27
 
28
+ if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'gwolle_gb_import' ) {
29
  gwolle_gb_page_import_post();
30
  }
31
 
52
  <div id="poststuff" class="gwolle_gb_import metabox-holder">
53
  <div class="postbox-container">
54
  <?php
55
+ add_meta_box( 'gwolle_gb_import_postbox_dms', esc_html__('Import guestbook entries from DMSGuestbook', 'gwolle-gb'), 'gwolle_gb_import_postbox_dms', 'gwolle_gb_import', 'normal' );
56
+ add_meta_box( 'gwolle_gb_import_postbox_wp', esc_html__('Import guestbook entries from WordPress comments', 'gwolle-gb'), 'gwolle_gb_import_postbox_wp', 'gwolle_gb_import', 'normal' );
57
+ add_meta_box( 'gwolle_gb_import_postbox_gwolle', esc_html__('Import guestbook entries from Gwolle-GB', 'gwolle-gb'), 'gwolle_gb_import_postbox_gwolle', 'gwolle_gb_import', 'normal' );
58
 
59
  do_meta_boxes( 'gwolle_gb_import', 'normal', '' );
60
  ?>
77
  <?php
78
  /* Nonce */
79
  $nonce = wp_create_nonce( 'gwolle_gb_page_import_dms' );
80
+ echo '<input type="hidden" id="gwolle_gb_wpnonce_dms" name="gwolle_gb_wpnonce_dms" value="' . esc_attr( $nonce ) . '" />';
81
 
82
  // Does the table of DMSGuestbook exist?
83
  $sql = "
84
  SHOW
85
  TABLES
86
  LIKE '" . $wpdb->prefix . "dmsguestbook'";
87
+ $found_tables = $wpdb->get_results( $sql, ARRAY_A );
88
 
89
  $count = 0;
90
+ if ( isset($found_tables[0]) && in_array( $wpdb->prefix . 'dmsguestbook', $found_tables[0] ) ) {
91
  // Get entry count
92
  $sql = "
93
  SELECT
100
  $count = (int) $data[0]['count'];
101
  }
102
 
103
+ if ( isset($found_tables[0]) && in_array( $wpdb->prefix . 'dmsguestbook', $found_tables[0] ) ) { ?>
104
  <div>
105
+ <?php /* translators: %s is the number of entries */ echo sprintf( _n('%s entry was found and will be imported.', ' %s entries were found and will be imported.', $count, 'gwolle-gb'), $count ); ?>
106
  </div>
107
  <div>
108
  <?php esc_html_e('The importer will preserve the following data per entry:', 'gwolle-gb'); ?>
149
  <?php
150
  /* Nonce */
151
  $nonce = wp_create_nonce( 'gwolle_gb_page_import_wp' );
152
+ echo '<input type="hidden" id="gwolle_gb_wpnonce_wp" name="gwolle_gb_wpnonce_wp" value="' . esc_attr( $nonce ) . '" />';
153
  ?>
154
 
155
  <div>
181
  'order' => 'ASC',
182
  'orderby' => 'title',
183
  'update_post_term_cache' => false,
184
+ 'update_post_meta_cache' => false,
185
  );
186
 
187
  $sel_query = new WP_Query( $args );
188
  if ( $sel_query->have_posts() ) {
189
+ while ( $sel_query->have_posts() ) {
190
+ $sel_query->the_post();
191
  $args = array(
192
  'status' => 'all',
193
  'post_id' => get_the_ID(),
194
+ 'count' => true,
195
  );
196
+ $num_comments = (int) get_comments($args);
197
  // get_comments_number returns only approved comments, and wp_count_comments seems to list spam too?
198
 
199
+ if ( $num_comments === 0 ) {
200
  continue;
201
  } else {
202
  /* translators: %s is the number of comments */
203
+ $comments = sprintf( _n('%s Comment', '%s Comments', $num_comments, 'gwolle-gb'), $num_comments );
204
  }
205
 
206
+ echo '<option value="' . get_the_ID() . '">' . get_the_title() . ' (' . $comments . ')</option>';
207
+ }
208
  }
209
  wp_reset_postdata(); ?>
210
  </select>
220
  'order' => 'ASC',
221
  'orderby' => 'title',
222
  'update_post_term_cache' => false,
223
+ 'update_post_meta_cache' => false,
224
  );
225
 
226
  $sel_query = new WP_Query( $args );
227
  if ( $sel_query->have_posts() ) {
228
+ while ( $sel_query->have_posts() ) {
229
+ $sel_query->the_post();
230
  $args = array(
231
  'status' => 'all',
232
  'post_id' => get_the_ID(),
233
+ 'count' => true,
234
  );
235
+ $num_comments = (int) get_comments($args);
236
 
237
+ if ( $num_comments === 0 ) {
238
  continue;
239
  } else {
240
  /* translators: %s is the number of comments */
241
  $comments = sprintf( _n('%s Comment', '%s Comments', $num_comments, 'gwolle-gb'), $num_comments );
242
  }
243
 
244
+ echo '<option value="' . get_the_ID() . '">' . get_the_title() . ' (' . $comments . ')</option>';
245
+ }
246
  }
247
  wp_reset_postdata(); ?>
248
  </select>
251
  <?php
252
  $args = array(
253
  'status' => 'all',
254
+ 'count' => true,
255
  );
256
+ $num_comments = (int) get_comments($args); ?>
257
 
258
  <p><label for="gwolle_gb_importfrom"><?php esc_html_e('Select where to import the comments from:', 'gwolle-gb'); ?></label><br />
259
  <label><input type="radio" name="gwolle_gb_importfrom" id="gwolle_gb_importfrom" value="page" /><?php esc_html_e('Comments from selected page.', 'gwolle-gb'); ?></label><br />
260
  <label><input type="radio" name="gwolle_gb_importfrom" id="gwolle_gb_importfrom" value="post" /><?php esc_html_e('Comments from selected post.', 'gwolle-gb'); ?></label><br />
261
+ <label><input type="radio" name="gwolle_gb_importfrom" id="gwolle_gb_importfrom" value="all" /><?php esc_html_e('All Comments', 'gwolle-gb'); echo ' (' . $num_comments . ').'; ?></label><br />
262
  </p>
263
 
264
  <p>
280
  <?php
281
  /* Nonce */
282
  $nonce = wp_create_nonce( 'gwolle_gb_page_import_gwolle' );
283
+ echo '<input type="hidden" id="gwolle_gb_wpnonce_gwolle" name="gwolle_gb_wpnonce_gwolle" value="' . esc_attr( $nonce ) . '" />';
284
  ?>
285
 
286
  <p>
308
 
309
  //if ( WP_DEBUG ) { echo "_POST: "; var_dump($_POST); }
310
 
311
+ if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'gwolle_gb_import' ) {
312
 
313
  if (isset($_POST['start_import_dms'])) {
314
 
317
  if ( isset($_POST['gwolle_gb_wpnonce_dms']) ) {
318
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce_dms'], 'gwolle_gb_page_import_dms' );
319
  }
320
+ if ( $verified === false ) {
321
  // Nonce is invalid.
322
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
323
  return;
329
  SHOW
330
  TABLES
331
  LIKE '" . $wpdb->prefix . "dmsguestbook'";
332
+ $found_tables = $wpdb->get_results( $sql, ARRAY_A );
333
 
334
+ if ( isset($found_tables[0]) && in_array( $wpdb->prefix . 'dmsguestbook', $found_tables[0] ) ) {
335
  $result = $wpdb->get_results("
336
  SELECT
337
  `name`,
349
  date ASC
350
  ", ARRAY_A);
351
 
352
+ if ( is_array($result) && ! empty($result) ) {
353
 
354
  $saved = 0;
355
  foreach ($result as $entry_data) {
358
  $entry = new gwolle_gb_entry();
359
 
360
  /* Set the data in the instance */
361
+ $entry->set_isspam( $entry_data['spam'] );
362
  $entry->set_ischecked( true );
363
+ $entry->set_istrash( $entry_data['flag'] );
364
+ $entry->set_content( $entry_data['message'] );
365
+ $entry->set_datetime( $entry_data['date'] );
366
+ $entry->set_author_name( $entry_data['name'] );
367
+ $entry->set_author_email( $entry_data['email'] );
368
+ $entry->set_author_ip( $entry_data['ip'] );
369
+ $entry->set_author_website( $entry_data['url'] );
370
 
371
  /* Save the instance */
372
  $save = $entry->save();
376
  $saved++;
377
  }
378
  }
379
+ if ( $saved === 0 ) {
380
  gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import entries from DMSGuestbook successfully.", 'gwolle-gb') . '</p>', true, false);
381
+ } else if ( $saved === 1 || $saved > 1 ) {
382
  do_action( 'gwolle_gb_save_entry_admin', $entry );
383
  /* translators: %s is the number of entries */
384
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from DMSGuestbook.', '%s entries imported successfully from DMSGuestbook.', $saved, 'gwolle-gb'), $saved ) . '</p>', false, false);
385
  }
386
  } else {
387
  /* translators: %s is for bold text */
398
  if ( isset($_POST['gwolle_gb_wpnonce_wp']) ) {
399
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce_wp'], 'gwolle_gb_page_import_wp' );
400
  }
401
+ if ( $verified === false ) {
402
  // Nonce is invalid.
403
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
404
  return;
406
 
407
  $args = array();
408
 
409
+ if ( isset($_POST['gwolle_gb_importfrom']) && $_POST['gwolle_gb_importfrom'] === 'page' && isset($_POST['gwolle_gb_pageid']) && (int) $_POST['gwolle_gb_pageid'] > 0 ) {
410
  $page_id = (int) $_POST['gwolle_gb_pageid'];
411
  $args = array(
412
  'status' => 'all',
413
+ 'post_id' => $page_id,
414
  );
415
+ } else if ( isset($_POST['gwolle_gb_importfrom']) && $_POST['gwolle_gb_importfrom'] === 'post' && isset($_POST['gwolle_gb_postid']) && (int) $_POST['gwolle_gb_postid'] > 0 ) {
416
  $post_id = (int) $_POST['gwolle_gb_postid'];
417
  $args = array(
418
  'status' => 'all',
419
+ 'post_id' => $post_id,
420
  );
421
+ } else if ( isset($_POST['gwolle_gb_importfrom']) && $_POST['gwolle_gb_importfrom'] === 'all' ) {
422
  $args = array(
423
  'status' => 'all',
424
  );
426
  gwolle_gb_add_message( '<p>' . esc_html__("You haven't chosen how to import from WordPress comments. Please choose and try again.", 'gwolle-gb') . '</p>', true, false);
427
  }
428
 
429
+ if ( is_array($args) && ! empty($args) ) {
430
  $comments = get_comments( $args );
431
 
432
+ if ( is_array($comments) && ! empty($comments) ) {
433
 
434
  $saved = 0;
435
  foreach ( $comments as $comment ) {
456
  $saved++;
457
  }
458
  }
459
+ if ( $saved === 0 ) {
460
  gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import comments from that page successfully.", 'gwolle-gb') . '</p>', true, false);
461
+ } else if ( $saved === 1 || $saved > 1 ) {
462
  do_action( 'gwolle_gb_save_entry_admin', $entry );
463
  /* translators: %s is the number of entries */
464
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from WordPress comments.', '%s entries imported successfully from WordPress comments.', $saved, 'gwolle-gb'), $saved ) . '</p>', false, false);
465
  }
466
  } else {
467
  /* translators: %s is for bold text */
478
  if ( isset($_POST['gwolle_gb_wpnonce_gwolle']) ) {
479
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce_gwolle'], 'gwolle_gb_page_import_gwolle' );
480
  }
481
+ if ( $verified === false ) {
482
  // Nonce is invalid.
483
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
484
  return;
485
  }
486
 
487
  // if they DID upload a file...
488
+ if ($_FILES['start_import_gwolle_file']['name']) {
489
+ if ( ! $_FILES['start_import_gwolle_file']['error'] ) { // if no errors...
490
  //now is the time to modify the future file name and validate the file
491
  // $new_file_name = strtolower( $_FILES['gwolle_gb_gwolle']['tmp_name'] ); //rename file
492
+ if ( $_FILES['start_import_gwolle_file']['size'] > ( 4096000 ) ) { // Can't be larger than 4 MB
493
  $valid_file = false;
494
  gwolle_gb_add_message( '<p>' . esc_html__('Your file is too large.', 'gwolle-gb') . '</p>', true, false);
495
  } else {
498
  }
499
 
500
  ini_set('auto_detect_line_endings', true);
501
+ $handle = fopen($_FILES['start_import_gwolle_file']['tmp_name'], 'r');
502
  $row = 0;
503
 
504
  while ( ( $data = fgetcsv( $handle, 2000, ',', '"' ) ) !== FALSE ) {
505
  $num = count($data);
506
+ if ($row === 0) {
507
  // Check the headerrow. $testrow_old is version 1.4.1 and older.
508
  $testrow_1_0 = array(
509
  'id',
517
  'date',
518
  'isspam',
519
  'ischecked',
520
+ 'istrash',
521
  );
522
  $testrow_1_4_1 = array(
523
  'id',
531
  'datetime',
532
  'isspam',
533
  'ischecked',
534
+ 'istrash',
535
  );
536
  $testrow_1_4_8 = array(
537
  'id',
546
  'isspam',
547
  'ischecked',
548
  'istrash',
549
+ 'admin_reply',
550
  );
551
  $testrow_2_3_9 = array(
552
  'id',
562
  'ischecked',
563
  'istrash',
564
  'admin_reply',
565
+ 'book_id',
566
  );
567
  $testrow_2_4_0 = array(
568
  'id',
579
  'istrash',
580
  'admin_reply',
581
  'book_id',
582
+ 'meta_fields',
583
  );
584
+ if ( $data !== $testrow_1_0 && $data !== $testrow_1_4_1 && $data !== $testrow_1_4_8 && $data !== $testrow_2_3_9 && $data !== $testrow_2_4_0 ) {
585
  gwolle_gb_add_message( '<p>' . esc_html__('It seems your CSV file is from an export that is not compatible with this version of Gwolle-GB.', 'gwolle-gb') . '</p>', true, false);
586
  break;
587
  }
589
  continue;
590
  }
591
 
592
+ if ( $num !== 12 && $num !== 13 && $num !== 14 && $num !== 15 ) {
593
  gwolle_gb_add_message( '<p>' . esc_html__('Your data seems to be corrupt. Import failed.', 'gwolle-gb') . '</p>', true, false);
594
  break;
595
  }
627
  }
628
 
629
  // Support author ID, based on email address.
630
+ $user = new WP_User();
631
  $user_object = $user->get_data_by( 'email', $data[2] );
632
  if ( is_object( $user_object ) && isset( $user_object->ID ) ) {
633
  $entry->set_author_id( $user_object->ID );
656
  }
657
  $row--; // minus the header
658
 
659
+ if ( $row === 0 ) {
660
  gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import entries from the CSV file.", 'gwolle-gb') . '</p>', true, false);
661
+ } else if ( $row === 1 || $row > 1 ) {
662
  do_action( 'gwolle_gb_save_entry_admin', $entry );
663
  /* translators: %s is the number of entries */
664
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from the CSV file.', '%s entries imported successfully from the CSV file.', $row, 'gwolle-gb'), $row ) . '</p>', false, false);
665
  }
666
 
667
  fclose($handle);
admin/gb-page-settings.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settings() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
@@ -22,7 +22,7 @@ function gwolle_gb_page_settings() {
22
  $saved = false;
23
  $active_tab = 'gwolle_gb_forms';
24
 
25
- if ( isset( $_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options' ) {
26
  gwolle_gb_page_settings_update();
27
  $saved = true;
28
  $active_tab = gwolle_gb_settings_active_tab();
@@ -54,49 +54,49 @@ function gwolle_gb_page_settings() {
54
  /* Do not use nav but h2, since it is using (in)visible content, not real navigation. */
55
  ?>
56
  <h2 class="nav-tab-wrapper gwolle-nav-tab-wrapper" role="tablist">
57
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_forms') { echo "nav-tab-active";} ?>" rel="gwolle_gb_forms"><?php /* translators: Settings page tab */ esc_html_e('Form', 'gwolle-gb'); ?></a>
58
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_reading') { echo "nav-tab-active";} ?>" rel="gwolle_gb_reading"><?php /* translators: Settings page tab */ esc_html_e('Reading', 'gwolle-gb'); ?></a>
59
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_admin') { echo "nav-tab-active";} ?>" rel="gwolle_gb_admin"><?php /* translators: Settings page tab */ esc_html_e('Admin', 'gwolle-gb'); ?></a>
60
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_antispam') { echo "nav-tab-active";} ?>" rel="gwolle_gb_antispam"><?php /* translators: Settings page tab */ esc_html_e('Anti-spam', 'gwolle-gb'); ?></a>
61
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_mail') { echo "nav-tab-active";} ?>" rel="gwolle_gb_mail"><?php /* translators: Settings page tab */ esc_html_e('Notifications', 'gwolle-gb'); ?></a>
62
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_debug') { echo "nav-tab-active";} ?>" rel="gwolle_gb_debug"><?php /* translators: Settings page tab */ esc_html_e('Debug', 'gwolle-gb'); ?></a>
63
- <?php if ( function_exists('is_multisite') && ! is_multisite() ) { ?>
64
- <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_uninstall') { echo "nav-tab-active";} ?>" rel="gwolle_gb_uninstall"><?php /* translators: Settings page tab */ esc_html_e('Uninstall', 'gwolle-gb'); ?></a>
65
  <?php } ?>
66
  </h2>
67
 
68
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_forms <?php if ($active_tab == 'gwolle_gb_forms') { echo "active";} ?>" method="post" action="#">
69
  <?php gwolle_gb_page_settingstab_form(); ?>
70
  </form>
71
 
72
 
73
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_reading <?php if ($active_tab == 'gwolle_gb_reading') { echo "active";} ?>" method="post" action="#">
74
  <?php gwolle_gb_page_settingstab_reading(); ?>
75
  </form>
76
 
77
 
78
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_admin <?php if ($active_tab == 'gwolle_gb_admin') { echo "active";} ?>" method="post" action="#">
79
  <?php gwolle_gb_page_settingstab_admin(); ?>
80
  </form>
81
 
82
 
83
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_antispam <?php if ($active_tab == 'gwolle_gb_antispam') { echo "active";} ?>" method="post" action="#">
84
  <?php gwolle_gb_page_settingstab_antispam(); ?>
85
  </form>
86
 
87
 
88
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_mail <?php if ($active_tab == 'gwolle_gb_mail') { echo "active";} ?>" method="post" action="#">
89
  <?php gwolle_gb_page_settingstab_email(); ?>
90
  </form>
91
 
92
 
93
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_debug <?php if ($active_tab == 'gwolle_gb_debug') { echo "active";} ?>" method="post" action="#">
94
  <?php gwolle_gb_page_settingstab_debug(); ?>
95
  </form>
96
 
97
 
98
- <?php if ( function_exists('is_multisite') && ! is_multisite() ) { ?>
99
- <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_uninstall <?php if ($active_tab == 'gwolle_gb_uninstall') { echo "active";} ?>" method="post" action="#">
100
  <?php gwolle_gb_page_settingstab_uninstall(); ?>
101
  </form>
102
  <?php } ?>
@@ -113,36 +113,35 @@ function gwolle_gb_page_settings() {
113
  */
114
  function gwolle_gb_page_settings_update() {
115
 
116
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
117
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
118
  }
119
 
120
- if ( isset( $_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options' ) {
121
  if ( isset( $_POST['gwolle_gb_tab'] ) ) {
122
- $active_tab = $_POST['gwolle_gb_tab'];
123
  gwolle_gb_settings_active_tab( $active_tab );
124
 
125
  switch ( $active_tab ) {
126
  case 'gwolle_gb_forms':
127
-
128
  /* Check Nonce */
129
  $verified = false;
130
  if ( isset($_POST['gwolle_gb_page_settings_formtab']) ) {
131
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_formtab'], 'gwolle_gb_page_settings_formtab' );
132
  }
133
- if ( $verified == false ) {
134
  // Nonce is invalid.
135
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
136
  break;
137
  }
138
 
139
- if (isset($_POST['require_login']) && $_POST['require_login'] == 'on') {
140
  update_option('gwolle_gb-require_login', 'true');
141
  } else {
142
  update_option('gwolle_gb-require_login', 'false');
143
  }
144
 
145
- if (isset($_POST['labels_float']) && $_POST['labels_float'] == 'on') {
146
  update_option('gwolle_gb-labels_float', 'true');
147
  } else {
148
  update_option('gwolle_gb-labels_float', 'false');
@@ -155,24 +154,24 @@ function gwolle_gb_page_settings_update() {
155
  $notice = gwolle_gb_sanitize_input( $_POST['notice'], 'setting_textarea' );
156
  update_option('gwolle_gb-notice', $notice);
157
 
158
- if (isset($_POST['form_ajax']) && $_POST['form_ajax'] == 'on') {
159
  update_option('gwolle_gb-form_ajax', 'true');
160
  } else {
161
  update_option('gwolle_gb-form_ajax', 'false');
162
  }
163
 
164
- if (isset($_POST['store_ip']) && $_POST['store_ip'] == 'on') {
165
  update_option('gwolle_gb-store_ip', 'true');
166
  } else {
167
  update_option('gwolle_gb-store_ip', 'false');
168
  }
169
 
170
- if (isset($_POST['gb_remove_ip']) && $_POST['gb_remove_ip'] == 'on') {
171
  gwolle_gb_remove_ip_host();
172
  gwolle_gb_add_message( '<p>' . esc_html__('IP address and hostname was removed from all the entries.', 'gwolle-gb') . '</p>', false, false);
173
  }
174
 
175
- $list = Array(
176
  'form_name_enabled',
177
  'form_name_mandatory',
178
  'form_city_enabled',
@@ -183,28 +182,36 @@ function gwolle_gb_page_settings_update() {
183
  'form_homepage_mandatory',
184
  'form_message_enabled',
185
  'form_message_mandatory',
 
186
  'form_bbcode_enabled',
187
  'form_antispam_enabled',
188
- 'form_privacy_enabled'
189
  );
190
- $form_setting = Array();
 
191
  foreach ( $list as $item ) {
192
- if ( isset($_POST["$item"]) && $_POST["$item"] == 'on' ) {
193
  $form_setting["$item"] = 'true';
194
  } else {
195
  $form_setting["$item"] = 'false';
196
  }
197
  }
 
 
 
 
 
 
198
  update_option( 'gwolle_gb-form', $form_setting );
199
  break;
200
- case 'gwolle_gb_reading':
201
 
 
202
  /* Check Nonce */
203
  $verified = false;
204
  if ( isset($_POST['gwolle_gb_page_settings_readingtab']) ) {
205
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_readingtab'], 'gwolle_gb_page_settings_readingtab' );
206
  }
207
- if ( $verified == false ) {
208
  // Nonce is invalid.
209
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
210
  break;
@@ -214,7 +221,7 @@ function gwolle_gb_page_settings_update() {
214
  update_option('gwolle_gb-entriesPerPage', (int) $_POST['entriesPerPage']);
215
  }
216
 
217
- if (isset($_POST['showLineBreaks']) && $_POST['showLineBreaks'] == 'on') {
218
  update_option('gwolle_gb-showLineBreaks', 'true');
219
  } else {
220
  update_option('gwolle_gb-showLineBreaks', 'false');
@@ -224,37 +231,37 @@ function gwolle_gb_page_settings_update() {
224
  update_option('gwolle_gb-excerpt_length', (int) $_POST['excerpt_length']);
225
  }
226
 
227
- if (isset($_POST['showSmilies']) && $_POST['showSmilies'] == 'on') {
228
  update_option('gwolle_gb-showSmilies', 'true');
229
  } else {
230
  update_option('gwolle_gb-showSmilies', 'false');
231
  }
232
 
233
- if (isset($_POST['linkAuthorWebsite']) && $_POST['linkAuthorWebsite'] == 'on') {
234
  update_option('gwolle_gb-linkAuthorWebsite', 'true');
235
  } else {
236
  update_option('gwolle_gb-linkAuthorWebsite', 'false');
237
  }
238
 
239
- if (isset($_POST['admin_style']) && $_POST['admin_style'] == 'on') {
240
  update_option('gwolle_gb-admin_style', 'true');
241
  } else {
242
  update_option('gwolle_gb-admin_style', 'false');
243
  }
244
 
245
- if (isset($_POST['navigation']) && $_POST['navigation'] == 0) {
246
  update_option('gwolle_gb-navigation', 0);
247
- } else if (isset($_POST['navigation']) && $_POST['navigation'] == 1) {
248
  update_option('gwolle_gb-navigation', 1);
249
  }
250
 
251
- if (isset($_POST['paginate_all']) && $_POST['paginate_all'] == 'on') {
252
  update_option('gwolle_gb-paginate_all', 'true');
253
  } else {
254
  update_option('gwolle_gb-paginate_all', 'false');
255
  }
256
 
257
- $list = Array(
258
  'read_avatar',
259
  'read_name',
260
  'read_city',
@@ -262,11 +269,11 @@ function gwolle_gb_page_settings_update() {
262
  'read_date',
263
  'read_content',
264
  'read_aavatar',
265
- 'read_editlink'
266
  );
267
- $read_setting = Array();
268
  foreach ( $list as $item ) {
269
- if ( isset($_POST["$item"]) && $_POST["$item"] == 'on' ) {
270
  $read_setting["$item"] = 'true';
271
  } else {
272
  $read_setting["$item"] = 'false';
@@ -274,14 +281,14 @@ function gwolle_gb_page_settings_update() {
274
  }
275
  update_option( 'gwolle_gb-read', $read_setting );
276
  break;
277
- case 'gwolle_gb_admin':
278
 
 
279
  /* Check Nonce */
280
  $verified = false;
281
  if ( isset($_POST['gwolle_gb_page_settings_admintab']) ) {
282
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_admintab'], 'gwolle_gb_page_settings_admintab' );
283
  }
284
- if ( $verified == false ) {
285
  // Nonce is invalid.
286
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
287
  break;
@@ -291,75 +298,74 @@ function gwolle_gb_page_settings_update() {
291
  update_option( 'gwolle_gb-entries_per_page', (int) $_POST['entries_per_page']);
292
  }
293
 
294
- if (isset($_POST['showEntryIcons']) && $_POST['showEntryIcons'] == 'on') {
295
  update_option('gwolle_gb-showEntryIcons', 'true');
296
  } else {
297
  update_option('gwolle_gb-showEntryIcons', 'false');
298
  }
299
-
300
  break;
301
- case 'gwolle_gb_antispam':
302
 
 
303
  /* Check Nonce */
304
  $verified = false;
305
  if ( isset($_POST['gwolle_gb_page_settings_antispamtab']) ) {
306
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_antispamtab'], 'gwolle_gb_page_settings_antispamtab' );
307
  }
308
- if ( $verified == false ) {
309
  // Nonce is invalid.
310
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
311
  break;
312
  }
313
 
314
- if (isset($_POST['moderate-entries']) && $_POST['moderate-entries'] == 'on') {
315
  update_option('gwolle_gb-moderate-entries', 'true');
316
  } else {
317
  update_option('gwolle_gb-moderate-entries', 'false');
318
  }
319
 
320
- if (isset($_POST['refuse-spam']) && $_POST['refuse-spam'] == 'on') {
321
  update_option('gwolle_gb-refuse-spam', 'true');
322
  } else {
323
  update_option('gwolle_gb-refuse-spam', 'false');
324
  }
325
 
326
- if (isset($_POST['honeypot']) && $_POST['honeypot'] == 'on') {
327
  update_option('gwolle_gb-honeypot', 'true');
328
  } else {
329
  update_option('gwolle_gb-honeypot', 'false');
330
  }
331
 
332
- if (isset($_POST['gwolle_gb_nonce']) && $_POST['gwolle_gb_nonce'] == 'on') {
333
  update_option('gwolle_gb-nonce', 'true');
334
  } else {
335
  update_option('gwolle_gb-nonce', 'false');
336
  }
337
 
338
- if (isset($_POST['gwolle_gb_longtext']) && $_POST['gwolle_gb_longtext'] == 'on') {
339
  update_option('gwolle_gb-longtext', 'true');
340
  } else {
341
  update_option('gwolle_gb-longtext', 'false');
342
  }
343
 
344
- if (isset($_POST['gwolle_gb_linkchecker']) && $_POST['gwolle_gb_linkchecker'] == 'on') {
345
  update_option('gwolle_gb-linkchecker', 'true');
346
  } else {
347
  update_option('gwolle_gb-linkchecker', 'false');
348
  }
349
 
350
- if (isset($_POST['gwolle_gb_timeout']) && $_POST['gwolle_gb_timeout'] == 'on') {
351
  update_option('gwolle_gb-timeout', 'true');
352
  } else {
353
  update_option('gwolle_gb-timeout', 'false');
354
  }
355
 
356
- if (isset($_POST['akismet-active']) && $_POST['akismet-active'] == 'on') {
357
  update_option('gwolle_gb-akismet-active', 'true');
358
  } else {
359
  update_option('gwolle_gb-akismet-active', 'false');
360
  }
361
 
362
- if (isset($_POST['gwolle_gb_sfs']) && $_POST['gwolle_gb_sfs'] == 'on') {
363
  update_option('gwolle_gb-sfs', 'true');
364
  } else {
365
  update_option('gwolle_gb-sfs', 'false');
@@ -380,22 +386,21 @@ function gwolle_gb_page_settings_update() {
380
  $blocklist = implode( "\n", $blocklist );
381
  update_option('gwolle_gb_addon-moderation_keys', $blocklist);
382
  }
383
-
384
  break;
385
- case 'gwolle_gb_mail':
386
 
 
387
  /* Check Nonce */
388
  $verified = false;
389
  if ( isset($_POST['gwolle_gb_page_settings_emailtab']) ) {
390
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_emailtab'], 'gwolle_gb_page_settings_emailtab' );
391
  }
392
- if ( $verified == false ) {
393
  // Nonce is invalid.
394
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
395
  break;
396
  }
397
 
398
- if ( isset($_POST['admin_mail_from']) && $_POST['admin_mail_from'] != gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) ) {
399
  $admin_mail_from = gwolle_gb_sanitize_input( $_POST['admin_mail_from'] );
400
  if ( filter_var( $admin_mail_from, FILTER_VALIDATE_EMAIL ) ) {
401
  // Valid Email address.
@@ -405,11 +410,11 @@ function gwolle_gb_page_settings_update() {
405
 
406
  if ( isset($_POST['unsubscribe']) && $_POST['unsubscribe'] > 0 ) {
407
  $user_id = (int) $_POST['unsubscribe'];
408
- $user_ids = Array();
409
 
410
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
411
  if ( strlen($user_ids_old) > 0 ) {
412
- $user_ids_old = explode( ",", $user_ids_old );
413
  foreach ( $user_ids_old as $user_id_old ) {
414
  if ( (int) $user_id_old === (int) $user_id ) {
415
  continue;
@@ -420,17 +425,17 @@ function gwolle_gb_page_settings_update() {
420
  }
421
  }
422
 
423
- $user_ids = implode(",", $user_ids);
424
  update_option('gwolle_gb-notifyByMail', $user_ids);
425
  }
426
 
427
  if ( isset($_POST['subscribe']) && $_POST['subscribe'] > 0 ) {
428
  $user_id = (int) $_POST['subscribe'];
429
- $user_ids = Array();
430
 
431
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
432
  if ( strlen($user_ids_old) > 0 ) {
433
- $user_ids_old = explode( ",", $user_ids_old );
434
  foreach ( $user_ids_old as $user_id_old ) {
435
  if ( (int) $user_id_old === (int) $user_id ) {
436
  continue; // will be added again below the loop
@@ -442,7 +447,7 @@ function gwolle_gb_page_settings_update() {
442
  }
443
  $user_ids[] = $user_id; // Really add it.
444
 
445
- $user_ids = implode(",", $user_ids);
446
  update_option('gwolle_gb-notifyByMail', $user_ids);
447
  }
448
 
@@ -451,7 +456,7 @@ function gwolle_gb_page_settings_update() {
451
  update_option('gwolle_gb-adminMailContent', $mail_content);
452
  }
453
 
454
- if (isset($_POST['mail_author']) && $_POST['mail_author'] == 'on') {
455
  update_option('gwolle_gb-mail_author', 'true');
456
  } else {
457
  update_option('gwolle_gb-mail_author', 'false');
@@ -462,7 +467,7 @@ function gwolle_gb_page_settings_update() {
462
  update_option('gwolle_gb-authorMailContent', $mail_content);
463
  }
464
 
465
- if (isset($_POST['mail_author_moderation']) && $_POST['mail_author_moderation'] == 'on') {
466
  update_option('gwolle_gb-mail_author_moderation', 'true');
467
  } else {
468
  update_option('gwolle_gb-mail_author_moderation', 'false');
@@ -477,26 +482,25 @@ function gwolle_gb_page_settings_update() {
477
  $mail_content = gwolle_gb_sanitize_input( $_POST['gwolle_gb-mail_admin_replyContent'], 'setting_textarea' );
478
  update_option('gwolle_gb-mail_admin_replyContent', $mail_content);
479
  }
480
-
481
  break;
482
- case 'gwolle_gb_debug':
483
 
 
484
  break;
485
- case 'gwolle_gb_uninstall':
486
 
 
487
  /* Check Nonce */
488
  $verified = false;
489
  if ( isset($_POST['gwolle_gb_page_settings_uninstalltab']) ) {
490
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_uninstalltab'], 'gwolle_gb_page_settings_uninstalltab' );
491
  }
492
- if ( $verified == false ) {
493
  // Nonce is invalid.
494
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
495
  break;
496
  }
497
 
498
- if (isset($_POST['gwolle_gb_uninstall_confirmed']) && $_POST['gwolle_gb_uninstall_confirmed'] == 'on') {
499
- if ( function_exists('is_multisite') && ! is_multisite() ) {
500
  // uninstall the plugin -> delete all tables and preferences of the plugin
501
  gwolle_gb_uninstall();
502
  gwolle_gb_add_message( '<p>' . esc_html__('The entries and settings have been removed.', 'gwolle-gb') . '</p>', false, false);
@@ -508,11 +512,12 @@ function gwolle_gb_page_settings_update() {
508
  } else {
509
  // Uninstallation not confirmed.
510
  }
511
-
512
  break;
 
513
  default:
514
  /* Just load the first tab */
515
  gwolle_gb_settings_active_tab( 'gwolle_gb_forms' );
 
516
  }
517
  }
518
  }
14
  */
15
  function gwolle_gb_page_settings() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
22
  $saved = false;
23
  $active_tab = 'gwolle_gb_forms';
24
 
25
+ if ( isset( $_POST['option_page']) && $_POST['option_page'] === 'gwolle_gb_options' ) {
26
  gwolle_gb_page_settings_update();
27
  $saved = true;
28
  $active_tab = gwolle_gb_settings_active_tab();
54
  /* Do not use nav but h2, since it is using (in)visible content, not real navigation. */
55
  ?>
56
  <h2 class="nav-tab-wrapper gwolle-nav-tab-wrapper" role="tablist">
57
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_forms') { echo "nav-tab-active";} ?>" rel="gwolle_gb_forms"><?php /* translators: Settings page tab */ esc_html_e('Form', 'gwolle-gb'); ?></a>
58
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_reading') { echo "nav-tab-active";} ?>" rel="gwolle_gb_reading"><?php /* translators: Settings page tab */ esc_html_e('Reading', 'gwolle-gb'); ?></a>
59
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_admin') { echo "nav-tab-active";} ?>" rel="gwolle_gb_admin"><?php /* translators: Settings page tab */ esc_html_e('Admin', 'gwolle-gb'); ?></a>
60
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_antispam') { echo "nav-tab-active";} ?>" rel="gwolle_gb_antispam"><?php /* translators: Settings page tab */ esc_html_e('Anti-spam', 'gwolle-gb'); ?></a>
61
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_mail') { echo "nav-tab-active";} ?>" rel="gwolle_gb_mail"><?php /* translators: Settings page tab */ esc_html_e('Notifications', 'gwolle-gb'); ?></a>
62
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_debug') { echo "nav-tab-active";} ?>" rel="gwolle_gb_debug"><?php /* translators: Settings page tab */ esc_html_e('Debug', 'gwolle-gb'); ?></a>
63
+ <?php if ( ! is_multisite() ) { ?>
64
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab === 'gwolle_gb_uninstall') { echo "nav-tab-active";} ?>" rel="gwolle_gb_uninstall"><?php /* translators: Settings page tab */ esc_html_e('Uninstall', 'gwolle-gb'); ?></a>
65
  <?php } ?>
66
  </h2>
67
 
68
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_forms <?php if ($active_tab === 'gwolle_gb_forms') { echo "active";} ?>" method="post" action="#">
69
  <?php gwolle_gb_page_settingstab_form(); ?>
70
  </form>
71
 
72
 
73
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_reading <?php if ($active_tab === 'gwolle_gb_reading') { echo "active";} ?>" method="post" action="#">
74
  <?php gwolle_gb_page_settingstab_reading(); ?>
75
  </form>
76
 
77
 
78
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_admin <?php if ($active_tab === 'gwolle_gb_admin') { echo "active";} ?>" method="post" action="#">
79
  <?php gwolle_gb_page_settingstab_admin(); ?>
80
  </form>
81
 
82
 
83
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_antispam <?php if ($active_tab === 'gwolle_gb_antispam') { echo "active";} ?>" method="post" action="#">
84
  <?php gwolle_gb_page_settingstab_antispam(); ?>
85
  </form>
86
 
87
 
88
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_mail <?php if ($active_tab === 'gwolle_gb_mail') { echo "active";} ?>" method="post" action="#">
89
  <?php gwolle_gb_page_settingstab_email(); ?>
90
  </form>
91
 
92
 
93
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_debug <?php if ($active_tab === 'gwolle_gb_debug') { echo "active";} ?>" method="post" action="#">
94
  <?php gwolle_gb_page_settingstab_debug(); ?>
95
  </form>
96
 
97
 
98
+ <?php if ( ! is_multisite() ) { ?>
99
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_uninstall <?php if ($active_tab === 'gwolle_gb_uninstall') { echo "active";} ?>" method="post" action="#">
100
  <?php gwolle_gb_page_settingstab_uninstall(); ?>
101
  </form>
102
  <?php } ?>
113
  */
114
  function gwolle_gb_page_settings_update() {
115
 
116
+ if ( ! current_user_can('manage_options') ) {
117
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
118
  }
119
 
120
+ if ( isset( $_POST['option_page']) && $_POST['option_page'] === 'gwolle_gb_options' ) {
121
  if ( isset( $_POST['gwolle_gb_tab'] ) ) {
122
+ $active_tab = (string) $_POST['gwolle_gb_tab'];
123
  gwolle_gb_settings_active_tab( $active_tab );
124
 
125
  switch ( $active_tab ) {
126
  case 'gwolle_gb_forms':
 
127
  /* Check Nonce */
128
  $verified = false;
129
  if ( isset($_POST['gwolle_gb_page_settings_formtab']) ) {
130
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_formtab'], 'gwolle_gb_page_settings_formtab' );
131
  }
132
+ if ( $verified === false ) {
133
  // Nonce is invalid.
134
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
135
  break;
136
  }
137
 
138
+ if (isset($_POST['require_login']) && $_POST['require_login'] === 'on') {
139
  update_option('gwolle_gb-require_login', 'true');
140
  } else {
141
  update_option('gwolle_gb-require_login', 'false');
142
  }
143
 
144
+ if (isset($_POST['labels_float']) && $_POST['labels_float'] === 'on') {
145
  update_option('gwolle_gb-labels_float', 'true');
146
  } else {
147
  update_option('gwolle_gb-labels_float', 'false');
154
  $notice = gwolle_gb_sanitize_input( $_POST['notice'], 'setting_textarea' );
155
  update_option('gwolle_gb-notice', $notice);
156
 
157
+ if (isset($_POST['form_ajax']) && $_POST['form_ajax'] === 'on') {
158
  update_option('gwolle_gb-form_ajax', 'true');
159
  } else {
160
  update_option('gwolle_gb-form_ajax', 'false');
161
  }
162
 
163
+ if (isset($_POST['store_ip']) && $_POST['store_ip'] === 'on') {
164
  update_option('gwolle_gb-store_ip', 'true');
165
  } else {
166
  update_option('gwolle_gb-store_ip', 'false');
167
  }
168
 
169
+ if (isset($_POST['gb_remove_ip']) && $_POST['gb_remove_ip'] === 'on') {
170
  gwolle_gb_remove_ip_host();
171
  gwolle_gb_add_message( '<p>' . esc_html__('IP address and hostname was removed from all the entries.', 'gwolle-gb') . '</p>', false, false);
172
  }
173
 
174
+ $list = array(
175
  'form_name_enabled',
176
  'form_name_mandatory',
177
  'form_city_enabled',
182
  'form_homepage_mandatory',
183
  'form_message_enabled',
184
  'form_message_mandatory',
185
+ 'form_message_maxlength',
186
  'form_bbcode_enabled',
187
  'form_antispam_enabled',
188
+ 'form_privacy_enabled',
189
  );
190
+ $form_setting = array();
191
+ // checkboxes
192
  foreach ( $list as $item ) {
193
+ if ( isset($_POST["$item"]) && $_POST["$item"] === 'on' ) {
194
  $form_setting["$item"] = 'true';
195
  } else {
196
  $form_setting["$item"] = 'false';
197
  }
198
  }
199
+ // select with options, 0 is default.
200
+ if ( isset($_POST['form_message_maxlength']) && is_numeric($_POST['form_message_maxlength']) && $_POST['form_message_maxlength'] > 0 ) {
201
+ $form_setting['form_message_maxlength'] = (int) $_POST['form_message_maxlength'];
202
+ } else {
203
+ $form_setting['form_message_maxlength'] = 0;
204
+ }
205
  update_option( 'gwolle_gb-form', $form_setting );
206
  break;
 
207
 
208
+ case 'gwolle_gb_reading':
209
  /* Check Nonce */
210
  $verified = false;
211
  if ( isset($_POST['gwolle_gb_page_settings_readingtab']) ) {
212
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_readingtab'], 'gwolle_gb_page_settings_readingtab' );
213
  }
214
+ if ( $verified === false ) {
215
  // Nonce is invalid.
216
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
217
  break;
221
  update_option('gwolle_gb-entriesPerPage', (int) $_POST['entriesPerPage']);
222
  }
223
 
224
+ if (isset($_POST['showLineBreaks']) && $_POST['showLineBreaks'] === 'on') {
225
  update_option('gwolle_gb-showLineBreaks', 'true');
226
  } else {
227
  update_option('gwolle_gb-showLineBreaks', 'false');
231
  update_option('gwolle_gb-excerpt_length', (int) $_POST['excerpt_length']);
232
  }
233
 
234
+ if (isset($_POST['showSmilies']) && $_POST['showSmilies'] === 'on') {
235
  update_option('gwolle_gb-showSmilies', 'true');
236
  } else {
237
  update_option('gwolle_gb-showSmilies', 'false');
238
  }
239
 
240
+ if (isset($_POST['linkAuthorWebsite']) && $_POST['linkAuthorWebsite'] === 'on') {
241
  update_option('gwolle_gb-linkAuthorWebsite', 'true');
242
  } else {
243
  update_option('gwolle_gb-linkAuthorWebsite', 'false');
244
  }
245
 
246
+ if (isset($_POST['admin_style']) && $_POST['admin_style'] === 'on') {
247
  update_option('gwolle_gb-admin_style', 'true');
248
  } else {
249
  update_option('gwolle_gb-admin_style', 'false');
250
  }
251
 
252
+ if (isset($_POST['navigation']) && (int) $_POST['navigation'] === 0) {
253
  update_option('gwolle_gb-navigation', 0);
254
+ } else if (isset($_POST['navigation']) && (int) $_POST['navigation'] === 1) {
255
  update_option('gwolle_gb-navigation', 1);
256
  }
257
 
258
+ if (isset($_POST['paginate_all']) && $_POST['paginate_all'] === 'on') {
259
  update_option('gwolle_gb-paginate_all', 'true');
260
  } else {
261
  update_option('gwolle_gb-paginate_all', 'false');
262
  }
263
 
264
+ $list = array(
265
  'read_avatar',
266
  'read_name',
267
  'read_city',
269
  'read_date',
270
  'read_content',
271
  'read_aavatar',
272
+ 'read_editlink',
273
  );
274
+ $read_setting = array();
275
  foreach ( $list as $item ) {
276
+ if ( isset($_POST["$item"]) && $_POST["$item"] === 'on' ) {
277
  $read_setting["$item"] = 'true';
278
  } else {
279
  $read_setting["$item"] = 'false';
281
  }
282
  update_option( 'gwolle_gb-read', $read_setting );
283
  break;
 
284
 
285
+ case 'gwolle_gb_admin':
286
  /* Check Nonce */
287
  $verified = false;
288
  if ( isset($_POST['gwolle_gb_page_settings_admintab']) ) {
289
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_admintab'], 'gwolle_gb_page_settings_admintab' );
290
  }
291
+ if ( $verified === false ) {
292
  // Nonce is invalid.
293
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
294
  break;
298
  update_option( 'gwolle_gb-entries_per_page', (int) $_POST['entries_per_page']);
299
  }
300
 
301
+ if (isset($_POST['showEntryIcons']) && $_POST['showEntryIcons'] === 'on') {
302
  update_option('gwolle_gb-showEntryIcons', 'true');
303
  } else {
304
  update_option('gwolle_gb-showEntryIcons', 'false');
305
  }
 
306
  break;
 
307
 
308
+ case 'gwolle_gb_antispam':
309
  /* Check Nonce */
310
  $verified = false;
311
  if ( isset($_POST['gwolle_gb_page_settings_antispamtab']) ) {
312
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_antispamtab'], 'gwolle_gb_page_settings_antispamtab' );
313
  }
314
+ if ( $verified === false ) {
315
  // Nonce is invalid.
316
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
317
  break;
318
  }
319
 
320
+ if (isset($_POST['moderate-entries']) && $_POST['moderate-entries'] === 'on') {
321
  update_option('gwolle_gb-moderate-entries', 'true');
322
  } else {
323
  update_option('gwolle_gb-moderate-entries', 'false');
324
  }
325
 
326
+ if (isset($_POST['refuse-spam']) && $_POST['refuse-spam'] === 'on') {
327
  update_option('gwolle_gb-refuse-spam', 'true');
328
  } else {
329
  update_option('gwolle_gb-refuse-spam', 'false');
330
  }
331
 
332
+ if (isset($_POST['honeypot']) && $_POST['honeypot'] === 'on') {
333
  update_option('gwolle_gb-honeypot', 'true');
334
  } else {
335
  update_option('gwolle_gb-honeypot', 'false');
336
  }
337
 
338
+ if (isset($_POST['gwolle_gb_nonce']) && $_POST['gwolle_gb_nonce'] === 'on') {
339
  update_option('gwolle_gb-nonce', 'true');
340
  } else {
341
  update_option('gwolle_gb-nonce', 'false');
342
  }
343
 
344
+ if (isset($_POST['gwolle_gb_longtext']) && $_POST['gwolle_gb_longtext'] === 'on') {
345
  update_option('gwolle_gb-longtext', 'true');
346
  } else {
347
  update_option('gwolle_gb-longtext', 'false');
348
  }
349
 
350
+ if (isset($_POST['gwolle_gb_linkchecker']) && $_POST['gwolle_gb_linkchecker'] === 'on') {
351
  update_option('gwolle_gb-linkchecker', 'true');
352
  } else {
353
  update_option('gwolle_gb-linkchecker', 'false');
354
  }
355
 
356
+ if (isset($_POST['gwolle_gb_timeout']) && $_POST['gwolle_gb_timeout'] === 'on') {
357
  update_option('gwolle_gb-timeout', 'true');
358
  } else {
359
  update_option('gwolle_gb-timeout', 'false');
360
  }
361
 
362
+ if (isset($_POST['akismet-active']) && $_POST['akismet-active'] === 'on') {
363
  update_option('gwolle_gb-akismet-active', 'true');
364
  } else {
365
  update_option('gwolle_gb-akismet-active', 'false');
366
  }
367
 
368
+ if (isset($_POST['gwolle_gb_sfs']) && $_POST['gwolle_gb_sfs'] === 'on') {
369
  update_option('gwolle_gb-sfs', 'true');
370
  } else {
371
  update_option('gwolle_gb-sfs', 'false');
386
  $blocklist = implode( "\n", $blocklist );
387
  update_option('gwolle_gb_addon-moderation_keys', $blocklist);
388
  }
 
389
  break;
 
390
 
391
+ case 'gwolle_gb_mail':
392
  /* Check Nonce */
393
  $verified = false;
394
  if ( isset($_POST['gwolle_gb_page_settings_emailtab']) ) {
395
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_emailtab'], 'gwolle_gb_page_settings_emailtab' );
396
  }
397
+ if ( $verified === false ) {
398
  // Nonce is invalid.
399
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
400
  break;
401
  }
402
 
403
+ if ( isset($_POST['admin_mail_from']) && $_POST['admin_mail_from'] !== gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) ) {
404
  $admin_mail_from = gwolle_gb_sanitize_input( $_POST['admin_mail_from'] );
405
  if ( filter_var( $admin_mail_from, FILTER_VALIDATE_EMAIL ) ) {
406
  // Valid Email address.
410
 
411
  if ( isset($_POST['unsubscribe']) && $_POST['unsubscribe'] > 0 ) {
412
  $user_id = (int) $_POST['unsubscribe'];
413
+ $user_ids = array();
414
 
415
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
416
  if ( strlen($user_ids_old) > 0 ) {
417
+ $user_ids_old = explode( ',', $user_ids_old );
418
  foreach ( $user_ids_old as $user_id_old ) {
419
  if ( (int) $user_id_old === (int) $user_id ) {
420
  continue;
425
  }
426
  }
427
 
428
+ $user_ids = implode( ',', $user_ids );
429
  update_option('gwolle_gb-notifyByMail', $user_ids);
430
  }
431
 
432
  if ( isset($_POST['subscribe']) && $_POST['subscribe'] > 0 ) {
433
  $user_id = (int) $_POST['subscribe'];
434
+ $user_ids = array();
435
 
436
  $user_ids_old = get_option('gwolle_gb-notifyByMail' );
437
  if ( strlen($user_ids_old) > 0 ) {
438
+ $user_ids_old = explode( ',', $user_ids_old );
439
  foreach ( $user_ids_old as $user_id_old ) {
440
  if ( (int) $user_id_old === (int) $user_id ) {
441
  continue; // will be added again below the loop
447
  }
448
  $user_ids[] = $user_id; // Really add it.
449
 
450
+ $user_ids = implode( ',', $user_ids );
451
  update_option('gwolle_gb-notifyByMail', $user_ids);
452
  }
453
 
456
  update_option('gwolle_gb-adminMailContent', $mail_content);
457
  }
458
 
459
+ if (isset($_POST['mail_author']) && $_POST['mail_author'] === 'on') {
460
  update_option('gwolle_gb-mail_author', 'true');
461
  } else {
462
  update_option('gwolle_gb-mail_author', 'false');
467
  update_option('gwolle_gb-authorMailContent', $mail_content);
468
  }
469
 
470
+ if (isset($_POST['mail_author_moderation']) && $_POST['mail_author_moderation'] === 'on') {
471
  update_option('gwolle_gb-mail_author_moderation', 'true');
472
  } else {
473
  update_option('gwolle_gb-mail_author_moderation', 'false');
482
  $mail_content = gwolle_gb_sanitize_input( $_POST['gwolle_gb-mail_admin_replyContent'], 'setting_textarea' );
483
  update_option('gwolle_gb-mail_admin_replyContent', $mail_content);
484
  }
 
485
  break;
 
486
 
487
+ case 'gwolle_gb_debug':
488
  break;
 
489
 
490
+ case 'gwolle_gb_uninstall':
491
  /* Check Nonce */
492
  $verified = false;
493
  if ( isset($_POST['gwolle_gb_page_settings_uninstalltab']) ) {
494
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_uninstalltab'], 'gwolle_gb_page_settings_uninstalltab' );
495
  }
496
+ if ( $verified === false ) {
497
  // Nonce is invalid.
498
  gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
499
  break;
500
  }
501
 
502
+ if (isset($_POST['gwolle_gb_uninstall_confirmed']) && $_POST['gwolle_gb_uninstall_confirmed'] === 'on') {
503
+ if ( ! is_multisite() ) {
504
  // uninstall the plugin -> delete all tables and preferences of the plugin
505
  gwolle_gb_uninstall();
506
  gwolle_gb_add_message( '<p>' . esc_html__('The entries and settings have been removed.', 'gwolle-gb') . '</p>', false, false);
512
  } else {
513
  // Uninstallation not confirmed.
514
  }
 
515
  break;
516
+
517
  default:
518
  /* Just load the first tab */
519
  gwolle_gb_settings_active_tab( 'gwolle_gb_forms' );
520
+ break;
521
  }
522
  }
523
  }
admin/gb-pagination.php CHANGED
@@ -10,13 +10,13 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
10
  * gwolle_gb_pagination_admin
11
  * Pagination of the entries for the page-entries.php
12
  *
13
- * @param int $pageNum the number of the requested page.
14
  * @param int $pages_total the total number of pages.
15
  * @param int $count total number of entries. Relative to the $show variable.
16
  * @param string $show the tab of the page that is shown.
17
  * @return string $pagination the html of the pagination.
18
  */
19
- function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
20
 
21
  $num_entries = (int) get_option('gwolle_gb-entries_per_page', 20);
22
 
@@ -26,23 +26,23 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
26
  }
27
 
28
  // Calculate written text with info "Showing 1 – 25 of 54"
29
- if ($count == 0) {
30
  $firstentry = 0;
31
  $lastentry = 0;
32
  } else {
33
- $firstentry = ($pageNum - 1) * $num_entries + 1;
34
- $total_on_this_page = $count - ( ($pageNum - 1) * $num_entries );
35
  if ( $total_on_this_page > $num_entries ) {
36
  $total_on_this_page = $num_entries;
37
  }
38
- $lastentry = $firstentry + $total_on_this_page -1;
39
  }
40
 
41
  $pagination = '
42
  <h2 class="screen-reader-text">' . esc_html__('Guestbook list navigation', 'gwolle-gb') . '</h2>
43
  <div class="tablenav-pages">';
44
 
45
- $highDotsMade = false;
46
  $pages_done = array();
47
 
48
  $pagination .= '<span class="displaying-num">' . esc_html__('Showing:', 'gwolle-gb') .
@@ -50,71 +50,77 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
50
  ';
51
 
52
 
53
- if ($pageNum > 1) {
54
- $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($pageNum - 1) . '&book_id=' . $book_id );
55
  $pagination .= '<a class="first page-numbers button" href="' . $link . '" rel="prev">&larr;</a>';
56
  }
57
 
58
- if ($pageNum < 5) {
59
- $showRange = 5;
60
  if ($pages_total < 6) {
61
- $showRange = $pages_total;
62
- $highDotsMade = true; // no need for highdots.
63
  }
64
- for ($i = 1; $i < ($showRange + 1); $i++) {
65
- if ($i == $pageNum) {
66
- if ( in_array( $i, $pages_done ) ) { continue; }
 
 
67
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
68
  $pages_done[] = $i;
69
  } else {
70
- if ( in_array( $i, $pages_done ) ) { continue; }
 
 
71
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id );
72
  $pagination .= '<a class="page-numbers button" href="' . $link . '">' . $i . '</a>';
73
  $pages_done[] = $i;
74
- if ( $i == $pages_total ) { break; }
 
 
75
  }
76
  }
77
 
78
- if ( ($pageNum + 4 < $pages_total) && ( ! $highDotsMade) ) {
79
  $pagination .= '<span class="page-numbers dots">...</span>';
80
- $highDotsMade = true;
81
  }
82
- } elseif ($pageNum > 4) {
83
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=1&book_id=' . $book_id );
84
  $pagination .= '<a class="page-numbers button" href="' . $link . '">1</a>';
85
  if ($pages_total > 4) {
86
  $pagination .= '<span class="page-numbers dots">...</span>';
87
  }
88
- if ($pageNum + 2 < $pages_total) {
89
- $minRange = $pageNum - 2;
90
- $showRange = $pageNum + 2;
91
  } else {
92
- $minRange = $pageNum - 3;
93
- $showRange = $pages_total - 1;
94
  }
95
- for ($i = $minRange; $i <= $showRange; $i++) {
96
- if ($i == $pageNum) {
97
  $pagination .= '<span class="page-numbers button current">' . $i . '</span>';
98
  } else {
99
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id );
100
  $pagination .= '<a class="page-numbers button" href="' . $link . '">' . $i . '</a>';
101
  }
102
  }
103
- if ($pageNum == $pages_total) {
104
- $pagination .= '<span class="page-numbers button current">' . $pageNum . '</span>';
105
  }
106
  }
107
 
108
- if ($pageNum < $pages_total) {
109
- if ( ($pageNum + 3 < $pages_total) && ( ! $highDotsMade) ) {
110
  $pagination .= '<span class="page-numbers dots">...</span>';
111
- $highDotsMade = true;
112
  }
113
- if ( ! in_array( $pages_total, $pages_done ) ) {
114
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $pages_total . '&book_id=' . $book_id );
115
  $pagination .= '<a class="page-numbers button" href="' . $link . '">' . $pages_total . '</a>';
116
  }
117
- $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($pageNum + 1) . '&book_id=' . $book_id );
118
  $pagination .= '<a class="last page-numbers button" href="' . $link . '" rel="next">&rarr;</a>';
119
  }
120
 
10
  * gwolle_gb_pagination_admin
11
  * Pagination of the entries for the page-entries.php
12
  *
13
+ * @param int $page_num the number of the requested page.
14
  * @param int $pages_total the total number of pages.
15
  * @param int $count total number of entries. Relative to the $show variable.
16
  * @param string $show the tab of the page that is shown.
17
  * @return string $pagination the html of the pagination.
18
  */
19
+ function gwolle_gb_pagination_admin( $page_num, $pages_total, $count, $show ) {
20
 
21
  $num_entries = (int) get_option('gwolle_gb-entries_per_page', 20);
22
 
26
  }
27
 
28
  // Calculate written text with info "Showing 1 – 25 of 54"
29
+ if ($count === 0) {
30
  $firstentry = 0;
31
  $lastentry = 0;
32
  } else {
33
+ $firstentry = ( ( $page_num - 1 ) * $num_entries ) + 1;
34
+ $total_on_this_page = $count - ( ( ( $page_num - 1 ) * $num_entries ) );
35
  if ( $total_on_this_page > $num_entries ) {
36
  $total_on_this_page = $num_entries;
37
  }
38
+ $lastentry = $firstentry + $total_on_this_page - 1;
39
  }
40
 
41
  $pagination = '
42
  <h2 class="screen-reader-text">' . esc_html__('Guestbook list navigation', 'gwolle-gb') . '</h2>
43
  <div class="tablenav-pages">';
44
 
45
+ $high_dots_made = false;
46
  $pages_done = array();
47
 
48
  $pagination .= '<span class="displaying-num">' . esc_html__('Showing:', 'gwolle-gb') .
50
  ';
51
 
52
 
53
+ if ($page_num > 1) {
54
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($page_num - 1) . '&book_id=' . $book_id );
55
  $pagination .= '<a class="first page-numbers button" href="' . $link . '" rel="prev">&larr;</a>';
56
  }
57
 
58
+ if ($page_num < 5) {
59
+ $show_range = 5;
60
  if ($pages_total < 6) {
61
+ $show_range = $pages_total;
62
+ $high_dots_made = true; // no need for highdots.
63
  }
64
+ for ( $i = 1; $i < ( $show_range + 1 ); $i++ ) {
65
+ if ($i === $page_num) {
66
+ if ( in_array( $i, $pages_done, true ) ) {
67
+ continue;
68
+ }
69
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
70
  $pages_done[] = $i;
71
  } else {
72
+ if ( in_array( $i, $pages_done, true ) ) {
73
+ continue;
74
+ }
75
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id );
76
  $pagination .= '<a class="page-numbers button" href="' . $link . '">' . $i . '</a>';
77
  $pages_done[] = $i;
78
+ if ( $i === $pages_total ) {
79
+ break;
80
+ }
81
  }
82
  }
83
 
84
+ if ( ( $page_num + 4 < $pages_total ) && ( ! $high_dots_made ) ) {
85
  $pagination .= '<span class="page-numbers dots">...</span>';
86
+ $high_dots_made = true;
87
  }
88
+ } else if ($page_num > 4) {
89
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=1&book_id=' . $book_id );
90
  $pagination .= '<a class="page-numbers button" href="' . $link . '">1</a>';
91
  if ($pages_total > 4) {
92
  $pagination .= '<span class="page-numbers dots">...</span>';
93
  }
94
+ if ( ( $page_num + 2 ) < $pages_total ) {
95
+ $min_range = $page_num - 2;
96
+ $show_range = $page_num + 2;
97
  } else {
98
+ $min_range = $page_num - 3;
99
+ $show_range = $pages_total - 1;
100
  }
101
+ for ($i = $min_range; $i <= $show_range; $i++) {
102
+ if ($i === $page_num) {
103
  $pagination .= '<span class="page-numbers button current">' . $i . '</span>';
104
  } else {
105
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id );
106
  $pagination .= '<a class="page-numbers button" href="' . $link . '">' . $i . '</a>';
107
  }
108
  }
109
+ if ($page_num === $pages_total) {
110
+ $pagination .= '<span class="page-numbers button current">' . $page_num . '</span>';
111
  }
112
  }
113
 
114
+ if ( $page_num < $pages_total ) {
115
+ if ( ( $page_num + 3 < $pages_total ) && ( ! $high_dots_made ) ) {
116
  $pagination .= '<span class="page-numbers dots">...</span>';
117
+ $high_dots_made = true;
118
  }
119
+ if ( ! in_array( $pages_total, $pages_done, true ) ) {
120
  $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $pages_total . '&book_id=' . $book_id );
121
  $pagination .= '<a class="page-numbers button" href="' . $link . '">' . $pages_total . '</a>';
122
  }
123
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($page_num + 1) . '&book_id=' . $book_id );
124
  $pagination .= '<a class="last page-numbers button" href="' . $link . '" rel="next">&rarr;</a>';
125
  }
126
 
admin/gb-upgrade.php CHANGED
@@ -65,7 +65,7 @@ function gwolle_gb_install() {
65
  $result = $wpdb->query($sql);
66
 
67
  /* Upgrade to new shiny db collation. Since WP 4.2 */
68
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
69
  if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
70
  if ( 'utf8mb4' === $wpdb->charset ) {
71
  maybe_convert_table_to_utf8mb4( $wpdb->gwolle_gb_entries );
@@ -79,7 +79,7 @@ function gwolle_gb_install() {
79
  /* Save plugin version to database only when we did install. */
80
  $result_after = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_entries'");
81
  $result_after2 = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_log'");
82
- if ( $result_after != 0 && $result_after2 != 0 ) {
83
  add_option('gwolle_gb_version', GWOLLE_GB_VER);
84
  }
85
 
@@ -136,7 +136,7 @@ function gwolle_gb_upgrade() {
136
  * 0.9 -> 0.9.1
137
  * Moved the email notification options to the WP options table.
138
  */
139
- $notifyUser = "
140
  SELECT *
141
  FROM
142
  " . $wpdb -> prefix . "gwolle_gb_settings
@@ -145,10 +145,10 @@ function gwolle_gb_upgrade() {
145
  AND
146
  setting_value = '1'
147
  ";
148
- $notifySettings = $wpdb->get_results($notifyUser, ARRAY_A);
149
- foreach ( $notifySettings as $notifySetting ) {
150
  // Add an option for each notification subscriber.
151
- add_option('gwolle_gb-notifyByMail-' . $notifySetting['user_id'], 'true');
152
  }
153
 
154
  // Delete the old settings table.
@@ -178,7 +178,7 @@ function gwolle_gb_upgrade() {
178
  add_option('gwolle_gb-akismet-active', 'false');
179
  $wpdb->query("
180
  ALTER
181
- TABLE " . $wpdb -> gwolle_gb_entries . "
182
  ADD
183
  entry_isSpam
184
  VARCHAR( 1 )
@@ -196,14 +196,14 @@ function gwolle_gb_upgrade() {
196
  add_option('gwolle_gb-access-level', '10');
197
  add_option('gwolle_gb-moderate-entries', 'true');
198
 
199
- $emailNotification = "
200
  SELECT *
201
  FROM
202
- " . $wpdb -> prefix . "options
203
  WHERE
204
  option_name LIKE 'gwolle_gb-notifyByMail-%'
205
  ";
206
- $notifications = $wpdb->get_results($emailNotification, ARRAY_A);
207
  foreach ( $notifications as $notification ) {
208
  add_option('gwolle_gb-notifyAll-' . str_replace('gwolle_gb-notifyByMail-', '', $notification['option_name']), 'true');
209
  }
@@ -212,7 +212,7 @@ function gwolle_gb_upgrade() {
212
  if (version_compare($installed_ver, '0.9.4.1', '<')) {
213
  /*
214
  ** 0.9.4->0.9.4.1
215
- ** Caching the Wordpress API key so that we don't need to
216
  ** validate it each time the user opens the settings panel.
217
  ** Also, add an option to show icons in the entry list.
218
  */
@@ -331,10 +331,10 @@ function gwolle_gb_upgrade() {
331
  ORDER BY
332
  option_name
333
  ";
334
- $notifyUser_result = $wpdb->get_results($sql, ARRAY_A);
335
- if ( count($notifyUser_result) > 0 ) {
336
- $user_ids = Array();
337
- foreach ( $notifyUser_result as $option ) {
338
  $user_id = (int) str_replace('gwolle_gb-notifyByMail-', '', $option['option_name']);
339
  $user_info = get_userdata($user_id);
340
  if ($user_info === FALSE) {
@@ -415,9 +415,8 @@ function gwolle_gb_upgrade() {
415
  */
416
  delete_option('gwolle_gb-guestbookOnly');
417
  delete_option('gwolle_gb-defaultMailText');
418
- if ( get_option('gwolle_gb-recaptcha-active', 'false') == 'true' ) {
419
- $form_setting = Array( 'form_recaptcha_enabled' => 'true' );
420
- $form_setting = serialize( $form_setting );
421
  update_option( 'gwolle_gb-form', $form_setting );
422
  }
423
  delete_option('gwolle_gb-recaptcha-active');
@@ -519,7 +518,7 @@ function gwolle_gb_upgrade() {
519
  }
520
 
521
  /* Upgrade to new shiny db collation. Since WP 4.2 */
522
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
523
  if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
524
  if ( 'utf8mb4' === $wpdb->charset ) {
525
  maybe_convert_table_to_utf8mb4( $wpdb->gwolle_gb_entries );
@@ -542,23 +541,23 @@ function gwolle_gb_upgrade() {
542
  * @since 2.5.0
543
  */
544
  function gwolle_gb_set_defaults() {
545
- if ( get_option('gwolle_gb-admin_style', false) == false ) {
546
  update_option( 'gwolle_gb-admin_style', 'false' );
547
  }
548
- if ( get_option('gwolle_gb-akismet-active', false) == false ) {
549
  update_option( 'gwolle_gb-akismet-active', 'false' );
550
  }
551
- if ( get_option('gwolle_gb-entries_per_page', false) == false ) {
552
  update_option( 'gwolle_gb-entries_per_page', 20 );
553
  }
554
- if ( get_option('gwolle_gb-entriesPerPage', false) == false ) {
555
  update_option( 'gwolle_gb-entriesPerPage', 20 );
556
  }
557
  if ( get_option('gwolle_gb-excerpt_length', false) === false ) {
558
  update_option( 'gwolle_gb-excerpt_length', 0 );
559
  }
560
- if ( get_option('gwolle_gb-form', false) == false ) {
561
- $defaults = Array(
562
  'form_name_enabled' => 'true',
563
  'form_name_mandatory' => 'true',
564
  'form_city_enabled' => 'true',
@@ -569,60 +568,61 @@ function gwolle_gb_set_defaults() {
569
  'form_homepage_mandatory' => 'false',
570
  'form_message_enabled' => 'true',
571
  'form_message_mandatory' => 'true',
 
572
  'form_bbcode_enabled' => 'false',
573
  'form_antispam_enabled' => 'false',
574
  'form_recaptcha_enabled' => 'false',
575
- 'form_privacy_enabled' => 'false'
576
  );
577
  update_option( 'gwolle_gb-form', $defaults );
578
  }
579
- if ( get_option('gwolle_gb-form_ajax', false) == false ) {
580
  update_option( 'gwolle_gb-form_ajax', 'true' );
581
  }
582
- if ( get_option('gwolle_gb-honeypot', false) == false ) {
583
  update_option( 'gwolle_gb-honeypot', 'true' );
584
  }
585
- if ( get_option('gwolle_gb-honeypot_value', false) == false ) {
586
  $random = rand( 1, 99 );
587
  update_option( 'gwolle_gb-honeypot_value', $random );
588
  }
589
- if ( get_option('gwolle_gb-labels_float', false) == false ) {
590
  update_option( 'gwolle_gb-labels_float', 'true' );
591
  }
592
- if ( get_option('gwolle_gb-linkAuthorWebsite', false) == false ) {
593
  update_option( 'gwolle_gb-linkAuthorWebsite', 'true' );
594
  }
595
- if ( get_option('gwolle_gb-linkchecker', false) == false ) {
596
  update_option( 'gwolle_gb-linkchecker', 'true' );
597
  }
598
- if ( get_option('gwolle_gb-longtext', false) == false ) {
599
  update_option( 'gwolle_gb-longtext', 'true' );
600
  }
601
- if ( get_option('gwolle_gb-mail_author', false) == false ) {
602
  update_option( 'gwolle_gb-mail_author', 'false' );
603
  }
604
- if ( get_option('gwolle_gb-mail_author_moderation', false) == false ) {
605
  update_option( 'gwolle_gb-mail_author_moderation', 'false' );
606
  }
607
- if ( get_option('gwolle_gb-moderate-entries', false) == false ) {
608
  update_option( 'gwolle_gb-moderate-entries', 'true' );
609
  }
610
  if ( get_option('gwolle_gb-navigation', false) === false ) {
611
  update_option( 'gwolle_gb-navigation', 0 );
612
  }
613
- if ( get_option('gwolle_gb-nonce', false) == false ) {
614
  update_option( 'gwolle_gb-nonce', 'true' );
615
  }
616
- if ( get_option('gwolle_gb-paginate_all', false) == false ) {
617
  update_option( 'gwolle_gb-paginate_all', 'false' );
618
  }
619
- if ( get_option('gwolle_gb-read', false) == false ) {
620
  if ( get_option('show_avatars') ) {
621
  $avatar = 'true';
622
  } else {
623
  $avatar = 'false';
624
  }
625
- $defaults = Array(
626
  'read_avatar' => $avatar,
627
  'read_name' => 'true',
628
  'read_city' => 'true',
@@ -630,32 +630,32 @@ function gwolle_gb_set_defaults() {
630
  'read_date' => 'false',
631
  'read_content' => 'true',
632
  'read_aavatar' => 'false',
633
- 'read_editlink' => 'true'
634
  );
635
  update_option( 'gwolle_gb-read', $defaults );
636
  }
637
- if ( get_option('gwolle_gb-refuse-spam', false) == false ) {
638
  update_option( 'gwolle_gb-refuse-spam', 'false' );
639
  }
640
- if ( get_option('gwolle_gb-require_login', false) == false ) {
641
  update_option( 'gwolle_gb-require_login', 'false' );
642
  }
643
- if ( get_option('gwolle_gb-sfs', false) == false ) {
644
  update_option( 'gwolle_gb-sfs', 'false' );
645
  }
646
- if ( get_option('gwolle_gb-store_ip', false) == false ) {
647
  update_option( 'gwolle_gb-store_ip', 'true' );
648
  }
649
- if ( get_option('gwolle_gb-showEntryIcons', false) == false ) {
650
  update_option( 'gwolle_gb-showEntryIcons', 'true' );
651
  }
652
- if ( get_option('gwolle_gb-showLineBreaks', false) == false ) {
653
  update_option( 'gwolle_gb-showLineBreaks', 'false' );
654
  }
655
- if ( get_option('gwolle_gb-showSmilies', false) == false ) {
656
  update_option( 'gwolle_gb-showSmilies', 'true' );
657
  }
658
- if ( get_option('gwolle_gb-timeout', false) == false ) {
659
  update_option( 'gwolle_gb-timeout', 'true' );
660
  }
661
  }
65
  $result = $wpdb->query($sql);
66
 
67
  /* Upgrade to new shiny db collation. Since WP 4.2 */
68
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
69
  if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
70
  if ( 'utf8mb4' === $wpdb->charset ) {
71
  maybe_convert_table_to_utf8mb4( $wpdb->gwolle_gb_entries );
79
  /* Save plugin version to database only when we did install. */
80
  $result_after = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_entries'");
81
  $result_after2 = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_log'");
82
+ if ( $result_after !== 0 && $result_after2 !== 0 ) {
83
  add_option('gwolle_gb_version', GWOLLE_GB_VER);
84
  }
85
 
136
  * 0.9 -> 0.9.1
137
  * Moved the email notification options to the WP options table.
138
  */
139
+ $notify_user = "
140
  SELECT *
141
  FROM
142
  " . $wpdb -> prefix . "gwolle_gb_settings
145
  AND
146
  setting_value = '1'
147
  ";
148
+ $notify_settings = $wpdb->get_results($notify_user, ARRAY_A);
149
+ foreach ( $notify_settings as $notify_setting ) {
150
  // Add an option for each notification subscriber.
151
+ add_option('gwolle_gb-notifyByMail-' . $notify_setting['user_id'], 'true');
152
  }
153
 
154
  // Delete the old settings table.
178
  add_option('gwolle_gb-akismet-active', 'false');
179
  $wpdb->query("
180
  ALTER
181
+ TABLE " . $wpdb->gwolle_gb_entries . "
182
  ADD
183
  entry_isSpam
184
  VARCHAR( 1 )
196
  add_option('gwolle_gb-access-level', '10');
197
  add_option('gwolle_gb-moderate-entries', 'true');
198
 
199
+ $email_notification = "
200
  SELECT *
201
  FROM
202
+ " . $wpdb->prefix . "options
203
  WHERE
204
  option_name LIKE 'gwolle_gb-notifyByMail-%'
205
  ";
206
+ $notifications = $wpdb->get_results($email_notification, ARRAY_A);
207
  foreach ( $notifications as $notification ) {
208
  add_option('gwolle_gb-notifyAll-' . str_replace('gwolle_gb-notifyByMail-', '', $notification['option_name']), 'true');
209
  }
212
  if (version_compare($installed_ver, '0.9.4.1', '<')) {
213
  /*
214
  ** 0.9.4->0.9.4.1
215
+ ** Caching the WordPress API key so that we don't need to
216
  ** validate it each time the user opens the settings panel.
217
  ** Also, add an option to show icons in the entry list.
218
  */
331
  ORDER BY
332
  option_name
333
  ";
334
+ $notify_user_result = $wpdb->get_results($sql, ARRAY_A);
335
+ if ( count($notify_user_result) > 0 ) {
336
+ $user_ids = array();
337
+ foreach ( $notify_user_result as $option ) {
338
  $user_id = (int) str_replace('gwolle_gb-notifyByMail-', '', $option['option_name']);
339
  $user_info = get_userdata($user_id);
340
  if ($user_info === FALSE) {
415
  */
416
  delete_option('gwolle_gb-guestbookOnly');
417
  delete_option('gwolle_gb-defaultMailText');
418
+ if ( get_option('gwolle_gb-recaptcha-active', 'false') === 'true' ) {
419
+ $form_setting = array( 'form_recaptcha_enabled' => 'true' );
 
420
  update_option( 'gwolle_gb-form', $form_setting );
421
  }
422
  delete_option('gwolle_gb-recaptcha-active');
518
  }
519
 
520
  /* Upgrade to new shiny db collation. Since WP 4.2 */
521
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
522
  if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
523
  if ( 'utf8mb4' === $wpdb->charset ) {
524
  maybe_convert_table_to_utf8mb4( $wpdb->gwolle_gb_entries );
541
  * @since 2.5.0
542
  */
543
  function gwolle_gb_set_defaults() {
544
+ if ( get_option('gwolle_gb-admin_style', false) === false ) {
545
  update_option( 'gwolle_gb-admin_style', 'false' );
546
  }
547
+ if ( get_option('gwolle_gb-akismet-active', false) === false ) {
548
  update_option( 'gwolle_gb-akismet-active', 'false' );
549
  }
550
+ if ( get_option('gwolle_gb-entries_per_page', false) === false ) {
551
  update_option( 'gwolle_gb-entries_per_page', 20 );
552
  }
553
+ if ( get_option('gwolle_gb-entriesPerPage', false) === false ) {
554
  update_option( 'gwolle_gb-entriesPerPage', 20 );
555
  }
556
  if ( get_option('gwolle_gb-excerpt_length', false) === false ) {
557
  update_option( 'gwolle_gb-excerpt_length', 0 );
558
  }
559
+ if ( get_option('gwolle_gb-form', false) === false ) {
560
+ $defaults = array(
561
  'form_name_enabled' => 'true',
562
  'form_name_mandatory' => 'true',
563
  'form_city_enabled' => 'true',
568
  'form_homepage_mandatory' => 'false',
569
  'form_message_enabled' => 'true',
570
  'form_message_mandatory' => 'true',
571
+ 'form_message_maxlength' => 0,
572
  'form_bbcode_enabled' => 'false',
573
  'form_antispam_enabled' => 'false',
574
  'form_recaptcha_enabled' => 'false',
575
+ 'form_privacy_enabled' => 'false',
576
  );
577
  update_option( 'gwolle_gb-form', $defaults );
578
  }
579
+ if ( get_option('gwolle_gb-form_ajax', false) === false ) {
580
  update_option( 'gwolle_gb-form_ajax', 'true' );
581
  }
582
+ if ( get_option('gwolle_gb-honeypot', false) === false ) {
583
  update_option( 'gwolle_gb-honeypot', 'true' );
584
  }
585
+ if ( get_option('gwolle_gb-honeypot_value', false) === false ) {
586
  $random = rand( 1, 99 );
587
  update_option( 'gwolle_gb-honeypot_value', $random );
588
  }
589
+ if ( get_option('gwolle_gb-labels_float', false) === false ) {
590
  update_option( 'gwolle_gb-labels_float', 'true' );
591
  }
592
+ if ( get_option('gwolle_gb-linkAuthorWebsite', false) === false ) {
593
  update_option( 'gwolle_gb-linkAuthorWebsite', 'true' );
594
  }
595
+ if ( get_option('gwolle_gb-linkchecker', false) === false ) {
596
  update_option( 'gwolle_gb-linkchecker', 'true' );
597
  }
598
+ if ( get_option('gwolle_gb-longtext', false) === false ) {
599
  update_option( 'gwolle_gb-longtext', 'true' );
600
  }
601
+ if ( get_option('gwolle_gb-mail_author', false) === false ) {
602
  update_option( 'gwolle_gb-mail_author', 'false' );
603
  }
604
+ if ( get_option('gwolle_gb-mail_author_moderation', false) === false ) {
605
  update_option( 'gwolle_gb-mail_author_moderation', 'false' );
606
  }
607
+ if ( get_option('gwolle_gb-moderate-entries', false) === false ) {
608
  update_option( 'gwolle_gb-moderate-entries', 'true' );
609
  }
610
  if ( get_option('gwolle_gb-navigation', false) === false ) {
611
  update_option( 'gwolle_gb-navigation', 0 );
612
  }
613
+ if ( get_option('gwolle_gb-nonce', false) === false ) {
614
  update_option( 'gwolle_gb-nonce', 'true' );
615
  }
616
+ if ( get_option('gwolle_gb-paginate_all', false) === false ) {
617
  update_option( 'gwolle_gb-paginate_all', 'false' );
618
  }
619
+ if ( get_option('gwolle_gb-read', false) === false ) {
620
  if ( get_option('show_avatars') ) {
621
  $avatar = 'true';
622
  } else {
623
  $avatar = 'false';
624
  }
625
+ $defaults = array(
626
  'read_avatar' => $avatar,
627
  'read_name' => 'true',
628
  'read_city' => 'true',
630
  'read_date' => 'false',
631
  'read_content' => 'true',
632
  'read_aavatar' => 'false',
633
+ 'read_editlink' => 'true',
634
  );
635
  update_option( 'gwolle_gb-read', $defaults );
636
  }
637
+ if ( get_option('gwolle_gb-refuse-spam', false) === false ) {
638
  update_option( 'gwolle_gb-refuse-spam', 'false' );
639
  }
640
+ if ( get_option('gwolle_gb-require_login', false) === false ) {
641
  update_option( 'gwolle_gb-require_login', 'false' );
642
  }
643
+ if ( get_option('gwolle_gb-sfs', false) === false ) {
644
  update_option( 'gwolle_gb-sfs', 'false' );
645
  }
646
+ if ( get_option('gwolle_gb-store_ip', false) === false ) {
647
  update_option( 'gwolle_gb-store_ip', 'true' );
648
  }
649
+ if ( get_option('gwolle_gb-showEntryIcons', false) === false ) {
650
  update_option( 'gwolle_gb-showEntryIcons', 'true' );
651
  }
652
+ if ( get_option('gwolle_gb-showLineBreaks', false) === false ) {
653
  update_option( 'gwolle_gb-showLineBreaks', 'false' );
654
  }
655
+ if ( get_option('gwolle_gb-showSmilies', false) === false ) {
656
  update_option( 'gwolle_gb-showSmilies', 'true' );
657
  }
658
+ if ( get_option('gwolle_gb-timeout', false) === false ) {
659
  update_option( 'gwolle_gb-timeout', 'true' );
660
  }
661
  }
admin/gwolle-gb-hooks.php CHANGED
@@ -21,9 +21,7 @@ function gwolle_gb_adminmenu() {
21
  /*
22
  * How to add new menu-entries:
23
  * add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '' )
24
- */
25
-
26
- /*
27
  * How to add new sub-menu-entries:
28
  * add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null )
29
  */
@@ -35,7 +33,7 @@ function gwolle_gb_adminmenu() {
35
  array(
36
  'checked' => 'unchecked',
37
  'trash' => 'notrash',
38
- 'spam' => 'nospam'
39
  )
40
  );
41
  set_transient( 'gwolle_gb_menu_counter', $count_unchecked, DAY_IN_SECONDS );
@@ -102,8 +100,8 @@ function gwolle_gb_admin_enqueue() {
102
  * Add Settings link to the main plugin page
103
  */
104
  function gwolle_gb_links( $links, $file ) {
105
- if ( $file == GWOLLE_GB_FOLDER . '/gwolle-gb.php' ) {
106
- $links[] = '<a href="' . admin_url( 'admin.php?page=gwolle-gb/settings.php' ) . '">' . esc_html__( 'Settings', 'gwolle-gb' ).'</a>';
107
  }
108
  return $links;
109
  }
@@ -121,7 +119,7 @@ function gwolle_gb_multisite_uninstall() {
121
  global $wpdb;
122
 
123
  if ( is_admin() ) {
124
- if ( function_exists('is_multisite') && is_multisite() ) {
125
  $do_uninstall = apply_filters( 'gwolle_gb_multisite_uninstall', false );
126
  if ( $do_uninstall ) {
127
  $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
@@ -160,7 +158,7 @@ function gwolle_gb_deps_admin_notice() {
160
 
161
  $active = is_plugin_active( 'gwolle-gb-addon/gwolle-gb-addon.php' ); // true or false
162
  if ( $active && defined( 'GWOLLE_GB_ADDON_VER' ) ) {
163
- $zeno_el = '<a href="https://zenoweb.nl/downloads/gwolle-guestbook-add-on/" target="_blank">';
164
  $zeno_el_close = '</a>';
165
  $required_version = '2.0.0';
166
 
@@ -168,7 +166,7 @@ function gwolle_gb_deps_admin_notice() {
168
  return; // We have the minimal version.
169
  }
170
 
171
- $message = sprintf( esc_html__( 'Gwolle Guestbook: This version of the Gwolle Guestbook Add-On is too old for this version of Gwolle Guestbook, you need at least %s. You have version %s. Go to the %sZenoWeb Webshop%s and login, download and update the Add-On.', 'gwolle-gb' ), $required_version, GWOLLE_GB_ADDON_VER, $zeno_el, $zeno_el_close );
172
  printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), $message );
173
 
174
  }
21
  /*
22
  * How to add new menu-entries:
23
  * add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '' )
24
+ *
 
 
25
  * How to add new sub-menu-entries:
26
  * add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null )
27
  */
33
  array(
34
  'checked' => 'unchecked',
35
  'trash' => 'notrash',
36
+ 'spam' => 'nospam',
37
  )
38
  );
39
  set_transient( 'gwolle_gb_menu_counter', $count_unchecked, DAY_IN_SECONDS );
100
  * Add Settings link to the main plugin page
101
  */
102
  function gwolle_gb_links( $links, $file ) {
103
+ if ( $file === GWOLLE_GB_FOLDER . '/gwolle-gb.php' ) {
104
+ $links[] = '<a href="' . admin_url( 'admin.php?page=gwolle-gb/settings.php' ) . '">' . esc_html__( 'Settings', 'gwolle-gb' ) . '</a>';
105
  }
106
  return $links;
107
  }
119
  global $wpdb;
120
 
121
  if ( is_admin() ) {
122
+ if ( is_multisite() ) {
123
  $do_uninstall = apply_filters( 'gwolle_gb_multisite_uninstall', false );
124
  if ( $do_uninstall ) {
125
  $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
158
 
159
  $active = is_plugin_active( 'gwolle-gb-addon/gwolle-gb-addon.php' ); // true or false
160
  if ( $active && defined( 'GWOLLE_GB_ADDON_VER' ) ) {
161
+ $zeno_el = '<a href="https://zenoweb.nl/downloads/gwolle-guestbook-add-on/" target="_blank">';
162
  $zeno_el_close = '</a>';
163
  $required_version = '2.0.0';
164
 
166
  return; // We have the minimal version.
167
  }
168
 
169
+ $message = sprintf( esc_html__( 'Gwolle Guestbook: This version of the Gwolle Guestbook Add-On is too old for this version of Gwolle Guestbook, you need at least %1$s. You have version %2$s. Go to the %3$sZenoWeb Webshop%4$s and login, download and update the Add-On.', 'gwolle-gb' ), $required_version, GWOLLE_GB_ADDON_VER, $zeno_el, $zeno_el_close );
170
  printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), $message );
171
 
172
  }
admin/js/gwolle-gb-admin.js CHANGED
@@ -85,7 +85,7 @@ jQuery(document).ready(function($) {
85
  var hh = jQuery("#hh").val();
86
  var mn = jQuery("#mn").val();
87
 
88
- var gwolle_date = new Date( yy, mm - 1, dd, hh, mn );
89
  readable_time = gwolle_date.toUTCString();
90
  readable_time = readable_time.replace(/GMT/i, '');
91
  var timestamp = Math.round( gwolle_date.getTime() / 1000 );
@@ -229,14 +229,14 @@ jQuery(document).ready(function($) {
229
  var parts = parseFloat( jQuery("#gwolle_gb_export_parts").val() );
230
 
231
  for ( var part = 1; part < (parts + 1); part++ ) {
232
- var timeout = (part - 1) * 10000;
233
  gwolle_gb_export_part( part, timeout );
234
  }
235
 
236
  setTimeout(
237
  function() {
238
  jQuery( ".gwolle_gb_export_gif" ).css( 'visibility', 'hidden' );
239
- }, ( (part - 1) * 10000 )
240
  );
241
 
242
  event.preventDefault();
85
  var hh = jQuery("#hh").val();
86
  var mn = jQuery("#mn").val();
87
 
88
+ var gwolle_date = new Date( yy, ( mm - 1 ), dd, hh, mn );
89
  readable_time = gwolle_date.toUTCString();
90
  readable_time = readable_time.replace(/GMT/i, '');
91
  var timestamp = Math.round( gwolle_date.getTime() / 1000 );
229
  var parts = parseFloat( jQuery("#gwolle_gb_export_parts").val() );
230
 
231
  for ( var part = 1; part < (parts + 1); part++ ) {
232
+ var timeout = ( part - 1 ) * 10000;
233
  gwolle_gb_export_part( part, timeout );
234
  }
235
 
236
  setTimeout(
237
  function() {
238
  jQuery( ".gwolle_gb_export_gif" ).css( 'visibility', 'hidden' );
239
+ }, ( (part - 1) * 10000 )
240
  );
241
 
242
  event.preventDefault();
admin/tabs/gb-admintab.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settingstab_admin() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
@@ -25,7 +25,7 @@ function gwolle_gb_page_settingstab_admin() {
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_admintab' );
28
- echo '<input type="hidden" id="gwolle_gb_page_settings_admintab" name="gwolle_gb_page_settings_admintab" value="' . $nonce . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
@@ -35,10 +35,11 @@ function gwolle_gb_page_settingstab_admin() {
35
  <td>
36
  <select name="entries_per_page" id="entries_per_page">
37
  <?php $entries_per_page = get_option( 'gwolle_gb-entries_per_page', 20 );
38
- $presets = array(5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150, 200, 250);
39
- for ($i = 0; $i < count($presets); $i++) {
40
- echo '<option value="' . $presets[$i] . '"';
41
- if ($presets[$i] == $entries_per_page) {
 
42
  echo ' selected="selected"';
43
  }
44
  echo '>' . $presets[$i] . ' ' . esc_html__('Entries', 'gwolle-gb') . '</option>';
14
  */
15
  function gwolle_gb_page_settingstab_admin() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_admintab' );
28
+ echo '<input type="hidden" id="gwolle_gb_page_settings_admintab" name="gwolle_gb_page_settings_admintab" value="' . esc_attr( $nonce ) . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
35
  <td>
36
  <select name="entries_per_page" id="entries_per_page">
37
  <?php $entries_per_page = get_option( 'gwolle_gb-entries_per_page', 20 );
38
+ $presets = array( 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150, 200, 250 );
39
+ $presets_count = count($presets);
40
+ for ($i = 0; $i < $presets_count; $i++) {
41
+ echo '<option value="' . (int) $presets[$i] . '"';
42
+ if ($presets[$i] === $entries_per_page) {
43
  echo ' selected="selected"';
44
  }
45
  echo '>' . $presets[$i] . ' ' . esc_html__('Entries', 'gwolle-gb') . '</option>';
admin/tabs/gb-antispamtab.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settingstab_antispam() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
@@ -25,7 +25,7 @@ function gwolle_gb_page_settingstab_antispam() {
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_antispamtab' );
28
- echo '<input type="hidden" id="gwolle_gb_page_settings_antispamtab" name="gwolle_gb_page_settings_antispamtab" value="' . $nonce . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
@@ -34,7 +34,7 @@ function gwolle_gb_page_settingstab_antispam() {
34
  <th scope="row"><label for="moderate-entries"><?php /* translators: Settings page, option for moderation */ esc_html_e('Moderate Guestbook', 'gwolle-gb'); ?></label></th>
35
  <td>
36
  <input <?php
37
- if (get_option( 'gwolle_gb-moderate-entries', 'true') == 'true') {
38
  echo 'checked="checked"';
39
  } ?>
40
  type="checkbox" name="moderate-entries" id="moderate-entries">
@@ -53,7 +53,7 @@ function gwolle_gb_page_settingstab_antispam() {
53
  <th scope="row"><label for="refuse-spam"><?php /* translators: Settings page, option for refusing spam */ esc_html_e('Refuse Spam', 'gwolle-gb'); ?></label></th>
54
  <td>
55
  <input <?php
56
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
57
  echo 'checked="checked"';
58
  } ?>
59
  type="checkbox" name="refuse-spam" id="refuse-spam">
@@ -72,7 +72,7 @@ function gwolle_gb_page_settingstab_antispam() {
72
  <th scope="row"><label for="honeypot"><?php esc_html_e('Honeypot', 'gwolle-gb'); ?></label></th>
73
  <td>
74
  <input <?php
75
- if (get_option( 'gwolle_gb-honeypot', 'true') == 'true') {
76
  echo 'checked="checked"';
77
  } ?>
78
  type="checkbox" name="honeypot" id="honeypot">
@@ -89,7 +89,7 @@ function gwolle_gb_page_settingstab_antispam() {
89
  <th scope="row"><label for="gwolle_gb_nonce"><?php esc_html_e('Nonce', 'gwolle-gb'); ?></label></th>
90
  <td>
91
  <input <?php
92
- if (get_option( 'gwolle_gb-nonce', 'true') == 'true') {
93
  echo 'checked="checked"';
94
  } ?>
95
  type="checkbox" name="gwolle_gb_nonce" id="gwolle_gb_nonce">
@@ -114,7 +114,7 @@ function gwolle_gb_page_settingstab_antispam() {
114
  <th scope="row"><label for="gwolle_gb_longtext"><?php esc_html_e('Long Text', 'gwolle-gb'); ?></label></th>
115
  <td>
116
  <input <?php
117
- if (get_option( 'gwolle_gb-longtext', 'true') == 'true') {
118
  echo 'checked="checked"';
119
  } ?>
120
  type="checkbox" name="gwolle_gb_longtext" id="gwolle_gb_longtext">
@@ -136,7 +136,7 @@ function gwolle_gb_page_settingstab_antispam() {
136
  <th scope="row"><label for="gwolle_gb_linkchecker"><?php esc_html_e('Link Checker', 'gwolle-gb'); ?></label></th>
137
  <td>
138
  <input <?php
139
- if (get_option( 'gwolle_gb-linkchecker', 'true') == 'true') {
140
  echo 'checked="checked"';
141
  } ?>
142
  type="checkbox" name="gwolle_gb_linkchecker" id="gwolle_gb_linkchecker">
@@ -155,7 +155,7 @@ function gwolle_gb_page_settingstab_antispam() {
155
  <th scope="row"><label for="gwolle_gb_timeout"><?php esc_html_e('Form Timeout', 'gwolle-gb'); ?></label></th>
156
  <td>
157
  <input <?php
158
- if (get_option( 'gwolle_gb-timeout', 'true') == 'true') {
159
  echo 'checked="checked"';
160
  } ?>
161
  type="checkbox" name="gwolle_gb_timeout" id="gwolle_gb_timeout">
@@ -185,10 +185,10 @@ function gwolle_gb_page_settingstab_antispam() {
185
 
186
  // Check wether Akismet is installed and activated or not.
187
  if ( ! in_array('akismet/akismet.php', $current_plugins)) {
188
- echo esc_html__("Akismet is an external service by Automattic that acts as a spamfilter for guestbook entries.", 'gwolle-gb') . '<br />';
189
  // Akismet is not installed and activated. Show notice with suggestion to install it.
190
  esc_html_e("Akismet helps you to fight spam. It's free and easy to install. Download and install it today to stop spam in your guestbook.", 'gwolle-gb');
191
- } elseif ( ! $wordpress_api_key) {
192
  // No WordPress API key is defined and set in the database.
193
  /* translators: First 2 %s are a strong element. Second %s is for a link. */
194
  echo sprintf( esc_html__("Sorry, wasn't able to locate your %sWordPress API key%s. You can enter it at the %sAkismet configuration page%s.", 'gwolle-gb'), '<strong>', '</strong>', '<a href="options-general.php?page=akismet-key-config">', '</a>' );
@@ -214,7 +214,7 @@ function gwolle_gb_page_settingstab_antispam() {
214
  <th scope="row"><label for="gwolle_gb_sfs"><?php esc_html_e('Stop Forum Spam', 'gwolle-gb'); ?></label></th>
215
  <td>
216
  <input <?php
217
- if (get_option( 'gwolle_gb-sfs', 'false') == 'true') {
218
  echo 'checked="checked"';
219
  } ?>
220
  type="checkbox" name="gwolle_gb_sfs" id="gwolle_gb_sfs">
@@ -241,9 +241,9 @@ function gwolle_gb_page_settingstab_antispam() {
241
  <td>
242
  <div>
243
  <label for="antispam-question" class="setting-description"><?php esc_html_e('Custom security question to battle spam:', 'gwolle-gb'); ?></label><br />
244
- <input name="antispam-question" type="text" id="antispam-question" value="<?php echo $antispam_question; ?>" class="regular-text" placeholder="<?php esc_attr_e('12 + six =', 'gwolle-gb'); ?>" /><br />
245
  <label for="antispam-answer" class="setting-description"><?php esc_html_e('The answer to your security question:', 'gwolle-gb'); ?></label><br />
246
- <input name="antispam-answer" type="text" id="antispam-answer" value="<?php echo $antispam_answer; ?>" class="regular-text" placeholder="<?php esc_attr_e('18', 'gwolle-gb'); ?>" /><br />
247
  <span class="setting-description"><?php esc_html_e('You can ask your visitors to answer a custom security question, so only real people can post an entry.', 'gwolle-gb'); ?></span>
248
  </div>
249
  </td>
14
  */
15
  function gwolle_gb_page_settingstab_antispam() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_antispamtab' );
28
+ echo '<input type="hidden" id="gwolle_gb_page_settings_antispamtab" name="gwolle_gb_page_settings_antispamtab" value="' . esc_attr( $nonce ) . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
34
  <th scope="row"><label for="moderate-entries"><?php /* translators: Settings page, option for moderation */ esc_html_e('Moderate Guestbook', 'gwolle-gb'); ?></label></th>
35
  <td>
36
  <input <?php
37
+ if (get_option( 'gwolle_gb-moderate-entries', 'true') === 'true') {
38
  echo 'checked="checked"';
39
  } ?>
40
  type="checkbox" name="moderate-entries" id="moderate-entries">
53
  <th scope="row"><label for="refuse-spam"><?php /* translators: Settings page, option for refusing spam */ esc_html_e('Refuse Spam', 'gwolle-gb'); ?></label></th>
54
  <td>
55
  <input <?php
56
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
57
  echo 'checked="checked"';
58
  } ?>
59
  type="checkbox" name="refuse-spam" id="refuse-spam">
72
  <th scope="row"><label for="honeypot"><?php esc_html_e('Honeypot', 'gwolle-gb'); ?></label></th>
73
  <td>
74
  <input <?php
75
+ if (get_option( 'gwolle_gb-honeypot', 'true') === 'true') {
76
  echo 'checked="checked"';
77
  } ?>
78
  type="checkbox" name="honeypot" id="honeypot">
89
  <th scope="row"><label for="gwolle_gb_nonce"><?php esc_html_e('Nonce', 'gwolle-gb'); ?></label></th>
90
  <td>
91
  <input <?php
92
+ if (get_option( 'gwolle_gb-nonce', 'true') === 'true') {
93
  echo 'checked="checked"';
94
  } ?>
95
  type="checkbox" name="gwolle_gb_nonce" id="gwolle_gb_nonce">
114
  <th scope="row"><label for="gwolle_gb_longtext"><?php esc_html_e('Long Text', 'gwolle-gb'); ?></label></th>
115
  <td>
116
  <input <?php
117
+ if (get_option( 'gwolle_gb-longtext', 'true') === 'true') {
118
  echo 'checked="checked"';
119
  } ?>
120
  type="checkbox" name="gwolle_gb_longtext" id="gwolle_gb_longtext">
136
  <th scope="row"><label for="gwolle_gb_linkchecker"><?php esc_html_e('Link Checker', 'gwolle-gb'); ?></label></th>
137
  <td>
138
  <input <?php
139
+ if (get_option( 'gwolle_gb-linkchecker', 'true') === 'true') {
140
  echo 'checked="checked"';
141
  } ?>
142
  type="checkbox" name="gwolle_gb_linkchecker" id="gwolle_gb_linkchecker">
155
  <th scope="row"><label for="gwolle_gb_timeout"><?php esc_html_e('Form Timeout', 'gwolle-gb'); ?></label></th>
156
  <td>
157
  <input <?php
158
+ if (get_option( 'gwolle_gb-timeout', 'true') === 'true') {
159
  echo 'checked="checked"';
160
  } ?>
161
  type="checkbox" name="gwolle_gb_timeout" id="gwolle_gb_timeout">
185
 
186
  // Check wether Akismet is installed and activated or not.
187
  if ( ! in_array('akismet/akismet.php', $current_plugins)) {
188
+ echo esc_html__('Akismet is an external service by Automattic that acts as a spamfilter for guestbook entries.', 'gwolle-gb') . '<br />';
189
  // Akismet is not installed and activated. Show notice with suggestion to install it.
190
  esc_html_e("Akismet helps you to fight spam. It's free and easy to install. Download and install it today to stop spam in your guestbook.", 'gwolle-gb');
191
+ } else if ( ! $wordpress_api_key) {
192
  // No WordPress API key is defined and set in the database.
193
  /* translators: First 2 %s are a strong element. Second %s is for a link. */
194
  echo sprintf( esc_html__("Sorry, wasn't able to locate your %sWordPress API key%s. You can enter it at the %sAkismet configuration page%s.", 'gwolle-gb'), '<strong>', '</strong>', '<a href="options-general.php?page=akismet-key-config">', '</a>' );
214
  <th scope="row"><label for="gwolle_gb_sfs"><?php esc_html_e('Stop Forum Spam', 'gwolle-gb'); ?></label></th>
215
  <td>
216
  <input <?php
217
+ if (get_option( 'gwolle_gb-sfs', 'false') === 'true') {
218
  echo 'checked="checked"';
219
  } ?>
220
  type="checkbox" name="gwolle_gb_sfs" id="gwolle_gb_sfs">
241
  <td>
242
  <div>
243
  <label for="antispam-question" class="setting-description"><?php esc_html_e('Custom security question to battle spam:', 'gwolle-gb'); ?></label><br />
244
+ <input name="antispam-question" type="text" id="antispam-question" value="<?php echo esc_attr( $antispam_question ); ?>" class="regular-text" placeholder="<?php esc_attr_e('12 + six =', 'gwolle-gb'); ?>" /><br />
245
  <label for="antispam-answer" class="setting-description"><?php esc_html_e('The answer to your security question:', 'gwolle-gb'); ?></label><br />
246
+ <input name="antispam-answer" type="text" id="antispam-answer" value="<?php echo esc_attr( $antispam_answer ); ?>" class="regular-text" placeholder="<?php esc_attr_e('18', 'gwolle-gb'); ?>" /><br />
247
  <span class="setting-description"><?php esc_html_e('You can ask your visitors to answer a custom security question, so only real people can post an entry.', 'gwolle-gb'); ?></span>
248
  </div>
249
  </td>
admin/tabs/gb-debugtab.php CHANGED
@@ -15,7 +15,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
15
  */
16
  function gwolle_gb_page_settingstab_debug() {
17
 
18
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
19
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
20
  } ?>
21
 
@@ -26,7 +26,7 @@ function gwolle_gb_page_settingstab_debug() {
26
 
27
  /* Nonce */
28
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_debugtab' );
29
- echo '<input type="hidden" id="gwolle_gb_page_settings_debugtab" name="gwolle_gb_page_settings_debugtab" value="' . $nonce . '" />';
30
  ?>
31
  <table class="form-table">
32
  <tbody>
@@ -45,7 +45,7 @@ function gwolle_gb_page_settingstab_debug() {
45
  if ( isset($_POST['gwolle_gb_page_settings_debugtab']) ) {
46
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_debugtab'], 'gwolle_gb_page_settings_debugtab' );
47
  }
48
- if ( $verified && isset( $_POST['gwolle_gb_debug']) ) {
49
  // Save test entries
50
  $entry_id = gwolle_gb_test_add_entry( false );
51
  $entry_id_emoji = gwolle_gb_test_add_entry( true );
@@ -54,7 +54,7 @@ function gwolle_gb_page_settingstab_debug() {
54
  <tr>
55
  <th><?php esc_html_e('Standard test:', 'gwolle-gb'); ?></th>
56
  <td><?php
57
- if ( $entry_id == 0 ) {
58
  echo '👎 ';
59
  esc_html_e('Failed.', 'gwolle-gb');
60
  } else {
@@ -66,7 +66,7 @@ function gwolle_gb_page_settingstab_debug() {
66
  <tr>
67
  <th><?php esc_html_e('Emoji test:', 'gwolle-gb'); ?></th>
68
  <td><?php
69
- if ( $entry_id_emoji == 0 ) {
70
  echo '👎 ';
71
  esc_html_e('Failed.', 'gwolle-gb');
72
  } else {
15
  */
16
  function gwolle_gb_page_settingstab_debug() {
17
 
18
+ if ( ! current_user_can('manage_options') ) {
19
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
20
  } ?>
21
 
26
 
27
  /* Nonce */
28
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_debugtab' );
29
+ echo '<input type="hidden" id="gwolle_gb_page_settings_debugtab" name="gwolle_gb_page_settings_debugtab" value="' . esc_attr( $nonce ) . '" />';
30
  ?>
31
  <table class="form-table">
32
  <tbody>
45
  if ( isset($_POST['gwolle_gb_page_settings_debugtab']) ) {
46
  $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_debugtab'], 'gwolle_gb_page_settings_debugtab' );
47
  }
48
+ if ( $verified && isset( $_POST['gwolle_gb_debug'] ) ) {
49
  // Save test entries
50
  $entry_id = gwolle_gb_test_add_entry( false );
51
  $entry_id_emoji = gwolle_gb_test_add_entry( true );
54
  <tr>
55
  <th><?php esc_html_e('Standard test:', 'gwolle-gb'); ?></th>
56
  <td><?php
57
+ if ( $entry_id === 0 ) {
58
  echo '👎 ';
59
  esc_html_e('Failed.', 'gwolle-gb');
60
  } else {
66
  <tr>
67
  <th><?php esc_html_e('Emoji test:', 'gwolle-gb'); ?></th>
68
  <td><?php
69
+ if ( $entry_id_emoji === 0 ) {
70
  echo '👎 ';
71
  esc_html_e('Failed.', 'gwolle-gb');
72
  } else {
admin/tabs/gb-emailtab.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settingstab_email() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
@@ -25,7 +25,7 @@ function gwolle_gb_page_settingstab_email() {
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_emailtab' );
28
- echo '<input type="hidden" id="gwolle_gb_page_settings_emailtab" name="gwolle_gb_page_settings_emailtab" value="' . $nonce . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
@@ -33,7 +33,7 @@ function gwolle_gb_page_settingstab_email() {
33
  <?php
34
  $user_ids = get_option('gwolle_gb-notifyByMail' );
35
  if ( strlen($user_ids) > 0 ) {
36
- $user_ids = explode( ",", $user_ids );
37
  } ?>
38
 
39
  <tr>
@@ -68,10 +68,10 @@ function gwolle_gb_page_settingstab_email() {
68
  }
69
 
70
  $username = $user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_email . ')';
71
- if ( $user_info->ID == get_current_user_id() ) {
72
  $username .= ' ' . esc_html__('You', 'gwolle-gb');
73
  }
74
- echo '<option value="' . $user_info->ID . '">' . $username . '</option>';
75
  }
76
  } ?>
77
  </select><br />
@@ -82,7 +82,7 @@ function gwolle_gb_page_settingstab_email() {
82
  /* translators: %s is a link */
83
  echo sprintf( esc_html__( 'A new WordPress user can be added on %sAdd New in the Users menu section%s.', 'gwolle-gb' ), $link_wp, '</a>' ); ?>
84
  <?php esc_html_e('After adding a new user it should be available in the dropdown menu above.', 'gwolle-gb'); ?>
85
- </label>
86
  </td>
87
  </tr>
88
 
@@ -93,7 +93,7 @@ function gwolle_gb_page_settingstab_email() {
93
  // Check if function mail() exists. If not, display a hint to the user.
94
  if ( ! function_exists('mail') ) {
95
  echo '<p class="setting-description">' .
96
- __('Sorry, but the function <code>mail()</code> required to notify you by mail is not enabled in your PHP configuration. You might want to install a WordPress plugin that uses SMTP instead of <code>mail()</code>. Or you can contact your hosting provider to change this.','gwolle-gb')
97
  . '</p>';
98
  } ?>
99
  <select name="unsubscribe" id="unsubscribe">
@@ -103,15 +103,15 @@ function gwolle_gb_page_settingstab_email() {
103
  foreach ( $user_ids as $user_id ) {
104
 
105
  $user_info = get_userdata( (int) $user_id );
106
- if ($user_info === FALSE) {
107
  // Invalid $user_id
108
  continue;
109
  }
110
  $username = $user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_email . ')';
111
- if ( $user_info->ID == get_current_user_id() ) {
112
  $username .= ' ' . esc_html__('You', 'gwolle-gb');
113
  }
114
- echo '<option value="' . $user_info->ID . '">' . $username . '</option>';
115
  }
116
  } ?>
117
  </select><br />
@@ -139,12 +139,12 @@ function gwolle_gb_page_settingstab_email() {
139
  <th scope="row"><label for="adminMailContent"><?php esc_html_e('Admin mail content', 'gwolle-gb'); ?></label></th>
140
  <td>
141
  <?php
142
- $mailText = gwolle_gb_sanitize_output( get_option('gwolle_gb-adminMailContent', false), 'setting_textarea' );
143
- if ( ! $mailText) { // No text set by the user. Use the default text.
144
- $mailText = esc_html__("
145
  Hello,
146
 
147
- There is a new guestbook entry at '%blog_name%'.
148
  You can check it at %entry_management_url%.
149
 
150
  Have a nice day.
@@ -157,22 +157,22 @@ User email: %user_email%
157
  Entry status: %status%
158
  Entry content:
159
  %entry_content%
160
- "
161
- , 'gwolle-gb');
162
- } ?>
163
- <textarea name="adminMailContent" id="adminMailContent" style="width:400px;height:300px;" class="regular-text"><?php echo $mailText; ?></textarea>
164
  <br />
165
  <span class="setting-description">
166
  <?php esc_html_e('You can set the content of the mail that a notification subscriber gets on new entries. The following tags are supported:', 'gwolle-gb');
167
  echo '<br />';
168
- $mailTags = array( 'user_email', 'user_name', 'entry_management_url', 'blog_name', 'blog_url', 'wp_admin_url', 'entry_content', 'status', 'author_ip', 'author_origin' );
169
- for ($i = 0; $i < count($mailTags); $i++) {
170
- if ($i != 0) {
 
171
  echo ', ';
172
  }
173
- echo '%' . $mailTags[$i] . '%';
174
  }
175
- echo "."; ?>
176
  </span>
177
  </td>
178
  </tr>
@@ -181,7 +181,7 @@ Entry content:
181
  <th scope="row"><label for="mail_author"><?php esc_html_e('Mail Author', 'gwolle-gb'); ?></label></th>
182
  <td>
183
  <input <?php
184
- if (get_option( 'gwolle_gb-mail_author', 'false') == 'true') {
185
  echo 'checked="checked"';
186
  } ?>
187
  type="checkbox" name="mail_author" id="mail_author">
@@ -190,7 +190,7 @@ Entry content:
190
  </label>
191
  <br />
192
  <span class="setting-description">
193
- <?php esc_html_e("The author of the guestbook entry will receive an email after posting. It will have a copy of the entry.", 'gwolle-gb'); ?>
194
  </span>
195
  </td>
196
  </tr>
@@ -199,12 +199,12 @@ Entry content:
199
  <th scope="row"><label for="authorMailContent"><?php esc_html_e('Author mail content', 'gwolle-gb'); ?></label></th>
200
  <td>
201
  <?php
202
- $mailText = gwolle_gb_sanitize_output( get_option('gwolle_gb-authorMailContent', false), 'setting_textarea' );
203
- if ( ! $mailText) { // No text set by the user. Use the default text.
204
- $mailText = esc_html__("
205
  Hello,
206
 
207
- You have just posted a new guestbook entry at '%blog_name%'.
208
 
209
  Have a nice day.
210
  The editors at %blog_name%.
@@ -215,20 +215,20 @@ User name: %user_name%
215
  User email: %user_email%
216
  Entry content:
217
  %entry_content%
218
- "
219
- , 'gwolle-gb');
220
- } ?>
221
- <textarea name="authorMailContent" id="authorMailContent" style="width:400px;height:300px;" class="regular-text"><?php echo $mailText; ?></textarea>
222
  <br />
223
  <span class="setting-description">
224
  <?php esc_html_e('You can set the content of the mail that the author of the entry will receive. The following tags are supported:', 'gwolle-gb');
225
  echo '<br />';
226
- $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content');
227
- for ($i = 0; $i < count($mailTags); $i++) {
228
- if ($i != 0) {
 
229
  echo ', ';
230
  }
231
- echo '%' . $mailTags[$i] . '%';
232
  }
233
  ?>
234
  </span>
@@ -239,7 +239,7 @@ Entry content:
239
  <th scope="row"><label for="mail_author_moderation"><?php esc_html_e('Mail Author on moderation', 'gwolle-gb'); ?></label></th>
240
  <td>
241
  <input <?php
242
- if (get_option( 'gwolle_gb-mail_author_moderation', 'false') == 'true') {
243
  echo 'checked="checked"';
244
  } ?>
245
  type="checkbox" name="mail_author_moderation" id="mail_author_moderation">
@@ -248,7 +248,7 @@ Entry content:
248
  </label>
249
  <br />
250
  <span class="setting-description">
251
- <?php esc_html_e("The author of the guestbook entry will receive an email after his entry was moderated.", 'gwolle-gb'); ?>
252
  </span>
253
  </td>
254
  </tr>
@@ -257,12 +257,12 @@ Entry content:
257
  <th scope="row"><label for="authormoderationcontent"><?php esc_html_e('Moderation mail content', 'gwolle-gb'); ?></label></th>
258
  <td>
259
  <?php
260
- $mailText = gwolle_gb_sanitize_output( get_option('gwolle_gb-authormoderationcontent', false), 'setting_textarea' );
261
- if ( ! $mailText) { // No text set by the user. Use the default text.
262
- $mailText = esc_html__("
263
  Hello,
264
 
265
- An admin has just moderated your guestbook entry at '%blog_name%'.
266
 
267
  Have a nice day.
268
  The editors at %blog_name%.
@@ -273,20 +273,20 @@ Website address: %blog_url%
273
 
274
  Original entry posted on %date%:
275
  %entry_content%
276
- "
277
- , 'gwolle-gb');
278
- } ?>
279
- <textarea name="authormoderationcontent" id="authormoderationcontent" style="width:400px;height:300px;" class="regular-text"><?php echo $mailText; ?></textarea>
280
  <br />
281
  <span class="setting-description">
282
  <?php esc_html_e('You can set the content of the moderation mail that the author of the entry will receive. The following tags are supported:', 'gwolle-gb');
283
  echo '<br />';
284
- $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content', 'date');
285
- for ($i = 0; $i < count($mailTags); $i++) {
286
- if ($i != 0) {
 
287
  echo ', ';
288
  }
289
- echo '%' . $mailTags[$i] . '%';
290
  }
291
  ?>
292
  </span>
@@ -297,12 +297,12 @@ Original entry posted on %date%:
297
  <th scope="row"><label for="gwolle_gb-mail_admin_replyContent"><?php esc_html_e('Admin Reply mail content', 'gwolle-gb'); ?></label></th>
298
  <td>
299
  <?php
300
- $mailText = gwolle_gb_sanitize_output( get_option('gwolle_gb-mail_admin_replyContent', false), 'setting_textarea' );
301
- if ( ! $mailText) { // No text set by the user. Use the default text.
302
- $mailText = esc_html__("
303
  Hello,
304
 
305
- An admin has just added or changed a reply message to your guestbook entry at '%blog_name%'.
306
 
307
  Have a nice day.
308
  The editors at %blog_name%.
@@ -315,20 +315,20 @@ Admin Reply:
315
 
316
  Original entry posted on %date%:
317
  %entry_content%
318
- "
319
- , 'gwolle-gb');
320
  } ?>
321
- <textarea name="gwolle_gb-mail_admin_replyContent" id="gwolle_gb-mail_admin_replyContent" style="width:400px;height:300px;" class="regular-text"><?php echo $mailText; ?></textarea>
322
  <br />
323
  <span class="setting-description">
324
  <?php esc_html_e('You can set the content of the mail that the author of the entry will receive when an Admin Reply is added. The following tags are supported:', 'gwolle-gb');
325
  echo '<br />';
326
- $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'admin_reply', 'entry_content', 'date');
327
- for ($i = 0; $i < count($mailTags); $i++) {
328
- if ($i != 0) {
 
329
  echo ', ';
330
  }
331
- echo '%' . $mailTags[$i] . '%';
332
  }
333
  ?>
334
  </span>
14
  */
15
  function gwolle_gb_page_settingstab_email() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_emailtab' );
28
+ echo '<input type="hidden" id="gwolle_gb_page_settings_emailtab" name="gwolle_gb_page_settings_emailtab" value="' . esc_attr( $nonce ) . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
33
  <?php
34
  $user_ids = get_option('gwolle_gb-notifyByMail' );
35
  if ( strlen($user_ids) > 0 ) {
36
+ $user_ids = explode( ',', $user_ids );
37
  } ?>
38
 
39
  <tr>
68
  }
69
 
70
  $username = $user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_email . ')';
71
+ if ( $user_info->ID === get_current_user_id() ) {
72
  $username .= ' ' . esc_html__('You', 'gwolle-gb');
73
  }
74
+ echo '<option value="' . (int) $user_info->ID . '">' . $username . '</option>';
75
  }
76
  } ?>
77
  </select><br />
82
  /* translators: %s is a link */
83
  echo sprintf( esc_html__( 'A new WordPress user can be added on %sAdd New in the Users menu section%s.', 'gwolle-gb' ), $link_wp, '</a>' ); ?>
84
  <?php esc_html_e('After adding a new user it should be available in the dropdown menu above.', 'gwolle-gb'); ?>
85
+ </label>
86
  </td>
87
  </tr>
88
 
93
  // Check if function mail() exists. If not, display a hint to the user.
94
  if ( ! function_exists('mail') ) {
95
  echo '<p class="setting-description">' .
96
+ __('Sorry, but the function <code>mail()</code> required to notify you by mail is not enabled in your PHP configuration. You might want to install a WordPress plugin that uses SMTP instead of <code>mail()</code>. Or you can contact your hosting provider to change this.', 'gwolle-gb')
97
  . '</p>';
98
  } ?>
99
  <select name="unsubscribe" id="unsubscribe">
103
  foreach ( $user_ids as $user_id ) {
104
 
105
  $user_info = get_userdata( (int) $user_id );
106
+ if ($user_info === false) {
107
  // Invalid $user_id
108
  continue;
109
  }
110
  $username = $user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_email . ')';
111
+ if ( $user_info->ID === get_current_user_id() ) {
112
  $username .= ' ' . esc_html__('You', 'gwolle-gb');
113
  }
114
+ echo '<option value="' . (int) $user_info->ID . '">' . $username . '</option>';
115
  }
116
  } ?>
117
  </select><br />
139
  <th scope="row"><label for="adminMailContent"><?php esc_html_e('Admin mail content', 'gwolle-gb'); ?></label></th>
140
  <td>
141
  <?php
142
+ $mailtext = gwolle_gb_sanitize_output( get_option('gwolle_gb-adminMailContent', false), 'setting_textarea' );
143
+ if ( ! $mailtext) { // No text set by the user. Use the default text.
144
+ $mailtext = esc_html__("
145
  Hello,
146
 
147
+ There is a new guestbook entry at %blog_name%.
148
  You can check it at %entry_management_url%.
149
 
150
  Have a nice day.
157
  Entry status: %status%
158
  Entry content:
159
  %entry_content%
160
+ ", 'gwolle-gb');
161
+ } ?>
162
+ <textarea name="adminMailContent" id="adminMailContent" style="width:400px;height:300px;" class="regular-text"><?php echo esc_textarea( $mailtext ); ?></textarea>
 
163
  <br />
164
  <span class="setting-description">
165
  <?php esc_html_e('You can set the content of the mail that a notification subscriber gets on new entries. The following tags are supported:', 'gwolle-gb');
166
  echo '<br />';
167
+ $mailtags = array( 'user_email', 'user_name', 'entry_management_url', 'blog_name', 'blog_url', 'wp_admin_url', 'entry_content', 'status', 'author_ip', 'author_origin' );
168
+ $mailtags_count = count($mailtags);
169
+ for ($i = 0; $i < $mailtags_count; $i++) {
170
+ if ($i !== 0) {
171
  echo ', ';
172
  }
173
+ echo '%' . $mailtags[$i] . '%';
174
  }
175
+ echo '.'; ?>
176
  </span>
177
  </td>
178
  </tr>
181
  <th scope="row"><label for="mail_author"><?php esc_html_e('Mail Author', 'gwolle-gb'); ?></label></th>
182
  <td>
183
  <input <?php
184
+ if (get_option( 'gwolle_gb-mail_author', 'false') === 'true') {
185
  echo 'checked="checked"';
186
  } ?>
187
  type="checkbox" name="mail_author" id="mail_author">
190
  </label>
191
  <br />
192
  <span class="setting-description">
193
+ <?php esc_html_e('The author of the guestbook entry will receive an email after posting. It will have a copy of the entry.', 'gwolle-gb'); ?>
194
  </span>
195
  </td>
196
  </tr>
199
  <th scope="row"><label for="authorMailContent"><?php esc_html_e('Author mail content', 'gwolle-gb'); ?></label></th>
200
  <td>
201
  <?php
202
+ $mailtext = gwolle_gb_sanitize_output( get_option('gwolle_gb-authorMailContent', false), 'setting_textarea' );
203
+ if ( ! $mailtext) { // No text set by the user. Use the default text.
204
+ $mailtext = esc_html__("
205
  Hello,
206
 
207
+ You have just posted a new guestbook entry at %blog_name%.
208
 
209
  Have a nice day.
210
  The editors at %blog_name%.
215
  User email: %user_email%
216
  Entry content:
217
  %entry_content%
218
+ ", 'gwolle-gb');
219
+ } ?>
220
+ <textarea name="authorMailContent" id="authorMailContent" style="width:400px;height:300px;" class="regular-text"><?php echo esc_textarea( $mailtext ); ?></textarea>
 
221
  <br />
222
  <span class="setting-description">
223
  <?php esc_html_e('You can set the content of the mail that the author of the entry will receive. The following tags are supported:', 'gwolle-gb');
224
  echo '<br />';
225
+ $mailtags = array( 'user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content' );
226
+ $mailtags_count = count($mailtags);
227
+ for ($i = 0; $i < $mailtags_count; $i++) {
228
+ if ($i !== 0) {
229
  echo ', ';
230
  }
231
+ echo '%' . $mailtags[$i] . '%';
232
  }
233
  ?>
234
  </span>
239
  <th scope="row"><label for="mail_author_moderation"><?php esc_html_e('Mail Author on moderation', 'gwolle-gb'); ?></label></th>
240
  <td>
241
  <input <?php
242
+ if (get_option( 'gwolle_gb-mail_author_moderation', 'false') === 'true') {
243
  echo 'checked="checked"';
244
  } ?>
245
  type="checkbox" name="mail_author_moderation" id="mail_author_moderation">
248
  </label>
249
  <br />
250
  <span class="setting-description">
251
+ <?php esc_html_e('The author of the guestbook entry will receive an email after his entry was moderated.', 'gwolle-gb'); ?>
252
  </span>
253
  </td>
254
  </tr>
257
  <th scope="row"><label for="authormoderationcontent"><?php esc_html_e('Moderation mail content', 'gwolle-gb'); ?></label></th>
258
  <td>
259
  <?php
260
+ $mailtext = gwolle_gb_sanitize_output( get_option('gwolle_gb-authormoderationcontent', false), 'setting_textarea' );
261
+ if ( ! $mailtext) { // No text set by the user. Use the default text.
262
+ $mailtext = esc_html__("
263
  Hello,
264
 
265
+ An admin has just moderated your guestbook entry at %blog_name%.
266
 
267
  Have a nice day.
268
  The editors at %blog_name%.
273
 
274
  Original entry posted on %date%:
275
  %entry_content%
276
+ ", 'gwolle-gb');
277
+ } ?>
278
+ <textarea name="authormoderationcontent" id="authormoderationcontent" style="width:400px;height:300px;" class="regular-text"><?php echo esc_textarea( $mailtext ); ?></textarea>
 
279
  <br />
280
  <span class="setting-description">
281
  <?php esc_html_e('You can set the content of the moderation mail that the author of the entry will receive. The following tags are supported:', 'gwolle-gb');
282
  echo '<br />';
283
+ $mailtags = array( 'user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content', 'date' );
284
+ $mailtags_count = count($mailtags);
285
+ for ($i = 0; $i < $mailtags_count; $i++) {
286
+ if ($i !== 0) {
287
  echo ', ';
288
  }
289
+ echo '%' . $mailtags[$i] . '%';
290
  }
291
  ?>
292
  </span>
297
  <th scope="row"><label for="gwolle_gb-mail_admin_replyContent"><?php esc_html_e('Admin Reply mail content', 'gwolle-gb'); ?></label></th>
298
  <td>
299
  <?php
300
+ $mailtext = gwolle_gb_sanitize_output( get_option('gwolle_gb-mail_admin_replyContent', false), 'setting_textarea' );
301
+ if ( ! $mailtext) { // No text set by the user. Use the default text.
302
+ $mailtext = esc_html__("
303
  Hello,
304
 
305
+ An admin has just added or changed a reply message to your guestbook entry at %blog_name%.
306
 
307
  Have a nice day.
308
  The editors at %blog_name%.
315
 
316
  Original entry posted on %date%:
317
  %entry_content%
318
+ ", 'gwolle-gb');
 
319
  } ?>
320
+ <textarea name="gwolle_gb-mail_admin_replyContent" id="gwolle_gb-mail_admin_replyContent" style="width:400px;height:300px;" class="regular-text"><?php echo esc_textarea( $mailtext ); ?></textarea>
321
  <br />
322
  <span class="setting-description">
323
  <?php esc_html_e('You can set the content of the mail that the author of the entry will receive when an Admin Reply is added. The following tags are supported:', 'gwolle-gb');
324
  echo '<br />';
325
+ $mailtags = array( 'user_email', 'user_name', 'blog_name', 'blog_url', 'admin_reply', 'entry_content', 'date' );
326
+ $mailtags_count = count($mailtags);
327
+ for ($i = 0; $i < $mailtags_count; $i++) {
328
+ if ($i !== 0) {
329
  echo ', ';
330
  }
331
+ echo '%' . $mailtags[$i] . '%';
332
  }
333
  ?>
334
  </span>
admin/tabs/gb-formtab.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settingstab_form() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
@@ -25,7 +25,7 @@ function gwolle_gb_page_settingstab_form() {
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_formtab' );
28
- echo '<input type="hidden" id="gwolle_gb_page_settings_formtab" name="gwolle_gb_page_settings_formtab" value="' . $nonce . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
@@ -65,7 +65,7 @@ function gwolle_gb_page_settingstab_form() {
65
  if ( ! $header ) {
66
  $header = esc_html__('Write a new entry for the Guestbook', 'gwolle-gb');
67
  } ?>
68
- <input name="gb_header" id="gb_header" class="regular-text" type="text" value="<?php echo $header; ?>" />
69
  <br />
70
  <span class="setting-description">
71
  <?php esc_html_e('You can set the header that is shown on top of the form.', 'gwolle-gb'); ?>
@@ -84,10 +84,9 @@ Fields marked with * are required.
84
  Your E-mail address won't be published.
85
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
86
  We reserve the right to edit, delete, or not publish entries.
87
- "
88
- , 'gwolle-gb');
89
- } ?>
90
- <textarea name="notice" id="notice" style="width:400px;height:180px;" class="regular-text"><?php echo $notice; ?></textarea>
91
  <br />
92
  <span class="setting-description">
93
  <?php esc_html_e('You can set the content of the notice that gets shown below the form.', 'gwolle-gb');
@@ -124,7 +123,7 @@ We reserve the right to edit, delete, or not publish entries.
124
  <label for="store_ip"><?php esc_html_e('Store IP Address and hostname for each entry.', 'gwolle-gb'); ?></label>
125
  <br />
126
  <span class="setting-description"><?php /* translators: The GDPR law often has a country specific name */
127
- esc_html_e('Since May 2018 there is a GDPR law in the EU about privacy and personal information that is being stored.', 'gwolle-gb'); echo '<br />';
128
  esc_html_e('Disabling this option will still have the IP Address used for spamfiltering in Stop Forum Spam.', 'gwolle-gb'); echo '<br />';
129
  esc_html_e('Disabling this option will probably make the Akismet spamfilter less effective.', 'gwolle-gb'); ?></span><br />
130
  </td>
@@ -154,7 +153,7 @@ We reserve the right to edit, delete, or not publish entries.
154
  <th scope="row"><label for="form_name_enabled"><?php esc_html_e('Name', 'gwolle-gb'); ?>:</label></th>
155
  <td>
156
  <input type="checkbox" id="form_name_enabled" name="form_name_enabled"<?php
157
- if ( isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true' ) {
158
  echo ' checked="checked"';
159
  }
160
  ?> />
@@ -162,7 +161,7 @@ We reserve the right to edit, delete, or not publish entries.
162
  </td>
163
  <td>
164
  <input type="checkbox" id="form_name_mandatory" name="form_name_mandatory"<?php
165
- if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
166
  echo ' checked="checked"';
167
  }
168
  ?> />
@@ -174,7 +173,7 @@ We reserve the right to edit, delete, or not publish entries.
174
  <th scope="row"><label for="form_city_enabled"><?php esc_html_e('City', 'gwolle-gb'); ?>:</label></th>
175
  <td>
176
  <input type="checkbox" id="form_city_enabled" name="form_city_enabled"<?php
177
- if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true' ) {
178
  echo ' checked="checked"';
179
  }
180
  ?> />
@@ -182,7 +181,7 @@ We reserve the right to edit, delete, or not publish entries.
182
  </td>
183
  <td>
184
  <input type="checkbox" id="form_city_mandatory" name="form_city_mandatory"<?php
185
- if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
186
  echo ' checked="checked"';
187
  }
188
  ?> />
@@ -194,7 +193,7 @@ We reserve the right to edit, delete, or not publish entries.
194
  <th scope="row"><label for="form_email_enabled"><?php esc_html_e('Email', 'gwolle-gb'); ?>:</label></th>
195
  <td>
196
  <input type="checkbox" id="form_email_enabled" name="form_email_enabled"<?php
197
- if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true' ) {
198
  echo ' checked="checked"';
199
  }
200
  ?> />
@@ -202,7 +201,7 @@ We reserve the right to edit, delete, or not publish entries.
202
  </td>
203
  <td>
204
  <input type="checkbox" id="form_email_mandatory" name="form_email_mandatory"<?php
205
- if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
206
  echo ' checked="checked"';
207
  }
208
  ?> />
@@ -214,7 +213,7 @@ We reserve the right to edit, delete, or not publish entries.
214
  <th scope="row"><label for="form_homepage_enabled"><?php esc_html_e('Website', 'gwolle-gb'); ?>:</label></th>
215
  <td>
216
  <input type="checkbox" id="form_homepage_enabled" name="form_homepage_enabled"<?php
217
- if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true' ) {
218
  echo ' checked="checked"';
219
  }
220
  ?> />
@@ -222,7 +221,7 @@ We reserve the right to edit, delete, or not publish entries.
222
  </td>
223
  <td>
224
  <input type="checkbox" id="form_homepage_mandatory" name="form_homepage_mandatory"<?php
225
- if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
226
  echo ' checked="checked"';
227
  }
228
  ?> />
@@ -234,7 +233,7 @@ We reserve the right to edit, delete, or not publish entries.
234
  <th scope="row"><label for="form_message_enabled"><?php esc_html_e('Message', 'gwolle-gb'); ?>:</label></th>
235
  <td>
236
  <input type="checkbox" id="form_message_enabled" name="form_message_enabled"<?php
237
- if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
238
  echo ' checked="checked"';
239
  }
240
  ?> />
@@ -242,11 +241,36 @@ We reserve the right to edit, delete, or not publish entries.
242
  </td>
243
  <td>
244
  <input type="checkbox" id="form_message_mandatory" name="form_message_mandatory"<?php
245
- if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
246
  echo ' checked="checked"';
247
  }
248
  ?> />
249
  <label for="form_message_mandatory"><?php esc_html_e('Mandatory', 'gwolle-gb'); ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  </td>
251
  </tr>
252
 
@@ -254,14 +278,15 @@ We reserve the right to edit, delete, or not publish entries.
254
  <th scope="row"><label for="form_bbcode_enabled"><?php esc_html_e('Visual formatting and Emoji', 'gwolle-gb'); ?>:</label></th>
255
  <td>
256
  <input type="checkbox" id="form_bbcode_enabled" name="form_bbcode_enabled"<?php
257
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
258
  echo ' checked="checked"';
259
  }
260
  ?> />
261
  <label for="form_bbcode_enabled"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label>
262
  </td>
263
  <td>
264
- <?php esc_html_e('Will only be shown if the Message is enabled.', 'gwolle-gb'); ?>
 
265
  </td>
266
  </tr>
267
 
@@ -269,7 +294,7 @@ We reserve the right to edit, delete, or not publish entries.
269
  <th scope="row"><label for="form_antispam_enabled"><?php esc_html_e('Custom Anti-spam', 'gwolle-gb'); ?>:</label></th>
270
  <td>
271
  <input type="checkbox" id="form_antispam_enabled" name="form_antispam_enabled"<?php
272
- if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
273
  echo ' checked="checked"';
274
  }
275
  ?> />
@@ -284,7 +309,7 @@ We reserve the right to edit, delete, or not publish entries.
284
  <th scope="row"><label for="form_privacy_enabled"><?php esc_html_e('Privacy checkbox', 'gwolle-gb'); ?>:</label></th>
285
  <td>
286
  <input type="checkbox" id="form_privacy_enabled" name="form_privacy_enabled"<?php
287
- if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
288
  echo ' checked="checked"';
289
  }
290
  ?> />
14
  */
15
  function gwolle_gb_page_settingstab_form() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
25
 
26
  /* Nonce */
27
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_formtab' );
28
+ echo '<input type="hidden" id="gwolle_gb_page_settings_formtab" name="gwolle_gb_page_settings_formtab" value="' . esc_attr( $nonce ) . '" />';
29
  ?>
30
  <table class="form-table">
31
  <tbody>
65
  if ( ! $header ) {
66
  $header = esc_html__('Write a new entry for the Guestbook', 'gwolle-gb');
67
  } ?>
68
+ <input name="gb_header" id="gb_header" class="regular-text" type="text" value="<?php echo esc_attr( $header ); ?>" />
69
  <br />
70
  <span class="setting-description">
71
  <?php esc_html_e('You can set the header that is shown on top of the form.', 'gwolle-gb'); ?>
84
  Your E-mail address won't be published.
85
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
86
  We reserve the right to edit, delete, or not publish entries.
87
+ ", 'gwolle-gb');
88
+ } ?>
89
+ <textarea name="notice" id="notice" style="width:400px;height:180px;" class="regular-text"><?php echo esc_textarea( $notice ); ?></textarea>
 
90
  <br />
91
  <span class="setting-description">
92
  <?php esc_html_e('You can set the content of the notice that gets shown below the form.', 'gwolle-gb');
123
  <label for="store_ip"><?php esc_html_e('Store IP Address and hostname for each entry.', 'gwolle-gb'); ?></label>
124
  <br />
125
  <span class="setting-description"><?php /* translators: The GDPR law often has a country specific name */
126
+ esc_html_e('In the EU there is the GDPR law about privacy and storing personal information.', 'gwolle-gb'); echo '<br />';
127
  esc_html_e('Disabling this option will still have the IP Address used for spamfiltering in Stop Forum Spam.', 'gwolle-gb'); echo '<br />';
128
  esc_html_e('Disabling this option will probably make the Akismet spamfilter less effective.', 'gwolle-gb'); ?></span><br />
129
  </td>
153
  <th scope="row"><label for="form_name_enabled"><?php esc_html_e('Name', 'gwolle-gb'); ?>:</label></th>
154
  <td>
155
  <input type="checkbox" id="form_name_enabled" name="form_name_enabled"<?php
156
+ if ( isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true' ) {
157
  echo ' checked="checked"';
158
  }
159
  ?> />
161
  </td>
162
  <td>
163
  <input type="checkbox" id="form_name_mandatory" name="form_name_mandatory"<?php
164
+ if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
165
  echo ' checked="checked"';
166
  }
167
  ?> />
173
  <th scope="row"><label for="form_city_enabled"><?php esc_html_e('City', 'gwolle-gb'); ?>:</label></th>
174
  <td>
175
  <input type="checkbox" id="form_city_enabled" name="form_city_enabled"<?php
176
+ if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true' ) {
177
  echo ' checked="checked"';
178
  }
179
  ?> />
181
  </td>
182
  <td>
183
  <input type="checkbox" id="form_city_mandatory" name="form_city_mandatory"<?php
184
+ if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
185
  echo ' checked="checked"';
186
  }
187
  ?> />
193
  <th scope="row"><label for="form_email_enabled"><?php esc_html_e('Email', 'gwolle-gb'); ?>:</label></th>
194
  <td>
195
  <input type="checkbox" id="form_email_enabled" name="form_email_enabled"<?php
196
+ if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true' ) {
197
  echo ' checked="checked"';
198
  }
199
  ?> />
201
  </td>
202
  <td>
203
  <input type="checkbox" id="form_email_mandatory" name="form_email_mandatory"<?php
204
+ if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
205
  echo ' checked="checked"';
206
  }
207
  ?> />
213
  <th scope="row"><label for="form_homepage_enabled"><?php esc_html_e('Website', 'gwolle-gb'); ?>:</label></th>
214
  <td>
215
  <input type="checkbox" id="form_homepage_enabled" name="form_homepage_enabled"<?php
216
+ if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true' ) {
217
  echo ' checked="checked"';
218
  }
219
  ?> />
221
  </td>
222
  <td>
223
  <input type="checkbox" id="form_homepage_mandatory" name="form_homepage_mandatory"<?php
224
+ if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
225
  echo ' checked="checked"';
226
  }
227
  ?> />
233
  <th scope="row"><label for="form_message_enabled"><?php esc_html_e('Message', 'gwolle-gb'); ?>:</label></th>
234
  <td>
235
  <input type="checkbox" id="form_message_enabled" name="form_message_enabled"<?php
236
+ if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
237
  echo ' checked="checked"';
238
  }
239
  ?> />
241
  </td>
242
  <td>
243
  <input type="checkbox" id="form_message_mandatory" name="form_message_mandatory"<?php
244
+ if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
245
  echo ' checked="checked"';
246
  }
247
  ?> />
248
  <label for="form_message_mandatory"><?php esc_html_e('Mandatory', 'gwolle-gb'); ?></label>
249
+
250
+ <label for="form_message_maxlength">
251
+ <select name="form_message_maxlength" id="form_message_maxlength">
252
+ <?php
253
+ $form_message_maxlength = 0;
254
+ if ( isset($form_setting['form_message_maxlength']) ) {
255
+ $form_message_maxlength = (int) $form_setting['form_message_maxlength'];
256
+ }
257
+ if ( $form_message_maxlength === 0 ) {
258
+ echo '<option value="0" selected="selected">' . esc_html__('No Length Limit', 'gwolle-gb') . '</option>';
259
+ } else {
260
+ echo '<option value="0">' . esc_html__('No Limit', 'gwolle-gb') . '</option>';
261
+ }
262
+ $presets = array( 100, 150, 200, 250, 300, 400, 500 );
263
+ $preset_count = count($presets);
264
+ for ($i = 0; $i < $preset_count; $i++) {
265
+ echo '<option value="' . (int) $presets[$i] . '"';
266
+ if ( $presets[$i] === $form_message_maxlength ) {
267
+ echo ' selected="selected"';
268
+ }
269
+ echo '>' . $presets[$i] . ' ' . esc_html__('Characters', 'gwolle-gb') . '</option>';
270
+ }
271
+ ?>
272
+ </select>
273
+ </label>
274
  </td>
275
  </tr>
276
 
278
  <th scope="row"><label for="form_bbcode_enabled"><?php esc_html_e('Visual formatting and Emoji', 'gwolle-gb'); ?>:</label></th>
279
  <td>
280
  <input type="checkbox" id="form_bbcode_enabled" name="form_bbcode_enabled"<?php
281
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
282
  echo ' checked="checked"';
283
  }
284
  ?> />
285
  <label for="form_bbcode_enabled"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label>
286
  </td>
287
  <td>
288
+ <?php esc_html_e('Will add a button row to the message field.', 'gwolle-gb'); echo '<br />';
289
+ esc_html_e('Adds bold and italic style, images, links and emoji.', 'gwolle-gb'); ?>
290
  </td>
291
  </tr>
292
 
294
  <th scope="row"><label for="form_antispam_enabled"><?php esc_html_e('Custom Anti-spam', 'gwolle-gb'); ?>:</label></th>
295
  <td>
296
  <input type="checkbox" id="form_antispam_enabled" name="form_antispam_enabled"<?php
297
+ if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
298
  echo ' checked="checked"';
299
  }
300
  ?> />
309
  <th scope="row"><label for="form_privacy_enabled"><?php esc_html_e('Privacy checkbox', 'gwolle-gb'); ?>:</label></th>
310
  <td>
311
  <input type="checkbox" id="form_privacy_enabled" name="form_privacy_enabled"<?php
312
+ if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
313
  echo ' checked="checked"';
314
  }
315
  ?> />
admin/tabs/gb-readingtab.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settingstab_reading() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
@@ -26,7 +26,7 @@ function gwolle_gb_page_settingstab_reading() {
26
 
27
  /* Nonce */
28
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_readingtab' );
29
- echo '<input type="hidden" id="gwolle_gb_page_settings_readingtab" name="gwolle_gb_page_settings_readingtab" value="' . $nonce . '" />';
30
  ?>
31
  <table class="form-table">
32
  <tbody>
@@ -35,11 +35,12 @@ function gwolle_gb_page_settingstab_reading() {
35
  <th scope="row"><label for="entriesPerPage"><?php esc_html_e('Entries per page on the frontend', 'gwolle-gb'); ?></label></th>
36
  <td>
37
  <select name="entriesPerPage" id="entriesPerPage">
38
- <?php $entriesPerPage = (int) get_option( 'gwolle_gb-entriesPerPage', 20 );
39
- $presets = array(3, 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150, 200, 250);
40
- for ($i = 0; $i < count($presets); $i++) {
41
- echo '<option value="' . $presets[$i] . '"';
42
- if ($presets[$i] == $entriesPerPage) {
 
43
  echo ' selected="selected"';
44
  }
45
  echo '>' . $presets[$i] . ' ' . esc_html__('Entries', 'gwolle-gb') . '</option>';
@@ -59,14 +60,14 @@ function gwolle_gb_page_settingstab_reading() {
59
  $excerpt_length = (int) get_option( 'gwolle_gb-excerpt_length', 0 );
60
  $presets = array( 20, 40, 60, 80, 100, 120, 150, 200, 300 );
61
  echo '<option value="0"';
62
- if ( 0 == $excerpt_length ) {
63
  echo ' selected="selected"';
64
  }
65
  echo '>' . esc_html__('Unlimited Words', 'gwolle-gb') . '</option>';
66
 
67
  foreach ( $presets as $preset ) {
68
- echo '<option value="' . $preset . '"';
69
- if ($preset == $excerpt_length) {
70
  echo ' selected="selected"';
71
  }
72
  echo '>' . $preset . ' ' . esc_html__('Words', 'gwolle-gb') . '</option>';
@@ -123,7 +124,7 @@ function gwolle_gb_page_settingstab_reading() {
123
  ?> />
124
  <label for="linkAuthorWebsite"><?php esc_html_e("Link authors' name to their website.", 'gwolle-gb'); ?></label>
125
  <br />
126
- <span class="setting-description"><?php esc_html_e("The author of an entry can set his/her website. If this setting is checked, his/her name will be a link to that website.", 'gwolle-gb'); ?></span>
127
  </td>
128
  </tr>
129
 
@@ -135,9 +136,9 @@ function gwolle_gb_page_settingstab_reading() {
135
  echo ' checked="checked"';
136
  }
137
  ?> />
138
- <label for="admin_style"><?php esc_html_e("Admin entries get a special CSS styling.", 'gwolle-gb'); ?></label>
139
  <br />
140
- <span class="setting-description"><?php esc_html_e("Admin entries get a special CSS styling. It will get a lightgrey background.", 'gwolle-gb'); ?></span>
141
  </td>
142
  </tr>
143
 
@@ -151,7 +152,7 @@ function gwolle_gb_page_settingstab_reading() {
151
  <label><input type="radio" name="navigation" value="1" <?php checked('1', $navigation); ?> />
152
  <?php esc_html_e('Infinite Scroll', 'gwolle-gb'); ?>
153
  </label><br />
154
- <span class="setting-description"><?php esc_html_e("Use standard navigation with links to all pages, or use infinite scroll where entries will be added to the bottom as you are reading.", 'gwolle-gb'); ?></span>
155
  </td>
156
  </tr>
157
 
@@ -163,9 +164,9 @@ function gwolle_gb_page_settingstab_reading() {
163
  echo ' checked="checked"';
164
  }
165
  ?> />
166
- <label for="paginate_all"><?php esc_html_e("Show a link in the pagination for All entries.", 'gwolle-gb'); ?></label>
167
  <br />
168
- <span class="setting-description"><?php esc_html_e("Clicking this link will list all the published entries in the guestbook.", 'gwolle-gb'); ?></span>
169
  </td>
170
  </tr>
171
 
@@ -180,7 +181,7 @@ function gwolle_gb_page_settingstab_reading() {
180
  <th scope="row"><label for="read_avatar"><?php esc_html_e('Avatar', 'gwolle-gb'); ?>:</label></th>
181
  <td>
182
  <input type="checkbox" id="read_avatar" name="read_avatar"<?php
183
- if ( isset($read_setting['read_avatar']) && $read_setting['read_avatar'] === 'true' ) {
184
  echo ' checked="checked"';
185
  }
186
  ?> />
@@ -192,7 +193,7 @@ function gwolle_gb_page_settingstab_reading() {
192
  <th scope="row"><label for="read_name"><?php esc_html_e('Name', 'gwolle-gb'); ?>:</label></th>
193
  <td>
194
  <input type="checkbox" id="read_name" name="read_name"<?php
195
- if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' ) {
196
  echo ' checked="checked"';
197
  }
198
  ?> />
@@ -204,7 +205,7 @@ function gwolle_gb_page_settingstab_reading() {
204
  <th scope="row"><label for="read_city"><?php esc_html_e('City', 'gwolle-gb'); ?>:</label></th>
205
  <td>
206
  <input type="checkbox" id="read_city" name="read_city"<?php
207
- if ( isset($read_setting['read_city']) && $read_setting['read_city'] === 'true' ) {
208
  echo ' checked="checked"';
209
  }
210
  ?> />
@@ -216,12 +217,12 @@ function gwolle_gb_page_settingstab_reading() {
216
  <th scope="row"><label for="read_datetime"><?php esc_html_e('Date and Time', 'gwolle-gb'); ?>:</label></th>
217
  <td>
218
  <input type="checkbox" id="read_datetime" name="read_datetime"<?php
219
- if ( isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' ) {
220
  echo ' checked="checked"';
221
  }
222
  ?> />
223
  <label for="read_datetime"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label><br />
224
- <span class="setting-description"><?php esc_html_e("Setting this will show the date and the time of the entry.", 'gwolle-gb'); ?></span>
225
  </td>
226
  </tr>
227
 
@@ -229,12 +230,12 @@ function gwolle_gb_page_settingstab_reading() {
229
  <th scope="row"><label for="read_date"><?php esc_html_e('Date', 'gwolle-gb'); ?>:</label></th>
230
  <td>
231
  <input type="checkbox" id="read_date" name="read_date"<?php
232
- if ( isset($read_setting['read_date']) && $read_setting['read_date'] === 'true' ) {
233
  echo ' checked="checked"';
234
  }
235
  ?> />
236
  <label for="read_date"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label><br />
237
- <span class="setting-description"><?php esc_html_e("Setting this will show the date of the entry. If Date and Time above are enabled, that setting has preference.", 'gwolle-gb'); ?></span>
238
  </td>
239
  </tr>
240
 
@@ -242,7 +243,7 @@ function gwolle_gb_page_settingstab_reading() {
242
  <th scope="row"><label for="read_content"><?php esc_html_e('Content', 'gwolle-gb'); ?>:</label></th>
243
  <td>
244
  <input type="checkbox" id="read_content" name="read_content"<?php
245
- if ( isset($read_setting['read_content']) && $read_setting['read_content'] === 'true' ) {
246
  echo ' checked="checked"';
247
  }
248
  ?> />
@@ -254,7 +255,7 @@ function gwolle_gb_page_settingstab_reading() {
254
  <th scope="row"><label for="read_aavatar"><?php esc_html_e('Admin Avatar', 'gwolle-gb'); ?>:</label></th>
255
  <td>
256
  <input type="checkbox" id="read_aavatar" name="read_aavatar"<?php
257
- if ( isset($read_setting['read_aavatar']) && $read_setting['read_aavatar'] === 'true' ) {
258
  echo ' checked="checked"';
259
  }
260
  ?> />
@@ -266,12 +267,12 @@ function gwolle_gb_page_settingstab_reading() {
266
  <th scope="row"><label for="read_editlink"><?php esc_html_e('Edit link', 'gwolle-gb'); ?>:</label></th>
267
  <td>
268
  <input type="checkbox" id="read_editlink" name="read_editlink"<?php
269
- if ( isset($read_setting['read_editlink']) && $read_setting['read_editlink'] === 'true' ) {
270
  echo ' checked="checked"';
271
  }
272
  ?> />
273
  <label for="read_editlink"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label><br />
274
- <span class="setting-description"><?php esc_html_e("A link to the editor will be added to the metabox. Only visible for moderators.", 'gwolle-gb'); ?></span>
275
  </td>
276
  </tr>
277
 
14
  */
15
  function gwolle_gb_page_settingstab_reading() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  } ?>
20
 
26
 
27
  /* Nonce */
28
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_readingtab' );
29
+ echo '<input type="hidden" id="gwolle_gb_page_settings_readingtab" name="gwolle_gb_page_settings_readingtab" value="' . esc_attr( $nonce ) . '" />';
30
  ?>
31
  <table class="form-table">
32
  <tbody>
35
  <th scope="row"><label for="entriesPerPage"><?php esc_html_e('Entries per page on the frontend', 'gwolle-gb'); ?></label></th>
36
  <td>
37
  <select name="entriesPerPage" id="entriesPerPage">
38
+ <?php $entries_per_page = (int) get_option( 'gwolle_gb-entriesPerPage', 20 );
39
+ $presets = array( 3, 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150, 200, 250 );
40
+ $presets_count = count( $presets );
41
+ for ($i = 0; $i < $presets_count; $i++) {
42
+ echo '<option value="' . (int) $presets[$i] . '"';
43
+ if ($presets[$i] === $entries_per_page) {
44
  echo ' selected="selected"';
45
  }
46
  echo '>' . $presets[$i] . ' ' . esc_html__('Entries', 'gwolle-gb') . '</option>';
60
  $excerpt_length = (int) get_option( 'gwolle_gb-excerpt_length', 0 );
61
  $presets = array( 20, 40, 60, 80, 100, 120, 150, 200, 300 );
62
  echo '<option value="0"';
63
+ if ( 0 === $excerpt_length ) {
64
  echo ' selected="selected"';
65
  }
66
  echo '>' . esc_html__('Unlimited Words', 'gwolle-gb') . '</option>';
67
 
68
  foreach ( $presets as $preset ) {
69
+ echo '<option value="' . (int) $preset . '"';
70
+ if ($preset === $excerpt_length) {
71
  echo ' selected="selected"';
72
  }
73
  echo '>' . $preset . ' ' . esc_html__('Words', 'gwolle-gb') . '</option>';
124
  ?> />
125
  <label for="linkAuthorWebsite"><?php esc_html_e("Link authors' name to their website.", 'gwolle-gb'); ?></label>
126
  <br />
127
+ <span class="setting-description"><?php esc_html_e('The author of an entry can set his/her website. If this setting is checked, his/her name will be a link to that website.', 'gwolle-gb'); ?></span>
128
  </td>
129
  </tr>
130
 
136
  echo ' checked="checked"';
137
  }
138
  ?> />
139
+ <label for="admin_style"><?php esc_html_e('Admin entries get a special CSS styling.', 'gwolle-gb'); ?></label>
140
  <br />
141
+ <span class="setting-description"><?php esc_html_e('Admin entries get a special CSS styling. It will get a lightgrey background.', 'gwolle-gb'); ?></span>
142
  </td>
143
  </tr>
144
 
152
  <label><input type="radio" name="navigation" value="1" <?php checked('1', $navigation); ?> />
153
  <?php esc_html_e('Infinite Scroll', 'gwolle-gb'); ?>
154
  </label><br />
155
+ <span class="setting-description"><?php esc_html_e('Use standard navigation with links to all pages, or use infinite scroll where entries will be added to the bottom as you are reading.', 'gwolle-gb'); ?></span>
156
  </td>
157
  </tr>
158
 
164
  echo ' checked="checked"';
165
  }
166
  ?> />
167
+ <label for="paginate_all"><?php esc_html_e('Show a link in the pagination for All entries.', 'gwolle-gb'); ?></label>
168
  <br />
169
+ <span class="setting-description"><?php esc_html_e('Clicking this link will list all the published entries in the guestbook.', 'gwolle-gb'); ?></span>
170
  </td>
171
  </tr>
172
 
181
  <th scope="row"><label for="read_avatar"><?php esc_html_e('Avatar', 'gwolle-gb'); ?>:</label></th>
182
  <td>
183
  <input type="checkbox" id="read_avatar" name="read_avatar"<?php
184
+ if ( isset($read_setting['read_avatar']) && $read_setting['read_avatar'] === 'true' ) {
185
  echo ' checked="checked"';
186
  }
187
  ?> />
193
  <th scope="row"><label for="read_name"><?php esc_html_e('Name', 'gwolle-gb'); ?>:</label></th>
194
  <td>
195
  <input type="checkbox" id="read_name" name="read_name"<?php
196
+ if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' ) {
197
  echo ' checked="checked"';
198
  }
199
  ?> />
205
  <th scope="row"><label for="read_city"><?php esc_html_e('City', 'gwolle-gb'); ?>:</label></th>
206
  <td>
207
  <input type="checkbox" id="read_city" name="read_city"<?php
208
+ if ( isset($read_setting['read_city']) && $read_setting['read_city'] === 'true' ) {
209
  echo ' checked="checked"';
210
  }
211
  ?> />
217
  <th scope="row"><label for="read_datetime"><?php esc_html_e('Date and Time', 'gwolle-gb'); ?>:</label></th>
218
  <td>
219
  <input type="checkbox" id="read_datetime" name="read_datetime"<?php
220
+ if ( isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' ) {
221
  echo ' checked="checked"';
222
  }
223
  ?> />
224
  <label for="read_datetime"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label><br />
225
+ <span class="setting-description"><?php esc_html_e('Setting this will show the date and the time of the entry.', 'gwolle-gb'); ?></span>
226
  </td>
227
  </tr>
228
 
230
  <th scope="row"><label for="read_date"><?php esc_html_e('Date', 'gwolle-gb'); ?>:</label></th>
231
  <td>
232
  <input type="checkbox" id="read_date" name="read_date"<?php
233
+ if ( isset($read_setting['read_date']) && $read_setting['read_date'] === 'true' ) {
234
  echo ' checked="checked"';
235
  }
236
  ?> />
237
  <label for="read_date"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label><br />
238
+ <span class="setting-description"><?php esc_html_e('Setting this will show the date of the entry. If Date and Time above are enabled, that setting has preference.', 'gwolle-gb'); ?></span>
239
  </td>
240
  </tr>
241
 
243
  <th scope="row"><label for="read_content"><?php esc_html_e('Content', 'gwolle-gb'); ?>:</label></th>
244
  <td>
245
  <input type="checkbox" id="read_content" name="read_content"<?php
246
+ if ( isset($read_setting['read_content']) && $read_setting['read_content'] === 'true' ) {
247
  echo ' checked="checked"';
248
  }
249
  ?> />
255
  <th scope="row"><label for="read_aavatar"><?php esc_html_e('Admin Avatar', 'gwolle-gb'); ?>:</label></th>
256
  <td>
257
  <input type="checkbox" id="read_aavatar" name="read_aavatar"<?php
258
+ if ( isset($read_setting['read_aavatar']) && $read_setting['read_aavatar'] === 'true' ) {
259
  echo ' checked="checked"';
260
  }
261
  ?> />
267
  <th scope="row"><label for="read_editlink"><?php esc_html_e('Edit link', 'gwolle-gb'); ?>:</label></th>
268
  <td>
269
  <input type="checkbox" id="read_editlink" name="read_editlink"<?php
270
+ if ( isset($read_setting['read_editlink']) && $read_setting['read_editlink'] === 'true' ) {
271
  echo ' checked="checked"';
272
  }
273
  ?> />
274
  <label for="read_editlink"><?php esc_html_e('Enabled', 'gwolle-gb'); ?></label><br />
275
+ <span class="setting-description"><?php esc_html_e('A link to the editor will be added to the metabox. Only visible for moderators.', 'gwolle-gb'); ?></span>
276
  </td>
277
  </tr>
278
 
admin/tabs/gb-uninstalltab.php CHANGED
@@ -14,10 +14,10 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settingstab_uninstall() {
16
 
17
- if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
- if ( function_exists('is_multisite') && is_multisite() ) {
21
  esc_html_e('You are on a multisite install of WordPress. Please take a look at the documentation how to remove all the data of this plugin on multisite.', 'gwolle-gb');
22
  return;
23
  } ?>
@@ -29,7 +29,7 @@ function gwolle_gb_page_settingstab_uninstall() {
29
 
30
  /* Nonce */
31
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_uninstalltab' );
32
- echo '<input type="hidden" id="gwolle_gb_page_settings_uninstalltab" name="gwolle_gb_page_settings_uninstalltab" value="' . $nonce . '" />';
33
  ?>
34
  <table class="form-table">
35
  <tbody>
14
  */
15
  function gwolle_gb_page_settingstab_uninstall() {
16
 
17
+ if ( ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
+ if ( is_multisite() ) {
21
  esc_html_e('You are on a multisite install of WordPress. Please take a look at the documentation how to remove all the data of this plugin on multisite.', 'gwolle-gb');
22
  return;
23
  } ?>
29
 
30
  /* Nonce */
31
  $nonce = wp_create_nonce( 'gwolle_gb_page_settings_uninstalltab' );
32
+ echo '<input type="hidden" id="gwolle_gb_page_settings_uninstalltab" name="gwolle_gb_page_settings_uninstalltab" value="' . esc_attr( $nonce ) . '" />';
33
  ?>
34
  <table class="form-table">
35
  <tbody>
docs/actions/gwolle_gb_save_entry_frontend.txt CHANGED
@@ -15,7 +15,11 @@ Where 'action_function_name' is the function WordPress should call when the acti
15
 
16
  ==Examples==
17
 
18
- function my_gwolle_gb_save_entry_frontend( $entry ) {
 
 
 
 
19
  // $entry is an object.
20
 
21
  // redirect moderator to the Editor.
@@ -25,4 +29,19 @@ function my_gwolle_gb_save_entry_frontend( $entry ) {
25
  }
26
 
27
  }
28
- add_action( 'gwolle_gb_save_entry_frontend', 'my_gwolle_gb_save_entry_frontend' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  ==Examples==
17
 
18
+ /*
19
+ * Redirect after saving an entry on the frontend.
20
+ * Please be aware that you will not see messages on the form and this redirect only works if AJAX is disabled.
21
+ */
22
+ function my_redirect_gwolle_gb_save_entry_frontend( $entry ) {
23
  // $entry is an object.
24
 
25
  // redirect moderator to the Editor.
29
  }
30
 
31
  }
32
+ add_action( 'gwolle_gb_save_entry_frontend', 'my_redirect_gwolle_gb_save_entry_frontend' );
33
+
34
+
35
+ /*
36
+ * Change the content of the saved message.
37
+ */
38
+ function my_quotes_gwolle_gb_save_entry_frontend( $entry ) {
39
+ // $entry is an object.
40
+
41
+ $entry_content = $entry->get_content();
42
+ $entry_content = '" ' . $entry_content . ' "';
43
+ $entry->set_content( $entry_content );
44
+ $entry->save();
45
+
46
+ }
47
+ add_action( 'gwolle_gb_save_entry_frontend', 'my_quotes_gwolle_gb_save_entry_frontend' );
docs/filters/gwolle_gb_entry_metabox_lines.txt CHANGED
@@ -21,7 +21,7 @@ Make sure you wrap your "line" inside a div with the gb-metabox-line class, like
21
  * Edit Link for Moderators
22
  */
23
  function my_gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
24
- if ( function_exists('current_user_can') && current_user_can('moderate_comments') ) {
25
  $gb_metabox .= '
26
  <div class="gb-metabox-line">
27
  <a class="gwolle_gb_edit_link" href="' . admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&amp;entry_id=' . $entry->get_id() ) . '" title="' . esc_html__('Edit entry', 'gwolle-gb') . '">' . esc_html__('Edit', 'gwolle-gb') . '</a>
21
  * Edit Link for Moderators
22
  */
23
  function my_gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
24
+ if ( current_user_can('moderate_comments') ) {
25
  $gb_metabox .= '
26
  <div class="gb-metabox-line">
27
  <a class="gwolle_gb_edit_link" href="' . admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&amp;entry_id=' . $entry->get_id() ) . '" title="' . esc_html__('Edit entry', 'gwolle-gb') . '">' . esc_html__('Edit', 'gwolle-gb') . '</a>
docs/filters/gwolle_gb_get_entries_sql.txt CHANGED
@@ -16,12 +16,22 @@ Where 'filter_function_name' is the function WordPress should call when the filt
16
  ==Examples==
17
 
18
  // Set ordering to ASC.
19
- function my_gwolle_gb_get_entries_sql( $sql, $sql_nonprepared, $values, $args ) {
20
- // $sql is a string
 
 
 
 
 
 
21
  $old = 'DESC';
22
  $new = 'ASC';
23
- $sql = str_replace( $old, $new, $sql );
 
 
 
24
  return $sql;
 
25
  }
26
- add_filter( 'gwolle_gb_get_entries_sql', 'my_gwolle_gb_get_entries_sql', 10, 4 );
27
 
16
  ==Examples==
17
 
18
  // Set ordering to ASC.
19
+ function my_asc_gwolle_gb_get_entries_sql( $sql, $sql_nonprepared, $values, $args ) {
20
+
21
+ global $wpdb;
22
+
23
+ if ( is_admin() ) {
24
+ return $sql;
25
+ }
26
+
27
  $old = 'DESC';
28
  $new = 'ASC';
29
+ $sql_nonprepared = str_replace( $old, $new, $sql_nonprepared );
30
+ // Always use $wpdb->prepare(), no exceptions.
31
+ $sql = $wpdb->prepare( $sql_nonprepared, $values );
32
+
33
  return $sql;
34
+
35
  }
36
+ add_filter( 'gwolle_gb_get_entries_sql', 'my_asc_gwolle_gb_get_entries_sql', 10, 4 );
37
 
docs/filters/{gwolle_gb_mail_moderator_body.txt → gwolle_gb_mail_moderators_body.txt} RENAMED
File without changes
docs/filters/{gwolle_gb_mail_moderator_subject.txt → gwolle_gb_mail_moderators_subject.txt} RENAMED
File without changes
frontend/gb-ajax-infinite-scroll.php CHANGED
@@ -1,98 +1,98 @@
1
- <?php
2
-
3
-
4
- // No direct calls to this script
5
- if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
6
- die('No direct calls allowed!');
7
- }
8
-
9
-
10
- /*
11
- * Handles AJAX request from Gwolle-GB for Infinite Scroll.
12
- * Will only be used if Infinite Scroll is enabled instead of default pagination.
13
- *
14
- * Prints html with a list of entries.
15
- */
16
- function gwolle_gb_infinite_scroll_callback() {
17
-
18
- $output = '';
19
-
20
- $pageNum = 1;
21
- if ( isset($_POST['pageNum']) && is_numeric($_POST['pageNum']) ) {
22
- $pageNum = (int) $_POST['pageNum'];
23
- }
24
-
25
- $book_id = 1;
26
- if ( isset($_POST['book_id']) && is_numeric($_POST['book_id']) ) {
27
- $book_id = (int) $_POST['book_id'];
28
- }
29
- $shortcode_atts = array();
30
- $shortcode_atts['book_id'] = $book_id;
31
-
32
- $num_entries = (int) get_option('gwolle_gb-entriesPerPage', 20);
33
- $num_entries = (int) apply_filters( 'gwolle_gb_read_num_entries', $num_entries, $shortcode_atts );
34
-
35
- if ( $pageNum == 1 ) {
36
- $offset = 0;
37
- } else {
38
- $offset = ( $pageNum - 1 ) * $num_entries;
39
- }
40
-
41
-
42
- /* Get the entries for the frontend */
43
- $entries = gwolle_gb_get_entries(
44
- array(
45
- 'offset' => $offset,
46
- 'num_entries' => $num_entries,
47
- 'checked' => 'checked',
48
- 'trash' => 'notrash',
49
- 'spam' => 'nospam',
50
- 'book_id' => $book_id
51
- )
52
- );
53
-
54
-
55
- /* Entries from the template */
56
- if ( ! is_array($entries) || empty($entries) ) {
57
- $output .= 'false';
58
- } else {
59
-
60
- // Try to load and require_once the template from the themes folders.
61
- if ( locate_template( array('gwolle_gb-entry.php'), true, true ) == '') {
62
-
63
- $output .= '<!-- Gwolle-GB Entry: Default Template Loaded -->
64
- ';
65
-
66
- // No template found and loaded in the theme folders.
67
- // Load the template from the plugin folder.
68
- require_once( GWOLLE_GB_DIR . '/frontend/gwolle_gb-entry.php' );
69
-
70
- } else {
71
-
72
- $output .= '<!-- Gwolle-GB Entry: Custom Template Loaded -->
73
- ';
74
-
75
- }
76
-
77
- $counter = $offset;
78
- $first = false;
79
- foreach ($entries as $entry) {
80
- $counter++;
81
-
82
- // Run the function from the template to get the entry.
83
- $entry_output = gwolle_gb_entry_template( $entry, $first, $counter );
84
-
85
- // Add a filter for each entry, so devs can add or remove parts.
86
- $output .= apply_filters( 'gwolle_gb_entry_read', $entry_output, $entry );
87
-
88
- }
89
-
90
- }
91
-
92
- echo $output;
93
-
94
- die(); // this is required to return a proper result
95
-
96
- }
97
- add_action( 'wp_ajax_gwolle_gb_infinite_scroll', 'gwolle_gb_infinite_scroll_callback' );
98
- add_action( 'wp_ajax_nopriv_gwolle_gb_infinite_scroll', 'gwolle_gb_infinite_scroll_callback' );
1
+ <?php
2
+
3
+
4
+ // No direct calls to this script
5
+ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
6
+ die('No direct calls allowed!');
7
+ }
8
+
9
+
10
+ /*
11
+ * Handles AJAX request from Gwolle-GB for Infinite Scroll.
12
+ * Will only be used if Infinite Scroll is enabled instead of default pagination.
13
+ *
14
+ * Prints html with a list of entries.
15
+ */
16
+ function gwolle_gb_infinite_scroll_callback() {
17
+
18
+ $output = '';
19
+
20
+ $page_num = 1;
21
+ if ( isset($_POST['pageNum']) && is_numeric($_POST['pageNum']) ) {
22
+ $page_num = (int) $_POST['pageNum'];
23
+ }
24
+
25
+ $book_id = 1;
26
+ if ( isset($_POST['book_id']) && is_numeric($_POST['book_id']) ) {
27
+ $book_id = (int) $_POST['book_id'];
28
+ }
29
+ $shortcode_atts = array();
30
+ $shortcode_atts['book_id'] = $book_id;
31
+
32
+ $num_entries = (int) get_option('gwolle_gb-entriesPerPage', 20);
33
+ $num_entries = (int) apply_filters( 'gwolle_gb_read_num_entries', $num_entries, $shortcode_atts );
34
+
35
+ if ( $page_num === 1 ) {
36
+ $offset = 0;
37
+ } else {
38
+ $offset = ( $page_num - 1 ) * $num_entries;
39
+ }
40
+
41
+
42
+ /* Get the entries for the frontend */
43
+ $entries = gwolle_gb_get_entries(
44
+ array(
45
+ 'offset' => $offset,
46
+ 'num_entries' => $num_entries,
47
+ 'checked' => 'checked',
48
+ 'trash' => 'notrash',
49
+ 'spam' => 'nospam',
50
+ 'book_id' => $book_id,
51
+ )
52
+ );
53
+
54
+
55
+ /* Entries from the template */
56
+ if ( ! is_array($entries) || empty($entries) ) {
57
+ $output .= 'false';
58
+ } else {
59
+
60
+ // Try to load and require_once the template from the themes folders.
61
+ if ( locate_template( array( 'gwolle_gb-entry.php' ), true, true ) === '') {
62
+
63
+ $output .= '<!-- Gwolle-GB Entry: Default Template Loaded -->
64
+ ';
65
+
66
+ // No template found and loaded in the theme folders.
67
+ // Load the template from the plugin folder.
68
+ require_once GWOLLE_GB_DIR . '/frontend/gwolle_gb-entry.php';
69
+
70
+ } else {
71
+
72
+ $output .= '<!-- Gwolle-GB Entry: Custom Template Loaded -->
73
+ ';
74
+
75
+ }
76
+
77
+ $counter = $offset;
78
+ $first = false;
79
+ foreach ($entries as $entry) {
80
+ $counter++;
81
+
82
+ // Run the function from the template to get the entry.
83
+ $entry_output = gwolle_gb_entry_template( $entry, $first, $counter );
84
+
85
+ // Add a filter for each entry, so devs can add or remove parts.
86
+ $output .= apply_filters( 'gwolle_gb_entry_read', $entry_output, $entry );
87
+
88
+ }
89
+
90
+ }
91
+
92
+ echo $output;
93
+
94
+ die(); // this is required to return a proper result
95
+
96
+ }
97
+ add_action( 'wp_ajax_gwolle_gb_infinite_scroll', 'gwolle_gb_infinite_scroll_callback' );
98
+ add_action( 'wp_ajax_nopriv_gwolle_gb_infinite_scroll', 'gwolle_gb_infinite_scroll_callback' );
frontend/gb-blocklist.php CHANGED
@@ -80,7 +80,7 @@ function gwolle_gb_blocklist( $entry ) {
80
  }
81
  }
82
 
83
- if ( $send_to_moderation == true ) {
84
  $entry->set_ischecked( false );
85
  }
86
 
80
  }
81
  }
82
 
83
+ if ( $send_to_moderation === true ) {
84
  $entry->set_ischecked( false );
85
  }
86
 
frontend/gb-form-ajax.php CHANGED
@@ -1,46 +1,46 @@
1
- <?php
2
-
3
-
4
- // No direct calls to this script
5
- if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
6
- die('No direct calls allowed!');
7
- }
8
-
9
-
10
- /*
11
- * Handles AJAX request from Gwolle-GB AJAX Submit.
12
- *
13
- * @return string json encoded data, which is handled with by frontend/js/script.js.
14
- */
15
- function gwolle_gb_form_ajax_callback() {
16
-
17
- $saved = gwolle_gb_frontend_posthandling();
18
-
19
- $data = array();
20
- $data['saved'] = $saved;
21
- $data['gwolle_gb_messages'] = gwolle_gb_get_messages();
22
- $data['gwolle_gb_errors'] = gwolle_gb_get_errors();
23
- $data['gwolle_gb_error_fields'] = gwolle_gb_get_error_fields();
24
-
25
- if ( $saved ) {
26
- $entry = new gwolle_gb_entry();
27
- $result = $entry->load( $saved );
28
- if ( $result ) {
29
- if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
30
-
31
- // Invisible.
32
-
33
- } else {
34
-
35
- $data['entry'] = gwolle_gb_single_view( $entry, true, 0 );
36
-
37
- }
38
- }
39
- }
40
-
41
- echo json_encode( $data );
42
- die(); // This is required to return a proper result.
43
-
44
- }
45
- add_action( 'wp_ajax_gwolle_gb_form_ajax', 'gwolle_gb_form_ajax_callback' );
46
- add_action( 'wp_ajax_nopriv_gwolle_gb_form_ajax', 'gwolle_gb_form_ajax_callback' );
1
+ <?php
2
+
3
+
4
+ // No direct calls to this script
5
+ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
6
+ die('No direct calls allowed!');
7
+ }
8
+
9
+
10
+ /*
11
+ * Handles AJAX request from Gwolle-GB AJAX Submit.
12
+ *
13
+ * @return string json encoded data, which is handled with by frontend/js/script.js.
14
+ */
15
+ function gwolle_gb_form_ajax_callback() {
16
+
17
+ $saved = gwolle_gb_frontend_posthandling();
18
+
19
+ $data = array();
20
+ $data['saved'] = $saved;
21
+ $data['gwolle_gb_messages'] = gwolle_gb_get_messages();
22
+ $data['gwolle_gb_errors'] = gwolle_gb_get_errors();
23
+ $data['gwolle_gb_error_fields'] = gwolle_gb_get_error_fields();
24
+
25
+ if ( $saved ) {
26
+ $entry = new gwolle_gb_entry();
27
+ $result = $entry->load( $saved );
28
+ if ( $result ) {
29
+ if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
30
+
31
+ // Invisible.
32
+
33
+ } else {
34
+
35
+ $data['entry'] = gwolle_gb_single_view( $entry, true, 0 );
36
+
37
+ }
38
+ }
39
+ }
40
+
41
+ echo json_encode( $data );
42
+ die(); // This is required to return a proper result.
43
+
44
+ }
45
+ add_action( 'wp_ajax_gwolle_gb_form_ajax', 'gwolle_gb_form_ajax_callback' );
46
+ add_action( 'wp_ajax_nopriv_gwolle_gb_form_ajax', 'gwolle_gb_form_ajax_callback' );
frontend/gb-form-posthandling.php CHANGED
@@ -8,12 +8,12 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
8
 
9
  /*
10
  * Handle the $_POST for the Frontend on a new entry.
11
- * Use this action, since $post is populated and we can use get_the_ID().
12
  */
13
  function gwolle_gb_handle_post() {
14
  if ( ! is_admin() ) {
15
  // Frontend Handling of $_POST, only one form
16
- if ( isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] == 'add_entry' ) {
17
  gwolle_gb_frontend_posthandling();
18
  }
19
  }
@@ -33,10 +33,10 @@ add_action('wp', 'gwolle_gb_handle_post');
33
  */
34
  function gwolle_gb_frontend_posthandling() {
35
 
36
- if ( isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] == 'add_entry' ) {
37
 
38
  // Option to allow only logged-in users to post. Don't show the form if not logged-in.
39
- if ( !is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true' ) {
40
  gwolle_gb_add_message( '<p class="require_login"><strong>' . esc_html__('Submitting a new guestbook entry is only allowed for logged-in users.', 'gwolle-gb') . '</strong></p>', true, false);
41
  return false;
42
  }
@@ -49,47 +49,47 @@ function gwolle_gb_frontend_posthandling() {
49
  $form_setting = gwolle_gb_get_setting( 'form' );
50
 
51
  /* Name */
52
- if ( isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true' ) {
53
  $field_name = gwolle_gb_get_field_name( 'name' );
54
  if (isset($_POST["$field_name"])) {
55
  $author_name = trim($_POST["$field_name"]);
56
  $author_name = gwolle_gb_maybe_encode_emoji( $author_name, 'author_name' );
57
  $gwolle_gb_formdata['author_name'] = $author_name;
58
  gwolle_gb_add_formdata( 'author_name', $author_name );
59
- if ( $author_name == "" ) {
60
- if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
61
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your name is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
62
  }
63
  }
64
  } else {
65
- if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
66
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your name is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
67
  }
68
  }
69
  }
70
 
71
  /* City / Origin */
72
- if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true' ) {
73
  $field_name = gwolle_gb_get_field_name( 'city' );
74
  if (isset($_POST["$field_name"])) {
75
  $author_origin = trim($_POST["$field_name"]);
76
  $author_origin = gwolle_gb_maybe_encode_emoji( $author_origin, 'author_origin' );
77
  $gwolle_gb_formdata['author_origin'] = $author_origin;
78
  gwolle_gb_add_formdata( 'author_origin', $author_origin );
79
- if ( $author_origin == "" ) {
80
- if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
81
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your origin is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
82
  }
83
  }
84
  } else {
85
- if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
86
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your origin is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
87
  }
88
  }
89
  }
90
 
91
  /* Email */
92
- if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true' ) {
93
  $field_name = gwolle_gb_get_field_name( 'email' );
94
  if (isset($_POST["$field_name"])) {
95
  $author_email = trim($_POST["$field_name"]);
@@ -97,11 +97,11 @@ function gwolle_gb_frontend_posthandling() {
97
  gwolle_gb_add_formdata( 'author_email', $author_email );
98
  if ( filter_var( $author_email, FILTER_VALIDATE_EMAIL ) ) {
99
  // Valid Email address.
100
- } else if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
101
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your e-mail address is not filled in correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
102
  }
103
  } else {
104
- if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
105
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your e-mail address is not filled in correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
106
  }
107
  }
@@ -114,36 +114,36 @@ function gwolle_gb_frontend_posthandling() {
114
  }
115
 
116
  /* Website / Homepage */
117
- if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true' ) {
118
  $field_name = gwolle_gb_get_field_name( 'website' );
119
  if (isset($_POST["$field_name"])) {
120
  $author_website = trim($_POST["$field_name"]);
121
  $gwolle_gb_formdata['author_website'] = $author_website;
122
  gwolle_gb_add_formdata( 'author_website', $author_website );
123
  $pattern = '/^http/';
124
- if ( !preg_match($pattern, $author_website, $matches) ) {
125
- $author_website = "http://" . $author_website;
126
  }
127
  if ( filter_var( $author_website, FILTER_VALIDATE_URL ) ) {
128
  // Valid Website URL.
129
- } else if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
130
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your website is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
131
  }
132
  } else {
133
- if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
134
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your website is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
135
  }
136
  }
137
  }
138
 
139
  /* Message */
140
- if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
141
  $field_name = gwolle_gb_get_field_name( 'content' );
142
  if (isset($_POST["$field_name"])) {
143
  $content = trim($_POST["$field_name"]);
144
- if ( $content == '' ) {
145
- if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
146
- gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There is no message, even though it is mandatory.', 'gwolle-gb') . '</strong></p>',true, $field_name); // mandatory
147
  }
148
  } else {
149
  $content = gwolle_gb_maybe_encode_emoji( $content, 'content' );
@@ -151,20 +151,20 @@ function gwolle_gb_frontend_posthandling() {
151
  gwolle_gb_add_formdata( 'content', $content );
152
  }
153
  } else {
154
- if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
155
- gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There is no message, even though it is mandatory.', 'gwolle-gb') . '</strong></p>',true, $field_name); // mandatory
156
  }
157
  }
158
  }
159
 
160
  /* Custom Anti-Spam */
161
- if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
162
  $field_name = gwolle_gb_get_field_name( 'custom' );
163
  $antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
164
  $antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
165
 
166
  if ( isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0 ) {
167
- if ( isset($_POST["$field_name"]) && trim($_POST["$field_name"]) == trim($antispam_answer) ) {
168
  //echo "You got it!";
169
  } else {
170
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('The anti-spam question was not answered correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
@@ -178,8 +178,8 @@ function gwolle_gb_frontend_posthandling() {
178
  }
179
 
180
  /* Privacy checkbox for GDPR compliance. */
181
- if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
182
- if (isset($_POST['gwolle_gb_privacy']) && $_POST['gwolle_gb_privacy'] == 'on') {
183
  gwolle_gb_add_formdata( 'gwolle_gb_privacy', 'on' );
184
  } else {
185
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('You did not accept the privacy policy, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, 'gwolle_gb_privacy'); // mandatory
@@ -204,7 +204,7 @@ function gwolle_gb_frontend_posthandling() {
204
  * Do this before the gwolle_gb_new_entry_frontend hook, so we can change it again if a hook needs to.
205
  */
206
  $user_id = get_current_user_id(); // Returns 0 if no current user.
207
- if ( get_option('gwolle_gb-moderate-entries', 'true') == 'true' ) {
208
  // Moderation, only set to checked for moderators.
209
  if ( gwolle_gb_is_moderator($user_id) ) {
210
  $entry->set_ischecked( true );
@@ -243,7 +243,7 @@ function gwolle_gb_frontend_posthandling() {
243
  // Returned true, so considered spam
244
  $entry->set_isspam(true);
245
  $marked_by_akismet = true;
246
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
247
  gwolle_gb_add_message( '<p class="refuse-spam-akismet"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
248
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
249
  return false;
@@ -253,13 +253,13 @@ function gwolle_gb_frontend_posthandling() {
253
 
254
  /* Stop Forum Spam: check for spam and set accordingly */
255
  $marked_by_sfs = false;
256
- if ( get_option( 'gwolle_gb-sfs', 'false') == 'true' ) {
257
  $isspam = gwolle_gb_stop_forum_spam( $entry );
258
  if ( $isspam ) {
259
  // Returned true, so considered spam
260
  $entry->set_isspam(true);
261
  $marked_by_sfs = true;
262
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
263
  gwolle_gb_add_message( '<p class="refuse-spam-sfs"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
264
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
265
  return false;
@@ -270,7 +270,7 @@ function gwolle_gb_frontend_posthandling() {
270
 
271
  /* Honeypot: check for spam and set accordingly. */
272
  $marked_by_honeypot = false;
273
- if (get_option( 'gwolle_gb-honeypot', 'true') == 'true') {
274
  $field_name = gwolle_gb_get_field_name( 'honeypot' );
275
  $field_name2 = gwolle_gb_get_field_name( 'honeypot2' );
276
  $honeypot_value = (int) get_option( 'gwolle_gb-honeypot_value', 15 );
@@ -278,17 +278,17 @@ function gwolle_gb_frontend_posthandling() {
278
  // Input field was filled in, so considered spam
279
  $entry->set_isspam(true);
280
  $marked_by_honeypot = true;
281
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
282
  gwolle_gb_add_message( '<p class="refuse-spam-honeypot"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
283
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
284
  return false;
285
  }
286
  }
287
- if ( ! isset($_POST["$field_name2"]) || $_POST["$field_name2"] != $honeypot_value ) {
288
  // Input field was not filled in correctly, so considered spam
289
  $entry->set_isspam(true);
290
  $marked_by_honeypot = true;
291
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
292
  gwolle_gb_add_message( '<p class="refuse-spam-honeypot2"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
293
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
294
  return false;
@@ -299,14 +299,14 @@ function gwolle_gb_frontend_posthandling() {
299
 
300
  /* Nonce: check for spam and set accordingly. */
301
  $marked_by_nonce = false;
302
- if (get_option( 'gwolle_gb-nonce', 'true') == 'true') {
303
  $field_name = gwolle_gb_get_field_name( 'nonce' );
304
- $verified = wp_verify_nonce( $_REQUEST["$field_name"], 'gwolle_gb_add_entry' );
305
- if ( $verified == false ) {
306
  // Nonce is invalid, so considered spam
307
  $entry->set_isspam(true);
308
  $marked_by_nonce = true;
309
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
310
  gwolle_gb_add_message( '<p class="refuse-spam-nonce"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
311
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
312
  return false;
@@ -317,10 +317,10 @@ function gwolle_gb_frontend_posthandling() {
317
 
318
  /* Scan for long and abusive text. */
319
  $marked_by_longtext = false;
320
- if ( get_option( 'gwolle_gb-longtext', 'true') == 'true' ) {
321
  // Check for abusive content (too long words). Set it to unchecked, so manual moderation is needed.
322
  $maxlength = 100;
323
- $words = explode( " ", $entry->get_content() );
324
  foreach ( $words as $word ) {
325
  $pattern = '/^href=http/';
326
  if ( preg_match($pattern, $word, $matches) ) {
@@ -341,7 +341,7 @@ function gwolle_gb_frontend_posthandling() {
341
  }
342
  }
343
  $maxlength = 60;
344
- $words = explode( " ", $entry->get_author_name() );
345
  foreach ( $words as $word ) {
346
  if ( strlen($word) > $maxlength ) {
347
  $entry->set_ischecked( false );
@@ -355,8 +355,8 @@ function gwolle_gb_frontend_posthandling() {
355
  /* Scan with Link Checker. */
356
  $marked_by_linkchecker = false;
357
  $counter_for_linkchecker = 0;
358
- if ( get_option( 'gwolle_gb-linkchecker', 'true') == 'true' ) {
359
- $words = explode( " ", $entry->get_content() );
360
  foreach ( $words as $word ) {
361
  $pattern = '/(http|https)\:\/\/?/';
362
  if ( preg_match( $pattern, $word, $matches ) ) {
@@ -367,7 +367,7 @@ function gwolle_gb_frontend_posthandling() {
367
  if ( $counter_for_linkchecker > 1 ) {
368
  $entry->set_isspam( true );
369
  $marked_by_linkchecker = true;
370
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
371
  gwolle_gb_add_message( '<p class="refuse-spam-linkchecker"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
372
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
373
  return false;
@@ -378,18 +378,18 @@ function gwolle_gb_frontend_posthandling() {
378
 
379
  /* Form Timeout: check for spam and set accordingly. */
380
  $marked_by_timeout = false;
381
- if (get_option( 'gwolle_gb-timeout', 'true') == 'true') {
382
  $field_name = gwolle_gb_get_field_name( 'timeout' );
383
  $field_name2 = gwolle_gb_get_field_name( 'timeout2' );
384
  if ( isset($_POST["$field_name"]) && strlen($_POST["$field_name"]) > 0 && isset($_POST["$field_name2"]) && strlen($_POST["$field_name2"]) > 0 ) {
385
  // Input fields were filled in, so continue.
386
  $timeout = (int) $_POST["$field_name"];
387
  $timeout2 = (int) $_POST["$field_name2"];
388
- if ( ($timeout2 - $timeout) < 2 ) {
389
  // Submitted less then 1 second after loading. Considered spam.
390
  $entry->set_isspam(true);
391
  $marked_by_timeout = true;
392
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
393
  gwolle_gb_add_message( '<p class="refuse-spam-timeout"><strong>' . esc_html__('Your entry was submitted too fast, please slow down and try again.', 'gwolle-gb') . '</strong></p>', true, false );
394
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
395
  return false;
@@ -399,7 +399,7 @@ function gwolle_gb_frontend_posthandling() {
399
  // Input fields were not filled in correctly. Considered spam.
400
  $entry->set_isspam(true);
401
  $marked_by_timeout = true;
402
- if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
403
  gwolle_gb_add_message( '<p class="refuse-spam-timeout"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
404
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
405
  return false;
@@ -417,7 +417,7 @@ function gwolle_gb_frontend_posthandling() {
417
  */
418
  $set_author_ip = (bool) apply_filters( 'gwolle_gb_set_author_ip', true );
419
  $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
420
- if ( $set_author_ip && ($set_author_ip2 == 'true') ) {
421
  $entry->set_author_ip( gwolle_gb_get_user_ip() );
422
  $entry->set_author_host( gethostbyaddr( gwolle_gb_get_user_ip() ) );
423
  }
@@ -448,9 +448,9 @@ function gwolle_gb_frontend_posthandling() {
448
  if ( $save ) {
449
  // We have been saved to the Database.
450
 
451
- gwolle_gb_add_message( '<p class="entry_saved gb-entry-saved">' . esc_html__('Thank you for your entry.','gwolle-gb') . '</p>', false, false );
452
- if ( $entry->get_ischecked() == 0 || $entry->get_isspam() == 1 ) {
453
- gwolle_gb_add_message( '<p>' . esc_html__('We will review it and unlock it in a short while.','gwolle-gb') . '</p>', false, false );
454
  }
455
 
456
 
@@ -482,7 +482,7 @@ function gwolle_gb_frontend_posthandling() {
482
 
483
 
484
  /* Privacy checkbox for GDPR compliance added to log. */
485
- if (isset($_POST['gwolle_gb_privacy']) && $_POST['gwolle_gb_privacy'] == 'on') {
486
  gwolle_gb_add_log_entry( $entry->get_id(), 'privacy-policy-accepted' );
487
  }
488
 
@@ -499,7 +499,7 @@ function gwolle_gb_frontend_posthandling() {
499
 
500
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
501
 
502
- gwolle_gb_add_message( '<p class="entry_notsaved gb-entry-notsaved">' . esc_html__('Sorry, something went wrong with saving your entry. Please contact a site admin.','gwolle-gb') . '</p>', true, false );
503
 
504
  return false;
505
 
@@ -522,15 +522,15 @@ function gwolle_gb_check_double_entry( $entry ) {
522
 
523
  $form_setting = gwolle_gb_get_setting( 'form' );
524
 
525
- if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
526
  $entries = gwolle_gb_get_entries(array(
527
  'email' => $entry->get_author_email(),
528
- 'book_id' => $entry->get_book_id()
529
  ));
530
  if ( is_array( $entries ) && ! empty( $entries ) ) {
531
  $field_name = gwolle_gb_get_field_name( 'content' );
532
  foreach ( $entries as $entry_email ) {
533
- if ( $entry_email->get_content() == $entry->get_content() ) {
534
  // Match is double entry
535
  gwolle_gb_add_message( '<p class="double_post gb-double-post"><strong>' . esc_html__('Double post: An entry with the data you entered has already been saved.', 'gwolle-gb') . '</strong></p>', true, $field_name );
536
  return $entry;
@@ -543,3 +543,36 @@ function gwolle_gb_check_double_entry( $entry ) {
543
  }
544
  add_filter( 'gwolle_gb_new_entry_frontend', 'gwolle_gb_check_double_entry' );
545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  /*
10
  * Handle the $_POST for the Frontend on a new entry.
11
+ * Use the 'wp' action, since global $post is populated and we can use get_the_ID().
12
  */
13
  function gwolle_gb_handle_post() {
14
  if ( ! is_admin() ) {
15
  // Frontend Handling of $_POST, only one form
16
+ if ( isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] === 'add_entry' ) {
17
  gwolle_gb_frontend_posthandling();
18
  }
19
  }
33
  */
34
  function gwolle_gb_frontend_posthandling() {
35
 
36
+ if ( isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] === 'add_entry' ) {
37
 
38
  // Option to allow only logged-in users to post. Don't show the form if not logged-in.
39
+ if ( ! is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') === 'true' ) {
40
  gwolle_gb_add_message( '<p class="require_login"><strong>' . esc_html__('Submitting a new guestbook entry is only allowed for logged-in users.', 'gwolle-gb') . '</strong></p>', true, false);
41
  return false;
42
  }
49
  $form_setting = gwolle_gb_get_setting( 'form' );
50
 
51
  /* Name */
52
+ if ( isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true' ) {
53
  $field_name = gwolle_gb_get_field_name( 'name' );
54
  if (isset($_POST["$field_name"])) {
55
  $author_name = trim($_POST["$field_name"]);
56
  $author_name = gwolle_gb_maybe_encode_emoji( $author_name, 'author_name' );
57
  $gwolle_gb_formdata['author_name'] = $author_name;
58
  gwolle_gb_add_formdata( 'author_name', $author_name );
59
+ if ( $author_name === '' ) {
60
+ if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
61
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your name is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
62
  }
63
  }
64
  } else {
65
+ if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
66
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your name is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
67
  }
68
  }
69
  }
70
 
71
  /* City / Origin */
72
+ if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true' ) {
73
  $field_name = gwolle_gb_get_field_name( 'city' );
74
  if (isset($_POST["$field_name"])) {
75
  $author_origin = trim($_POST["$field_name"]);
76
  $author_origin = gwolle_gb_maybe_encode_emoji( $author_origin, 'author_origin' );
77
  $gwolle_gb_formdata['author_origin'] = $author_origin;
78
  gwolle_gb_add_formdata( 'author_origin', $author_origin );
79
+ if ( $author_origin === '' ) {
80
+ if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
81
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your origin is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
82
  }
83
  }
84
  } else {
85
+ if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
86
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your origin is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
87
  }
88
  }
89
  }
90
 
91
  /* Email */
92
+ if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true' ) {
93
  $field_name = gwolle_gb_get_field_name( 'email' );
94
  if (isset($_POST["$field_name"])) {
95
  $author_email = trim($_POST["$field_name"]);
97
  gwolle_gb_add_formdata( 'author_email', $author_email );
98
  if ( filter_var( $author_email, FILTER_VALIDATE_EMAIL ) ) {
99
  // Valid Email address.
100
+ } else if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
101
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your e-mail address is not filled in correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
102
  }
103
  } else {
104
+ if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
105
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your e-mail address is not filled in correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
106
  }
107
  }
114
  }
115
 
116
  /* Website / Homepage */
117
+ if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true' ) {
118
  $field_name = gwolle_gb_get_field_name( 'website' );
119
  if (isset($_POST["$field_name"])) {
120
  $author_website = trim($_POST["$field_name"]);
121
  $gwolle_gb_formdata['author_website'] = $author_website;
122
  gwolle_gb_add_formdata( 'author_website', $author_website );
123
  $pattern = '/^http/';
124
+ if ( ! preg_match($pattern, $author_website, $matches) ) {
125
+ $author_website = 'http://' . $author_website;
126
  }
127
  if ( filter_var( $author_website, FILTER_VALIDATE_URL ) ) {
128
  // Valid Website URL.
129
+ } else if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
130
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your website is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
131
  }
132
  } else {
133
+ if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
134
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('Your website is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
135
  }
136
  }
137
  }
138
 
139
  /* Message */
140
+ if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
141
  $field_name = gwolle_gb_get_field_name( 'content' );
142
  if (isset($_POST["$field_name"])) {
143
  $content = trim($_POST["$field_name"]);
144
+ if ( $content === '' ) {
145
+ if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
146
+ gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There is no message, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
147
  }
148
  } else {
149
  $content = gwolle_gb_maybe_encode_emoji( $content, 'content' );
151
  gwolle_gb_add_formdata( 'content', $content );
152
  }
153
  } else {
154
+ if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
155
+ gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There is no message, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
156
  }
157
  }
158
  }
159
 
160
  /* Custom Anti-Spam */
161
+ if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
162
  $field_name = gwolle_gb_get_field_name( 'custom' );
163
  $antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
164
  $antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
165
 
166
  if ( isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0 ) {
167
+ if ( isset($_POST["$field_name"]) && trim($_POST["$field_name"]) === trim($antispam_answer) ) {
168
  //echo "You got it!";
169
  } else {
170
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('The anti-spam question was not answered correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
178
  }
179
 
180
  /* Privacy checkbox for GDPR compliance. */
181
+ if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
182
+ if (isset($_POST['gwolle_gb_privacy']) && $_POST['gwolle_gb_privacy'] === 'on') {
183
  gwolle_gb_add_formdata( 'gwolle_gb_privacy', 'on' );
184
  } else {
185
  gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('You did not accept the privacy policy, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, 'gwolle_gb_privacy'); // mandatory
204
  * Do this before the gwolle_gb_new_entry_frontend hook, so we can change it again if a hook needs to.
205
  */
206
  $user_id = get_current_user_id(); // Returns 0 if no current user.
207
+ if ( get_option('gwolle_gb-moderate-entries', 'true') === 'true' ) {
208
  // Moderation, only set to checked for moderators.
209
  if ( gwolle_gb_is_moderator($user_id) ) {
210
  $entry->set_ischecked( true );
243
  // Returned true, so considered spam
244
  $entry->set_isspam(true);
245
  $marked_by_akismet = true;
246
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
247
  gwolle_gb_add_message( '<p class="refuse-spam-akismet"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
248
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
249
  return false;
253
 
254
  /* Stop Forum Spam: check for spam and set accordingly */
255
  $marked_by_sfs = false;
256
+ if ( get_option( 'gwolle_gb-sfs', 'false') === 'true' ) {
257
  $isspam = gwolle_gb_stop_forum_spam( $entry );
258
  if ( $isspam ) {
259
  // Returned true, so considered spam
260
  $entry->set_isspam(true);
261
  $marked_by_sfs = true;
262
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
263
  gwolle_gb_add_message( '<p class="refuse-spam-sfs"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
264
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
265
  return false;
270
 
271
  /* Honeypot: check for spam and set accordingly. */
272
  $marked_by_honeypot = false;
273
+ if (get_option( 'gwolle_gb-honeypot', 'true') === 'true') {
274
  $field_name = gwolle_gb_get_field_name( 'honeypot' );
275
  $field_name2 = gwolle_gb_get_field_name( 'honeypot2' );
276
  $honeypot_value = (int) get_option( 'gwolle_gb-honeypot_value', 15 );
278
  // Input field was filled in, so considered spam
279
  $entry->set_isspam(true);
280
  $marked_by_honeypot = true;
281
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
282
  gwolle_gb_add_message( '<p class="refuse-spam-honeypot"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
283
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
284
  return false;
285
  }
286
  }
287
+ if ( ! isset($_POST["$field_name2"]) || (int) $_POST["$field_name2"] !== $honeypot_value ) {
288
  // Input field was not filled in correctly, so considered spam
289
  $entry->set_isspam(true);
290
  $marked_by_honeypot = true;
291
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
292
  gwolle_gb_add_message( '<p class="refuse-spam-honeypot2"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
293
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
294
  return false;
299
 
300
  /* Nonce: check for spam and set accordingly. */
301
  $marked_by_nonce = false;
302
+ if (get_option( 'gwolle_gb-nonce', 'true') === 'true') {
303
  $field_name = gwolle_gb_get_field_name( 'nonce' );
304
+ $verified = wp_verify_nonce( $_POST["$field_name"], 'gwolle_gb_add_entry' );
305
+ if ( $verified === false ) {
306
  // Nonce is invalid, so considered spam
307
  $entry->set_isspam(true);
308
  $marked_by_nonce = true;
309
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
310
  gwolle_gb_add_message( '<p class="refuse-spam-nonce"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
311
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
312
  return false;
317
 
318
  /* Scan for long and abusive text. */
319
  $marked_by_longtext = false;
320
+ if ( get_option( 'gwolle_gb-longtext', 'true') === 'true' ) {
321
  // Check for abusive content (too long words). Set it to unchecked, so manual moderation is needed.
322
  $maxlength = 100;
323
+ $words = explode( ' ', $entry->get_content() );
324
  foreach ( $words as $word ) {
325
  $pattern = '/^href=http/';
326
  if ( preg_match($pattern, $word, $matches) ) {
341
  }
342
  }
343
  $maxlength = 60;
344
+ $words = explode( ' ', $entry->get_author_name() );
345
  foreach ( $words as $word ) {
346
  if ( strlen($word) > $maxlength ) {
347
  $entry->set_ischecked( false );
355
  /* Scan with Link Checker. */
356
  $marked_by_linkchecker = false;
357
  $counter_for_linkchecker = 0;
358
+ if ( get_option( 'gwolle_gb-linkchecker', 'true') === 'true' ) {
359
+ $words = explode( ' ', $entry->get_content() );
360
  foreach ( $words as $word ) {
361
  $pattern = '/(http|https)\:\/\/?/';
362
  if ( preg_match( $pattern, $word, $matches ) ) {
367
  if ( $counter_for_linkchecker > 1 ) {
368
  $entry->set_isspam( true );
369
  $marked_by_linkchecker = true;
370
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
371
  gwolle_gb_add_message( '<p class="refuse-spam-linkchecker"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
372
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
373
  return false;
378
 
379
  /* Form Timeout: check for spam and set accordingly. */
380
  $marked_by_timeout = false;
381
+ if (get_option( 'gwolle_gb-timeout', 'true') === 'true') {
382
  $field_name = gwolle_gb_get_field_name( 'timeout' );
383
  $field_name2 = gwolle_gb_get_field_name( 'timeout2' );
384
  if ( isset($_POST["$field_name"]) && strlen($_POST["$field_name"]) > 0 && isset($_POST["$field_name2"]) && strlen($_POST["$field_name2"]) > 0 ) {
385
  // Input fields were filled in, so continue.
386
  $timeout = (int) $_POST["$field_name"];
387
  $timeout2 = (int) $_POST["$field_name2"];
388
+ if ( ( $timeout2 - $timeout ) < 2 ) {
389
  // Submitted less then 1 second after loading. Considered spam.
390
  $entry->set_isspam(true);
391
  $marked_by_timeout = true;
392
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
393
  gwolle_gb_add_message( '<p class="refuse-spam-timeout"><strong>' . esc_html__('Your entry was submitted too fast, please slow down and try again.', 'gwolle-gb') . '</strong></p>', true, false );
394
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
395
  return false;
399
  // Input fields were not filled in correctly. Considered spam.
400
  $entry->set_isspam(true);
401
  $marked_by_timeout = true;
402
+ if (get_option( 'gwolle_gb-refuse-spam', 'false') === 'true') {
403
  gwolle_gb_add_message( '<p class="refuse-spam-timeout"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
404
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
405
  return false;
417
  */
418
  $set_author_ip = (bool) apply_filters( 'gwolle_gb_set_author_ip', true );
419
  $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
420
+ if ( $set_author_ip && ( $set_author_ip2 === 'true' ) ) {
421
  $entry->set_author_ip( gwolle_gb_get_user_ip() );
422
  $entry->set_author_host( gethostbyaddr( gwolle_gb_get_user_ip() ) );
423
  }
448
  if ( $save ) {
449
  // We have been saved to the Database.
450
 
451
+ gwolle_gb_add_message( '<p class="entry_saved gb-entry-saved">' . esc_html__('Thank you for your entry.', 'gwolle-gb') . '</p>', false, false );
452
+ if ( $entry->get_ischecked() === 0 || $entry->get_isspam() === 1 ) {
453
+ gwolle_gb_add_message( '<p>' . esc_html__('We will review it and unlock it in a short while.', 'gwolle-gb') . '</p>', false, false );
454
  }
455
 
456
 
482
 
483
 
484
  /* Privacy checkbox for GDPR compliance added to log. */
485
+ if (isset($_POST['gwolle_gb_privacy']) && $_POST['gwolle_gb_privacy'] === 'on') {
486
  gwolle_gb_add_log_entry( $entry->get_id(), 'privacy-policy-accepted' );
487
  }
488
 
499
 
500
  do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
501
 
502
+ gwolle_gb_add_message( '<p class="entry_notsaved gb-entry-notsaved">' . esc_html__('Sorry, something went wrong with saving your entry. Please contact a site admin.', 'gwolle-gb') . '</p>', true, false );
503
 
504
  return false;
505
 
522
 
523
  $form_setting = gwolle_gb_get_setting( 'form' );
524
 
525
+ if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
526
  $entries = gwolle_gb_get_entries(array(
527
  'email' => $entry->get_author_email(),
528
+ 'book_id' => $entry->get_book_id(),
529
  ));
530
  if ( is_array( $entries ) && ! empty( $entries ) ) {
531
  $field_name = gwolle_gb_get_field_name( 'content' );
532
  foreach ( $entries as $entry_email ) {
533
+ if ( $entry_email->get_content() === $entry->get_content() ) {
534
  // Match is double entry
535
  gwolle_gb_add_message( '<p class="double_post gb-double-post"><strong>' . esc_html__('Double post: An entry with the data you entered has already been saved.', 'gwolle-gb') . '</strong></p>', true, $field_name );
536
  return $entry;
543
  }
544
  add_filter( 'gwolle_gb_new_entry_frontend', 'gwolle_gb_check_double_entry' );
545
 
546
+
547
+ /*
548
+ * Check for max length in content textarea.
549
+ * If there are too many characters, do not save the message and return the form with an error.
550
+ *
551
+ * @since 4.2.0
552
+ *
553
+ * @param object $entry the guestbook entry that was submitted by the user.
554
+ *
555
+ * @return object $entry the guestbook entry that was submitted by the user.
556
+ */
557
+ function gwolle_gb_check_maxlength( $entry ) {
558
+
559
+ $form_setting = gwolle_gb_get_setting( 'form' );
560
+
561
+ if ( isset($form_setting['form_message_maxlength']) && is_numeric($form_setting['form_message_maxlength']) && $form_setting['form_message_maxlength'] > 0 ) {
562
+ $form_message_maxlength = (int) $form_setting['form_message_maxlength'];
563
+ $content = $entry->get_content();
564
+ $used_characters = gwolle_gb_count_characters( $content );
565
+
566
+ if ( $used_characters > $form_message_maxlength ) {
567
+ // Content has too many characters.
568
+ $field_name = gwolle_gb_get_field_name( 'content' );
569
+ $message = sprintf( esc_html__('Too many characters: Allowed is %1$d characters, used is %2$d characters in content field.', 'gwolle-gb'), $form_message_maxlength, $used_characters );
570
+ gwolle_gb_add_message( '<p class="gb-max-length"><strong>' . $message . '</strong></p>', true, $field_name );
571
+ return $entry;
572
+ }
573
+ }
574
+ return $entry;
575
+
576
+ }
577
+ add_filter( 'gwolle_gb_new_entry_frontend', 'gwolle_gb_check_maxlength' );
578
+
frontend/gb-form.php CHANGED
@@ -89,7 +89,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
89
  $messageclass = 'error';
90
  }
91
  $output .= '<div class="gwolle_gb_messages_top_container">';
92
- if ( isset($gwolle_gb_messages) && $gwolle_gb_messages != '') {
93
  $output .= '<div class="gwolle_gb_messages ' . $messageclass . '">';
94
  $output .= $gwolle_gb_messages;
95
  $output .= '</div>';
@@ -98,7 +98,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
98
 
99
 
100
  // Option to allow only logged-in users to post. Don't show the form if not logged-in. We still see the messages above.
101
- if ( !is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true' ) {
102
  $output .= '
103
  <div class="gwolle-gb-write">
104
  <h3>' . esc_html__('Log in to post an entry', 'gwolle-gb') . '</h3>';
@@ -122,10 +122,10 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
122
  * Only show when shortcode [gwolle_gb] is used and there are no errors.
123
  */
124
  $formclass = 'gwolle-gb-write';
125
- if ( ( $shortcode_atts['button'] == 'true' ) && ( ! $gwolle_gb_errors ) ) {
126
  $button = '
127
  <div class="gwolle-gb-write-button">
128
- <input type="button" name="gwolle-gb-write-button" class="button btn btn-default ' . $button_class . '" value="&raquo; ' . /* translators: Button text */ esc_attr__('Write a new entry.', 'gwolle-gb') . '" />
129
  </div>';
130
  $output .= apply_filters( 'gwolle_gb_button', $button);
131
 
@@ -146,46 +146,46 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
146
  }
147
 
148
  $header = gwolle_gb_sanitize_output( get_option('gwolle_gb-header', false) );
149
- if ( $header == false ) {
150
  $header = esc_html__('Write a new entry for the Guestbook', 'gwolle-gb');
151
  }
152
 
153
  $hidebutton = '';
154
- if ( ( $shortcode_atts['button'] == 'true' ) ) {
155
  $hidebutton = '<button type="button" class="gb-notice-dismiss">x<span class="screen-reader-text">' . esc_html__('Hide this form.', 'gwolle-gb') . '</span></button>
156
  ';
157
  }
158
  $output .= '
159
- <form action="#" method="POST" class="' . $formclass . '">
160
  <h3>' . $header . '</h3>
161
  ' . $hidebutton . '
162
  <input type="hidden" name="gwolle_gb_function" class="gwolle_gb_function" value="add_entry" />';
163
 
164
  // The book_id from the shortcode, to be used by the posthandling function again.
165
- $output .= '<input type="hidden" name="gwolle_gb_book_id" class="gwolle_gb_book_id" value="' . $shortcode_atts['book_id'] . '" />';
166
 
167
  // Use this filter to just add something
168
  $output .= apply_filters( 'gwolle_gb_write_add_before', '' );
169
 
170
 
171
  /* Name */
172
- if ( isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true' ) {
173
  $field_name = gwolle_gb_get_field_name( 'name' );
174
  $label = apply_filters( 'gwolle_gb_author_name_label', esc_html__('Name', 'gwolle-gb') );
175
- $output .= '<div class="' . $field_name . '">
176
- <div class="label"><label for="' . $field_name . '" class="text-info">' . $label;
177
- if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) { $output .= ' *';}
178
  $output .= '</label></div>
179
- <div class="input"><input class="wp-exclude-emoji ' . $field_name;
180
  if (in_array($field_name, $gwolle_gb_error_fields)) {
181
  $output .= ' error';
182
  }
183
- $output .= '" value="' . $name . '" type="text" name="' . $field_name . '"';
184
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
185
  $output .= $autofocus;
186
  $autofocus = false; // disable it for the next error.
187
  }
188
- if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
189
  $output .= ' required';
190
  }
191
  $output .= ' /></div>
@@ -196,23 +196,23 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
196
 
197
 
198
  /* City / Origin */
199
- if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true' ) {
200
  $field_name = gwolle_gb_get_field_name( 'city' );
201
  $label = apply_filters( 'gwolle_gb_author_origin_label', esc_html__('City', 'gwolle-gb') );
202
- $output .= '<div class="' . $field_name . '">
203
- <div class="label"><label for="' . $field_name . '" class="text-info">' . $label;
204
- if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) { $output .= ' *';}
205
  $output .= '</label></div>
206
- <div class="input"><input class="wp-exclude-emoji ' . $field_name;
207
  if (in_array($field_name, $gwolle_gb_error_fields)) {
208
  $output .= ' error';
209
  }
210
- $output .= '" value="' . $origin . '" type="text" name="' . $field_name . '"';
211
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
212
  $output .= $autofocus;
213
  $autofocus = false; // disable it for the next error.
214
  }
215
- if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
216
  $output .= ' required';
217
  }
218
  $output .= ' /></div>
@@ -222,23 +222,23 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
222
  $output .= apply_filters( 'gwolle_gb_write_add_after_origin', '' );
223
 
224
  /* Email */
225
- if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true' ) {
226
  $field_name = gwolle_gb_get_field_name( 'email' );
227
  $label = apply_filters( 'gwolle_gb_author_email_label', esc_html__('Email', 'gwolle-gb') );
228
- $output .= '<div class="' . $field_name . '">
229
- <div class="label"><label for="' . $field_name . '" class="text-info">' . $label;
230
- if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) { $output .= ' *';}
231
  $output .= '</label></div>
232
- <div class="input"><input class="' . $field_name;
233
  if (in_array($field_name, $gwolle_gb_error_fields)) {
234
  $output .= ' error';
235
  }
236
- $output .= '" value="' . $email . '" ' . ($html5 ? 'type="email"' : 'type="text"') . ' name="' . $field_name . '"';
237
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
238
  $output .= $autofocus;
239
  $autofocus = false; // disable it for the next error.
240
  }
241
- if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
242
  $output .= ' required';
243
  }
244
  $output .= ' /></div>
@@ -246,30 +246,31 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
246
  <div class="clearBoth">&nbsp;</div>';
247
  } else {
248
  if ( isset($email) && strlen($email) > 0 ) {
 
249
  // For logged in users, just save the email anyway.
250
- $output .= '<input value="' . $email . '" type="hidden" name="gwolle_gb_author_email" class="gwolle_gb_author_email" />';
251
  }
252
  }
253
  $output .= apply_filters( 'gwolle_gb_write_add_after_email', '' );
254
 
255
  /* Website / Homepage */
256
- if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true' ) {
257
  $field_name = gwolle_gb_get_field_name( 'website' );
258
  $label = apply_filters( 'gwolle_gb_author_website_label', esc_html__('Website', 'gwolle-gb') );
259
- $output .= '<div class="' . $field_name . '">
260
- <div class="label"><label for="' . $field_name . '" class="text-info">' . $label;
261
- if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) { $output .= ' *';}
262
  $output .= '</label></div>
263
- <div class="input"><input class="' . $field_name;
264
  if (in_array($field_name, $gwolle_gb_error_fields)) {
265
  $output .= ' error';
266
  }
267
- $output .= '" value="' . $website . '" ' . ($html5 ? 'type="url"' : 'type="text"') . ' name="' . $field_name . '"';
268
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
269
  $output .= $autofocus;
270
  $autofocus = false; // disable it for the next error.
271
  }
272
- if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
273
  $output .= ' required';
274
  }
275
  // $output .= ' pattern="[a-z0-9]+\.[a-z]$"'; // try to relax validation to work without http://
@@ -280,67 +281,75 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
280
  $output .= apply_filters( 'gwolle_gb_write_add_after_website', '' );
281
 
282
  /* Honeypot */
283
- if ( get_option( 'gwolle_gb-honeypot', 'true') == 'true' ) {
284
  $field_name = gwolle_gb_get_field_name( 'honeypot' );
285
  $field_name2 = gwolle_gb_get_field_name( 'honeypot2' );
286
  $honeypot_value = (int) get_option( 'gwolle_gb-honeypot_value', 15 );
287
  $output .= '
288
- <div class="' . $field_name . '" style="display:none;">
289
  <div class="label">
290
- <label for="' . $field_name . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
291
- <label for="' . $field_name2 . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
292
  </div>
293
  <div class="input">
294
- <input value="' . $honeypot_value . '" type="text" name="' . $field_name . '" class="' . $field_name . '" />
295
- <input value="" type="text" name="' . $field_name2 . '" class="' . $field_name2 . '" />
296
  </div>
297
  </div>
298
  <div class="clearBoth"></div>';
299
  }
300
 
301
  /* Form Timeout */
302
- if ( get_option( 'gwolle_gb-timeout', 'true') == 'true' ) {
303
  $field_name = gwolle_gb_get_field_name( 'timeout' );
304
  $field_name2 = gwolle_gb_get_field_name( 'timeout2' );
305
  $random = rand( 100, 100000 );
306
  $output .= '
307
- <div class="' . $field_name . '" style="display:none;">
308
  <div class="label">
309
- <label for="' . $field_name . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
310
- <label for="' . $field_name2 . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
311
  </div>
312
  <div class="input">
313
- <input value="' . $random . '" type="text" name="' . $field_name . '" class="' . $field_name . '" />
314
- <input value="' . $random . '" type="text" name="' . $field_name2 . '" class="' . $field_name2 . '" />
315
  </div>
316
  </div>
317
  <div class="clearBoth"></div>';
318
  }
319
 
320
  /* Content */
321
- if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
322
  $field_name = gwolle_gb_get_field_name( 'content' );
323
  $label = apply_filters( 'gwolle_gb_content_label', esc_html__('Guestbook entry', 'gwolle-gb') ); // backwards compatible.
324
  $label = apply_filters( 'gwolle_gb_author_content_label', $label ); // new consistent name.
325
- $output .= '<div class="' . $field_name . '">
326
- <div class="label"><label for="' . $field_name . '" class="text-info">' . $label;
327
- if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) { $output .= ' *';}
 
 
 
328
  $output .= '</label></div>
329
- <div class="input"><textarea name="' . $field_name . '" class="' . $field_name . ' wp-exclude-emoji';
330
  if (in_array($field_name, $gwolle_gb_error_fields)) {
331
  $output .= ' error';
332
  }
 
 
 
333
  $output .= '"';
334
  if ( in_array('content', $gwolle_gb_error_fields) && isset($autofocus) ) {
335
  $output .= $autofocus;
336
  $autofocus = false; // disable it for the next error.
337
  }
338
- if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
339
  $output .= ' required';
340
  }
341
- $output .= ' >' . $content . '</textarea>';
342
-
343
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
 
 
344
  // BBcode and MarkItUp
345
  gwolle_gb_enqueue_markitup();
346
 
@@ -350,7 +359,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
350
  $output .= '</div>';
351
  }
352
 
353
- $output .= '</div>'; // .input
354
 
355
  $output .= '
356
  </div>
@@ -359,7 +368,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
359
  $output .= apply_filters( 'gwolle_gb_write_add_after_content', '' );
360
 
361
  /* Custom Anti-Spam */
362
- if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
363
  $field_name = gwolle_gb_get_field_name( 'custom' );
364
  $antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
365
  $antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
@@ -368,14 +377,14 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
368
  $output .= '
369
  <div class="gwolle_gb_antispam">
370
  <div class="label">
371
- <label for="' . $field_name . '" class="text-info">'
372
- . esc_html__('Question:', 'gwolle-gb') . ' ' . $antispam_question . ' *</label>
373
  </div>
374
- <div class="input"><input class="' . $field_name;
375
  if (in_array( $field_name, $gwolle_gb_error_fields)) {
376
  $output .= ' error ';
377
  }
378
- $output .= '" value="' . $antispam . '" type="text" name="' . $field_name . '"';
379
  if ( in_array( $field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
380
  $output .= $autofocus;
381
  $autofocus = false; // disable it for the next error.
@@ -390,9 +399,9 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
390
  $output .= apply_filters( 'gwolle_gb_write_add_after_antispam', '' );
391
 
392
  /* Privacy checkbox for GDPR compliance. */
393
- if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
394
  $checked = '';
395
- if ( isset($gwolle_gb_formdata['gwolle_gb_privacy']) && $gwolle_gb_formdata['gwolle_gb_privacy'] == 'on' ) {
396
  $checked = ' checked="checked"';
397
  }
398
  $a_open = '';
@@ -405,7 +414,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
405
  }
406
  }
407
  /* translators: %s is a link to the privacy policy page. */
408
- $label = apply_filters( 'gwolle_gb_privacy_label', sprintf( esc_html__( 'Accept %sPrivacy Policy%s', 'gwolle-gb' ), $a_open, $a_close ) );
409
  $output .= '
410
  <div class="gwolle_gb_privacy">
411
  <div class="label"><label for="gwolle_gb_privacy" class="text-info">' . $label . ' *</label></div>
@@ -415,10 +424,10 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
415
  }
416
 
417
  /* Nonce */
418
- if (get_option( 'gwolle_gb-nonce', 'true') == 'true') {
419
  $field_name = gwolle_gb_get_field_name( 'nonce' );
420
  $nonce = wp_create_nonce( 'gwolle_gb_add_entry' );
421
- $output .= '<input type="hidden" class="' . $field_name . '" name="' . $field_name . '" value="' . $nonce . '" />';
422
  }
423
 
424
  /* Use this filter to just add something */
@@ -432,7 +441,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
432
  <div class="gwolle_gb_submit">
433
  <div class="label gwolle-gb-invisible text-muted">&nbsp;</div>
434
  <div class="input">
435
- <input type="submit" name="gwolle_gb_submit" class="gwolle_gb_submit button btn btn-primary ' . $button_class . '" value="' . esc_attr__('Submit', 'gwolle-gb') . '" />
436
  <span class="gwolle_gb_submit_ajax_icon"></span>
437
  ';
438
 
@@ -447,14 +456,13 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
447
  ';
448
 
449
  $notice = gwolle_gb_sanitize_output( get_option('gwolle_gb-notice', false), 'setting_textarea' );
450
- if ( $notice == false ) { // No text set by the user. Use the default text.
451
  $notice = esc_html__("
452
  Fields marked with * are required.
453
  Your E-mail address won't be published.
454
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
455
  We reserve the right to edit, delete, or not publish entries.
456
- "
457
- , 'gwolle-gb');
458
  }
459
 
460
  $notice = nl2br($notice);
89
  $messageclass = 'error';
90
  }
91
  $output .= '<div class="gwolle_gb_messages_top_container">';
92
+ if ( isset($gwolle_gb_messages) && $gwolle_gb_messages !== '') {
93
  $output .= '<div class="gwolle_gb_messages ' . $messageclass . '">';
94
  $output .= $gwolle_gb_messages;
95
  $output .= '</div>';
98
 
99
 
100
  // Option to allow only logged-in users to post. Don't show the form if not logged-in. We still see the messages above.
101
+ if ( ! is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') === 'true' ) {
102
  $output .= '
103
  <div class="gwolle-gb-write">
104
  <h3>' . esc_html__('Log in to post an entry', 'gwolle-gb') . '</h3>';
122
  * Only show when shortcode [gwolle_gb] is used and there are no errors.
123
  */
124
  $formclass = 'gwolle-gb-write';
125
+ if ( ( $shortcode_atts['button'] === 'true' ) && ( ! $gwolle_gb_errors ) ) {
126
  $button = '
127
  <div class="gwolle-gb-write-button">
128
+ <input type="button" name="gwolle-gb-write-button" class="button btn btn-default ' . esc_attr( $button_class ) . '" value="&raquo; ' . /* translators: Button text */ esc_attr__('Write a new entry.', 'gwolle-gb') . '" />
129
  </div>';
130
  $output .= apply_filters( 'gwolle_gb_button', $button);
131
 
146
  }
147
 
148
  $header = gwolle_gb_sanitize_output( get_option('gwolle_gb-header', false) );
149
+ if ( $header === false ) {
150
  $header = esc_html__('Write a new entry for the Guestbook', 'gwolle-gb');
151
  }
152
 
153
  $hidebutton = '';
154
+ if ( ( $shortcode_atts['button'] === 'true' ) ) {
155
  $hidebutton = '<button type="button" class="gb-notice-dismiss">x<span class="screen-reader-text">' . esc_html__('Hide this form.', 'gwolle-gb') . '</span></button>
156
  ';
157
  }
158
  $output .= '
159
+ <form action="#" method="POST" class="' . esc_attr( $formclass ) . '">
160
  <h3>' . $header . '</h3>
161
  ' . $hidebutton . '
162
  <input type="hidden" name="gwolle_gb_function" class="gwolle_gb_function" value="add_entry" />';
163
 
164
  // The book_id from the shortcode, to be used by the posthandling function again.
165
+ $output .= '<input type="hidden" name="gwolle_gb_book_id" class="gwolle_gb_book_id" value="' . (int) $shortcode_atts['book_id'] . '" />';
166
 
167
  // Use this filter to just add something
168
  $output .= apply_filters( 'gwolle_gb_write_add_before', '' );
169
 
170
 
171
  /* Name */
172
+ if ( isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true' ) {
173
  $field_name = gwolle_gb_get_field_name( 'name' );
174
  $label = apply_filters( 'gwolle_gb_author_name_label', esc_html__('Name', 'gwolle-gb') );
175
+ $output .= '<div class="' . esc_attr( $field_name ) . '">
176
+ <div class="label"><label for="' . esc_attr( $field_name ) . '" class="text-info">' . $label;
177
+ if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) { $output .= ' *';}
178
  $output .= '</label></div>
179
+ <div class="input"><input class="wp-exclude-emoji ' . esc_attr( $field_name );
180
  if (in_array($field_name, $gwolle_gb_error_fields)) {
181
  $output .= ' error';
182
  }
183
+ $output .= '" value="' . esc_attr( $name ) . '" type="text" name="' . esc_attr( $field_name ) . '"';
184
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
185
  $output .= $autofocus;
186
  $autofocus = false; // disable it for the next error.
187
  }
188
+ if ( isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true' ) {
189
  $output .= ' required';
190
  }
191
  $output .= ' /></div>
196
 
197
 
198
  /* City / Origin */
199
+ if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true' ) {
200
  $field_name = gwolle_gb_get_field_name( 'city' );
201
  $label = apply_filters( 'gwolle_gb_author_origin_label', esc_html__('City', 'gwolle-gb') );
202
+ $output .= '<div class="' . esc_attr( $field_name ) . '">
203
+ <div class="label"><label for="' . esc_attr( $field_name ) . '" class="text-info">' . $label;
204
+ if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) { $output .= ' *';}
205
  $output .= '</label></div>
206
+ <div class="input"><input class="wp-exclude-emoji ' . esc_attr( $field_name );
207
  if (in_array($field_name, $gwolle_gb_error_fields)) {
208
  $output .= ' error';
209
  }
210
+ $output .= '" value="' . esc_attr( $origin ) . '" type="text" name="' . esc_attr( $field_name ) . '"';
211
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
212
  $output .= $autofocus;
213
  $autofocus = false; // disable it for the next error.
214
  }
215
+ if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true' ) {
216
  $output .= ' required';
217
  }
218
  $output .= ' /></div>
222
  $output .= apply_filters( 'gwolle_gb_write_add_after_origin', '' );
223
 
224
  /* Email */
225
+ if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true' ) {
226
  $field_name = gwolle_gb_get_field_name( 'email' );
227
  $label = apply_filters( 'gwolle_gb_author_email_label', esc_html__('Email', 'gwolle-gb') );
228
+ $output .= '<div class="' . esc_attr( $field_name ) . '">
229
+ <div class="label"><label for="' . esc_attr( $field_name ) . '" class="text-info">' . $label;
230
+ if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) { $output .= ' *';}
231
  $output .= '</label></div>
232
+ <div class="input"><input class="' . esc_attr( $field_name );
233
  if (in_array($field_name, $gwolle_gb_error_fields)) {
234
  $output .= ' error';
235
  }
236
+ $output .= '" value="' . esc_attr( $email ) . '" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' name="' . esc_attr( $field_name ) . '"';
237
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
238
  $output .= $autofocus;
239
  $autofocus = false; // disable it for the next error.
240
  }
241
+ if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true' ) {
242
  $output .= ' required';
243
  }
244
  $output .= ' /></div>
246
  <div class="clearBoth">&nbsp;</div>';
247
  } else {
248
  if ( isset($email) && strlen($email) > 0 ) {
249
+ $field_name = gwolle_gb_get_field_name( 'email' );
250
  // For logged in users, just save the email anyway.
251
+ $output .= '<input value="' . esc_attr( $email ) . '" type="hidden" name="' . esc_attr( $field_name ) . '" class="gwolle_gb_author_email" />';
252
  }
253
  }
254
  $output .= apply_filters( 'gwolle_gb_write_add_after_email', '' );
255
 
256
  /* Website / Homepage */
257
+ if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true' ) {
258
  $field_name = gwolle_gb_get_field_name( 'website' );
259
  $label = apply_filters( 'gwolle_gb_author_website_label', esc_html__('Website', 'gwolle-gb') );
260
+ $output .= '<div class="' . esc_attr( $field_name ) . '">
261
+ <div class="label"><label for="' . esc_attr( $field_name ) . '" class="text-info">' . $label;
262
+ if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) { $output .= ' *';}
263
  $output .= '</label></div>
264
+ <div class="input"><input class="' . esc_attr( $field_name );
265
  if (in_array($field_name, $gwolle_gb_error_fields)) {
266
  $output .= ' error';
267
  }
268
+ $output .= '" value="' . esc_attr( $website ) . '" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' name="' . esc_attr( $field_name ) . '"';
269
  if ( in_array($field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
270
  $output .= $autofocus;
271
  $autofocus = false; // disable it for the next error.
272
  }
273
+ if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true' ) {
274
  $output .= ' required';
275
  }
276
  // $output .= ' pattern="[a-z0-9]+\.[a-z]$"'; // try to relax validation to work without http://
281
  $output .= apply_filters( 'gwolle_gb_write_add_after_website', '' );
282
 
283
  /* Honeypot */
284
+ if ( get_option( 'gwolle_gb-honeypot', 'true') === 'true' ) {
285
  $field_name = gwolle_gb_get_field_name( 'honeypot' );
286
  $field_name2 = gwolle_gb_get_field_name( 'honeypot2' );
287
  $honeypot_value = (int) get_option( 'gwolle_gb-honeypot_value', 15 );
288
  $output .= '
289
+ <div class="' . esc_attr( $field_name ) . '" style="display:none;">
290
  <div class="label">
291
+ <label for="' . esc_attr( $field_name ) . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
292
+ <label for="' . esc_attr( $field_name2 ) . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
293
  </div>
294
  <div class="input">
295
+ <input value="' . esc_attr( $honeypot_value ) . '" type="text" name="' . esc_attr( $field_name ) . '" class="' . esc_attr( $field_name ) . '" />
296
+ <input value="" type="text" name="' . esc_attr( $field_name2 ) . '" class="' . esc_attr( $field_name2 ) . '" />
297
  </div>
298
  </div>
299
  <div class="clearBoth"></div>';
300
  }
301
 
302
  /* Form Timeout */
303
+ if ( get_option( 'gwolle_gb-timeout', 'true') === 'true' ) {
304
  $field_name = gwolle_gb_get_field_name( 'timeout' );
305
  $field_name2 = gwolle_gb_get_field_name( 'timeout2' );
306
  $random = rand( 100, 100000 );
307
  $output .= '
308
+ <div class="' . esc_attr( $field_name ) . '" style="display:none;">
309
  <div class="label">
310
+ <label for="' . esc_attr( $field_name ) . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
311
+ <label for="' . esc_attr( $field_name2 ) . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . '</label>
312
  </div>
313
  <div class="input">
314
+ <input value="' . esc_attr( $random ) . '" type="text" name="' . esc_attr( $field_name ) . '" class="' . esc_attr( $field_name ) . '" />
315
+ <input value="' . esc_attr( $random ) . '" type="text" name="' . esc_attr( $field_name2 ) . '" class="' . esc_attr( $field_name2 ) . '" />
316
  </div>
317
  </div>
318
  <div class="clearBoth"></div>';
319
  }
320
 
321
  /* Content */
322
+ if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
323
  $field_name = gwolle_gb_get_field_name( 'content' );
324
  $label = apply_filters( 'gwolle_gb_content_label', esc_html__('Guestbook entry', 'gwolle-gb') ); // backwards compatible.
325
  $label = apply_filters( 'gwolle_gb_author_content_label', $label ); // new consistent name.
326
+ $form_message_maxlength = (int) $form_setting['form_message_maxlength'];
327
+ $used_characters = gwolle_gb_count_characters( $content );
328
+
329
+ $output .= '<div class="' . esc_attr( $field_name ) . '">
330
+ <div class="label"><label for="' . esc_attr( $field_name ) . '" class="text-info">' . $label;
331
+ if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) { $output .= ' *';}
332
  $output .= '</label></div>
333
+ <div class="input"><textarea name="' . esc_textarea( $field_name ) . '" class="' . esc_attr( $field_name ) . ' wp-exclude-emoji';
334
  if (in_array($field_name, $gwolle_gb_error_fields)) {
335
  $output .= ' error';
336
  }
337
+ if ( isset($form_message_maxlength) && is_numeric($form_message_maxlength) && $form_message_maxlength > 0 ) {
338
+ $output .= ' maxlength maxlength-' . $form_message_maxlength;
339
+ }
340
  $output .= '"';
341
  if ( in_array('content', $gwolle_gb_error_fields) && isset($autofocus) ) {
342
  $output .= $autofocus;
343
  $autofocus = false; // disable it for the next error.
344
  }
345
+ if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
346
  $output .= ' required';
347
  }
348
+ $output .= ' >' . esc_textarea( $content ) . '</textarea>';
349
+ if ( isset($form_message_maxlength) && is_numeric($form_message_maxlength) && $form_message_maxlength > 0 ) {
350
+ $output .= '<span class="gb-max-length-text"><span class="gb-used-characters">' . $used_characters . '</span>/<span class="gb-max-characters">' . $form_message_maxlength . '</span> ' . esc_html__('characters', 'gwolle-gb') . '</span>';
351
+ }
352
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
353
  // BBcode and MarkItUp
354
  gwolle_gb_enqueue_markitup();
355
 
359
  $output .= '</div>';
360
  }
361
 
362
+ $output .= '</div>'; // div.input
363
 
364
  $output .= '
365
  </div>
368
  $output .= apply_filters( 'gwolle_gb_write_add_after_content', '' );
369
 
370
  /* Custom Anti-Spam */
371
+ if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
372
  $field_name = gwolle_gb_get_field_name( 'custom' );
373
  $antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
374
  $antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
377
  $output .= '
378
  <div class="gwolle_gb_antispam">
379
  <div class="label">
380
+ <label for="' . esc_attr( $field_name ) . '" class="text-info">'
381
+ . esc_html__('Question:', 'gwolle-gb') . ' ' . esc_attr( $antispam_question ) . ' *</label>
382
  </div>
383
+ <div class="input"><input class="' . esc_attr( $field_name );
384
  if (in_array( $field_name, $gwolle_gb_error_fields)) {
385
  $output .= ' error ';
386
  }
387
+ $output .= '" value="' . esc_attr( $antispam ) . '" type="text" name="' . esc_attr( $field_name ) . '"';
388
  if ( in_array( $field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
389
  $output .= $autofocus;
390
  $autofocus = false; // disable it for the next error.
399
  $output .= apply_filters( 'gwolle_gb_write_add_after_antispam', '' );
400
 
401
  /* Privacy checkbox for GDPR compliance. */
402
+ if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
403
  $checked = '';
404
+ if ( isset($gwolle_gb_formdata['gwolle_gb_privacy']) && $gwolle_gb_formdata['gwolle_gb_privacy'] === 'on' ) {
405
  $checked = ' checked="checked"';
406
  }
407
  $a_open = '';
414
  }
415
  }
416
  /* translators: %s is a link to the privacy policy page. */
417
+ $label = apply_filters( 'gwolle_gb_privacy_label', sprintf( esc_html__( 'I accept the %sPrivacy Policy%s', 'gwolle-gb' ), $a_open, $a_close ) );
418
  $output .= '
419
  <div class="gwolle_gb_privacy">
420
  <div class="label"><label for="gwolle_gb_privacy" class="text-info">' . $label . ' *</label></div>
424
  }
425
 
426
  /* Nonce */
427
+ if (get_option( 'gwolle_gb-nonce', 'true') === 'true') {
428
  $field_name = gwolle_gb_get_field_name( 'nonce' );
429
  $nonce = wp_create_nonce( 'gwolle_gb_add_entry' );
430
+ $output .= '<input type="hidden" class="' . esc_attr( $field_name ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $nonce ) . '" />';
431
  }
432
 
433
  /* Use this filter to just add something */
441
  <div class="gwolle_gb_submit">
442
  <div class="label gwolle-gb-invisible text-muted">&nbsp;</div>
443
  <div class="input">
444
+ <input type="submit" name="gwolle_gb_submit" class="gwolle_gb_submit button btn btn-primary ' . esc_attr( $button_class ) . '" value="' . esc_attr__('Submit', 'gwolle-gb') . '" />
445
  <span class="gwolle_gb_submit_ajax_icon"></span>
446
  ';
447
 
456
  ';
457
 
458
  $notice = gwolle_gb_sanitize_output( get_option('gwolle_gb-notice', false), 'setting_textarea' );
459
+ if ( $notice === false ) { // No text set by the user. Use the default text.
460
  $notice = esc_html__("
461
  Fields marked with * are required.
462
  Your E-mail address won't be published.
463
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
464
  We reserve the right to edit, delete, or not publish entries.
465
+ ", 'gwolle-gb');
 
466
  }
467
 
468
  $notice = nl2br($notice);
frontend/gb-pagination.php CHANGED
@@ -10,19 +10,19 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
10
  * gwolle_gb_pagination_frontend
11
  * Pagination of the entries for the guestbook frontend
12
  *
13
- * @param int $pageNum the number of the requested page.
14
  * @param int $pages_total the total number of pages.
15
  * @return string $pagination the html of the pagination.
16
  */
17
- function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
18
 
19
- $highDotsMade = false;
20
  $pages_done = array();
21
 
22
  $permalink = gwolle_gb_get_permalink(get_the_ID());
23
  $is_search = gwolle_gb_is_search();
24
  if ( $is_search ) {
25
- $search_query = trim($_GET['gwolle-gb-search-input']);
26
  $permalink = add_query_arg( 'gwolle-gb-search-input', $search_query, $permalink );
27
  }
28
 
@@ -30,18 +30,18 @@ function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
30
  <div class="page-navigation">
31
  <span class="screen-reader-text">' . esc_html__('Guestbook list navigation', 'gwolle-gb') . '</span>';
32
 
33
- if ($pageNum > 1) {
34
- $pagination .= '<a href="' . add_query_arg( 'pageNum', round($pageNum - 1), $permalink ) . '" title="' . esc_attr__('Previous page', 'gwolle-gb') . '" rel="prev">&larr;</a>';
35
  }
36
 
37
- if ($pageNum < 5) {
38
- $showRange = 5;
39
  if ($pages_total < 6) {
40
- $showRange = $pages_total;
41
- $highDotsMade = true; // no need for highdots.
42
  }
43
- for ($i = 1; $i < ($showRange + 1); $i++) {
44
- if ($i == $pageNum) {
45
  if ( in_array( $i, $pages_done ) ) { continue; }
46
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
47
  $pages_done[] = $i;
@@ -49,52 +49,52 @@ function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
49
  if ( in_array( $i, $pages_done ) ) { continue; }
50
  $pagination .= '<a href="' . add_query_arg( 'pageNum', $i, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' ' . $i . '">' . $i . '</a>';
51
  $pages_done[] = $i;
52
- if ( $i == $pages_total ) { break; }
53
  }
54
  }
55
 
56
- if ( ($pageNum + 4 < $pages_total) && ( ! $highDotsMade) ) {
57
  $pagination .= '<span class="page-numbers dots">...</span>';
58
- $highDotsMade = true;
59
  }
60
- } elseif ($pageNum > 4) {
61
  $pagination .= '<a href="' . add_query_arg( 'pageNum', 1, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' 1">1</a>';
62
  if ($pages_total > 4) {
63
  $pagination .= '<span class="page-numbers dots">...</span>';
64
  }
65
- if ($pageNum + 2 < $pages_total) {
66
- $minRange = $pageNum - 2;
67
- $showRange = $pageNum + 2;
68
  } else {
69
- $minRange = $pageNum - 3;
70
- $showRange = $pages_total - 1;
71
  }
72
- for ($i = $minRange; $i <= $showRange; $i++) {
73
- if ($i == $pageNum) {
74
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
75
  } else {
76
  $pagination .= '<a href="' . add_query_arg( 'pageNum', $i, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' ' . $i . '">' . $i . '</a>';
77
  }
78
  }
79
- if ($pageNum == $pages_total) {
80
- $pagination .= '<span class="page-numbers current">' . $pageNum . '</span>';
81
  }
82
  }
83
 
84
- if ($pageNum < $pages_total) {
85
- if ( ($pageNum + 3 < $pages_total) && ( ! $highDotsMade) ) {
86
  $pagination .= '<span class="page-numbers dots">...</span>';
87
- $highDotsMade = true;
88
  }
89
  if ( ! in_array( $pages_total, $pages_done ) ) {
90
  $pagination .= '<a href="' . add_query_arg( 'pageNum', $pages_total, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' ' . $pages_total . '">' . $pages_total . '</a>';
91
  }
92
- $pagination .= '<a href="' . add_query_arg( 'pageNum', round($pageNum + 1), $permalink ) . '" title="' . esc_attr__('Next page', 'gwolle-gb') . '" rel="next">&rarr;</a>';
93
  }
94
 
95
  // 'All' link
96
  if ( $pages_total >= 2 && get_option( 'gwolle_gb-paginate_all', 'false' ) === 'true' && ! $is_search ) {
97
- if ( isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
98
  $pagination .= '<span class="page-numbers all">' . esc_html__('All', 'gwolle-gb') . '</span>';
99
  } else {
100
  $pagination .= '<a href="' . add_query_arg( 'show_all', 'true', $permalink ) . '" title="' . esc_attr__('All entries', 'gwolle-gb') . '">' . esc_html__('All', 'gwolle-gb') . '</a>';
10
  * gwolle_gb_pagination_frontend
11
  * Pagination of the entries for the guestbook frontend
12
  *
13
+ * @param int $page_num the number of the requested page.
14
  * @param int $pages_total the total number of pages.
15
  * @return string $pagination the html of the pagination.
16
  */
17
+ function gwolle_gb_pagination_frontend( $page_num, $pages_total ) {
18
 
19
+ $high_dots_made = false;
20
  $pages_done = array();
21
 
22
  $permalink = gwolle_gb_get_permalink(get_the_ID());
23
  $is_search = gwolle_gb_is_search();
24
  if ( $is_search ) {
25
+ $search_query = gwolle_gb_sanitize_input( $_GET['gwolle-gb-search-input'] );
26
  $permalink = add_query_arg( 'gwolle-gb-search-input', $search_query, $permalink );
27
  }
28
 
30
  <div class="page-navigation">
31
  <span class="screen-reader-text">' . esc_html__('Guestbook list navigation', 'gwolle-gb') . '</span>';
32
 
33
+ if ($page_num > 1) {
34
+ $pagination .= '<a href="' . add_query_arg( 'pageNum', round($page_num - 1), $permalink ) . '" title="' . esc_attr__('Previous page', 'gwolle-gb') . '" rel="prev">&larr;</a>';
35
  }
36
 
37
+ if ($page_num < 5) {
38
+ $showrange = 5;
39
  if ($pages_total < 6) {
40
+ $showrange = $pages_total;
41
+ $high_dots_made = true; // no need for highdots.
42
  }
43
+ for ( $i = 1; $i < ( $showrange + 1 ); $i++ ) {
44
+ if ($i === $page_num) {
45
  if ( in_array( $i, $pages_done ) ) { continue; }
46
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
47
  $pages_done[] = $i;
49
  if ( in_array( $i, $pages_done ) ) { continue; }
50
  $pagination .= '<a href="' . add_query_arg( 'pageNum', $i, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' ' . $i . '">' . $i . '</a>';
51
  $pages_done[] = $i;
52
+ if ( $i === $pages_total ) { break; }
53
  }
54
  }
55
 
56
+ if ( ( $page_num + 4 < $pages_total ) && ( ! $high_dots_made ) ) {
57
  $pagination .= '<span class="page-numbers dots">...</span>';
58
+ $high_dots_made = true;
59
  }
60
+ } else if ($page_num > 4) {
61
  $pagination .= '<a href="' . add_query_arg( 'pageNum', 1, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' 1">1</a>';
62
  if ($pages_total > 4) {
63
  $pagination .= '<span class="page-numbers dots">...</span>';
64
  }
65
+ if ( ($page_num + 2 ) < $pages_total ) {
66
+ $minrange = $page_num - 2;
67
+ $showrange = $page_num + 2;
68
  } else {
69
+ $minrange = $page_num - 3;
70
+ $showrange = $pages_total - 1;
71
  }
72
+ for ($i = $minrange; $i <= $showrange; $i++) {
73
+ if ($i === $page_num) {
74
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
75
  } else {
76
  $pagination .= '<a href="' . add_query_arg( 'pageNum', $i, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' ' . $i . '">' . $i . '</a>';
77
  }
78
  }
79
+ if ($page_num === $pages_total) {
80
+ $pagination .= '<span class="page-numbers current">' . $page_num . '</span>';
81
  }
82
  }
83
 
84
+ if ($page_num < $pages_total) {
85
+ if ( ( ( $page_num + 3 ) < $pages_total ) && ( ! $high_dots_made ) ) {
86
  $pagination .= '<span class="page-numbers dots">...</span>';
87
+ $high_dots_made = true;
88
  }
89
  if ( ! in_array( $pages_total, $pages_done ) ) {
90
  $pagination .= '<a href="' . add_query_arg( 'pageNum', $pages_total, $permalink ) . '" title="' . esc_attr__('Page', 'gwolle-gb') . ' ' . $pages_total . '">' . $pages_total . '</a>';
91
  }
92
+ $pagination .= '<a href="' . add_query_arg( 'pageNum', round($page_num + 1), $permalink ) . '" title="' . esc_attr__('Next page', 'gwolle-gb') . '" rel="next">&rarr;</a>';
93
  }
94
 
95
  // 'All' link
96
  if ( $pages_total >= 2 && get_option( 'gwolle_gb-paginate_all', 'false' ) === 'true' && ! $is_search ) {
97
+ if ( isset($_GET['show_all']) && $_GET['show_all'] === 'true' ) {
98
  $pagination .= '<span class="page-numbers all">' . esc_html__('All', 'gwolle-gb') . '</span>';
99
  } else {
100
  $pagination .= '<a href="' . add_query_arg( 'show_all', 'true', $permalink ) . '" title="' . esc_attr__('All entries', 'gwolle-gb') . '">' . esc_html__('All', 'gwolle-gb') . '</a>';
frontend/gb-read.php CHANGED
@@ -21,7 +21,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
21
  $is_search = gwolle_gb_is_search();
22
 
23
  /* Show single entry if requested and is not search. */
24
- if ( ((int) $shortcode_atts['entry_id'] > 0 && ! $is_search ) || ( isset($_GET['entry_id']) && (int) $_GET['entry_id'] > 0 && ! $is_search ) ) {
25
 
26
  if ( (int) $shortcode_atts['entry_id'] > 0 ) {
27
  $entry_id = (int) $shortcode_atts['entry_id'];
@@ -38,7 +38,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
38
  } else if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
39
  // Not visible.
40
  $output .= esc_html__( 'Sorry, but this entry does not seem to exist.', 'gwolle-gb' );
41
- } else if ( $entry_book_id != $shortcode_atts['book_id'] ) {
42
  // Not the right book.
43
  $output .= esc_html__( 'Sorry, but this entry does not seem to exist.', 'gwolle-gb' );
44
  } else {
@@ -72,7 +72,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
72
  'checked' => 'checked',
73
  'trash' => 'notrash',
74
  'spam' => 'nospam',
75
- 'book_id' => $shortcode_atts['book_id']
76
  )
77
  );
78
  } else {
@@ -85,7 +85,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
85
  'checked' => 'checked',
86
  'trash' => 'notrash',
87
  'spam' => 'nospam',
88
- 'book_id' => $shortcode_atts['book_id']
89
  )
90
  );
91
  set_transient( $key, $entries_total, DAY_IN_SECONDS );
@@ -93,22 +93,22 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
93
  }
94
  $pages_total = ceil( $entries_total / $num_entries );
95
 
96
- $pageNum = 1;
97
  if ( isset($_GET['pageNum']) && is_numeric($_GET['pageNum']) ) {
98
- $pageNum = (int) $_GET['pageNum'];
99
  }
100
 
101
- if ( $pageNum > $pages_total ) {
102
  // Page doesnot exist
103
- $pageNum = 1;
104
  }
105
 
106
- if ( $pageNum == 1 && $entries_total > 0 ) {
107
  $offset = 0;
108
- } elseif ( $entries_total == 0 ) {
109
  $offset = 0;
110
  } else {
111
- $offset = ( $pageNum - 1 ) * $num_entries;
112
  }
113
 
114
 
@@ -121,10 +121,10 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
121
  'checked' => 'checked',
122
  'trash' => 'notrash',
123
  'spam' => 'nospam',
124
- 'book_id' => $shortcode_atts['book_id']
125
  )
126
  );
127
- } else if ( $is_search && isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
128
  $entries = gwolle_gb_get_entries_from_search(
129
  array(
130
  'offset' => 0,
@@ -132,11 +132,11 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
132
  'checked' => 'checked',
133
  'trash' => 'notrash',
134
  'spam' => 'nospam',
135
- 'book_id' => $shortcode_atts['book_id']
136
  )
137
  );
138
- $pageNum = 0; // do not have it set to 1, this way the '1' will be clickable too.
139
- } else if ( isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
140
  $entries = gwolle_gb_get_entries(
141
  array(
142
  'offset' => 0,
@@ -144,10 +144,10 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
144
  'checked' => 'checked',
145
  'trash' => 'notrash',
146
  'spam' => 'nospam',
147
- 'book_id' => $shortcode_atts['book_id']
148
  )
149
  );
150
- $pageNum = 0; // do not have it set to 1, this way the '1' will be clickable too.
151
  } else {
152
  $entries = gwolle_gb_get_entries(
153
  array(
@@ -156,7 +156,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
156
  'checked' => 'checked',
157
  'trash' => 'notrash',
158
  'spam' => 'nospam',
159
- 'book_id' => $shortcode_atts['book_id']
160
  )
161
  );
162
  }
@@ -165,10 +165,10 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
165
  /* Page navigation on top */
166
  $navigation = (int) get_option( 'gwolle_gb-navigation', 0 );
167
  $entries_list_class = 'gwolle-gb-read ';
168
- if ( $navigation == 0 ) {
169
- $pagination = gwolle_gb_pagination_frontend( $pageNum, $pages_total );
170
  $output .= $pagination;
171
- } else if ( $navigation == 1 ) {
172
  $entries_list_class .= 'gwolle_gb_infinite gwolle-gb-infinite';
173
  }
174
  $entries_list_class = apply_filters( 'gwolle_gb_entries_list_class', $entries_list_class );
@@ -176,32 +176,32 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
176
  /* Entries from the template */
177
  if ( ! is_array( $entries ) || empty( $entries ) ) {
178
  $no_entries = apply_filters( 'gwolle_gb_read_no_entries', esc_html__('(no entries yet)', 'gwolle-gb') );
179
- $output .= '<div class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
180
  $output .= $no_entries;
181
  $output .= '</div>';
182
  } else {
183
  $first = true;
184
 
185
- $output .= '<div class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
186
 
187
  $args = array(
188
  'checked' => 'checked',
189
  'trash' => 'notrash',
190
  'spam' => 'nospam',
191
- 'book_id' => $shortcode_atts['book_id']
192
  );
193
  $output .= apply_filters( 'gwolle_gb_entries_list_before', '', $args );
194
 
195
 
196
  // Try to load and require_once the template from the themes folders.
197
- if ( locate_template( array('gwolle_gb-entry.php'), true, true ) == '') {
198
 
199
  $output .= '<!-- Gwolle-GB Entry: Default Template Loaded -->
200
  ';
201
 
202
  // No template found and loaded in the theme folders.
203
  // Load the template from the plugin folder.
204
- require_once( GWOLLE_GB_DIR . '/frontend/gwolle_gb-entry.php' );
205
 
206
  } else {
207
 
@@ -230,7 +230,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
230
 
231
 
232
  /* Page navigation on bottom */
233
- if ( $navigation == 0 ) {
234
  $output .= $pagination;
235
  }
236
 
@@ -239,4 +239,5 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
239
  $output = apply_filters( 'gwolle_gb_entries_read', $output);
240
 
241
  return $output;
 
242
  }
21
  $is_search = gwolle_gb_is_search();
22
 
23
  /* Show single entry if requested and is not search. */
24
+ if ( ( (int) $shortcode_atts['entry_id'] > 0 && ! $is_search ) || ( isset($_GET['entry_id']) && (int) $_GET['entry_id'] > 0 && ! $is_search ) ) {
25
 
26
  if ( (int) $shortcode_atts['entry_id'] > 0 ) {
27
  $entry_id = (int) $shortcode_atts['entry_id'];
38
  } else if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
39
  // Not visible.
40
  $output .= esc_html__( 'Sorry, but this entry does not seem to exist.', 'gwolle-gb' );
41
+ } else if ( $entry_book_id !== (int) $shortcode_atts['book_id'] ) {
42
  // Not the right book.
43
  $output .= esc_html__( 'Sorry, but this entry does not seem to exist.', 'gwolle-gb' );
44
  } else {
72
  'checked' => 'checked',
73
  'trash' => 'notrash',
74
  'spam' => 'nospam',
75
+ 'book_id' => $shortcode_atts['book_id'],
76
  )
77
  );
78
  } else {
85
  'checked' => 'checked',
86
  'trash' => 'notrash',
87
  'spam' => 'nospam',
88
+ 'book_id' => $shortcode_atts['book_id'],
89
  )
90
  );
91
  set_transient( $key, $entries_total, DAY_IN_SECONDS );
93
  }
94
  $pages_total = ceil( $entries_total / $num_entries );
95
 
96
+ $page_num = 1;
97
  if ( isset($_GET['pageNum']) && is_numeric($_GET['pageNum']) ) {
98
+ $page_num = (int) $_GET['pageNum'];
99
  }
100
 
101
+ if ( $page_num > $pages_total ) {
102
  // Page doesnot exist
103
+ $page_num = 1;
104
  }
105
 
106
+ if ( $page_num === 1 && $entries_total > 0 ) {
107
  $offset = 0;
108
+ } else if ( $entries_total === 0 ) {
109
  $offset = 0;
110
  } else {
111
+ $offset = ( $page_num - 1 ) * $num_entries;
112
  }
113
 
114
 
121
  'checked' => 'checked',
122
  'trash' => 'notrash',
123
  'spam' => 'nospam',
124
+ 'book_id' => $shortcode_atts['book_id'],
125
  )
126
  );
127
+ } else if ( $is_search && isset($_GET['show_all']) && $_GET['show_all'] === 'true' ) {
128
  $entries = gwolle_gb_get_entries_from_search(
129
  array(
130
  'offset' => 0,
132
  'checked' => 'checked',
133
  'trash' => 'notrash',
134
  'spam' => 'nospam',
135
+ 'book_id' => $shortcode_atts['book_id'],
136
  )
137
  );
138
+ $page_num = 0; // do not have it set to 1, this way the '1' will be clickable too.
139
+ } else if ( isset($_GET['show_all']) && $_GET['show_all'] === 'true' ) {
140
  $entries = gwolle_gb_get_entries(
141
  array(
142
  'offset' => 0,
144
  'checked' => 'checked',
145
  'trash' => 'notrash',
146
  'spam' => 'nospam',
147
+ 'book_id' => $shortcode_atts['book_id'],
148
  )
149
  );
150
+ $page_num = 0; // do not have it set to 1, this way the '1' will be clickable too.
151
  } else {
152
  $entries = gwolle_gb_get_entries(
153
  array(
156
  'checked' => 'checked',
157
  'trash' => 'notrash',
158
  'spam' => 'nospam',
159
+ 'book_id' => $shortcode_atts['book_id'],
160
  )
161
  );
162
  }
165
  /* Page navigation on top */
166
  $navigation = (int) get_option( 'gwolle_gb-navigation', 0 );
167
  $entries_list_class = 'gwolle-gb-read ';
168
+ if ( $navigation === 0 ) {
169
+ $pagination = gwolle_gb_pagination_frontend( $page_num, $pages_total );
170
  $output .= $pagination;
171
+ } else if ( $navigation === 1 ) {
172
  $entries_list_class .= 'gwolle_gb_infinite gwolle-gb-infinite';
173
  }
174
  $entries_list_class = apply_filters( 'gwolle_gb_entries_list_class', $entries_list_class );
176
  /* Entries from the template */
177
  if ( ! is_array( $entries ) || empty( $entries ) ) {
178
  $no_entries = apply_filters( 'gwolle_gb_read_no_entries', esc_html__('(no entries yet)', 'gwolle-gb') );
179
+ $output .= '<div class="' . esc_attr( $entries_list_class ) . '" data-book_id="' . (int) $shortcode_atts['book_id'] . '">';
180
  $output .= $no_entries;
181
  $output .= '</div>';
182
  } else {
183
  $first = true;
184
 
185
+ $output .= '<div class="' . esc_attr( $entries_list_class ) . '" data-book_id="' . (int) $shortcode_atts['book_id'] . '">';
186
 
187
  $args = array(
188
  'checked' => 'checked',
189
  'trash' => 'notrash',
190
  'spam' => 'nospam',
191
+ 'book_id' => (int) $shortcode_atts['book_id'],
192
  );
193
  $output .= apply_filters( 'gwolle_gb_entries_list_before', '', $args );
194
 
195
 
196
  // Try to load and require_once the template from the themes folders.
197
+ if ( locate_template( array( 'gwolle_gb-entry.php' ), true, true ) === '') {
198
 
199
  $output .= '<!-- Gwolle-GB Entry: Default Template Loaded -->
200
  ';
201
 
202
  // No template found and loaded in the theme folders.
203
  // Load the template from the plugin folder.
204
+ require_once GWOLLE_GB_DIR . '/frontend/gwolle_gb-entry.php';
205
 
206
  } else {
207
 
230
 
231
 
232
  /* Page navigation on bottom */
233
+ if ( $navigation === 0 ) {
234
  $output .= $pagination;
235
  }
236
 
239
  $output = apply_filters( 'gwolle_gb_entries_read', $output);
240
 
241
  return $output;
242
+
243
  }
frontend/gb-rss.php CHANGED
@@ -10,7 +10,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
10
  /*
11
  * Add the feed.
12
  */
13
- function gwolle_gb_rss_init(){
14
  add_feed('gwolle_gb', 'gwolle_gb_rss');
15
  }
16
  add_action('init', 'gwolle_gb_rss_init');
@@ -21,7 +21,7 @@ add_action('init', 'gwolle_gb_rss_init');
21
  * There is no post_content yet, but we do have get_the_ID().
22
  */
23
  function gwolle_gb_rss_head() {
24
- if ( is_singular() && function_exists('has_shortcode') ) {
25
  $post = get_post( get_the_ID() );
26
  if ( has_shortcode( $post->post_content, 'gwolle_gb' ) || has_shortcode( $post->post_content, 'gwolle_gb_read' ) ) {
27
 
@@ -34,11 +34,11 @@ function gwolle_gb_rss_head() {
34
  $permalinks = $wp_rewrite->permalink_structure;
35
  if ( $permalinks ) {
36
  ?>
37
- <link rel="alternate" type="application/rss+xml" title="<?php esc_attr_e("Guestbook Feed", 'gwolle-gb'); ?>" href="<?php bloginfo('url'); ?>/feed/gwolle_gb" />
38
  <?php
39
  } else {
40
  ?>
41
- <link rel="alternate" type="application/rss+xml" title="<?php esc_attr_e("Guestbook Feed", 'gwolle-gb'); ?>" href="<?php bloginfo('url'); ?>/?feed=gwolle_gb" />
42
  <?php
43
  }
44
  }
@@ -65,16 +65,16 @@ add_filter( 'feed_content_type', 'gwolle_gb_rss_content_type', 10, 2 );
65
  function gwolle_gb_rss() {
66
 
67
  // Only show the first page of entries.
68
- $entriesPerPage = (int) apply_filters( 'gwolle_gb_rss_nr_entries', 20 );
69
 
70
  /* Get the entries for the RSS Feed */
71
  $entries = gwolle_gb_get_entries(
72
  array(
73
  'offset' => 0,
74
- 'num_entries' => $entriesPerPage,
75
  'checked' => 'checked',
76
  'trash' => 'notrash',
77
- 'spam' => 'nospam'
78
  )
79
  );
80
 
@@ -83,7 +83,7 @@ function gwolle_gb_rss() {
83
  $datetimeformat = 'd M Y H:i:s';
84
 
85
  /* Get the time of the last entry, else of the last edited post */
86
- if ( is_array($entries) && !empty($entries) ) {
87
  $lastbuild = gmdate( $datetimeformat, $entries[0]->get_datetime() ) . ' ' . $timezone;
88
  } else {
89
  $lastbuild = mysql2date($datetimeformat, get_lastpostmodified('GMT'), false) . ' GMT';
@@ -98,12 +98,12 @@ function gwolle_gb_rss() {
98
  $permalink_biggest_book = $blog_url . '?p=' . $biggest_book;
99
  }
100
  /* Get the Language setting */
101
- $WPLANG = get_locale();
102
- if ( ! $WPLANG ) {
103
- $WPLANG = 'en-us';
104
  }
105
- $WPLANG = str_replace( '_', '-', $WPLANG );
106
- $WPLANG = strtolower( $WPLANG );
107
 
108
  /* Build the XML content */
109
  header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
@@ -120,22 +120,22 @@ function gwolle_gb_rss() {
120
  <?php do_action('rss2_ns'); ?>>
121
 
122
  <channel>
123
- <title><?php bloginfo_rss('name'); echo " - " . esc_html__('Guestbook Feed', 'gwolle-gb'); ?></title>
124
  <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
125
  <link><?php echo $permalink_biggest_book; ?></link>
126
- <description><?php bloginfo_rss('description'); echo " - " . esc_html__('Guestbook Feed', 'gwolle-gb'); ?></description>
127
  <lastBuildDate><?php echo $lastbuild; ?></lastBuildDate>
128
- <language><?php echo $WPLANG; ?></language>
129
  <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
130
  <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
131
  <?php do_action('rss2_head'); ?>
132
 
133
  <?php
134
- if ( is_array($entries) && !empty($entries) ) {
135
  foreach ( $entries as $entry ) { ?>
136
 
137
  <item>
138
- <title><?php esc_html_e('Guestbook Entry by', 'gwolle-gb'); echo " " . trim( $entry->get_author_name() ) . " (" . trim(date_i18n( get_option('date_format'), $entry->get_datetime() )) . " " . trim(date_i18n( get_option('time_format'), $entry->get_datetime() )) . ")"; ?></title>
139
  <link><?php
140
  $postid = gwolle_gb_get_postid( (int) $entry->get_book_id() );
141
  $permalink = $blog_url; // init for new entry.
10
  /*
11
  * Add the feed.
12
  */
13
+ function gwolle_gb_rss_init() {
14
  add_feed('gwolle_gb', 'gwolle_gb_rss');
15
  }
16
  add_action('init', 'gwolle_gb_rss_init');
21
  * There is no post_content yet, but we do have get_the_ID().
22
  */
23
  function gwolle_gb_rss_head() {
24
+ if ( is_singular() ) {
25
  $post = get_post( get_the_ID() );
26
  if ( has_shortcode( $post->post_content, 'gwolle_gb' ) || has_shortcode( $post->post_content, 'gwolle_gb_read' ) ) {
27
 
34
  $permalinks = $wp_rewrite->permalink_structure;
35
  if ( $permalinks ) {
36
  ?>
37
+ <link rel="alternate" type="application/rss+xml" title="<?php esc_attr_e('Guestbook Feed', 'gwolle-gb'); ?>" href="<?php bloginfo('url'); ?>/feed/gwolle_gb" />
38
  <?php
39
  } else {
40
  ?>
41
+ <link rel="alternate" type="application/rss+xml" title="<?php esc_attr_e('Guestbook Feed', 'gwolle-gb'); ?>" href="<?php bloginfo('url'); ?>/?feed=gwolle_gb" />
42
  <?php
43
  }
44
  }
65
  function gwolle_gb_rss() {
66
 
67
  // Only show the first page of entries.
68
+ $entries_per_page = (int) apply_filters( 'gwolle_gb_rss_nr_entries', 20 );
69
 
70
  /* Get the entries for the RSS Feed */
71
  $entries = gwolle_gb_get_entries(
72
  array(
73
  'offset' => 0,
74
+ 'num_entries' => $entries_per_page,
75
  'checked' => 'checked',
76
  'trash' => 'notrash',
77
+ 'spam' => 'nospam',
78
  )
79
  );
80
 
83
  $datetimeformat = 'd M Y H:i:s';
84
 
85
  /* Get the time of the last entry, else of the last edited post */
86
+ if ( is_array($entries) && ! empty($entries) ) {
87
  $lastbuild = gmdate( $datetimeformat, $entries[0]->get_datetime() ) . ' ' . $timezone;
88
  } else {
89
  $lastbuild = mysql2date($datetimeformat, get_lastpostmodified('GMT'), false) . ' GMT';
98
  $permalink_biggest_book = $blog_url . '?p=' . $biggest_book;
99
  }
100
  /* Get the Language setting */
101
+ $wplang = get_locale();
102
+ if ( ! $wplang ) {
103
+ $wplang = 'en-us';
104
  }
105
+ $wplang = str_replace( '_', '-', $wplang );
106
+ $wplang = strtolower( $wplang );
107
 
108
  /* Build the XML content */
109
  header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
120
  <?php do_action('rss2_ns'); ?>>
121
 
122
  <channel>
123
+ <title><?php bloginfo_rss('name'); echo ' - ' . esc_html__('Guestbook Feed', 'gwolle-gb'); ?></title>
124
  <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
125
  <link><?php echo $permalink_biggest_book; ?></link>
126
+ <description><?php bloginfo_rss('description'); echo ' - ' . esc_html__('Guestbook Feed', 'gwolle-gb'); ?></description>
127
  <lastBuildDate><?php echo $lastbuild; ?></lastBuildDate>
128
+ <language><?php echo $wplang; ?></language>
129
  <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
130
  <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
131
  <?php do_action('rss2_head'); ?>
132
 
133
  <?php
134
+ if ( is_array($entries) && ! empty($entries) ) {
135
  foreach ( $entries as $entry ) { ?>
136
 
137
  <item>
138
+ <title><?php esc_html_e('Guestbook Entry by', 'gwolle-gb'); echo ' ' . trim( $entry->get_author_name() ) . ' (' . trim(date_i18n( get_option('date_format'), $entry->get_datetime() )) . ' ' . trim(date_i18n( get_option('time_format'), $entry->get_datetime() )) . ')'; ?></title>
139
  <link><?php
140
  $postid = gwolle_gb_get_postid( (int) $entry->get_book_id() );
141
  $permalink = $blog_url; // init for new entry.
frontend/gb-shortcode-widget.php CHANGED
@@ -81,7 +81,7 @@ function get_gwolle_gb_shortcode_widget( $atts ) {
81
  );
82
 
83
  if ( is_array( $entries ) && ! empty( $entries ) ) {
84
- foreach( $entries as $entry ) {
85
  $widget_html .= '
86
  <li class="' . $widget_item_class . '">';
87
 
81
  );
82
 
83
  if ( is_array( $entries ) && ! empty( $entries ) ) {
84
+ foreach ( $entries as $entry ) {
85
  $widget_html .= '
86
  <li class="' . $widget_item_class . '">';
87
 
frontend/gb-total.php CHANGED
@@ -35,6 +35,7 @@ function gwolle_gb_addon_get_total_entries( $html, $args ) {
35
  * @since 2.6.0
36
  */
37
  function gwolle_gb_get_total_entries( $html, $args ) {
 
38
  if ( ! isset($args['book_id']) ) {
39
  $args['book_id'] = 1; // default
40
  }
@@ -46,7 +47,7 @@ function gwolle_gb_get_total_entries( $html, $args ) {
46
  'checked' => 'checked',
47
  'trash' => 'notrash',
48
  'spam' => 'nospam',
49
- 'book_id' => $args['book_id']
50
  )
51
  );
52
  } else {
@@ -58,7 +59,7 @@ function gwolle_gb_get_total_entries( $html, $args ) {
58
  'checked' => 'checked',
59
  'trash' => 'notrash',
60
  'spam' => 'nospam',
61
- 'book_id' => $args['book_id']
62
  )
63
  );
64
  set_transient( $key, $entries_total, DAY_IN_SECONDS );
@@ -67,6 +68,8 @@ function gwolle_gb_get_total_entries( $html, $args ) {
67
  $html .= '<div id="gwolle-gb-total">' .
68
  sprintf( _n( '%d entry.', '%d entries.', $entries_total, 'gwolle-gb' ), $entries_total )
69
  . '</div>';
 
70
  return $html;
 
71
  }
72
  add_filter( 'gwolle_gb_entries_list_before', 'gwolle_gb_get_total_entries', 8, 2 );
35
  * @since 2.6.0
36
  */
37
  function gwolle_gb_get_total_entries( $html, $args ) {
38
+
39
  if ( ! isset($args['book_id']) ) {
40
  $args['book_id'] = 1; // default
41
  }
47
  'checked' => 'checked',
48
  'trash' => 'notrash',
49
  'spam' => 'nospam',
50
+ 'book_id' => $args['book_id'],
51
  )
52
  );
53
  } else {
59
  'checked' => 'checked',
60
  'trash' => 'notrash',
61
  'spam' => 'nospam',
62
+ 'book_id' => $args['book_id'],
63
  )
64
  );
65
  set_transient( $key, $entries_total, DAY_IN_SECONDS );
68
  $html .= '<div id="gwolle-gb-total">' .
69
  sprintf( _n( '%d entry.', '%d entries.', $entries_total, 'gwolle-gb' ), $entries_total )
70
  . '</div>';
71
+
72
  return $html;
73
+
74
  }
75
  add_filter( 'gwolle_gb_entries_list_before', 'gwolle_gb_get_total_entries', 8, 2 );
frontend/gb-widget-search.php CHANGED
@@ -16,19 +16,22 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
16
  class GwolleGB_Widget_search extends WP_Widget {
17
 
18
  /* Constructor */
19
- function __construct() {
20
- $widget_ops = array( 'classname' => 'gwolle_gb_search', 'description' => esc_html__('Search for guestbook entries.','gwolle-gb') );
 
 
 
21
  parent::__construct('gwolle_gb_search', esc_html__('Guestbook Search', 'gwolle-gb'), $widget_ops);
22
  $this->alt_option_name = 'gwolle_gb_search';
23
  }
24
 
25
  /** @see WP_Widget::widget */
26
- function widget($args, $instance) {
27
  extract($args);
28
 
29
  $default_value = array(
30
- 'title' => esc_html__('Guestbook Search', 'gwolle-gb'),
31
- );
32
  $instance = wp_parse_args( (array) $instance, $default_value );
33
  $widget_title = esc_attr($instance['title']);
34
  $widget_class = 'gwolle-gb-widget-search';
@@ -56,12 +59,12 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
56
  }
57
 
58
  $widget_html .= '
59
- <form id="gwolle-gb-widget-search" action="#" method="GET" class="' . $widget_class . '" role="search" aria-label="' . esc_html__( 'Guestbook', 'gwolle-gb' ) . '">
60
  <div class="label">
61
  <label for="gwolle-gb-search-input" class="text-info">' . esc_html__('Search:', 'gwolle-gb') . '</label>
62
  </div>
63
  <div class="input">
64
- <input class="wp-exclude-emoji" value="' . $searchwords . '" type="text" name="gwolle-gb-search-input" id="gwolle-gb-search-input" placeholder="' . esc_attr__('Search...', 'gwolle-gb') . '" required="required" />
65
  </div>
66
  <div class="gwolle-gb-search-submit">
67
  <div class="input">
@@ -84,19 +87,19 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
84
  }
85
 
86
  /** @see WP_Widget::update */
87
- function update($new_instance, $old_instance) {
88
  $instance = $old_instance;
89
- $instance['title'] = strip_tags($new_instance['title']);
90
 
91
  return $instance;
92
  }
93
 
94
  /** @see WP_Widget::form */
95
- function form($instance) {
96
 
97
  $default_value = array(
98
- 'title' => esc_html__('Guestbook Search', 'gwolle-gb'),
99
- );
100
  $instance = wp_parse_args( (array) $instance, $default_value );
101
  $title = esc_attr($instance['title']);
102
  ?>
@@ -109,7 +112,6 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
109
 
110
  <?php
111
  }
112
-
113
  }
114
 
115
  function gwolle_gb_widget_search() {
16
  class GwolleGB_Widget_search extends WP_Widget {
17
 
18
  /* Constructor */
19
+ public function __construct() {
20
+ $widget_ops = array(
21
+ 'classname' => 'gwolle_gb_search',
22
+ 'description' => esc_html__('Search for guestbook entries.', 'gwolle-gb'),
23
+ );
24
  parent::__construct('gwolle_gb_search', esc_html__('Guestbook Search', 'gwolle-gb'), $widget_ops);
25
  $this->alt_option_name = 'gwolle_gb_search';
26
  }
27
 
28
  /** @see WP_Widget::widget */
29
+ public function widget( $args, $instance ) {
30
  extract($args);
31
 
32
  $default_value = array(
33
+ 'title' => esc_html__('Guestbook Search', 'gwolle-gb'),
34
+ );
35
  $instance = wp_parse_args( (array) $instance, $default_value );
36
  $widget_title = esc_attr($instance['title']);
37
  $widget_class = 'gwolle-gb-widget-search';
59
  }
60
 
61
  $widget_html .= '
62
+ <form id="gwolle-gb-widget-search" action="#" method="GET" class="' . esc_attr( $widget_class ) . '" role="search" aria-label="' . esc_html__( 'Guestbook', 'gwolle-gb' ) . '">
63
  <div class="label">
64
  <label for="gwolle-gb-search-input" class="text-info">' . esc_html__('Search:', 'gwolle-gb') . '</label>
65
  </div>
66
  <div class="input">
67
+ <input class="wp-exclude-emoji" value="' . esc_attr( $searchwords ) . '" type="text" name="gwolle-gb-search-input" id="gwolle-gb-search-input" placeholder="' . esc_attr__('Search...', 'gwolle-gb') . '" required="required" />
68
  </div>
69
  <div class="gwolle-gb-search-submit">
70
  <div class="input">
87
  }
88
 
89
  /** @see WP_Widget::update */
90
+ public function update( $new_instance, $old_instance ) {
91
  $instance = $old_instance;
92
+ $instance['title'] = wp_strip_all_tags($new_instance['title']);
93
 
94
  return $instance;
95
  }
96
 
97
  /** @see WP_Widget::form */
98
+ public function form( $instance ) {
99
 
100
  $default_value = array(
101
+ 'title' => esc_html__('Guestbook Search', 'gwolle-gb'),
102
+ );
103
  $instance = wp_parse_args( (array) $instance, $default_value );
104
  $title = esc_attr($instance['title']);
105
  ?>
112
 
113
  <?php
114
  }
 
115
  }
116
 
117
  function gwolle_gb_widget_search() {
frontend/gb-widget.php CHANGED
@@ -15,14 +15,17 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
15
  class GwolleGB_Widget extends WP_Widget {
16
 
17
  /* Constructor */
18
- function __construct() {
19
- $widget_ops = array( 'classname' => 'gwolle_gb', 'description' => esc_html__('Displays the recent guestbook entries.','gwolle-gb') );
 
 
 
20
  parent::__construct('gwolle_gb', esc_html__('Gwolle Guestbook', 'gwolle-gb'), $widget_ops);
21
  $this->alt_option_name = 'gwolle_gb';
22
  }
23
 
24
  /** @see WP_Widget::widget */
25
- function widget($args, $instance) {
26
  extract($args);
27
 
28
  $default_value = array(
@@ -36,16 +39,18 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
36
  'num_words' => 10,
37
  'book_id' => 0,
38
  'link_text' => esc_html__('Visit guestbook', 'gwolle-gb'),
39
- 'postid' => 0
40
  );
41
  $instance = wp_parse_args( (array) $instance, $default_value );
42
 
43
  $widget_title = esc_attr($instance['title']);
44
  $num_entries = (int) esc_attr($instance['num_entries']);
45
  $best = esc_attr($instance['best']);
46
- $best = explode(",", $best);
47
  $no_mod = (int) esc_attr($instance['no_mod']);
48
- if ( $no_mod ) { $no_mod = 'true'; }
 
 
49
  $name = (int) esc_attr($instance['name']);
50
  $date = (int) esc_attr($instance['date']);
51
  $slider = (int) esc_attr($instance['slider']);
@@ -82,7 +87,7 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
82
  if ( (int) $postid > 0 ) {
83
  $permalink = gwolle_gb_get_permalink( $postid );
84
  $raquo = '
85
- <span class="gb-guestbook-link"><a href="' . $permalink . '" title="' . esc_attr__('Click here to get to the guestbook.', 'gwolle-gb') . '">&raquo;</a></span>
86
  ';
87
  }
88
 
@@ -93,12 +98,14 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
93
  // Get the best entries first
94
  if ( is_array( $best ) && ! empty( $best ) ) {
95
  foreach ($best as $entry_id) {
96
- if ( $counter == $num_entries) { break; } // we have enough
 
 
97
  $entry = new gwolle_gb_entry();
98
  $entry_id = (int) $entry_id;
99
  if ( isset($entry_id) && $entry_id > 0 ) {
100
  $result = $entry->load( $entry_id );
101
- if ( !$result ) {
102
  // No entry loaded
103
  continue;
104
  }
@@ -158,7 +165,7 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
158
  }
159
 
160
  // Get the latest $num_entries guestbook entries
161
- if ( $counter != $num_entries) { // we have enough
162
  $entries = gwolle_gb_get_entries(
163
  array(
164
  'num_entries' => $num_entries,
@@ -166,13 +173,17 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
166
  'trash' => 'notrash',
167
  'spam' => 'nospam',
168
  'book_id' => $book_id,
169
- 'no_moderators' => $no_mod
170
  )
171
  );
172
- if ( is_array( $entries ) && !empty( $entries ) ) {
173
- foreach( $entries as $entry ) {
174
- if ( $counter == $num_entries) { break; } // we have enough
175
- if ( is_array( $best) && in_array( $entry->get_id(), $best ) ) { continue; } // already listed
 
 
 
 
176
  // Main Content
177
  $widget_html .= '
178
  <li class="' . $widget_item_class . '">';
@@ -235,7 +246,7 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
235
  if ( (int) $postid > 0 ) {
236
  $widget_html .= '
237
  <p class="gwolle_gb_link gwolle-gb-link">
238
- <a href="' . $permalink . '" title="' . esc_attr__('Click here to get to the guestbook.', 'gwolle-gb') . '">' . $link_text . ' &raquo;</a>
239
  </p>';
240
  }
241
  $widget_html .= '
@@ -255,11 +266,11 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
255
  }
256
 
257
  /** @see WP_Widget::update */
258
- function update($new_instance, $old_instance) {
259
  $instance = $old_instance;
260
- $instance['title'] = strip_tags($new_instance['title']);
261
- $instance['num_entries'] = (int) strip_tags($new_instance['num_entries']);
262
- $instance['best'] = strip_tags($new_instance['best']);
263
  if ( isset($new_instance['no_mod']) ) {
264
  $instance['no_mod'] = (int) $new_instance['no_mod'];
265
  } else {
@@ -282,14 +293,14 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
282
  }
283
  $instance['num_words'] = (int) $new_instance['num_words'];
284
  $instance['book_id'] = (int) $new_instance['book_id'];
285
- $instance['link_text'] = strip_tags($new_instance['link_text']);
286
  $instance['postid'] = (int) $new_instance['postid'];
287
 
288
  return $instance;
289
  }
290
 
291
  /** @see WP_Widget::form */
292
- function form($instance) {
293
 
294
  $default_value = array(
295
  'title' => esc_html__('Guestbook', 'gwolle-gb'),
@@ -302,7 +313,7 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
302
  'num_words' => 10,
303
  'book_id' => 0,
304
  'link_text' => esc_html__('Visit guestbook', 'gwolle-gb'),
305
- 'postid' => 0
306
  );
307
  $instance = wp_parse_args( (array) $instance, $default_value );
308
 
@@ -418,27 +429,27 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
418
  ),
419
  ),
420
  'update_post_term_cache' => false,
421
- 'update_post_meta_cache' => false
422
  );
423
 
424
  $sel_query = new WP_Query( $args );
425
  if ( $sel_query->have_posts() ) {
426
- while ( $sel_query->have_posts() ) : $sel_query->the_post();
 
427
  $selected = false;
428
- if ( get_the_ID() == $postid ) {
429
  $selected = true;
430
  }
431
  echo '<option value="' . get_the_ID() . '"'
432
  . selected( $selected )
433
- . '>'. get_the_title() . '</option>';
434
- endwhile;
435
  }
436
  wp_reset_postdata(); ?>
437
  </select>
438
  </p>
439
  <?php
440
  }
441
-
442
  }
443
 
444
  function gwolle_gb_widget() {
15
  class GwolleGB_Widget extends WP_Widget {
16
 
17
  /* Constructor */
18
+ public function __construct() {
19
+ $widget_ops = array(
20
+ 'classname' => 'gwolle_gb',
21
+ 'description' => esc_html__('Displays the recent guestbook entries.', 'gwolle-gb'),
22
+ );
23
  parent::__construct('gwolle_gb', esc_html__('Gwolle Guestbook', 'gwolle-gb'), $widget_ops);
24
  $this->alt_option_name = 'gwolle_gb';
25
  }
26
 
27
  /** @see WP_Widget::widget */
28
+ public function widget( $args, $instance ) {
29
  extract($args);
30
 
31
  $default_value = array(
39
  'num_words' => 10,
40
  'book_id' => 0,
41
  'link_text' => esc_html__('Visit guestbook', 'gwolle-gb'),
42
+ 'postid' => 0,
43
  );
44
  $instance = wp_parse_args( (array) $instance, $default_value );
45
 
46
  $widget_title = esc_attr($instance['title']);
47
  $num_entries = (int) esc_attr($instance['num_entries']);
48
  $best = esc_attr($instance['best']);
49
+ $best = explode(',', $best);
50
  $no_mod = (int) esc_attr($instance['no_mod']);
51
+ if ( $no_mod ) {
52
+ $no_mod = 'true';
53
+ }
54
  $name = (int) esc_attr($instance['name']);
55
  $date = (int) esc_attr($instance['date']);
56
  $slider = (int) esc_attr($instance['slider']);
87
  if ( (int) $postid > 0 ) {
88
  $permalink = gwolle_gb_get_permalink( $postid );
89
  $raquo = '
90
+ <span class="gb-guestbook-link"><a href="' . esc_attr( $permalink ) . '" title="' . esc_attr__('Click here to get to the guestbook.', 'gwolle-gb') . '">&raquo;</a></span>
91
  ';
92
  }
93
 
98
  // Get the best entries first
99
  if ( is_array( $best ) && ! empty( $best ) ) {
100
  foreach ($best as $entry_id) {
101
+ if ( $counter === $num_entries ) {
102
+ break; // we have enough
103
+ }
104
  $entry = new gwolle_gb_entry();
105
  $entry_id = (int) $entry_id;
106
  if ( isset($entry_id) && $entry_id > 0 ) {
107
  $result = $entry->load( $entry_id );
108
+ if ( ! $result ) {
109
  // No entry loaded
110
  continue;
111
  }
165
  }
166
 
167
  // Get the latest $num_entries guestbook entries
168
+ if ( $counter !== $num_entries) { // we have enough
169
  $entries = gwolle_gb_get_entries(
170
  array(
171
  'num_entries' => $num_entries,
173
  'trash' => 'notrash',
174
  'spam' => 'nospam',
175
  'book_id' => $book_id,
176
+ 'no_moderators' => $no_mod,
177
  )
178
  );
179
+ if ( is_array( $entries ) && ! empty( $entries ) ) {
180
+ foreach ( $entries as $entry ) {
181
+ if ( $counter === $num_entries) {
182
+ break; // we have enough
183
+ }
184
+ if ( is_array( $best) && in_array( $entry->get_id(), $best ) ) {
185
+ continue; // already listed
186
+ }
187
  // Main Content
188
  $widget_html .= '
189
  <li class="' . $widget_item_class . '">';
246
  if ( (int) $postid > 0 ) {
247
  $widget_html .= '
248
  <p class="gwolle_gb_link gwolle-gb-link">
249
+ <a href="' . esc_attr( $permalink ) . '" title="' . esc_attr__('Click here to get to the guestbook.', 'gwolle-gb') . '">' . $link_text . ' &raquo;</a>
250
  </p>';
251
  }
252
  $widget_html .= '
266
  }
267
 
268
  /** @see WP_Widget::update */
269
+ public function update( $new_instance, $old_instance ) {
270
  $instance = $old_instance;
271
+ $instance['title'] = wp_strip_all_tags($new_instance['title']);
272
+ $instance['num_entries'] = (int) wp_strip_all_tags($new_instance['num_entries']);
273
+ $instance['best'] = wp_strip_all_tags($new_instance['best']);
274
  if ( isset($new_instance['no_mod']) ) {
275
  $instance['no_mod'] = (int) $new_instance['no_mod'];
276
  } else {
293
  }
294
  $instance['num_words'] = (int) $new_instance['num_words'];
295
  $instance['book_id'] = (int) $new_instance['book_id'];
296
+ $instance['link_text'] = wp_strip_all_tags($new_instance['link_text']);
297
  $instance['postid'] = (int) $new_instance['postid'];
298
 
299
  return $instance;
300
  }
301
 
302
  /** @see WP_Widget::form */
303
+ public function form( $instance ) {
304
 
305
  $default_value = array(
306
  'title' => esc_html__('Guestbook', 'gwolle-gb'),
313
  'num_words' => 10,
314
  'book_id' => 0,
315
  'link_text' => esc_html__('Visit guestbook', 'gwolle-gb'),
316
+ 'postid' => 0,
317
  );
318
  $instance = wp_parse_args( (array) $instance, $default_value );
319
 
429
  ),
430
  ),
431
  'update_post_term_cache' => false,
432
+ 'update_post_meta_cache' => false,
433
  );
434
 
435
  $sel_query = new WP_Query( $args );
436
  if ( $sel_query->have_posts() ) {
437
+ while ( $sel_query->have_posts() ) {
438
+ $sel_query->the_post();
439
  $selected = false;
440
+ if ( get_the_ID() === $postid ) {
441
  $selected = true;
442
  }
443
  echo '<option value="' . get_the_ID() . '"'
444
  . selected( $selected )
445
+ . '>' . get_the_title() . '</option>';
446
+ }
447
  }
448
  wp_reset_postdata(); ?>
449
  </select>
450
  </p>
451
  <?php
452
  }
 
453
  }
454
 
455
  function gwolle_gb_widget() {
frontend/gwolle_gb-entry.php CHANGED
@@ -14,15 +14,16 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  die('No direct calls allowed!');
15
  }
16
 
17
- /*
18
- * Template file for s single guestbook entry.
19
- *
20
- * @param object $entry instance of gwolle_gb_entry.
21
- * @param bool $first true if it is the first entry.
22
- * @param int $counter the number of the entry. (since 1.4.7)
23
- * @return: string, html with a single guestbook entry.
24
- */
25
  if ( ! function_exists('gwolle_gb_entry_template') ) {
 
 
 
 
 
 
 
 
26
  function gwolle_gb_entry_template( $entry, $first, $counter ) {
27
 
28
  $html5 = current_theme_supports( 'html5' );
@@ -40,7 +41,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
40
  } else {
41
  $entry_class .= ' gwolle_gb_uneven gwolle-gb-uneven';
42
  }
43
- if ( $first == true ) {
44
  $entry_class .= ' gwolle_gb_first gwolle-gb-first';
45
  }
46
 
@@ -67,7 +68,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
67
  <div class="gb-author-info">';
68
 
69
  // Author Avatar
70
- if ( isset($read_setting['read_avatar']) && $read_setting['read_avatar'] === 'true' ) {
71
  $avatar = get_avatar( $entry->get_author_email(), 32, '', $entry->get_author_name() );
72
  if ($avatar) {
73
  $avatar = str_replace('<img', '<img referrerpolicy="no-referrer"', $avatar);
@@ -77,7 +78,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
77
  }
78
 
79
  // Author Name
80
- if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' ) {
81
  $author_name_html = gwolle_gb_get_author_name_html($entry);
82
  $entry_output .= '
83
  <span class="gb-author-name">' . $author_name_html . '
@@ -85,7 +86,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
85
  }
86
 
87
  // Author Origin
88
- if ( isset($read_setting['read_city']) && $read_setting['read_city'] === 'true' ) {
89
  $origin = $entry->get_author_origin();
90
  if ( strlen(str_replace(' ', '', $origin)) > 0 ) {
91
  $entry_output .= '
@@ -97,16 +98,16 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
97
  }
98
 
99
  // Entry Date and Time
100
- if ( ( isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' ) || ( isset($read_setting['read_date']) && $read_setting['read_date'] === 'true' ) ) {
101
  $entry_output .= '
102
  <span class="gb-datetime">
103
  <span class="gb-date">';
104
- if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' ) {
105
  $entry_output .= '<span class="gb-date-wrote-text"> ' . /* translators: on a certain date */ esc_html__('wrote on', 'gwolle-gb') . '</span>';
106
  }
107
  $entry_output .= '<span class="gb-date-text"> ' . date_i18n( get_option('date_format'), $entry->get_datetime() ) . '</span>
108
  </span>';
109
- if ( isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' ) {
110
  // Use 'at'. Follow WordPress Core: class-walker-comment.php
111
  $entry_output .= '<span class="gb-time">
112
  <span class="gb-time-at-text"> ' . /* translators: at a certain time */ esc_html__('at', 'gwolle-gb') . '</span>
@@ -118,10 +119,10 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
118
  }
119
 
120
  $entry_output .= '
121
- </div>'; // <div class="gb-author-info">
122
 
123
  // Main Content
124
- if ( isset($read_setting['read_content']) && $read_setting['read_content'] === 'true' ) {
125
  $entry_output .= '
126
  <div class="gb-entry-content">';
127
 
@@ -135,7 +136,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
135
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
136
  $entry_content = nl2br($entry_content);
137
  }
138
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
139
  $entry_content = gwolle_gb_bbcode_parse($entry_content);
140
  } else {
141
  $entry_content = gwolle_gb_bbcode_strip($entry_content);
@@ -165,7 +166,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
165
  // This filters the real content of the admin reply.
166
  $admin_reply_content = apply_filters( 'gwolle_gb_entry_the_admin_reply', $admin_reply_content, $entry );
167
 
168
- if ( $admin_reply_content != '' ) {
169
 
170
  $class = '';
171
  if ( get_option( 'gwolle_gb-admin_style', 'false' ) === 'true' ) {
@@ -180,7 +181,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
180
  <div class="gb-admin_reply_uid gb-admin-reply-uid">';
181
  $admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
182
  /* Admin Avatar */
183
- if ( isset($read_setting['read_aavatar']) && $read_setting['read_aavatar'] === 'true' ) {
184
  $user_info = get_userdata( $entry->get_admin_reply_uid() );
185
  if ( is_object($user_info) ) {
186
  $admin_reply_email = $user_info->user_email;
@@ -192,7 +193,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
192
  }
193
  }
194
  /* Admin Header */
195
- if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' && $admin_reply_name ) {
196
  $admin_reply_header = '
197
  <em>' . esc_html__('Admin Reply by:', 'gwolle-gb') . ' ' . $admin_reply_name . '</em>';
198
  } else {
@@ -210,7 +211,7 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
210
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
211
  $admin_reply_content = nl2br($admin_reply_content);
212
  }
213
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
214
  $admin_reply_content = gwolle_gb_bbcode_parse($admin_reply_content);
215
  } else {
216
  $admin_reply_content = gwolle_gb_bbcode_strip($admin_reply_content);
14
  die('No direct calls allowed!');
15
  }
16
 
17
+
 
 
 
 
 
 
 
18
  if ( ! function_exists('gwolle_gb_entry_template') ) {
19
+ /*
20
+ * Template file for s single guestbook entry.
21
+ *
22
+ * @param object $entry instance of gwolle_gb_entry.
23
+ * @param bool $first true if it is the first entry.
24
+ * @param int $counter the number of the entry. (since 1.4.7)
25
+ * @return: string, html with a single guestbook entry.
26
+ */
27
  function gwolle_gb_entry_template( $entry, $first, $counter ) {
28
 
29
  $html5 = current_theme_supports( 'html5' );
41
  } else {
42
  $entry_class .= ' gwolle_gb_uneven gwolle-gb-uneven';
43
  }
44
+ if ( $first === true ) {
45
  $entry_class .= ' gwolle_gb_first gwolle-gb-first';
46
  }
47
 
68
  <div class="gb-author-info">';
69
 
70
  // Author Avatar
71
+ if ( isset($read_setting['read_avatar']) && $read_setting['read_avatar'] === 'true' ) {
72
  $avatar = get_avatar( $entry->get_author_email(), 32, '', $entry->get_author_name() );
73
  if ($avatar) {
74
  $avatar = str_replace('<img', '<img referrerpolicy="no-referrer"', $avatar);
78
  }
79
 
80
  // Author Name
81
+ if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' ) {
82
  $author_name_html = gwolle_gb_get_author_name_html($entry);
83
  $entry_output .= '
84
  <span class="gb-author-name">' . $author_name_html . '
86
  }
87
 
88
  // Author Origin
89
+ if ( isset($read_setting['read_city']) && $read_setting['read_city'] === 'true' ) {
90
  $origin = $entry->get_author_origin();
91
  if ( strlen(str_replace(' ', '', $origin)) > 0 ) {
92
  $entry_output .= '
98
  }
99
 
100
  // Entry Date and Time
101
+ if ( ( isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' ) || ( isset($read_setting['read_date']) && $read_setting['read_date'] === 'true' ) ) {
102
  $entry_output .= '
103
  <span class="gb-datetime">
104
  <span class="gb-date">';
105
+ if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' ) {
106
  $entry_output .= '<span class="gb-date-wrote-text"> ' . /* translators: on a certain date */ esc_html__('wrote on', 'gwolle-gb') . '</span>';
107
  }
108
  $entry_output .= '<span class="gb-date-text"> ' . date_i18n( get_option('date_format'), $entry->get_datetime() ) . '</span>
109
  </span>';
110
+ if ( isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' ) {
111
  // Use 'at'. Follow WordPress Core: class-walker-comment.php
112
  $entry_output .= '<span class="gb-time">
113
  <span class="gb-time-at-text"> ' . /* translators: at a certain time */ esc_html__('at', 'gwolle-gb') . '</span>
119
  }
120
 
121
  $entry_output .= '
122
+ </div>'; // end <div class="gb-author-info">
123
 
124
  // Main Content
125
+ if ( isset($read_setting['read_content']) && $read_setting['read_content'] === 'true' ) {
126
  $entry_output .= '
127
  <div class="gb-entry-content">';
128
 
136
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
137
  $entry_content = nl2br($entry_content);
138
  }
139
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
140
  $entry_content = gwolle_gb_bbcode_parse($entry_content);
141
  } else {
142
  $entry_content = gwolle_gb_bbcode_strip($entry_content);
166
  // This filters the real content of the admin reply.
167
  $admin_reply_content = apply_filters( 'gwolle_gb_entry_the_admin_reply', $admin_reply_content, $entry );
168
 
169
+ if ( $admin_reply_content !== '' ) {
170
 
171
  $class = '';
172
  if ( get_option( 'gwolle_gb-admin_style', 'false' ) === 'true' ) {
181
  <div class="gb-admin_reply_uid gb-admin-reply-uid">';
182
  $admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
183
  /* Admin Avatar */
184
+ if ( isset($read_setting['read_aavatar']) && $read_setting['read_aavatar'] === 'true' ) {
185
  $user_info = get_userdata( $entry->get_admin_reply_uid() );
186
  if ( is_object($user_info) ) {
187
  $admin_reply_email = $user_info->user_email;
193
  }
194
  }
195
  /* Admin Header */
196
+ if ( isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' && $admin_reply_name ) {
197
  $admin_reply_header = '
198
  <em>' . esc_html__('Admin Reply by:', 'gwolle-gb') . ' ' . $admin_reply_name . '</em>';
199
  } else {
211
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
212
  $admin_reply_content = nl2br($admin_reply_content);
213
  }
214
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
215
  $admin_reply_content = gwolle_gb_bbcode_parse($admin_reply_content);
216
  } else {
217
  $admin_reply_content = gwolle_gb_bbcode_strip($admin_reply_content);
frontend/js/gwolle-gb-frontend.js CHANGED
@@ -114,7 +114,7 @@ jQuery(document).ready(function($) {
114
  if ( jQuery( ".gwolle-gb-read" ).hasClass( 'gwolle-gb-infinite' ) ) {
115
  var gwolle_gb_scroll_count = 2; // We already have page 1 listed.
116
 
117
- var gwolle_gb_load_message = '<div class="gb-entry gwolle_gb_load_message">' + gwolle_gb_frontend_script.load_message + '</div>' ;
118
  jQuery( ".gwolle-gb-read" ).append( gwolle_gb_load_message );
119
 
120
  jQuery(window).on('scroll', function() {
@@ -131,10 +131,10 @@ jQuery(document).ready(function($) {
131
 
132
  jQuery('.gwolle_gb_load_message').toggle();
133
 
134
- var gwolle_gb_end_message = '<div class="gb-entry gwolle_gb_end_message">' + gwolle_gb_frontend_script.end_message + '</div>' ;
135
 
136
  var data = {
137
- action: 'gwolle_gb_infinite_scroll',
138
  pageNum: page,
139
  permalink: window.location.href,
140
  book_id: jQuery( ".gwolle-gb-read" ).attr( "data-book_id" )
@@ -203,7 +203,7 @@ jQuery(document).ready(function($) {
203
  var timeout2 = gwolle_gb_frontend_script.timeout2;
204
 
205
  var timer = new Number( jQuery( 'input.' + timeout, form ).val() );
206
- var timer2 = new Number( jQuery( 'input.' + timeout2, form ).val() );
207
 
208
  var timer = timer - 1;
209
  var timer2 = timer2 + 1;
@@ -239,14 +239,14 @@ jQuery(document).ready(function($) {
239
  var val = jQuery( this ).prop('value');
240
  var name = jQuery( this ).attr('name');
241
  var type = jQuery( this ).attr('type');
242
- if ( type == 'checkbox' ) {
243
  var checked = jQuery( this, main_div ).prop('checked');
244
- if ( checked == true ) {
245
  gwolle_gb_ajax_data[name] = 'on'; // Mimick standard $_POST value.
246
  }
247
- } else if ( type == 'radio' ) {
248
  var checked = jQuery( this, main_div ).prop('checked');
249
- if ( checked == true ) {
250
  gwolle_gb_ajax_data[name] = val;
251
  }
252
  } else {
@@ -269,10 +269,10 @@ jQuery(document).ready(function($) {
269
  if ( gwolle_gb_is_json( response ) ) {
270
  data = JSON.parse( response );
271
 
272
- if ( ( typeof data['saved'] == 'boolean' || typeof data['saved'] == 'number' )
273
- && typeof data['gwolle_gb_messages'] == 'string'
274
- && typeof data['gwolle_gb_errors'] == 'boolean'
275
- && typeof data['gwolle_gb_error_fields'] == 'object' ) { // Too strict in testing?
276
 
277
  var saved = data['saved'];
278
  var gwolle_gb_messages = data['gwolle_gb_messages'];
@@ -285,7 +285,7 @@ jQuery(document).ready(function($) {
285
  jQuery( '.gwolle_gb_form_ajax div.input').removeClass( 'error' );
286
 
287
  // we have all the data we expect.
288
- if ( typeof data['saved'] == 'number' ) {
289
 
290
  // Show returned messages.
291
  jQuery( '.gwolle_gb_messages_bottom_container', main_div ).html('');
@@ -297,7 +297,7 @@ jQuery(document).ready(function($) {
297
  jQuery( '.gwolle-gb-write-button', main_div ).css( 'display', 'block' );
298
 
299
  // Prepend entry to the entry list if desired.
300
- if ( typeof data['entry'] == 'string' ) {
301
  jQuery( '.gwolle-gb-read', main_div ).prepend( data['entry'] );
302
  }
303
 
@@ -345,11 +345,11 @@ jQuery(document).ready(function($) {
345
  jQuery( 'textarea.' + value, main_div ).addClass( 'error' );
346
  jQuery( 'input.' + value, main_div ).addClass( 'error' );
347
  var type = jQuery( 'input.' + value, main_div ).attr('type');
348
- if ( typeof type != 'undefined' && type == 'radio' ) {
349
  jQuery( 'input.' + value, main_div ).closest('div.input').addClass( 'error' );
350
  }
351
  var select = jQuery( 'select.' + value, main_div ).length;
352
- if ( typeof select != 'undefined' && select == 1 ) { // number of elements, which should be 1.
353
  jQuery( 'select.' + value, main_div ).closest('div.input').addClass( 'error' );
354
  }
355
  });
@@ -371,6 +371,29 @@ jQuery(document).ready(function($) {
371
  });
372
 
373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  function gwolle_gb_is_json( string ) {
375
  try {
376
  JSON.parse( string );
114
  if ( jQuery( ".gwolle-gb-read" ).hasClass( 'gwolle-gb-infinite' ) ) {
115
  var gwolle_gb_scroll_count = 2; // We already have page 1 listed.
116
 
117
+ var gwolle_gb_load_message = '<div class="gb-entry gwolle_gb_load_message">' + gwolle_gb_frontend_script.load_message + '</div>';
118
  jQuery( ".gwolle-gb-read" ).append( gwolle_gb_load_message );
119
 
120
  jQuery(window).on('scroll', function() {
131
 
132
  jQuery('.gwolle_gb_load_message').toggle();
133
 
134
+ var gwolle_gb_end_message = '<div class="gb-entry gwolle_gb_end_message">' + gwolle_gb_frontend_script.end_message + '</div>';
135
 
136
  var data = {
137
+ action: 'gwolle_gb_infinite_scroll',
138
  pageNum: page,
139
  permalink: window.location.href,
140
  book_id: jQuery( ".gwolle-gb-read" ).attr( "data-book_id" )
203
  var timeout2 = gwolle_gb_frontend_script.timeout2;
204
 
205
  var timer = new Number( jQuery( 'input.' + timeout, form ).val() );
206
+ var timer2 = new Number( jQuery( 'input.' + timeout2, form ).val() );
207
 
208
  var timer = timer - 1;
209
  var timer2 = timer2 + 1;
239
  var val = jQuery( this ).prop('value');
240
  var name = jQuery( this ).attr('name');
241
  var type = jQuery( this ).attr('type');
242
+ if ( type === 'checkbox' ) {
243
  var checked = jQuery( this, main_div ).prop('checked');
244
+ if ( checked === true ) {
245
  gwolle_gb_ajax_data[name] = 'on'; // Mimick standard $_POST value.
246
  }
247
+ } else if ( type === 'radio' ) {
248
  var checked = jQuery( this, main_div ).prop('checked');
249
+ if ( checked === true ) {
250
  gwolle_gb_ajax_data[name] = val;
251
  }
252
  } else {
269
  if ( gwolle_gb_is_json( response ) ) {
270
  data = JSON.parse( response );
271
 
272
+ if ( ( typeof data['saved'] === 'boolean' || typeof data['saved'] === 'number' )
273
+ && typeof data['gwolle_gb_messages'] === 'string'
274
+ && typeof data['gwolle_gb_errors'] === 'boolean'
275
+ && typeof data['gwolle_gb_error_fields'] === 'object' ) { // Too strict in testing?
276
 
277
  var saved = data['saved'];
278
  var gwolle_gb_messages = data['gwolle_gb_messages'];
285
  jQuery( '.gwolle_gb_form_ajax div.input').removeClass( 'error' );
286
 
287
  // we have all the data we expect.
288
+ if ( typeof data['saved'] === 'number' ) {
289
 
290
  // Show returned messages.
291
  jQuery( '.gwolle_gb_messages_bottom_container', main_div ).html('');
297
  jQuery( '.gwolle-gb-write-button', main_div ).css( 'display', 'block' );
298
 
299
  // Prepend entry to the entry list if desired.
300
+ if ( typeof data['entry'] === 'string' ) {
301
  jQuery( '.gwolle-gb-read', main_div ).prepend( data['entry'] );
302
  }
303
 
345
  jQuery( 'textarea.' + value, main_div ).addClass( 'error' );
346
  jQuery( 'input.' + value, main_div ).addClass( 'error' );
347
  var type = jQuery( 'input.' + value, main_div ).attr('type');
348
+ if ( typeof type !== 'undefined' && type === 'radio' ) {
349
  jQuery( 'input.' + value, main_div ).closest('div.input').addClass( 'error' );
350
  }
351
  var select = jQuery( 'select.' + value, main_div ).length;
352
+ if ( typeof select !== 'undefined' && select === 1 ) { // number of elements, which should be 1.
353
  jQuery( 'select.' + value, main_div ).closest('div.input').addClass( 'error' );
354
  }
355
  });
371
  });
372
 
373
 
374
+ jQuery(document).ready(function($) {
375
+ jQuery( 'form.gwolle-gb-write textarea.maxlength' ).on( 'keyup', function( textarea ) {
376
+ var div_input = jQuery( textarea.target ).closest( 'div.input' );
377
+ var content = jQuery( this ).prop('value');
378
+ content = content.trim();
379
+
380
+ // split and assign cut up emoji. Array.from and spread operator support multibyte characters like emoji.
381
+ if ( typeof Array.from === 'function' ) {
382
+ // New browsers with support for ES6
383
+ var chars = Array.from( content );
384
+ var length = chars.length;
385
+ } else {
386
+ // Old browsers: Count emoji as double characters.
387
+ var length = content.length;
388
+ }
389
+
390
+ jQuery( 'span.gb-used-characters', div_input ).text( length );
391
+
392
+ return false;
393
+ });
394
+ });
395
+
396
+
397
  function gwolle_gb_is_json( string ) {
398
  try {
399
  JSON.parse( string );
frontend/js/sss/index.html ADDED
File without changes
functions/gb-akismet.php CHANGED
@@ -27,7 +27,7 @@ function gwolle_gb_akismet( $entry, $action ) {
27
  $actions = array(
28
  'comment-check',
29
  'submit-ham',
30
- 'submit-spam'
31
  );
32
 
33
  if ( ! in_array( $action, $actions ) ) {
@@ -40,7 +40,7 @@ function gwolle_gb_akismet( $entry, $action ) {
40
  }
41
 
42
  $akismet_active = get_option( 'gwolle_gb-akismet-active', 'false' );
43
- if ( $akismet_active != 'true' ) {
44
  return false;
45
  }
46
 
@@ -76,9 +76,11 @@ function gwolle_gb_akismet( $entry, $action ) {
76
  $comment['blog_lang'] = get_locale();
77
  $comment['blog_charset'] = get_option( 'blog_charset' );
78
  $store_author_ip = get_option('gwolle_gb-store_ip', 'true');
79
- if ( $store_author_ip == 'true' ) {
80
  $comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', gwolle_gb_get_user_ip() );
81
- $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
 
 
82
  }
83
  if ( isset($_SERVER['HTTP_REFERER']) ) {
84
  $comment['referrer'] = $_SERVER['HTTP_REFERER'];
@@ -122,8 +124,10 @@ function gwolle_gb_akismet_entry_check( $comment, $action ) {
122
  $query_string = '';
123
 
124
  foreach ( $comment as $key => $data ) {
125
- if (is_array($data)) { continue; }
126
- $query_string .= $key . '=' . urlencode( wp_unslash( (string) $data ) ) . '&';
 
 
127
  }
128
 
129
  if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
@@ -135,11 +139,11 @@ function gwolle_gb_akismet_entry_check( $comment, $action ) {
135
 
136
  //if ( WP_DEBUG ) { echo "Akismet response: "; var_dump($response); }
137
 
138
- if ( $action == 'comment-check' && isset( $response[1] ) && 'true' == $response[1] ) {
139
  return true;
140
- } else if ( $action == 'submit-ham' && isset( $response[1] ) ) {
141
  return true;
142
- } else if ( $action == 'submit-spam' && isset( $response[1] ) ) {
143
  return true;
144
  } else {
145
  return false;
27
  $actions = array(
28
  'comment-check',
29
  'submit-ham',
30
+ 'submit-spam',
31
  );
32
 
33
  if ( ! in_array( $action, $actions ) ) {
40
  }
41
 
42
  $akismet_active = get_option( 'gwolle_gb-akismet-active', 'false' );
43
+ if ( $akismet_active !== 'true' ) {
44
  return false;
45
  }
46
 
76
  $comment['blog_lang'] = get_locale();
77
  $comment['blog_charset'] = get_option( 'blog_charset' );
78
  $store_author_ip = get_option('gwolle_gb-store_ip', 'true');
79
+ if ( $store_author_ip === 'true' ) {
80
  $comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', gwolle_gb_get_user_ip() );
81
+ if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
82
+ $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
83
+ }
84
  }
85
  if ( isset($_SERVER['HTTP_REFERER']) ) {
86
  $comment['referrer'] = $_SERVER['HTTP_REFERER'];
124
  $query_string = '';
125
 
126
  foreach ( $comment as $key => $data ) {
127
+ if ( is_array($data) ) {
128
+ continue;
129
+ }
130
+ $query_string .= $key . '=' . rawurlencode( wp_unslash( (string) $data ) ) . '&';
131
  }
132
 
133
  if ( is_callable( array( 'Akismet', 'http_post' ) ) ) {
139
 
140
  //if ( WP_DEBUG ) { echo "Akismet response: "; var_dump($response); }
141
 
142
+ if ( $action === 'comment-check' && isset( $response[1] ) && 'true' === $response[1] ) {
143
  return true;
144
+ } else if ( $action === 'submit-ham' && isset( $response[1] ) ) {
145
  return true;
146
+ } else if ( $action === 'submit-spam' && isset( $response[1] ) ) {
147
  return true;
148
  } else {
149
  return false;
functions/gb-bbcode_emoji.php CHANGED
@@ -75,7 +75,7 @@ function gwolle_gb_bbcode_parse( $str ) {
75
  * @param string $str content that needs to be stripped
76
  * @return string stripped content
77
  */
78
- function gwolle_gb_bbcode_strip( $str ){
79
  $bb = array();
80
  $html = array();
81
 
@@ -204,7 +204,7 @@ function gwolle_gb_get_emoji() {
204
  function gwolle_gb_maybe_encode_emoji( $string, $field ) {
205
  global $wpdb;
206
  $db_charset = $wpdb->charset;
207
- if ( 'utf8mb4' != $db_charset ) {
208
  if ( function_exists( 'wp_encode_emoji' ) && function_exists( 'mb_convert_encoding' ) ) {
209
  // No support for the proper charset, so encode to html entities.
210
  $string = wp_encode_emoji( $string );
75
  * @param string $str content that needs to be stripped
76
  * @return string stripped content
77
  */
78
+ function gwolle_gb_bbcode_strip( $str ) {
79
  $bb = array();
80
  $html = array();
81
 
204
  function gwolle_gb_maybe_encode_emoji( $string, $field ) {
205
  global $wpdb;
206
  $db_charset = $wpdb->charset;
207
+ if ( 'utf8mb4' !== $db_charset ) {
208
  if ( function_exists( 'wp_encode_emoji' ) && function_exists( 'mb_convert_encoding' ) ) {
209
  // No support for the proper charset, so encode to html entities.
210
  $string = wp_encode_emoji( $string );
functions/gb-book_id.php CHANGED
@@ -29,18 +29,20 @@ function gwolle_gb_get_postid( $book_id = 1 ) {
29
  ),
30
  ),
31
  'update_post_term_cache' => false,
32
- 'update_post_meta_cache' => false
33
  ));
34
 
35
  if ( $the_query->have_posts() ) {
36
- while ( $the_query->have_posts() ) : $the_query->the_post();
 
37
  $postid = get_the_ID();
38
  return $postid; // only one postid is needed.
39
- endwhile;
40
  wp_reset_postdata();
41
  }
42
 
43
  return 0;
 
44
  }
45
 
46
 
@@ -56,7 +58,7 @@ function gwolle_gb_get_postid_biggest_book() {
56
  $postids = gwolle_gb_get_books();
57
  if ( is_array($postids) && ! empty($postids) ) {
58
 
59
- if ( count( $postids ) == 1 ) {
60
  return $postids[0]; // just one guestbook, return it.
61
  }
62
 
@@ -75,7 +77,7 @@ function gwolle_gb_get_postid_biggest_book() {
75
  'checked' => 'checked',
76
  'trash' => 'notrash',
77
  'spam' => 'nospam',
78
- 'book_id' => $bookid
79
  )
80
  );
81
  set_transient( $key, $entries_total, DAY_IN_SECONDS );
@@ -83,7 +85,7 @@ function gwolle_gb_get_postid_biggest_book() {
83
  $book = array();
84
  $book['postid'] = $postid;
85
  $book['bookid'] = $bookid;
86
- $book['entries_total'] = $entries_total;
87
  $books[] = $book;
88
  $totals[] = $entries_total;
89
  }
@@ -92,13 +94,14 @@ function gwolle_gb_get_postid_biggest_book() {
92
  rsort( $totals );
93
 
94
  foreach ( $books as $book ) {
95
- if ( $book['entries_total'] == $totals[0] ) {
96
  return $book['postid'];
97
  }
98
  }
99
  }
100
 
101
  return 0;
 
102
  }
103
 
104
 
@@ -123,17 +126,19 @@ function gwolle_gb_get_books() {
123
  ),
124
  ),
125
  'update_post_term_cache' => false,
126
- 'update_post_meta_cache' => false
127
  ));
128
  $postids = array();
129
  if ( $the_query->have_posts() ) {
130
- while ( $the_query->have_posts() ) : $the_query->the_post();
 
131
  $postids[] = get_the_ID();
132
- endwhile;
133
  wp_reset_postdata();
134
  }
135
 
136
  return $postids;
 
137
  }
138
 
139
 
@@ -150,23 +155,24 @@ function gwolle_gb_get_permalinks() {
150
 
151
  foreach ( $postids as $postid ) {
152
  $permalink = gwolle_gb_get_permalink( $postid );
153
- if ( strlen( $permalink ) == 0 ) {
154
  continue;
155
  }
156
 
157
  $book_id = get_post_meta( $postid, 'gwolle_gb_book_id', true );
158
- if ( strlen( $book_id ) == 0 ) {
159
  continue;
160
  }
161
 
162
  $books[] = array(
163
  'post_id' => $postid,
164
  'book_id' => $book_id,
165
- 'permalink' => $permalink
166
  );
167
  }
168
 
169
  return $books;
 
170
  }
171
 
172
 
29
  ),
30
  ),
31
  'update_post_term_cache' => false,
32
+ 'update_post_meta_cache' => false,
33
  ));
34
 
35
  if ( $the_query->have_posts() ) {
36
+ while ( $the_query->have_posts() ) {
37
+ $the_query->the_post();
38
  $postid = get_the_ID();
39
  return $postid; // only one postid is needed.
40
+ }
41
  wp_reset_postdata();
42
  }
43
 
44
  return 0;
45
+
46
  }
47
 
48
 
58
  $postids = gwolle_gb_get_books();
59
  if ( is_array($postids) && ! empty($postids) ) {
60
 
61
+ if ( count( $postids ) === 1 ) {
62
  return $postids[0]; // just one guestbook, return it.
63
  }
64
 
77
  'checked' => 'checked',
78
  'trash' => 'notrash',
79
  'spam' => 'nospam',
80
+ 'book_id' => $bookid,
81
  )
82
  );
83
  set_transient( $key, $entries_total, DAY_IN_SECONDS );
85
  $book = array();
86
  $book['postid'] = $postid;
87
  $book['bookid'] = $bookid;
88
+ $book['entries_total'] = (int) $entries_total;
89
  $books[] = $book;
90
  $totals[] = $entries_total;
91
  }
94
  rsort( $totals );
95
 
96
  foreach ( $books as $book ) {
97
+ if ( $book['entries_total'] === $totals[0] ) {
98
  return $book['postid'];
99
  }
100
  }
101
  }
102
 
103
  return 0;
104
+
105
  }
106
 
107
 
126
  ),
127
  ),
128
  'update_post_term_cache' => false,
129
+ 'update_post_meta_cache' => false,
130
  ));
131
  $postids = array();
132
  if ( $the_query->have_posts() ) {
133
+ while ( $the_query->have_posts() ) {
134
+ $the_query->the_post();
135
  $postids[] = get_the_ID();
136
+ }
137
  wp_reset_postdata();
138
  }
139
 
140
  return $postids;
141
+
142
  }
143
 
144
 
155
 
156
  foreach ( $postids as $postid ) {
157
  $permalink = gwolle_gb_get_permalink( $postid );
158
+ if ( strlen( $permalink ) === 0 ) {
159
  continue;
160
  }
161
 
162
  $book_id = get_post_meta( $postid, 'gwolle_gb_book_id', true );
163
+ if ( strlen( $book_id ) === 0 ) {
164
  continue;
165
  }
166
 
167
  $books[] = array(
168
  'post_id' => $postid,
169
  'book_id' => $book_id,
170
+ 'permalink' => $permalink,
171
  );
172
  }
173
 
174
  return $books;
175
+
176
  }
177
 
178
 
functions/gb-cache.php CHANGED
@@ -56,15 +56,15 @@ function gwolle_gb_clear_cache( $entry = false ) {
56
 
57
  /* WP Fastest Cache */
58
  if ( class_exists('WpFastestCache') ) {
59
- $WpFastestCache = new WpFastestCache();
60
- if ( method_exists($WpFastestCache, 'deleteCache') ) {
61
- $WpFastestCache->deleteCache();
62
  }
63
  }
64
 
65
  /* WP Super Cache */
66
  if ( function_exists('wp_cache_clear_cache') ) {
67
- $GLOBALS["super_cache_enabled"] = 1;
68
  wp_cache_clear_cache();
69
  }
70
 
56
 
57
  /* WP Fastest Cache */
58
  if ( class_exists('WpFastestCache') ) {
59
+ $wp_fastest_cache = new WpFastestCache();
60
+ if ( method_exists($wp_fastest_cache, 'deleteCache') ) {
61
+ $wp_fastest_cache->deleteCache();
62
  }
63
  }
64
 
65
  /* WP Super Cache */
66
  if ( function_exists('wp_cache_clear_cache') ) {
67
+ $GLOBALS['super_cache_enabled'] = 1;
68
  wp_cache_clear_cache();
69
  }
70
 
functions/gb-class-entry.php CHANGED
@@ -54,20 +54,20 @@ class gwolle_gb_entry {
54
 
55
  public function __construct() {
56
  $this->id = (int) 0;
57
- $this->author_name = (string) "";
58
  $this->author_id = (int) 0;
59
- $this->author_email = (string) "";
60
- $this->author_origin = (string) "";
61
- $this->author_website = (string) "";
62
- $this->author_ip = (string) "";
63
- $this->author_host = (string) "";
64
- $this->content = (string) "";
65
  $this->datetime = (int) current_time( 'timestamp' );
66
  $this->ischecked = (int) 0;
67
  $this->checkedby = (int) 0;
68
  $this->istrash = (int) 0;
69
  $this->isspam = (int) 0;
70
- $this->admin_reply = (string) "";
71
  $this->admin_reply_uid = (int) 0;
72
  $this->book_id = (int) 1;
73
  }
@@ -87,13 +87,13 @@ class gwolle_gb_entry {
87
  global $wpdb;
88
 
89
  $where = " 1 = %d";
90
- $values = Array(1);
91
 
92
- if ( !is_numeric($id) ) {
93
  return false;
94
  }
95
 
96
- if ((int) $id > 0) {
97
  $where .= "
98
  AND
99
  id = %d";
@@ -245,7 +245,7 @@ class gwolle_gb_entry {
245
  $this->get_admin_reply(),
246
  $this->get_admin_reply_uid(),
247
  $this->get_book_id(),
248
- $this->get_id()
249
  );
250
 
251
  $result = $wpdb->query(
@@ -310,7 +310,7 @@ class gwolle_gb_entry {
310
  $this->get_istrash(),
311
  $this->get_admin_reply(),
312
  $this->get_admin_reply_uid(),
313
- $this->get_book_id()
314
  )
315
  ) );
316
 
@@ -363,7 +363,7 @@ class gwolle_gb_entry {
363
 
364
  */
365
 
366
- public function set_data($args) {
367
 
368
  if ( isset( $args['id']) ) {
369
  $this->set_id( $args['id'] );
@@ -385,7 +385,7 @@ class gwolle_gb_entry {
385
  }
386
  if ( isset( $args['author_ip'] ) ) {
387
  $this->set_author_ip( $args['author_ip'] );
388
- } else if ( !$this->get_author_ip() ) {
389
  $this->set_author_ip(); // set as new
390
  }
391
  if ( isset( $args['author_host'] ) ) {
@@ -396,7 +396,7 @@ class gwolle_gb_entry {
396
  }
397
  if ( isset( $args['datetime'] ) ) {
398
  $this->set_datetime( $args['datetime'] );
399
- } else if ( !$this->get_datetime() ) {
400
  $this->set_datetime(); // set as new
401
  }
402
  if ( isset( $args['ischecked'] ) ) {
@@ -424,57 +424,57 @@ class gwolle_gb_entry {
424
  return true;
425
  }
426
 
427
- public function set_id($id) {
428
  $id = (int) $id;
429
  if ($id) {
430
  $this->id = $id;
431
  }
432
  }
433
- public function set_author_name($author_name) {
434
  $author_name = gwolle_gb_sanitize_input($author_name);
435
  if ($author_name) {
436
  $this->author_name = $author_name;
437
  }
438
  }
439
- public function set_author_id($author_id) {
440
  $this->author_id = (int) $author_id;
441
  }
442
- public function set_author_email($author_email) {
443
  $author_email = gwolle_gb_sanitize_input($author_email);
444
  //$author_email = filter_var($author_email, FILTER_VALIDATE_EMAIL);
445
  $this->author_email = $author_email;
446
  }
447
- public function set_author_origin($author_origin) {
448
  $author_origin = gwolle_gb_sanitize_input($author_origin);
449
  $this->author_origin = $author_origin;
450
  }
451
- public function set_author_website($author_website) {
452
  $author_website = gwolle_gb_sanitize_input($author_website);
453
  $pattern = '/^http/';
454
  if ( ! preg_match($pattern, $author_website, $matches) ) {
455
- $author_website = "http://" . $author_website;
456
  }
457
  $author_website = filter_var($author_website, FILTER_VALIDATE_URL);
458
  $this->author_website = $author_website;
459
  }
460
- public function set_author_ip($author_ip = NULL) {
461
  $author_ip = gwolle_gb_sanitize_input($author_ip);
462
  $this->author_ip = $author_ip;
463
  }
464
- public function set_author_host($author_host = NULL) {
465
  $author_host = gwolle_gb_sanitize_input($author_host);
466
  $this->author_host = $author_host;
467
  }
468
- public function set_content($content) {
469
  $content = gwolle_gb_sanitize_input($content, 'content');
470
  if ( strlen($content) > 0 ) {
471
  $this->content = $content;
472
  }
473
  }
474
- public function set_date($date = NULL) {
475
- _deprecated_function( __FUNCTION__, ' 1.4.2', 'set_datetime()' );
476
  }
477
- public function set_datetime($datetime = 0) {
478
  $datetime = (int) $datetime; // timestamp can be cast to int.
479
  if ( ! $datetime ) {
480
  $datetime = current_time( 'timestamp' );
@@ -483,34 +483,34 @@ class gwolle_gb_entry {
483
  $this->datetime = $datetime;
484
  }
485
  }
486
- public function set_ischecked($ischecked) {
487
  // $ischecked means the message has been moderated
488
  $ischecked = (int) $ischecked;
489
  $this->ischecked = $ischecked;
490
  }
491
- public function set_checkedby($checkedby) {
492
  // $checkedby is a userid of the moderator
493
  $checkedby = (int) $checkedby;
494
  if ($checkedby) {
495
  $this->checkedby = $checkedby;
496
  }
497
  }
498
- public function set_istrash($istrash) {
499
  $istrash = (int) $istrash;
500
  $this->istrash = $istrash;
501
  }
502
- public function set_isspam($isspam) {
503
  $isspam = (int) $isspam;
504
  $this->isspam = $isspam;
505
  }
506
- public function set_admin_reply($admin_reply) {
507
  $admin_reply = gwolle_gb_sanitize_input($admin_reply, 'admin_reply');
508
  $this->admin_reply = $admin_reply;
509
  }
510
- public function set_admin_reply_uid($admin_reply_uid) {
511
  $this->admin_reply_uid = (int) $admin_reply_uid;
512
  }
513
- public function set_book_id($book_id) {
514
  $this->book_id = (int) $book_id;
515
  if ( ! $book_id) {
516
  $this->book_id = 1;
@@ -589,7 +589,7 @@ class gwolle_gb_entry {
589
  public function delete() {
590
  global $wpdb;
591
 
592
- if ( $this->get_isspam() == 0 && $this->get_istrash() == 0 ) {
593
  // Do not delete the good stuff.
594
  return false;
595
  }
@@ -605,7 +605,7 @@ class gwolle_gb_entry {
605
  LIMIT 1";
606
 
607
  $values = array(
608
- $id
609
  );
610
 
611
  $result = $wpdb->query(
@@ -613,7 +613,7 @@ class gwolle_gb_entry {
613
  );
614
 
615
 
616
- if ($result == 1) {
617
  // Also remove the log entries and possibly meta fields.
618
  do_action( 'gwolle_gb_delete_entry', $id );
619
 
@@ -622,11 +622,11 @@ class gwolle_gb_entry {
622
  return false;
623
  }
624
 
625
- function check_userids() {
626
  $author_id = $this->get_author_id();
627
  if ( $author_id > 0 ) {
628
  $userdata = get_userdata( $author_id );
629
- if ( !is_object($userdata) ) {
630
  // reset non-existent user because of heavy load in db queries (userid 0 does not get cached).
631
  $this->author_id = 0;
632
  }
@@ -634,11 +634,10 @@ class gwolle_gb_entry {
634
  $checkedby = $this->get_checkedby();
635
  if ( $checkedby > 0 ) {
636
  $userdata = get_userdata( $checkedby );
637
- if ( !is_object($userdata) ) {
638
  // reset non-existent user because of heavy load in db queries (userid 0 does not get cached).
639
  $this->checkedby = 0;
640
  }
641
  }
642
  }
643
-
644
  }
54
 
55
  public function __construct() {
56
  $this->id = (int) 0;
57
+ $this->author_name = (string) '';
58
  $this->author_id = (int) 0;
59
+ $this->author_email = (string) '';
60
+ $this->author_origin = (string) '';
61
+ $this->author_website = (string) '';
62
+ $this->author_ip = (string) '';
63
+ $this->author_host = (string) '';
64
+ $this->content = (string) '';
65
  $this->datetime = (int) current_time( 'timestamp' );
66
  $this->ischecked = (int) 0;
67
  $this->checkedby = (int) 0;
68
  $this->istrash = (int) 0;
69
  $this->isspam = (int) 0;
70
+ $this->admin_reply = (string) '';
71
  $this->admin_reply_uid = (int) 0;
72
  $this->book_id = (int) 1;
73
  }
87
  global $wpdb;
88
 
89
  $where = " 1 = %d";
90
+ $values = array( 1 );
91
 
92
+ if ( ! is_numeric($id) ) {
93
  return false;
94
  }
95
 
96
+ if ( (int) $id > 0 ) {
97
  $where .= "
98
  AND
99
  id = %d";
245
  $this->get_admin_reply(),
246
  $this->get_admin_reply_uid(),
247
  $this->get_book_id(),
248
+ $this->get_id(),
249
  );
250
 
251
  $result = $wpdb->query(
310
  $this->get_istrash(),
311
  $this->get_admin_reply(),
312
  $this->get_admin_reply_uid(),
313
+ $this->get_book_id(),
314
  )
315
  ) );
316
 
363
 
364
  */
365
 
366
+ public function set_data( $args ) {
367
 
368
  if ( isset( $args['id']) ) {
369
  $this->set_id( $args['id'] );
385
  }
386
  if ( isset( $args['author_ip'] ) ) {
387
  $this->set_author_ip( $args['author_ip'] );
388
+ } else if ( ! $this->get_author_ip() ) {
389
  $this->set_author_ip(); // set as new
390
  }
391
  if ( isset( $args['author_host'] ) ) {
396
  }
397
  if ( isset( $args['datetime'] ) ) {
398
  $this->set_datetime( $args['datetime'] );
399
+ } else if ( ! $this->get_datetime() ) {
400
  $this->set_datetime(); // set as new
401
  }
402
  if ( isset( $args['ischecked'] ) ) {
424
  return true;
425
  }
426
 
427
+ public function set_id( $id ) {
428
  $id = (int) $id;
429
  if ($id) {
430
  $this->id = $id;
431
  }
432
  }
433
+ public function set_author_name( $author_name ) {
434
  $author_name = gwolle_gb_sanitize_input($author_name);
435
  if ($author_name) {
436
  $this->author_name = $author_name;
437
  }
438
  }
439
+ public function set_author_id( $author_id ) {
440
  $this->author_id = (int) $author_id;
441
  }
442
+ public function set_author_email( $author_email ) {
443
  $author_email = gwolle_gb_sanitize_input($author_email);
444
  //$author_email = filter_var($author_email, FILTER_VALIDATE_EMAIL);
445
  $this->author_email = $author_email;
446
  }
447
+ public function set_author_origin( $author_origin ) {
448
  $author_origin = gwolle_gb_sanitize_input($author_origin);
449
  $this->author_origin = $author_origin;
450
  }
451
+ public function set_author_website( $author_website ) {
452
  $author_website = gwolle_gb_sanitize_input($author_website);
453
  $pattern = '/^http/';
454
  if ( ! preg_match($pattern, $author_website, $matches) ) {
455
+ $author_website = 'http://' . $author_website;
456
  }
457
  $author_website = filter_var($author_website, FILTER_VALIDATE_URL);
458
  $this->author_website = $author_website;
459
  }
460
+ public function set_author_ip( $author_ip = NULL ) {
461
  $author_ip = gwolle_gb_sanitize_input($author_ip);
462
  $this->author_ip = $author_ip;
463
  }
464
+ public function set_author_host( $author_host = NULL ) {
465
  $author_host = gwolle_gb_sanitize_input($author_host);
466
  $this->author_host = $author_host;
467
  }
468
+ public function set_content( $content ) {
469
  $content = gwolle_gb_sanitize_input($content, 'content');
470
  if ( strlen($content) > 0 ) {
471
  $this->content = $content;
472
  }
473
  }
474
+ public function set_date( $date = NULL ) {
475
+ _deprecated_function( __FUNCTION__, ' 1.4.2', 'set_datetime()' );
476
  }
477
+ public function set_datetime( $datetime = 0 ) {
478
  $datetime = (int) $datetime; // timestamp can be cast to int.
479
  if ( ! $datetime ) {
480
  $datetime = current_time( 'timestamp' );
483
  $this->datetime = $datetime;
484
  }
485
  }
486
+ public function set_ischecked( $ischecked ) {
487
  // $ischecked means the message has been moderated
488
  $ischecked = (int) $ischecked;
489
  $this->ischecked = $ischecked;
490
  }
491
+ public function set_checkedby( $checkedby ) {
492
  // $checkedby is a userid of the moderator
493
  $checkedby = (int) $checkedby;
494
  if ($checkedby) {
495
  $this->checkedby = $checkedby;
496
  }
497
  }
498
+ public function set_istrash( $istrash ) {
499
  $istrash = (int) $istrash;
500
  $this->istrash = $istrash;
501
  }
502
+ public function set_isspam( $isspam ) {
503
  $isspam = (int) $isspam;
504
  $this->isspam = $isspam;
505
  }
506
+ public function set_admin_reply( $admin_reply ) {
507
  $admin_reply = gwolle_gb_sanitize_input($admin_reply, 'admin_reply');
508
  $this->admin_reply = $admin_reply;
509
  }
510
+ public function set_admin_reply_uid( $admin_reply_uid ) {
511
  $this->admin_reply_uid = (int) $admin_reply_uid;
512
  }
513
+ public function set_book_id( $book_id ) {
514
  $this->book_id = (int) $book_id;
515
  if ( ! $book_id) {
516
  $this->book_id = 1;
589
  public function delete() {
590
  global $wpdb;
591
 
592
+ if ( $this->get_isspam() === 0 && $this->get_istrash() === 0 ) {
593
  // Do not delete the good stuff.
594
  return false;
595
  }
605
  LIMIT 1";
606
 
607
  $values = array(
608
+ $id,
609
  );
610
 
611
  $result = $wpdb->query(
613
  );
614
 
615
 
616
+ if ($result === 1) {
617
  // Also remove the log entries and possibly meta fields.
618
  do_action( 'gwolle_gb_delete_entry', $id );
619
 
622
  return false;
623
  }
624
 
625
+ public function check_userids() {
626
  $author_id = $this->get_author_id();
627
  if ( $author_id > 0 ) {
628
  $userdata = get_userdata( $author_id );
629
+ if ( ! is_object($userdata) ) {
630
  // reset non-existent user because of heavy load in db queries (userid 0 does not get cached).
631
  $this->author_id = 0;
632
  }
634
  $checkedby = $this->get_checkedby();
635
  if ( $checkedby > 0 ) {
636
  $userdata = get_userdata( $checkedby );
637
+ if ( ! is_object($userdata) ) {
638
  // reset non-existent user because of heavy load in db queries (userid 0 does not get cached).
639
  $this->checkedby = 0;
640
  }
641
  }
642
  }
 
643
  }
functions/gb-debug.php CHANGED
@@ -15,31 +15,32 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
15
  function gwolle_gb_debug_info() {
16
  global $wp_version, $wp_db_version, $wpdb;
17
 
18
- if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) {
19
  return;
20
  } ?>
21
 
22
  <tr>
23
  <th><?php esc_html_e('WordPress version:', 'gwolle-gb'); ?></th>
24
- <td><?php echo $wp_version . ' (db: ' . $wp_db_version . ')'; ?></td>
 
 
 
 
 
25
  </tr>
26
 
27
  <tr>
28
  <th><?php esc_html_e('WordPress theme:', 'gwolle-gb'); ?></th>
29
- <td><?php
30
- if ( version_compare($wp_version,'3.4', '>=') ) {
31
- echo wp_get_theme()->get('Name');
32
- } else if ( function_exists('get_current_theme') ) {
33
- echo get_current_theme();
34
- } ?>
35
- </td>
36
  </tr>
37
 
38
  <tr>
39
  <th><?php esc_html_e('Active plugins:', 'gwolle-gb'); ?></th>
40
  <td><?php
41
- $active_plugins = get_option('active_plugins');
42
- print_r( $active_plugins ); ?>
 
 
43
  </td>
44
  </tr>
45
 
@@ -47,8 +48,7 @@ function gwolle_gb_debug_info() {
47
  <th><?php esc_html_e('PHP Version:', 'gwolle-gb'); ?></th>
48
  <td><?php
49
  echo PHP_VERSION;
50
- if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
51
- // PHP 5.2 is insecure, urge for an upgrade.
52
  echo '<br />' . esc_html__( 'You have a very old version of PHP. Please contact your hosting provider and request an upgrade.', 'gwolle-gb' );
53
  } ?>
54
  </td>
@@ -124,7 +124,7 @@ function gwolle_gb_debug_info() {
124
  <tr>
125
  <th><?php esc_html_e('MySQL / MySQLi:', 'gwolle-gb'); ?></th>
126
  <td><?php
127
- if ( $wpdb->use_mysqli == true ) {
128
  echo 'mysqli';
129
  } else {
130
  echo 'mysql';
@@ -143,8 +143,9 @@ function gwolle_gb_debug_info() {
143
  $mysql_variables_char[$variable[0]] = $variable[1];
144
  }
145
  }
146
- print_r( $mysql_variables_char );
147
- ?>
 
148
  </td>
149
  </tr>
150
 
@@ -186,7 +187,7 @@ function gwolle_gb_test_add_entry( $emoji = false ) {
186
  'author_name' => 'You',
187
  'author_id' => 0,
188
  'author_email' => 'test@example.com',
189
- 'author_origin' => 'Zwolle',
190
  'author_website' => 'https://example.com',
191
  'author_ip' => '127.0.0.1',
192
  'author_host' => 'example.com',
@@ -198,7 +199,7 @@ function gwolle_gb_test_add_entry( $emoji = false ) {
198
  'isspam' => 0,
199
  'admin_reply' => esc_html__('Just a test', 'gwolle-gb'),
200
  'admin_reply_uid' => 0,
201
- 'book_id' => 1
202
  );
203
  if ( $emoji ) {
204
  $data['content'] = gwolle_gb_maybe_encode_emoji( $content . ' 😄👍👌', 'content' );
@@ -214,4 +215,5 @@ function gwolle_gb_test_add_entry( $emoji = false ) {
214
  }
215
 
216
  return $entry_id;
 
217
  }
15
  function gwolle_gb_debug_info() {
16
  global $wp_version, $wp_db_version, $wpdb;
17
 
18
+ if ( ! current_user_can( 'manage_options' ) ) {
19
  return;
20
  } ?>
21
 
22
  <tr>
23
  <th><?php esc_html_e('WordPress version:', 'gwolle-gb'); ?></th>
24
+ <td><?php
25
+ echo $wp_version . ' (db: ' . $wp_db_version . ')';
26
+ if ( version_compare( $wp_version, '3.7', '<' ) ) {
27
+ echo '<br />' . esc_html__( 'You have a very old version of WordPress that is not receiving security updates anymore. Please upgrade WordPress to a more recent version.', 'gwolle-gb' );
28
+ } ?>
29
+ </td>
30
  </tr>
31
 
32
  <tr>
33
  <th><?php esc_html_e('WordPress theme:', 'gwolle-gb'); ?></th>
34
+ <td><?php echo wp_get_theme()->get('Name'); ?></td>
 
 
 
 
 
 
35
  </tr>
36
 
37
  <tr>
38
  <th><?php esc_html_e('Active plugins:', 'gwolle-gb'); ?></th>
39
  <td><?php
40
+ if ( function_exists( 'print_r' ) ) {
41
+ $active_plugins = get_option('active_plugins');
42
+ print_r( $active_plugins );
43
+ } ?>
44
  </td>
45
  </tr>
46
 
48
  <th><?php esc_html_e('PHP Version:', 'gwolle-gb'); ?></th>
49
  <td><?php
50
  echo PHP_VERSION;
51
+ if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
 
52
  echo '<br />' . esc_html__( 'You have a very old version of PHP. Please contact your hosting provider and request an upgrade.', 'gwolle-gb' );
53
  } ?>
54
  </td>
124
  <tr>
125
  <th><?php esc_html_e('MySQL / MySQLi:', 'gwolle-gb'); ?></th>
126
  <td><?php
127
+ if ( $wpdb->use_mysqli === true ) {
128
  echo 'mysqli';
129
  } else {
130
  echo 'mysql';
143
  $mysql_variables_char[$variable[0]] = $variable[1];
144
  }
145
  }
146
+ if ( function_exists( 'print_r' ) ) {
147
+ print_r( $mysql_variables_char );
148
+ } ?>
149
  </td>
150
  </tr>
151
 
187
  'author_name' => 'You',
188
  'author_id' => 0,
189
  'author_email' => 'test@example.com',
190
+ 'author_origin' => 'Home',
191
  'author_website' => 'https://example.com',
192
  'author_ip' => '127.0.0.1',
193
  'author_host' => 'example.com',
199
  'isspam' => 0,
200
  'admin_reply' => esc_html__('Just a test', 'gwolle-gb'),
201
  'admin_reply_uid' => 0,
202
+ 'book_id' => 1,
203
  );
204
  if ( $emoji ) {
205
  $data['content'] = gwolle_gb_maybe_encode_emoji( $content . ' 😄👍👌', 'content' );
215
  }
216
 
217
  return $entry_id;
218
+
219
  }
functions/gb-fields.php CHANGED
@@ -29,4 +29,5 @@ function gwolle_gb_get_field_name( $field ) {
29
  $field_name = 'gwolle_gb_' . $field_name;
30
 
31
  return $field_name;
 
32
  }
29
  $field_name = 'gwolle_gb_' . $field_name;
30
 
31
  return $field_name;
32
+
33
  }
functions/gb-formatting.php CHANGED
@@ -22,7 +22,7 @@ function gwolle_gb_sanitize_input( $input, $field = '' ) {
22
  $input = str_replace('"', '&#34;', $input);
23
  $input = str_replace("'", '&#39;', $input);
24
  $input = trim($input);
25
- if ( $field == 'content' || $field == 'admin_reply' || $field == 'setting_textarea' ) {
26
  $input = wp_kses( $input, array() ); // Rely on this, not on strip_tags.
27
  } else {
28
  $input = sanitize_text_field( $input );
@@ -39,6 +39,7 @@ function gwolle_gb_sanitize_input( $input, $field = '' ) {
39
  * @return string $input sanitized string
40
  */
41
  function gwolle_gb_sanitize_output( $output, $field = '' ) {
 
42
  $output = (string) $output;
43
  $output = trim($output);
44
  $output = htmlspecialchars_decode($output, ENT_COMPAT);
@@ -47,12 +48,13 @@ function gwolle_gb_sanitize_output( $output, $field = '' ) {
47
  $output = str_replace('\\', '&#92;', $output);
48
  $output = str_replace('"', '&#34;', $output);
49
  $output = str_replace("'", '&#39;', $output);
50
- if ( $field == 'content' || $field == 'admin_reply' || $field == 'setting_textarea' ) {
51
  $output = wp_kses( $output, array() );
52
  } else {
53
  $output = sanitize_text_field( $output );
54
  }
55
  return $output;
 
56
  }
57
 
58
 
@@ -62,12 +64,13 @@ function gwolle_gb_sanitize_output( $output, $field = '' ) {
62
  * @param string $value string to sanitize
63
  * @return string $value sanitized string
64
  */
65
- function gwolle_gb_format_values_for_mail($value) {
 
66
  $value = htmlspecialchars_decode($value, ENT_COMPAT);
67
  $value = str_replace('<', '{', $value);
68
  $value = str_replace('>', '}', $value);
69
- $value = str_replace('&#34;','"', $value);
70
- $value = str_replace('&#034;','"', $value);
71
  $value = str_replace('&#39;', "'", $value);
72
  $value = str_replace('&#039;', "'", $value);
73
  $value = str_replace('&#47;', '/', $value);
@@ -75,6 +78,7 @@ function gwolle_gb_format_values_for_mail($value) {
75
  $value = str_replace('&#92;', '\\', $value);
76
  $value = str_replace('&#092;', '\\', $value);
77
  return $value;
 
78
  }
79
 
80
 
@@ -86,12 +90,14 @@ function gwolle_gb_format_values_for_mail($value) {
86
  * @return $excerpt string the shortened content
87
  */
88
  function gwolle_gb_get_excerpt( $content, $excerpt_length = 20 ) {
 
89
  $excerpt = wp_trim_words( $content, $excerpt_length, '...' );
90
  $excerpt = gwolle_gb_sanitize_output( $excerpt );
91
- if ( trim($excerpt) == '' ) {
92
  $excerpt = '<i class="gb-no-content">' . esc_html__('No content to display. This entry is empty.', 'gwolle-gb') . '</i>';
93
  }
94
  return $excerpt;
 
95
  }
96
 
97
 
@@ -122,3 +128,33 @@ function gwolle_gb_highlight( $text, $words ) {
122
  return $text;
123
 
124
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  $input = str_replace('"', '&#34;', $input);
23
  $input = str_replace("'", '&#39;', $input);
24
  $input = trim($input);
25
+ if ( $field === 'content' || $field === 'admin_reply' || $field === 'setting_textarea' ) {
26
  $input = wp_kses( $input, array() ); // Rely on this, not on strip_tags.
27
  } else {
28
  $input = sanitize_text_field( $input );
39
  * @return string $input sanitized string
40
  */
41
  function gwolle_gb_sanitize_output( $output, $field = '' ) {
42
+
43
  $output = (string) $output;
44
  $output = trim($output);
45
  $output = htmlspecialchars_decode($output, ENT_COMPAT);
48
  $output = str_replace('\\', '&#92;', $output);
49
  $output = str_replace('"', '&#34;', $output);
50
  $output = str_replace("'", '&#39;', $output);
51
+ if ( $field === 'content' || $field === 'admin_reply' || $field === 'setting_textarea' ) {
52
  $output = wp_kses( $output, array() );
53
  } else {
54
  $output = sanitize_text_field( $output );
55
  }
56
  return $output;
57
+
58
  }
59
 
60
 
64
  * @param string $value string to sanitize
65
  * @return string $value sanitized string
66
  */
67
+ function gwolle_gb_format_values_for_mail( $value ) {
68
+
69
  $value = htmlspecialchars_decode($value, ENT_COMPAT);
70
  $value = str_replace('<', '{', $value);
71
  $value = str_replace('>', '}', $value);
72
+ $value = str_replace('&#34;', '"', $value);
73
+ $value = str_replace('&#034;', '"', $value);
74
  $value = str_replace('&#39;', "'", $value);
75
  $value = str_replace('&#039;', "'", $value);
76
  $value = str_replace('&#47;', '/', $value);
78
  $value = str_replace('&#92;', '\\', $value);
79
  $value = str_replace('&#092;', '\\', $value);
80
  return $value;
81
+
82
  }
83
 
84
 
90
  * @return $excerpt string the shortened content
91
  */
92
  function gwolle_gb_get_excerpt( $content, $excerpt_length = 20 ) {
93
+
94
  $excerpt = wp_trim_words( $content, $excerpt_length, '...' );
95
  $excerpt = gwolle_gb_sanitize_output( $excerpt );
96
+ if ( trim($excerpt) === '' ) {
97
  $excerpt = '<i class="gb-no-content">' . esc_html__('No content to display. This entry is empty.', 'gwolle-gb') . '</i>';
98
  }
99
  return $excerpt;
100
+
101
  }
102
 
103
 
128
  return $text;
129
 
130
  }
131
+
132
+
133
+ /*
134
+ * Returns the number of single characters in a string.
135
+ * Will count multibyte characters (like emoji) as one character if mb_strlen or iconv_strlen are available.
136
+ * Expects string to be available in UTF-8.
137
+ * No idea what happens when database doesn't support utf8mb4 but only utf8mb3, it will probably count wrong.
138
+ *
139
+ * @param string $string the string to count the number of characters of.
140
+ *
141
+ * @return int The number of characters.
142
+ *
143
+ * @since 4.2.0
144
+ */
145
+ function gwolle_gb_count_characters( $string ) {
146
+
147
+ $string = (string) $string;
148
+ $string = str_replace( "\r\n", "\n", $string );
149
+
150
+ if ( function_exists( 'mb_strlen' ) ) {
151
+ return mb_strlen( $string, 'UTF-8' );
152
+ }
153
+
154
+ if ( function_exists( 'iconv_strlen' ) ) {
155
+ return iconv_strlen( $string, 'UTF-8' );
156
+ }
157
+
158
+ return strlen( $string );
159
+
160
+ }
functions/gb-get_entries.php CHANGED
@@ -35,44 +35,44 @@ function gwolle_gb_get_entries( $args = array() ) {
35
  global $wpdb;
36
 
37
  $where = " 1 = %d";
38
- $values = Array(1);
39
 
40
  if ( ! is_array( $args ) ) {
41
  return false;
42
  }
43
 
44
  if ( isset($args['checked']) ) {
45
- if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
46
  $where .= "
47
  AND
48
  ischecked = %d";
49
- if ( $args['checked'] == 'checked' ) {
50
  $values[] = 1;
51
- } else if ( $args['checked'] == 'unchecked' ) {
52
  $values[] = 0;
53
  }
54
  }
55
  }
56
  if ( isset($args['spam']) ) {
57
- if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
58
  $where .= "
59
  AND
60
  isspam = %d";
61
- if ( $args['spam'] == 'spam' ) {
62
  $values[] = 1;
63
- } else if ( $args['spam'] == 'nospam' ) {
64
  $values[] = 0;
65
  }
66
  }
67
  }
68
  if ( isset($args['trash']) ) {
69
- if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
70
  $where .= "
71
  AND
72
  istrash = %d";
73
- if ( $args['trash'] == 'trash' ) {
74
  $values[] = 1;
75
- } else if ( $args['trash'] == 'notrash' ) {
76
  $values[] = 0;
77
  }
78
  }
@@ -99,7 +99,7 @@ function gwolle_gb_get_entries( $args = array() ) {
99
  $no_moderators = $args['no_moderators'];
100
  if ( $no_moderators === 'true' ) {
101
  $users = gwolle_gb_get_moderators();
102
- if ( is_array($users) && !empty($users) ) {
103
  foreach ( $users as $user_info ) {
104
  $where .= "
105
  AND
@@ -109,7 +109,7 @@ function gwolle_gb_get_entries( $args = array() ) {
109
  }
110
  }
111
  }
112
- if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
113
  $where .= "
114
  AND
115
  book_id = %d";
@@ -118,7 +118,7 @@ function gwolle_gb_get_entries( $args = array() ) {
118
 
119
  if ( isset( $args['date_query'] ) && is_array( $args['date_query'] ) && ! empty( $args['date_query'] ) ) {
120
  $date_query = $args['date_query'];
121
- if ( isset( $date_query['datetime'] ) && ((int) $date_query['datetime'] > 0 ) ) {
122
  $datetime = $date_query['datetime'];
123
  if ( isset( $date_query['before'] ) && $date_query['before'] === true ) {
124
  $where .= "
@@ -150,7 +150,7 @@ function gwolle_gb_get_entries( $args = array() ) {
150
  $limit = " LIMIT " . $perpage_option; // default
151
  if ( isset($args['num_entries']) && (int) $args['num_entries'] > 0 ) {
152
  $limit = " LIMIT " . (int) $args['num_entries'];
153
- } else if ( isset($args['num_entries']) && (int) $args['num_entries'] == -1 ) {
154
  $limit = ' LIMIT 999999999999999 ';
155
  $offset = ' OFFSET 0 ';
156
  }
@@ -257,6 +257,7 @@ function gwolle_gb_get_entries( $args = array() ) {
257
  return $entries;
258
  }
259
  return false;
 
260
  }
261
 
262
 
@@ -277,48 +278,48 @@ function gwolle_gb_get_entries( $args = array() ) {
277
  *
278
  * @since 2.3.0
279
  */
280
- function gwolle_gb_get_entry_ids($args = array()) {
281
  global $wpdb;
282
 
283
  $where = " 1 = %d";
284
- $values = Array(1);
285
 
286
- if ( !is_array($args) ) {
287
  return false;
288
  }
289
 
290
  if ( isset($args['checked']) ) {
291
- if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
292
  $where .= "
293
  AND
294
  ischecked = %d";
295
- if ( $args['checked'] == 'checked' ) {
296
  $values[] = 1;
297
- } else if ( $args['checked'] == 'unchecked' ) {
298
  $values[] = 0;
299
  }
300
  }
301
  }
302
  if ( isset($args['spam']) ) {
303
- if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
304
  $where .= "
305
  AND
306
  isspam = %d";
307
- if ( $args['spam'] == 'spam' ) {
308
  $values[] = 1;
309
- } else if ( $args['spam'] == 'nospam' ) {
310
  $values[] = 0;
311
  }
312
  }
313
  }
314
  if ( isset($args['trash']) ) {
315
- if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
316
  $where .= "
317
  AND
318
  istrash = %d";
319
- if ( $args['trash'] == 'trash' ) {
320
  $values[] = 1;
321
- } else if ( $args['trash'] == 'notrash' ) {
322
  $values[] = 0;
323
  }
324
  }
@@ -339,7 +340,7 @@ function gwolle_gb_get_entry_ids($args = array()) {
339
  $no_moderators = $args['no_moderators'];
340
  if ( $no_moderators === 'true' ) {
341
  $users = gwolle_gb_get_moderators();
342
- if ( is_array($users) && !empty($users) ) {
343
  foreach ( $users as $user_info ) {
344
  $where .= "
345
  AND
@@ -349,7 +350,7 @@ function gwolle_gb_get_entry_ids($args = array()) {
349
  }
350
  }
351
  }
352
- if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
353
  $where .= "
354
  AND
355
  book_id = %d";
@@ -395,6 +396,7 @@ function gwolle_gb_get_entry_ids($args = array()) {
395
  return $_entry_ids;
396
  }
397
  return false;
 
398
  }
399
 
400
 
@@ -417,11 +419,11 @@ function gwolle_gb_del_entries( $status ) {
417
 
418
  // First get all the id's, so we can remove the logs later
419
 
420
- if ( $status == 'spam' ) {
421
  $where = "
422
  isspam = %d";
423
  $values[] = 1;
424
- } else if ( $status == 'trash' ) {
425
  $where = "
426
  istrash = %d";
427
  $values[] = 1;
@@ -470,6 +472,7 @@ function gwolle_gb_del_entries( $status ) {
470
  }
471
  }
472
  return 0;
 
473
  }
474
 
475
 
@@ -486,55 +489,55 @@ function gwolle_gb_del_entries( $status ) {
486
  *
487
  * @return mixed int with the count of the entries, false if there's an error.
488
  */
489
- function gwolle_gb_get_entry_count($args) {
490
 
491
  global $wpdb;
492
 
493
 
494
  $where = " 1 = %d";
495
- $values = Array(1);
496
 
497
- if ( !is_array($args) ) {
498
  return false;
499
  }
500
 
501
  if ( isset($args['checked']) ) {
502
- if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
503
  $where .= "
504
  AND
505
  ischecked = %d";
506
- if ( $args['checked'] == 'checked' ) {
507
  $values[] = 1;
508
- } else if ( $args['checked'] == 'unchecked' ) {
509
  $values[] = 0;
510
  }
511
  }
512
  }
513
  if ( isset($args['spam']) ) {
514
- if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
515
  $where .= "
516
  AND
517
  isspam = %d";
518
- if ( $args['spam'] == 'spam' ) {
519
  $values[] = 1;
520
- } else if ( $args['spam'] == 'nospam' ) {
521
  $values[] = 0;
522
  }
523
  }
524
  }
525
  if ( isset($args['trash']) ) {
526
- if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
527
  $where .= "
528
  AND
529
  istrash = %d";
530
- if ( $args['trash'] == 'trash' ) {
531
  $values[] = 1;
532
- } else if ( $args['trash'] == 'notrash' ) {
533
  $values[] = 0;
534
  }
535
  }
536
  }
537
- if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
538
  $where .= "
539
  AND
540
  book_id = %d";
35
  global $wpdb;
36
 
37
  $where = " 1 = %d";
38
+ $values = array( 1 );
39
 
40
  if ( ! is_array( $args ) ) {
41
  return false;
42
  }
43
 
44
  if ( isset($args['checked']) ) {
45
+ if ( $args['checked'] === 'checked' || $args['checked'] === 'unchecked' ) {
46
  $where .= "
47
  AND
48
  ischecked = %d";
49
+ if ( $args['checked'] === 'checked' ) {
50
  $values[] = 1;
51
+ } else if ( $args['checked'] === 'unchecked' ) {
52
  $values[] = 0;
53
  }
54
  }
55
  }
56
  if ( isset($args['spam']) ) {
57
+ if ( $args['spam'] === 'spam' || $args['spam'] === 'nospam' ) {
58
  $where .= "
59
  AND
60
  isspam = %d";
61
+ if ( $args['spam'] === 'spam' ) {
62
  $values[] = 1;
63
+ } else if ( $args['spam'] === 'nospam' ) {
64
  $values[] = 0;
65
  }
66
  }
67
  }
68
  if ( isset($args['trash']) ) {
69
+ if ( $args['trash'] === 'trash' || $args['trash'] === 'notrash' ) {
70
  $where .= "
71
  AND
72
  istrash = %d";
73
+ if ( $args['trash'] === 'trash' ) {
74
  $values[] = 1;
75
+ } else if ( $args['trash'] === 'notrash' ) {
76
  $values[] = 0;
77
  }
78
  }
99
  $no_moderators = $args['no_moderators'];
100
  if ( $no_moderators === 'true' ) {
101
  $users = gwolle_gb_get_moderators();
102
+ if ( is_array($users) && ! empty($users) ) {
103
  foreach ( $users as $user_info ) {
104
  $where .= "
105
  AND
109
  }
110
  }
111
  }
112
+ if ( isset( $args['book_id'] ) && ( (int) $args['book_id'] ) > 0 ) {
113
  $where .= "
114
  AND
115
  book_id = %d";
118
 
119
  if ( isset( $args['date_query'] ) && is_array( $args['date_query'] ) && ! empty( $args['date_query'] ) ) {
120
  $date_query = $args['date_query'];
121
+ if ( isset( $date_query['datetime'] ) && ( (int) $date_query['datetime'] > 0 ) ) {
122
  $datetime = $date_query['datetime'];
123
  if ( isset( $date_query['before'] ) && $date_query['before'] === true ) {
124
  $where .= "
150
  $limit = " LIMIT " . $perpage_option; // default
151
  if ( isset($args['num_entries']) && (int) $args['num_entries'] > 0 ) {
152
  $limit = " LIMIT " . (int) $args['num_entries'];
153
+ } else if ( isset($args['num_entries']) && (int) $args['num_entries'] === -1 ) {
154
  $limit = ' LIMIT 999999999999999 ';
155
  $offset = ' OFFSET 0 ';
156
  }
257
  return $entries;
258
  }
259
  return false;
260
+
261
  }
262
 
263
 
278
  *
279
  * @since 2.3.0
280
  */
281
+ function gwolle_gb_get_entry_ids( $args = array() ) {
282
  global $wpdb;
283
 
284
  $where = " 1 = %d";
285
+ $values = array( 1 );
286
 
287
+ if ( ! is_array($args) ) {
288
  return false;
289
  }
290
 
291
  if ( isset($args['checked']) ) {
292
+ if ( $args['checked'] === 'checked' || $args['checked'] === 'unchecked' ) {
293
  $where .= "
294
  AND
295
  ischecked = %d";
296
+ if ( $args['checked'] === 'checked' ) {
297
  $values[] = 1;
298
+ } else if ( $args['checked'] === 'unchecked' ) {
299
  $values[] = 0;
300
  }
301
  }
302
  }
303
  if ( isset($args['spam']) ) {
304
+ if ( $args['spam'] === 'spam' || $args['spam'] === 'nospam' ) {
305
  $where .= "
306
  AND
307
  isspam = %d";
308
+ if ( $args['spam'] === 'spam' ) {
309
  $values[] = 1;
310
+ } else if ( $args['spam'] === 'nospam' ) {
311
  $values[] = 0;
312
  }
313
  }
314
  }
315
  if ( isset($args['trash']) ) {
316
+ if ( $args['trash'] === 'trash' || $args['trash'] === 'notrash' ) {
317
  $where .= "
318
  AND
319
  istrash = %d";
320
+ if ( $args['trash'] === 'trash' ) {
321
  $values[] = 1;
322
+ } else if ( $args['trash'] === 'notrash' ) {
323
  $values[] = 0;
324
  }
325
  }
340
  $no_moderators = $args['no_moderators'];
341
  if ( $no_moderators === 'true' ) {
342
  $users = gwolle_gb_get_moderators();
343
+ if ( is_array($users) && ! empty($users) ) {
344
  foreach ( $users as $user_info ) {
345
  $where .= "
346
  AND
350
  }
351
  }
352
  }
353
+ if ( isset( $args['book_id'] ) && ( (int) $args['book_id'] ) > 0 ) {
354
  $where .= "
355
  AND
356
  book_id = %d";
396
  return $_entry_ids;
397
  }
398
  return false;
399
+
400
  }
401
 
402
 
419
 
420
  // First get all the id's, so we can remove the logs later
421
 
422
+ if ( $status === 'spam' ) {
423
  $where = "
424
  isspam = %d";
425
  $values[] = 1;
426
+ } else if ( $status === 'trash' ) {
427
  $where = "
428
  istrash = %d";
429
  $values[] = 1;
472
  }
473
  }
474
  return 0;
475
+
476
  }
477
 
478
 
489
  *
490
  * @return mixed int with the count of the entries, false if there's an error.
491
  */
492
+ function gwolle_gb_get_entry_count( $args ) {
493
 
494
  global $wpdb;
495
 
496
 
497
  $where = " 1 = %d";
498
+ $values = array( 1 );
499
 
500
+ if ( ! is_array($args) ) {
501
  return false;
502
  }
503
 
504
  if ( isset($args['checked']) ) {
505
+ if ( $args['checked'] === 'checked' || $args['checked'] === 'unchecked' ) {
506
  $where .= "
507
  AND
508
  ischecked = %d";
509
+ if ( $args['checked'] === 'checked' ) {
510
  $values[] = 1;
511
+ } else if ( $args['checked'] === 'unchecked' ) {
512
  $values[] = 0;
513
  }
514
  }
515
  }
516
  if ( isset($args['spam']) ) {
517
+ if ( $args['spam'] === 'spam' || $args['spam'] === 'nospam' ) {
518
  $where .= "
519
  AND
520
  isspam = %d";
521
+ if ( $args['spam'] === 'spam' ) {
522
  $values[] = 1;
523
+ } else if ( $args['spam'] === 'nospam' ) {
524
  $values[] = 0;
525
  }
526
  }
527
  }
528
  if ( isset($args['trash']) ) {
529
+ if ( $args['trash'] === 'trash' || $args['trash'] === 'notrash' ) {
530
  $where .= "
531
  AND
532
  istrash = %d";
533
+ if ( $args['trash'] === 'trash' ) {
534
  $values[] = 1;
535
+ } else if ( $args['trash'] === 'notrash' ) {
536
  $values[] = 0;
537
  }
538
  }
539
  }
540
+ if ( isset( $args['book_id'] ) && ( (int) $args['book_id'] ) > 0 ) {
541
  $where .= "
542
  AND
543
  book_id = %d";
functions/gb-get_entries_from_search.php CHANGED
@@ -24,7 +24,7 @@ function gwolle_gb_get_entries_from_search( $args = array() ) {
24
  global $wpdb;
25
 
26
  $where = " 1 = %d";
27
- $values = Array(1);
28
 
29
  if ( ! is_array( $args ) ) {
30
  return false;
@@ -45,7 +45,7 @@ function gwolle_gb_get_entries_from_search( $args = array() ) {
45
  istrash = %d";
46
  $values[] = 0;
47
 
48
- if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
49
  $where .= "
50
  AND
51
  book_id = %d";
@@ -83,7 +83,7 @@ function gwolle_gb_get_entries_from_search( $args = array() ) {
83
  $limit = " LIMIT " . $perpage_option; // default
84
  if ( isset($args['num_entries']) && (int) $args['num_entries'] > 0 ) {
85
  $limit = " LIMIT " . (int) $args['num_entries'];
86
- } else if ( isset($args['num_entries']) && (int) $args['num_entries'] == -1 ) {
87
  $limit = ' LIMIT 999999999999999 ';
88
  $offset = ' OFFSET 0 ';
89
  }
@@ -161,6 +161,7 @@ function gwolle_gb_get_entries_from_search( $args = array() ) {
161
  return $entries;
162
  }
163
  return false;
 
164
  }
165
 
166
 
@@ -233,49 +234,49 @@ function gwolle_gb_get_entry_count_from_search( $args ) {
233
  }
234
 
235
  $where = " 1 = %d";
236
- $values = Array(1);
237
 
238
  if ( ! is_array($args) ) {
239
  return false;
240
  }
241
 
242
  if ( isset($args['checked']) ) {
243
- if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
244
  $where .= "
245
  AND
246
  ischecked = %d";
247
- if ( $args['checked'] == 'checked' ) {
248
  $values[] = 1;
249
- } else if ( $args['checked'] == 'unchecked' ) {
250
  $values[] = 0;
251
  }
252
  }
253
  }
254
  if ( isset($args['spam']) ) {
255
- if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
256
  $where .= "
257
  AND
258
  isspam = %d";
259
- if ( $args['spam'] == 'spam' ) {
260
  $values[] = 1;
261
- } else if ( $args['spam'] == 'nospam' ) {
262
  $values[] = 0;
263
  }
264
  }
265
  }
266
  if ( isset($args['trash']) ) {
267
- if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
268
  $where .= "
269
  AND
270
  istrash = %d";
271
- if ( $args['trash'] == 'trash' ) {
272
  $values[] = 1;
273
- } else if ( $args['trash'] == 'notrash' ) {
274
  $values[] = 0;
275
  }
276
  }
277
  }
278
- if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
279
  $where .= "
280
  AND
281
  book_id = %d";
@@ -284,8 +285,8 @@ function gwolle_gb_get_entry_count_from_search( $args ) {
284
 
285
  $search_query = gwolle_gb_is_search();
286
  $tablename = $wpdb->prefix . "gwolle_gb_entries";
287
- foreach ( $search_query as $term ) {
288
- $like = '%' . $wpdb->esc_like( $term ) . '%';
289
  $where .= $wpdb->prepare( "
290
  AND (
291
  ($tablename . author_name LIKE %s)
24
  global $wpdb;
25
 
26
  $where = " 1 = %d";
27
+ $values = array( 1 );
28
 
29
  if ( ! is_array( $args ) ) {
30
  return false;
45
  istrash = %d";
46
  $values[] = 0;
47
 
48
+ if ( isset( $args['book_id'] ) && ( (int) $args['book_id'] ) > 0 ) {
49
  $where .= "
50
  AND
51
  book_id = %d";
83
  $limit = " LIMIT " . $perpage_option; // default
84
  if ( isset($args['num_entries']) && (int) $args['num_entries'] > 0 ) {
85
  $limit = " LIMIT " . (int) $args['num_entries'];
86
+ } else if ( isset($args['num_entries']) && (int) $args['num_entries'] === -1 ) {
87
  $limit = ' LIMIT 999999999999999 ';
88
  $offset = ' OFFSET 0 ';
89
  }
161
  return $entries;
162
  }
163
  return false;
164
+
165
  }
166
 
167
 
234
  }
235
 
236
  $where = " 1 = %d";
237
+ $values = array( 1 );
238
 
239
  if ( ! is_array($args) ) {
240
  return false;
241
  }
242
 
243
  if ( isset($args['checked']) ) {
244
+ if ( $args['checked'] === 'checked' || $args['checked'] === 'unchecked' ) {
245
  $where .= "
246
  AND
247
  ischecked = %d";
248
+ if ( $args['checked'] === 'checked' ) {
249
  $values[] = 1;
250
+ } else if ( $args['checked'] === 'unchecked' ) {
251
  $values[] = 0;
252
  }
253
  }
254
  }
255
  if ( isset($args['spam']) ) {
256
+ if ( $args['spam'] === 'spam' || $args['spam'] === 'nospam' ) {
257
  $where .= "
258
  AND
259
  isspam = %d";
260
+ if ( $args['spam'] === 'spam' ) {
261
  $values[] = 1;
262
+ } else if ( $args['spam'] === 'nospam' ) {
263
  $values[] = 0;
264
  }
265
  }
266
  }
267
  if ( isset($args['trash']) ) {
268
+ if ( $args['trash'] === 'trash' || $args['trash'] === 'notrash' ) {
269
  $where .= "
270
  AND
271
  istrash = %d";
272
+ if ( $args['trash'] === 'trash' ) {
273
  $values[] = 1;
274
+ } else if ( $args['trash'] === 'notrash' ) {
275
  $values[] = 0;
276
  }
277
  }
278
  }
279
+ if ( isset( $args['book_id'] ) && ( (int) $args['book_id'] ) > 0 ) {
280
  $where .= "
281
  AND
282
  book_id = %d";
285
 
286
  $search_query = gwolle_gb_is_search();
287
  $tablename = $wpdb->prefix . "gwolle_gb_entries";
288
+ foreach ( $search_query as $search_term ) {
289
+ $like = '%' . $wpdb->esc_like( $search_term ) . '%';
290
  $where .= $wpdb->prepare( "
291
  AND (
292
  ($tablename . author_name LIKE %s)
functions/gb-log.php CHANGED
@@ -44,7 +44,7 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
44
  'admin-reply-updated',
45
  'admin-reply-removed',
46
  'entry-anonymized',
47
- 'privacy-policy-accepted'
48
  );
49
  if ( ! in_array( $subject, $log_messages ) ) {
50
  return false;
@@ -69,14 +69,15 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
69
  addslashes( $subject ),
70
  (int) $entry_id,
71
  (int) get_current_user_id(),
72
- current_time( 'timestamp' )
73
  )
74
  ) );
75
 
76
- if ($result == 1) {
77
  return true;
78
  }
79
  return false;
 
80
  }
81
 
82
 
@@ -105,9 +106,9 @@ function gwolle_gb_get_log_entries( $entry_id ) {
105
 
106
  // Message to strings
107
  $log_messages = array(
108
- 'entry-unchecked' => /* translators: Log message */ esc_html__('Entry has been locked.', 'gwolle-gb'),
109
- 'entry-checked' => /* translators: Log message */ esc_html__('Entry has been checked.', 'gwolle-gb'),
110
- 'marked-as-spam' => /* translators: Log message */ esc_html__('Entry marked as spam.', 'gwolle-gb'),
111
  'marked-as-not-spam' => /* translators: Log message */ esc_html__('Entry marked as not spam.', 'gwolle-gb'),
112
  'marked-by-honeypot' => /* translators: Log message */ esc_html__('Entry marked by the Honeypot.', 'gwolle-gb'),
113
  'marked-by-nonce' => /* translators: Log message */ esc_html__('Entry marked by invalid Nonce.', 'gwolle-gb'),
@@ -116,18 +117,18 @@ function gwolle_gb_get_log_entries( $entry_id ) {
116
  'marked-by-longtext' => /* translators: Log message */ esc_html__('Entry marked for too long text.', 'gwolle-gb'),
117
  'marked-by-linkchecker' => /* translators: Log message */ esc_html__('Entry marked for too many links.', 'gwolle-gb'),
118
  'marked-by-timeout' => /* translators: Log message */ esc_html__('Entry marked for being submitted too fast.', 'gwolle-gb'),
119
- 'entry-edited' => /* translators: Log message */ esc_html__('Entry has been edited.', 'gwolle-gb'),
120
  'imported-from-dmsguestbook' => /* translators: Log message */ esc_html__('Imported from DMSGuestbook', 'gwolle-gb'),
121
  'imported-from-wp' => /* translators: Log message */ esc_html__('Imported from WordPress comments', 'gwolle-gb'),
122
  'imported-from-gwolle' => /* translators: Log message */ esc_html__('Imported from Gwolle-GB', 'gwolle-gb'),
123
  'exported-to-csv' => /* translators: Log message */ esc_html__('Exported to CSV file', 'gwolle-gb'),
124
- 'entry-trashed' => /* translators: Log message */ esc_html__('Entry has been trashed.', 'gwolle-gb'),
125
  'entry-untrashed' => /* translators: Log message */ esc_html__('Entry has been untrashed.', 'gwolle-gb'),
126
  'admin-reply-added' => /* translators: Log message */ esc_html__('Admin reply has been added.', 'gwolle-gb'),
127
  'admin-reply-updated' => /* translators: Log message */ esc_html__('Admin reply has been updated.', 'gwolle-gb'),
128
  'admin-reply-removed' => /* translators: Log message */ esc_html__('Admin reply has been removed.', 'gwolle-gb'),
129
  'entry-anonymized' => /* translators: Log message */ esc_html__('Entry has been anonymized.', 'gwolle-gb'),
130
- 'privacy-policy-accepted' => /* translators: Log message */ esc_html__('Privacy Policy was accepted.', 'gwolle-gb')
131
  );
132
 
133
  $where = " 1 = %d";
@@ -162,7 +163,7 @@ function gwolle_gb_get_log_entries( $entry_id ) {
162
  //$wpdb->print_error();
163
  //echo "number of rows: " . $wpdb->num_rows;
164
 
165
- if ( is_array($entries) && !empty($entries) ) {
166
 
167
  // Array to store the log entries
168
  $log_entries = array();
@@ -173,14 +174,20 @@ function gwolle_gb_get_log_entries( $entry_id ) {
173
  'subject' => stripslashes($entry['subject']),
174
  'entry_id' => (int) $entry['entry_id'],
175
  'author_id' => (int) $entry['author_id'],
176
- 'datetime' => (int) $entry['datetime']
177
  );
178
 
179
- $log_entry['msg'] = (isset($log_messages[$log_entry['subject']])) ? $log_messages[$log_entry['subject']] : $log_entry['subject'];
 
 
 
 
 
 
180
 
181
  // Get author's display name or login name if not already done.
182
  $userdata = get_userdata( $log_entry['author_id'] );
183
- if (is_object($userdata)) {
184
  if ( isset( $userdata->display_name ) ) {
185
  $log_entry['author_login'] = $userdata->display_name;
186
  } else {
@@ -191,22 +198,22 @@ function gwolle_gb_get_log_entries( $entry_id ) {
191
  }
192
 
193
  // Construct the message in HTML
194
- $log_entry['msg_html'] = date_i18n( get_option('date_format'), $log_entry['datetime']) . ", ";
195
  $log_entry['msg_html'] .= date_i18n( get_option('time_format'), $log_entry['datetime']);
196
  $log_entry['msg_html'] .= ': ' . $log_entry['msg'];
197
 
198
- if ( $log_entry['author_id'] == get_current_user_id() && $log_entry['author_id'] != 0 ) {
199
  $log_entry['msg_html'] .= ' <i>(<strong>' . esc_html__('You', 'gwolle-gb') . '</strong>)</i>';
200
  } else {
201
  $log_entry['msg_html'] .= ' <i>(' . $log_entry['author_login'] . ')</i>';
202
  }
203
 
204
  // Construct the message in plain text
205
- $log_entry['msg_txt'] = date_i18n( get_option('date_format'), $log_entry['datetime']) . ", ";
206
  $log_entry['msg_txt'] .= date_i18n( get_option('time_format'), $log_entry['datetime']);
207
  $log_entry['msg_txt'] .= ': ' . $log_entry['msg'];
208
 
209
- if ( $log_entry['author_id'] == get_current_user_id() && $log_entry['author_id'] != 0 ) {
210
  $log_entry['msg_txt'] .= ' (' . esc_html__('You', 'gwolle-gb') . ')';
211
  } else {
212
  $log_entry['msg_txt'] .= ' (' . $log_entry['author_login'] . ')';
@@ -217,6 +224,7 @@ function gwolle_gb_get_log_entries( $entry_id ) {
217
  return $log_entries;
218
  }
219
  return false;
 
220
  }
221
 
222
 
@@ -229,9 +237,9 @@ function gwolle_gb_get_log_entries( $entry_id ) {
229
  function gwolle_gb_del_log_entries( $entry_id ) {
230
  global $wpdb;
231
 
232
- $entry_id = (int) $entry_id ;
233
 
234
- if ( $entry_id == 0 || $entry_id < 0 ) {
235
  return false;
236
  }
237
 
@@ -243,7 +251,7 @@ function gwolle_gb_del_log_entries( $entry_id ) {
243
  entry_id = %d";
244
 
245
  $values = array(
246
- $entry_id
247
  );
248
 
249
  $result = $wpdb->query(
@@ -255,5 +263,6 @@ function gwolle_gb_del_log_entries( $entry_id ) {
255
  return true;
256
  }
257
  return false;
 
258
  }
259
  add_action( 'gwolle_gb_delete_entry', 'gwolle_gb_del_log_entries' );
44
  'admin-reply-updated',
45
  'admin-reply-removed',
46
  'entry-anonymized',
47
+ 'privacy-policy-accepted',
48
  );
49
  if ( ! in_array( $subject, $log_messages ) ) {
50
  return false;
69
  addslashes( $subject ),
70
  (int) $entry_id,
71
  (int) get_current_user_id(),
72
+ current_time( 'timestamp' ),
73
  )
74
  ) );
75
 
76
+ if ( $result === 1 ) {
77
  return true;
78
  }
79
  return false;
80
+
81
  }
82
 
83
 
106
 
107
  // Message to strings
108
  $log_messages = array(
109
+ 'entry-unchecked' => /* translators: Log message */ esc_html__('Entry has been locked.', 'gwolle-gb'),
110
+ 'entry-checked' => /* translators: Log message */ esc_html__('Entry has been checked.', 'gwolle-gb'),
111
+ 'marked-as-spam' => /* translators: Log message */ esc_html__('Entry marked as spam.', 'gwolle-gb'),
112
  'marked-as-not-spam' => /* translators: Log message */ esc_html__('Entry marked as not spam.', 'gwolle-gb'),
113
  'marked-by-honeypot' => /* translators: Log message */ esc_html__('Entry marked by the Honeypot.', 'gwolle-gb'),
114
  'marked-by-nonce' => /* translators: Log message */ esc_html__('Entry marked by invalid Nonce.', 'gwolle-gb'),
117
  'marked-by-longtext' => /* translators: Log message */ esc_html__('Entry marked for too long text.', 'gwolle-gb'),
118
  'marked-by-linkchecker' => /* translators: Log message */ esc_html__('Entry marked for too many links.', 'gwolle-gb'),
119
  'marked-by-timeout' => /* translators: Log message */ esc_html__('Entry marked for being submitted too fast.', 'gwolle-gb'),
120
+ 'entry-edited' => /* translators: Log message */ esc_html__('Entry has been edited.', 'gwolle-gb'),
121
  'imported-from-dmsguestbook' => /* translators: Log message */ esc_html__('Imported from DMSGuestbook', 'gwolle-gb'),
122
  'imported-from-wp' => /* translators: Log message */ esc_html__('Imported from WordPress comments', 'gwolle-gb'),
123
  'imported-from-gwolle' => /* translators: Log message */ esc_html__('Imported from Gwolle-GB', 'gwolle-gb'),
124
  'exported-to-csv' => /* translators: Log message */ esc_html__('Exported to CSV file', 'gwolle-gb'),
125
+ 'entry-trashed' => /* translators: Log message */ esc_html__('Entry has been trashed.', 'gwolle-gb'),
126
  'entry-untrashed' => /* translators: Log message */ esc_html__('Entry has been untrashed.', 'gwolle-gb'),
127
  'admin-reply-added' => /* translators: Log message */ esc_html__('Admin reply has been added.', 'gwolle-gb'),
128
  'admin-reply-updated' => /* translators: Log message */ esc_html__('Admin reply has been updated.', 'gwolle-gb'),
129
  'admin-reply-removed' => /* translators: Log message */ esc_html__('Admin reply has been removed.', 'gwolle-gb'),
130
  'entry-anonymized' => /* translators: Log message */ esc_html__('Entry has been anonymized.', 'gwolle-gb'),
131
+ 'privacy-policy-accepted' => /* translators: Log message */ esc_html__('Privacy Policy was accepted.', 'gwolle-gb'),
132
  );
133
 
134
  $where = " 1 = %d";
163
  //$wpdb->print_error();
164
  //echo "number of rows: " . $wpdb->num_rows;
165
 
166
+ if ( is_array($entries) && ! empty($entries) ) {
167
 
168
  // Array to store the log entries
169
  $log_entries = array();
174
  'subject' => stripslashes($entry['subject']),
175
  'entry_id' => (int) $entry['entry_id'],
176
  'author_id' => (int) $entry['author_id'],
177
+ 'datetime' => (int) $entry['datetime'],
178
  );
179
 
180
+ $log_entry_subject = $log_entry['subject'];
181
+ if ( isset($log_messages["$log_entry_subject"]) ) {
182
+ // Use translation if it exists.
183
+ $log_entry['msg'] = $log_messages["$log_entry_subject"];
184
+ } else {
185
+ $log_entry['msg'] = $log_entry['subject'];
186
+ }
187
 
188
  // Get author's display name or login name if not already done.
189
  $userdata = get_userdata( $log_entry['author_id'] );
190
+ if ( is_object($userdata) ) {
191
  if ( isset( $userdata->display_name ) ) {
192
  $log_entry['author_login'] = $userdata->display_name;
193
  } else {
198
  }
199
 
200
  // Construct the message in HTML
201
+ $log_entry['msg_html'] = date_i18n( get_option('date_format'), $log_entry['datetime']) . ', ';
202
  $log_entry['msg_html'] .= date_i18n( get_option('time_format'), $log_entry['datetime']);
203
  $log_entry['msg_html'] .= ': ' . $log_entry['msg'];
204
 
205
+ if ( $log_entry['author_id'] === get_current_user_id() && $log_entry['author_id'] !== 0 ) {
206
  $log_entry['msg_html'] .= ' <i>(<strong>' . esc_html__('You', 'gwolle-gb') . '</strong>)</i>';
207
  } else {
208
  $log_entry['msg_html'] .= ' <i>(' . $log_entry['author_login'] . ')</i>';
209
  }
210
 
211
  // Construct the message in plain text
212
+ $log_entry['msg_txt'] = date_i18n( get_option('date_format'), $log_entry['datetime']) . ', ';
213
  $log_entry['msg_txt'] .= date_i18n( get_option('time_format'), $log_entry['datetime']);
214
  $log_entry['msg_txt'] .= ': ' . $log_entry['msg'];
215
 
216
+ if ( $log_entry['author_id'] === get_current_user_id() && $log_entry['author_id'] !== 0 ) {
217
  $log_entry['msg_txt'] .= ' (' . esc_html__('You', 'gwolle-gb') . ')';
218
  } else {
219
  $log_entry['msg_txt'] .= ' (' . $log_entry['author_login'] . ')';
224
  return $log_entries;
225
  }
226
  return false;
227
+
228
  }
229
 
230
 
237
  function gwolle_gb_del_log_entries( $entry_id ) {
238
  global $wpdb;
239
 
240
+ $entry_id = (int) $entry_id;
241
 
242
+ if ( $entry_id === 0 || $entry_id < 0 ) {
243
  return false;
244
  }
245
 
251
  entry_id = %d";
252
 
253
  $values = array(
254
+ $entry_id,
255
  );
256
 
257
  $result = $wpdb->query(
263
  return true;
264
  }
265
  return false;
266
+
267
  }
268
  add_action( 'gwolle_gb_delete_entry', 'gwolle_gb_del_log_entries' );
functions/gb-mail.php CHANGED
@@ -20,10 +20,10 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
20
  function gwolle_gb_mail_moderators( $entry ) {
21
  $isspam = $entry->get_isspam();
22
  if ( ! $isspam ) {
23
- $subscribers = Array();
24
  $recipients = get_option('gwolle_gb-notifyByMail');
25
  if ( is_string( $recipients ) && strlen($recipients) > 0 ) {
26
- $recipients = explode( ",", $recipients );
27
  }
28
  if ( is_array( $recipients ) && count( $recipients ) > 0 ) {
29
  foreach ( $recipients as $recipient ) {
@@ -37,13 +37,13 @@ function gwolle_gb_mail_moderators( $entry ) {
37
  }
38
 
39
  // Set the Mail Content
40
- $mailTags = array( 'user_email', 'user_name', 'status', 'entry_management_url', 'blog_name', 'blog_url', 'wp_admin_url', 'entry_content', 'author_ip', 'author_origin' );
41
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-adminMailContent', false ), 'setting_textarea' );
42
  if ( ! $mail_body) {
43
  $mail_body = esc_html__("
44
  Hello,
45
 
46
- There is a new guestbook entry at '%blog_name%'.
47
  You can check it at %entry_management_url%.
48
 
49
  Have a nice day.
@@ -56,8 +56,7 @@ User email: %user_email%
56
  Entry status: %status%
57
  Entry content:
58
  %entry_content%
59
- "
60
- , 'gwolle-gb');
61
  }
62
  $mail_body = apply_filters( 'gwolle_gb_mail_moderators_body', $mail_body, $entry );
63
 
@@ -67,7 +66,7 @@ Entry content:
67
 
68
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail.
69
  if ( get_option('gwolle_gb-mail-from', false) ) {
70
- $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . get_option('gwolle_gb-mail-from') . ">\r\n";
71
  }
72
  $author_email = $entry->get_author_email();
73
  if ( $author_email ) {
@@ -105,15 +104,17 @@ Entry content:
105
  }
106
 
107
  // The last tags are bloginfo-based
108
- for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
109
- $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
110
- $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
 
111
  }
 
112
 
113
  // Add logging to mail
114
  $log_entries = gwolle_gb_get_log_entries( $entry->get_id() );
115
  if ( is_array($log_entries) && ! empty($log_entries) ) {
116
- $mail_body .= "\r\n" . esc_html__('Log messages:', 'gwolle-gb') . "\r\n";
117
  if ($entry->get_datetime() > 0) {
118
  $mail_body .= date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
119
  $mail_body .= date_i18n( get_option('time_format'), $entry->get_datetime() );
@@ -124,7 +125,7 @@ Entry content:
124
  }
125
  }
126
 
127
- if ( is_array($subscribers) && !empty($subscribers) ) {
128
  foreach ( $subscribers as $subscriber ) {
129
  wp_mail($subscriber, $subject, $mail_body, $header);
130
  }
@@ -143,17 +144,17 @@ add_action( 'gwolle_gb_save_entry_frontend', 'gwolle_gb_mail_moderators' );
143
  */
144
  function gwolle_gb_mail_author( $entry ) {
145
  $isspam = $entry->get_isspam();
146
- if ( !$isspam ) {
147
- if ( get_option( 'gwolle_gb-mail_author', 'false' ) == 'true' ) {
148
 
149
  // Set the Mail Content
150
- $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content');
151
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-authorMailContent', false ), 'setting_textarea' );
152
  if ( ! $mail_body) {
153
  $mail_body = esc_html__("
154
  Hello,
155
 
156
- You have just posted a new guestbook entry at '%blog_name%'.
157
 
158
  Have a nice day.
159
  The editors at %blog_name%.
@@ -164,8 +165,7 @@ User name: %user_name%
164
  User email: %user_email%
165
  Entry content:
166
  %entry_content%
167
- "
168
- , 'gwolle-gb');
169
  }
170
  $mail_body = apply_filters( 'gwolle_gb_mail_author_body', $mail_body, $entry );
171
 
@@ -175,7 +175,7 @@ Entry content:
175
 
176
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail
177
  if ( get_option('gwolle_gb-mail-from', false) ) {
178
- $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) . ">\r\n";
179
  }
180
 
181
  // Replace the tags from the mailtemplate with real data from the website and entry
@@ -195,10 +195,12 @@ Entry content:
195
  $info['blog_url'] = get_bloginfo('wpurl');
196
  }
197
  $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_content(), 'content' ));
198
- for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
199
- $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
200
- $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
 
201
  }
 
202
 
203
  wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
204
 
@@ -217,20 +219,20 @@ add_action( 'gwolle_gb_save_entry_frontend', 'gwolle_gb_mail_author' );
217
  */
218
  function gwolle_gb_mail_author_on_moderation( $entry ) {
219
 
220
- if (get_option( 'gwolle_gb-mail_author_moderation', 'false') != 'true') {
221
  return;
222
  }
223
 
224
- if ( $entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
225
 
226
  // Set the Mail Content
227
- $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content', 'date');
228
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-authormoderationcontent', false ), 'setting_textarea' );
229
  if ( ! $mail_body) {
230
  $mail_body = esc_html__("
231
  Hello,
232
 
233
- An admin has just moderated your guestbook entry at '%blog_name%'.
234
 
235
  Have a nice day.
236
  The editors at %blog_name%.
@@ -241,8 +243,7 @@ Website address: %blog_url%
241
 
242
  Original entry posted on %date%:
243
  %entry_content%
244
- "
245
- , 'gwolle-gb');
246
  }
247
  $mail_body = apply_filters( 'gwolle_gb_mail_author_on_moderation_body', $mail_body, $entry );
248
 
@@ -252,7 +253,7 @@ Original entry posted on %date%:
252
 
253
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail
254
  if ( get_option('gwolle_gb-mail-from', false) ) {
255
- $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) . ">\r\n";
256
  }
257
 
258
  // Replace the tags from the mailtemplate with real data from the website and entry
@@ -273,10 +274,12 @@ Original entry posted on %date%:
273
  }
274
  $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_content(), 'content' ));
275
  $info['date'] = date_i18n( get_option('date_format'), $entry->get_datetime() );
276
- for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
277
- $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
278
- $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
 
279
  }
 
280
 
281
  wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
282
 
@@ -296,13 +299,13 @@ function gwolle_gb_mail_author_on_admin_reply( $entry ) {
296
  if ( ! $isspam ) {
297
 
298
  // Set the Mail Content
299
- $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'admin_reply', 'entry_content', 'date');
300
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-mail_admin_replyContent', false ), 'setting_textarea' );
301
  if ( ! $mail_body) {
302
  $mail_body = esc_html__("
303
  Hello,
304
 
305
- An admin has just added or changed a reply message to your guestbook entry at '%blog_name%'.
306
 
307
  Have a nice day.
308
  The editors at %blog_name%.
@@ -315,8 +318,7 @@ Admin Reply:
315
 
316
  Original entry posted on %date%:
317
  %entry_content%
318
- "
319
- , 'gwolle-gb');
320
  }
321
  $mail_body = apply_filters( 'gwolle_gb_mail_author_on_admin_reply_body', $mail_body, $entry );
322
 
@@ -326,7 +328,7 @@ Original entry posted on %date%:
326
 
327
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail
328
  if ( get_option('gwolle_gb-mail-from', false) ) {
329
- $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) . ">\r\n";
330
  }
331
 
332
  // Replace the tags from the mailtemplate with real data from the website and entry
@@ -348,10 +350,12 @@ Original entry posted on %date%:
348
  $info['admin_reply'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ));
349
  $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_content(), 'content' ));
350
  $info['date'] = date_i18n( get_option('date_format'), $entry->get_datetime() );
351
- for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
352
- $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
353
- $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
 
354
  }
 
355
 
356
  wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
357
 
20
  function gwolle_gb_mail_moderators( $entry ) {
21
  $isspam = $entry->get_isspam();
22
  if ( ! $isspam ) {
23
+ $subscribers = array();
24
  $recipients = get_option('gwolle_gb-notifyByMail');
25
  if ( is_string( $recipients ) && strlen($recipients) > 0 ) {
26
+ $recipients = explode( ',', $recipients );
27
  }
28
  if ( is_array( $recipients ) && count( $recipients ) > 0 ) {
29
  foreach ( $recipients as $recipient ) {
37
  }
38
 
39
  // Set the Mail Content
40
+ $mailtags = array( 'user_email', 'user_name', 'status', 'entry_management_url', 'blog_name', 'blog_url', 'wp_admin_url', 'entry_content', 'author_ip', 'author_origin' );
41
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-adminMailContent', false ), 'setting_textarea' );
42
  if ( ! $mail_body) {
43
  $mail_body = esc_html__("
44
  Hello,
45
 
46
+ There is a new guestbook entry at %blog_name%.
47
  You can check it at %entry_management_url%.
48
 
49
  Have a nice day.
56
  Entry status: %status%
57
  Entry content:
58
  %entry_content%
59
+ ", 'gwolle-gb');
 
60
  }
61
  $mail_body = apply_filters( 'gwolle_gb_mail_moderators_body', $mail_body, $entry );
62
 
66
 
67
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail.
68
  if ( get_option('gwolle_gb-mail-from', false) ) {
69
+ $header .= 'From: ' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . ' <' . get_option('gwolle_gb-mail-from') . ">\r\n";
70
  }
71
  $author_email = $entry->get_author_email();
72
  if ( $author_email ) {
104
  }
105
 
106
  // The last tags are bloginfo-based
107
+ $mailtags_count = count($mailtags);
108
+ for ($tagnum = 0; $tagnum < $mailtags_count; $tagnum++) {
109
+ $tagname = $mailtags["$tagnum"];
110
+ $mail_body = str_replace('%' . $tagname . '%', $info["$tagname"], $mail_body);
111
  }
112
+ $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
113
 
114
  // Add logging to mail
115
  $log_entries = gwolle_gb_get_log_entries( $entry->get_id() );
116
  if ( is_array($log_entries) && ! empty($log_entries) ) {
117
+ $mail_body .= "\r\n" . esc_html__('Log messages:', 'gwolle-gb') . "\r\n";
118
  if ($entry->get_datetime() > 0) {
119
  $mail_body .= date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
120
  $mail_body .= date_i18n( get_option('time_format'), $entry->get_datetime() );
125
  }
126
  }
127
 
128
+ if ( is_array($subscribers) && ! empty($subscribers) ) {
129
  foreach ( $subscribers as $subscriber ) {
130
  wp_mail($subscriber, $subject, $mail_body, $header);
131
  }
144
  */
145
  function gwolle_gb_mail_author( $entry ) {
146
  $isspam = $entry->get_isspam();
147
+ if ( ! $isspam ) {
148
+ if ( get_option( 'gwolle_gb-mail_author', 'false' ) === 'true' ) {
149
 
150
  // Set the Mail Content
151
+ $mailtags = array( 'user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content' );
152
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-authorMailContent', false ), 'setting_textarea' );
153
  if ( ! $mail_body) {
154
  $mail_body = esc_html__("
155
  Hello,
156
 
157
+ You have just posted a new guestbook entry at %blog_name%.
158
 
159
  Have a nice day.
160
  The editors at %blog_name%.
165
  User email: %user_email%
166
  Entry content:
167
  %entry_content%
168
+ ", 'gwolle-gb');
 
169
  }
170
  $mail_body = apply_filters( 'gwolle_gb_mail_author_body', $mail_body, $entry );
171
 
175
 
176
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail
177
  if ( get_option('gwolle_gb-mail-from', false) ) {
178
+ $header .= 'From: ' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . ' <' . gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) . ">\r\n";
179
  }
180
 
181
  // Replace the tags from the mailtemplate with real data from the website and entry
195
  $info['blog_url'] = get_bloginfo('wpurl');
196
  }
197
  $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_content(), 'content' ));
198
+ $mailtags_count = count($mailtags);
199
+ for ($tagnum = 0; $tagnum < $mailtags_count; $tagnum++) {
200
+ $tagname = $mailtags["$tagnum"];
201
+ $mail_body = str_replace('%' . $tagname . '%', $info["$tagname"], $mail_body);
202
  }
203
+ $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
204
 
205
  wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
206
 
219
  */
220
  function gwolle_gb_mail_author_on_moderation( $entry ) {
221
 
222
+ if (get_option( 'gwolle_gb-mail_author_moderation', 'false') !== 'true') {
223
  return;
224
  }
225
 
226
+ if ( $entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 ) {
227
 
228
  // Set the Mail Content
229
+ $mailtags = array( 'user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content', 'date' );
230
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-authormoderationcontent', false ), 'setting_textarea' );
231
  if ( ! $mail_body) {
232
  $mail_body = esc_html__("
233
  Hello,
234
 
235
+ An admin has just moderated your guestbook entry at %blog_name%.
236
 
237
  Have a nice day.
238
  The editors at %blog_name%.
243
 
244
  Original entry posted on %date%:
245
  %entry_content%
246
+ ", 'gwolle-gb');
 
247
  }
248
  $mail_body = apply_filters( 'gwolle_gb_mail_author_on_moderation_body', $mail_body, $entry );
249
 
253
 
254
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail
255
  if ( get_option('gwolle_gb-mail-from', false) ) {
256
+ $header .= 'From: ' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . ' <' . gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) . ">\r\n";
257
  }
258
 
259
  // Replace the tags from the mailtemplate with real data from the website and entry
274
  }
275
  $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_content(), 'content' ));
276
  $info['date'] = date_i18n( get_option('date_format'), $entry->get_datetime() );
277
+ $mailtags_count = count($mailtags);
278
+ for ($tagnum = 0; $tagnum < $mailtags_count; $tagnum++) {
279
+ $tagname = $mailtags["$tagnum"];
280
+ $mail_body = str_replace('%' . $tagname . '%', $info["$tagname"], $mail_body);
281
  }
282
+ $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
283
 
284
  wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
285
 
299
  if ( ! $isspam ) {
300
 
301
  // Set the Mail Content
302
+ $mailtags = array( 'user_email', 'user_name', 'blog_name', 'blog_url', 'admin_reply', 'entry_content', 'date' );
303
  $mail_body = gwolle_gb_sanitize_output( get_option( 'gwolle_gb-mail_admin_replyContent', false ), 'setting_textarea' );
304
  if ( ! $mail_body) {
305
  $mail_body = esc_html__("
306
  Hello,
307
 
308
+ An admin has just added or changed a reply message to your guestbook entry at %blog_name%.
309
 
310
  Have a nice day.
311
  The editors at %blog_name%.
318
 
319
  Original entry posted on %date%:
320
  %entry_content%
321
+ ", 'gwolle-gb');
 
322
  }
323
  $mail_body = apply_filters( 'gwolle_gb_mail_author_on_admin_reply_body', $mail_body, $entry );
324
 
328
 
329
  $header = "Content-Type: text/plain; charset=UTF-8\r\n"; // Encoding of the mail
330
  if ( get_option('gwolle_gb-mail-from', false) ) {
331
+ $header .= 'From: ' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . ' <' . gwolle_gb_sanitize_output( get_option('gwolle_gb-mail-from') ) . ">\r\n";
332
  }
333
 
334
  // Replace the tags from the mailtemplate with real data from the website and entry
350
  $info['admin_reply'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ));
351
  $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output( $entry->get_content(), 'content' ));
352
  $info['date'] = date_i18n( get_option('date_format'), $entry->get_datetime() );
353
+ $mailtags_count = count($mailtags);
354
+ for ($tagnum = 0; $tagnum < $mailtags_count; $tagnum++) {
355
+ $tagname = $mailtags["$tagnum"];
356
+ $mail_body = str_replace('%' . $tagname . '%', $info["$tagname"], $mail_body);
357
  }
358
+ $mail_body = gwolle_gb_format_values_for_mail( $mail_body );
359
 
360
  wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
361
 
functions/gb-messages.php CHANGED
@@ -64,7 +64,9 @@ function gwolle_gb_get_messages() {
64
  if ( $gwolle_gb_errors && is_array( $gwolle_gb_error_fields ) && ! empty( $gwolle_gb_error_fields ) ) {
65
  // There was no data filled in, even though that was mandatory.
66
  $gwolle_gb_messages[] = '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There were errors submitting your guestbook entry.', 'gwolle-gb') . '</strong></p>';
67
- $gwolle_gb_messages[] = '<p class="error_fields gb-error-fields" style="display: none;">' . print_r( $gwolle_gb_error_fields, true ) . '</p>';
 
 
68
  }
69
 
70
  $gwolle_gb_messages = apply_filters( 'gwolle_gb_messages', $gwolle_gb_messages );
64
  if ( $gwolle_gb_errors && is_array( $gwolle_gb_error_fields ) && ! empty( $gwolle_gb_error_fields ) ) {
65
  // There was no data filled in, even though that was mandatory.
66
  $gwolle_gb_messages[] = '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There were errors submitting your guestbook entry.', 'gwolle-gb') . '</strong></p>';
67
+ if ( function_exists( 'print_r' ) ) {
68
+ $gwolle_gb_messages[] = '<p class="error_fields gb-error-fields" style="display: none;">' . print_r( $gwolle_gb_error_fields, true ) . '</p>';
69
+ }
70
  }
71
 
72
  $gwolle_gb_messages = apply_filters( 'gwolle_gb_messages', $gwolle_gb_messages );
functions/gb-metabox.php CHANGED
@@ -17,13 +17,15 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
17
  * @since 2.3.0
18
  */
19
  function gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
20
- if ( function_exists('current_user_can') && current_user_can('moderate_comments') ) {
 
21
  $gb_metabox .= '
22
  <div class="gb-metabox-line">
23
  <a class="gwolle_gb_edit_link gwolle-gb-edit-link" href="' . admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&amp;entry_id=' . $entry->get_id() ) . '" title="' . esc_attr__('Edit entry', 'gwolle-gb') . '">' . esc_html__('Edit in Editor', 'gwolle-gb') . '</a>
24
  </div>';
25
  }
26
  return $gb_metabox;
 
27
  }
28
  add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_edit_link', 90, 2 );
29
 
@@ -39,7 +41,8 @@ add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_edit
39
  * @since 2.3.0
40
  */
41
  function gwolle_gb_entry_metabox_lines_ajax_icon( $gb_metabox, $entry ) {
42
- if ( function_exists('current_user_can') && current_user_can('moderate_comments') ) {
 
43
  if ( $gb_metabox ) {
44
 
45
  $gb_metabox .= '
@@ -49,5 +52,6 @@ function gwolle_gb_entry_metabox_lines_ajax_icon( $gb_metabox, $entry ) {
49
  }
50
  }
51
  return $gb_metabox;
 
52
  }
53
  add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_ajax_icon', 99, 2 );
17
  * @since 2.3.0
18
  */
19
  function gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
20
+
21
+ if ( current_user_can('moderate_comments') ) {
22
  $gb_metabox .= '
23
  <div class="gb-metabox-line">
24
  <a class="gwolle_gb_edit_link gwolle-gb-edit-link" href="' . admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&amp;entry_id=' . $entry->get_id() ) . '" title="' . esc_attr__('Edit entry', 'gwolle-gb') . '">' . esc_html__('Edit in Editor', 'gwolle-gb') . '</a>
25
  </div>';
26
  }
27
  return $gb_metabox;
28
+
29
  }
30
  add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_edit_link', 90, 2 );
31
 
41
  * @since 2.3.0
42
  */
43
  function gwolle_gb_entry_metabox_lines_ajax_icon( $gb_metabox, $entry ) {
44
+
45
+ if ( current_user_can('moderate_comments') ) {
46
  if ( $gb_metabox ) {
47
 
48
  $gb_metabox .= '
52
  }
53
  }
54
  return $gb_metabox;
55
+
56
  }
57
  add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_ajax_icon', 99, 2 );
functions/gb-post-meta.php CHANGED
@@ -12,7 +12,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
12
  *
13
  * @param int $id ID of the post
14
  */
15
- function gwolle_gb_save_post($id) {
16
 
17
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
18
  return;
@@ -21,26 +21,25 @@ function gwolle_gb_save_post($id) {
21
  if ( defined( 'DOING_CRON' ) && DOING_CRON )
22
  return;
23
 
24
- if ( function_exists('has_shortcode') ) {
25
  $post = get_post( $id );
26
 
27
- if ( has_shortcode( $post->post_content, 'gwolle_gb' ) || has_shortcode( $post->post_content, 'gwolle_gb_read' ) ) {
28
- // Set a meta_key so we can find the post with the shortcode back.
29
- $meta_value = get_post_meta( $id, 'gwolle_gb_read', true );
30
- if ( $meta_value != 'true' ) {
31
- update_post_meta( $id, 'gwolle_gb_read', 'true' );
32
- }
33
- } else {
34
- // Remove the meta_key in case it is set.
35
- delete_post_meta( $id, 'gwolle_gb_read' );
36
  }
 
 
 
 
37
 
38
- if ( has_shortcode( $post->post_content, 'gwolle_gb' ) || has_shortcode( $post->post_content, 'gwolle_gb_read' ) || has_shortcode( $post->post_content, 'gwolle_gb_write' ) ) {
39
- // Nothing to do
40
- } else {
41
- delete_post_meta( $id, 'gwolle_gb_book_id' );
42
- }
43
  }
 
44
  }
45
  add_action('save_post', 'gwolle_gb_save_post');
46
 
@@ -59,25 +58,23 @@ function gwolle_gb_content_filter_for_meta_keys( $content ) {
59
  return $content;
60
  }
61
 
62
- if ( function_exists('has_shortcode') ) {
63
- $id = get_the_ID();
64
-
65
- if ( has_shortcode( $content, 'gwolle_gb' ) || has_shortcode( $content, 'gwolle_gb_read' ) ) {
66
- // Set a meta_key so we can find the post with the shortcode back.
67
- $meta_value = get_post_meta( $id, 'gwolle_gb_read', true );
68
- if ( $meta_value != 'true' ) {
69
- update_post_meta( $id, 'gwolle_gb_read', 'true' );
70
- }
71
- } else {
72
- // Remove the meta_key in case it is set.
73
- delete_post_meta( $id, 'gwolle_gb_read' );
74
- }
75
 
76
- if ( has_shortcode( $content, 'gwolle_gb' ) || has_shortcode( $content, 'gwolle_gb_read' ) || has_shortcode( $content, 'gwolle_gb_write' ) ) {
77
- // Nothing to do
78
- } else {
79
- delete_post_meta( $id, 'gwolle_gb_book_id' );
 
80
  }
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  return $content;
@@ -95,8 +92,12 @@ function gwolle_gb_is_protected_meta( $protected, $meta_key, $meta_type ) {
95
  switch ($meta_key) {
96
  case 'gwolle_gb_read':
97
  return true;
 
98
  case 'gwolle_gb_book_id':
99
  return true;
 
 
 
100
  }
101
 
102
  return $protected;
@@ -117,7 +118,6 @@ add_filter( 'is_protected_meta', 'gwolle_gb_is_protected_meta', 10, 3 );
117
  function gwolle_gb_set_meta_keys( $shortcode, $shortcode_atts ) {
118
 
119
  _deprecated_function( __FUNCTION__, ' 3.1.8', 'gwolle_gb_content_filter_for_meta_keys()' );
120
- return;
121
 
122
  }
123
 
@@ -134,7 +134,7 @@ function gwolle_gb_set_meta_keys( $shortcode, $shortcode_atts ) {
134
  function gwolle_gb_post_is_guestbook( $post_id ) {
135
 
136
  $meta_value_read = get_post_meta( $post_id, 'gwolle_gb_read', true );
137
- if ( $meta_value_read == 'true' ) {
138
  return true;
139
  }
140
 
12
  *
13
  * @param int $id ID of the post
14
  */
15
+ function gwolle_gb_save_post( $id ) {
16
 
17
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
18
  return;
21
  if ( defined( 'DOING_CRON' ) && DOING_CRON )
22
  return;
23
 
 
24
  $post = get_post( $id );
25
 
26
+ if ( has_shortcode( $post->post_content, 'gwolle_gb' ) || has_shortcode( $post->post_content, 'gwolle_gb_read' ) ) {
27
+ // Set a meta_key so we can find the post with the shortcode back.
28
+ $meta_value = get_post_meta( $id, 'gwolle_gb_read', true );
29
+ if ( $meta_value !== 'true' ) {
30
+ update_post_meta( $id, 'gwolle_gb_read', 'true' );
 
 
 
 
31
  }
32
+ } else {
33
+ // Remove the meta_key in case it is set.
34
+ delete_post_meta( $id, 'gwolle_gb_read' );
35
+ }
36
 
37
+ if ( has_shortcode( $post->post_content, 'gwolle_gb' ) || has_shortcode( $post->post_content, 'gwolle_gb_read' ) || has_shortcode( $post->post_content, 'gwolle_gb_write' ) ) {
38
+ // Nothing to do
39
+ } else {
40
+ delete_post_meta( $id, 'gwolle_gb_book_id' );
 
41
  }
42
+
43
  }
44
  add_action('save_post', 'gwolle_gb_save_post');
45
 
58
  return $content;
59
  }
60
 
61
+ $id = get_the_ID();
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
+ if ( has_shortcode( $content, 'gwolle_gb' ) || has_shortcode( $content, 'gwolle_gb_read' ) ) {
64
+ // Set a meta_key so we can find the post with the shortcode back.
65
+ $meta_value = get_post_meta( $id, 'gwolle_gb_read', true );
66
+ if ( $meta_value !== 'true' ) {
67
+ update_post_meta( $id, 'gwolle_gb_read', 'true' );
68
  }
69
+ } else {
70
+ // Remove the meta_key in case it is set.
71
+ delete_post_meta( $id, 'gwolle_gb_read' );
72
+ }
73
+
74
+ if ( has_shortcode( $content, 'gwolle_gb' ) || has_shortcode( $content, 'gwolle_gb_read' ) || has_shortcode( $content, 'gwolle_gb_write' ) ) {
75
+ // Nothing to do
76
+ } else {
77
+ delete_post_meta( $id, 'gwolle_gb_book_id' );
78
  }
79
 
80
  return $content;
92
  switch ($meta_key) {
93
  case 'gwolle_gb_read':
94
  return true;
95
+
96
  case 'gwolle_gb_book_id':
97
  return true;
98
+
99
+ default:
100
+ return $protected;
101
  }
102
 
103
  return $protected;
118
  function gwolle_gb_set_meta_keys( $shortcode, $shortcode_atts ) {
119
 
120
  _deprecated_function( __FUNCTION__, ' 3.1.8', 'gwolle_gb_content_filter_for_meta_keys()' );
 
121
 
122
  }
123
 
134
  function gwolle_gb_post_is_guestbook( $post_id ) {
135
 
136
  $meta_value_read = get_post_meta( $post_id, 'gwolle_gb_read', true );
137
+ if ( $meta_value_read === 'true' ) {
138
  return true;
139
  }
140
 
functions/gb-privacy.php CHANGED
@@ -98,13 +98,13 @@ function gwolle_gb_personal_data_exporter( $email_address, $page = 1 ) {
98
  /* Used for permalinks */
99
  $books = gwolle_gb_get_permalinks();
100
 
101
- $offset = $number * ($page - 1);
102
  $entries = gwolle_gb_get_entries(
103
  array(
104
  'all' => 'all',
105
  'offset' => $offset,
106
  'num_entries' => $number,
107
- 'email' => $email_address
108
  )
109
  );
110
 
@@ -126,21 +126,27 @@ function gwolle_gb_personal_data_exporter( $email_address, $page = 1 ) {
126
  case 'author_name':
127
  $value = gwolle_gb_sanitize_output( trim( $entry->get_author_name() ) );
128
  break;
 
129
  case 'author_email':
130
  $value = $entry->get_author_email();
131
  break;
 
132
  case 'author_origin':
133
  $value = gwolle_gb_sanitize_output( $entry->get_author_origin() );
134
  break;
 
135
  case 'author_website':
136
  $value = $entry->get_author_website();
137
  break;
 
138
  case 'author_ip':
139
  $value = $entry->get_author_ip();
140
  break;
 
141
  case 'author_host':
142
  $value = $entry->get_author_host();
143
  break;
 
144
  case 'datetime':
145
  $value = date_i18n( get_option('date_format'), $entry->get_datetime() ) . ' ' . esc_html__('at', 'gwolle-gb') . ' ' . trim(date_i18n( get_option('time_format'), $entry->get_datetime() ));
146
  break;
@@ -150,7 +156,7 @@ function gwolle_gb_personal_data_exporter( $email_address, $page = 1 ) {
150
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
151
  $entry_content = nl2br($entry_content);
152
  }
153
- if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
154
  $entry_content = gwolle_gb_bbcode_parse($entry_content);
155
  } else {
156
  $entry_content = gwolle_gb_bbcode_strip($entry_content);
@@ -161,11 +167,11 @@ function gwolle_gb_personal_data_exporter( $email_address, $page = 1 ) {
161
  case 'entry_link':
162
  $book_id = $entry->get_book_id();
163
  $permalink = '';
164
- if ( isset( $books["$book_id"] ) && isset( $books["$book_id"]["permalink"] ) ) {
165
- $permalink = $books["$book_id"]["permalink"];
166
  $permalink = add_query_arg( 'entry_id', $entry_id, $permalink );
167
  }
168
- if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 && strlen( $permalink ) > 0 ) {
169
  $value = sprintf(
170
  '<a href="%s" target="_blank" rel="noreferrer noopener">%s</a>',
171
  esc_url( $permalink ),
@@ -175,6 +181,9 @@ function gwolle_gb_personal_data_exporter( $email_address, $page = 1 ) {
175
  $value = esc_html__('This entry is Not Visible.', 'gwolle-gb');
176
  }
177
  break;
 
 
 
178
  }
179
 
180
  if ( ! empty( $value ) ) {
@@ -255,17 +264,17 @@ function gwolle_gb_personal_data_eraser( $email_address, $page = 1 ) {
255
  array(
256
  'offset' => 0,
257
  'num_entries' => $number,
258
- 'email' => $email_address
259
  )
260
  );
261
 
262
  if ( ! is_array($entries) || empty($entries) ) {
263
- $messages[] = esc_html__( 'No guestbook entries have been found for this email address.' );
264
  return array(
265
  'items_removed' => false,
266
  'items_retained' => false,
267
  'messages' => $messages,
268
- 'done' => true
269
  );
270
  }
271
 
@@ -279,7 +288,7 @@ function gwolle_gb_personal_data_eraser( $email_address, $page = 1 ) {
279
  } else {
280
  $items_retained = true;
281
  /* translators: %d: Entry ID */
282
- $messages[] = sprintf( esc_html__( 'Guestbook entry %d contains personal data but could not be anonymized.' ), $entry->get_id() );
283
  }
284
  }
285
 
@@ -289,7 +298,7 @@ function gwolle_gb_personal_data_eraser( $email_address, $page = 1 ) {
289
  'items_removed' => $items_removed,
290
  'items_retained' => $items_retained,
291
  'messages' => $messages,
292
- 'done' => $done
293
  );
294
  }
295
 
@@ -303,6 +312,7 @@ function gwolle_gb_personal_data_eraser( $email_address, $page = 1 ) {
303
  * @return object $entry anonymized instance of gwolle_gb_entry class.
304
  */
305
  function gwolle_gb_privacy_anonymize_entry( $entry ) {
 
306
  $entry->set_author_name( /* translators: Username */ esc_html__( 'Anonymous', 'gwolle-gb' ) );
307
  $entry->set_author_id( 0 );
308
  $entry->set_author_email( '' );
@@ -312,4 +322,5 @@ function gwolle_gb_privacy_anonymize_entry( $entry ) {
312
  $entry->set_author_host( '' );
313
 
314
  return $entry;
 
315
  }
98
  /* Used for permalinks */
99
  $books = gwolle_gb_get_permalinks();
100
 
101
+ $offset = $number * ( $page - 1 );
102
  $entries = gwolle_gb_get_entries(
103
  array(
104
  'all' => 'all',
105
  'offset' => $offset,
106
  'num_entries' => $number,
107
+ 'email' => $email_address,
108
  )
109
  );
110
 
126
  case 'author_name':
127
  $value = gwolle_gb_sanitize_output( trim( $entry->get_author_name() ) );
128
  break;
129
+
130
  case 'author_email':
131
  $value = $entry->get_author_email();
132
  break;
133
+
134
  case 'author_origin':
135
  $value = gwolle_gb_sanitize_output( $entry->get_author_origin() );
136
  break;
137
+
138
  case 'author_website':
139
  $value = $entry->get_author_website();
140
  break;
141
+
142
  case 'author_ip':
143
  $value = $entry->get_author_ip();
144
  break;
145
+
146
  case 'author_host':
147
  $value = $entry->get_author_host();
148
  break;
149
+
150
  case 'datetime':
151
  $value = date_i18n( get_option('date_format'), $entry->get_datetime() ) . ' ' . esc_html__('at', 'gwolle-gb') . ' ' . trim(date_i18n( get_option('time_format'), $entry->get_datetime() ));
152
  break;
156
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
157
  $entry_content = nl2br($entry_content);
158
  }
159
+ if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
160
  $entry_content = gwolle_gb_bbcode_parse($entry_content);
161
  } else {
162
  $entry_content = gwolle_gb_bbcode_strip($entry_content);
167
  case 'entry_link':
168
  $book_id = $entry->get_book_id();
169
  $permalink = '';
170
+ if ( isset( $books["$book_id"] ) && isset( $books["$book_id"]['permalink'] ) ) {
171
+ $permalink = $books["$book_id"]['permalink'];
172
  $permalink = add_query_arg( 'entry_id', $entry_id, $permalink );
173
  }
174
+ if ( $entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 && strlen( $permalink ) > 0 ) {
175
  $value = sprintf(
176
  '<a href="%s" target="_blank" rel="noreferrer noopener">%s</a>',
177
  esc_url( $permalink ),
181
  $value = esc_html__('This entry is Not Visible.', 'gwolle-gb');
182
  }
183
  break;
184
+
185
+ default:
186
+ break;
187
  }
188
 
189
  if ( ! empty( $value ) ) {
264
  array(
265
  'offset' => 0,
266
  'num_entries' => $number,
267
+ 'email' => $email_address,
268
  )
269
  );
270
 
271
  if ( ! is_array($entries) || empty($entries) ) {
272
+ $messages[] = esc_html__( 'No guestbook entries have been found for this email address.', 'gwolle-gb' );
273
  return array(
274
  'items_removed' => false,
275
  'items_retained' => false,
276
  'messages' => $messages,
277
+ 'done' => true,
278
  );
279
  }
280
 
288
  } else {
289
  $items_retained = true;
290
  /* translators: %d: Entry ID */
291
+ $messages[] = sprintf( esc_html__( 'Guestbook entry %d contains personal data but could not be anonymized.', 'gwolle-gb' ), $entry->get_id() );
292
  }
293
  }
294
 
298
  'items_removed' => $items_removed,
299
  'items_retained' => $items_retained,
300
  'messages' => $messages,
301
+ 'done' => $done,
302
  );
303
  }
304
 
312
  * @return object $entry anonymized instance of gwolle_gb_entry class.
313
  */
314
  function gwolle_gb_privacy_anonymize_entry( $entry ) {
315
+
316
  $entry->set_author_name( /* translators: Username */ esc_html__( 'Anonymous', 'gwolle-gb' ) );
317
  $entry->set_author_id( 0 );
318
  $entry->set_author_email( '' );
322
  $entry->set_author_host( '' );
323
 
324
  return $entry;
325
+
326
  }
functions/gb-settings.php CHANGED
@@ -65,13 +65,13 @@ add_action( 'admin_init', 'gwolle_gb_register_settings' );
65
  * - Array with settings for that request.
66
  * - or false if no setting.
67
  */
68
- function gwolle_gb_get_setting($request) {
69
 
70
- $provided = array('form', 'read');
71
  if ( in_array( $request, $provided ) ) {
72
  switch ( $request ) {
73
  case 'form':
74
- $defaults = Array(
75
  'form_name_enabled' => 'true',
76
  'form_name_mandatory' => 'true',
77
  'form_city_enabled' => 'true',
@@ -82,19 +82,21 @@ function gwolle_gb_get_setting($request) {
82
  'form_homepage_mandatory' => 'false',
83
  'form_message_enabled' => 'true',
84
  'form_message_mandatory' => 'true',
 
85
  'form_bbcode_enabled' => 'false',
86
  'form_antispam_enabled' => 'false',
87
- 'form_privacy_enabled' => 'false'
88
  );
89
- $setting = get_option( 'gwolle_gb-form', Array() );
90
  if ( is_string( $setting ) ) {
91
  $setting = maybe_unserialize( $setting );
92
  }
93
- if ( is_array($setting) && !empty($setting) ) {
94
  $setting = array_merge( $defaults, $setting );
95
  return $setting;
96
  }
97
  return $defaults;
 
98
  case 'read':
99
  if ( get_option('show_avatars') ) {
100
  $avatar = 'true';
@@ -102,7 +104,7 @@ function gwolle_gb_get_setting($request) {
102
  $avatar = 'false';
103
  }
104
 
105
- $defaults = Array(
106
  'read_avatar' => $avatar,
107
  'read_name' => 'true',
108
  'read_city' => 'true',
@@ -110,20 +112,22 @@ function gwolle_gb_get_setting($request) {
110
  'read_date' => 'false',
111
  'read_content' => 'true',
112
  'read_aavatar' => 'false',
113
- 'read_editlink' => 'true'
114
  );
115
- $setting = get_option( 'gwolle_gb-read', Array() );
116
  if ( is_string( $setting ) ) {
117
  $setting = maybe_unserialize( $setting );
118
  }
119
- if ( is_array($setting) && !empty($setting) ) {
120
  $setting = array_merge( $defaults, $setting );
121
  return $setting;
122
  }
123
  return $defaults;
 
124
  default:
125
  return false;
126
  }
127
  }
128
  return false;
 
129
  }
65
  * - Array with settings for that request.
66
  * - or false if no setting.
67
  */
68
+ function gwolle_gb_get_setting( $request ) {
69
 
70
+ $provided = array( 'form', 'read' );
71
  if ( in_array( $request, $provided ) ) {
72
  switch ( $request ) {
73
  case 'form':
74
+ $defaults = array(
75
  'form_name_enabled' => 'true',
76
  'form_name_mandatory' => 'true',
77
  'form_city_enabled' => 'true',
82
  'form_homepage_mandatory' => 'false',
83
  'form_message_enabled' => 'true',
84
  'form_message_mandatory' => 'true',
85
+ 'form_message_maxlength' => 0,
86
  'form_bbcode_enabled' => 'false',
87
  'form_antispam_enabled' => 'false',
88
+ 'form_privacy_enabled' => 'false',
89
  );
90
+ $setting = get_option( 'gwolle_gb-form', array() );
91
  if ( is_string( $setting ) ) {
92
  $setting = maybe_unserialize( $setting );
93
  }
94
+ if ( is_array($setting) && ! empty($setting) ) {
95
  $setting = array_merge( $defaults, $setting );
96
  return $setting;
97
  }
98
  return $defaults;
99
+
100
  case 'read':
101
  if ( get_option('show_avatars') ) {
102
  $avatar = 'true';
104
  $avatar = 'false';
105
  }
106
 
107
+ $defaults = array(
108
  'read_avatar' => $avatar,
109
  'read_name' => 'true',
110
  'read_city' => 'true',
112
  'read_date' => 'false',
113
  'read_content' => 'true',
114
  'read_aavatar' => 'false',
115
+ 'read_editlink' => 'true',
116
  );
117
+ $setting = get_option( 'gwolle_gb-read', array() );
118
  if ( is_string( $setting ) ) {
119
  $setting = maybe_unserialize( $setting );
120
  }
121
+ if ( is_array($setting) && ! empty($setting) ) {
122
  $setting = array_merge( $defaults, $setting );
123
  return $setting;
124
  }
125
  return $defaults;
126
+
127
  default:
128
  return false;
129
  }
130
  }
131
  return false;
132
+
133
  }
functions/gb-single-view.php CHANGED
@@ -21,14 +21,14 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
21
  function gwolle_gb_single_view( $entry, $first = false, $counter = 0 ) {
22
 
23
  // Try to load and require_once the template from the themes folders.
24
- if ( locate_template( array('gwolle_gb-entry.php'), true, true ) == '') {
25
 
26
  $output = '<!-- Gwolle-GB Entry: Default Template Loaded -->
27
  ';
28
 
29
  // No template found and loaded in the theme folders.
30
  // Load the template from the plugin folder.
31
- require_once( GWOLLE_GB_DIR . '/frontend/gwolle_gb-entry.php' );
32
 
33
  } else {
34
 
@@ -44,4 +44,5 @@ function gwolle_gb_single_view( $entry, $first = false, $counter = 0 ) {
44
  $output .= apply_filters( 'gwolle_gb_entry_read', $entry_output, $entry );
45
 
46
  return $output;
 
47
  }
21
  function gwolle_gb_single_view( $entry, $first = false, $counter = 0 ) {
22
 
23
  // Try to load and require_once the template from the themes folders.
24
+ if ( locate_template( array( 'gwolle_gb-entry.php' ), true, true ) === '') {
25
 
26
  $output = '<!-- Gwolle-GB Entry: Default Template Loaded -->
27
  ';
28
 
29
  // No template found and loaded in the theme folders.
30
  // Load the template from the plugin folder.
31
+ require_once GWOLLE_GB_DIR . '/frontend/gwolle_gb-entry.php';
32
 
33
  } else {
34
 
44
  $output .= apply_filters( 'gwolle_gb_entry_read', $entry_output, $entry );
45
 
46
  return $output;
47
+
48
  }
functions/gb-stop-forum-spam.php CHANGED
@@ -23,27 +23,28 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
23
  function gwolle_gb_stop_forum_spam( $entry ) {
24
  $args = array();
25
  $args['ip'] = gwolle_gb_get_user_ip();
26
- $args['email'] = urlencode(iconv( 'GBK', 'UTF-8', $entry->get_author_email() ));
27
- $args['username'] = urlencode(iconv( 'GBK', 'UTF-8', $entry->get_author_name() ));
28
- $args['f'] = 'json';
29
- $args['confidence'] = true;
30
  $args = array_filter( $args );
31
 
32
  $url = 'https://api.stopforumspam.com/api?';
33
  $query = $url . http_build_query( $args );
34
  $key = md5( $query );
35
 
36
- if ( false === ( $transient = get_transient( 'gwolle_gb_sfs_' . $key ) ) ) {
 
37
  $result = wp_remote_get( $query );
38
  if ( ! is_wp_error( $result ) ) {
39
 
40
- if ( strlen( $result['body'] ) < 10 || ! $result['response']['code'] == 200 ) {
41
  return false;
42
  }
43
 
44
  if ( $data = json_decode( $result['body'] ) ) {
45
  // It is json. Continue.
46
- if ( $data->success != 1 ) {
47
  return false;
48
  }
49
 
@@ -51,9 +52,15 @@ function gwolle_gb_stop_forum_spam( $entry ) {
51
 
52
  $blocked = false;
53
 
54
- if ( isset( $data->ip->confidence ) && $data->ip->confidence > 75 ) { $blocked = 'ip'; }
55
- if ( isset( $data->username->confidence ) && $data->username->confidence > 80 ) { $blocked = 'username'; }
56
- if ( isset( $data->email->confidence ) && $data->email->confidence > 75 ) { $blocked = 'email'; }
 
 
 
 
 
 
57
 
58
  if ( $blocked ) {
59
  set_transient( 'gwolle_gb_sfs_' . $key, 'true', DAY_IN_SECONDS );
23
  function gwolle_gb_stop_forum_spam( $entry ) {
24
  $args = array();
25
  $args['ip'] = gwolle_gb_get_user_ip();
26
+ $args['email'] = rawurlencode(iconv( 'GBK', 'UTF-8', $entry->get_author_email() ));
27
+ $args['username'] = rawurlencode(iconv( 'GBK', 'UTF-8', $entry->get_author_name() ));
28
+ $args['f'] = 'json';
29
+ $args['confidence'] = true;
30
  $args = array_filter( $args );
31
 
32
  $url = 'https://api.stopforumspam.com/api?';
33
  $query = $url . http_build_query( $args );
34
  $key = md5( $query );
35
 
36
+ $transient = get_transient( 'gwolle_gb_sfs_' . $key );
37
+ if ( false === $transient ) {
38
  $result = wp_remote_get( $query );
39
  if ( ! is_wp_error( $result ) ) {
40
 
41
+ if ( strlen( $result['body'] ) < 10 || ! (int) $result['response']['code'] === 200 ) {
42
  return false;
43
  }
44
 
45
  if ( $data = json_decode( $result['body'] ) ) {
46
  // It is json. Continue.
47
+ if ( (int) $data->success !== 1 ) {
48
  return false;
49
  }
50
 
52
 
53
  $blocked = false;
54
 
55
+ if ( isset( $data->ip->confidence ) && $data->ip->confidence > 75 ) {
56
+ $blocked = 'ip';
57
+ }
58
+ if ( isset( $data->username->confidence ) && $data->username->confidence > 80 ) {
59
+ $blocked = 'username';
60
+ }
61
+ if ( isset( $data->email->confidence ) && $data->email->confidence > 75 ) {
62
+ $blocked = 'email';
63
+ }
64
 
65
  if ( $blocked ) {
66
  set_transient( 'gwolle_gb_sfs_' . $key, 'true', DAY_IN_SECONDS );
functions/gb-user-ip.php CHANGED
@@ -38,18 +38,18 @@ function gwolle_gb_get_user_ip() {
38
  'CLIENT_IP',
39
  'FORWARDED_FOR_IP',
40
  'HTTP_PROXY_CONNECTION',
41
- 'REMOTE_ADDR'
42
  );
43
  foreach ( $proxy_headers as $header ) {
44
- if ( isset( $_SERVER[ "$header" ] ) ) {
45
- $user_ip = $_SERVER[ "$header" ];
46
  break;
47
  }
48
  }
49
  return $user_ip;
50
  }
51
 
52
- $user_ip = $_SERVER[ 'REMOTE_ADDR' ];
53
  return $user_ip;
54
 
55
  }
38
  'CLIENT_IP',
39
  'FORWARDED_FOR_IP',
40
  'HTTP_PROXY_CONNECTION',
41
+ 'REMOTE_ADDR',
42
  );
43
  foreach ( $proxy_headers as $header ) {
44
+ if ( isset( $_SERVER["$header"] ) ) {
45
+ $user_ip = $_SERVER["$header"];
46
  break;
47
  }
48
  }
49
  return $user_ip;
50
  }
51
 
52
+ $user_ip = $_SERVER['REMOTE_ADDR'];
53
  return $user_ip;
54
 
55
  }
functions/gb-user.php CHANGED
@@ -20,7 +20,7 @@ function gwolle_gb_is_author( $entry ) {
20
  $user_id = get_current_user_id(); // returns 0 if no current user
21
  if ( $user_id > 0 ) {
22
  $author_id = $entry->get_author_id();
23
- if ( $author_id == $user_id ) {
24
  return true;
25
  }
26
  }
@@ -37,13 +37,13 @@ function gwolle_gb_is_author( $entry ) {
37
  * - string user_nicename or user_login if allowed
38
  * - bool false if not allowed
39
  */
40
- function gwolle_gb_is_moderator($user_id) {
41
 
42
  if ( $user_id > 0 ) {
43
- if ( function_exists('user_can') && user_can( $user_id, 'moderate_comments' ) ) {
44
  // Only moderators
45
  $userdata = get_userdata( $user_id );
46
- if (is_object($userdata)) {
47
  if ( isset( $userdata->display_name ) ) {
48
  return $userdata->display_name;
49
  } else {
@@ -70,7 +70,7 @@ function gwolle_gb_get_moderators() {
70
  $users_query = new WP_User_Query( array(
71
  'role__in' => $role__in,
72
  'fields' => 'all',
73
- 'orderby' => 'display_name'
74
  ) );
75
  $users = $users_query->get_results();
76
 
@@ -79,7 +79,7 @@ function gwolle_gb_get_moderators() {
79
  if ( is_array($users) && ! empty($users) ) {
80
  foreach ( $users as $user_info ) {
81
 
82
- if ($user_info === FALSE) {
83
  // Invalid $user_id
84
  continue;
85
  }
@@ -106,9 +106,9 @@ function gwolle_gb_get_moderators() {
106
  function gwolle_gb_deleted_user( $user_id ) {
107
  $entries = gwolle_gb_get_entries(array(
108
  'author_id' => $user_id,
109
- 'num_entries' => -1
110
  ));
111
- if ( is_array( $entries ) && !empty( $entries ) ) {
112
  foreach ( $entries as $entry ) {
113
  // method will take care of it...
114
  $save = $entry->save();
@@ -124,7 +124,7 @@ add_action( 'deleted_user', 'gwolle_gb_deleted_user' );
124
  * @param object $entry instance of gb_entry class.
125
  * @return string $author_name_html html with formatted username
126
  */
127
- function gwolle_gb_get_author_name_html($entry) {
128
 
129
  $author_name = gwolle_gb_sanitize_output( trim( $entry->get_author_name() ) );
130
  $author_name = apply_filters( 'gwolle_gb_entry_the_author_name', $author_name, $entry );
@@ -133,7 +133,7 @@ function gwolle_gb_get_author_name_html($entry) {
133
  $author_id = $entry->get_author_id();
134
  $is_moderator = gwolle_gb_is_moderator( $author_id );
135
  if ( $is_moderator ) {
136
- $author_name_html = '<i class="gb-moderator">' . $author_name . '</i>';
137
  } else {
138
  $author_name_html = $author_name;
139
  }
@@ -144,8 +144,8 @@ function gwolle_gb_get_author_name_html($entry) {
144
  $author_website = trim( bp_core_get_user_domain( $author_id ) );
145
  if ($author_website) {
146
  $author_link_rel = apply_filters( 'gwolle_gb_author_link_rel', 'nofollow noopener noreferrer' );
147
- $author_name_html = '<a href="' . $author_website . '" target="_blank" rel="' . $author_link_rel . '"
148
- title="' . /* translators: BuddyPress profile */ esc_attr__( 'Visit the profile of', 'gwolle-gb' ) . ' ' . $author_name . ': ' . $author_website . '">' . $author_name_html . '</a>';
149
  }
150
  } else if ( get_option('gwolle_gb-linkAuthorWebsite', 'true') === 'true' ) {
151
  // Link to author website if set in options.
@@ -153,15 +153,16 @@ function gwolle_gb_get_author_name_html($entry) {
153
  if ($author_website) {
154
  $pattern = '/^http/';
155
  if ( ! preg_match($pattern, $author_website, $matches) ) {
156
- $author_website = "http://" . $author_website;
157
  }
158
  $author_link_rel = apply_filters( 'gwolle_gb_author_link_rel', 'nofollow noopener noreferrer' );
159
- $author_name_html = '<a href="' . $author_website . '" target="_blank" rel="' . $author_link_rel . '"
160
- title="' . esc_attr__( 'Visit the website of', 'gwolle-gb' ) . ' ' . $author_name . ': ' . $author_website . '">' . $author_name_html . '</a>';
161
  }
162
  }
163
 
164
  $author_name_html = apply_filters( 'gwolle_gb_author_name_html', $author_name_html, $entry );
165
 
166
  return $author_name_html;
 
167
  }
20
  $user_id = get_current_user_id(); // returns 0 if no current user
21
  if ( $user_id > 0 ) {
22
  $author_id = $entry->get_author_id();
23
+ if ( $author_id === $user_id ) {
24
  return true;
25
  }
26
  }
37
  * - string user_nicename or user_login if allowed
38
  * - bool false if not allowed
39
  */
40
+ function gwolle_gb_is_moderator( $user_id ) {
41
 
42
  if ( $user_id > 0 ) {
43
+ if ( user_can( $user_id, 'moderate_comments' ) ) {
44
  // Only moderators
45
  $userdata = get_userdata( $user_id );
46
+ if ( is_object($userdata) ) {
47
  if ( isset( $userdata->display_name ) ) {
48
  return $userdata->display_name;
49
  } else {
70
  $users_query = new WP_User_Query( array(
71
  'role__in' => $role__in,
72
  'fields' => 'all',
73
+ 'orderby' => 'display_name',
74
  ) );
75
  $users = $users_query->get_results();
76
 
79
  if ( is_array($users) && ! empty($users) ) {
80
  foreach ( $users as $user_info ) {
81
 
82
+ if ($user_info === false) {
83
  // Invalid $user_id
84
  continue;
85
  }
106
  function gwolle_gb_deleted_user( $user_id ) {
107
  $entries = gwolle_gb_get_entries(array(
108
  'author_id' => $user_id,
109
+ 'num_entries' => -1,
110
  ));
111
+ if ( is_array( $entries ) && ! empty( $entries ) ) {
112
  foreach ( $entries as $entry ) {
113
  // method will take care of it...
114
  $save = $entry->save();
124
  * @param object $entry instance of gb_entry class.
125
  * @return string $author_name_html html with formatted username
126
  */
127
+ function gwolle_gb_get_author_name_html( $entry ) {
128
 
129
  $author_name = gwolle_gb_sanitize_output( trim( $entry->get_author_name() ) );
130
  $author_name = apply_filters( 'gwolle_gb_entry_the_author_name', $author_name, $entry );
133
  $author_id = $entry->get_author_id();
134
  $is_moderator = gwolle_gb_is_moderator( $author_id );
135
  if ( $is_moderator ) {
136
+ $author_name_html = '<i class="gb-moderator">' . esc_attr( $author_name ) . '</i>';
137
  } else {
138
  $author_name_html = $author_name;
139
  }
144
  $author_website = trim( bp_core_get_user_domain( $author_id ) );
145
  if ($author_website) {
146
  $author_link_rel = apply_filters( 'gwolle_gb_author_link_rel', 'nofollow noopener noreferrer' );
147
+ $author_name_html = '<a href="' . esc_attr( $author_website ) . '" target="_blank" rel="' . esc_attr( $author_link_rel ) . '"
148
+ title="' . /* translators: BuddyPress profile */ esc_attr__( 'Visit the profile of', 'gwolle-gb' ) . ' ' . esc_attr( $author_name ) . ': ' . esc_attr( $author_website ) . '">' . $author_name_html . '</a>';
149
  }
150
  } else if ( get_option('gwolle_gb-linkAuthorWebsite', 'true') === 'true' ) {
151
  // Link to author website if set in options.
153
  if ($author_website) {
154
  $pattern = '/^http/';
155
  if ( ! preg_match($pattern, $author_website, $matches) ) {
156
+ $author_website = 'http://' . $author_website;
157
  }
158
  $author_link_rel = apply_filters( 'gwolle_gb_author_link_rel', 'nofollow noopener noreferrer' );
159
+ $author_name_html = '<a href="' . esc_attr( $author_website ) . '" target="_blank" rel="' . esc_attr( $author_link_rel ) . '"
160
+ title="' . esc_attr__( 'Visit the website of', 'gwolle-gb' ) . ' ' . esc_attr( $author_name ) . ': ' . esc_attr( $author_website ) . '">' . $author_name_html . '</a>';
161
  }
162
  }
163
 
164
  $author_name_html = apply_filters( 'gwolle_gb_author_name_html', $author_name_html, $entry );
165
 
166
  return $author_name_html;
167
+
168
  }
gwolle-gb-hooks.php CHANGED
@@ -23,13 +23,13 @@ function gwolle_gb_init() {
23
 
24
  $current_version = get_option( 'gwolle_gb_version' );
25
 
26
- if ($current_version && version_compare($current_version, GWOLLE_GB_VER, '<')) {
27
  // Upgrade, if this version differs from what the database says.
28
 
29
- if ( function_exists('is_multisite') && is_multisite() ) {
30
  $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
31
  foreach ($blogids as $blog_id) {
32
- switch_to_blog($blog_id);
33
  gwolle_gb_upgrade();
34
  restore_current_blog();
35
  }
@@ -38,7 +38,7 @@ function gwolle_gb_init() {
38
  }
39
  }
40
  }
41
- add_action('admin_init', 'gwolle_gb_init');
42
 
43
 
44
  /*
@@ -47,8 +47,8 @@ add_action('admin_init', 'gwolle_gb_init');
47
  *
48
  * @since 1.5.2
49
  */
50
- function gwolle_gb_activate_new_site($blog_id) {
51
- switch_to_blog($blog_id);
52
  gwolle_gb_install();
53
  restore_current_blog();
54
  }
@@ -81,16 +81,16 @@ function gwolle_gb_register() {
81
 
82
  // Register script for frontend. Load it later.
83
  wp_register_script( 'gwolle_gb_frontend_js', GWOLLE_GB_URL . 'frontend/js/gwolle-gb-frontend.js', 'jquery', GWOLLE_GB_VER, true );
84
- $dataToBePassed = array(
85
  'ajax_url' => admin_url('admin-ajax.php'),
86
  'load_message' => /* translators: Infinite Scroll */ esc_html__('Loading more...', 'gwolle-gb'),
87
  'end_message' => /* translators: Infinite Scroll */ esc_html__('No more entries.', 'gwolle-gb'),
88
  'honeypot' => gwolle_gb_get_field_name( 'honeypot' ),
89
  'honeypot2' => gwolle_gb_get_field_name( 'honeypot2' ),
90
  'timeout' => gwolle_gb_get_field_name( 'timeout' ),
91
- 'timeout2' => gwolle_gb_get_field_name( 'timeout2' )
92
  );
93
- wp_localize_script( 'gwolle_gb_frontend_js', 'gwolle_gb_frontend_script', $dataToBePassed );
94
 
95
  // Register style for frontend. Load it later.
96
  wp_register_style('gwolle_gb_frontend_css', GWOLLE_GB_URL . 'frontend/css/gwolle-gb-frontend.css', false, GWOLLE_GB_VER, 'screen');
@@ -104,10 +104,10 @@ add_action('wp_enqueue_scripts', 'gwolle_gb_register');
104
  * @since 3.0.0
105
  */
106
  function gwolle_gb_enqueue_markitup() {
107
- wp_enqueue_script( 'markitup', GWOLLE_GB_URL . 'frontend/markitup/jquery.markitup.js', 'jquery', GWOLLE_GB_VER, false );
108
  wp_enqueue_style('gwolle_gb_markitup_css', GWOLLE_GB_URL . 'frontend/markitup/style.css', false, GWOLLE_GB_VER, 'screen');
109
 
110
- $dataToBePassed = array(
111
  'bold' => /* translators: MarkItUp menu item */ esc_html__('Bold', 'gwolle-gb' ),
112
  'italic' => /* translators: MarkItUp menu item */ esc_html__('Italic', 'gwolle-gb' ),
113
  'bullet' => /* translators: MarkItUp menu item */ esc_html__('Bulleted List', 'gwolle-gb' ),
@@ -117,9 +117,9 @@ function gwolle_gb_enqueue_markitup() {
117
  'link' => /* translators: MarkItUp menu item */ esc_html__('Link', 'gwolle-gb' ),
118
  'linktext' => /* translators: MarkItUp menu item */ esc_html__('Your text to link...', 'gwolle-gb' ),
119
  'clean' => /* translators: MarkItUp menu item */ esc_html__('Clean', 'gwolle-gb' ),
120
- 'emoji' => /* translators: MarkItUp menu item */ esc_html__('Emoji', 'gwolle-gb' )
121
  );
122
- wp_localize_script( 'markitup', 'gwolle_gb_localize', $dataToBePassed );
123
  }
124
 
125
 
@@ -136,7 +136,7 @@ add_action('plugins_loaded', 'gwolle_gb_load_lang');
136
  * Add number of unchecked entries to admin bar, if > 0.
137
  */
138
  function gwolle_gb_admin_bar_menu( $wp_admin_bar ) {
139
- if ( !current_user_can('moderate_comments') )
140
  return;
141
 
142
  // Counter
@@ -144,7 +144,7 @@ function gwolle_gb_admin_bar_menu( $wp_admin_bar ) {
144
  array(
145
  'checked' => 'unchecked',
146
  'trash' => 'notrash',
147
- 'spam' => 'nospam'
148
  )
149
  );
150
 
23
 
24
  $current_version = get_option( 'gwolle_gb_version' );
25
 
26
+ if ( $current_version && version_compare($current_version, GWOLLE_GB_VER, '<') ) {
27
  // Upgrade, if this version differs from what the database says.
28
 
29
+ if ( is_multisite() ) {
30
  $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
31
  foreach ($blogids as $blog_id) {
32
+ switch_to_blog( $blog_id );
33
  gwolle_gb_upgrade();
34
  restore_current_blog();
35
  }
38
  }
39
  }
40
  }
41
+ add_action( 'init', 'gwolle_gb_init' );
42
 
43
 
44
  /*
47
  *
48
  * @since 1.5.2
49
  */
50
+ function gwolle_gb_activate_new_site( $blog_id ) {
51
+ switch_to_blog( $blog_id );
52
  gwolle_gb_install();
53
  restore_current_blog();
54
  }
81
 
82
  // Register script for frontend. Load it later.
83
  wp_register_script( 'gwolle_gb_frontend_js', GWOLLE_GB_URL . 'frontend/js/gwolle-gb-frontend.js', 'jquery', GWOLLE_GB_VER, true );
84
+ $data_to_be_passed = array(
85
  'ajax_url' => admin_url('admin-ajax.php'),
86
  'load_message' => /* translators: Infinite Scroll */ esc_html__('Loading more...', 'gwolle-gb'),
87
  'end_message' => /* translators: Infinite Scroll */ esc_html__('No more entries.', 'gwolle-gb'),
88
  'honeypot' => gwolle_gb_get_field_name( 'honeypot' ),
89
  'honeypot2' => gwolle_gb_get_field_name( 'honeypot2' ),
90
  'timeout' => gwolle_gb_get_field_name( 'timeout' ),
91
+ 'timeout2' => gwolle_gb_get_field_name( 'timeout2' ),
92
  );
93
+ wp_localize_script( 'gwolle_gb_frontend_js', 'gwolle_gb_frontend_script', $data_to_be_passed );
94
 
95
  // Register style for frontend. Load it later.
96
  wp_register_style('gwolle_gb_frontend_css', GWOLLE_GB_URL . 'frontend/css/gwolle-gb-frontend.css', false, GWOLLE_GB_VER, 'screen');
104
  * @since 3.0.0
105
  */
106
  function gwolle_gb_enqueue_markitup() {
107
+ wp_enqueue_script( 'markitup', GWOLLE_GB_URL . 'frontend/markitup/jquery.markitup.js', 'jquery', GWOLLE_GB_VER, true );
108
  wp_enqueue_style('gwolle_gb_markitup_css', GWOLLE_GB_URL . 'frontend/markitup/style.css', false, GWOLLE_GB_VER, 'screen');
109
 
110
+ $data_to_be_passed = array(
111
  'bold' => /* translators: MarkItUp menu item */ esc_html__('Bold', 'gwolle-gb' ),
112
  'italic' => /* translators: MarkItUp menu item */ esc_html__('Italic', 'gwolle-gb' ),
113
  'bullet' => /* translators: MarkItUp menu item */ esc_html__('Bulleted List', 'gwolle-gb' ),
117
  'link' => /* translators: MarkItUp menu item */ esc_html__('Link', 'gwolle-gb' ),
118
  'linktext' => /* translators: MarkItUp menu item */ esc_html__('Your text to link...', 'gwolle-gb' ),
119
  'clean' => /* translators: MarkItUp menu item */ esc_html__('Clean', 'gwolle-gb' ),
120
+ 'emoji' => /* translators: MarkItUp menu item */ esc_html__('Emoji', 'gwolle-gb' ),
121
  );
122
+ wp_localize_script( 'markitup', 'gwolle_gb_localize', $data_to_be_passed );
123
  }
124
 
125
 
136
  * Add number of unchecked entries to admin bar, if > 0.
137
  */
138
  function gwolle_gb_admin_bar_menu( $wp_admin_bar ) {
139
+ if ( ! current_user_can('moderate_comments') )
140
  return;
141
 
142
  // Counter
144
  array(
145
  'checked' => 'unchecked',
146
  'trash' => 'notrash',
147
+ 'spam' => 'nospam',
148
  )
149
  );
150
 
gwolle-gb.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Gwolle Guestbook
4
  Plugin URI: https://wordpress.org/plugins/gwolle-gb/
5
  Description: Gwolle Guestbook is not just another guestbook for WordPress. The goal is to provide an easy and slim way to integrate a guestbook into your WordPress powered site. Don't use your 'comment' section the wrong way - install Gwolle Guestbook and have a real guestbook.
6
- Version: 4.1.2
7
  Author: Marcel Pol
8
  Author URI: https://zenoweb.nl
9
  License: GPLv2 or later
@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
 
32
 
33
  // Plugin Version
34
- define('GWOLLE_GB_VER', '4.1.2');
35
 
36
 
37
  /*
@@ -62,8 +62,11 @@ define('GWOLLE_GB_VER', '4.1.2');
62
  * - Use select2 or similar for subscribe/unsubcribe dropdowns.
63
  * - On one-page-design, paging doesn't work correctly in Chrome:
64
  * https://wordpress.org/support/topic/problem-of-text-selection-in-gwolle-guestbook/
 
65
  * - Use more CSS transitions and SVG icons.
66
  * - Use CSS classes from contactform plugins, when they are active.
 
 
67
  *
68
  */
69
 
@@ -84,74 +87,74 @@ $wpdb->gwolle_gb_log = $wpdb->prefix . 'gwolle_gb_log';
84
 
85
 
86
  // Classes
87
- include_once( GWOLLE_GB_DIR . '/functions/gb-class-entry.php' );
88
 
89
  // Functions for the frontend
90
- include_once( GWOLLE_GB_DIR . '/frontend/gb-ajax-infinite-scroll.php' );
91
- include_once( GWOLLE_GB_DIR . '/frontend/gb-blocklist.php' );
92
- include_once( GWOLLE_GB_DIR . '/frontend/gb-form.php' );
93
- include_once( GWOLLE_GB_DIR . '/frontend/gb-form-ajax.php' );
94
- include_once( GWOLLE_GB_DIR . '/frontend/gb-form-posthandling.php' );
95
- include_once( GWOLLE_GB_DIR . '/frontend/gb-shortcode-widget.php' );
96
- include_once( GWOLLE_GB_DIR . '/frontend/gb-shortcodes.php' );
97
- include_once( GWOLLE_GB_DIR . '/frontend/gb-pagination.php' );
98
- include_once( GWOLLE_GB_DIR . '/frontend/gb-read.php' );
99
- include_once( GWOLLE_GB_DIR . '/frontend/gb-rss.php' );
100
- include_once( GWOLLE_GB_DIR . '/frontend/gb-total.php' );
101
- include_once( GWOLLE_GB_DIR . '/frontend/gb-widget.php' );
102
- include_once( GWOLLE_GB_DIR . '/frontend/gb-widget-search.php' );
103
 
104
  // Functions and pages for the backend
105
  if ( is_admin() ) {
106
- include_once( GWOLLE_GB_DIR . '/admin/gb-ajax-management.php' );
107
- include_once( GWOLLE_GB_DIR . '/admin/gb-dashboard-widget.php' );
108
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-add-on.php' );
109
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-editor.php' );
110
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-entries.php' );
111
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-export.php' );
112
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-gwolle-gb.php' );
113
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-import.php' );
114
- include_once( GWOLLE_GB_DIR . '/admin/gb-page-settings.php' );
115
- include_once( GWOLLE_GB_DIR . '/admin/gb-pagination.php' );
116
- include_once( GWOLLE_GB_DIR . '/admin/gwolle-gb-hooks.php' );
117
  }
118
- include_once( GWOLLE_GB_DIR . '/admin/gb-upgrade.php' );
119
 
120
  // Tabs for gb-page-settings.php
121
  if ( is_admin() ) {
122
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-formtab.php' );
123
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-readingtab.php' );
124
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-admintab.php' );
125
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-antispamtab.php' );
126
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-emailtab.php' );
127
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-debugtab.php' );
128
- include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-uninstalltab.php' );
129
  }
130
 
131
  // General Functions
132
- include_once( GWOLLE_GB_DIR . '/functions/gb-akismet.php' );
133
- include_once( GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php' );
134
- include_once( GWOLLE_GB_DIR . '/functions/gb-book_id.php' );
135
- include_once( GWOLLE_GB_DIR . '/functions/gb-cache.php' );
136
- include_once( GWOLLE_GB_DIR . '/functions/gb-debug.php' );
137
- include_once( GWOLLE_GB_DIR . '/functions/gb-fields.php' );
138
- include_once( GWOLLE_GB_DIR . '/functions/gb-formatting.php' );
139
- include_once( GWOLLE_GB_DIR . '/functions/gb-get_entries.php' );
140
- include_once( GWOLLE_GB_DIR . '/functions/gb-get_entries_from_search.php' );
141
- include_once( GWOLLE_GB_DIR . '/functions/gb-log.php' );
142
- include_once( GWOLLE_GB_DIR . '/functions/gb-mail.php' );
143
- include_once( GWOLLE_GB_DIR . '/functions/gb-messages.php' );
144
- include_once( GWOLLE_GB_DIR . '/functions/gb-metabox.php' );
145
- include_once( GWOLLE_GB_DIR . '/functions/gb-post-meta.php' );
146
- include_once( GWOLLE_GB_DIR . '/functions/gb-privacy.php' );
147
- include_once( GWOLLE_GB_DIR . '/functions/gb-settings.php' );
148
- include_once( GWOLLE_GB_DIR . '/functions/gb-single-view.php' );
149
- include_once( GWOLLE_GB_DIR . '/functions/gb-stop-forum-spam.php' );
150
- include_once( GWOLLE_GB_DIR . '/functions/gb-user.php' );
151
- include_once( GWOLLE_GB_DIR . '/functions/gb-user-ip.php' );
152
 
153
  // General Hooks
154
- include_once( GWOLLE_GB_DIR . '/gwolle-gb-hooks.php' );
155
 
156
 
157
  /*
@@ -162,21 +165,21 @@ function gwolle_gb_activation( $networkwide ) {
162
 
163
  $current_version = get_option( 'gwolle_gb_version' );
164
 
165
- if ( function_exists('is_multisite') && is_multisite() ) {
166
  $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
167
  foreach ($blogids as $blog_id) {
168
  switch_to_blog($blog_id);
169
- if ( $current_version == false ) {
170
  gwolle_gb_install();
171
- } elseif ($current_version != GWOLLE_GB_VER) {
172
  gwolle_gb_upgrade();
173
  }
174
  restore_current_blog();
175
  }
176
  } else {
177
- if ( $current_version == false ) {
178
  gwolle_gb_install();
179
- } elseif ($current_version != GWOLLE_GB_VER) {
180
  gwolle_gb_upgrade();
181
  }
182
  }
3
  Plugin Name: Gwolle Guestbook
4
  Plugin URI: https://wordpress.org/plugins/gwolle-gb/
5
  Description: Gwolle Guestbook is not just another guestbook for WordPress. The goal is to provide an easy and slim way to integrate a guestbook into your WordPress powered site. Don't use your 'comment' section the wrong way - install Gwolle Guestbook and have a real guestbook.
6
+ Version: 4.2.0
7
  Author: Marcel Pol
8
  Author URI: https://zenoweb.nl
9
  License: GPLv2 or later
31
 
32
 
33
  // Plugin Version
34
+ define('GWOLLE_GB_VER', '4.2.0');
35
 
36
 
37
  /*
62
  * - Use select2 or similar for subscribe/unsubcribe dropdowns.
63
  * - On one-page-design, paging doesn't work correctly in Chrome:
64
  * https://wordpress.org/support/topic/problem-of-text-selection-in-gwolle-guestbook/
65
+ * Using AJAX for pagination would solve this.
66
  * - Use more CSS transitions and SVG icons.
67
  * - Use CSS classes from contactform plugins, when they are active.
68
+ * - Have custom capability through a filter instead of `moderate_comments`.
69
+ * https://wordpress.org/support/topic/user-roles-changing/
70
  *
71
  */
72
 
87
 
88
 
89
  // Classes
90
+ require_once GWOLLE_GB_DIR . '/functions/gb-class-entry.php';
91
 
92
  // Functions for the frontend
93
+ require_once GWOLLE_GB_DIR . '/frontend/gb-ajax-infinite-scroll.php';
94
+ require_once GWOLLE_GB_DIR . '/frontend/gb-blocklist.php';
95
+ require_once GWOLLE_GB_DIR . '/frontend/gb-form.php';
96
+ require_once GWOLLE_GB_DIR . '/frontend/gb-form-ajax.php';
97
+ require_once GWOLLE_GB_DIR . '/frontend/gb-form-posthandling.php';
98
+ require_once GWOLLE_GB_DIR . '/frontend/gb-shortcode-widget.php';
99
+ require_once GWOLLE_GB_DIR . '/frontend/gb-shortcodes.php';
100
+ require_once GWOLLE_GB_DIR . '/frontend/gb-pagination.php';
101
+ require_once GWOLLE_GB_DIR . '/frontend/gb-read.php';
102
+ require_once GWOLLE_GB_DIR . '/frontend/gb-rss.php';
103
+ require_once GWOLLE_GB_DIR . '/frontend/gb-total.php';
104
+ require_once GWOLLE_GB_DIR . '/frontend/gb-widget.php';
105
+ require_once GWOLLE_GB_DIR . '/frontend/gb-widget-search.php';
106
 
107
  // Functions and pages for the backend
108
  if ( is_admin() ) {
109
+ require_once GWOLLE_GB_DIR . '/admin/gb-ajax-management.php';
110
+ require_once GWOLLE_GB_DIR . '/admin/gb-dashboard-widget.php';
111
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-add-on.php';
112
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-editor.php';
113
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-entries.php';
114
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-export.php';
115
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-gwolle-gb.php';
116
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-import.php';
117
+ require_once GWOLLE_GB_DIR . '/admin/gb-page-settings.php';
118
+ require_once GWOLLE_GB_DIR . '/admin/gb-pagination.php';
119
+ require_once GWOLLE_GB_DIR . '/admin/gwolle-gb-hooks.php';
120
  }
121
+ require_once GWOLLE_GB_DIR . '/admin/gb-upgrade.php';
122
 
123
  // Tabs for gb-page-settings.php
124
  if ( is_admin() ) {
125
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-formtab.php';
126
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-readingtab.php';
127
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-admintab.php';
128
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-antispamtab.php';
129
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-emailtab.php';
130
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-debugtab.php';
131
+ require_once GWOLLE_GB_DIR . '/admin/tabs/gb-uninstalltab.php';
132
  }
133
 
134
  // General Functions
135
+ require_once GWOLLE_GB_DIR . '/functions/gb-akismet.php';
136
+ require_once GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php';
137
+ require_once GWOLLE_GB_DIR . '/functions/gb-book_id.php';
138
+ require_once GWOLLE_GB_DIR . '/functions/gb-cache.php';
139
+ require_once GWOLLE_GB_DIR . '/functions/gb-debug.php';
140
+ require_once GWOLLE_GB_DIR . '/functions/gb-fields.php';
141
+ require_once GWOLLE_GB_DIR . '/functions/gb-formatting.php';
142
+ require_once GWOLLE_GB_DIR . '/functions/gb-get_entries.php';
143
+ require_once GWOLLE_GB_DIR . '/functions/gb-get_entries_from_search.php';
144
+ require_once GWOLLE_GB_DIR . '/functions/gb-log.php';
145
+ require_once GWOLLE_GB_DIR . '/functions/gb-mail.php';
146
+ require_once GWOLLE_GB_DIR . '/functions/gb-messages.php';
147
+ require_once GWOLLE_GB_DIR . '/functions/gb-metabox.php';
148
+ require_once GWOLLE_GB_DIR . '/functions/gb-post-meta.php';
149
+ require_once GWOLLE_GB_DIR . '/functions/gb-privacy.php';
150
+ require_once GWOLLE_GB_DIR . '/functions/gb-settings.php';
151
+ require_once GWOLLE_GB_DIR . '/functions/gb-single-view.php';
152
+ require_once GWOLLE_GB_DIR . '/functions/gb-stop-forum-spam.php';
153
+ require_once GWOLLE_GB_DIR . '/functions/gb-user.php';
154
+ require_once GWOLLE_GB_DIR . '/functions/gb-user-ip.php';
155
 
156
  // General Hooks
157
+ require_once GWOLLE_GB_DIR . '/gwolle-gb-hooks.php';
158
 
159
 
160
  /*
165
 
166
  $current_version = get_option( 'gwolle_gb_version' );
167
 
168
+ if ( is_multisite() ) {
169
  $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
170
  foreach ($blogids as $blog_id) {
171
  switch_to_blog($blog_id);
172
+ if ( $current_version === false ) {
173
  gwolle_gb_install();
174
+ } else if ($current_version !== GWOLLE_GB_VER) {
175
  gwolle_gb_upgrade();
176
  }
177
  restore_current_blog();
178
  }
179
  } else {
180
+ if ( $current_version === false ) {
181
  gwolle_gb_install();
182
+ } else if ($current_version !== GWOLLE_GB_VER) {
183
  gwolle_gb_upgrade();
184
  }
185
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Gwolle, mpol
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 3.7
5
  Tested up to: 5.8
6
- Stable tag: 4.1.2
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
@@ -432,6 +432,20 @@ But if you don't use standard comments, you can just as easily use the comment s
432
 
433
  == Changelog ==
434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  = 4.1.2 =
436
  * 2021-05-05
437
  * Add more classes to text elements, for better customization.
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 3.7
5
  Tested up to: 5.8
6
+ Stable tag: 4.2.0
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
432
 
433
  == Changelog ==
434
 
435
+ = 4.2.0 =
436
+ * 2021-11-18
437
+ * Security fix for CSRF, use 'sanitize_text_field' for user_email on author search.
438
+ * Thanks Erwan from wpscan.
439
+ * Use more 'esc_attr' when appropriate.
440
+ * Add option for character limit in content of entry.
441
+ * Add function 'gwolle_gb_check_maxlength'.
442
+ * Add function 'gwolle_gb_count_characters'.
443
+ * Load markitup.js in footer.
444
+ * Run update hook in 'init' instead of 'admin_init' to support background updates.
445
+ * No need to check if function 'current_user_can', 'user_can', 'is_multisite' and 'has_shortcode' exist.
446
+ * Drop support for WP 3.4 and using 'get_current_theme'.
447
+ * Some updates from phpcs and wpcs.
448
+
449
  = 4.1.2 =
450
  * 2021-05-05
451
  * Add more classes to text elements, for better customization.