Gwolle Guestbook - Version 4.4.0

Version Description

  • 2022-11-18
  • Use custom capabilities 'gwolle_gb_moderate_comments' and 'gwolle_gb_upload_files'.
  • Refactor Admin Editor, saving new entry saves more options.
Download this release

Release Info

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

Code changes from version 4.3.0 to 4.4.0

add-on/gb-add-on.php CHANGED
@@ -207,6 +207,8 @@ User IP address: %author_ip%
207
  /* translators: Settings page, option for uploading of images */
208
  esc_html_e('Offer uploading of images. This will only be offered for users with the capability `upload_files`, which ususally is limited to Author, Editor and Administrator.', 'gwolle-gb');
209
  /* translators: Settings page, option for uploading of images */
 
 
210
  esc_html_e('Images can be added through the form and will be uploaded to the Media Library and added to the content of the entry.', 'gwolle-gb');
211
  /* translators: Settings page, option for likes */
212
  esc_html_e('Likes', 'gwolle-gb');
207
  /* translators: Settings page, option for uploading of images */
208
  esc_html_e('Offer uploading of images. This will only be offered for users with the capability `upload_files`, which ususally is limited to Author, Editor and Administrator.', 'gwolle-gb');
209
  /* translators: Settings page, option for uploading of images */
210
+ esc_html_e('Offer uploading of images. This will only be offered for users with the capability `gwolle_gb_upload_files`, which ususally is limited to Author, Editor and Administrator.', 'gwolle-gb');
211
+ /* translators: Settings page, option for uploading of images */
212
  esc_html_e('Images can be added through the form and will be uploaded to the Media Library and added to the content of the entry.', 'gwolle-gb');
213
  /* translators: Settings page, option for likes */
214
  esc_html_e('Likes', 'gwolle-gb');
admin/gb-ajax-management.php CHANGED
@@ -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 ( ! current_user_can('moderate_comments') ) {
20
  return;
21
  }
22
 
@@ -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 ( ! current_user_can('moderate_comments') ) {
336
  echo 'error';
337
  die();
338
  }
16
  */
17
  add_action( 'admin_footer', 'gwolle_gb_ajax_javascript' );
18
  function gwolle_gb_ajax_javascript() {
19
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
20
  return;
21
  }
22
 
332
  add_action( 'wp_ajax_gwolle_gb_ajax', 'gwolle_gb_ajax_callback' );
333
  function gwolle_gb_ajax_callback() {
334
 
335
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
336
  echo 'error';
337
  die();
338
  }
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 ( ! current_user_can('moderate_comments') ) {
16
  return;
17
  }
18
 
