Gwolle Guestbook - Version 2.6.0

Version Description

  • 2018-06-11
  • Add option to permanently remove IP address and hostname from entries.
  • Add cancel button for the form.
  • Close metabox again after click event.
  • Remove %ip% from default notice text.
  • Add example text to the privacy policy.
  • Refactor link to privacy policy.
  • Included real fix for not handling form data on some installs.
  • Show on editor if author was logged in or not.
  • Add log message to mail notification with writing time like on editor.
  • Add guestbook entries to WordPress personal data exporter.
  • Add guestbook entries to WordPress personal data eraser.
  • Add anonymize option to mass edit.
  • Add 'gwolle_gb_privacy_anonymize_entry' function.
  • Add 'gwolle_gb_get_permalinks' function.
  • Add 'gwolle_gb_get_total_entries' function.
  • Deprecate 'gwolle_gb_addon_get_total_entries' function.
  • Use 'admin_url' everywhere.
  • Updates for Add-On 1.2.0.
Download this release

Release Info

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

Code changes from version 2.5.4 to 2.6.0

add-on/gb-add-on.php CHANGED
@@ -4,6 +4,13 @@
4
  * http://www.mojomarketplace.com/item/gwolle-gb-add-on
5
  */
6
 
 
 
 
 
 
 
 
7
  function gwolle_gb_addon_translation_strings() {
8
 
9
  // description of readme
@@ -37,6 +44,40 @@ function gwolle_gb_addon_translation_strings() {
37
 
38
  // function gwolle_gb_admin_reply_javascript() {
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  // function gwolle_gb_entry_metabox_lines_delete_link( $gb_metabox, $entry ) {
41
  /* translators: Commercial Add-On */
42
  esc_attr__('Delete entry', 'gwolle-gb');
@@ -190,6 +231,14 @@ function gwolle_gb_addon_translation_strings() {
190
  /* translators: Commercial Add-On */
191
  esc_html_e('+ Add new string.', 'gwolle-gb');
192
 
 
 
 
 
 
 
 
 
193
  // function gwolle_gb_addon_starrating_average_html()
194
  /* translators: Commercial Add-On. %s is the value/number of votes. */
195
  __( 'Average Rating: <strong>%s out of %s</strong> (%s votes)', 'gwolle-gb' );
4
  * http://www.mojomarketplace.com/item/gwolle-gb-add-on
5
  */
6
 
7
+
8
+ // No direct calls to this script
9
+ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
10
+ die('No direct calls allowed!');
11
+ }
12
+
13
+
14
  function gwolle_gb_addon_translation_strings() {
15
 
16
  // description of readme
44
 
45
  // function gwolle_gb_admin_reply_javascript() {
46
 
47
+ // function gwolle_gb_entry_metabox_lines_report_abuse( $gb_metabox, $entry ) {
48
+ /* translators: Commercial Add-On */
49
+ esc_attr__('Report Abuse for this entry', 'gwolle-gb');
50
+ /* translators: Commercial Add-On, frontend metabox */
51
+ esc_html__('Report Abuse', 'gwolle-gb');
52
+
53
+ // function gwolle_gb_report_abuse_javascript()
54
+ /* translators: Commercial Add-On, abuse report submitted */
55
+ esc_html__('Reported', 'gwolle-gb');
56
+ /* translators: Commercial Add-On, error on abuse report */
57
+ esc_html__('Error', 'gwolle-gb');
58
+
59
+ // gwolle_gb_addon_mail_moderators_report_abuse()
60
+ /* translators: Commercial Add-On, mail notification on abuse report */
61
+ esc_html__("
62
+ Hello,
63
+
64
+ There was a report for abuse for a guestbook entry at '%blog_name%'.
65
+ You can check it at %entry_management_url%.
66
+
67
+ Have a nice day.
68
+ Your Gwolle-GB-Mailer
69
+
70
+
71
+ Website address: %blog_url%
72
+ User name: %user_name%
73
+ User email: %user_email%
74
+ Entry status: %status%
75
+ Reports: %reports%
76
+ Entry content:
77
+ %entry_content%
78
+ "
79
+ , 'gwolle-gb');
80
+
81
  // function gwolle_gb_entry_metabox_lines_delete_link( $gb_metabox, $entry ) {
82
  /* translators: Commercial Add-On */
83
  esc_attr__('Delete entry', 'gwolle-gb');
231
  /* translators: Commercial Add-On */
232
  esc_html_e('+ Add new string.', 'gwolle-gb');
233
 
234
+ // gwolle_gb_addon_editor_metabox_meta()
235
+ /* translators: Commercial Add-On, metabox on editor */
236
+ esc_html__('Abuse Reports', 'gwolle-gb');
237
+ /* translators: Commercial Add-On, remove abuse reports and moderate entry */
238
+ esc_html__('Remove and moderate', 'gwolle-gb');
239
+ /* translators: Commercial Add-On */
240
+ esc_html__('Already moderated', 'gwolle-gb');
241
+
242
  // function gwolle_gb_addon_starrating_average_html()
243
  /* translators: Commercial Add-On. %s is the value/number of votes. */
244
  __( 'Average Rating: <strong>%s out of %s</strong> (%s votes)', 'gwolle-gb' );
admin/css/gwolle-gb-admin.css CHANGED
@@ -309,7 +309,6 @@ span.gwolle_gb_ajax {
309
  position: absolute;
310
  bottom: 0;
311
  left: 150px;
312
-
313
  }
314
 
315
 
@@ -339,3 +338,7 @@ form.gwolle_gb_options.gwolle_gb_strings td {
339
  .gb-string-add-new {
340
  cursor: pointer;
341
  }
 
 
 
 
309
  position: absolute;
310
  bottom: 0;
311
  left: 150px;
 
312
  }
313
 
314
 
338
  .gb-string-add-new {
339
  cursor: pointer;
340
  }
341
+
342
+ span.gwolle-gb-report-abuse-positive a {
343
+ cursor: pointer;
344
+ }
admin/gb-dashboard-widget.php CHANGED
@@ -26,19 +26,19 @@ function gwolle_gb_dashboard() {
26
  'spam' => 'nospam'
27
  ));
28
 
29
- if ( is_array($entries) && !empty($entries) ) {
30
 
31
  // List of guestbook entries
32
  echo '<div class="gwolle-gb-dashboard gwolle-gb">';
33
- $rowOdd = false;
34
  foreach ( $entries as $entry ) {
35
  $class = '';
36
  // rows have a different color.
37
- if ($rowOdd) {
38
- $rowOdd = false;
39
  $class = ' alternate';
40
  } else {
41
- $rowOdd = true;
42
  $class = '';
43
  }
44
 
@@ -108,7 +108,7 @@ function gwolle_gb_dashboard() {
108
  ?>
109
  <p class="row-actions" id="entry-actions-<?php echo $entry->get_id(); ?>">
110
  <span class="gwolle_gb_edit">
111
- <a href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/editor.php&entry_id=<?php echo $entry->get_id(); ?>" title="<?php esc_attr_e('Edit entry', 'gwolle-gb'); ?>"><?php esc_html_e('Edit', 'gwolle-gb'); ?></a>
112
  </span>
113
  <span class="gwolle_gb_check">
114
  &nbsp;|&nbsp;
26
  'spam' => 'nospam'
27
  ));
28
 
29
+ if ( is_array($entries) && ! empty($entries) ) {
30
 
31
  // List of guestbook entries
32
  echo '<div class="gwolle-gb-dashboard gwolle-gb">';
33
+ $rowodd = false;
34
  foreach ( $entries as $entry ) {
35
  $class = '';
36
  // rows have a different color.
37
+ if ($rowodd) {
38
+ $rowodd = false;
39
  $class = ' alternate';
40
  } else {
41
+ $rowodd = true;
42
  $class = '';
43
  }
44
 
108
  ?>
109
  <p class="row-actions" id="entry-actions-<?php echo $entry->get_id(); ?>">
110
  <span class="gwolle_gb_edit">
111
+ <a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() ); ?>" title="<?php esc_attr_e('Edit entry', 'gwolle-gb'); ?>"><?php esc_html_e('Edit', 'gwolle-gb'); ?></a>
112
  </span>
113
  <span class="gwolle_gb_check">
114
  &nbsp;|&nbsp;
admin/gb-page-add-on.php CHANGED
@@ -84,6 +84,7 @@ function gwolle_gb_addon_features() {
84
  <li>' . esc_html__('Preview for the frontend form.','gwolle-gb').'</li>
85
  <li>' . esc_html__('Preview for the admin editor form.','gwolle-gb').'</li>
86
  <li>' . esc_html__('Admin reply on the frontend with AJAX.','gwolle-gb').'</li>
 
87
  <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>
88
  <li>' . esc_html__('Delete button in each entry for the moderator and author (optional).','gwolle-gb').'</li>
89
  <li>' . esc_html__('Permalink button in each entry for easy access (optional).','gwolle-gb').'</li>
84
  <li>' . esc_html__('Preview for the frontend form.','gwolle-gb').'</li>
85
  <li>' . esc_html__('Preview for the admin editor form.','gwolle-gb').'</li>
86
  <li>' . esc_html__('Admin reply on the frontend with AJAX.','gwolle-gb').'</li>
87
+ <li>' . esc_html__('Report Abuse.','gwolle-gb').'</li>
88
  <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>
89
  <li>' . esc_html__('Delete button in each entry for the moderator and author (optional).','gwolle-gb').'</li>
90
  <li>' . esc_html__('Permalink button in each entry for easy access (optional).','gwolle-gb').'</li>
admin/gb-page-editor.php CHANGED
@@ -362,7 +362,7 @@ function gwolle_gb_page_editor() {
362
  add_meta_box('gwolle_gb_editor_postbox_preview', esc_html__('Preview','gwolle-gb'), 'gwolle_gb_addon_editor_postbox_preview', 'gwolle_gb_editor', 'normal');
363
  }
364
  if ( $active && function_exists( 'gwolle_gb_addon_editor_metabox_meta' ) ) {
365
- add_meta_box('gwolle_gb_addon_editor_metabox_meta', esc_html__('Meta Fields','gwolle-gb'), 'gwolle_gb_addon_editor_metabox_meta', 'gwolle_gb_editor', 'normal');
366
  }
367
 
368
  do_meta_boxes( 'gwolle_gb_editor', 'normal', $entry );
@@ -394,8 +394,9 @@ function gwolle_gb_editor_postbox_content( $entry ) {
394
  <textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji" tabindex="1" placeholder="<?php esc_html_e('Message', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_content(), 'content' ); ?></textarea>
395
  <?php
396
  if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
 
397
  /* translators: %s is a link */
398
- echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), '<a href="admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php">', '</a>' ) . '</p>';
399
  }
400
  $form_setting = gwolle_gb_get_setting( 'form' );
401
 
@@ -496,8 +497,9 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
496
 
497
  <?php
498
  if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
 
499
  /* translators: %s is a link */
500
- echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), '<a href="admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php">', '</a>' ) . '</p>';
501
  }