@@ -162,7 +162,7 @@ function gwolle_gb_dashboard() {
162
  */
163
  function gwolle_gb_dashboard_setup() {
164
 
165
- if ( ! current_user_can('moderate_comments') ) {
166
  return;
167
  }
168
 
12
  */
13
  function gwolle_gb_dashboard() {
14
 
15
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
16
  return;
17
  }
18
 
162
  */
163
  function gwolle_gb_dashboard_setup() {
164
 
165
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
166
  return;
167
  }
168
 
admin/gb-page-add-on.php CHANGED
@@ -15,7 +15,7 @@ function gwolle_gb_addon_menu_advertisement() {
15
  if ( $active && defined( 'GWOLLE_GB_ADDON_VER' ) ) {
16
  return;
17
  } else {
18
- add_submenu_page( GWOLLE_GB_FOLDER . '/gwolle-gb.php', esc_html__('The Add-On', 'gwolle-gb'), /* translators: Menu entry */ esc_html__('The Add-On', 'gwolle-gb'), 'moderate_comments', GWOLLE_GB_FOLDER . '/addon-settings.php', 'gwolle_gb_addon_page_advertisement' );
19
  }
20
  }
21
  add_action( 'admin_menu', 'gwolle_gb_addon_menu_advertisement', 11 );
@@ -26,7 +26,7 @@ add_action( 'admin_menu', 'gwolle_gb_addon_menu_advertisement', 11 );
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
 
@@ -94,7 +94,7 @@ function gwolle_gb_addon_features() {
94
  <li>' . esc_html__('Delete button in each entry for the moderator and author (optional).', 'gwolle-gb') . '</li>
95
  <li>' . esc_html__('Permalink button in each entry for easy access (optional).', 'gwolle-gb') . '</li>
96
  <li>' . esc_html__('Email button to contact each author (optional).', 'gwolle-gb') . '</li>
97
- <li>' . esc_html__('Upload Images through the form. (Only for Author, Editor and Administrator with capability "upload_files") (optional).', 'gwolle-gb') . '</li>
98
  <li>' . esc_html__('Sitemap support for popular SEO/Sitemap plugins.', 'gwolle-gb') . '</li>
99
  <li>' . esc_html__('Auto Anonymize timer (optional).', 'gwolle-gb') . '</li>
100
  <li>' . esc_html__('Auto Delete timer (optional).', 'gwolle-gb') . '</li>
15
  if ( $active && defined( 'GWOLLE_GB_ADDON_VER' ) ) {
16
  return;
17
  } else {
18
+ add_submenu_page( GWOLLE_GB_FOLDER . '/gwolle-gb.php', esc_html__('The Add-On', 'gwolle-gb'), /* translators: Menu entry */ esc_html__('The Add-On', 'gwolle-gb'), 'gwolle_gb_moderate_comments', GWOLLE_GB_FOLDER . '/addon-settings.php', 'gwolle_gb_addon_page_advertisement' );
19
  }
20
  }
21
  add_action( 'admin_menu', 'gwolle_gb_addon_menu_advertisement', 11 );
26
  */
27
  function gwolle_gb_addon_page_advertisement() {
28
 
29
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
30
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
31
  }
32
 
94
  <li>' . esc_html__('Delete button in each entry for the moderator and author (optional).', 'gwolle-gb') . '</li>
95
  <li>' . esc_html__('Permalink button in each entry for easy access (optional).', 'gwolle-gb') . '</li>
96
  <li>' . esc_html__('Email button to contact each author (optional).', 'gwolle-gb') . '</li>
97
+ <li>' . esc_html__('Upload Images through the form. (Only for Author, Editor and Administrator with capability "gwolle_gb_upload_files") (optional).', 'gwolle-gb') . '</li>
98
  <li>' . esc_html__('Sitemap support for popular SEO/Sitemap plugins.', 'gwolle-gb') . '</li>
99
  <li>' . esc_html__('Auto Anonymize timer (optional).', 'gwolle-gb') . '</li>
100
  <li>' . esc_html__('Auto Delete timer (optional).', 'gwolle-gb') . '</li>
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 ( ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
@@ -39,16 +39,18 @@ function gwolle_gb_page_editor() {
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();
53
  $gwolle_gb_errors = gwolle_gb_get_errors();
54
  $messageclass = '';
@@ -56,6 +58,7 @@ function gwolle_gb_page_editor() {
56
  $messageclass = 'error';
57
  }
58
 
 
59
  /*
60
  * Build the Page and the Form
61
  */
@@ -67,9 +70,9 @@ function gwolle_gb_page_editor() {
67
  <?php
68
  if ( $gwolle_gb_messages ) {
69
  echo '
70
- <div id="message" class="updated fade notice is-dismissible ' . $messageclass . ' ">' .
71
- $gwolle_gb_messages .
72
- '</div>';
73
  }
74
  ?>
75
 
@@ -259,62 +262,58 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
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>
269
- ';
270
- } else {
271
- echo '
272
- <h3 class="h3-visible" style="display:none;">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
273
- <h3 class="h3-invisible">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
274
- ';
275
- } ?>
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
- ?> />
283
- <?php esc_html_e('Checked', 'gwolle-gb'); ?>
284
- </label>
285
-
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
- ?> />
293
- <?php esc_html_e('Spam', 'gwolle-gb'); ?>
294
- </label>
295
 
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
- ?> />
303
- <?php /* translators: Is in Trashcan */ esc_html_e('In Trash', 'gwolle-gb'); ?>
304
- </label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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" />
314
- <?php esc_html_e('Remove this entry Permanently.', 'gwolle-gb'); ?>
315
- </label>
316
- <?php
317
  } ?>
 
 
 
 
 
 
318
 
319
  <div id="publishing-action">
320
  <input name="save" type="submit" class="button-primary" id="publish" value="<?php esc_attr_e('Save', 'gwolle-gb'); ?>" />
@@ -331,7 +330,7 @@ function gwolle_gb_editor_postbox_actions( $entry ) {
331
 
332
  $class = gwolle_gb_editor_get_class( $entry );
333
 
334
- if ( $entry->get_id() > 0 ) {
335
  echo '
336
  <p class="gwolle_gb_actions ' . $class . '">
337
  <span class="gwolle_gb_check">
@@ -466,10 +465,14 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
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);
@@ -479,15 +482,24 @@ function gwolle_gb_editor_meta_inputs( $entry ) {
479
  echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . '</option>';
480
  }
481
  echo '
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">
@@ -548,7 +560,7 @@ function gwolle_gb_editor_postbox_logs( $entry ) {
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
 
@@ -556,11 +568,6 @@ function gwolle_gb_page_editor_update( $entry ) {
556
  $verified = false;
557
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
558
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_editor' );
559
- if ( $verified === false ) {
560
- // Nonce is invalid, so considered spam
561
- gwolle_gb_add_message( '<p>' . esc_html__('The Nonce did not validate. Please reload the page and try again.', 'gwolle-gb') . '</p>', true, false);
562
- return $entry;
563
- }
564
  }
565
  if ( $verified === false ) {
566
  // Nonce is invalid.
@@ -568,267 +575,198 @@ function gwolle_gb_page_editor_update( $entry ) {
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;
582
- gwolle_gb_add_message( '<p>' . esc_html__('Entry removed.', 'gwolle-gb') . '</p>', false, false);
583
- $entry = new gwolle_gb_entry();
584
- return $entry;
585
- }
586
- }
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 ) {
614
- gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
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 ) {
622
- gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
623
- }
624
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
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
- }
637
 
638
- /* Check if the content changed, and update accordingly */
639
- if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
640
- if ( trim($_POST['gwolle_gb_content']) != $entry->get_content() ) {
641
- $entry_content = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_content'], 'content' );
642
- $entry->set_content( $entry_content );
643
- }
644
- }
645
 
646
- /* Check if the website changed, and update accordingly */
647
- if ( isset( $_POST['gwolle_gb_author_website'] ) ) {
648
- $website = trim( $_POST['gwolle_gb_author_website'] );
649
- } else {
650
- $website = '';
651
- }
652
- if ( $website !== $entry->get_author_website() ) {
653
- $entry->set_author_website( $website );
654
  }
 
 
 
 
655
 
656
- /* Check if the author_origin changed, and update accordingly */
657
- if ( isset($_POST['gwolle_gb_author_origin']) ) {
658
- if ( $_POST['gwolle_gb_author_origin'] != $entry->get_author_origin() ) {
659
- $entry_origin = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_origin'], 'author_origin' );
660
- $entry->set_author_origin( $entry_origin );
 
 
661
  }
 
662
  }
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() );
670
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
671
- } else if ( $gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '' ) {
672
- $entry->set_admin_reply_uid( 0 );
673
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-removed' );
674
- } else if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '' ) {
675
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-updated' );
676
- }
677
- $entry->set_admin_reply( $gwolle_gb_admin_reply );
678
- }
679
  }
 
 
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
  }
 
 
 
 
687
 
688
- /* Check if the author_name changed, and update accordingly */
689
- if ( isset($_POST['gwolle_gb_author_name']) ) {
690
- if ( $_POST['gwolle_gb_author_name'] != $entry->get_author_name() ) {
691
- $entry_name = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_name'], 'author_name' );
692
- $entry->set_author_name( $entry_name );
693
- }
694
  }
 
695
 
696
- /* Check if the author_id changed, and update accordingly */
697
- if ( isset($_POST['gwolle_gb_author_id']) ) {
698
- if ( $_POST['gwolle_gb_author_id'] != $entry->get_author_id() ) {
699
- $entry_author_id = (int) $_POST['gwolle_gb_author_id'];
700
- $entry->set_author_id( $entry_author_id );
701
- }
702
- }
 
 
703
 