502
  }
503
 
@@ -697,6 +699,13 @@ function gwolle_gb_editor_postbox_details( $entry ) {
697
  echo '(' . esc_html__('Not yet', 'gwolle-gb') . ')';
698
  } ?>
699
  </span><br />
 
 
 
 
 
 
 
700
  <?php esc_html_e("Author's IP-address", 'gwolle-gb'); ?>: <span><?php
701
  if (strlen( $entry->get_author_ip() ) > 0) {
702
  echo '<a href="http://www.db.ripe.net/whois?form_type=simple&searchtext=' . $entry->get_author_ip() . '"
362
  add_meta_box('gwolle_gb_editor_postbox_preview', esc_html__('Preview','gwolle-gb'), 'gwolle_gb_addon_editor_postbox_preview', 'gwolle_gb_editor', 'normal');
363
  }
364
  if ( $active && function_exists( 'gwolle_gb_addon_editor_metabox_meta' ) ) {
365
+ 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');
366
  }
367
 
368
  do_meta_boxes( 'gwolle_gb_editor', 'normal', $entry );
394
  <textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji" tabindex="1" placeholder="<?php esc_html_e('Message', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_content(), 'content' ); ?></textarea>
395
  <?php
396
  if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
397
+ $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
398
  /* translators: %s is a link */
399
+ echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), $settingslink, '</a>' ) . '</p>';
400
  }
401
  $form_setting = gwolle_gb_get_setting( 'form' );
402
 
497
 
498
  <?php
499
  if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
500
+ $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
501
  /* translators: %s is a link */
502
+ echo '<p>' . sprintf( esc_html__('Line breaks will not be visible to the visitors due to your %ssettings%s.', 'gwolle-gb'), $settingslink, '</a>' ) . '</p>';
503
  }
504
  }
505
 
699
  echo '(' . esc_html__('Not yet', 'gwolle-gb') . ')';
700
  } ?>
701
  </span><br />
702
+ <?php esc_html_e('Logged in', 'gwolle-gb'); ?>: <span><?php
703
+ if ( (int) $entry->get_author_id() > 0 ) {
704
+ esc_html_e('Yes', 'gwolle-gb');
705
+ } else {
706
+ esc_html_e('No', 'gwolle-gb');
707
+ } ?>
708
+ </span><br />
709
  <?php esc_html_e("Author's IP-address", 'gwolle-gb'); ?>: <span><?php
710
  if (strlen( $entry->get_author_ip() ) > 0) {
711
  echo '<a href="http://www.db.ripe.net/whois?form_type=simple&searchtext=' . $entry->get_author_ip() . '"
admin/gb-page-entries.php CHANGED
@@ -43,6 +43,8 @@ function gwolle_gb_page_entries() {
43
  $action = 'untrash';
44
  } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'remove' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'remove' ) ) {
45
  $action = 'remove';
 
 
46
  }
47
 
48
 
@@ -237,6 +239,16 @@ function gwolle_gb_page_entries() {
237
  } else {
238
  $entries_not_handled++;
239
  }
 
 
 
 
 
 
 
 
 
 
240
  }
241
  } else { // no result on load()
242
  $entries_not_handled++;
@@ -287,6 +299,9 @@ function gwolle_gb_page_entries() {
287
  } else if ( $action == 'remove' ) {
288
  /* translators: %s is the number of entries */
289
  $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
 
 
 
290
  }
291
  }
292
 
@@ -469,29 +484,29 @@ function gwolle_gb_page_entries() {
469
  ?>
470
 
471
  <ul class="subsubsub">
472
- <li><a href='admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php' <?php
473
  if ($show == 'all') { echo 'class="current"'; }
474
  ?>>
475
  <?php esc_html_e('All', 'gwolle-gb'); ?> <span class="count gwolle_gb_all">(<?php echo $count['all']; ?>)</span></a> |
476
  </li>
477
- <li><a href='admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=checked' <?php
478
  if ($show == 'checked') { echo 'class="current"'; }
479
  ?>>
480
  <?php esc_html_e('Unlocked', 'gwolle-gb'); ?> <span class="count gwolle_gb_unlocked">(<?php echo $count['checked']; ?>)</span></a> |
481
  </li>
482
- <li><a href='admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=unchecked' <?php
483
  if ($show == 'unchecked') { echo 'class="current"'; }
484
  ?>><?php esc_html_e('New', 'gwolle-gb'); ?> <span class="count gwolle_gb_new">(<?php echo $count['unchecked']; ?>)</span></a> |
485
  </li>
486
- <li><a href='admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=spam' <?php
487
  if ($show == 'spam') { echo 'class="current"'; }
488
  ?>><?php esc_html_e('Spam', 'gwolle-gb'); ?> <span class="count gwolle_gb_spam_">(<?php echo $count['spam']; ?>)</span></a> |
489
  </li>
490
- <li><a href='admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=trash' <?php
491
  if ($show == 'trash') { echo 'class="current"'; }
492
  ?>><?php /* translators: Is in Trashcan */ esc_html_e('In Trash', 'gwolle-gb'); ?> <span class="count gwolle_gb_trash_">(<?php echo $count['trash']; ?>)</span></a> |
493
  </li>
494
- <li><a href='admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=user' <?php
495
  if ($show == 'user') { echo 'class="current"'; }
496
  ?>><?php esc_html_e('Author', 'gwolle-gb'); ?></a>
497
  </li>
@@ -540,6 +555,7 @@ function gwolle_gb_page_entries() {
540
  if ( $show == 'spam' ) {
541
  $massEditControls .= '<option value="remove">' . esc_html__('Remove permanently', 'gwolle-gb') . '</option>';
542
  }
 
543
 
544
  }
545
  $massEditControls .= '</select>';
@@ -729,7 +745,7 @@ function gwolle_gb_page_entries() {
729
  $html_output .= '
730
  <td class="gwolle_gb_actions">
731
  <span class="gwolle_gb_edit">
732
- <a href="admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() . '" title="' . esc_attr__('Edit entry', 'gwolle-gb') . '">' . esc_html__('Edit', 'gwolle-gb') . '</a>
733
  </span>
734
  <span class="gwolle_gb_check">&nbsp;|&nbsp;
735
  <a id="check_' . $entry->get_id() . '" href="#" class="vim-a" title="' . esc_attr__('Check entry', 'gwolle-gb') . '">' . esc_html__('Check', 'gwolle-gb') . '</a>
43
  $action = 'untrash';
44
  } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'remove' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'remove' ) ) {
45
  $action = 'remove';
46
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'anon' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'anon' ) ) {
47
+ $action = 'anon';
48
  }
49
 
50
 
239
  } else {
240
  $entries_not_handled++;
241
  }
242
+ } else if ( $action == 'anon' ) {
243
+ $entry = gwolle_gb_privacy_anonymize_entry( $entry );
244
+ $result = $entry->save();
245
+ if ( $result ) {
246
+ $entries_handled++;
247
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
248
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-anonymized' );
249
+ } else {
250
+ $entries_not_handled++;
251
+ }
252
  }
253
  } else { // no result on load()
254
  $entries_not_handled++;
299
  } else if ( $action == 'remove' ) {
300
  /* translators: %s is the number of entries */
301
  $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
302
+ } else if ( $action == 'anon' ) {
303
+ /* translators: %s is the number of entries */
304
+ $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry anonymized.','%s entries anonymized.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
305
  }
306
  }
307
 
484
  ?>
485
 
486
  <ul class="subsubsub">
487
+ <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=all' ); ?>" <?php
488
  if ($show == 'all') { echo 'class="current"'; }
489
  ?>>
490
  <?php esc_html_e('All', 'gwolle-gb'); ?> <span class="count gwolle_gb_all">(<?php echo $count['all']; ?>)</span></a> |
491
  </li>
492
+ <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=checked' ); ?>" <?php
493
  if ($show == 'checked') { echo 'class="current"'; }
494
  ?>>
495
  <?php esc_html_e('Unlocked', 'gwolle-gb'); ?> <span class="count gwolle_gb_unlocked">(<?php echo $count['checked']; ?>)</span></a> |
496
  </li>
497
+ <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=unchecked' ); ?>" <?php
498
  if ($show == 'unchecked') { echo 'class="current"'; }
499
  ?>><?php esc_html_e('New', 'gwolle-gb'); ?> <span class="count gwolle_gb_new">(<?php echo $count['unchecked']; ?>)</span></a> |
500
  </li>