704
- /* Check if the datetime changed, and update from all input. */
705
- if ( isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp']) ) {
706
- $timestamp = (int) $_POST['gwolle_gb_timestamp'];
707
- $entry->set_datetime( $timestamp );
 
708
  }
 
709
 
710
- /* Check if the book_id changed, and update accordingly */
711
- if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
712
- if ( $_POST['gwolle_gb_book_id'] != $entry->get_book_id() ) {
713
- $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
 
 
 
 
 
 
 
 
714
  }
 
715
  }
 
716
 
717
- /* Save the entry */
718
- $result = $entry->save();
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 );
726
- } else {
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
-
744
- /* Set metadata of the admin */
745
- $userdata = get_userdata( $user_id );
746
-
747
- if (is_object($userdata)) {
748
- if ( isset( $userdata->display_name ) ) {
749
- $author_name = $userdata->display_name;
750
- } else {
751
- $author_name = $userdata->user_login;
752
- }
753
- $author_email = $userdata->user_email;
754
  }
755
- $data['author_name'] = $author_name;
756
- $data['author_name'] = gwolle_gb_maybe_encode_emoji( $data['author_name'], 'author_name' );
757
- $data['author_email'] = $author_email;
758
-
759
- /* Set as Not Spam */
760
- $data['isspam'] = false;
761
-
762
- /* Do not set as trash */
763
- $data['istrash'] = false;
764
 
765
- /* Check if the content is filled in, and save accordingly */
766
- if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
767
- $data['content'] = $_POST['gwolle_gb_content'];
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'] = '';
775
- }
776
  }
 
777
 
778
- /* Check if the website is set, and save accordingly */
779
- if ( isset($_POST['gwolle_gb_author_website']) ) {
780
- if ( $_POST['gwolle_gb_author_website'] != '' ) {
781
- $data['author_website'] = $_POST['gwolle_gb_author_website'];
782
- } else {
783
- $data['author_website'] = home_url();
784
- }
785
- }
786
 
787
- /* Check if the author_origin is set, and save accordingly */
788
- if ( isset($_POST['gwolle_gb_author_origin']) ) {
789
- if ( $_POST['gwolle_gb_author_origin'] != '' ) {
790
- $data['author_origin'] = $_POST['gwolle_gb_author_origin'];
791
- $data['author_origin'] = gwolle_gb_maybe_encode_emoji( $data['author_origin'], 'author_origin' );
792
- }
793
  }
 
794
 
795
- /* Check if the admin_reply is set, and save accordingly */
796
- if ( isset($_POST['gwolle_gb_admin_reply']) ) {
797
- if ( $_POST['gwolle_gb_admin_reply'] != '' ) {
798
- $data['admin_reply'] = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
799
- $data['admin_reply_uid'] = get_current_user_id();
800
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
 
 
801
  }
802
  }
 
803
 
804
- /* Check if the book_id is set, and save accordingly */
805
- if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
806
- $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
807
- }
808
-
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
  }
 
816
 
817
- $result1 = $entry->set_data( $data );
818
- if ( $result1 ) {
819
- $result2 = $entry->save();
820
- if ( $result1 && $result2 ) {
821
- gwolle_gb_add_message( '<p>' . esc_html__('Entry saved.', 'gwolle-gb') . '</p>', false, false);
822
- gwolle_gb_clear_cache( $entry );
823
- do_action( 'gwolle_gb_save_entry_admin', $entry );
824
- } else {
825
- gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
826
- }
827
- } else {
828
- gwolle_gb_add_message( '<p>' . esc_html__('Entry was not saved.', 'gwolle-gb') . '</p>', true, false);
829
  }
 
 
 
830
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  return $entry;
 
832
  }
833
 
834
 
@@ -888,3 +826,63 @@ function gwolle_gb_editor_get_class( $entry ) {
888
  return $class_static;
889
 
890
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  */
15
  function gwolle_gb_page_editor() {
16
 
17
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
39
  $gwolle_gb_errors = true;
40
  $section_heading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
41
  }
 
 
42
  }
43
 
 
 
 
44
  if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] === 'editor' && $gwolle_gb_errors === false ) {
45
  $entry = gwolle_gb_page_editor_update( $entry );
46
  }
47
+
48
+ // only on really new entry, after deleting/removing, or if saving new entry messed up.
49
+ if ( $entry->get_id() === 0 ) {
50
+ $section_heading = esc_html__('New guestbook entry', 'gwolle-gb');
51
+ $entry = gwolle_gb_page_editor_entry_init( $entry );
52
+ }
53
+
54
  $gwolle_gb_messages = gwolle_gb_get_messages();
55
  $gwolle_gb_errors = gwolle_gb_get_errors();
56
  $messageclass = '';
58
  $messageclass = 'error';
59
  }
60
 
61
+
62
  /*
63
  * Build the Page and the Form
64
  */
70
  <?php
71
  if ( $gwolle_gb_messages ) {
72
  echo '
73
+ <div id="message" class="updated fade notice is-dismissible ' . $messageclass . ' ">' .
74
+ $gwolle_gb_messages .
75
+ '</div>';
76
  }
77
  ?>
78
 
262
  <?php
263
  }
264
 
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>
269
+ ';
270
  } else {
271
+ echo '
272
+ <h3 class="h3-visible" style="display:none;">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
273
+ <h3 class="h3-invisible">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
274
+ ';
275
+ } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
 
277
+ <label for="ischecked" class="selectit">
278
+ <input id="ischecked" name="ischecked" type="checkbox" <?php
279
+ if ($entry->get_ischecked() === 1) {
280
+ echo 'checked="checked"';
281
+ }
282
+ ?> />
283
+ <?php esc_html_e('Checked', 'gwolle-gb'); ?>
284
+ </label>
285
+
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
+ ?> />
293
+ <?php esc_html_e('Spam', 'gwolle-gb'); ?>
294
+ </label>
295
+
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
+ ?> />
303
+ <?php /* translators: Is in Trashcan */ esc_html_e('In Trash', 'gwolle-gb'); ?>
304
+ </label>
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" />
314
+ <?php esc_html_e('Remove this entry Permanently.', 'gwolle-gb'); ?>
315
+ </label>
316
+
317
 
318
  <div id="publishing-action">
319
  <input name="save" type="submit" class="button-primary" id="publish" value="<?php esc_attr_e('Save', 'gwolle-gb'); ?>" />