501
+ <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=spam' ); ?>" <?php
502
  if ($show == 'spam') { echo 'class="current"'; }
503
  ?>><?php esc_html_e('Spam', 'gwolle-gb'); ?> <span class="count gwolle_gb_spam_">(<?php echo $count['spam']; ?>)</span></a> |
504
  </li>
505
+ <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=trash' ); ?>" <?php
506
  if ($show == 'trash') { echo 'class="current"'; }
507
  ?>><?php /* translators: Is in Trashcan */ esc_html_e('In Trash', 'gwolle-gb'); ?> <span class="count gwolle_gb_trash_">(<?php echo $count['trash']; ?>)</span></a> |
508
  </li>
509
+ <li><a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=user' ); ?>" <?php
510
  if ($show == 'user') { echo 'class="current"'; }
511
  ?>><?php esc_html_e('Author', 'gwolle-gb'); ?></a>
512
  </li>
555
  if ( $show == 'spam' ) {
556
  $massEditControls .= '<option value="remove">' . esc_html__('Remove permanently', 'gwolle-gb') . '</option>';
557
  }
558
+ $massEditControls .= '<option value="anon">' . esc_html__('Anonymize', 'gwolle-gb') . '</option>';
559
 
560
  }
561
  $massEditControls .= '</select>';
745
  $html_output .= '
746
  <td class="gwolle_gb_actions">
747
  <span class="gwolle_gb_edit">
748
+ <a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() ) . '" title="' . esc_attr__('Edit entry', 'gwolle-gb') . '">' . esc_html__('Edit', 'gwolle-gb') . '</a>
749
  </span>
750
  <span class="gwolle_gb_check">&nbsp;|&nbsp;
751
  <a id="check_' . $entry->get_id() . '" href="#" class="vim-a" title="' . esc_attr__('Check entry', 'gwolle-gb') . '">' . esc_html__('Check', 'gwolle-gb') . '</a>
admin/gb-page-gwolle-gb.php CHANGED
@@ -98,7 +98,7 @@ function gwolle_gb_overview(){
98
  <tbody>
99
  <tr class="first">
100
  <td class="first b">
101
- <a href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php">
102
  <?php echo $count['all']; ?>
103
  </a>
104
  </td>
@@ -112,7 +112,7 @@ function gwolle_gb_overview(){
112
 
113
  <tr>
114
  <td class="first b">
115
- <a href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=checked">
116
  <?php echo $count['checked']; ?>
117
  </a></td>
118
  <td class="t" style="color:#008000;">
@@ -124,7 +124,7 @@ function gwolle_gb_overview(){
124
 
125
  <tr>
126
  <td class="first b">
127
- <a href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=unchecked">
128
  <?php echo $count['unchecked']; ?>
129
  </a></td>
130
  <td class="t" style="color:#ff6f00;">
@@ -136,7 +136,7 @@ function gwolle_gb_overview(){
136
 
137
  <tr>
138
  <td class="first b">
139
- <a href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=spam">
140
  <?php echo $count['spam']; ?>
141
  </a></td>
142
  <td class="t" style="color:#FF0000;">
@@ -148,7 +148,7 @@ function gwolle_gb_overview(){
148
 
149
  <tr>
150
  <td class="first b">
151
- <a href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/entries.php&amp;show=trash">
152
  <?php echo $count['trash']; ?>
153
  </a></td>
154
  <td class="t" style="color:#FF0000;">
@@ -171,7 +171,7 @@ function gwolle_gb_overview(){
171
  <a class="button rbutton button button-primary" href="<?php echo $permalink; ?>"><?php esc_html_e('View Guestbook','gwolle-gb'); ?></a>
172
  <?php
173
  } ?>
174
- <a class="button rbutton button button-primary" href="admin.php?page=<?php echo GWOLLE_GB_FOLDER; ?>/editor.php"><?php esc_html_e('Write admin entry','gwolle-gb'); ?></a>
175
  </p>
176
  <p>
177
  <?php
@@ -229,7 +229,7 @@ function gwolle_gb_overview_notification() {
229
  } ?> >
230
  <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>
231
  <p class="submit">
232
- <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save setting', 'gwolle-gb'); ?>" />
233
  </p>
234
  </form>
235
  <div>
98
  <tbody>
99
  <tr class="first">
100
  <td class="first b">
101
+ <a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&amp;show=all' ); ?>">
102
  <?php echo $count['all']; ?>
103
  </a>
104
  </td>
112
 
113
  <tr>
114
  <td class="first b">
115
+ <a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&amp;show=checked' ); ?>">
116
  <?php echo $count['checked']; ?>
117
  </a></td>
118
  <td class="t" style="color:#008000;">
124
 
125
  <tr>
126
  <td class="first b">
127
+ <a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&amp;show=unchecked' ); ?>">
128
  <?php echo $count['unchecked']; ?>
129
  </a></td>
130
  <td class="t" style="color:#ff6f00;">
136
 
137
  <tr>
138
  <td class="first b">
139
+ <a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&amp;show=spam' ); ?>">
140
  <?php echo $count['spam']; ?>
141
  </a></td>
142
  <td class="t" style="color:#FF0000;">
148
 
149
  <tr>
150
  <td class="first b">
151
+ <a href="<?php echo admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&amp;show=trash' ); ?>">
152
  <?php echo $count['trash']; ?>
153
  </a></td>
154
  <td class="t" style="color:#FF0000;">
171
  <a class="button rbutton button button-primary" href="<?php echo $permalink; ?>"><?php esc_html_e('View Guestbook','gwolle-gb'); ?></a>
172
  <?php
173
  } ?>
174
+ <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>
175
  </p>
176
  <p>
177
  <?php
229
  } ?> >
230
  <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>
231
  <p class="submit">
232
+ <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save setting', 'gwolle-gb'); ?>" />
233
  </p>
234
  </form>
235
  <div>
admin/gb-page-settings.php CHANGED
@@ -88,6 +88,11 @@ function gwolle_gb_page_settings() {
88
  $saved = true;
89
  }
90
 
 
 
 
 
 
91
  $list = Array(
92
  'form_name_enabled',
93
  'form_name_mandatory',
@@ -495,16 +500,17 @@ function gwolle_gb_page_settings() {
495
  <h1><?php esc_html_e('Settings', 'gwolle-gb'); ?></h1>
496
 
497
  <?php
498
- if ( $saved ) {
499
- echo '
500
- <div id="message" class="updated fade notice is-dismissible">
501
- <p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>
502
- </div>';
503
- } else if ( $gwolle_gb_messages ) {
504
  echo '
505
  <div id="message" class="updated fade notice is-dismissible ' . $gwolle_gb_errors . ' ">' .
506
  $gwolle_gb_messages .
507
  '</div>';
 
 
 
 
 
 
508
  }
509
 
510
  /* The rel attribute will be the form that becomes active */ ?>
88
  $saved = true;
89
  }
90
 
91
+ if (isset($_POST['gb_remove_ip']) && $_POST['gb_remove_ip'] == 'on') {
92
+ gwolle_gb_remove_ip_host();
93
+ $gwolle_gb_messages .= '<p>' . esc_html__('IP address and hostname was removed from all the entries.', 'gwolle-gb') . '</p>';
94
+ }
95
+
96
  $list = Array(
97
  'form_name_enabled',
98
  'form_name_mandatory',
500
  <h1><?php esc_html_e('Settings', 'gwolle-gb'); ?></h1>
501
 
502
  <?php
503
+ if ( isset($gwolle_gb_errors) ) {
 
 
 
 
 
504
  echo '
505
  <div id="message" class="updated fade notice is-dismissible ' . $gwolle_gb_errors . ' ">' .
506
  $gwolle_gb_messages .
507
  '</div>';
508
+ } else if ( $saved ) {
509
+ echo '
510
+ <div id="message" class="updated fade notice is-dismissible">
511
+ <p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>' .
512
+ $gwolle_gb_messages . '
513
+ </div>';
514
  }
515
 
516
  /* The rel attribute will be the form that becomes active */ ?>
admin/gb-pagination.php CHANGED
@@ -49,7 +49,8 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
49
 
50
 
51
  if ($pageNum > 1) {
52
- $pagination .= '<a class="first page-numbers" href="admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($pageNum - 1) . '&book_id=' . $book_id . '" rel="prev">&laquo;</a>';
 
53
  }
54
 
55
  if ($pageNum < 5) {
@@ -65,7 +66,8 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
65
  $pages_done[] = $i;
66
  } else {
67
  if ( in_array( $i, $pages_done ) ) { continue; }
68
- $pagination .= '<a class="page-numbers" href="admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id . '">' . $i . '</a>';
 
69
  $pages_done[] = $i;
70
  if ( $i == $pages_total ) { break; }
71
  }
@@ -76,7 +78,8 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
76
  $highDotsMade = true;
77
  }
78
  } elseif ($pageNum > 4) {
79
- $pagination .= '<a class="page-numbers" href="admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=1&book_id=' . $book_id . '">1</a>';
 
80
  if ($pages_total > 4) {
81
  $pagination .= '<span class="page-numbers dots">...</span>';
82
  }
@@ -91,7 +94,8 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
91
  if ($i == $pageNum) {
92
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
93
  } else {
94
- $pagination .= '<a class="page-numbers" href="admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id . '">' . $i . '</a>';
 
95
  }
96
  }
97
  if ($pageNum == $pages_total) {
@@ -105,9 +109,11 @@ function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
105
  $highDotsMade = true;
106
  }
107
  if ( ! in_array( $pages_total, $pages_done ) ) {
108
- $pagination .= '<a class="page-numbers" href="admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $pages_total . '&book_id=' . $book_id . '">' . $pages_total . '</a>';
 
109
  }
110
- $pagination .= '<a class="last page-numbers" href="admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($pageNum + 1) . '&book_id=' . $book_id . '" rel="next">&raquo;</a>';
 
111
  }
112
 
113
  $pagination .= '</div>';
49
 
50
 
51
  if ($pageNum > 1) {
52
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($pageNum - 1) . '&book_id=' . $book_id );
53
+ $pagination .= '<a class="first page-numbers" href="' . $link . '" rel="prev">&laquo;</a>';
54
  }
55
 
56
  if ($pageNum < 5) {
66
  $pages_done[] = $i;
67
  } else {
68
  if ( in_array( $i, $pages_done ) ) { continue; }
69
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id );
70
+ $pagination .= '<a class="page-numbers" href="' . $link . '">' . $i . '</a>';
71
  $pages_done[] = $i;
72
  if ( $i == $pages_total ) { break; }
73
  }