330
 
331
  $class = gwolle_gb_editor_get_class( $entry );
332
 
333
+ if ( $entry->get_id() > 0 ) { // Entry 0 doesn't exist yet, so no actions available. Needs to be published first.
334
  echo '
335
  <p class="gwolle_gb_actions ' . $class . '">
336
  <span class="gwolle_gb_check">
465
  $mn = date_i18n( 'i', $date );
466
 
467
  // Day
468
+ echo '
469
+ <label><span class="screen-reader-text">' . esc_html__( 'Day', 'gwolle-gb' ) . '</span>
470
+ <input type="text" id="dd" name="dd" value="' . esc_attr( $dd ) . '" size="2" maxlength="2" autocomplete="off" />
471
+ </label>';
472
 
473
  // Month
474
+ echo '
475
+ <label for="mm"><span class="screen-reader-text">' . esc_html__( 'Month', 'gwolle-gb' ) . '</span>
476
  <select id="mm" name="mm">';
477
  for ( $i = 1; $i < 13; $i++ ) {
478
  $monthnum = zeroise($i, 2);
482
  echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . '</option>';
483
  }
484
  echo '
485
+ </select>
486
+ </label>';
487
 
488
  // Year
489
+ echo '
490
+ <label for="yy"><span class="screen-reader-text">' . esc_html__( 'Year', 'gwolle-gb' ) . '</span>
491
+ <input type="text" id="yy" name="yy" value="' . esc_attr( $yy ) . '" size="4" maxlength="4" autocomplete="off" />
492
+ </label><br />';
493
  // Hour
494
+ echo '
495
+ <label for="hh"><span class="screen-reader-text">' . esc_html__( 'Hour', 'gwolle-gb' ) . '</span>
496
+ <input type="text" id="hh" name="hh" value="' . esc_attr( $hh ) . '" size="2" maxlength="2" autocomplete="off" />
497
+ </label>:';
498
  // Minute
499
+ echo '
500
+ <label for="mn"><span class="screen-reader-text">' . esc_html__( 'Minute', 'gwolle-gb' ) . '</span>
501
+ <input type="text" id="mn" name="mn" value="' . esc_attr( $mn ) . '" size="2" maxlength="2" autocomplete="off" />
502
+ </label>';
503
  ?>
504
 
505
  <div class="gwolle_gb_timestamp">
560
  */
561
  function gwolle_gb_page_editor_update( $entry ) {
562
 
563
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
564
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
565
  }
566
 
568
  $verified = false;
569
  if ( isset($_POST['gwolle_gb_wpnonce']) ) {
570
  $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_editor' );
 
 
 
 
 
571
  }
572
  if ( $verified === false ) {
573
  // Nonce is invalid.
575
  return $entry;
576
  }
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
579
+ /* Remove permanently and return early. */
580
+ if ( isset($_POST['istrash']) && $_POST['istrash'] === 'on' && isset($_POST['remove']) && $_POST['remove'] === 'on' ) {
581
+ if ( $entry->get_istrash() === 1 ) {
582
+ $entry->delete();
583
+ $entry->set_id(0);
584
+ $changed = true;
585
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry removed.', 'gwolle-gb') . '</p>', false, false);
586
+ $entry = new gwolle_gb_entry();
587
+ return $entry;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
588
  }
589
+ }
590
 
 
 
 
 
 
 
 
 
 
 
591
 
592
+ /* Check if it was visible or not. We need to check this, because multiple changes are possible and we don't want multiple emails. */
593
+ $was_visible = false;
594
+ if ( $entry->get_id() > 0 && $entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 ) {
595
+ $was_visible = true;
596
+ }
 
 
597
 
598
+ /* Set as checked or unchecked, and by whom */
599
+ if ( isset($_POST['ischecked']) && $_POST['ischecked'] === 'on' ) {
600
+ if ( $_POST['ischecked'] === 'on' ) {
601
+ $entry->set_ischecked( true );
602
+ $user_id = get_current_user_id(); // returns 0 if no current user
603
+ $entry->set_checkedby( $user_id );
604
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
605
+ gwolle_gb_clear_cache( $entry );
606
  }
607
+ } else {
608
+ $entry->set_ischecked( false );
609
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
610
+ }
611
 
612
+ /* Set as spam or not, and submit as ham or spam to Akismet service */
613
+ if ( isset($_POST['isspam']) && $_POST['isspam'] === 'on' ) {
614
+ if ( $_POST['isspam'] === 'on' && $entry->get_isspam() === 0 ) {
615
+ $entry->set_isspam( true );
616
+ $result = gwolle_gb_akismet( $entry, 'submit-spam' );
617
+ if ( $result ) {
618
+ gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
619
  }
620
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
621
  }
622
+ } else if ( $entry->get_isspam() === 1 ) {
623
+ $entry->set_isspam( false );
624
+ $result = gwolle_gb_akismet( $entry, 'submit-ham' );
625
+ if ( $result ) {
626
+ gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
 
 
 
 
 
 
 
 
 
 
 
627
  }
628
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
629
+ }
630
 
631
+ /* Set as trash or not */
632
+ if ( isset($_POST['istrash']) && $_POST['istrash'] === 'on' ) {
633
+ if ( $_POST['istrash'] === 'on' && $entry->get_istrash() === 0 ) {
634
+ $entry->set_istrash( true );
635
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
636
  }
637
+ } else if ( $entry->get_istrash() === 1 ) {
638
+ $entry->set_istrash( false );
639
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
640
+ }
641
 
642
+ /* Check if the content changed, and update accordingly */
643
+ if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
644
+ if ( trim($_POST['gwolle_gb_content']) != $entry->get_content() ) {
645
+ $entry_content = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_content'], 'content' );
646
+ $entry->set_content( $entry_content );
 
647
  }
648
+ }
649
 
650
+ /* Check if the website changed, and update accordingly */
651
+ if ( isset( $_POST['gwolle_gb_author_website'] ) ) {
652
+ $website = trim( $_POST['gwolle_gb_author_website'] );
653
+ } else {
654
+ $website = '';
655
+ }
656
+ if ( $website !== $entry->get_author_website() ) {
657
+ $entry->set_author_website( $website );
658
+ }
659
 