78
  $highDotsMade = true;
79
  }
80
  } elseif ($pageNum > 4) {
81
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=1&book_id=' . $book_id );
82
+ $pagination .= '<a class="page-numbers" href="' . $link . '">1</a>';
83
  if ($pages_total > 4) {
84
  $pagination .= '<span class="page-numbers dots">...</span>';
85
  }
94
  if ($i == $pageNum) {
95
  $pagination .= '<span class="page-numbers current">' . $i . '</span>';
96
  } else {
97
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $i . '&book_id=' . $book_id );
98
+ $pagination .= '<a class="page-numbers" href="' . $link . '">' . $i . '</a>';
99
  }
100
  }
101
  if ($pageNum == $pages_total) {
109
  $highDotsMade = true;
110
  }
111
  if ( ! in_array( $pages_total, $pages_done ) ) {
112
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . $pages_total . '&book_id=' . $book_id );
113
+ $pagination .= '<a class="page-numbers" href="' . $link . '">' . $pages_total . '</a>';
114
  }
115
+ $link = admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/entries.php&show=' . $show . '&pageNum=' . round($pageNum + 1) . '&book_id=' . $book_id );
116
+ $pagination .= '<a class="last page-numbers" href="' . $link . '" rel="next">&raquo;</a>';
117
  }
118
 
119
  $pagination .= '</div>';