660
+ /* Check if the author_origin changed, and update accordingly */
661
+ if ( isset($_POST['gwolle_gb_author_origin']) ) {
662
+ if ( $_POST['gwolle_gb_author_origin'] != $entry->get_author_origin() ) {
663
+ $entry_origin = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_origin'], 'author_origin' );
664
+ $entry->set_author_origin( $entry_origin );
665
  }
666
+ }
667
 
668
+ /* Check if the admin_reply changed, and update and log accordingly */
669
+ if ( isset($_POST['gwolle_gb_admin_reply']) ) {
670
+ if ( trim($_POST['gwolle_gb_admin_reply']) !== $entry->get_admin_reply() ) {
671
+ $gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
672
+ if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
673
+ $entry->set_admin_reply_uid( get_current_user_id() );
674
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
675
+ } else if ( $gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '' ) {
676
+ $entry->set_admin_reply_uid( 0 );
677
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-removed' );
678
+ } else if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '' ) {
679
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-updated' );
680
  }
681
+ $entry->set_admin_reply( $gwolle_gb_admin_reply );
682
  }
683
+ }
684
 
685
+ /* Mail the author about the Admin Reply, if so requested */
686
+ if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
687
+ if ( $_POST['gwolle_gb_admin_reply_mail_author'] === 'on' ) {
688
+ gwolle_gb_mail_author_on_admin_reply( $entry );
 
 
 
 
 
 
 
689
  }
690
+ }
691
 
692
+ /* Check if the author_name changed, and update accordingly */
693
+ if ( isset($_POST['gwolle_gb_author_name']) ) {
694
+ if ( $_POST['gwolle_gb_author_name'] != $entry->get_author_name() ) {
695
+ $entry_name = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_name'], 'author_name' );
696
+ $entry->set_author_name( $entry_name );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  }
698
+ }
 
 
 
 
 
 
 
 
699
 
700
+ /* Check if the author_id changed, and update accordingly */
701
+ if ( isset($_POST['gwolle_gb_author_id']) ) {
702
+ if ( $_POST['gwolle_gb_author_id'] != $entry->get_author_id() ) {
703
+ $entry_author_id = (int) $_POST['gwolle_gb_author_id'];
704
+ $entry->set_author_id( $entry_author_id );
 
 
 
 
 
 
705
  }
706
+ }
707
 
708
+ /* Save the datetime. */
709
+ if ( isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp']) ) {
710
+ $timestamp = (int) $_POST['gwolle_gb_timestamp'];
711
+ $entry->set_datetime( $timestamp );
712
+ }
 
 
 
713
 
714
+ /* Save the book_id. */
715
+ if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
716
+ if ( $_POST['gwolle_gb_book_id'] != $entry->get_book_id() ) {
717
+ $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
 
 
718
  }
719
+ }
720
 
721
+ /* Email, auto-fill from user account on new entry. */
722
+ if ( $entry->get_id() === 0 ) {
723
+ $user_id = get_current_user_id(); // returns 0 if no current user
724
+ if ( $user_id > 0 ) {
725
+ $userdata = get_userdata( $user_id );
726
+ if ( is_object( $userdata ) ) {
727
+ $email = $userdata->user_email;
728
+ $entry->set_author_email( $email );
729
  }
730
  }
731
+ }
732
 
733
+ /* Save Network Information on new entry. */
734
+ if ( $entry->get_id() === 0 ) {
735
+ $set_author_ip = (bool) apply_filters( 'gwolle_gb_set_author_ip', true );
 
 
 
 
736
  $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
737
  if ( $set_author_ip && ( $set_author_ip2 === 'true' ) ) {
738
  $entry->set_author_ip( gwolle_gb_get_user_ip() );
739
  $entry->set_author_host( gethostbyaddr( gwolle_gb_get_user_ip() ) );
740
  }
741
+ }
742
 
743
+ /* Save the entry */
744
+ $entry_id = $entry->save();
745
+ if ( $entry_id ) {
746
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
747
+ gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
748
+ if ( $was_visible === false && $entry->get_ischecked() === 1 && $entry->get_isspam() === 0 && $entry->get_istrash() === 0 ) {
749
+ gwolle_gb_mail_author_on_moderation( $entry );
 
 
 
 
 
750
  }
751
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
752
+ } else {
753
+ gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
754
  }
755
+
756
+ if ( isset($entry_id) && $entry_id > 0 ) {
757
+ // Always reload the requested entry, so we have saved and fresh data.
758
+ $entry = new gwolle_gb_entry();
759
+
760
+ $result = $entry->load( $entry_id );
761
+ if ( ! $result ) {
762
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry could not be reloaded.', 'gwolle-gb') . '</p>', true, false);
763
+ $gwolle_gb_errors = true;
764
+ return $entry;
765
+ }
766
+ }
767
+
768
  return $entry;
769
+
770
  }
771
 
772
 
826
  return $class_static;
827
 
828
  }
829
+
830
+
831
+ /*
832
+ * Initialize a new entry for the editor. Used for new entries.
833
+ *
834
+ * @since 4.4.0
835
+ */
836
+ function gwolle_gb_page_editor_entry_init( $entry ) {
837
+
838
+ if ( $entry->get_id() !== 0 ) {
839
+ return $entry; // already an existing entry, do not overwrite data.
840
+ }
841
+
842
+ $user_id = get_current_user_id(); // returns 0 if no current user
843
+ $data['author_id'] = $user_id;
844
+
845
+ /* Set metadata of the admin */
846
+ $userdata = get_userdata( $user_id );
847
+
848
+ $author_name = '';
849
+ $author_email = '';
850
+ $author_email = '';
851
+ if (is_object($userdata)) {
852
+ if ( isset( $userdata->display_name ) ) {
853
+ $author_name = $userdata->display_name;
854
+ } else {
855
+ $author_name = $userdata->user_login;
856
+ }
857
+ $author_name = gwolle_gb_maybe_encode_emoji( $author_name, 'author_name' );
858
+ $author_email = $userdata->user_email;
859
+ }
860
+
861
+ /* Network Information */
862
+ $set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
863
+ $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
864
+ if ( $set_author_ip && ( $set_author_ip2 === 'true' ) ) {
865
+ $entry->set_author_ip( gwolle_gb_get_user_ip() );
866
+ $entry->set_author_host( gethostbyaddr( gwolle_gb_get_user_ip() ) );
867
+ }
868
+
869
+ $entry->set_author_name( $author_name );
870
+ $entry->set_author_id( $user_id );
871
+ $entry->set_author_email( $author_email );
872
+ $entry->set_author_origin( '' );
873
+ $entry->set_author_website( '' );
874
+
875
+ $entry->set_datetime(); // set as new
876
+
877
+ $entry->set_ischecked( 0 ); // editor needs to check it manually, so it doesn't get published by accident.
878
+ $entry->set_istrash( 0 );
879
+ $entry->set_isspam( 0 );
880
+
881
+ $entry->set_content( '' );
882
+ $entry->set_admin_reply( '' );
883
+
884
+ $entry->set_book_id( 1 ); // default 1
885
+
886
+ return $entry;
887
+
888
+ }
admin/gb-page-entries.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
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
 