admin/tabs/gb-formtab.php CHANGED
@@ -78,11 +78,10 @@ function gwolle_gb_page_settingstab_form() {
78
  <td>
79
  <?php
80
  $notice = gwolle_gb_sanitize_output( get_option('gwolle_gb-notice', false), 'setting_textarea' );
81
- if (!$notice) { // No text set by the user. Use the default text.
82
  $notice = esc_html__("
83
  Fields marked with * are required.
84
  Your E-mail address won't be published.
85
- For security reasons we save the IP address %ip%.
86
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
87
  We reserve the right to edit, delete, or not publish entries.
88
  "
@@ -127,7 +126,15 @@ We reserve the right to edit, delete, or not publish entries.
127
  <span class="setting-description"><?php /* translators: The GDPR law often has a country specific name */
128
  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 />';
129
  esc_html_e('Disabling this option will still have the IP Address used for spamfiltering in Stop Forum Spam.', 'gwolle-gb'); echo '<br />';
130
- esc_html_e('Disabling this option will probably make the Akismet spamfilter less effective.', 'gwolle-gb'); ?></span>
 
 
 
 
 
 
 
 
131
  </td>
132
  </tr>
133
 
78
  <td>
79
  <?php
80
  $notice = gwolle_gb_sanitize_output( get_option('gwolle_gb-notice', false), 'setting_textarea' );
81
+ if ( ! $notice) { // No text set by the user. Use the default text.
82
  $notice = esc_html__("
83
  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
  "
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>
131
+ </tr>
132
+
133
+ <tr valign="top">
134
+ <th scope="row"><label for="gb_remove_ip"><?php esc_html_e('Remove IP Address', 'gwolle-gb'); ?></label></th>
135
+ <td>
136
+ <input type="checkbox" id="gb_remove_ip" name="gb_remove_ip" />
137
+ <label for="gb_remove_ip"><?php esc_html_e('Permanently remove IP Address and hostname for all existing entries.', 'gwolle-gb'); ?></label>
138
  </td>
139
  </tr>
140
 
docs/filters/gwolle_gb_wpadmin_url.txt CHANGED
@@ -18,7 +18,7 @@ Where 'filter_function_name' is the function WordPress should call when the filt
18
 
19
  function my_gwolle_gb_wpadmin_url( $wpadmin_url ) {
20
  // this is the default;
21
- $wpadmin_url = admin_url( '/admin.php' );
22
  return $wpadmin_url;
23
  }
24
  add_filter( 'gwolle_gb_wpadmin_url', 'my_gwolle_gb_wpadmin_url', 10,1 );
18
 
19
  function my_gwolle_gb_wpadmin_url( $wpadmin_url ) {
20
  // this is the default;
21
+ $wpadmin_url = admin_url( 'admin.php' );
22
  return $wpadmin_url;
23
  }
24
  add_filter( 'gwolle_gb_wpadmin_url', 'my_gwolle_gb_wpadmin_url', 10,1 );
frontend/css/gwolle-gb-frontend.css CHANGED
@@ -28,10 +28,34 @@
28
 
29
  #gwolle_gb form#gwolle_gb_new_entry,
30
  #gwolle_gb form#gwolle-gb-new-entry {
 
31
  margin-top: 20px;
32
  text-align: left;
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  .gwolle_gb_float .label,
36
  .gwolle_gb_float .input,
37
  .gwolle-gb-float .label,
28
 
29
  #gwolle_gb form#gwolle_gb_new_entry,
30
  #gwolle_gb form#gwolle-gb-new-entry {
31
+ position: relative;
32
  margin-top: 20px;
33
  text-align: left;
34
  }
35
 
36
+ button.gb-notice-dismiss {
37
+ position: absolute;
38
+ top: 0;
39
+ right: 1px;
40
+ border: none;
41
+ margin: 0;
42
+ padding: 9px;
43
+ background: none;
44
+ color: #72777c;
45
+ cursor: pointer;
46
+ }
47
+ button.gb-notice-dismiss::before {
48
+ background: none;
49
+ color: #72777c;
50
+ content: "\f153";
51
+ display: block;
52
+ font: normal 16px/20px dashicons;
53
+ speak: none;
54
+ height: 20px;
55
+ text-align: center;
56
+ width: 20px;
57
+ }
58
+
59
  .gwolle_gb_float .label,
60
  .gwolle_gb_float .input,
61
  .gwolle-gb-float .label,
frontend/gb-form.php CHANGED
@@ -154,6 +154,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
154
  $output .= '
155
  <form id="gwolle_gb_new_entry" action="#" method="POST" class="' . $formclass . '">
156
  <h3>' . $header . '</h3>
 
157
  <input type="hidden" name="gwolle_gb_function" id="gwolle_gb_function" value="add_entry" />';
158
 
159
  // The book_id from the shortcode, to be used by the posthandling function again.
@@ -481,11 +482,12 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
481
  if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
482
  $a_open = '';
483
  $a_close = '';
484
- $privacy_policy_page_id = gwolle_gb_get_privacy_policy_id();
485
- if ( ! empty( $privacy_policy_page_id ) ) {
486
- $privacy_policy_page_permalink = get_permalink( $privacy_policy_page_id );
487
- $a_open = '<a href="' . $privacy_policy_page_permalink . '" title="' . esc_attr__('Read the Privacy Policy', 'gwolle-gb') . '" target="_blank">';
488
- $a_close = '</a>';
 
489
  }
490
  /* translators: %s is a link to the privacy policy page. */
491
  $label = apply_filters( 'gwolle_gb_privacy_label', sprintf( esc_html__( 'Accept %sPrivacy Policy%s', 'gwolle-gb' ), $a_open, $a_close ) );
@@ -532,7 +534,6 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
532
  $notice = esc_html__("
533
  Fields marked with * are required.
534
  Your E-mail address won't be published.
535
- For security reasons we save the IP address %ip%.
536
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
537
  We reserve the right to edit, delete, or not publish entries.
538
  "
154
  $output .= '
155
  <form id="gwolle_gb_new_entry" action="#" method="POST" class="' . $formclass . '">
156
  <h3>' . $header . '</h3>
157
+ <button type="button" class="gb-notice-dismiss"><span class="screen-reader-text">' . esc_html__('Hide this form.', 'gwolle-gb') . '</span></button>
158
  <input type="hidden" name="gwolle_gb_function" id="gwolle_gb_function" value="add_entry" />';
159
 
160
  // The book_id from the shortcode, to be used by the posthandling function again.
482
  if ( isset($form_setting['form_privacy_enabled']) && $form_setting['form_privacy_enabled'] === 'true' ) {
483
  $a_open = '';
484
  $a_close = '';
485
+ if ( function_exists( 'get_privacy_policy_url' ) ) {
486
+ $privacy_policy_page = get_privacy_policy_url(); // Since WP 4.9.6
487
+ if ( ! empty( $privacy_policy_page ) ) {
488
+ $a_open = '<a href="' . $privacy_policy_page . '" title="' . esc_attr__('Read the Privacy Policy', 'gwolle-gb') . '" target="_blank">';
489
+ $a_close = '</a>';
490
+ }
491
  }
492
  /* translators: %s is a link to the privacy policy page. */
493
  $label = apply_filters( 'gwolle_gb_privacy_label', sprintf( esc_html__( 'Accept %sPrivacy Policy%s', 'gwolle-gb' ), $a_open, $a_close ) );
534
  $notice = esc_html__("
535
  Fields marked with * are required.
536
  Your E-mail address won't be published.
 
537
  It's possible that your entry will only be visible in the guestbook after we reviewed it.
538
  We reserve the right to edit, delete, or not publish entries.
539
  "
frontend/gb-read.php CHANGED
@@ -136,7 +136,7 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
136
  $entries_list_class = apply_filters( 'gwolle_gb_entries_list_class', $entries_list_class );
137
 
138
  /* Entries from the template */
139
- if ( !is_array($entries) || empty($entries) ) {
140
  $no_entries = apply_filters( 'gwolle_gb_read_no_entries', esc_html__('(no entries yet)', 'gwolle-gb') );
141
  $output .= '<div id="gwolle_gb_entries" class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
142
  $output .= $no_entries;
136
  $entries_list_class = apply_filters( 'gwolle_gb_entries_list_class', $entries_list_class );
137
 
138
  /* Entries from the template */
139
+ if ( ! is_array($entries) || empty($entries) ) {
140
  $no_entries = apply_filters( 'gwolle_gb_read_no_entries', esc_html__('(no entries yet)', 'gwolle-gb') );
141
  $output .= '<div id="gwolle_gb_entries" class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
142
  $output .= $no_entries;
frontend/gb-total.php CHANGED
@@ -20,6 +20,21 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
20
  * @since 2.3.2
21
  */
22
  function gwolle_gb_addon_get_total_entries( $html, $args ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  if ( ! isset($args['book_id']) ) {
24
  $args['book_id'] = 1; // default
25
  }
@@ -42,4 +57,4 @@ function gwolle_gb_addon_get_total_entries( $html, $args ) {
42
  . '</div>';
43
  return $html;
44
  }
45
- add_filter( 'gwolle_gb_entries_list_before', 'gwolle_gb_addon_get_total_entries', 8, 2 );
20
  * @since 2.3.2
21
  */
22
  function gwolle_gb_addon_get_total_entries( $html, $args ) {
23
+ _deprecated_function( __FUNCTION__, ' 2.6.0', 'gwolle_gb_get_total_entries()' );
24
+ return gwolle_gb_get_total_entries( $html, $args );
25
+ }
26
+
27
+
28
+ /*
29
+ * Display the total number of entries in a book.
30
+ *
31
+ * @param string $html html content of the filter.
32
+ * @param array $args the parameters of the query for visible entries. Defaults to 'book_id' = 1.
33
+ * @return string $html new html content of the filter.
34
+ *
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
  }
57
  . '</div>';
58
  return $html;
59
  }
60
+ add_filter( 'gwolle_gb_entries_list_before', 'gwolle_gb_get_total_entries', 8, 2 );
frontend/js/gwolle-gb-frontend.js CHANGED
@@ -8,11 +8,19 @@
8
  */
9
  jQuery(document).ready(function($) {
10
  jQuery( "#gwolle_gb_write_button input" ).click(function() {
11
- document.getElementById("gwolle_gb_write_button").style.display = "none";
12
  jQuery("#gwolle_gb_new_entry").slideDown(1000);
13
  return false;
14
  });
15
  });
 
 
 
 
 
 
 
 
16
 
17
 
18
  /*
@@ -59,6 +67,11 @@ function gwolle_gb_metabox_handle() {
59
  });
60
  return false;
61
  }
 
 
 
 
 
62
 
63
 
64
  /*
@@ -174,19 +187,21 @@ function gwolle_gb_timout_clock() {
174
  /*
175
  * AJAX Submit for Gwolle Guestbook Frontend.
176
  */
177
- var gwolle_gb_ajax_data = {};
178
- gwolle_gb_ajax_data['permalink'] = window.location.href;
179
-
180
  var gwolle_gb_ajax_callback = jQuery.Callbacks(); // Callback function to be fired after AJAX request.
181
-
182
  jQuery(document).ready(function($) {
183
  jQuery( '.gwolle_gb_form_ajax #gwolle_gb_submit' ).click( function( submit_button ) {
184
 
185
  jQuery( '#gwolle_gb .gwolle_gb_submit_ajax_icon' ).css( 'display', 'inline' );
186
 
 
 
 
 
 
 
187
  jQuery('.gwolle_gb_form_ajax input').each(function( index, value ) {
188
- var val = jQuery( value ).val();
189
- var id = jQuery( value ).attr('id');
190
  if ( id == 'gwolle_gb_privacy' ) {
191
  var checked = jQuery('.gwolle_gb_form_ajax input#gwolle_gb_privacy').prop('checked');
192
  if ( checked == true ) {
@@ -197,11 +212,10 @@ jQuery(document).ready(function($) {
197
  }
198
  });
199
  jQuery('.gwolle_gb_form_ajax textarea').each(function( index, value ) {
200
- var val = jQuery( value ).val();
201
- var id = jQuery( value ).attr('id');
202
  gwolle_gb_ajax_data[id] = val;
203
  });
204
- gwolle_gb_ajax_data['action'] = 'gwolle_gb_form_ajax';
205
 
206
  jQuery.post( gwolle_gb_frontend_script.ajax_url, gwolle_gb_ajax_data, function( response ) {
207
 
8
  */
9
  jQuery(document).ready(function($) {
10
  jQuery( "#gwolle_gb_write_button input" ).click(function() {
11
+ jQuery("#gwolle_gb_write_button").slideUp(1000);
12
  jQuery("#gwolle_gb_new_entry").slideDown(1000);
13
  return false;
14
  });
15
  });
16
+ // And close it again.
17
+ jQuery(document).ready(function($) {
18
+ jQuery( "button.gb-notice-dismiss" ).click(function() {
19
+ jQuery("#gwolle_gb_write_button").slideDown(1000);
20
+ jQuery("#gwolle_gb_new_entry").slideUp(1000);
21
+ return false;
22
+ });
23
+ });
24
 
25
 
26
  /*
67
  });
68
  return false;
69
  }
70
+ jQuery(document).ready(function($) {
71
+ jQuery('body').on('click', function( el ) {
72
+ jQuery('div.gb-metabox').addClass( 'gwolle_gb_invisible' );
73
+ });
74
+ });
75
 
76
 
77
  /*
187
  /*
188
  * AJAX Submit for Gwolle Guestbook Frontend.
189
  */
 
 
 
190
  var gwolle_gb_ajax_callback = jQuery.Callbacks(); // Callback function to be fired after AJAX request.
 
191
  jQuery(document).ready(function($) {
192
  jQuery( '.gwolle_gb_form_ajax #gwolle_gb_submit' ).click( function( submit_button ) {
193
 
194
  jQuery( '#gwolle_gb .gwolle_gb_submit_ajax_icon' ).css( 'display', 'inline' );
195
 
196
+ // Use an object, arrays are only indexed by integers.
197
+ var gwolle_gb_ajax_data = {
198
+ permalink: window.location.href,
199
+ action: 'gwolle_gb_form_ajax'
200
+ };
201
+
202
  jQuery('.gwolle_gb_form_ajax input').each(function( index, value ) {
203
+ var val = jQuery( this ).val();
204
+ var id = jQuery( this ).attr('id');
205
  if ( id == 'gwolle_gb_privacy' ) {
206
  var checked = jQuery('.gwolle_gb_form_ajax input#gwolle_gb_privacy').prop('checked');
207
  if ( checked == true ) {
212
  }
213
  });
214
  jQuery('.gwolle_gb_form_ajax textarea').each(function( index, value ) {
215
+ var val = jQuery( this ).val();
216
+ var id = jQuery( this ).attr('id');
217
  gwolle_gb_ajax_data[id] = val;
218
  });
 
219
 
220
  jQuery.post( gwolle_gb_frontend_script.ajax_url, gwolle_gb_ajax_data, function( response ) {
221
 
functions/gb-book_id.php CHANGED
@@ -40,8 +40,8 @@ function gwolle_gb_get_postid( $book_id = 1 ) {
40
  endwhile;
41
  wp_reset_postdata();
42
  }
43
- return 0;
44
 
 
45
  }
46
 
47
 
@@ -100,7 +100,6 @@ function gwolle_gb_get_postid_biggest_book() {
100
  }
101
 
102
  return 0;
103
-
104
  }
105
 
106
 
@@ -135,5 +134,38 @@ function gwolle_gb_get_books() {
135
  }
136
 
137
  return $postids;
 
 
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
40
  endwhile;
41
  wp_reset_postdata();
42
  }
 
43
 
44
+ return 0;
45
  }
46
 
47
 
100
  }
101
 
102
  return 0;
 
103
  }
104
 
105
 
134
  }
135
 
136
  return $postids;
137
+ }
138
+
139
 
140
+ /*
141
+ * Get all books and corresponding permalinks.
142
+ *
143
+ * @return array with post IDs, book IDS and permalinks that contain a guestbook.
144
+ *
145
+ * @since 2.6.0
146
+ */
147
+ function gwolle_gb_get_permalinks() {
148
+ $postids = gwolle_gb_get_books();
149
+ $books = array();
150
+
151
+ /* Build up all the permalinks for the books. */
152
+ foreach ( $postids as $postid ) {
153
+ $permalink = get_permalink( $postid );
154
+
155
+ if ( empty( $permalink ) ) {
156
+ continue;
157
+ }
158
+
159
+ $book_id = get_post_meta( $postid, 'gwolle_gb_book_id', true );
160
+ if ( empty( $book_id ) ) {
161
+ continue;
162
+ }
163
+
164
+ $books["$book_id"] = array(
165
+ 'post_id' => $postid,
166
+ 'book_id' => $book_id,
167
+ 'permalink' => $permalink
168
+ );
169
+ }
170
+ return $books;
171
  }
functions/gb-class-entry.php CHANGED
@@ -425,7 +425,6 @@ class gwolle_gb_entry {
425
  }
426
  }
427
  public function set_author_name($author_name) {
428
- // User input
429
  $author_name = gwolle_gb_sanitize_input($author_name);
430
  if ($author_name) {
431
  $this->author_name = $author_name;
@@ -433,12 +432,9 @@ class gwolle_gb_entry {
433
  }
434
  public function set_author_id($author_id) {
435
  $author_id = intval($author_id);
436
- if ($author_id) {
437
- $this->author_id = $author_id;
438
- }
439
  }
440
  public function set_author_email($author_email) {
441
- // User input
442
  $author_email = gwolle_gb_sanitize_input($author_email);
443
  $author_email = filter_var($author_email, FILTER_VALIDATE_EMAIL);
444
  if ($author_email) {
@@ -446,17 +442,13 @@ class gwolle_gb_entry {
446
  }
447
  }
448
  public function set_author_origin($author_origin) {
449
- // User input
450
  $author_origin = gwolle_gb_sanitize_input($author_origin);
451
- if ($author_origin) {
452
- $this->author_origin = $author_origin;
453
- }
454
  }
455
  public function set_author_website($author_website) {
456
- // User input
457
  $author_website = gwolle_gb_sanitize_input($author_website);
458
  $pattern = '/^http/';
459
- if ( !preg_match($pattern, $author_website, $matches) ) {
460
  $author_website = "http://" . $author_website;
461
  }
462
  $author_website = filter_var($author_website, FILTER_VALIDATE_URL);
@@ -464,20 +456,13 @@ class gwolle_gb_entry {
464
  }
465
  public function set_author_ip($author_ip = NULL) {
466
  $author_ip = gwolle_gb_sanitize_input($author_ip);
467
- if ($author_ip) {
468
- $this->author_ip = $author_ip;
469
- }
470
  }
471
  public function set_author_host($author_host = NULL) {
472
  $author_host = gwolle_gb_sanitize_input($author_host);
473
- // Don't use this here, only when it is really needed, like on a new entry
474
- // $author_host = gethostbyaddr( $author_ip );
475
- if ($author_host) {
476
- $this->author_host = $author_host;
477
- }
478
  }
479
  public function set_content($content) {
480
- // User input
481
  $content = gwolle_gb_sanitize_input($content, 'content');
482
  if ( strlen($content) > 0 ) {
483
  $this->content = $content;
@@ -488,7 +473,7 @@ class gwolle_gb_entry {
488
  }
489
  public function set_datetime($date = NULL) {
490
  $date = intval($date); // timestamp can be cast to int.
491
- if ( !$date ) {
492
  $date = current_time( 'timestamp' );
493
  }
494
  if ($date) {
@@ -516,7 +501,6 @@ class gwolle_gb_entry {
516
  $this->isspam = $isspam;
517
  }
518
  public function set_admin_reply($admin_reply) {
519
- // User input
520
  $admin_reply = gwolle_gb_sanitize_input($admin_reply, 'admin_reply');
521
  $this->admin_reply = $admin_reply;
522
  }
@@ -525,7 +509,7 @@ class gwolle_gb_entry {
525
  }
526
  public function set_book_id($book_id) {
527
  $this->book_id = intval($book_id);
528
- if (!$book_id) {
529
  $this->book_id = 1;
530
  }
531
  }
425
  }
426
  }
427
  public function set_author_name($author_name) {
 
428
  $author_name = gwolle_gb_sanitize_input($author_name);
429
  if ($author_name) {
430
  $this->author_name = $author_name;
432
  }
433
  public function set_author_id($author_id) {
434
  $author_id = intval($author_id);
435
+ $this->author_id = $author_id;
 
 
436
  }
437
  public function set_author_email($author_email) {
 
438
  $author_email = gwolle_gb_sanitize_input($author_email);
439
  $author_email = filter_var($author_email, FILTER_VALIDATE_EMAIL);
440
  if ($author_email) {
442
  }
443
  }
444
  public function set_author_origin($author_origin) {
 
445
  $author_origin = gwolle_gb_sanitize_input($author_origin);
446
+ $this->author_origin = $author_origin;
 
 
447
  }
448
  public function set_author_website($author_website) {
 
449
  $author_website = gwolle_gb_sanitize_input($author_website);
450
  $pattern = '/^http/';
451
+ if ( ! preg_match($pattern, $author_website, $matches) ) {
452
  $author_website = "http://" . $author_website;
453
  }
454
  $author_website = filter_var($author_website, FILTER_VALIDATE_URL);
456
  }
457
  public function set_author_ip($author_ip = NULL) {
458
  $author_ip = gwolle_gb_sanitize_input($author_ip);
459
+ $this->author_ip = $author_ip;
 
 
460
  }
461
  public function set_author_host($author_host = NULL) {
462
  $author_host = gwolle_gb_sanitize_input($author_host);
463
+ $this->author_host = $author_host;
 
 
 
 
464
  }
465
  public function set_content($content) {
 
466
  $content = gwolle_gb_sanitize_input($content, 'content');
467
  if ( strlen($content) > 0 ) {
468
  $this->content = $content;
473
  }
474
  public function set_datetime($date = NULL) {
475
  $date = intval($date); // timestamp can be cast to int.
476
+ if ( ! $date ) {
477
  $date = current_time( 'timestamp' );
478
  }
479
  if ($date) {
501
  $this->isspam = $isspam;
502
  }
503
  public function set_admin_reply($admin_reply) {
 
504
  $admin_reply = gwolle_gb_sanitize_input($admin_reply, 'admin_reply');
505
  $this->admin_reply = $admin_reply;
506
  }
509
  }
510
  public function set_book_id($book_id) {
511
  $this->book_id = intval($book_id);
512
+ if ( ! $book_id) {
513
  $this->book_id = 1;
514
  }
515
  }
functions/gb-log.php CHANGED
@@ -8,12 +8,11 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
8
 
9
 
10
  /*
11
- * gwolle_gb_add_log_entry()
12
- * Add a new log entry
13
  *
14
- * @param int $entry_id ID of the entry
15
- * @param string $subject one of the possible log_messages
16
- * @return bool true or false, depending on succes
17
  */
18
  function gwolle_gb_add_log_entry( $entry_id, $subject ) {
19
  global $wpdb;
@@ -43,9 +42,10 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
43
  'entry-untrashed',
44
  'admin-reply-added',
45
  'admin-reply-updated',
46
- 'admin-reply-removed'
 
47
  );
48
- if ( !in_array( $subject, $log_messages ) ) {
49
  return false;
50
  }
51
 
@@ -80,7 +80,6 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
80
 
81
 
82
  /*
83
- * gwolle_gb_get_log_entries
84
  * Function to get log entries.
85
  *
86
  * @param int $entry_id ID of the guestbook entry where the log belongs to
@@ -124,7 +123,8 @@ function gwolle_gb_get_log_entries( $entry_id ) {
124
  'entry-untrashed' => /* translators: Log message */ esc_html__('Entry has been untrashed.', 'gwolle-gb'),
125
  'admin-reply-added' => /* translators: Log message */ esc_html__('Admin reply has been added.', 'gwolle-gb'),
126
  'admin-reply-updated' => /* translators: Log message */ esc_html__('Admin reply has been updated.', 'gwolle-gb'),
127
- 'admin-reply-removed' => /* translators: Log message */ esc_html__('Admin reply has been removed.', 'gwolle-gb')
 
128
  );
129
 
130
  $where = " 1 = %d";
@@ -208,11 +208,9 @@ function gwolle_gb_get_log_entries( $entry_id ) {
208
 
209
 
210
  /*
211
- * gwolle_gb_del_log_entries()
212
- * Delete the log entries for a guestbook entry
213
- *
214
- * @param int $entry_id ID of the entry
215
  *
 
216
  * @return bool true or false, depending on succes
217
  */
218
  function gwolle_gb_del_log_entries( $entry_id ) {
8
 
9
 
10
  /*
11
+ * Add a new log for an entry.
 
12
  *
13
+ * @param int $entry_id ID of the entry
14
+ * @param string $subject one of the possible log_messages
15
+ * @return bool true or false, depending on succes
16
  */
17
  function gwolle_gb_add_log_entry( $entry_id, $subject ) {
18
  global $wpdb;
42
  'entry-untrashed',
43
  'admin-reply-added',
44
  'admin-reply-updated',
45
+ 'admin-reply-removed',
46
+ 'entry-anonymized'
47
  );
48
+ if ( ! in_array( $subject, $log_messages ) ) {
49
  return false;
50
  }
51
 
80
 
81
 
82
  /*
 
83
  * Function to get log entries.
84
  *
85
  * @param int $entry_id ID of the guestbook entry where the log belongs to
123
  'entry-untrashed' => /* translators: Log message */ esc_html__('Entry has been untrashed.', 'gwolle-gb'),
124
  'admin-reply-added' => /* translators: Log message */ esc_html__('Admin reply has been added.', 'gwolle-gb'),
125
  'admin-reply-updated' => /* translators: Log message */ esc_html__('Admin reply has been updated.', 'gwolle-gb'),
126
+ 'admin-reply-removed' => /* translators: Log message */ esc_html__('Admin reply has been removed.', 'gwolle-gb'),
127
+ 'entry-anonymized' => /* translators: Log message */ esc_html__('Entry has been anonymized.', 'gwolle-gb')
128
  );
129
 
130
  $where = " 1 = %d";
208
 
209
 
210
  /*
211
+ * Delete the log entries for a guestbook entry after the entry was removed.
 
 
 
212
  *
213
+ * @param int $entry_id ID of the entry
214
  * @return bool true or false, depending on succes
215
  */
216
  function gwolle_gb_del_log_entries( $entry_id ) {
functions/gb-mail.php CHANGED
@@ -95,7 +95,7 @@ Entry content:
95
  $info['blog_url'] = get_bloginfo('wpurl');
96
  }
97
 
98
- $wpadmin = apply_filters( 'gwolle_gb_wpadmin_url', admin_url( '/admin.php' ) );
99
  $info['wp_admin_url'] = $wpadmin;
100
  $info['entry_management_url'] = $wpadmin . '?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id();
101
 
@@ -118,6 +118,11 @@ Entry content:
118
  $log_entries = gwolle_gb_get_log_entries( $entry->get_id() );
119
  if ( is_array($log_entries) && !empty($log_entries) ) {
120
  $mail_body .= "\r\n\r\n" . esc_html__('Log messages:', 'gwolle-gb') . "\r\n";
 
 
 
 
 
121
  foreach ($log_entries as $log_entry) {
122
  $mail_body .= $log_entry['msg_html'] . "\r\n";
123
  }
95
  $info['blog_url'] = get_bloginfo('wpurl');
96
  }
97
 
98
+ $wpadmin = apply_filters( 'gwolle_gb_wpadmin_url', admin_url( 'admin.php' ) );
99
  $info['wp_admin_url'] = $wpadmin;
100
  $info['entry_management_url'] = $wpadmin . '?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id();
101
 
118
  $log_entries = gwolle_gb_get_log_entries( $entry->get_id() );
119
  if ( is_array($log_entries) && !empty($log_entries) ) {
120
  $mail_body .= "\r\n\r\n" . esc_html__('Log messages:', 'gwolle-gb') . "\r\n";
121
+ if ($entry->get_datetime() > 0) {
122
+ $mail_body .= date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
123
+ $mail_body .= date_i18n( get_option('time_format'), $entry->get_datetime() );
124
+ $mail_body .= ': ' . esc_html__('Written', 'gwolle-gb') . "\r\n";
125
+ }
126
  foreach ($log_entries as $log_entry) {
127
  $mail_body .= $log_entry['msg_html'] . "\r\n";
128
  }
functions/gb-misc.php CHANGED
@@ -91,32 +91,3 @@ function gwolle_gb_get_field_name( $field ) {
91
 
92
  return $field_name;
93
  }
94
-
95
-
96
- /*
97
- * If a privacy policy page ID is available, make sure the page actually exists. If not, display an error.
98
- *
99
- * @return int page ID of the privacy policy page. Returns false if no page found.
100
- *
101
- * @since 2.5.2
102
- */
103
- function gwolle_gb_get_privacy_policy_id() {
104
-
105
- $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); // Available since WordPress 4.9.6
106
-
107
- if ( ! empty( $privacy_policy_page_id ) ) {
108
- $privacy_policy_page = get_post( $privacy_policy_page_id );
109
-
110
- if ( ! $privacy_policy_page instanceof WP_Post ) {
111
- return false;
112
- } else {
113
- if ( 'trash' === $privacy_policy_page->post_status ) {
114
- return false;
115
- } else {
116
- return $privacy_policy_page_id;
117
- }
118
- }
119
- }
120
- return false;
121
-
122
- }
91
 
92
  return $field_name;
93
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/gb-privacy.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Remove IP address and hostname from existing database entries.
12
+ *
13
+ * @since 2.6.0
14
+ */
15
+ function gwolle_gb_remove_ip_host() {
16
+ global $wpdb;
17
+
18
+ $wpdb->query( "
19
+ UPDATE `$wpdb->gwolle_gb_entries` SET `author_ip` = '';
20
+ ");
21
+ $wpdb->query( "
22
+ UPDATE `$wpdb->gwolle_gb_entries` SET `author_host` = '';
23
+ ");
24
+
25
+ }
26
+
27
+
28
+ /*
29
+ * Add example text to the privacy policy.
30
+ *
31
+ * @since 2.6.0
32
+ */
33
+ function gwolle_gb_add_privacy_policy_content() {
34
+ if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
35
+ return;
36
+ }
37
+
38
+ $content = sprintf(
39
+ '<p>' . __( 'When visitors leave entries on the site we collect the data entered in the guestbook form and possibly the IP address and hostname of the visitor to help spam detection.', 'gwolle-gb' ) . '</p>' .
40
+ '<p>' . __( 'An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your entry, your profile picture is visible to the public in the context of your guestbook entry.', 'gwolle-gb' ) . '</p>' .
41
+ '<p>' . __( 'The entered entry and its metadata may be sent to third parties like Akismet and Stop Forum Spam to help spam detection. Their respective privacy policies are at https://automattic.com/privacy/ and https://www.stopforumspam.com/privacy.', 'gwolle-gb' ) . '</p>'
42
+ );
43
+
44
+ wp_add_privacy_policy_content(
45
+ 'Gwolle Guestbook',
46
+ wp_kses_post( wpautop( $content, false ) )
47
+ );
48
+ }
49
+ add_action( 'admin_init', 'gwolle_gb_add_privacy_policy_content' );
50
+
51
+
52
+ /*
53
+ * Registers the personal data exporter for guestbook entries.
54
+ *
55
+ * @since 2.6.0
56
+ *
57
+ * @param array $exporters An array of personal data exporters.
58
+ * @return array $exporters An array of personal data exporters.
59
+ */
60
+ function gwolle_gb_register_personal_data_exporter( $exporters ) {
61
+ $exporters['gwolle-gb'] = array(
62
+ 'exporter_friendly_name' => __( 'Gwolle Guestbook', 'gwolle-gb' ),
63
+ 'callback' => 'gwolle_gb_personal_data_exporter',
64
+ );
65
+
66
+ return $exporters;
67
+ }
68
+ add_filter( 'wp_privacy_personal_data_exporters', 'gwolle_gb_register_personal_data_exporter' );
69
+
70
+
71
+ /*
72
+ * Finds and exports personal data associated with an email address from the entries table.
73
+ *
74
+ * @since 2.6.0
75
+ *
76
+ * @param string $email_address The entry author email address.
77
+ * @param int $page Export page.
78
+ * @return array $return An array of personal data.
79
+ */
80
+ function gwolle_gb_personal_data_exporter( $email_address, $page = 1 ) {
81
+ $number = 100;
82
+ $page = (int) $page;
83
+
84
+ $data_to_export = array();
85
+
86
+ $entry_prop_to_export = array(
87
+ 'author_name' => __( 'Author', 'gwolle-gb' ),
88
+ 'author_email' => __( 'Email', 'gwolle-gb' ),
89
+ 'author_origin' => __( 'Origin', 'gwolle-gb' ),
90
+ 'author_website' => __( 'Website', 'gwolle-gb' ),
91
+ 'author_ip' => __( 'IP address', 'gwolle-gb' ),
92
+ 'author_host' => __( 'Host address', 'gwolle-gb' ),
93
+ 'datetime' => __( 'Date of the entry', 'gwolle-gb' ),
94
+ 'content' => __( 'Content', 'gwolle-gb' ),
95
+ 'entry_link' => __( 'URL of entry', 'gwolle-gb' ),
96
+ );
97
+
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
+
111
+ if ( ! is_array($entries) || empty($entries) ) {
112
+ return array(
113
+ 'data' => array(),
114
+ 'done' => true,
115
+ );
116
+ }
117
+
118
+ foreach ( (array) $entries as $entry ) {
119
+ $entry_data_to_export = array();
120
+ $entry_id = $entry->get_id();
121
+
122
+ foreach ( $entry_prop_to_export as $key => $name ) {
123
+ $value = '';
124
+
125
+ switch ( $key ) {
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;
147
+
148
+ case 'content':
149
+ $entry_content = gwolle_gb_sanitize_output( $entry->get_content(), 'content' );
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);
157
+ }
158
+ $value = $entry_content;
159
+ break;
160
+
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 ),
172
+ esc_html( $permalink )
173
+ );
174
+ } else {
175
+ $value = esc_html__('This entry is Not Visible.', 'gwolle-gb');
176
+ }
177
+ break;
178
+ }
179
+
180
+ if ( ! empty( $value ) ) {
181
+ $entry_data_to_export[] = array(
182
+ 'name' => $name,
183
+ 'value' => $value,
184
+ );
185
+ }
186
+ } // end foreach props, entry is done.
187
+
188
+ $data_to_export[] = array(
189
+ 'group_id' => 'gwolle-gb',
190
+ 'group_label' => __( 'Guestbook entries', 'gwolle-gb' ),
191
+ 'item_id' => "gb-entry-{$entry_id}",
192
+ 'data' => $entry_data_to_export,
193
+ );
194
+ } // end foreach entries.
195
+
196
+ $done = false;
197
+ if ( count( $entries ) < $number ) {
198
+ $done = true;
199
+ }
200
+
201
+ return array(
202
+ 'data' => $data_to_export,
203
+ 'done' => $done,
204
+ );
205
+ }
206
+
207
+
208
+ /*
209
+ * Registers the personal data eraser for guestbook entries.
210
+ *
211
+ * @since 2.6.0
212
+ *
213
+ * @param array $erasers An array of personal data erasers.
214
+ * @return array $erasers An array of personal data erasers.
215
+ */
216
+ function gwolle_gb_register_personal_data_eraser( $erasers ) {
217
+ $erasers['gwolle-gb'] = array(
218
+ 'eraser_friendly_name' => __( 'Gwolle Guestbook', 'gwolle-gb' ),
219
+ 'callback' => 'gwolle_gb_personal_data_eraser',
220
+ );
221
+
222
+ return $erasers;
223
+ }
224
+ add_filter( 'wp_privacy_personal_data_erasers', 'gwolle_gb_register_personal_data_eraser' );
225
+
226
+
227
+ /*
228
+ * Erases personal data associated with an email address from the entries table.
229
+ *
230
+ * @since 2.6.0
231
+ *
232
+ * @param string $email_address The author email address.
233
+ * @param int $page Erase page.
234
+ * @return array
235
+ */
236
+ function gwolle_gb_personal_data_eraser( $email_address, $page = 1 ) {
237
+
238
+ if ( empty( $email_address ) ) {
239
+ return array(
240
+ 'items_removed' => false,
241
+ 'items_retained' => false,
242
+ 'messages' => array(),
243
+ 'done' => true,
244
+ );
245
+ }
246
+
247
+ // Limit us to 100 entries at a time to avoid timing out.
248
+ $number = 100;
249
+ $page = (int) $page;
250
+ $items_removed = false;
251
+ $items_retained = false;
252
+ $messages = array();
253
+
254
+ $entries = gwolle_gb_get_entries(
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[] = __( '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
+
272
+ foreach ( $entries as $entry ) {
273
+ $entry = gwolle_gb_privacy_anonymize_entry( $entry );
274
+ $result = $entry->save();
275
+ if ( $result ) {
276
+ $items_removed = true;
277
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
278
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-anonymized' );
279
+ } else {
280
+ $items_retained = true;
281
+ /* translators: %d: Entry ID */
282
+ $messages[] = sprintf( __( 'Guestbook entry %d contains personal data but could not be anonymized.' ), $entry->get_id() );
283
+ }
284
+ }
285
+
286
+ $done = count( $entries ) < $number;
287
+
288
+ return array(
289
+ 'items_removed' => $items_removed,
290
+ 'items_retained' => $items_retained,
291
+ 'messages' => $messages,
292
+ 'done' => $done
293
+ );
294
+ }
295
+
296
+
297
+ /*
298
+ * Anonymize personal data associated with an entry.
299
+ *
300
+ * @since 2.6.0
301
+ *
302
+ * @param object $entry instance of gwolle_gb_entry class.
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 */ __( 'Anonymous', 'gwolle-gb' ) );
307
+ $entry->set_author_id( 0 );
308
+ $entry->set_author_email( 'deleted@site.invalid' );
309
+ $entry->set_author_origin( '' );
310
+ $entry->set_author_website( 'https://site.invalid' );
311
+ $entry->set_author_ip( '' );
312
+ $entry->set_author_host( '' );
313
+
314
+ return $entry;
315
+ }
gwolle-gb.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Gwolle Guestbook
4
  Plugin URI: http://zenoweb.nl
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: 2.5.4
7
  Author: Marcel Pol
8
  Author URI: http://zenoweb.nl
9
  License: GPLv2 or later
@@ -32,7 +32,7 @@ Domain Path: /lang/
32
 
33
 
34
  // Plugin Version
35
- define('GWOLLE_GB_VER', '2.5.4');
36
 
37
 
38
  /*
@@ -51,9 +51,6 @@ define('GWOLLE_GB_VER', '2.5.4');
51
  * - Localize admin ajax script.
52
  * - Add Filter for get_entry_count SQL, like get_entries.
53
  * - Add filters similar to pre_get_posts.
54
- * - Think about a cancel button for the form:
55
- * https://wordpress.org/support/topic/missing-cancel-button-in-new-entry-from/
56
- * Consider making the messages and the expanded form dismissible with an 'x' and a jQuery.slideUp().
57
  * - Better support for aria attributes.
58
  * - Add proper docblocks to filters in the code.
59
  * - Use GWOLLE_GB_URL where appropriate.
@@ -63,7 +60,6 @@ define('GWOLLE_GB_VER', '2.5.4');
63
  * - Support mark-as-spam and mark-as-ham for Stop Forum Spam.
64
  * - Consider adding a checkbox to honeypot.
65
  * - Emoji: Sinterklaas and Zwarte Piet.
66
- * - Remove %ip% from default notice text.
67
  * - Someday, do something with the REST API. Someday.
68
  *
69
  */
@@ -138,6 +134,7 @@ include_once( GWOLLE_GB_DIR . '/functions/gb-messages.php' );
138
  include_once( GWOLLE_GB_DIR . '/functions/gb-metabox.php' );
139
  include_once( GWOLLE_GB_DIR . '/functions/gb-misc.php' );
140
  include_once( GWOLLE_GB_DIR . '/functions/gb-post-meta.php' );
 
141
  include_once( GWOLLE_GB_DIR . '/functions/gb-settings.php' );
142
  include_once( GWOLLE_GB_DIR . '/functions/gb-single-view.php' );
143
  include_once( GWOLLE_GB_DIR . '/functions/gb-stop-forum-spam.php' );
3
  Plugin Name: Gwolle Guestbook
4
  Plugin URI: http://zenoweb.nl
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: 2.6.0
7
  Author: Marcel Pol
8
  Author URI: http://zenoweb.nl
9
  License: GPLv2 or later
32
 
33
 
34
  // Plugin Version
35
+ define('GWOLLE_GB_VER', '2.6.0');
36
 
37
 
38
  /*
51
  * - Localize admin ajax script.
52
  * - Add Filter for get_entry_count SQL, like get_entries.
53
  * - Add filters similar to pre_get_posts.
 
 
 
54
  * - Better support for aria attributes.
55
  * - Add proper docblocks to filters in the code.
56
  * - Use GWOLLE_GB_URL where appropriate.
60
  * - Support mark-as-spam and mark-as-ham for Stop Forum Spam.
61
  * - Consider adding a checkbox to honeypot.
62
  * - Emoji: Sinterklaas and Zwarte Piet.
 
63
  * - Someday, do something with the REST API. Someday.
64
  *
65
  */
134
  include_once( GWOLLE_GB_DIR . '/functions/gb-metabox.php' );
135
  include_once( GWOLLE_GB_DIR . '/functions/gb-misc.php' );
136
  include_once( GWOLLE_GB_DIR . '/functions/gb-post-meta.php' );
137
+ include_once( GWOLLE_GB_DIR . '/functions/gb-privacy.php' );
138
  include_once( GWOLLE_GB_DIR . '/functions/gb-settings.php' );
139
  include_once( GWOLLE_GB_DIR . '/functions/gb-single-view.php' );
140
  include_once( GWOLLE_GB_DIR . '/functions/gb-stop-forum-spam.php' );
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: 4.9
6
- Stable tag: 2.5.4
7
  License: GPLv2 or later
8
 
9
  Gwolle Guestbook is the WordPress guestbook you've just been looking for. Beautiful and easy.
@@ -25,7 +25,7 @@ Current features include:
25
  * Easy Import from other guestbooks into Gwolle Guestbook.
26
  * Notification by mail when a new entry has been posted.
27
  * Moderation, so that you can check an entry before it is visible in your guestbook (optional).
28
- * 6 anti-spam features, like Honeypot, Nonce, Akismet, Stop Forum Spam, Custom Quiz Question and CAPTCHA.
29
  * Simple Form Builder to select which form-fields you want to use.
30
  * Simple Entry Builder with the parts of each entry that you want to show.
31
  * Multiple guestbooks are possible.
@@ -81,6 +81,7 @@ Current features include:
81
  * Preview for the frontend form.
82
  * Preview for the admin editor form.
83
  * Admin reply on the frontend with AJAX.
 
84
  * Easy String Replacement in the default text so you can make this guestbook into a review section or anything you want.
85
  * Delete button in each entry for the moderator and author (optional).
86
  * Permalink button in each entry for easy access (optional).
@@ -405,6 +406,27 @@ But if you don't use standard comments, you can just as easily use the comment s
405
 
406
  == Changelog ==
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  = 2.5.4 =
409
  * 2018-06-06
410
  * Fix XSS security issue on admin dashboard widget (thanks DefenseCode).
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 3.7
5
  Tested up to: 4.9
6
+ Stable tag: 2.6.0
7
  License: GPLv2 or later
8
 
9
  Gwolle Guestbook is the WordPress guestbook you've just been looking for. Beautiful and easy.
25
  * Easy Import from other guestbooks into Gwolle Guestbook.
26
  * Notification by mail when a new entry has been posted.
27
  * Moderation, so that you can check an entry before it is visible in your guestbook (optional).
28
+ * 7 anti-spam features, like Honeypot, Nonce, Form Timeout, Akismet, Stop Forum Spam, Custom Quiz Question and CAPTCHA.
29
  * Simple Form Builder to select which form-fields you want to use.
30
  * Simple Entry Builder with the parts of each entry that you want to show.
31
  * Multiple guestbooks are possible.
81
  * Preview for the frontend form.
82
  * Preview for the admin editor form.
83
  * Admin reply on the frontend with AJAX.
84
+ * Report Abuse.
85
  * Easy String Replacement in the default text so you can make this guestbook into a review section or anything you want.
86
  * Delete button in each entry for the moderator and author (optional).
87
  * Permalink button in each entry for easy access (optional).
406
 
407
  == Changelog ==
408
 
409
+ = 2.6.0 =
410
+ * 2018-06-11
411
+ * Add option to permanently remove IP address and hostname from entries.
412
+ * Add cancel button for the form.
413
+ * Close metabox again after click event.
414
+ * Remove %ip% from default notice text.
415
+ * Add example text to the privacy policy.
416
+ * Refactor link to privacy policy.
417
+ * Included real fix for not handling form data on some installs.
418
+ * Show on editor if author was logged in or not.
419
+ * Add log message to mail notification with writing time like on editor.
420
+ * Add guestbook entries to WordPress personal data exporter.
421
+ * Add guestbook entries to WordPress personal data eraser.
422
+ * Add anonymize option to mass edit.
423
+ * Add 'gwolle_gb_privacy_anonymize_entry' function.
424
+ * Add 'gwolle_gb_get_permalinks' function.
425
+ * Add 'gwolle_gb_get_total_entries' function.
426
+ * Deprecate 'gwolle_gb_addon_get_total_entries' function.
427
+ * Use 'admin_url' everywhere.
428
+ * Updates for Add-On 1.2.0.
429
+
430
  = 2.5.4 =
431
  * 2018-06-06
432
  * Fix XSS security issue on admin dashboard widget (thanks DefenseCode).