@@ -541,7 +541,7 @@ function gwolle_gb_page_entries() {
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
 
14
  */
15
  function gwolle_gb_page_entries() {
16
 
17
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
541
  */
542
  function gwolle_gb_page_entries_update() {
543
 
544
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
545
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
546
  }
547
 
admin/gb-page-gwolle-gb.php CHANGED
@@ -14,7 +14,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
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
 
14
  */
15
  function gwolle_gb_welcome() {
16
 
17
+ if ( ! current_user_can('gwolle_gb_moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
admin/gwolle-gb-hooks.php CHANGED
@@ -45,7 +45,7 @@ function gwolle_gb_adminmenu() {
45
  add_menu_page(
46
  esc_html__('Guestbook', 'gwolle-gb'), /* translators: Menu entry */
47
  $menu_text,
48
- 'moderate_comments',
49
  GWOLLE_GB_FOLDER . '/gwolle-gb.php',
50
  'gwolle_gb_welcome',
51
  'dashicons-testimonial'
@@ -57,13 +57,13 @@ function gwolle_gb_adminmenu() {
57
  GWOLLE_GB_FOLDER . '/gwolle-gb.php',
58
  esc_html__('Entries', 'gwolle-gb'), /* translators: Menu entry */
59
  $menu_text,
60
- 'moderate_comments',
61
  GWOLLE_GB_FOLDER . '/entries.php',
62
  'gwolle_gb_page_entries'
63
  );
64
 
65
  // Admin page: admin/editor.php
66
- add_submenu_page( GWOLLE_GB_FOLDER . '/gwolle-gb.php', esc_html__('Entry editor', 'gwolle-gb'), /* translators: Menu entry */ esc_html__('Add/Edit entry', 'gwolle-gb'), 'moderate_comments', GWOLLE_GB_FOLDER . '/editor.php', 'gwolle_gb_page_editor' );
67
 
68
  // Admin page: admin/settings.php
69
  add_submenu_page( GWOLLE_GB_FOLDER . '/gwolle-gb.php', esc_html__('Settings', 'gwolle-gb'), /* translators: Menu entry */ esc_html__('Settings', 'gwolle-gb'), 'manage_options', GWOLLE_GB_FOLDER . '/settings.php', 'gwolle_gb_page_settings' );
@@ -141,11 +141,12 @@ add_action('admin_init', 'gwolle_gb_multisite_uninstall', 99);
141
 
142
  /*
143
  * Show admin notice when gwolle-gb-addon is active and needs an update.
144
- * Is dismissable by activating or updating.
145
  *
146
  * @since 4.0.0
147
  */
148
  function gwolle_gb_deps_admin_notice() {
 
149
  $class = 'notice notice-error';
150
 
151
  if ( ! isset($_GET['page']) ) {
@@ -160,7 +161,7 @@ function gwolle_gb_deps_admin_notice() {
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
 
165
  if ( version_compare( GWOLLE_GB_ADDON_VER, $required_version, '>=' ) ) {
166
  return; // We have the minimal version.
@@ -168,7 +169,7 @@ function gwolle_gb_deps_admin_notice() {
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
  }
 
173
  }
174
  add_action( 'admin_notices', 'gwolle_gb_deps_admin_notice' );
45
  add_menu_page(
46
  esc_html__('Guestbook', 'gwolle-gb'), /* translators: Menu entry */
47
  $menu_text,
48
+ 'gwolle_gb_moderate_comments',
49
  GWOLLE_GB_FOLDER . '/gwolle-gb.php',
50
  'gwolle_gb_welcome',
51
  'dashicons-testimonial'
57
  GWOLLE_GB_FOLDER . '/gwolle-gb.php',
58
  esc_html__('Entries', 'gwolle-gb'), /* translators: Menu entry */
59
  $menu_text,
60
+ 'gwolle_gb_moderate_comments',
61
  GWOLLE_GB_FOLDER . '/entries.php',
62
  'gwolle_gb_page_entries'
63
  );
64
 
65
  // Admin page: admin/editor.php
66
+ add_submenu_page( GWOLLE_GB_FOLDER . '/gwolle-gb.php', esc_html__('Entry editor', 'gwolle-gb'), /* translators: Menu entry */ esc_html__('Add/Edit entry', 'gwolle-gb'), 'gwolle_gb_moderate_comments', GWOLLE_GB_FOLDER . '/editor.php', 'gwolle_gb_page_editor' );
67
 
68
  // Admin page: admin/settings.php
69
  add_submenu_page( GWOLLE_GB_FOLDER . '/gwolle-gb.php', esc_html__('Settings', 'gwolle-gb'), /* translators: Menu entry */ esc_html__('Settings', 'gwolle-gb'), 'manage_options', GWOLLE_GB_FOLDER . '/settings.php', 'gwolle_gb_page_settings' );
141
 
142
  /*
143
  * Show admin notice when gwolle-gb-addon is active and needs an update.
144
+ * Is dismissable by deactivating or updating.
145
  *
146
  * @since 4.0.0
147
  */
148
  function gwolle_gb_deps_admin_notice() {
149
+
150
  $class = 'notice notice-error';
151
 
152
  if ( ! isset($_GET['page']) ) {
161
  if ( $active && defined( 'GWOLLE_GB_ADDON_VER' ) ) {
162
  $zeno_el = '<a href="https://zenoweb.nl/downloads/gwolle-guestbook-add-on/" target="_blank">';
163
  $zeno_el_close = '</a>';
164
+ $required_version = '2.5.0';
165
 
166
  if ( version_compare( GWOLLE_GB_ADDON_VER, $required_version, '>=' ) ) {
167
  return; // We have the minimal version.
169
 
170
  $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 );
171
  printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), $message );
 
172
  }
173
+
174
  }
175
  add_action( 'admin_notices', 'gwolle_gb_deps_admin_notice' );
admin/tabs/gb-emailtab.php CHANGED
@@ -77,7 +77,7 @@ function gwolle_gb_page_settingstab_email() {
77
  </select><br />
78
  <label for="subscribe"><?php esc_html_e('You can subscribe a moderator to the notification emails.', 'gwolle-gb'); ?><br />
79
  <?php esc_html_e('Select a user that you want subscribed to the notification emails.', 'gwolle-gb'); ?>
80
- <?php esc_html_e("You will only see users with the roles of Administrator, Editor and Author, who have the capability 'moderate_comments' .", 'gwolle-gb'); ?><br />
81
  <?php $link_wp = '<a href="' . admin_url( '/user-new.php' ) . '">';
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>' ); ?>
77
  </select><br />
78
  <label for="subscribe"><?php esc_html_e('You can subscribe a moderator to the notification emails.', 'gwolle-gb'); ?><br />
79
  <?php esc_html_e('Select a user that you want subscribed to the notification emails.', 'gwolle-gb'); ?>
80
+ <?php esc_html_e("You will only see users with the roles of Administrator, Editor and Author, who have the capability 'gwolle_gb_moderate_comments'.", 'gwolle-gb'); ?><br />
81
  <?php $link_wp = '<a href="' . admin_url( '/user-new.php' ) . '">';
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>' ); ?>
docs/actions/gwolle_gb_notsaved_entry_frontend.txt CHANGED
@@ -19,7 +19,7 @@ function my_gwolle_gb_notsaved_entry_frontend( $entry ) {
19
  // $entry is an object.
20
 
21
  // redirect moderator to the Editor.
22
- if ( current_user_can( 'moderate_comments' ) ) {
23
  wp_redirect( admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() ) );
24
  exit;
25
  }
19
  // $entry is an object.
20
 
21
  // redirect moderator to the Editor.
22
+ if ( current_user_can( 'gwolle_gb_moderate_comments' ) ) {
23
  wp_redirect( admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() ) );
24
  exit;
25
  }
docs/actions/gwolle_gb_save_entry_frontend.txt CHANGED
@@ -23,7 +23,7 @@ function my_redirect_gwolle_gb_save_entry_frontend( $entry ) {
23
  // $entry is an object.
24
 
25
  // redirect moderator to the Editor.
26
- if ( current_user_can( 'moderate_comments' ) ) {
27
  wp_redirect( admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() ) );
28
  exit;
29
  }
23
  // $entry is an object.
24
 
25
  // redirect moderator to the Editor.
26
+ if ( current_user_can( 'gwolle_gb_moderate_comments' ) ) {
27
  wp_redirect( admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() ) );
28
  exit;
29
  }
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 ( 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('gwolle_gb_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>
functions/gb-capabilities.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Use a custom capability for 'moderate_comments' and 'upload_files'.
12
+ * Add them to the corresponding roles.
13
+ * Checked with WordPress 6.1.
14
+ *
15
+ * @since 4.4.0
16
+ */
17
+ function gwolle_gb_custom_capabilities() {
18
+
19
+ $role = get_role( 'administrator' );
20
+ $role->add_cap( 'gwolle_gb_upload_files', true );
21
+ $role->add_cap( 'gwolle_gb_moderate_comments', true );
22
+
23
+ $role = get_role( 'editor' );
24
+ $role->add_cap( 'gwolle_gb_upload_files', true );
25
+ $role->add_cap( 'gwolle_gb_moderate_comments', true );
26
+
27
+ $role = get_role( 'author' );
28
+ $role->add_cap( 'gwolle_gb_upload_files', true );
29
+ //$role->add_cap( 'gwolle_gb_moderate_comments', true ); // nope :)
30
+
31
+ }
32
+ // priority must be after the initial role definition.
33
+ add_action( 'init', 'gwolle_gb_custom_capabilities', 11 );
34
+
functions/gb-metabox.php CHANGED
@@ -18,7 +18,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
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>
@@ -42,7 +42,7 @@ add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_edit
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 .= '
18
  */
19
  function gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
20
 
21
+ if ( current_user_can('gwolle_gb_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>
42
  */
43
  function gwolle_gb_entry_metabox_lines_ajax_icon( $gb_metabox, $entry ) {
44
 
45
+ if ( current_user_can('gwolle_gb_moderate_comments') ) {
46
  if ( $gb_metabox ) {
47
 
48
  $gb_metabox .= '
functions/gb-user.php CHANGED
@@ -40,7 +40,7 @@ function gwolle_gb_is_author( $entry ) {
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) ) {
@@ -57,7 +57,7 @@ function gwolle_gb_is_moderator( $user_id ) {
57
 
58
 
59
  /*
60
- * Get all the users with capability 'moderate_comments'.
61
  *
62
  * @return array User objects.
63
  */
@@ -85,7 +85,7 @@ function gwolle_gb_get_moderators() {
85
  }
86
 
87
  // No capability
88
- if ( ! user_can( $user_info, 'moderate_comments' ) ) {
89
  continue;
90
  }
91
 
40
  function gwolle_gb_is_moderator( $user_id ) {
41
 
42
  if ( $user_id > 0 ) {
43
+ if ( user_can( $user_id, 'gwolle_gb_moderate_comments' ) ) {
44
  // Only moderators
45
  $userdata = get_userdata( $user_id );
46
  if ( is_object($userdata) ) {
57
 
58
 
59
  /*
60
+ * Get all the users with capability 'gwolle_gb_moderate_comments'.
61
  *
62
  * @return array User objects.
63
  */
85
  }
86
 
87
  // No capability
88
+ if ( ! user_can( $user_info, 'gwolle_gb_moderate_comments' ) ) {
89
  continue;
90
  }
91
 
gwolle-gb-hooks.php CHANGED
@@ -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
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('gwolle_gb_moderate_comments') )
140
  return;
141
 
142
  // Counter
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.3.0
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.3.0');
35
 
36
 
37
  /*
@@ -69,14 +69,12 @@ define('GWOLLE_GB_VER', '4.3.0');
69
  * - Use more CSS transitions and SVG icons.
70
  * https://stackoverflow.com/questions/15979235/css-transition-show-div-smoothly
71
  * - Use CSS classes from contactform plugins, when they are active.
72
- * - Have custom capability through a filter instead of `moderate_comments`.
73
- * - https://wordpress.org/support/topic/user-roles-changing/
74
  * - Use new capability options in WP_User_Query in WP 5.9.
75
  * - https://make.wordpress.org/core/2022/01/05/new-capability-queries-in-wordpress-5-9/
76
  * - Automatically convert links and images to bbcode after cut-and-paste into the textarea.
77
  * - https://zenoweb.nl/forums/topic/automatic-link-creation/
78
  * - Redo the "visitor from city wrote on datetime" into better translatable text with placeholders.
79
- * - Editor: really fix timezone issues, new entry should follow given options and data.
80
  * https://wordpress.org/support/topic/problem-with-message-via-backend-timezone-and-editing-details/
81
  *
82
  */
@@ -147,6 +145,7 @@ require_once GWOLLE_GB_DIR . '/functions/gb-akismet.php';
147
  require_once GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php';
148
  require_once GWOLLE_GB_DIR . '/functions/gb-book_id.php';
149
  require_once GWOLLE_GB_DIR . '/functions/gb-cache.php';
 
150
  require_once GWOLLE_GB_DIR . '/functions/gb-debug.php';
151
  require_once GWOLLE_GB_DIR . '/functions/gb-fields.php';
152
  require_once GWOLLE_GB_DIR . '/functions/gb-formatting.php';
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.4.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.4.0');
35
 
36
 
37
  /*
69
  * - Use more CSS transitions and SVG icons.
70
  * https://stackoverflow.com/questions/15979235/css-transition-show-div-smoothly
71
  * - Use CSS classes from contactform plugins, when they are active.
 
 
72
  * - Use new capability options in WP_User_Query in WP 5.9.
73
  * - https://make.wordpress.org/core/2022/01/05/new-capability-queries-in-wordpress-5-9/
74
  * - Automatically convert links and images to bbcode after cut-and-paste into the textarea.
75
  * - https://zenoweb.nl/forums/topic/automatic-link-creation/
76
  * - Redo the "visitor from city wrote on datetime" into better translatable text with placeholders.
77
+ * - Editor: really fix timezone issues.
78
  * https://wordpress.org/support/topic/problem-with-message-via-backend-timezone-and-editing-details/
79
  *
80
  */
145
  require_once GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php';
146
  require_once GWOLLE_GB_DIR . '/functions/gb-book_id.php';
147
  require_once GWOLLE_GB_DIR . '/functions/gb-cache.php';
148
+ require_once GWOLLE_GB_DIR . '/functions/gb-capabilities.php';
149
  require_once GWOLLE_GB_DIR . '/functions/gb-debug.php';
150
  require_once GWOLLE_GB_DIR . '/functions/gb-fields.php';
151
  require_once GWOLLE_GB_DIR . '/functions/gb-formatting.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: 4.1
5
  Tested up to: 6.1
6
- Stable tag: 4.3.0
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
@@ -90,7 +90,7 @@ Current features include:
90
  * Delete button in each entry for the moderator and author (optional).
91
  * Permalink button in each entry for easy access (optional).
92
  * Email button to contact each author (optional).
93
- * Upload Images through the form. (Only for Author, Editor and Administrator with capability 'upload_files') (optional).
94
  * Sitemap support for popular SEO/Sitemap plugins.
95
  * Auto Anonymize timer (optional).
96
  * Auto Delete timer (optional).
@@ -334,7 +334,7 @@ You can use them as '[gwolle_gb button="false"]' or '[gwolle_gb_write button="tr
334
 
335
  = Moderation is enabled, but my entry is marked as checked =
336
 
337
- If a user with capability of 'moderate_comments' posts an entry, it will be marked as checked by default, because he can mark it as checked anyway.
338
 
339
  = Moderation is disabled, but some entries are still unchecked =
340
 
@@ -384,7 +384,7 @@ On the autoptimize settings page, you might have to click on "show advanced sett
384
 
385
  = What capabilities are needed? =
386
 
387
- For moderating comments you need the capability 'moderate_comments'.
388
 
389
  For managing options you need the capability 'manage_options'.
390
 
@@ -435,7 +435,8 @@ But if you don't use standard comments, you can just as easily use the comment s
435
  == Changelog ==
436
 
437
  = 4.4.0 =
438
- * 2022-
 
439
  * Refactor Admin Editor, saving new entry saves more options.
440
 
441
  = 4.3.0 =
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 4.1
5
  Tested up to: 6.1
6
+ Stable tag: 4.4.0
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
90
  * Delete button in each entry for the moderator and author (optional).
91
  * Permalink button in each entry for easy access (optional).
92
  * Email button to contact each author (optional).
93
+ * Upload Images through the form. (Only for Author, Editor and Administrator with capability 'gwolle_gb_upload_files') (optional).
94
  * Sitemap support for popular SEO/Sitemap plugins.
95
  * Auto Anonymize timer (optional).
96
  * Auto Delete timer (optional).
334
 
335
  = Moderation is enabled, but my entry is marked as checked =
336
 
337
+ If a user with capability of 'gwolle_gb_moderate_comments' posts an entry, it will be marked as checked by default, because he can mark it as checked anyway.
338
 
339
  = Moderation is disabled, but some entries are still unchecked =
340
 
384
 
385
  = What capabilities are needed? =
386
 
387
+ For moderating comments you need the capability 'gwolle_gb_moderate_comments'.
388
 
389
  For managing options you need the capability 'manage_options'.
390
 
435
  == Changelog ==
436
 
437
  = 4.4.0 =
438
+ * 2022-11-18
439
+ * Use custom capabilities 'gwolle_gb_moderate_comments' and 'gwolle_gb_upload_files'.
440
  * Refactor Admin Editor, saving new entry saves more options.
441
 
442
  = 4.3.0 =