Gwolle Guestbook - Version 3.0.0

Version Description

  • 2019-01-22
  • Add search widget (only visible on guestbook pages).
  • Add '[noscript]' to frontend form for when JavaScript is disabled.
  • Add function 'gwolle_gb_post_is_guestbook'.
  • Add function 'gwolle_gb_get_entries_from_search'.
  • Add function 'gwolle_gb_enqueue_markitup'.
  • Fix BBcode: support images inside links.
  • Fix BBcode: have sublists work.
  • Show new username and book ID after editing in editor postbox.
  • Add some accessibility fixes.
  • Switch database engine to InnoDB.
  • Don't use transients for hashed field names, is faster this way.
  • Better test if admin user exists for admin_reply.
  • Use 'field-name' for gwolle_gb_content too.
  • On admin pages, have separate functions for $_POST update. (settings, editor, entries).
  • Use GWOLLE_GB_URL where appropriate.
  • Use static vars instead of global vars.
  • Integrate 2 JavaScript files for Markitup/BBcode.
  • Switch export to 2000 entries per part instead of 3000.
  • Add strings for add-on 1.3.0.
  • Cleanup changelog. Add changelog-v2.txt.
Download this release

Release Info

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

Code changes from version 2.6.7 to 3.0.0

add-on/gb-add-on.php CHANGED
@@ -136,6 +136,10 @@ Entry content:
136
 
137
 
138
  // function gwolle_gb_addon_page_settingstab_misc() {
 
 
 
 
139
  /* translators: Settings page, option for permalink */
140
  esc_html_e('Permalink', 'gwolle-gb');
141
  /* translators: Commercial Add-On */
136
 
137
 
138
  // function gwolle_gb_addon_page_settingstab_misc() {
139
+ /* translators: Settings page, option for preview */
140
+ esc_html_e('Show Preview button in Form.', 'gwolle-gb');
141
+ /* translators: Settings page, option for preview */
142
+ esc_html_e('Adds a button to the form where visitors can preview their entry before posting.', 'gwolle-gb');
143
  /* translators: Settings page, option for permalink */
144
  esc_html_e('Permalink', 'gwolle-gb');
145
  /* translators: Commercial Add-On */
admin/css/gwolle-gb-admin.css CHANGED
@@ -85,7 +85,7 @@ body #dashboard-widgets .postbox#gwolle_gb_notification ul {
85
  margin-top: 1em;
86
  }
87
 
88
- #gwolle_gb_editor .gwolle_gb_edit_meta_inputs {
89
  display: none;
90
  }
91
 
@@ -222,7 +222,7 @@ span.book-icon a {
222
  width: 16px;
223
  height: 16px;
224
  margin-right: 5px;
225
- background-image: url('../gfx/entry-admin_reply.png');
226
  }
227
 
228
  /* AJAX */
85
  margin-top: 1em;
86
  }
87
 
88
+ #gwolle_gb_editor .gwolle_gb_editor_meta_inputs {
89
  display: none;
90
  }
91
 
222
  width: 16px;
223
  height: 16px;
224
  margin-right: 5px;
225
+ background-image: url('../gfx/entry-admin-reply.png');
226
  }
227
 
228
  /* AJAX */
admin/gb-ajax-management.php CHANGED
@@ -234,13 +234,13 @@ function gwolle_gb_ajax_javascript() {
234
  if ( jQuery( '.gwolle_gb_actions' ).hasClass('checked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
235
  jQuery( '.entry-icons' ).addClass('visible').removeClass('invisible');
236
  jQuery( '.gwolle_gb_actions' ).addClass('visible').removeClass('invisible');
237
- jQuery( '.h3_invisible' ).css('display', 'none');
238
- jQuery( '.h3_visible' ).css('display', 'block');
239
  } else {
240
  jQuery( '.entry-icons' ).addClass('invisible').removeClass('visible');
241
  jQuery( '.gwolle_gb_actions' ).addClass('invisible').removeClass('visible');
242
- jQuery( '.h3_visible' ).css('display', 'none');
243
- jQuery( '.h3_invisible' ).css('display', 'block');
244
  }
245
 
246
  // Countup counter in admin menu, toolbar
234
  if ( jQuery( '.gwolle_gb_actions' ).hasClass('checked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
235
  jQuery( '.entry-icons' ).addClass('visible').removeClass('invisible');
236
  jQuery( '.gwolle_gb_actions' ).addClass('visible').removeClass('invisible');
237
+ jQuery( '.h3-invisible' ).css('display', 'none');
238
+ jQuery( '.h3-visible' ).css('display', 'block');
239
  } else {
240
  jQuery( '.entry-icons' ).addClass('invisible').removeClass('visible');
241
  jQuery( '.gwolle_gb_actions' ).addClass('invisible').removeClass('visible');
242
+ jQuery( '.h3-visible' ).css('display', 'none');
243
+ jQuery( '.h3-invisible' ).css('display', 'block');
244
  }
245
 
246
  // Countup counter in admin menu, toolbar
admin/gb-page-editor.php CHANGED
@@ -13,18 +13,15 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
13
  * Admin page with the entry editor. Used for new and existing entries.
14
  */
15
  function gwolle_gb_page_editor() {
16
- global $entry;
17
 
18
- if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) {
19
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
20
  }
21
 
22
  gwolle_gb_admin_enqueue();
23
  gwolle_gb_register();
24
 
25
- $gwolle_gb_errors = '';
26
- $gwolle_gb_messages = '';
27
-
28
  $sectionHeading = esc_html__('Edit guestbook entry', 'gwolle-gb');
29
 
30
  // Always fetch the requested entry, so we can compare the $entry and the $_POST.
@@ -38,287 +35,26 @@ function gwolle_gb_page_editor() {
38
  if ( isset($entry_id) && $entry_id > 0 ) {
39
  $result = $entry->load( $entry_id );
40
  if ( ! $result ) {
41
- $gwolle_gb_messages .= '<p class="error">' . esc_html__('Entry could not be found.', 'gwolle-gb') . '</p>';
42
- $gwolle_gb_errors = 'error';
43
  $sectionHeading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
44
  }
45
  } else {
46
  $sectionHeading = esc_html__('New guestbook entry', 'gwolle-gb');
47
  }
48
 
49
-
50
  /*
51
  * Handle the $_POST
52
  */
53
- if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'editor' && $gwolle_gb_errors == '' ) {
54
-
55
- /* Check Nonce */
56
- $continue_on_nonce_checked = false;
57
- if ( isset($_POST['gwolle_gb_wpnonce']) ) {
58
- $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_editor' );
59
- if ( $verified == true ) {
60
- $continue_on_nonce_checked = true;
61
- } else {
62
- // Nonce is invalid, so considered spam
63
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
64
- $gwolle_gb_errors = 'error';
65
- }
66
- }
67
-
68
- if ( !isset($_POST['entry_id']) || $_POST['entry_id'] != $entry->get_id() ) {
69
- $gwolle_gb_messages .= '<p class="error">' . esc_html__('Something strange happened.', 'gwolle-gb') . '</p>';
70
- $gwolle_gb_errors = 'error';
71
- } else if ( $_POST['entry_id'] > 0 && $entry->get_id() > 0 && $continue_on_nonce_checked ) {
72
-
73
- /* Set as checked or unchecked, and by whom */
74
- if ( isset($_POST['ischecked']) && $_POST['ischecked'] == 'on' ) {
75
- if ( $_POST['ischecked'] == 'on' && $entry->get_ischecked() == 0 ) {
76
- $entry->set_ischecked( true );
77
- $user_id = get_current_user_id(); // returns 0 if no current user
78
- $entry->set_checkedby( $user_id );
79
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
80
- gwolle_gb_clear_cache( $entry );
81
- }
82
- } else if ( $entry->get_ischecked() == 1 ) {
83
- $entry->set_ischecked( false );
84
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
85
- }
86
-
87
- /* Set as spam or not, and submit as ham or spam to Akismet service */
88
- if ( isset($_POST['isspam']) && $_POST['isspam'] == 'on' ) {
89
- if ( $_POST['isspam'] == 'on' && $entry->get_isspam() == 0 ) {
90
- $entry->set_isspam( true );
91
- $result = gwolle_gb_akismet( $entry, 'submit-spam' );
92
- if ( $result ) {
93
- $gwolle_gb_messages .= '<p>' . esc_html__('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>';
94
- }
95
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
96
- }
97
- } else if ( $entry->get_isspam() == 1 ) {
98
- $entry->set_isspam( false );
99
- $result = gwolle_gb_akismet( $entry, 'submit-ham' );
100
- if ( $result ) {
101
- $gwolle_gb_messages .= '<p>' . esc_html__('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>';
102
- }
103
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
104
- }
105
-
106
- /* Set as trash or not */
107
- if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' ) {
108
- if ( $_POST['istrash'] == 'on' && $entry->get_istrash() == 0 ) {
109
- $entry->set_istrash( true );
110
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
111
- }
112
- } else if ( $entry->get_istrash() == 1 ) {
113
- $entry->set_istrash( false );
114
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
115
- }
116
-
117
- /* Check if the content changed, and update accordingly */
118
- if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
119
- if ( trim($_POST['gwolle_gb_content']) != $entry->get_content() ) {
120
- $entry_content = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_content'], 'content' );
121
- $entry->set_content( $entry_content );
122
- }
123
- }
124
-
125
- /* Check if the website changed, and update accordingly */
126
- if ( isset( $_POST['gwolle_gb_author_website'] ) ) {
127
- $website = trim( $_POST['gwolle_gb_author_website'] );
128
- } else {
129
- $website = '';
130
- }
131
- if ( $website != $entry->get_author_website() ) {
132
- $entry->set_author_website( $website );
133
- }
134
-
135
- /* Check if the author_origin changed, and update accordingly */
136
- if ( isset($_POST['gwolle_gb_author_origin']) ) {
137
- if ( $_POST['gwolle_gb_author_origin'] != $entry->get_author_origin() ) {
138
- $entry_origin = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_origin'], 'author_origin' );
139
- $entry->set_author_origin( $entry_origin );
140
- }
141
- }
142
-
143
- /* Check if the admin_reply changed, and update and log accordingly */
144
- if ( isset($_POST['gwolle_gb_admin_reply']) ) {
145
- if ( trim($_POST['gwolle_gb_admin_reply']) != $entry->get_admin_reply() ) {
146
- $gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
147
- if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
148
- $entry->set_admin_reply_uid( get_current_user_id() );
149
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
150
- } else if ( $gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '' ) {
151
- $entry->set_admin_reply_uid( 0 );
152
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-removed' );
153
- } else if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '' ) {
154
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-updated' );
155
- }
156
- $entry->set_admin_reply( $gwolle_gb_admin_reply );
157
- }
158
- }
159
-
160
- /* Mail the author about the Admin Reply, if so requested */
161
- if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
162
- if ( $_POST['gwolle_gb_admin_reply_mail_author'] == 'on' ) {
163
- gwolle_gb_mail_author_on_admin_reply( $entry );
164
- }
165
- }
166
-
167
- /* Check if the author_name changed, and update accordingly */
168
- if ( isset($_POST['gwolle_gb_author_name']) ) {
169
- if ( $_POST['gwolle_gb_author_name'] != $entry->get_author_name() ) {
170
- $entry_name = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_name'], 'author_name' );
171
- $entry->set_author_name( $entry_name );
172
- }
173
- }
174
-
175
- /* Check if the datetime changed, and update accordingly */
176
- if ( isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp']) ) {
177
- if ( $_POST['gwolle_gb_timestamp'] != $entry->get_datetime() ) {
178
- $entry->set_datetime( (int) $_POST['gwolle_gb_timestamp'] );
179
- }
180
- }
181
-
182
- /* Check if the book_id changed, and update accordingly */
183
- if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
184
- if ( $_POST['gwolle_gb_book_id'] != $entry->get_book_id() ) {
185
- $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
186
- }
187
- }
188
-
189
- /* Save the entry */
190
- $result = $entry->save();
191
- if ($result ) {
192
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
193
- $gwolle_gb_messages .= '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>';
194
- do_action( 'gwolle_gb_save_entry_admin', $entry );
195
- } else {
196
- $gwolle_gb_messages .= '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>';
197
- $gwolle_gb_errors = 'error';
198
- }
199
-
200
-
201
- /* Remove permanently */
202
- if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' && isset($_POST['remove']) && $_POST['remove'] == 'on' ) {
203
- if ( $entry->get_istrash() == 1 ) {
204
- $entry->delete();
205
- $entry->set_id(0);
206
- $changed = true;
207
- // Overwrite any other message, only removal is relevant.
208
- $gwolle_gb_messages = '<p>' . esc_html__('Entry removed.', 'gwolle-gb') . '</p>';
209
- $entry = new gwolle_gb_entry();
210
- }
211
- }
212
-
213
- } else if ( $_POST['entry_id'] == 0 && $entry->get_id() == 0 && $continue_on_nonce_checked ) {
214
-
215
- /*
216
- * Check for input, and save accordingly. This is on a New Entry! (So no logging)
217
- */
218
-
219
- $saved = false;
220
- $data = Array();
221
-
222
- /* Set as checked anyway, new entry is always by an admin */
223
- $data['ischecked'] = true;
224
- $user_id = get_current_user_id(); // returns 0 if no current user
225
- $data['checkedby'] = $user_id;
226
- $data['author_id'] = $user_id;
227
-
228
- /* Set metadata of the admin */
229
- $userdata = get_userdata( $user_id );
230
-
231
- if (is_object($userdata)) {
232
- if ( isset( $userdata->display_name ) ) {
233
- $author_name = $userdata->display_name;
234
- } else {
235
- $author_name = $userdata->user_login;
236
- }
237
- $author_email = $userdata->user_email;
238
- }
239
- $data['author_name'] = $author_name;
240
- $data['author_name'] = gwolle_gb_maybe_encode_emoji( $data['author_name'], 'author_name' );
241
- $data['author_email'] = $author_email;
242
-
243
- /* Set as Not Spam */
244
- $data['isspam'] = false;
245
-
246
- /* Do not set as trash */
247
- $data['istrash'] = false;
248
-
249
- /* Check if the content is filled in, and save accordingly */
250
- if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
251
- $data['content'] = $_POST['gwolle_gb_content'];
252
- $data['content'] = gwolle_gb_maybe_encode_emoji( $data['content'], 'content' );
253
- $saved = true;
254
- } else {
255
- $form_setting = gwolle_gb_get_setting( 'form' );
256
- 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' ) {
257
- $gwolle_gb_messages .= '<p>' . esc_html__('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>';
258
- $gwolle_gb_errors = 'error';
259
- } else {
260
- $data['content'] = '';
261
- $saved = true;
262
- }
263
- }
264
-
265
- /* Check if the website is set, and save accordingly */
266
- if ( isset($_POST['gwolle_gb_author_website']) ) {
267
- if ( $_POST['gwolle_gb_author_website'] != '' ) {
268
- $data['author_website'] = $_POST['gwolle_gb_author_website'];
269
- } else {
270
- $data['author_website'] = home_url();
271
- }
272
- }
273
-
274
- /* Check if the author_origin is set, and save accordingly */
275
- if ( isset($_POST['gwolle_gb_author_origin']) ) {
276
- if ( $_POST['gwolle_gb_author_origin'] != '' ) {
277
- $data['author_origin'] = $_POST['gwolle_gb_author_origin'];
278
- $data['author_origin'] = gwolle_gb_maybe_encode_emoji( $data['author_origin'], 'author_origin' );
279
- }
280
- }
281
-
282
- /* Check if the admin_reply is set, and save accordingly */
283
- if ( isset($_POST['gwolle_gb_admin_reply']) ) {
284
- if ( $_POST['gwolle_gb_admin_reply'] != '' ) {
285
- $data['admin_reply'] = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
286
- $data['admin_reply_uid'] = get_current_user_id();
287
- gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
288
- }
289
- }
290
-
291
- /* Check if the book_id is set, and save accordingly */
292
- if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
293
- $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
294
- }
295
-
296
- /* Network Information */
297
- $set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
298
- $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
299
- if ( $set_author_ip && ($set_author_ip2 == 'true') ) {
300
- $entry->set_author_ip( $_SERVER['REMOTE_ADDR'] );
301
- $entry->set_author_host( gethostbyaddr( $_SERVER['REMOTE_ADDR'] ) );
302
- }
303
-
304
- $result1 = $entry->set_data( $data );
305
- if ( $saved ) {
306
- $result2 = $entry->save();
307
- if ( $result1 && $result2 ) {
308
- $gwolle_gb_messages .= '<p>' . esc_html__('Entry saved.', 'gwolle-gb') . '</p>';
309
- gwolle_gb_clear_cache( $entry );
310
- do_action( 'gwolle_gb_save_entry_admin', $entry );
311
- } else {
312
- $gwolle_gb_messages .= '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>';
313
- $gwolle_gb_errors = 'error';
314
- }
315
- } else {
316
- $gwolle_gb_messages .= '<p>' . esc_html__('Entry was not saved.', 'gwolle-gb') . '</p>';
317
- }
318
-
319
- }
320
  }
321
-
322
 
323
  /*
324
  * Build the Page and the Form
@@ -331,7 +67,7 @@ function gwolle_gb_page_editor() {
331
  <?php
332
  if ( $gwolle_gb_messages ) {
333
  echo '
334
- <div id="message" class="updated fade notice is-dismissible ' . $gwolle_gb_errors . ' ">' .
335
  $gwolle_gb_messages .
336
  '</div>';
337
  }
@@ -391,7 +127,7 @@ function gwolle_gb_page_editor() {
391
  */
392
  function gwolle_gb_editor_postbox_content( $entry ) {
393
  ?>
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' ) . '">';
@@ -401,23 +137,7 @@ function gwolle_gb_editor_postbox_content( $entry ) {
401
  $form_setting = gwolle_gb_get_setting( 'form' );
402
 
403
  if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
404
- wp_enqueue_script( 'markitup', plugins_url('../frontend/markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false );
405
- wp_enqueue_script( 'markitup_set', plugins_url('../frontend/markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false );
406
- wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('../frontend/markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
407
-
408
- $dataToBePassed = array(
409
- 'bold' => /* translators: MarkItUp menu item */ esc_html__('Bold', 'gwolle-gb' ),
410
- 'italic' => /* translators: MarkItUp menu item */ esc_html__('Italic', 'gwolle-gb' ),
411
- 'bullet' => /* translators: MarkItUp menu item */ esc_html__('Bulleted List', 'gwolle-gb' ),
412
- 'numeric' => /* translators: MarkItUp menu item */ esc_html__('Numeric List', 'gwolle-gb' ),
413
- 'picture' => /* translators: MarkItUp menu item */ esc_html__('Picture', 'gwolle-gb' ),
414
- 'source' => /* translators: MarkItUp menu item */ esc_html__('Source', 'gwolle-gb' ),
415
- 'link' => /* translators: MarkItUp menu item */ esc_html__('Link', 'gwolle-gb' ),
416
- 'linktext' => /* translators: MarkItUp menu item */ esc_html__('Your text to link...', 'gwolle-gb' ),
417
- 'clean' => /* translators: MarkItUp menu item */ esc_html__('Clean', 'gwolle-gb' ),
418
- 'emoji' => /* translators: MarkItUp menu item */ esc_html__('Emoji', 'gwolle-gb' )
419
- );
420
- wp_localize_script( 'markitup_set', 'gwolle_gb_localize', $dataToBePassed );
421
 
422
  // Emoji symbols
423
  echo '<div class="gwolle_gb_emoji gwolle_gb_hide">';
@@ -437,7 +157,7 @@ function gwolle_gb_editor_postbox_content( $entry ) {
437
  */
438
  function gwolle_gb_editor_postbox_website( $entry ) {
439
  ?>
440
- <input type="url" name="gwolle_gb_author_website" tabindex="2" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_website() ); ?>" id="author_website" placeholder="<?php esc_attr_e('Website', 'gwolle-gb'); ?>" />
441
  <p><?php
442
  /* translators: %s is a code element */
443
  echo sprintf( esc_html__('Example: %shttp://www.example.com/%s', 'gwolle-gb'), '<code>', '</code>' ); ?>
@@ -451,7 +171,7 @@ function gwolle_gb_editor_postbox_website( $entry ) {
451
  */
452
  function gwolle_gb_editor_postbox_author_origin( $entry ) {
453
  ?>
454
- <input type="text" name="gwolle_gb_author_origin" tabindex="3" class="wp-exclude-emoji" placeholder="<?php esc_attr_e('City', 'gwolle-gb'); ?>" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_origin() ); ?>" id="author_origin" />
455
  <?php
456
  }
457
 
@@ -463,7 +183,7 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
463
  $form_setting = gwolle_gb_get_setting( 'form' );
464
  ?>
465
 
466
- <textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" class="wp-exclude-emoji" tabindex="4" placeholder="<?php esc_attr_e('Admin Reply', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ); ?></textarea>
467
 
468
  <?php
469
  if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
@@ -482,7 +202,7 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
482
  $admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
483
  if ( $admin_reply_name ) { ?>
484
  <p class="gb-admin_reply_uid"><?php
485
- $admin_reply_header = '<em>' . esc_html__('Admin Reply by:', 'gwolle-gb') . ' ' . $admin_reply_name . '</em>';
486
  echo apply_filters( 'gwolle_gb_admin_reply_header', $admin_reply_header, $entry );
487
  ?>
488
  </p><?php
@@ -508,43 +228,8 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
508
  * Metabox with the icons and checkboxes for quick glancing at the visibility of the entry.
509
  */
510
  function gwolle_gb_editor_postbox_icons( $entry ) {
511
- global $class;
512
-
513
- $class = '';
514
- // Attach 'spam' to class if the entry is spam
515
- if ( $entry->get_isspam() === 1 ) {
516
- $class .= ' spam';
517
- } else {
518
- $class .= ' nospam';
519
- }
520
-
521
- // Attach 'trash' to class if the entry is in trash
522
- if ( $entry->get_istrash() === 1 ) {
523
- $class .= ' trash';
524
- } else {
525
- $class .= ' notrash';
526
- }
527
 
528
- // Attach 'checked/unchecked' to class
529
- if ( $entry->get_ischecked() === 1 ) {
530
- $class .= ' checked';
531
- } else {
532
- $class .= ' unchecked';
533
- }
534
-
535
- // Attach 'visible/invisible' to class
536
- if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
537
- $class .= ' invisible';
538
- } else {
539
- $class .= ' visible';
540
- }
541
-
542
- // Add admin-entry class to an entry from an admin
543
- $author_id = $entry->get_author_id();
544
- $is_moderator = gwolle_gb_is_moderator( $author_id );
545
- if ( $is_moderator ) {
546
- $class .= ' admin-entry';
547
- }
548
 
549
  $postid = gwolle_gb_get_postid( (int) $entry->get_book_id() );
550
  if ( $postid ) {
@@ -574,17 +259,17 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
574
  }
575
 
576
  if ( $entry->get_id() == 0 ) {
577
- echo '<h3 class="h3_invisible">' . esc_html__('This entry is not yet visible.', 'gwolle-gb') . '</h3>';
578
  } else {
579
  if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
580
  echo '
581
- <h3 class="h3_visible">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
582
- <h3 class="h3_invisible" style="display:none;">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
583
  ';
584
  } else {
585
  echo '
586
- <h3 class="h3_visible" style="display:none;">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
587
- <h3 class="h3_invisible">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
588
  ';
589
  } ?>
590
 
@@ -629,7 +314,7 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
629
  } ?>
630
 
631
  <div id="publishing-action">
632
- <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Save', 'gwolle-gb'); ?>" />
633
  </div> <!-- .publishing-action -->
634
  <div class="clear"></div>
635
  <?php
@@ -640,7 +325,9 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
640
  * Metabox with quick actions for the entry (AJAX).
641
  */
642
  function gwolle_gb_editor_postbox_actions( $entry ) {
643
- global $class;
 
 
644
  if ( $entry->get_id() > 0 ) {
645
  echo '
646
  <p class="gwolle_gb_actions ' . $class . '">
@@ -677,7 +364,7 @@ function gwolle_gb_editor_postbox_actions( $entry ) {
677
  function gwolle_gb_editor_postbox_details( $entry ) {
678
  ?>
679
  <p>
680
- <?php esc_html_e('Author', 'gwolle-gb'); ?>: <span><?php
681
  if ( $entry->get_author_name() ) {
682
  echo gwolle_gb_sanitize_output( $entry->get_author_name() );
683
  } else {
@@ -691,7 +378,7 @@ function gwolle_gb_editor_postbox_details( $entry ) {
691
  echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
692
  } ?>
693
  </span><br />
694
- <?php esc_html_e('Date and time', 'gwolle-gb'); ?>: <span class="gb-datetime"><?php
695
  if ( $entry->get_datetime() > 0 ) {
696
  echo date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
697
  echo date_i18n( get_option('time_format'), $entry->get_datetime() );
@@ -723,24 +410,15 @@ function gwolle_gb_editor_postbox_details( $entry ) {
723
  echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
724
  } ?>
725
  </span><br />
726
- <?php esc_html_e('Book', 'gwolle-gb'); ?>: <span><?php echo $entry->get_book_id(); ?>
727
  </span><br />
728
  <span class="gwolle_gb_edit_meta">
729
  <a href="#" title="<?php esc_attr_e('Edit metadata', 'gwolle-gb'); ?>"><?php esc_html_e('Edit', 'gwolle-gb'); ?></a>
730
  </span>
731
  </p>
732
 
733
- <div class="gwolle_gb_edit_meta_inputs">
734
- <label for="gwolle_gb_author_name"><?php esc_html_e('Author', 'gwolle-gb'); ?>: </label><br />
735
- <input type="text" name="gwolle_gb_author_name" size="24" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_name() ); ?>" id="gwolle_gb_author_name" class="wp-exclude-emoji" /><br />
736
-
737
- <span><?php esc_html_e('Date and time', 'gwolle-gb'); ?>: </span><br />
738
- <div class="gwolle_gb_date"><?php
739
- gwolle_gb_touch_time( $entry ); ?>
740
- </div>
741
-
742
- <label for="gwolle_gb_book_id"><?php esc_html_e('Book ID', 'gwolle-gb'); ?>: </label><br />
743
- <input type="text" name="gwolle_gb_book_id" size="4" value="<?php echo (int) $entry->get_book_id(); ?>" id="gwolle_gb_book_id" />
744
  </div>
745
 
746
  <?php
@@ -773,3 +451,407 @@ function gwolle_gb_editor_postbox_logs( $entry ) {
773
  </ul>
774
  <?php
775
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  * Admin page with the entry editor. Used for new and existing entries.
14
  */
15
  function gwolle_gb_page_editor() {
 
16
 
17
+ if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  gwolle_gb_admin_enqueue();
22
  gwolle_gb_register();
23
 
24
+ $gwolle_gb_errors = false;
 
 
25
  $sectionHeading = esc_html__('Edit guestbook entry', 'gwolle-gb');
26
 
27
  // Always fetch the requested entry, so we can compare the $entry and the $_POST.
35
  if ( isset($entry_id) && $entry_id > 0 ) {
36
  $result = $entry->load( $entry_id );
37
  if ( ! $result ) {
38
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry could not be found.', 'gwolle-gb') . '</p>', true, false);
39
+ $gwolle_gb_errors = true;
40
  $sectionHeading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
41
  }
42
  } else {
43
  $sectionHeading = esc_html__('New guestbook entry', 'gwolle-gb');
44
  }
45
 
 
46
  /*
47
  * Handle the $_POST
48
  */
49
+ if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'editor' && $gwolle_gb_errors === false ) {
50
+ $entry = gwolle_gb_page_editor_update( $entry );
51
+ }
52
+ $gwolle_gb_messages = gwolle_gb_get_messages();
53
+ $gwolle_gb_errors = gwolle_gb_get_errors();
54
+ $messageclass = '';
55
+ if ( $gwolle_gb_errors ) {
56
+ $messageclass = 'error';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
 
58
 
59
  /*
60
  * Build the Page and the Form
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
  }
127
  */
128
  function gwolle_gb_editor_postbox_content( $entry ) {
129
  ?>
130
+ <textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji" placeholder="<?php esc_html_e('Message', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_content(), 'content' ); ?></textarea>
131
  <?php
132
  if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
133
  $settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
137
  $form_setting = gwolle_gb_get_setting( 'form' );
138
 
139
  if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
140
+ gwolle_gb_enqueue_markitup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  // Emoji symbols
143
  echo '<div class="gwolle_gb_emoji gwolle_gb_hide">';
157
  */
158
  function gwolle_gb_editor_postbox_website( $entry ) {
159
  ?>
160
+ <input type="url" name="gwolle_gb_author_website" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_website() ); ?>" id="author_website" placeholder="<?php esc_attr_e('Website', 'gwolle-gb'); ?>" />
161
  <p><?php
162
  /* translators: %s is a code element */
163
  echo sprintf( esc_html__('Example: %shttp://www.example.com/%s', 'gwolle-gb'), '<code>', '</code>' ); ?>
171
  */
172
  function gwolle_gb_editor_postbox_author_origin( $entry ) {
173
  ?>
174
+ <input type="text" name="gwolle_gb_author_origin" class="wp-exclude-emoji" placeholder="<?php esc_attr_e('City', 'gwolle-gb'); ?>" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_origin() ); ?>" id="author_origin" />
175
  <?php
176
  }
177
 
183
  $form_setting = gwolle_gb_get_setting( 'form' );
184
  ?>
185
 
186
+ <textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" class="wp-exclude-emoji" placeholder="<?php esc_attr_e('Admin Reply', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ); ?></textarea>
187
 
188
  <?php
189
  if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
202
  $admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
203
  if ( $admin_reply_name ) { ?>
204
  <p class="gb-admin_reply_uid"><?php
205
+ $admin_reply_header = '<em>' . sprintf( esc_html__('Admin Reply by: %s', 'gwolle-gb'), $admin_reply_name ) . '</em>';
206
  echo apply_filters( 'gwolle_gb_admin_reply_header', $admin_reply_header, $entry );
207
  ?>
208
  </p><?php
228
  * Metabox with the icons and checkboxes for quick glancing at the visibility of the entry.
229
  */
230
  function gwolle_gb_editor_postbox_icons( $entry ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
+ $class = gwolle_gb_editor_get_class( $entry );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
 
234
  $postid = gwolle_gb_get_postid( (int) $entry->get_book_id() );
235
  if ( $postid ) {
259
  }
260
 
261
  if ( $entry->get_id() == 0 ) {
262
+ echo '<h3 class="h3-invisible">' . esc_html__('This entry is not yet visible.', 'gwolle-gb') . '</h3>';
263
  } else {
264
  if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
265
  echo '
266
+ <h3 class="h3-visible">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
267
+ <h3 class="h3-invisible" style="display:none;">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
268
  ';
269
  } else {
270
  echo '
271
+ <h3 class="h3-visible" style="display:none;">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
272
+ <h3 class="h3-invisible">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
273
  ';
274
  } ?>
275
 
314
  } ?>
315
 
316
  <div id="publishing-action">
317
+ <input name="save" type="submit" class="button-primary" id="publish" value="<?php esc_attr_e('Save', 'gwolle-gb'); ?>" />
318
  </div> <!-- .publishing-action -->
319
  <div class="clear"></div>
320
  <?php
325
  * Metabox with quick actions for the entry (AJAX).
326
  */
327
  function gwolle_gb_editor_postbox_actions( $entry ) {
328
+
329
+ $class = gwolle_gb_editor_get_class( $entry );
330
+
331
  if ( $entry->get_id() > 0 ) {
332
  echo '
333
  <p class="gwolle_gb_actions ' . $class . '">
364
  function gwolle_gb_editor_postbox_details( $entry ) {
365
  ?>
366
  <p>
367
+ <?php esc_html_e('Author', 'gwolle-gb'); ?>: <span class="gb-editor-author-name"><?php
368
  if ( $entry->get_author_name() ) {
369
  echo gwolle_gb_sanitize_output( $entry->get_author_name() );
370
  } else {
378
  echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
379
  } ?>
380
  </span><br />
381
+ <?php esc_html_e('Date and time', 'gwolle-gb'); ?>: <span class="gb-editor-datetime"><?php
382
  if ( $entry->get_datetime() > 0 ) {
383
  echo date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
384
  echo date_i18n( get_option('time_format'), $entry->get_datetime() );
410
  echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
411
  } ?>
412
  </span><br />
413
+ <?php esc_html_e('Book', 'gwolle-gb'); ?>: <span class="gb-editor-book-id"><?php echo $entry->get_book_id(); ?>
414
  </span><br />
415
  <span class="gwolle_gb_edit_meta">
416
  <a href="#" title="<?php esc_attr_e('Edit metadata', 'gwolle-gb'); ?>"><?php esc_html_e('Edit', 'gwolle-gb'); ?></a>
417
  </span>
418
  </p>
419
 
420
+ <div class="gwolle_gb_editor_meta_inputs">
421
+ <?php gwolle_gb_editor_meta_inputs( $entry ); ?>
 
 
 
 
 
 
 
 
 
422
  </div>
423
 
424
  <?php
451
  </ul>
452
  <?php
453
  }
454
+
455
+
456
+ /*
457
+ * Taken from wp-admin/includes/template.php touch_time()
458
+ * Adapted for simplicity.
459
+ *
460
+ * @param object $entry instance of the class gb_entry
461
+ */
462
+ function gwolle_gb_editor_meta_inputs( $entry ) {
463
+ global $wp_locale;
464
+
465
+ ?>
466
+ <label for="gwolle_gb_author_name"><?php esc_html_e('Author', 'gwolle-gb'); ?>: </label><br />
467
+ <input type="text" name="gwolle_gb_author_name" size="24" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_name() ); ?>" id="gwolle_gb_author_name" class="wp-exclude-emoji" /><br />
468
+
469
+ <span><?php esc_html_e('Date and time', 'gwolle-gb'); ?>: </span><br />
470
+ <div class="gwolle_gb_date"><?php
471
+
472
+ $date = $entry->get_datetime();
473
+ if ( ! $date ) {
474
+ $date = current_time('timestamp');
475
+ }
476
+
477
+ $dd = date( 'd', $date );
478
+ $mm = date( 'm', $date );
479
+ $yy = date( 'Y', $date );
480
+ $hh = date( 'H', $date );
481
+ $mn = date( 'i', $date );
482
+
483
+ // Day
484
+ echo '<label><span class="screen-reader-text">' . esc_html__( 'Day', 'gwolle-gb' ) . '</span><input type="text" id="dd" name="dd" value="' . $dd . '" size="2" maxlength="2" autocomplete="off" /></label>';
485
+
486
+ // Month
487
+ echo '<label for="mm"><span class="screen-reader-text">' . esc_html__( 'Month', 'gwolle-gb' ) . '</span><select id="mm" name="mm">\n';
488
+ for ( $i = 1; $i < 13; $i = $i +1 ) {
489
+ $monthnum = zeroise($i, 2);
490
+ echo "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
491
+ /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
492
+ echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
493
+ }
494
+ echo '</select></label>';
495
+
496
+ // Year
497
+ echo '<label for="yy"><span class="screen-reader-text">' . esc_html__( 'Year', 'gwolle-gb' ) . '</span><input type="text" id="yy" name="yy" value="' . $yy . '" size="4" maxlength="4" autocomplete="off" /></label>';
498
+ echo '<br />';
499
+ // Hour
500
+ echo '<label for="hh"><span class="screen-reader-text">' . esc_html__( 'Hour', 'gwolle-gb' ) . '</span><input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2" autocomplete="off" /></label>:';
501
+ // Minute
502
+ echo '<label for="mn"><span class="screen-reader-text">' . esc_html__( 'Minute', 'gwolle-gb' ) . '</span><input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2" autocomplete="off" /></label>';
503
+ ?>
504
+
505
+ <div class="gwolle_gb_timestamp">
506
+ <!-- Clicking OK will place a timestamp here. -->
507
+ <input type="hidden" id="gwolle_gb_timestamp" name="gwolle_gb_timestamp" value="" />
508
+ </div>
509
+ </div>
510
+
511
+ <label for="gwolle_gb_book_id"><?php esc_html_e('Book ID', 'gwolle-gb'); ?>: </label><br />
512
+ <input type="text" name="gwolle_gb_book_id" size="4" value="<?php echo (int) $entry->get_book_id(); ?>" id="gwolle_gb_book_id" />
513
+
514
+ <p>
515
+ <a href="#" class="gwolle_gb_save_timestamp hide-if-no-js button" title="<?php esc_attr_e('Save the date and time', 'gwolle-gb'); ?>">
516
+ <?php esc_html_e('Save', 'gwolle-gb'); ?>
517
+ </a>
518
+ <a href="#" class="gwolle_gb_cancel_timestamp hide-if-no-js button-cancel" title="<?php esc_attr_e('Cancel saving date and time', 'gwolle-gb'); ?>">
519
+ <?php esc_html_e('Cancel', 'gwolle-gb'); ?>
520
+ </a>
521
+ </p>
522
+
523
+ <?php
524
+ }
525
+
526
+
527
+ /*
528
+ * Update admin page with the entry editor. Used for new and existing entries.
529
+ *
530
+ * @since 3.0.0
531
+ */
532
+ function gwolle_gb_page_editor_update( $entry ) {
533
+
534
+ if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
535
+ die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
536
+ }
537
+
538
+ /* Check Nonce */
539
+ $verified = false;
540
+ if ( isset($_POST['gwolle_gb_wpnonce']) ) {
541
+ $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_editor' );
542
+ if ( $verified === false ) {
543
+ // Nonce is invalid, so considered spam
544
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
545
+ return $entry;
546
+ }
547
+ }
548
+ if ( $verified === false ) {
549
+ // Nonce is invalid.
550
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
551
+ return $entry;
552
+ }
553
+
554
+ if ( ! isset($_POST['entry_id']) || $_POST['entry_id'] != $entry->get_id() ) {
555
+ gwolle_gb_add_message( '<p>' . esc_html__('Something strange happened.', 'gwolle-gb') . '</p>', true, false);
556
+ return $entry;
557
+ } else if ( $_POST['entry_id'] > 0 && $entry->get_id() > 0 ) {
558
+
559
+ /* Remove permanently and return early. */
560
+ if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' && isset($_POST['remove']) && $_POST['remove'] == 'on' ) {
561
+ if ( $entry->get_istrash() == 1 ) {
562
+ $entry->delete();
563
+ $entry->set_id(0);
564
+ $changed = true;
565
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry removed.', 'gwolle-gb') . '</p>', false, false);
566
+ $entry = new gwolle_gb_entry();
567
+ return $entry;
568
+ }
569
+ }
570
+
571
+ /* Set as checked or unchecked, and by whom */
572
+ if ( isset($_POST['ischecked']) && $_POST['ischecked'] == 'on' ) {
573
+ if ( $_POST['ischecked'] == 'on' && $entry->get_ischecked() == 0 ) {
574
+ $entry->set_ischecked( true );
575
+ $user_id = get_current_user_id(); // returns 0 if no current user
576
+ $entry->set_checkedby( $user_id );
577
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
578
+ gwolle_gb_clear_cache( $entry );
579
+ }
580
+ } else if ( $entry->get_ischecked() == 1 ) {
581
+ $entry->set_ischecked( false );
582
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
583
+ }
584
+
585
+ /* Set as spam or not, and submit as ham or spam to Akismet service */
586
+ if ( isset($_POST['isspam']) && $_POST['isspam'] == 'on' ) {
587
+ if ( $_POST['isspam'] == 'on' && $entry->get_isspam() == 0 ) {
588
+ $entry->set_isspam( true );
589
+ $result = gwolle_gb_akismet( $entry, 'submit-spam' );
590
+ if ( $result ) {
591
+ gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
592
+ }
593
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
594
+ }
595
+ } else if ( $entry->get_isspam() == 1 ) {
596
+ $entry->set_isspam( false );
597
+ $result = gwolle_gb_akismet( $entry, 'submit-ham' );
598
+ if ( $result ) {
599
+ gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
600
+ }
601
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
602
+ }
603
+
604
+ /* Set as trash or not */
605
+ if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' ) {
606
+ if ( $_POST['istrash'] == 'on' && $entry->get_istrash() == 0 ) {
607
+ $entry->set_istrash( true );
608
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
609
+ }
610
+ } else if ( $entry->get_istrash() == 1 ) {
611
+ $entry->set_istrash( false );
612
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
613
+ }
614
+
615
+ /* Check if the content changed, and update accordingly */
616
+ if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
617
+ if ( trim($_POST['gwolle_gb_content']) != $entry->get_content() ) {
618
+ $entry_content = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_content'], 'content' );
619
+ $entry->set_content( $entry_content );
620
+ }
621
+ }
622
+
623
+ /* Check if the website changed, and update accordingly */
624
+ if ( isset( $_POST['gwolle_gb_author_website'] ) ) {
625
+ $website = trim( $_POST['gwolle_gb_author_website'] );
626
+ } else {
627
+ $website = '';
628
+ }
629
+ if ( $website != $entry->get_author_website() ) {
630
+ $entry->set_author_website( $website );
631
+ }
632
+
633
+ /* Check if the author_origin changed, and update accordingly */
634
+ if ( isset($_POST['gwolle_gb_author_origin']) ) {
635
+ if ( $_POST['gwolle_gb_author_origin'] != $entry->get_author_origin() ) {
636
+ $entry_origin = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_origin'], 'author_origin' );
637
+ $entry->set_author_origin( $entry_origin );
638
+ }
639
+ }
640
+
641
+ /* Check if the admin_reply changed, and update and log accordingly */
642
+ if ( isset($_POST['gwolle_gb_admin_reply']) ) {
643
+ if ( trim($_POST['gwolle_gb_admin_reply']) != $entry->get_admin_reply() ) {
644
+ $gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
645
+ if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
646
+ $entry->set_admin_reply_uid( get_current_user_id() );
647
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
648
+ } else if ( $gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '' ) {
649
+ $entry->set_admin_reply_uid( 0 );
650
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-removed' );
651
+ } else if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '' ) {
652
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-updated' );
653
+ }
654
+ $entry->set_admin_reply( $gwolle_gb_admin_reply );
655
+ }
656
+ }
657
+
658
+ /* Mail the author about the Admin Reply, if so requested */
659
+ if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
660
+ if ( $_POST['gwolle_gb_admin_reply_mail_author'] == 'on' ) {
661
+ gwolle_gb_mail_author_on_admin_reply( $entry );
662
+ }
663
+ }
664
+
665
+ /* Check if the author_name changed, and update accordingly */
666
+ if ( isset($_POST['gwolle_gb_author_name']) ) {
667
+ if ( $_POST['gwolle_gb_author_name'] != $entry->get_author_name() ) {
668
+ $entry_name = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_name'], 'author_name' );
669
+ $entry->set_author_name( $entry_name );
670
+ }
671
+ }
672
+
673
+ /* Check if the datetime changed, and update accordingly */
674
+ if ( isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp']) ) {
675
+ if ( $_POST['gwolle_gb_timestamp'] != $entry->get_datetime() ) {
676
+ $entry->set_datetime( (int) $_POST['gwolle_gb_timestamp'] );
677
+ }
678
+ }
679
+
680
+ /* Check if the book_id changed, and update accordingly */
681
+ if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
682
+ if ( $_POST['gwolle_gb_book_id'] != $entry->get_book_id() ) {
683
+ $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
684
+ }
685
+ }
686
+
687
+ /* Save the entry */
688
+ $result = $entry->save();
689
+ if ($result ) {
690
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
691
+ gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
692
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
693
+ } else {
694
+ gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
695
+ }
696
+
697
+ } else if ( $_POST['entry_id'] == 0 && $entry->get_id() == 0 ) {
698
+
699
+ /*
700
+ * Check for input, and save accordingly. This is on a New Entry! (So no logging)
701
+ */
702
+
703
+ $data = Array();
704
+
705
+ /* Set as checked anyway, new entry is always by an admin */
706
+ $data['ischecked'] = true;
707
+ $user_id = get_current_user_id(); // returns 0 if no current user
708
+ $data['checkedby'] = $user_id;
709
+ $data['author_id'] = $user_id;
710
+
711
+ /* Set metadata of the admin */
712
+ $userdata = get_userdata( $user_id );
713
+
714
+ if (is_object($userdata)) {
715
+ if ( isset( $userdata->display_name ) ) {
716
+ $author_name = $userdata->display_name;
717
+ } else {
718
+ $author_name = $userdata->user_login;
719
+ }
720
+ $author_email = $userdata->user_email;
721
+ }
722
+ $data['author_name'] = $author_name;
723
+ $data['author_name'] = gwolle_gb_maybe_encode_emoji( $data['author_name'], 'author_name' );
724
+ $data['author_email'] = $author_email;
725
+
726
+ /* Set as Not Spam */
727
+ $data['isspam'] = false;
728
+
729
+ /* Do not set as trash */
730
+ $data['istrash'] = false;
731
+
732
+ /* Check if the content is filled in, and save accordingly */
733
+ if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
734
+ $data['content'] = $_POST['gwolle_gb_content'];
735
+ $data['content'] = gwolle_gb_maybe_encode_emoji( $data['content'], 'content' );
736
+ } else {
737
+ $form_setting = gwolle_gb_get_setting( 'form' );
738
+ 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' ) {
739
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>', true, false);
740
+ } else {
741
+ $data['content'] = '';
742
+ }
743
+ }
744
+
745
+ /* Check if the website is set, and save accordingly */
746
+ if ( isset($_POST['gwolle_gb_author_website']) ) {
747
+ if ( $_POST['gwolle_gb_author_website'] != '' ) {
748
+ $data['author_website'] = $_POST['gwolle_gb_author_website'];
749
+ } else {
750
+ $data['author_website'] = home_url();
751
+ }
752
+ }
753
+
754
+ /* Check if the author_origin is set, and save accordingly */
755
+ if ( isset($_POST['gwolle_gb_author_origin']) ) {
756
+ if ( $_POST['gwolle_gb_author_origin'] != '' ) {
757
+ $data['author_origin'] = $_POST['gwolle_gb_author_origin'];
758
+ $data['author_origin'] = gwolle_gb_maybe_encode_emoji( $data['author_origin'], 'author_origin' );
759
+ }
760
+ }
761
+
762
+ /* Check if the admin_reply is set, and save accordingly */
763
+ if ( isset($_POST['gwolle_gb_admin_reply']) ) {
764
+ if ( $_POST['gwolle_gb_admin_reply'] != '' ) {
765
+ $data['admin_reply'] = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
766
+ $data['admin_reply_uid'] = get_current_user_id();
767
+ gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
768
+ }
769
+ }
770
+
771
+ /* Check if the book_id is set, and save accordingly */
772
+ if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
773
+ $entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
774
+ }
775
+
776
+ /* Network Information */
777
+ $set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
778
+ $set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
779
+ if ( $set_author_ip && ($set_author_ip2 == 'true') ) {
780
+ $entry->set_author_ip( $_SERVER['REMOTE_ADDR'] );
781
+ $entry->set_author_host( gethostbyaddr( $_SERVER['REMOTE_ADDR'] ) );
782
+ }
783
+
784
+ $result1 = $entry->set_data( $data );
785
+ if ( $result1 ) {
786
+ $result2 = $entry->save();
787
+ if ( $result1 && $result2 ) {
788
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry saved.', 'gwolle-gb') . '</p>', false, false);
789
+ gwolle_gb_clear_cache( $entry );
790
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
791
+ } else {
792
+ gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
793
+ }
794
+ } else {
795
+ gwolle_gb_add_message( '<p>' . esc_html__('Entry was not saved.', 'gwolle-gb') . '</p>', true, false);
796
+ }
797
+ }
798
+ return $entry;
799
+ }
800
+
801
+
802
+ /*
803
+ * Get editor class for this entry.
804
+ *
805
+ * @param object $entry instance of gwolle_gb_entry class.
806
+ * @return string text string with CSS classes.
807
+ *
808
+ * @since 3.0.0
809
+ */
810
+ function gwolle_gb_editor_get_class( $entry ) {
811
+
812
+ static $class_static;
813
+
814
+ if ( $class_static ) {
815
+ return $class_static;
816
+ }
817
+
818
+ $class = '';
819
+ // Attach 'spam' to class if the entry is spam
820
+ if ( $entry->get_isspam() === 1 ) {
821
+ $class .= 'spam';
822
+ } else {
823
+ $class .= 'nospam';
824
+ }
825
+
826
+ // Attach 'trash' to class if the entry is in trash
827
+ if ( $entry->get_istrash() === 1 ) {
828
+ $class .= ' trash';
829
+ } else {
830
+ $class .= ' notrash';
831
+ }
832
+
833
+ // Attach 'checked/unchecked' to class
834
+ if ( $entry->get_ischecked() === 1 ) {
835
+ $class .= ' checked';
836
+ } else {
837
+ $class .= ' unchecked';
838
+ }
839
+
840
+ // Attach 'visible/invisible' to class
841
+ if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
842
+ $class .= ' invisible';
843
+ } else {
844
+ $class .= ' visible';
845
+ }
846
+
847
+ // Add admin-entry class to an entry from an admin
848
+ $author_id = $entry->get_author_id();
849
+ $is_moderator = gwolle_gb_is_moderator( $author_id );
850
+ if ( $is_moderator ) {
851
+ $class .= ' admin-entry';
852
+ }
853
+
854
+ $class_static = $class;
855
+ return $class_static;
856
+
857
+ }
admin/gb-page-entries.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
  /*
3
- * entries.php
4
  * Displays the guestbook entries in a list.
5
  */
6
 
@@ -15,309 +14,23 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
15
  */
16
  function gwolle_gb_page_entries() {
17
 
18
- if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) {
19
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
20
  }
21
 
22
  gwolle_gb_admin_enqueue();
23
 
24
- $gwolle_gb_errors = '';
25
- $gwolle_gb_messages = '';
26
  $show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
27
 
28
  if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
29
- $action = '';
30
- if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'check' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'check' ) ) {
31
- $action = 'check';
32
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'uncheck' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'uncheck' ) ) {
33
- $action = 'uncheck';
34
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'spam' ) ) {
35
- $action = 'spam';
36
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'no-spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'no-spam' ) ) {
37
- $action = 'no-spam';
38
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'akismet' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'akismet' ) ) {
39
- $action = 'akismet';
40
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'trash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'trash' ) ) {
41
- $action = 'trash';
42
- } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'untrash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'untrash' ) ) {
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
-
51
- /* Check if we are not sending in more entries than were even listed... */
52
- $continue_on_entries_checked = false;
53
- $entries_checked = 0;
54
- $num_entries = get_option('gwolle_gb-entries_per_page', 20);
55
- foreach( array_keys($_POST) as $postElementName ) {
56
- if (strpos($postElementName, 'check') > -1 && !strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
57
- $entries_checked++;
58
- }
59
- }
60
- if ( $entries_checked < ( $num_entries + 1 ) ) {
61
- $continue_on_entries_checked = true;
62
- } else if ( $show == 'user' ) {
63
- // special case for mass edit all entries from user.
64
- $continue_on_entries_checked = true;
65
- } else {
66
- $gwolle_gb_messages .= '<p>' . /* translators: Someone seems to be abusing the website in strange ways. */ esc_html__('It seems you checked more entries then were even listed on the page.', 'gwolle-gb') . '</p>';
67
- $gwolle_gb_errors = 'error';
68
- }
69
-
70
- /* Check Nonce */
71
- $continue_on_nonce_checked = false;
72
- if ( isset($_POST['gwolle_gb_wpnonce']) ) {
73
- $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_entries' );
74
- if ( $verified == true ) {
75
- $continue_on_nonce_checked = true;
76
- } else {
77
- // Nonce is invalid, so considered spam
78
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
79
- $gwolle_gb_errors = 'error';
80
- }
81
- }
82
- /* End of security checks. */
83
-
84
-
85
- if ( $action != '' && $continue_on_entries_checked && $continue_on_nonce_checked ) {
86
- // Initialize variables to generate messages with
87
- $entries_handled = 0;
88
- $entries_not_handled = 0;
89
- $akismet_spam = 0;
90
- $akismet_not_spam = 0;
91
- $akismet_already_spam = 0;
92
- $akismet_already_not_spam = 0;
93
-
94
- /* Handle the $_POST entries */
95
- foreach( array_keys($_POST) as $postElementName ) {
96
- if (strpos($postElementName, 'check') > -1 && !strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
97
- $entry_id = str_replace('check-','',$postElementName);
98
- $entry_id = intval($entry_id);
99
- if ( isset($entry_id) && $entry_id > 0 ) {
100
- $entry = new gwolle_gb_entry();
101
- $result = $entry->load( $entry_id );
102
- if ( $result ) {
103
-
104
- if ( $action == 'check' ) {
105
- if ( $entry->get_ischecked() == 0 ) {
106
- $entry->set_ischecked( true );
107
- $user_id = get_current_user_id(); // returns 0 if no current user
108
- $entry->set_checkedby( $user_id );
109
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
110
- $result = $entry->save();
111
- if ( $result ) {
112
- $entries_handled++;
113
- do_action( 'gwolle_gb_save_entry_admin', $entry );
114
- } else {
115
- $entries_not_handled++;
116
- }
117
- } else {
118
- $entries_not_handled++;
119
- }
120
- } else if ( $action == 'uncheck' ) {
121
- if ( $entry->get_ischecked() == 1 ) {
122
- $entry->set_ischecked( false );
123
- $user_id = get_current_user_id(); // returns 0 if no current user
124
- $entry->set_checkedby( $user_id );
125
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
126
- $result = $entry->save();
127
- if ( $result ) {
128
- $entries_handled++;
129
- do_action( 'gwolle_gb_save_entry_admin', $entry );
130
- } else {
131
- $entries_not_handled++;
132
- }
133
- } else {
134
- $entries_not_handled++;
135
- }
136
- } else if ( $action == 'spam' ) {
137
-
138
- if ( $entry->get_isspam() == 0 ) {
139
- $entry->set_isspam( true );
140
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
141
- gwolle_gb_akismet( $entry, 'submit-spam' );
142
- }
143
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
144
- $result = $entry->save();
145
- if ( $result ) {
146
- $entries_handled++;
147
- do_action( 'gwolle_gb_save_entry_admin', $entry );
148
- } else {
149
- $entries_not_handled++;
150
- }
151
- } else {
152
- $entries_not_handled++;
153
- }
154
- } else if ( $action == 'no-spam' ) {
155
- if ( $entry->get_isspam() == 1 ) {
156
- $entry->set_isspam( false );
157
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
158
- gwolle_gb_akismet( $entry, 'submit-ham' );
159
- }
160
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
161
- $result = $entry->save();
162
- if ( $result ) {
163
- $entries_handled++;
164
- do_action( 'gwolle_gb_save_entry_admin', $entry );
165
- } else {
166
- $entries_not_handled++;
167
- }
168
- } else {
169
- $entries_not_handled++;
170
- }
171
- } else if ( $action == 'akismet' ) {
172
- /* Check for spam and set accordingly */
173
- if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
174
- $isspam = gwolle_gb_akismet( $entry, 'comment-check' );
175
- if ( $isspam ) {
176
- // Returned true, so considered spam
177
- if ( $entry->get_isspam() == 0 ) {
178
- $entry->set_isspam( true );
179
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
180
- $result = $entry->save();
181
- if ( $result ) {
182
- $akismet_spam++;
183
- do_action( 'gwolle_gb_save_entry_admin', $entry );
184
- } else {
185
- $akismet_not_spam++;
186
- }
187
- } else {
188
- $akismet_already_spam++;
189
- }
190
- } else {
191
- if ( $entry->get_isspam() == 1 ) {
192
- $entry->set_isspam( false );
193
- gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
194
- $result = $entry->save();
195
- if ( $result ) {
196
- $akismet_not_spam++;
197
- do_action( 'gwolle_gb_save_entry_admin', $entry );
198
- } else {
199
- $akismet_spam++;
200
- }
201
- } else {
202
- $akismet_already_not_spam++;
203
- }
204
- }
205
- }
206
- } else if ( $action == 'trash' ) {
207
- if ( $entry->get_istrash() == 0 ) {
208
- $entry->set_istrash( true );
209
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
210
- $result = $entry->save();
211
- if ( $result ) {
212
- $entries_handled++;
213
- do_action( 'gwolle_gb_save_entry_admin', $entry );
214
- } else {
215
- $entries_not_handled++;
216
- }
217
- } else {
218
- $entries_not_handled++;
219
- }
220
- } else if ( $action == 'untrash' ) {
221
- if ( $entry->get_istrash() == 1 ) {
222
- $entry->set_istrash( false );
223
- gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
224
- $result = $entry->save();
225
- if ( $result ) {
226
- $entries_handled++;
227
- do_action( 'gwolle_gb_save_entry_admin', $entry );
228
- } else {
229
- $entries_not_handled++;
230
- }
231
- } else {
232
- $entries_not_handled++;
233
- }
234
- } else if ( $action == 'remove' ) {
235
- $result = $entry->delete();
236
- if ( $result ) {
237
- $entries_handled++;
238
- do_action( 'gwolle_gb_save_entry_admin', $entry );
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++;
255
- }
256
- } else { // entry_id is not set or not > 0
257
- $entries_not_handled++;
258
- }
259
- } // no entry with the check-'entry_id' input, continue
260
- } // foreach
261
-
262
-
263
- /* Construct Message */
264
- if ( $action == 'check' ) {
265
- /* translators: %s is the number of entries */
266
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry checked.','%s entries checked.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
267
- } else if ( $action == 'uncheck' ) {
268
- /* translators: %s is the number of entries */
269
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry unchecked.','%s entries unchecked.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
270
- } else if ( $action == 'spam' ) {
271
- /* translators: %s is the number of entries */
272
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry marked as spam and submitted to Akismet as spam (if Akismet was enabled).','%s entries marked as spam and submitted to Akismet as spam (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
273
- } else if ( $action == 'no-spam' ) {
274
- /* translators: %s is the number of entries */
275
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry marked as not spam and submitted to Akismet as ham (if Akismet was enabled).','%s entries marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
276
- } else if ( $action == 'akismet' ) {
277
- if ( $akismet_spam > 0 ) {
278
- /* translators: %s is the number of entries */
279
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry considered spam and marked as such.','%s entries considered spam and marked as such.', $akismet_spam, 'gwolle-gb'), $akismet_spam ). '</p>';
280
- }
281
- if ( $akismet_not_spam > 0 ) {
282
- /* translators: %s is the number of entries */
283
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry considered not spam and marked as such.','%s entries considered not spam and marked as such.', $akismet_not_spam, 'gwolle-gb'), $akismet_not_spam ). '</p>';
284
- }
285
- if ( $akismet_already_spam > 0 ) {
286
- /* translators: %s is the number of entries */
287
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry already considered spam and not changed.','%s entries already considered spam and not changed.', $akismet_already_spam, 'gwolle-gb'), $akismet_already_spam ). '</p>';
288
- }
289
- if ( $akismet_already_not_spam > 0 ) {
290
- /* translators: %s is the number of entries */
291
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry already considered not spam and not changed.','%s entries already considered not spam and not changed.', $akismet_already_not_spam, 'gwolle-gb'), $akismet_already_not_spam ). '</p>';
292
- }
293
- } else if ( $action == 'trash' ) {
294
- /* translators: %s is the number of entries */
295
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry moved to trash.','%s entries moved to trash.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
296
- } else if ( $action == 'untrash' ) {
297
- /* translators: %s is the number of entries */
298
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry recovered from trash.','%s entries recovered from trash.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
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
-
308
- if ( isset( $_POST['delete_all'] ) || isset( $_POST['delete_all2'] ) ) {
309
- if ( $continue_on_nonce_checked ) {
310
- // Delete all entries in spam or trash
311
- if ( isset($_POST['show']) && in_array($_POST['show'], array('spam', 'trash')) ) {
312
- $delstatus = $_POST['show'];
313
- $deleted = gwolle_gb_del_entries( $delstatus );
314
- /* translators: %s is the number of entries */
315
- $gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $deleted, 'gwolle-gb'), $deleted ). '</p>';
316
- }
317
- }
318
- }
319
  }
320
-
321
 
322
  // Get entry counts
323
  $count = Array();
@@ -343,10 +56,10 @@ function gwolle_gb_page_entries() {
343
 
344
  $pages_total = ceil( $count[$show] / $num_entries );
345
  if ($pageNum > $pages_total) {
346
- $pageNum = 1; // page doesnot exist, return to first page
347
  }
348
 
349
- // Calculate Query
350
  if ($pageNum == 1 && $count[$show] > 0) {
351
  $offset = 0;
352
  } elseif ($count[$show] == 0) {
@@ -360,7 +73,7 @@ function gwolle_gb_page_entries() {
360
  $book_id = (int) $_GET['book_id'];
361
  }
362
 
363
- // Get the entries
364
  if ( $show == 'checked' ) {
365
  $entries = gwolle_gb_get_entries(array(
366
  'num_entries' => $num_entries,
@@ -464,7 +177,7 @@ function gwolle_gb_page_entries() {
464
  <?php
465
  if ( $gwolle_gb_messages ) {
466
  echo '
467
- <div id="message" class="updated fade notice is-dismissible ' . $gwolle_gb_errors . ' ">' .
468
  $gwolle_gb_messages .
469
  '</div>';
470
  } ?>
@@ -628,7 +341,7 @@ function gwolle_gb_page_entries() {
628
  $request_uri = $_SERVER['REQUEST_URI'];
629
  $rowOdd = true;
630
  $html_output = '';
631
- if ( !is_array($entries) || empty($entries) ) {
632
  $colspan = (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') ? 8 : 7;
633
  $html_output .= '
634
  <tr>
@@ -795,7 +508,7 @@ function gwolle_gb_page_entries() {
795
  }
796
 
797
  // Only show controls when there are entries
798
- if ( is_array($entries) && !empty($entries) ) {
799
  echo $massEditControls_select . $massEditControls . $empty_button;
800
  } ?>
801
  </div>
@@ -810,3 +523,309 @@ function gwolle_gb_page_entries() {
810
  </div>
811
  <?php
812
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /*
 
3
  * Displays the guestbook entries in a list.
4
  */
5
 
14
  */
15
  function gwolle_gb_page_entries() {
16
 
17
+ if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  gwolle_gb_admin_enqueue();
22
 
 
 
23
  $show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
24
 
25
  if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
26
+ gwolle_gb_page_entries_update();
27
+ }
28
+ $gwolle_gb_messages = gwolle_gb_get_messages();
29
+ $gwolle_gb_errors = gwolle_gb_get_errors();
30
+ $messageclass = '';
31
+ if ( $gwolle_gb_errors ) {
32
+ $messageclass = 'error';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
 
34
 
35
  // Get entry counts
36
  $count = Array();
56
 
57
  $pages_total = ceil( $count[$show] / $num_entries );
58
  if ($pageNum > $pages_total) {
59
+ $pageNum = 1; // page does not exist, return to first page.
60
  }
61
 
62
+ // Calculate query.
63
  if ($pageNum == 1 && $count[$show] > 0) {
64
  $offset = 0;
65
  } elseif ($count[$show] == 0) {
73
  $book_id = (int) $_GET['book_id'];
74
  }
75
 
76
+ // Get the entries.
77
  if ( $show == 'checked' ) {
78
  $entries = gwolle_gb_get_entries(array(
79
  'num_entries' => $num_entries,
177
  <?php
178
  if ( $gwolle_gb_messages ) {
179
  echo '
180
+ <div id="message" class="updated fade notice is-dismissible ' . $messageclass . ' ">' .
181
  $gwolle_gb_messages .
182
  '</div>';
183
  } ?>
341
  $request_uri = $_SERVER['REQUEST_URI'];
342
  $rowOdd = true;
343
  $html_output = '';
344
+ if ( ! is_array( $entries ) || empty( $entries ) ) {
345
  $colspan = (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') ? 8 : 7;
346
  $html_output .= '
347
  <tr>
508
  }
509
 
510
  // Only show controls when there are entries
511
+ if ( is_array($entries) && ! empty($entries) ) {
512
  echo $massEditControls_select . $massEditControls . $empty_button;
513
  } ?>
514
  </div>
523
  </div>
524
  <?php
525
  }
526
+
527
+
528
+
529
+ /*
530
+ * Update admin page with lists of entries.
531
+ *
532
+ * @since 3.0.0
533
+ */
534
+ function gwolle_gb_page_entries_update() {
535
+
536
+ if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
537
+ die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
538
+ }
539
+
540
+ $show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
541
+
542
+ /* Check Nonce */
543
+ if ( isset($_POST['gwolle_gb_wpnonce']) ) {
544
+ $verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_entries' );
545
+ if ( $verified == false ) {
546
+ // Nonce is invalid, so considered spam.
547
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
548
+ return;
549
+ }
550
+ } else {
551
+ // Nonce is not set, so considered spam.
552
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
553
+ return;
554
+ }
555
+
556
+ /* Check if we are not sending in more entries than were even listed. */
557
+ $entries_checked = 0;
558
+ $num_entries = get_option('gwolle_gb-entries_per_page', 20);
559
+ foreach( array_keys($_POST) as $postElementName ) {
560
+ if (strpos($postElementName, 'check') > -1 && ! strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
561
+ $entries_checked++;
562
+ }
563
+ }
564
+ if ( $entries_checked < ( $num_entries + 1 ) ) {
565
+ // number of entries checked is less or equal to the number listed on the page.
566
+ } else if ( $show == 'user' ) {
567
+ // special case for mass edit all entries from user.
568
+ } else {
569
+ gwolle_gb_add_message( '<p>' . esc_html__('It seems you checked more entries then were even listed on the page.', 'gwolle-gb') . '</p>', true, false);
570
+ return;
571
+ }
572
+ /* End of security checks. */
573
+
574
+
575
+ if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
576
+ $action = '';
577
+ if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'check' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'check' ) ) {
578
+ $action = 'check';
579
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'uncheck' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'uncheck' ) ) {
580
+ $action = 'uncheck';
581
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'spam' ) ) {
582
+ $action = 'spam';
583
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'no-spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'no-spam' ) ) {
584
+ $action = 'no-spam';
585
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'akismet' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'akismet' ) ) {
586
+ $action = 'akismet';
587
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'trash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'trash' ) ) {
588
+ $action = 'trash';
589
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'untrash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'untrash' ) ) {
590
+ $action = 'untrash';
591
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'remove' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'remove' ) ) {
592
+ $action = 'remove';
593
+ } else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'anon' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'anon' ) ) {
594
+ $action = 'anon';
595
+ }
596
+ if ( $action == '' && $show != 'user' && ! isset( $_POST['delete_all'] ) && ! isset( $_POST['delete_all2'] ) ) {
597
+ gwolle_gb_add_message( '<p>' . esc_html__('Something went wrong. Please try again.', 'gwolle-gb') . '</p>', true, false);
598
+ return;
599
+ }
600
+
601
+ // Initialize variables to generate messages with.
602
+ $entries_handled = 0;
603
+ $entries_not_handled = 0;
604
+ $akismet_spam = 0;
605
+ $akismet_not_spam = 0;
606
+ $akismet_already_spam = 0;
607
+ $akismet_already_not_spam = 0;
608
+
609
+ foreach( array_keys($_POST) as $postElementName ) {
610
+ if (strpos($postElementName, 'check') > -1 && ! strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
611
+ $entry_id = str_replace('check-','',$postElementName);
612
+ $entry_id = intval($entry_id);
613
+ if ( isset($entry_id) && $entry_id > 0 ) {
614
+ $entry = new gwolle_gb_entry();
615
+ $result = $entry->load( $entry_id );
616
+ if ( $result ) {
617
+
618
+ if ( $action == 'check' ) {
619
+ if ( $entry->get_ischecked() == 0 ) {
620
+ $entry->set_ischecked( true );
621
+ $user_id = get_current_user_id(); // returns 0 if no current user
622
+ $entry->set_checkedby( $user_id );
623
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
624
+ $result = $entry->save();
625
+ if ( $result ) {
626
+ $entries_handled++;
627
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
628
+ } else {
629
+ $entries_not_handled++;
630
+ }
631
+ } else {
632
+ $entries_not_handled++;
633
+ }
634
+ } else if ( $action == 'uncheck' ) {
635
+ if ( $entry->get_ischecked() == 1 ) {
636
+ $entry->set_ischecked( false );
637
+ $user_id = get_current_user_id(); // returns 0 if no current user
638
+ $entry->set_checkedby( $user_id );
639
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
640
+ $result = $entry->save();
641
+ if ( $result ) {
642
+ $entries_handled++;
643
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
644
+ } else {
645
+ $entries_not_handled++;
646
+ }
647
+ } else {
648
+ $entries_not_handled++;
649
+ }
650
+ } else if ( $action == 'spam' ) {
651
+
652
+ if ( $entry->get_isspam() == 0 ) {
653
+ $entry->set_isspam( true );
654
+ if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
655
+ gwolle_gb_akismet( $entry, 'submit-spam' );
656
+ }
657
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
658
+ $result = $entry->save();
659
+ if ( $result ) {
660
+ $entries_handled++;
661
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
662
+ } else {
663
+ $entries_not_handled++;
664
+ }
665
+ } else {
666
+ $entries_not_handled++;
667
+ }
668
+ } else if ( $action == 'no-spam' ) {
669
+ if ( $entry->get_isspam() == 1 ) {
670
+ $entry->set_isspam( false );
671
+ if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
672
+ gwolle_gb_akismet( $entry, 'submit-ham' );
673
+ }
674
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
675
+ $result = $entry->save();
676
+ if ( $result ) {
677
+ $entries_handled++;
678
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
679
+ } else {
680
+ $entries_not_handled++;
681
+ }
682
+ } else {
683
+ $entries_not_handled++;
684
+ }
685
+ } else if ( $action == 'akismet' ) {
686
+ /* Check for spam and set accordingly */
687
+ if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
688
+ $isspam = gwolle_gb_akismet( $entry, 'comment-check' );
689
+ if ( $isspam ) {
690
+ // Returned true, so considered spam
691
+ if ( $entry->get_isspam() == 0 ) {
692
+ $entry->set_isspam( true );
693
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
694
+ $result = $entry->save();
695
+ if ( $result ) {
696
+ $akismet_spam++;
697
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
698
+ } else {
699
+ $akismet_not_spam++;
700
+ }
701
+ } else {
702
+ $akismet_already_spam++;
703
+ }
704
+ } else {
705
+ if ( $entry->get_isspam() == 1 ) {
706
+ $entry->set_isspam( false );
707
+ gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
708
+ $result = $entry->save();
709
+ if ( $result ) {
710
+ $akismet_not_spam++;
711
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
712
+ } else {
713
+ $akismet_spam++;
714
+ }
715
+ } else {
716
+ $akismet_already_not_spam++;
717
+ }
718
+ }
719
+ }
720
+ } else if ( $action == 'trash' ) {
721
+ if ( $entry->get_istrash() == 0 ) {
722
+ $entry->set_istrash( true );
723
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
724
+ $result = $entry->save();
725
+ if ( $result ) {
726
+ $entries_handled++;
727
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
728
+ } else {
729
+ $entries_not_handled++;
730
+ }
731
+ } else {
732
+ $entries_not_handled++;
733
+ }
734
+ } else if ( $action == 'untrash' ) {
735
+ if ( $entry->get_istrash() == 1 ) {
736
+ $entry->set_istrash( false );
737
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
738
+ $result = $entry->save();
739
+ if ( $result ) {
740
+ $entries_handled++;
741
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
742
+ } else {
743
+ $entries_not_handled++;
744
+ }
745
+ } else {
746
+ $entries_not_handled++;
747
+ }
748
+ } else if ( $action == 'remove' ) {
749
+ $result = $entry->delete();
750
+ if ( $result ) {
751
+ $entries_handled++;
752
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
753
+ } else {
754
+ $entries_not_handled++;
755
+ }
756
+ } else if ( $action == 'anon' ) {
757
+ $entry = gwolle_gb_privacy_anonymize_entry( $entry );
758
+ $result = $entry->save();
759
+ if ( $result ) {
760
+ $entries_handled++;
761
+ do_action( 'gwolle_gb_save_entry_admin', $entry );
762
+ gwolle_gb_add_log_entry( $entry->get_id(), 'entry-anonymized' );
763
+ } else {
764
+ $entries_not_handled++;
765
+ }
766
+ }
767
+ } else { // no result on load()
768
+ $entries_not_handled++;
769
+ }
770
+ } else { // entry_id is not set or not > 0
771
+ $entries_not_handled++;
772
+ }
773
+ } // no entry with the check-'entry_id' input, continue
774
+ } // foreach
775
+
776
+
777
+ /* Construct Message */
778
+ if ( $action == 'check' ) {
779
+ /* translators: %s is the number of entries */
780
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry checked.','%s entries checked.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
781
+ } else if ( $action == 'uncheck' ) {
782
+ /* translators: %s is the number of entries */
783
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry unchecked.','%s entries unchecked.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
784
+ } else if ( $action == 'spam' ) {
785
+ /* translators: %s is the number of entries */
786
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry marked as spam and submitted to Akismet as spam (if Akismet was enabled).','%s entries marked as spam and submitted to Akismet as spam (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
787
+ } else if ( $action == 'no-spam' ) {
788
+ /* translators: %s is the number of entries */
789
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry marked as not spam and submitted to Akismet as ham (if Akismet was enabled).','%s entries marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
790
+ } else if ( $action == 'akismet' ) {
791
+ if ( $akismet_spam > 0 ) {
792
+ /* translators: %s is the number of entries */
793
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry considered spam and marked as such.','%s entries considered spam and marked as such.', $akismet_spam, 'gwolle-gb'), $akismet_spam ) . '</p>', false, false);
794
+ }
795
+ if ( $akismet_not_spam > 0 ) {
796
+ /* translators: %s is the number of entries */
797
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry considered not spam and marked as such.','%s entries considered not spam and marked as such.', $akismet_not_spam, 'gwolle-gb'), $akismet_not_spam ) . '</p>', false, false);
798
+ }
799
+ if ( $akismet_already_spam > 0 ) {
800
+ /* translators: %s is the number of entries */
801
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry already considered spam and not changed.','%s entries already considered spam and not changed.', $akismet_already_spam, 'gwolle-gb'), $akismet_already_spam ) . '</p>', false, false);
802
+ }
803
+ if ( $akismet_already_not_spam > 0 ) {
804
+ /* translators: %s is the number of entries */
805
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry already considered not spam and not changed.','%s entries already considered not spam and not changed.', $akismet_already_not_spam, 'gwolle-gb'), $akismet_already_not_spam ) . '</p>', false, false);
806
+ }
807
+ } else if ( $action == 'trash' ) {
808
+ /* translators: %s is the number of entries */
809
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry moved to trash.','%s entries moved to trash.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
810
+ } else if ( $action == 'untrash' ) {
811
+ /* translators: %s is the number of entries */
812
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry recovered from trash.','%s entries recovered from trash.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
813
+ } else if ( $action == 'remove' ) {
814
+ /* translators: %s is the number of entries */
815
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
816
+ } else if ( $action == 'anon' ) {
817
+ /* translators: %s is the number of entries */
818
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry anonymized.','%s entries anonymized.', $entries_handled, 'gwolle-gb'), $entries_handled ) . '</p>', false, false);
819
+ }
820
+
821
+ if ( isset( $_POST['delete_all'] ) || isset( $_POST['delete_all2'] ) ) {
822
+ // Delete all entries in spam or trash.
823
+ if ( isset($_POST['show']) && in_array($_POST['show'], array('spam', 'trash')) ) {
824
+ $status = $_POST['show'];
825
+ $deleted = gwolle_gb_del_entries( $status );
826
+ /* translators: %s is the number of entries */
827
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $deleted, 'gwolle-gb'), $deleted ) . '</p>', false, false);
828
+ }
829
+ }
830
+ }
831
+ }
admin/gb-page-export.php CHANGED
@@ -48,7 +48,7 @@ function gwolle_gb_page_export() {
48
  function gwolle_gb_export_postbox() {
49
 
50
  $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
51
- $num_entries = 3000;
52
  $parts = ceil( $count / $num_entries );
53
  ?>
54
 
@@ -140,7 +140,7 @@ function gwolle_gb_export_callback() {
140
  }
141
 
142
  $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
143
- $num_entries = 3000;
144
  $parts = ceil( $count / $num_entries );
145
  if ( isset( $_POST['gwolle_gb_export_part']) && ( (int) $_POST['gwolle_gb_export_part'] < ($parts + 1) ) ) {
146
  $part = (int) $_POST['gwolle_gb_export_part'];
@@ -148,7 +148,7 @@ function gwolle_gb_export_callback() {
148
  echo '(Gwolle-GB) Wrong part requested.';
149
  die();
150
  }
151
- $offset = ($part * 3000) - 3000;
152
 
153
  $entries = gwolle_gb_get_entries(array(
154
  'num_entries' => $num_entries,
@@ -214,7 +214,7 @@ function gwolle_gb_export_callback() {
214
  }
215
  $row[] = $meta;
216
 
217
- fputcsv($output, $row);
218
 
219
  gwolle_gb_add_log_entry( $entry->get_id(), 'exported-to-csv' );
220
 
@@ -378,7 +378,7 @@ function gwolle_gb_export_user_callback() {
378
  }
379
  $row[] = $meta;
380
 
381
- fputcsv($output, $row);
382
 
383
  gwolle_gb_add_log_entry( $entry->get_id(), 'exported-to-csv' );
384
 
48
  function gwolle_gb_export_postbox() {
49
 
50
  $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
51
+ $num_entries = 2000;
52
  $parts = ceil( $count / $num_entries );
53
  ?>
54
 
140
  }
141
 
142
  $count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
143
+ $num_entries = 2000;
144
  $parts = ceil( $count / $num_entries );
145
  if ( isset( $_POST['gwolle_gb_export_part']) && ( (int) $_POST['gwolle_gb_export_part'] < ($parts + 1) ) ) {
146
  $part = (int) $_POST['gwolle_gb_export_part'];
148
  echo '(Gwolle-GB) Wrong part requested.';
149
  die();
150
  }
151
+ $offset = ($part * $num_entries) - $num_entries;
152
 
153
  $entries = gwolle_gb_get_entries(array(
154
  'num_entries' => $num_entries,
214
  }
215
  $row[] = $meta;
216
 
217
+ fputcsv($output, $row, ',', '"');
218
 
219
  gwolle_gb_add_log_entry( $entry->get_id(), 'exported-to-csv' );
220
 
378
  }
379
  $row[] = $meta;
380
 
381
+ fputcsv($output, $row, ',', '"');
382
 
383
  gwolle_gb_add_log_entry( $entry->get_id(), 'exported-to-csv' );
384
 
admin/gb-page-import.php CHANGED
@@ -1,10 +1,9 @@
1
- <?php /*
2
- *
3
- * import.php
4
  * Lets the user import guestbook entries from other plugins.
5
  * Currently supported:
6
  * - DMSGuestbook (http://wordpress.org/plugins/dmsguestbook/).
7
- * - WordPress coments from a page, post or just all.
8
  * - Gwolle-GB through a CSV-file.
9
  */
10
 
@@ -22,11 +21,10 @@ function gwolle_gb_page_import() {
22
 
23
  gwolle_gb_admin_enqueue();
24
 
25
- if ( function_exists('current_user_can') && !current_user_can('manage_options') ) {
26
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
27
  }
28
 
29
- /* $_POST handling. */
30
  if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'gwolle_gb_import' ) {
31
  gwolle_gb_page_import_post();
32
  }
1
+ <?php
2
+ /*
 
3
  * Lets the user import guestbook entries from other plugins.
4
  * Currently supported:
5
  * - DMSGuestbook (http://wordpress.org/plugins/dmsguestbook/).
6
+ * - WordPress comments from a page, post or just all.
7
  * - Gwolle-GB through a CSV-file.
8
  */
9
 
21
 
22
  gwolle_gb_admin_enqueue();
23
 
24
+ if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
25
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
26
  }
27
 
 
28
  if ( isset( $_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'gwolle_gb_import' ) {
29
  gwolle_gb_page_import_post();
30
  }
admin/gb-page-settings.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- * Settings page for the guestbook
4
  */
5
 
6
  // No direct calls to this script
@@ -14,26 +14,114 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
14
  */
15
  function gwolle_gb_page_settings() {
16
 
17
- if ( function_exists('current_user_can') && !current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  gwolle_gb_admin_enqueue();
22
-
23
- $active_tab = 'gwolle_gb_forms';
24
  $saved = false;
25
- $debug_test = false;
26
- $uninstalled = false;
27
- $gwolle_gb_messages = '';
28
- //if ( WP_DEBUG ) { echo "_POST: "; var_dump($_POST); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  if ( isset( $_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options' ) {
31
  if ( isset( $_POST['gwolle_gb_tab'] ) ) {
32
  $active_tab = $_POST['gwolle_gb_tab'];
 
33
 
34
  switch ( $active_tab ) {
35
  case 'gwolle_gb_forms':
36
- /* Form Settings */
37
 
38
  /* Check Nonce */
39
  $verified = false;
@@ -42,55 +130,44 @@ function gwolle_gb_page_settings() {
42
  }
43
  if ( $verified == false ) {
44
  // Nonce is invalid.
45
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
46
- $gwolle_gb_errors = 'error';
47
  break;
48
  }
49
 
50
  if (isset($_POST['require_login']) && $_POST['require_login'] == 'on') {
51
  update_option('gwolle_gb-require_login', 'true');
52
- $saved = true;
53
  } else {
54
  update_option('gwolle_gb-require_login', 'false');
55
- $saved = true;
56
  }
57
 
58
  if (isset($_POST['labels_float']) && $_POST['labels_float'] == 'on') {
59
  update_option('gwolle_gb-labels_float', 'true');
60
- $saved = true;
61
  } else {
62
  update_option('gwolle_gb-labels_float', 'false');
63
- $saved = true;
64
  }
65
 
66
  // Always save it, even when empty, for MultiLingual plugins.
67
  $header = gwolle_gb_sanitize_input( $_POST['gb_header'] );
68
  update_option('gwolle_gb-header', $header);
69
- $saved = true;
70
 
71
  $notice = gwolle_gb_sanitize_input( $_POST['notice'], 'setting_textarea' );
72
  update_option('gwolle_gb-notice', $notice);
73
- $saved = true;
74
 
75
  if (isset($_POST['form_ajax']) && $_POST['form_ajax'] == 'on') {
76
  update_option('gwolle_gb-form_ajax', 'true');
77
- $saved = true;
78
  } else {
79
  update_option('gwolle_gb-form_ajax', 'false');
80
- $saved = true;
81
  }
82
 
83
  if (isset($_POST['store_ip']) && $_POST['store_ip'] == 'on') {
84
  update_option('gwolle_gb-store_ip', 'true');
85
- $saved = true;
86
  } else {
87
  update_option('gwolle_gb-store_ip', 'false');
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(
@@ -119,10 +196,8 @@ function gwolle_gb_page_settings() {
119
  }
120
  $form_setting = serialize( $form_setting );
121
  update_option( 'gwolle_gb-form', $form_setting );
122
- $saved = true;
123
  break;
124
  case 'gwolle_gb_reading':
125
- /* Reading Settings */
126
 
127
  /* Check Nonce */
128
  $verified = false;
@@ -131,67 +206,52 @@ function gwolle_gb_page_settings() {
131
  }
132
  if ( $verified == false ) {
133
  // Nonce is invalid.
134
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
135
- $gwolle_gb_errors = 'error';
136
  break;
137
  }
138
 
139
  if ( isset($_POST['entriesPerPage']) && is_numeric($_POST['entriesPerPage']) && $_POST['entriesPerPage'] > 0 ) {
140
  update_option('gwolle_gb-entriesPerPage', (int) $_POST['entriesPerPage']);
141
- $saved = true;
142
  }
143
 
144
  if (isset($_POST['showLineBreaks']) && $_POST['showLineBreaks'] == 'on') {
145
  update_option('gwolle_gb-showLineBreaks', 'true');
146
- $saved = true;
147
  } else {
148
  update_option('gwolle_gb-showLineBreaks', 'false');
149
- $saved = true;
150
  }
151
 
152
  if ( isset($_POST['excerpt_length']) && is_numeric($_POST['excerpt_length']) ) {
153
  update_option('gwolle_gb-excerpt_length', (int) $_POST['excerpt_length']);
154
- $saved = true;
155
  }
156
 
157
  if (isset($_POST['showSmilies']) && $_POST['showSmilies'] == 'on') {
158
  update_option('gwolle_gb-showSmilies', 'true');
159
- $saved = true;
160
  } else {
161
  update_option('gwolle_gb-showSmilies', 'false');
162
- $saved = true;
163
  }
164
 
165
  if (isset($_POST['linkAuthorWebsite']) && $_POST['linkAuthorWebsite'] == 'on') {
166
  update_option('gwolle_gb-linkAuthorWebsite', 'true');
167
- $saved = true;
168
  } else {
169
  update_option('gwolle_gb-linkAuthorWebsite', 'false');
170
- $saved = true;
171
  }
172
 
173
  if (isset($_POST['admin_style']) && $_POST['admin_style'] == 'on') {
174
  update_option('gwolle_gb-admin_style', 'true');
175
- $saved = true;
176
  } else {
177
  update_option('gwolle_gb-admin_style', 'false');
178
- $saved = true;
179
  }
180
 
181
  if (isset($_POST['navigation']) && $_POST['navigation'] == 0) {
182
  update_option('gwolle_gb-navigation', 0);
183
- $saved = true;
184
  } else if (isset($_POST['navigation']) && $_POST['navigation'] == 1) {
185
  update_option('gwolle_gb-navigation', 1);
186
- $saved = true;
187
  }
188
 
189
  if (isset($_POST['paginate_all']) && $_POST['paginate_all'] == 'on') {
190
  update_option('gwolle_gb-paginate_all', 'true');
191
- $saved = true;
192
  } else {
193
  update_option('gwolle_gb-paginate_all', 'false');
194
- $saved = true;
195
  }
196
 
197
  $list = Array(
@@ -214,10 +274,8 @@ function gwolle_gb_page_settings() {
214
  }
215
  $read_setting = serialize( $read_setting );
216
  update_option( 'gwolle_gb-read', $read_setting );
217
- $saved = true;
218
  break;
219
  case 'gwolle_gb_admin':
220
- /* Admin Settings */
221
 
222
  /* Check Nonce */
223
  $verified = false;
@@ -226,27 +284,22 @@ function gwolle_gb_page_settings() {
226
  }
227
  if ( $verified == false ) {
228
  // Nonce is invalid.
229
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
230
- $gwolle_gb_errors = 'error';
231
  break;
232
  }
233
 
234
  if ( isset($_POST['entries_per_page']) && is_numeric($_POST['entries_per_page']) && $_POST['entries_per_page'] > 0 ) {
235
  update_option( 'gwolle_gb-entries_per_page', (int) $_POST['entries_per_page']);
236
- $saved = true;
237
  }
238
 
239
  if (isset($_POST['showEntryIcons']) && $_POST['showEntryIcons'] == 'on') {
240
  update_option('gwolle_gb-showEntryIcons', 'true');
241
- $saved = true;
242
  } else {
243
  update_option('gwolle_gb-showEntryIcons', 'false');
244
- $saved = true;
245
  }
246
 
247
  break;
248
  case 'gwolle_gb_antispam':
249
- /* Anti-Spam Settings */
250
 
251
  /* Check Nonce */
252
  $verified = false;
@@ -255,95 +308,73 @@ function gwolle_gb_page_settings() {
255
  }
256
  if ( $verified == false ) {
257
  // Nonce is invalid.
258
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
259
- $gwolle_gb_errors = 'error';
260
  break;
261
  }
262
 
263
  if (isset($_POST['moderate-entries']) && $_POST['moderate-entries'] == 'on') {
264
  update_option('gwolle_gb-moderate-entries', 'true');
265
- $saved = true;
266
  } else {
267
  update_option('gwolle_gb-moderate-entries', 'false');
268
- $saved = true;
269
  }
270
 
271
  if (isset($_POST['refuse-spam']) && $_POST['refuse-spam'] == 'on') {
272
  update_option('gwolle_gb-refuse-spam', 'true');
273
- $saved = true;
274
  } else {
275
  update_option('gwolle_gb-refuse-spam', 'false');
276
- $saved = true;
277
  }
278
 
279
  if (isset($_POST['honeypot']) && $_POST['honeypot'] == 'on') {
280
  update_option('gwolle_gb-honeypot', 'true');
281
- $saved = true;
282
  } else {
283
  update_option('gwolle_gb-honeypot', 'false');
284
- $saved = true;
285
  }
286
 
287
  if (isset($_POST['gwolle_gb_nonce']) && $_POST['gwolle_gb_nonce'] == 'on') {
288
  update_option('gwolle_gb-nonce', 'true');
289
- $saved = true;
290
  } else {
291
  update_option('gwolle_gb-nonce', 'false');
292
- $saved = true;
293
  }
294
 
295
  if (isset($_POST['gwolle_gb_longtext']) && $_POST['gwolle_gb_longtext'] == 'on') {
296
  update_option('gwolle_gb-longtext', 'true');
297
- $saved = true;
298
  } else {
299
  update_option('gwolle_gb-longtext', 'false');
300
- $saved = true;
301
  }
302
 
303
  if (isset($_POST['gwolle_gb_linkchecker']) && $_POST['gwolle_gb_linkchecker'] == 'on') {
304
  update_option('gwolle_gb-linkchecker', 'true');
305
- $saved = true;
306
  } else {
307
  update_option('gwolle_gb-linkchecker', 'false');
308
- $saved = true;
309
  }
310
 
311
  if (isset($_POST['gwolle_gb_timeout']) && $_POST['gwolle_gb_timeout'] == 'on') {
312
  update_option('gwolle_gb-timeout', 'true');
313
- $saved = true;
314
  } else {
315
  update_option('gwolle_gb-timeout', 'false');
316
- $saved = true;
317
  }
318
 
319
  if (isset($_POST['akismet-active']) && $_POST['akismet-active'] == 'on') {
320
  update_option('gwolle_gb-akismet-active', 'true');
321
- $saved = true;
322
  } else {
323
  update_option('gwolle_gb-akismet-active', 'false');
324
- $saved = true;
325
  }
326
 
327
  if (isset($_POST['gwolle_gb_sfs']) && $_POST['gwolle_gb_sfs'] == 'on') {
328
  update_option('gwolle_gb-sfs', 'true');
329
- $saved = true;
330
  } else {
331
  update_option('gwolle_gb-sfs', 'false');
332
- $saved = true;
333
  }
334
 
335
  if ( isset($_POST['antispam-question']) ) {
336
  update_option('gwolle_gb-antispam-question', gwolle_gb_sanitize_input($_POST['antispam-question']));
337
- $saved = true;
338
  }
339
  if ( isset($_POST['antispam-answer']) ) {
340
  update_option('gwolle_gb-antispam-answer', gwolle_gb_sanitize_input($_POST['antispam-answer']));
341
- $saved = true;
342
  }
343
 
344
  break;
345
  case 'gwolle_gb_mail':
346
- /* Mail Settings */
347
 
348
  /* Check Nonce */
349
  $verified = false;
@@ -352,8 +383,7 @@ function gwolle_gb_page_settings() {
352
  }
353
  if ( $verified == false ) {
354
  // Nonce is invalid.
355
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
356
- $gwolle_gb_errors = 'error';
357
  break;
358
  }
359
 
@@ -362,7 +392,6 @@ function gwolle_gb_page_settings() {
362
  if ( filter_var( $admin_mail_from, FILTER_VALIDATE_EMAIL ) ) {
363
  // Valid Email address.
364
  update_option('gwolle_gb-mail-from', $admin_mail_from);
365
- $saved = true;
366
  }
367
  }
368
 
@@ -385,7 +414,6 @@ function gwolle_gb_page_settings() {
385
 
386
  $user_ids = implode(",", $user_ids);
387
  update_option('gwolle_gb-notifyByMail', $user_ids);
388
- $saved = true;
389
  }
390
 
391
  if ( isset($_POST['subscribe']) && $_POST['subscribe'] > 0 ) {
@@ -408,61 +436,34 @@ function gwolle_gb_page_settings() {
408
 
409
  $user_ids = implode(",", $user_ids);
410
  update_option('gwolle_gb-notifyByMail', $user_ids);
411
- $saved = true;
412
  }
413
 
414
  if ( isset($_POST['adminMailContent']) ) {
415
  $mail_content = gwolle_gb_sanitize_input( $_POST['adminMailContent'], 'setting_textarea' );
416
  update_option('gwolle_gb-adminMailContent', $mail_content);
417
- $saved = true;
418
  }
419
 
420
  if (isset($_POST['mail_author']) && $_POST['mail_author'] == 'on') {
421
  update_option('gwolle_gb-mail_author', 'true');
422
- $saved = true;
423
  } else {
424
  update_option('gwolle_gb-mail_author', 'false');
425
- $saved = true;
426
  }
427
 
428
  if ( isset($_POST['authorMailContent']) ) {
429
  $mail_content = gwolle_gb_sanitize_input( $_POST['authorMailContent'], 'setting_textarea' );
430
  update_option('gwolle_gb-authorMailContent', $mail_content);
431
- $saved = true;
432
  }
433
 
434
  if ( isset($_POST['gwolle_gb-mail_admin_replyContent']) ) {
435
  $mail_content = gwolle_gb_sanitize_input( $_POST['gwolle_gb-mail_admin_replyContent'], 'setting_textarea' );
436
  update_option('gwolle_gb-mail_admin_replyContent', $mail_content);
437
- $saved = true;
438
  }
439
 
440
  break;
441
  case 'gwolle_gb_debug':
442
- /* Debug */
443
-
444
- /* Check Nonce */
445
- $verified = false;
446
- if ( isset($_POST['gwolle_gb_page_settings_debugtab']) ) {
447
- $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_debugtab'], 'gwolle_gb_page_settings_debugtab' );
448
- }
449
- if ( $verified == false ) {
450
- // Nonce is invalid.
451
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
452
- $gwolle_gb_errors = 'error';
453
- break;
454
- }
455
-
456
- if (isset( $_POST['gwolle_gb_debug']) ) {
457
- // Save test entries
458
- $debug_test = true;
459
- } else {
460
- // Uninstallation not confirmed.
461
- }
462
 
463
  break;
464
  case 'gwolle_gb_uninstall':
465
- /* Uninstall */
466
 
467
  /* Check Nonce */
468
  $verified = false;
@@ -471,8 +472,7 @@ function gwolle_gb_page_settings() {
471
  }
472
  if ( $verified == false ) {
473
  // Nonce is invalid.
474
- $gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
475
- $gwolle_gb_errors = 'error';
476
  break;
477
  }
478
 
@@ -480,7 +480,11 @@ function gwolle_gb_page_settings() {
480
  if ( function_exists('is_multisite') && ! is_multisite() ) {
481
  // uninstall the plugin -> delete all tables and preferences of the plugin
482
  gwolle_gb_uninstall();
483
- $uninstalled = true;
 
 
 
 
484
  }
485
  } else {
486
  // Uninstallation not confirmed.
@@ -489,81 +493,29 @@ function gwolle_gb_page_settings() {
489
  break;
490
  default:
491
  /* Just load the first tab */
492
- $active_tab = 'gwolle_gb_forms';
493
  }
494
  }
495
- } ?>
496
-
497
- <div class="wrap gwolle_gb">
498
-
499
- <div id="icon-gwolle-gb"><br /></div>
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 */ ?>
517
- <h2 class="nav-tab-wrapper gwolle-nav-tab-wrapper">
518
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_forms') { echo "nav-tab-active";} ?>" rel="gwolle_gb_forms"><?php /* translators: Settings page tab */ esc_html_e('Form', 'gwolle-gb'); ?></a>
519
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_reading') { echo "nav-tab-active";} ?>" rel="gwolle_gb_reading"><?php /* translators: Settings page tab */ esc_html_e('Reading', 'gwolle-gb'); ?></a>
520
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_admin') { echo "nav-tab-active";} ?>" rel="gwolle_gb_admin"><?php /* translators: Settings page tab */ esc_html_e('Admin', 'gwolle-gb'); ?></a>
521
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_antispam') { echo "nav-tab-active";} ?>" rel="gwolle_gb_antispam"><?php /* translators: Settings page tab */ esc_html_e('Anti-spam', 'gwolle-gb'); ?></a>
522
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_mail') { echo "nav-tab-active";} ?>" rel="gwolle_gb_mail"><?php /* translators: Settings page tab */ esc_html_e('Notifications', 'gwolle-gb'); ?></a>
523
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_debug') { echo "nav-tab-active";} ?>" rel="gwolle_gb_debug"><?php /* translators: Settings page tab */ esc_html_e('Debug', 'gwolle-gb'); ?></a>
524
- <?php if ( function_exists('is_multisite') && ! is_multisite() ) { ?>
525
- <a href="#" class="nav-tab <?php if ($active_tab == 'gwolle_gb_uninstall') { echo "nav-tab-active";} ?>" rel="gwolle_gb_uninstall"><?php /* translators: Settings page tab */ esc_html_e('Uninstall', 'gwolle-gb'); ?></a>
526
- <?php } ?>
527
- </h2>
528
-
529
-
530
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_forms <?php if ($active_tab == 'gwolle_gb_forms') { echo "active";} ?>" method="post" action="">
531
- <?php gwolle_gb_page_settingstab_form(); ?>
532
- </form>
533
-
534
-
535
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_reading <?php if ($active_tab == 'gwolle_gb_reading') { echo "active";} ?>" method="post" action="">
536
- <?php gwolle_gb_page_settingstab_reading(); ?>
537
- </form>
538
-
539
-
540
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_admin <?php if ($active_tab == 'gwolle_gb_admin') { echo "active";} ?>" method="post" action="">
541
- <?php gwolle_gb_page_settingstab_admin(); ?>
542
- </form>
543
-
544
-
545
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_antispam <?php if ($active_tab == 'gwolle_gb_antispam') { echo "active";} ?>" method="post" action="">
546
- <?php gwolle_gb_page_settingstab_antispam(); ?>
547
- </form>
548
-
549
-
550
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_mail <?php if ($active_tab == 'gwolle_gb_mail') { echo "active";} ?>" method="post" action="">
551
- <?php gwolle_gb_page_settingstab_email(); ?>
552
- </form>
553
 
554
 
555
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_debug <?php if ($active_tab == 'gwolle_gb_debug') { echo "active";} ?>" method="post" action="">
556
- <?php gwolle_gb_page_settingstab_debug( $debug_test ); ?>
557
- </form>
 
 
 
 
 
 
558
 
 
559
 
560
- <?php if ( function_exists('is_multisite') && ! is_multisite() ) { ?>
561
- <form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_uninstall <?php if ($active_tab == 'gwolle_gb_uninstall') { echo "active";} ?>" method="post" action="">
562
- <?php gwolle_gb_page_settingstab_uninstall( $uninstalled ); ?>
563
- </form>
564
- <?php } ?>
565
 
 
566
 
567
- </div> <!-- wrap -->
568
- <?php
569
  }
1
  <?php
2
  /*
3
+ * Settings page for the guestbook.
4
  */
5
 
6
  // No direct calls to this script
14
  */
15
  function gwolle_gb_page_settings() {
16
 
17
+ if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
19
  }
20
 
21
  gwolle_gb_admin_enqueue();
 
 
22
  $saved = false;
23
+ $active_tab = 'gwolle_gb_forms';
24
+
25
+ if ( isset( $_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options' ) {
26
+ gwolle_gb_page_settings_update();
27
+ $saved = true;
28
+ $active_tab = gwolle_gb_settings_active_tab();
29
+ }
30
+ $gwolle_gb_messages = gwolle_gb_get_messages();
31
+ $gwolle_gb_errors = gwolle_gb_get_errors();
32
+ ?>
33
+
34
+ <div class="wrap gwolle_gb">
35
+
36
+ <div id="icon-gwolle-gb"><br /></div>
37
+ <h1><?php esc_html_e('Settings', 'gwolle-gb'); ?></h1>
38
+
39
+ <?php
40
+ if ( $gwolle_gb_errors ) {
41
+ echo '
42
+ <div id="message" class="updated fade notice is-dismissible error">' .
43
+ $gwolle_gb_messages .
44
+ '</div>';
45
+ } else if ( $saved ) {
46
+ echo '
47
+ <div id="message" class="updated fade notice is-dismissible">
48
+ <p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>' .
49
+ $gwolle_gb_messages .
50
+ '</div>';
51
+ }
52
+
53
+ /* The rel attribute will be the form that becomes active */ ?>
54
+ <h2 class="nav-tab-wrapper gwolle-nav-tab-wrapper" role="tablist">
55
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_forms') { echo "nav-tab-active";} ?>" rel="gwolle_gb_forms"><?php /* translators: Settings page tab */ esc_html_e('Form', 'gwolle-gb'); ?></a>
56
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_reading') { echo "nav-tab-active";} ?>" rel="gwolle_gb_reading"><?php /* translators: Settings page tab */ esc_html_e('Reading', 'gwolle-gb'); ?></a>
57
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_admin') { echo "nav-tab-active";} ?>" rel="gwolle_gb_admin"><?php /* translators: Settings page tab */ esc_html_e('Admin', 'gwolle-gb'); ?></a>
58
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_antispam') { echo "nav-tab-active";} ?>" rel="gwolle_gb_antispam"><?php /* translators: Settings page tab */ esc_html_e('Anti-spam', 'gwolle-gb'); ?></a>
59
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_mail') { echo "nav-tab-active";} ?>" rel="gwolle_gb_mail"><?php /* translators: Settings page tab */ esc_html_e('Notifications', 'gwolle-gb'); ?></a>
60
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_debug') { echo "nav-tab-active";} ?>" rel="gwolle_gb_debug"><?php /* translators: Settings page tab */ esc_html_e('Debug', 'gwolle-gb'); ?></a>
61
+ <?php if ( function_exists('is_multisite') && ! is_multisite() ) { ?>
62
+ <a href="#" role="tab" class="nav-tab <?php if ($active_tab == 'gwolle_gb_uninstall') { echo "nav-tab-active";} ?>" rel="gwolle_gb_uninstall"><?php /* translators: Settings page tab */ esc_html_e('Uninstall', 'gwolle-gb'); ?></a>
63
+ <?php } ?>
64
+ </h2>
65
+
66
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_forms <?php if ($active_tab == 'gwolle_gb_forms') { echo "active";} ?>" method="post" action="">
67
+ <?php gwolle_gb_page_settingstab_form(); ?>
68
+ </form>
69
+
70
+
71
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_reading <?php if ($active_tab == 'gwolle_gb_reading') { echo "active";} ?>" method="post" action="">
72
+ <?php gwolle_gb_page_settingstab_reading(); ?>
73
+ </form>
74
+
75
+
76
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_admin <?php if ($active_tab == 'gwolle_gb_admin') { echo "active";} ?>" method="post" action="">
77
+ <?php gwolle_gb_page_settingstab_admin(); ?>
78
+ </form>
79
+
80
+
81
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_antispam <?php if ($active_tab == 'gwolle_gb_antispam') { echo "active";} ?>" method="post" action="">
82
+ <?php gwolle_gb_page_settingstab_antispam(); ?>
83
+ </form>
84
+
85
+
86
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_mail <?php if ($active_tab == 'gwolle_gb_mail') { echo "active";} ?>" method="post" action="">
87
+ <?php gwolle_gb_page_settingstab_email(); ?>
88
+ </form>
89
+
90
+
91
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_debug <?php if ($active_tab == 'gwolle_gb_debug') { echo "active";} ?>" method="post" action="">
92
+ <?php gwolle_gb_page_settingstab_debug(); ?>
93
+ </form>
94
+
95
+
96
+ <?php if ( function_exists('is_multisite') && ! is_multisite() ) { ?>
97
+ <form name="gwolle_gb_options" role="tabpanel" class="gwolle_gb_options gwolle_gb_uninstall <?php if ($active_tab == 'gwolle_gb_uninstall') { echo "active";} ?>" method="post" action="">
98
+ <?php gwolle_gb_page_settingstab_uninstall(); ?>
99
+ </form>
100
+ <?php } ?>
101
+
102
+ </div> <!-- wrap -->
103
+ <?php
104
+ }
105
+
106
+
107
+ /*
108
+ * Update Settings.
109
+ *
110
+ * @since 3.0.0
111
+ */
112
+ function gwolle_gb_page_settings_update() {
113
+
114
+ if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
115
+ die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
116
+ }
117
 
118
  if ( isset( $_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options' ) {
119
  if ( isset( $_POST['gwolle_gb_tab'] ) ) {
120
  $active_tab = $_POST['gwolle_gb_tab'];
121
+ gwolle_gb_settings_active_tab( $active_tab );
122
 
123
  switch ( $active_tab ) {
124
  case 'gwolle_gb_forms':
 
125
 
126
  /* Check Nonce */
127
  $verified = false;
130
  }
131
  if ( $verified == false ) {
132
  // Nonce is invalid.
133
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
 
134
  break;
135
  }
136
 
137
  if (isset($_POST['require_login']) && $_POST['require_login'] == 'on') {
138
  update_option('gwolle_gb-require_login', 'true');
 
139
  } else {
140
  update_option('gwolle_gb-require_login', 'false');
 
141
  }
142
 
143
  if (isset($_POST['labels_float']) && $_POST['labels_float'] == 'on') {
144
  update_option('gwolle_gb-labels_float', 'true');
 
145
  } else {
146
  update_option('gwolle_gb-labels_float', 'false');
 
147
  }
148
 
149
  // Always save it, even when empty, for MultiLingual plugins.
150
  $header = gwolle_gb_sanitize_input( $_POST['gb_header'] );
151
  update_option('gwolle_gb-header', $header);
 
152
 
153
  $notice = gwolle_gb_sanitize_input( $_POST['notice'], 'setting_textarea' );
154
  update_option('gwolle_gb-notice', $notice);
 
155
 
156
  if (isset($_POST['form_ajax']) && $_POST['form_ajax'] == 'on') {
157
  update_option('gwolle_gb-form_ajax', 'true');
 
158
  } else {
159
  update_option('gwolle_gb-form_ajax', 'false');
 
160
  }
161
 
162
  if (isset($_POST['store_ip']) && $_POST['store_ip'] == 'on') {
163
  update_option('gwolle_gb-store_ip', 'true');
 
164
  } else {
165
  update_option('gwolle_gb-store_ip', 'false');
 
166
  }
167
 
168
  if (isset($_POST['gb_remove_ip']) && $_POST['gb_remove_ip'] == 'on') {
169
  gwolle_gb_remove_ip_host();
170
+ gwolle_gb_add_message( '<p>' . esc_html__('IP address and hostname was removed from all the entries.', 'gwolle-gb') . '</p>', false, false);
171
  }
172
 
173
  $list = Array(
196
  }
197
  $form_setting = serialize( $form_setting );
198
  update_option( 'gwolle_gb-form', $form_setting );
 
199
  break;
200
  case 'gwolle_gb_reading':
 
201
 
202
  /* Check Nonce */
203
  $verified = false;
206
  }
207
  if ( $verified == false ) {
208
  // Nonce is invalid.
209
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
 
210
  break;
211
  }
212
 
213
  if ( isset($_POST['entriesPerPage']) && is_numeric($_POST['entriesPerPage']) && $_POST['entriesPerPage'] > 0 ) {
214
  update_option('gwolle_gb-entriesPerPage', (int) $_POST['entriesPerPage']);
 
215
  }
216
 
217
  if (isset($_POST['showLineBreaks']) && $_POST['showLineBreaks'] == 'on') {
218
  update_option('gwolle_gb-showLineBreaks', 'true');
 
219
  } else {
220
  update_option('gwolle_gb-showLineBreaks', 'false');
 
221
  }
222
 
223
  if ( isset($_POST['excerpt_length']) && is_numeric($_POST['excerpt_length']) ) {
224
  update_option('gwolle_gb-excerpt_length', (int) $_POST['excerpt_length']);
 
225
  }
226
 
227
  if (isset($_POST['showSmilies']) && $_POST['showSmilies'] == 'on') {
228
  update_option('gwolle_gb-showSmilies', 'true');
 
229
  } else {
230
  update_option('gwolle_gb-showSmilies', 'false');
 
231
  }
232
 
233
  if (isset($_POST['linkAuthorWebsite']) && $_POST['linkAuthorWebsite'] == 'on') {
234
  update_option('gwolle_gb-linkAuthorWebsite', 'true');
 
235
  } else {
236
  update_option('gwolle_gb-linkAuthorWebsite', 'false');
 
237
  }
238
 
239
  if (isset($_POST['admin_style']) && $_POST['admin_style'] == 'on') {
240
  update_option('gwolle_gb-admin_style', 'true');
 
241
  } else {
242
  update_option('gwolle_gb-admin_style', 'false');
 
243
  }
244
 
245
  if (isset($_POST['navigation']) && $_POST['navigation'] == 0) {
246
  update_option('gwolle_gb-navigation', 0);
 
247
  } else if (isset($_POST['navigation']) && $_POST['navigation'] == 1) {
248
  update_option('gwolle_gb-navigation', 1);
 
249
  }
250
 
251
  if (isset($_POST['paginate_all']) && $_POST['paginate_all'] == 'on') {
252
  update_option('gwolle_gb-paginate_all', 'true');
 
253
  } else {
254
  update_option('gwolle_gb-paginate_all', 'false');
 
255
  }
256
 
257
  $list = Array(
274
  }
275
  $read_setting = serialize( $read_setting );
276
  update_option( 'gwolle_gb-read', $read_setting );
 
277
  break;
278
  case 'gwolle_gb_admin':
 
279
 
280
  /* Check Nonce */
281
  $verified = false;
284
  }
285
  if ( $verified == false ) {
286
  // Nonce is invalid.
287
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
 
288
  break;
289
  }
290
 
291
  if ( isset($_POST['entries_per_page']) && is_numeric($_POST['entries_per_page']) && $_POST['entries_per_page'] > 0 ) {
292
  update_option( 'gwolle_gb-entries_per_page', (int) $_POST['entries_per_page']);
 
293
  }
294
 
295
  if (isset($_POST['showEntryIcons']) && $_POST['showEntryIcons'] == 'on') {
296
  update_option('gwolle_gb-showEntryIcons', 'true');
 
297
  } else {
298
  update_option('gwolle_gb-showEntryIcons', 'false');
 
299
  }
300
 
301
  break;
302
  case 'gwolle_gb_antispam':
 
303
 
304
  /* Check Nonce */
305
  $verified = false;
308
  }
309
  if ( $verified == false ) {
310
  // Nonce is invalid.
311
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
 
312
  break;
313
  }
314
 
315
  if (isset($_POST['moderate-entries']) && $_POST['moderate-entries'] == 'on') {
316
  update_option('gwolle_gb-moderate-entries', 'true');
 
317
  } else {
318
  update_option('gwolle_gb-moderate-entries', 'false');
 
319
  }
320
 
321
  if (isset($_POST['refuse-spam']) && $_POST['refuse-spam'] == 'on') {
322
  update_option('gwolle_gb-refuse-spam', 'true');
 
323
  } else {
324
  update_option('gwolle_gb-refuse-spam', 'false');
 
325
  }
326
 
327
  if (isset($_POST['honeypot']) && $_POST['honeypot'] == 'on') {
328
  update_option('gwolle_gb-honeypot', 'true');
 
329
  } else {
330
  update_option('gwolle_gb-honeypot', 'false');
 
331
  }
332
 
333
  if (isset($_POST['gwolle_gb_nonce']) && $_POST['gwolle_gb_nonce'] == 'on') {
334
  update_option('gwolle_gb-nonce', 'true');
 
335
  } else {
336
  update_option('gwolle_gb-nonce', 'false');
 
337
  }
338
 
339
  if (isset($_POST['gwolle_gb_longtext']) && $_POST['gwolle_gb_longtext'] == 'on') {
340
  update_option('gwolle_gb-longtext', 'true');
 
341
  } else {
342
  update_option('gwolle_gb-longtext', 'false');
 
343
  }
344
 
345
  if (isset($_POST['gwolle_gb_linkchecker']) && $_POST['gwolle_gb_linkchecker'] == 'on') {
346
  update_option('gwolle_gb-linkchecker', 'true');
 
347
  } else {
348
  update_option('gwolle_gb-linkchecker', 'false');
 
349
  }
350
 
351
  if (isset($_POST['gwolle_gb_timeout']) && $_POST['gwolle_gb_timeout'] == 'on') {
352
  update_option('gwolle_gb-timeout', 'true');
 
353
  } else {
354
  update_option('gwolle_gb-timeout', 'false');
 
355
  }
356
 
357
  if (isset($_POST['akismet-active']) && $_POST['akismet-active'] == 'on') {
358
  update_option('gwolle_gb-akismet-active', 'true');
 
359
  } else {
360
  update_option('gwolle_gb-akismet-active', 'false');
 
361
  }
362
 
363
  if (isset($_POST['gwolle_gb_sfs']) && $_POST['gwolle_gb_sfs'] == 'on') {
364
  update_option('gwolle_gb-sfs', 'true');
 
365
  } else {
366
  update_option('gwolle_gb-sfs', 'false');
 
367
  }
368
 
369
  if ( isset($_POST['antispam-question']) ) {
370
  update_option('gwolle_gb-antispam-question', gwolle_gb_sanitize_input($_POST['antispam-question']));
 
371
  }
372
  if ( isset($_POST['antispam-answer']) ) {
373
  update_option('gwolle_gb-antispam-answer', gwolle_gb_sanitize_input($_POST['antispam-answer']));
 
374
  }
375
 
376
  break;
377
  case 'gwolle_gb_mail':
 
378
 
379
  /* Check Nonce */
380
  $verified = false;
383
  }
384
  if ( $verified == false ) {
385
  // Nonce is invalid.
386
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
 
387
  break;
388
  }
389
 
392
  if ( filter_var( $admin_mail_from, FILTER_VALIDATE_EMAIL ) ) {
393
  // Valid Email address.
394
  update_option('gwolle_gb-mail-from', $admin_mail_from);
 
395
  }
396
  }
397
 
414
 
415
  $user_ids = implode(",", $user_ids);
416
  update_option('gwolle_gb-notifyByMail', $user_ids);
 
417
  }
418
 
419
  if ( isset($_POST['subscribe']) && $_POST['subscribe'] > 0 ) {
436
 
437
  $user_ids = implode(",", $user_ids);
438
  update_option('gwolle_gb-notifyByMail', $user_ids);
 
439
  }
440
 
441
  if ( isset($_POST['adminMailContent']) ) {
442
  $mail_content = gwolle_gb_sanitize_input( $_POST['adminMailContent'], 'setting_textarea' );
443
  update_option('gwolle_gb-adminMailContent', $mail_content);
 
444
  }
445
 
446
  if (isset($_POST['mail_author']) && $_POST['mail_author'] == 'on') {
447
  update_option('gwolle_gb-mail_author', 'true');
 
448
  } else {
449
  update_option('gwolle_gb-mail_author', 'false');
 
450
  }
451
 
452
  if ( isset($_POST['authorMailContent']) ) {
453
  $mail_content = gwolle_gb_sanitize_input( $_POST['authorMailContent'], 'setting_textarea' );
454
  update_option('gwolle_gb-authorMailContent', $mail_content);
 
455
  }
456
 
457
  if ( isset($_POST['gwolle_gb-mail_admin_replyContent']) ) {
458
  $mail_content = gwolle_gb_sanitize_input( $_POST['gwolle_gb-mail_admin_replyContent'], 'setting_textarea' );
459
  update_option('gwolle_gb-mail_admin_replyContent', $mail_content);
 
460
  }
461
 
462
  break;
463
  case 'gwolle_gb_debug':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
 
465
  break;
466
  case 'gwolle_gb_uninstall':
 
467
 
468
  /* Check Nonce */
469
  $verified = false;
472
  }
473
  if ( $verified == false ) {
474
  // Nonce is invalid.
475
+ gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
 
476
  break;
477
  }
478
 
480
  if ( function_exists('is_multisite') && ! is_multisite() ) {
481
  // uninstall the plugin -> delete all tables and preferences of the plugin
482
  gwolle_gb_uninstall();
483
+ gwolle_gb_add_message( '<p>' . esc_html__('The entries and settings have been removed.', 'gwolle-gb') . '</p>', false, false);
484
+ gwolle_gb_add_message( '<p>' . esc_html__('The plugin is deactivated.', 'gwolle-gb') . '</p>', false, false);
485
+ $dashboard = '<a href="' . admin_url( '/index.php' ) . '">' . esc_html__('Dashboard', 'gwolle-gb') . '</a>';
486
+ /* translators: %s is a link to the dashboard */
487
+ gwolle_gb_add_message( '<p>' . sprintf( __('You can now go to your %s.', 'gwolle-gb'), $dashboard ) . '</p>', false, false);
488
  }
489
  } else {
490
  // Uninstallation not confirmed.
493
  break;
494
  default:
495
  /* Just load the first tab */
496
+ gwolle_gb_settings_active_tab( 'gwolle_gb_forms' );
497
  }
498
  }
499
+ }
500
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
 
502
 
503
+ /*
504
+ * Set and Get active tab for settings page.
505
+ *
506
+ * @param string $active_tab text string with active tab (optional).
507
+ * @return string text string with active tab.
508
+ *
509
+ * @since 3.0.0
510
+ */
511
+ function gwolle_gb_settings_active_tab( $active_tab = false ) {
512
 
513
+ static $active_tab_static;
514
 
515
+ if ( $active_tab ) {
516
+ $active_tab_static = $active_tab;
517
+ }
 
 
518
 
519
+ return $active_tab_static;
520
 
 
 
521
  }
admin/gb-upgrade.php CHANGED
@@ -50,7 +50,7 @@ function gwolle_gb_install() {
50
  admin_reply_uid int(5) NOT NULL default '0',
51
  book_id int(5) NOT NULL default '1',
52
  PRIMARY KEY (id)
53
- ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci";
54
  $result = $wpdb->query($sql);
55
  }
56
 
@@ -66,7 +66,7 @@ function gwolle_gb_install() {
66
  author_id int(5) NOT NULL,
67
  datetime bigint(8) UNSIGNED NOT NULL,
68
  PRIMARY KEY (id)
69
- ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci";
70
  $result = $wpdb->query($sql);
71
  }
72
 
@@ -490,11 +490,24 @@ function gwolle_gb_upgrade() {
490
  * 1.5.0->1.5.1
491
  * Add book_id field to database and fill it with value '1'.
492
  */
493
- $wpdb->query( "
494
  ALTER TABLE $wpdb->gwolle_gb_entries ADD `book_id` INT(8) UNSIGNED NOT NULL default '1' AFTER `admin_reply_uid`;
495
  ");
496
  }
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  /* Upgrade to new shiny db collation. Since WP 4.2 */
499
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
500
  if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
@@ -531,7 +544,7 @@ function gwolle_gb_set_defaults() {
531
  if ( get_option('gwolle_gb-entriesPerPage', false) == false ) {
532
  update_option( 'gwolle_gb-entriesPerPage', 20 );
533
  }
534
- if ( get_option('gwolle_gb-excerpt_length', false) == false ) {
535
  update_option( 'gwolle_gb-excerpt_length', 0 );
536
  }
537
  if ( get_option('gwolle_gb-form', false) == false ) {
@@ -582,7 +595,7 @@ function gwolle_gb_set_defaults() {
582
  if ( get_option('gwolle_gb-moderate-entries', false) == false ) {
583
  update_option( 'gwolle_gb-moderate-entries', 'true' );
584
  }
585
- if ( get_option('gwolle_gb-navigation', false) == false ) {
586
  update_option( 'gwolle_gb-navigation', 0 );
587
  }
588
  if ( get_option('gwolle_gb-nonce', false) == false ) {
50
  admin_reply_uid int(5) NOT NULL default '0',
51
  book_id int(5) NOT NULL default '1',
52
  PRIMARY KEY (id)
53
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci";
54
  $result = $wpdb->query($sql);
55
  }
56
 
66
  author_id int(5) NOT NULL,
67
  datetime bigint(8) UNSIGNED NOT NULL,
68
  PRIMARY KEY (id)
69
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci";
70
  $result = $wpdb->query($sql);
71
  }
72
 
490
  * 1.5.0->1.5.1
491
  * Add book_id field to database and fill it with value '1'.
492
  */
493
+ $wpdb->query( "
494
  ALTER TABLE $wpdb->gwolle_gb_entries ADD `book_id` INT(8) UNSIGNED NOT NULL default '1' AFTER `admin_reply_uid`;
495
  ");
496
  }
497
 
498
+ if (version_compare($installed_ver, '3.0.0', '<')) {
499
+ /*
500
+ * 2.6.7->3.0.0
501
+ * Switch from MyISAM to InnoDB database engine.
502
+ */
503
+ $wpdb->query( "
504
+ ALTER TABLE $wpdb->gwolle_gb_entries ENGINE=InnoDB;
505
+ ");
506
+ $wpdb->query( "
507
+ ALTER TABLE $wpdb->gwolle_gb_log ENGINE=InnoDB;
508
+ ");
509
+ }
510
+
511
  /* Upgrade to new shiny db collation. Since WP 4.2 */
512
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
513
  if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
544
  if ( get_option('gwolle_gb-entriesPerPage', false) == false ) {
545
  update_option( 'gwolle_gb-entriesPerPage', 20 );
546
  }
547
+ if ( get_option('gwolle_gb-excerpt_length', false) === false ) {
548
  update_option( 'gwolle_gb-excerpt_length', 0 );
549
  }
550
  if ( get_option('gwolle_gb-form', false) == false ) {
595
  if ( get_option('gwolle_gb-moderate-entries', false) == false ) {
596
  update_option( 'gwolle_gb-moderate-entries', 'true' );
597
  }
598
+ if ( get_option('gwolle_gb-navigation', false) === false ) {
599
  update_option( 'gwolle_gb-navigation', 0 );
600
  }
601
  if ( get_option('gwolle_gb-nonce', false) == false ) {
admin/gfx/{entry-admin_reply.png → entry-admin-reply.png} RENAMED
File without changes
admin/gwolle-gb-hooks.php CHANGED
@@ -78,7 +78,7 @@ add_action('admin_menu', 'gwolle_gb_adminmenu');
78
  * Load CSS for admin.
79
  */
80
  function gwolle_gb_admin_enqueue_style() {
81
- wp_enqueue_style( 'gwolle-gb-admin-css', plugins_url( '/css/gwolle-gb-admin.css', __FILE__ ), false, GWOLLE_GB_VER, 'all' );
82
  }
83
  add_action( 'admin_enqueue_scripts', 'gwolle_gb_admin_enqueue_style' );
84
 
@@ -88,7 +88,7 @@ add_action( 'admin_enqueue_scripts', 'gwolle_gb_admin_enqueue_style' );
88
  * It's called directly on the adminpages, it's not being used as a hook.
89
  */
90
  function gwolle_gb_admin_enqueue() {
91
- wp_enqueue_script( 'gwolle-gb-admin-js', plugins_url( '/js/gwolle-gb-admin.js', __FILE__ ), 'jquery', GWOLLE_GB_VER, true );
92
  }
93
  //add_action( 'admin_enqueue_scripts', 'gwolle_gb_admin_enqueue' );
94
 
78
  * Load CSS for admin.
79
  */
80
  function gwolle_gb_admin_enqueue_style() {
81
+ wp_enqueue_style( 'gwolle-gb-admin-css', GWOLLE_GB_URL . 'admin/css/gwolle-gb-admin.css', false, GWOLLE_GB_VER, 'all' );
82
  }
83
  add_action( 'admin_enqueue_scripts', 'gwolle_gb_admin_enqueue_style' );
84
 
88
  * It's called directly on the adminpages, it's not being used as a hook.
89
  */
90
  function gwolle_gb_admin_enqueue() {
91
+ wp_enqueue_script( 'gwolle-gb-admin-js', GWOLLE_GB_URL . 'admin/js/gwolle-gb-admin.js', 'jquery', GWOLLE_GB_VER, true );
92
  }
93
  //add_action( 'admin_enqueue_scripts', 'gwolle_gb_admin_enqueue' );
94
 
admin/js/gwolle-gb-admin.js CHANGED
@@ -48,12 +48,12 @@ jQuery(document).ready(function($) {
48
  /* Edit metadata */
49
  jQuery(document).ready(function($) {
50
  jQuery('.gwolle_gb_edit_meta').click( function() {
51
- jQuery('.gwolle_gb_edit_meta_inputs').toggle();
52
  return false;
53
  });
54
 
55
  jQuery('.gwolle_gb_cancel_timestamp').click( function() {
56
- jQuery('.gwolle_gb_edit_meta_inputs').toggle();
57
  return false;
58
  });
59
 
@@ -72,9 +72,16 @@ jQuery(document).ready(function($) {
72
  jQuery("#gwolle_gb_timestamp").val(timestamp);
73
 
74
  var readable_time = gb_timeconverter( timestamp );
75
- jQuery( 'span.gb-datetime' ).text( readable_time );
76
 
77
- jQuery('.gwolle_gb_edit_meta_inputs').toggle();
 
 
 
 
 
 
 
78
  return false;
79
  });
80
  });
@@ -217,14 +224,14 @@ jQuery(document).ready(function($) {
217
  var parts = parseFloat( jQuery("#gwolle_gb_export_parts").val() );
218
 
219
  for ( var part = 1; part < (parts + 1); part++ ) {
220
- var timeout = (part - 1) * 3000;
221
  gwolle_gb_export_part( part, timeout );
222
  }
223
 
224
  setTimeout(
225
  function() {
226
  jQuery( ".gwolle_gb_export_gif" ).css( 'visibility', 'hidden' );
227
- }, ( (part - 1) * 3000 )
228
  );
229
 
230
  event.preventDefault();
48
  /* Edit metadata */
49
  jQuery(document).ready(function($) {
50
  jQuery('.gwolle_gb_edit_meta').click( function() {
51
+ jQuery('.gwolle_gb_editor_meta_inputs').toggle();
52
  return false;
53
  });
54
 
55
  jQuery('.gwolle_gb_cancel_timestamp').click( function() {
56
+ jQuery('.gwolle_gb_editor_meta_inputs').toggle();
57
  return false;
58
  });
59
 
72
  jQuery("#gwolle_gb_timestamp").val(timestamp);
73
 
74
  var readable_time = gb_timeconverter( timestamp );
75
+ jQuery( 'span.gb-editor-datetime' ).text( readable_time );
76
 
77
+ var author_name = jQuery("#gwolle_gb_author_name").val();
78
+ jQuery( 'span.gb-editor-author-name' ).text( author_name );
79
+
80
+ var book_id = jQuery("#gwolle_gb_book_id").val();
81
+ jQuery( 'span.gb-editor-book-id' ).text( book_id );
82
+
83
+
84
+ jQuery('.gwolle_gb_editor_meta_inputs').toggle();
85
  return false;
86
  });
87
  });
224
  var parts = parseFloat( jQuery("#gwolle_gb_export_parts").val() );
225
 
226
  for ( var part = 1; part < (parts + 1); part++ ) {
227
+ var timeout = (part - 1) * 10000;
228
  gwolle_gb_export_part( part, timeout );
229
  }
230
 
231
  setTimeout(
232
  function() {
233
  jQuery( ".gwolle_gb_export_gif" ).css( 'visibility', 'hidden' );
234
+ }, ( (part - 1) * 10000 )
235
  );
236
 
237
  event.preventDefault();
admin/tabs/gb-debugtab.php CHANGED
@@ -12,9 +12,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
12
  /*
13
  * Debug tab of the Settings page.
14
  *
15
- * @param bool $debug_test if we want a debug test to be done.
16
  */
17
- function gwolle_gb_page_settingstab_debug( $debug_test ) {
18
 
19
  if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
20
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
@@ -41,7 +40,13 @@ function gwolle_gb_page_settingstab_debug( $debug_test ) {
41
  </tr>
42
 
43
  <?php
44
- if ( $debug_test ) {
 
 
 
 
 
 
45
  $entry_id = gwolle_gb_test_add_entry( false );
46
  $entry_id_emoji = gwolle_gb_test_add_entry( true );
47
  ?>
12
  /*
13
  * Debug tab of the Settings page.
14
  *
 
15
  */
16
+ function gwolle_gb_page_settingstab_debug() {
17
 
18
  if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
19
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
40
  </tr>
41
 
42
  <?php
43
+ /* Check Nonce */
44
+ $verified = false;
45
+ if ( isset($_POST['gwolle_gb_page_settings_debugtab']) ) {
46
+ $verified = wp_verify_nonce( $_POST['gwolle_gb_page_settings_debugtab'], 'gwolle_gb_page_settings_debugtab' );
47
+ }
48
+ if ( $verified && isset( $_POST['gwolle_gb_debug']) ) {
49
+ // Save test entries
50
  $entry_id = gwolle_gb_test_add_entry( false );
51
  $entry_id_emoji = gwolle_gb_test_add_entry( true );
52
  ?>
admin/tabs/gb-uninstalltab.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- * Settings page for the guestbook
4
  */
5
 
6
  // No direct calls to this script
@@ -11,10 +11,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
11
 
12
  /*
13
  * Uninstall tab of the Settings page.
14
- *
15
- * @param bool $uninstalled if the install has been done already. In that case, show messages.
16
  */
17
- function gwolle_gb_page_settingstab_uninstall( $uninstalled ) {
18
 
19
  if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
20
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
@@ -35,32 +33,8 @@ function gwolle_gb_page_settingstab_uninstall( $uninstalled ) {
35
  <table class="form-table">
36
  <tbody>
37
 
38
- <?php
39
- if ( $uninstalled == true ) { ?>
40
- <tr valign="top">
41
- <th scope="row"><?php esc_html_e('Message', 'gwolle-gb'); ?></th>
42
- <td>
43
- <div id="message" class="updated error fade">
44
- <p><?php esc_html_e('The entries and settings have been removed.', 'gwolle-gb'); ?></p>
45
- <p><?php esc_html_e('The plugin is deactivated.', 'gwolle-gb'); ?></p>
46
- <p><?php echo esc_html__('You can now go to your', 'gwolle-gb') . ' <a href="' . admin_url( '/index.php' ) . '">' . esc_html__('Dashboard', 'gwolle-gb') . '</a>. ' . esc_html__('(We will go there in 10 seconds)', 'gwolle-gb') ; ?>
47
- </div>
48
-
49
- <?php // Redirect to main admin page after 10 seconds. wp_redirect() does not work, headers were already sent. ?>
50
- <script>
51
- setTimeout(
52
- function() {
53
- window.location.href = '<?php echo admin_url( '/index.php' ); ?>'
54
- }, 10000 );
55
- </script>
56
- </td>
57
- </tr>
58
- <?php
59
- }
60
- ?>
61
-
62
  <tr valign="top">
63
- <th scope="row" style="color:#FF0000;"><label for="blogdescription"><?php esc_html_e('Uninstall', 'gwolle-gb'); ?></label></th>
64
  <td>
65
  <?php esc_html_e('Uninstalling means that all database entries are removed (settings and entries).', 'gwolle-gb');
66
  echo '<br />';
1
  <?php
2
  /*
3
+ * Settings tab for the guestbook.
4
  */
5
 
6
  // No direct calls to this script
11
 
12
  /*
13
  * Uninstall tab of the Settings page.
 
 
14
  */
15
+ function gwolle_gb_page_settingstab_uninstall() {
16
 
17
  if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
18
  die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
33
  <table class="form-table">
34
  <tbody>
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  <tr valign="top">
37
+ <th scope="row" style="color:#FF0000;"><label><?php esc_html_e('Uninstall', 'gwolle-gb'); ?></label></th>
38
  <td>
39
  <?php esc_html_e('Uninstalling means that all database entries are removed (settings and entries).', 'gwolle-gb');
40
  echo '<br />';
changelog-v2.txt ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ == Changelog ==
3
+
4
+ = 2.6.7 =
5
+ * 2018-11-07
6
+ * Revert previous jQuery bugfix (incompatible with IE 11).
7
+ * Slightly bigger icons for BBcode menu.
8
+
9
+ = 2.6.6 =
10
+ * 2018-10-30
11
+ * Only load admin files on wp-admin.
12
+ * Use jQuery to get data from input fields in form.
13
+
14
+ = 2.6.5 =
15
+ * 2018-09-23
16
+ * Better CSS for Microsoft browsers.
17
+
18
+ = 2.6.4 =
19
+ * 2018-09-23
20
+ * Add CSS for screen-readers for broken themes.
21
+
22
+ = 2.6.3 =
23
+ * 2018-09-07
24
+ * Better test if akismet is active.
25
+ * Set timeout check from 7s to 4s.
26
+ * Break email address in entries list as well.
27
+ * Better CSS colors in admin overview.
28
+ * Add support for Dark Mode beta plugin.
29
+
30
+ = 2.6.2 =
31
+ * 2018-07-19
32
+ * Fix form for "button = false" forms.
33
+ * Don't replace author URL and email with anything (follow WP core 4.9.8).
34
+
35
+ = 2.6.1 =
36
+ * 2018-07-09
37
+ * Add screen-reader-text to frontend metabox.
38
+ * Hide 'hide this form' button when form was visible on page load.
39
+ * Add a filter for button class 'gwolle_gb_button_class'.
40
+ * Add 'no_email' parameter to 'gwolle_gb_get_entries' function.
41
+ * Add second parameter $entry to filter for mail body notifications.
42
+ * Admin entries page, change label to ID column.
43
+ * Fix compatibility with Add-On version 1.0.0 till 1.1.2.
44
+ * Updates for Add-On 1.2.1.
45
+
46
+ = 2.6.0 =
47
+ * 2018-06-11
48
+ * Add option to permanently remove IP address and hostname from entries.
49
+ * Add cancel button for the form.
50
+ * Close metabox again after click event.
51
+ * Remove %ip% from default notice text.
52
+ * Add example text to the privacy policy.
53
+ * Refactor link to privacy policy.
54
+ * Included real fix for not handling form data on some installs.
55
+ * Show on editor if author was logged in or not.
56
+ * Add log message to mail notification with writing time like on editor.
57
+ * Add guestbook entries to WordPress personal data exporter.
58
+ * Add guestbook entries to WordPress personal data eraser.
59
+ * Add anonymize option to mass edit.
60
+ * Add 'gwolle_gb_privacy_anonymize_entry' function.
61
+ * Add 'gwolle_gb_get_permalinks' function.
62
+ * Add 'gwolle_gb_get_total_entries' function.
63
+ * Deprecate 'gwolle_gb_addon_get_total_entries' function.
64
+ * Use 'admin_url' everywhere.
65
+ * Updates for Add-On 1.2.0.
66
+
67
+ = 2.5.4 =
68
+ * 2018-06-06
69
+ * Fix XSS security issue on admin dashboard widget (thanks DefenseCode).
70
+
71
+ = 2.5.3 =
72
+ * 2018-06-04
73
+ * Better testing if anti-spam functions are enabled when checking the form input.
74
+ * Included possible fix for not handling form data on some installs.
75
+
76
+ = 2.5.2 =
77
+ * 2018-05-12
78
+ * Support link to privacy policy (requires WordPress 4.9.6).
79
+
80
+ = 2.5.1 =
81
+ * 2018-05-01
82
+ * Fix link checker.
83
+ * Add default parameter 'book_id' to function 'gwolle_gb_addon_get_total_entries'.
84
+
85
+ = 2.5.0 =
86
+ * 2018-04-13
87
+ * Improve custom quiz question.
88
+ * Improve and extend Honeypot anti-spam.
89
+ * Add Link Checker for anti-spam.
90
+ * Add timeout for submitting the form for anti-spam.
91
+ * Do not send IP Address to Akismet if disabled.
92
+ * Add 'date_query' parameter to 'gwolle_gb_get_entries' function.
93
+ * Set default settings upon install/upgrade, so we can cache them.
94
+ * Add action 'gwolle_gb_uninstall'.
95
+ * Switch multisite uninstall to 'admin_init' hook.
96
+ * Flush transients from cache if no book_id is set.
97
+ * Switch export to 3000 entries per part instead of 5000.
98
+ * New file '/functions/gb-book_id.php'.
99
+ * Improve comment blocks for functions.
100
+
101
+ = 2.4.2 =
102
+ * 2018-03-30
103
+ * Close div element correctly.
104
+
105
+ = 2.4.1 =
106
+ * 2018-03-28
107
+ * Improve features for anti-spam.
108
+ * Add readmore link to admin reply excerpt.
109
+ * More improvements to mobile CSS for the form.
110
+ * Fix warning when sending mail to moderator.
111
+
112
+ = 2.4.0 =
113
+ * 2018-03-25
114
+ * Add checkbox for privacy policy for GDPR compliance.
115
+ * Add option to store or not store IP Address and hostname.
116
+ * Add export for user based on ID or email.
117
+ * Add search on entries page for user based on ID or email.
118
+ * Support meta fields from the add-on in export/import (needs add-on > 1.1.0 ).
119
+ * Fix CSS for mobile form and form in widget.
120
+ * Remove book_id meta key when only one entry is shown.
121
+ * Fix warning on entries page when no entries.
122
+ * Add function 'gwolle_gb_get_postid_biggest_book'.
123
+ * Add function 'gwolle_gb_get_books'.
124
+ * Add hook 'gwolle_gb_delete_entry' when permanently deleting an entry.
125
+ * Delete log entries in that hook.
126
+ * Use correct URL in RSS feed.
127
+ * Add filters for email body.
128
+ * Fix docs for filters for email subject.
129
+ * Drop support for Shortcake feature plugin.
130
+ * Rephrase Cheating messages like WP Core.
131
+
132
+ = 2.3.10 =
133
+ * 2018-02-10
134
+ * Small CSS update for login form.
135
+ * Small CSS update for .gb-entry.
136
+ * Small CSS update for Twenty Fifteen.
137
+ * Update strings for add-on 1.0.7.
138
+
139
+ = 2.3.9 =
140
+ * 2018-01-26
141
+ * Support book_id for export and import (thanks therab).
142
+
143
+ = 2.3.8 =
144
+ * 2018-01-18
145
+ * Editor.php: Heading for City should really be City.
146
+ * Improve and add translator comments.
147
+
148
+ = 2.3.7 =
149
+ * 2017-11-29
150
+ * Rename header field in settingsform for compatibility.
151
+ * Improve some text strings (thanks dedotombo).
152
+ * Update strings for add-on 1.0.5.
153
+
154
+ = 2.3.6 =
155
+ * 2017-11-06
156
+ * Update strings for add-on 1.0.4.
157
+
158
+ = 2.3.5 =
159
+ * 2017-11-04
160
+ * Add classes with dashes.
161
+ * Small text updates.
162
+
163
+ = 2.3.4 =
164
+ * 2017-10-19
165
+ * When editing date, show new date after saving the date.
166
+ * Add translations for Add-On to GlotPress of gwolle-gb.
167
+
168
+ = 2.3.3 =
169
+ * 2017-10-06
170
+ * Use more of esc_html function in translatable strings.
171
+ * Add advertisement page for Add-On.
172
+
173
+ = 2.3.2 =
174
+ * 2017-09-06
175
+ * Editor: also save when no change was made.
176
+ * Add total counter to frontend list.
177
+
178
+ = 2.3.1 =
179
+ * 2017-08-29
180
+ * Use correct class for menu-counters.
181
+
182
+ = 2.3.0 =
183
+ * 2017-08-28
184
+ * Add Stop Forum Spam service for anti-spam.
185
+ * GET parameter entry_id with single view is back (back from the dead).
186
+ * Set admin styling to off by default.
187
+ * Remove "display:inline" for span elements, it is default.
188
+ * Don't use 'strip_tags' anymore.
189
+ * Add Metabox on frontend for more action links.
190
+ * Move Edit link and add Ajax icon to metabox in new file gb-metabox.php.
191
+ * Attach event listener to frontend metabox after posting with AJAX.
192
+ * Add option for Admin Avatar (thanks roots84).
193
+ * Add more filters to frontend form.
194
+ * Add filter 'gwolle_gb_entry_read_add_content_before'.
195
+ * Add filter 'gwolle_gb_entries_list_before'.
196
+ * Add action 'gwolle_gb_notsaved_entry_frontend'.
197
+ * Add filter 'gwolle_gb_get_emoji'.
198
+ * Add function 'gwolle_gb_get_entry_ids'.
199
+ * Add callbacks for infinite scroll and AJAX post.
200
+ * Set border between entries to solid instead of dotted.
201
+ * Fix counters on entries.php page.
202
+ * Admin Editor.php uses less globals now.
203
+ * Use esc_html functions for translatable strings.
204
+ * Store entry total for frontend pagination in a transient.
205
+ * Store counter for admin menu in a transient.
206
+ * Add gwolle_gb_is_author function.
207
+ * Small refactor of AJAX JS code.
208
+ * Move functions for settings, user/author, cache and shortcake to their own files.
209
+
210
+ = 2.2.1 =
211
+ * 2017-05-24
212
+ * Fix jQuery incompatibility in Super Simple Slider (for widget).
213
+
214
+ = 2.2.0 =
215
+ * 2017-05-03
216
+ * Add setting to refuse spam entries.
217
+ * Update counter in admin menu and toolbar after check of entry.
218
+ * Add translator comments for Trash (in Trash / to Trash).
219
+ * Add CSS text-color to pagination.
220
+ * Add filter 'gwolle_gb_entries_list_class'.
221
+ * Add filter 'gwolle_gb_entry_class'.
222
+ * Add filter 'gwolle_gb_widget_list_class'.
223
+ * Add filter 'gwolle_gb_widget_item_class'.
224
+ * Add filter 'gwolle_gb_author_link_rel'.
225
+ * Add filter 'gwolle_gb_bbcode_link_rel'.
226
+ * Use wp_kses_post function for sanitizing content and admin_reply.
227
+ * Use sanitize_text_field function for sanitizing other fields.
228
+ * Better testing for 'post_id' in shortcodes.
229
+ * Some better explanations at the Settingspage for anti-spam.
230
+ * Do not concatenate strings, but use sprintf on about page.
231
+ * Move functions for post-meta to own file.
232
+
233
+ = 2.1.5 =
234
+ * 2017-02-13
235
+ * Add CSS for responsive design for the form.
236
+ * Add CSS for the form inside a .widget and .widget-area.
237
+ * Add class .button to buttons on frontend form.
238
+ * Query for widgets checks on meta field.
239
+ * Make our custom fields protected.
240
+ * Only save custom fields on page edit.
241
+ * Improve error handling on import with missing finfo_open.
242
+ * On entries list, icon column gets header 'Status'.
243
+ * Don't update caches on wp_query.
244
+ * Remove Polish from zipfile, it is maintained in GlotPress.
245
+
246
+ = 2.1.4 =
247
+ * 2017-01-19
248
+ * Borrow pagination CSS from bbPress.
249
+ * Add shortcode for widget layout: [gwolle_gb_widget].
250
+ * Improve HTML formatting of widget.
251
+ * Remove Italian and Swedish from zipfile, they are at 100% in GlotPress.
252
+
253
+ = 2.1.3 =
254
+ * 2016-12-24
255
+ * Add rel="nofollow" to website link.
256
+ * Improve HTML formatting of entry.
257
+ * Add filter gwolle_gb_author_link_to_buddypress.
258
+ * Add filters for prefill of the form.
259
+
260
+ = 2.1.2 =
261
+ * 2016-11-06
262
+ * Wrap text '(no entries yet)' inside the standard div#gwolle_gb_entries so we always list the submitted entry.
263
+ * Add filter for gwolle_gb_admin_reply_header.
264
+ * Long words check shouldn't match http, https or ftp strings.
265
+ * Explain scan for long text better.
266
+ * Again fix for Twenty Sixteen and Twenty Seventeen.
267
+ * On import, run the clear_cache function only once.
268
+ * Slightly improve error handling for admin AJAX.
269
+
270
+ = 2.1.1 =
271
+ * 2016-09-07
272
+ * Security fix: fix XSS on editor view (Thanks Radjnies of securify.nl).
273
+ * Security fix: fix CSRF on admin pages (Thanks Radjnies of securify.nl).
274
+ * Use str_replace on quotes the right way (no need to escape).
275
+ * Add Nonces to admin pages and check on them.
276
+ * Check the max number of checked entries on bulk edit on admin list.
277
+ * Flush cache on mass delete.
278
+ * Update text of metaboxes on main admin page.
279
+
280
+ = 2.1.0 =
281
+ * 2016-08-23
282
+ * Fix html validation in form buttons.
283
+ * Add setting for the scan for long text.
284
+ * Set that scan from 80 chars to 100 chars.
285
+ * Support persistent object cache.
286
+ * Flush cache on saving an entry on admin too.
287
+ * Add save-hook to mass edit.
288
+ * Add save-hook to AJAX admin actions.
289
+ * Add save-hook to importer.
290
+ * Load admin CSS on all pages (not JS).
291
+ * Offer MultiSite uninstall through a filter.
292
+ * Set wpdb prefix correctly on uninstall.
293
+ * Rename most files with prefix.
294
+
295
+ = 2.0.2 =
296
+ * 2016-08-19
297
+ * Fix loading images in CSS.
298
+ * Better AJAX icon.
299
+ * Improve a11y of toolbar menu-item.
300
+
301
+ = 2.0.1 =
302
+ * 2016-08-16
303
+ * Fix upgrade in MultiSite.
304
+ * More subtle styling of AJAX icon.
305
+ * More consistent naming in error fields.
306
+ * Append Infinite Scroll load message to div#gwolle_gb_entries.
307
+ * Don't use 'focus()' in form ajax, no point to it.
308
+ * Rename CSS and JS files.
309
+ * Rename infinite_scroll.php to ajax-infinite_scroll.php.
310
+ * Rename captcha-ajax.php to ajax-captcha.php.
311
+ * Rename admin/upgrade.php to admin/gwolle-gb-upgrade.php.
312
+
313
+ = 2.0.0 =
314
+ * 2016-08-08
315
+ * Add AJAX Form Submit (default).
316
+ * Add container div around gwolle_gb_messages div.
317
+ * Small adaptations to form-posthandling.php.
318
+ * Function 'gwolle_gb_clear_cache()' is now hooked to 'gwolle_gb_save_entry_frontend' action.
319
+ * Moderator and author mail are now hooked to 'gwolle_gb_save_entry_frontend' action.
320
+ * Rename frontend/write.php to frontend/form.php.
321
+ * Rename frontend/posthandling.php to frontend/form-posthandling.php.
322
+ * Rename admin/ajax.php to admin/ajax-management.php.
323
+ * Remove more br elements from BBcode lists.
324
+ * Add a 'read more' link to each entry in the widget in the form of a '&raquo;'.
325
+ * Set CSS width of '.input input[type="email"]' and '.input input[type="url"]' to 100%.
326
+ * Set z-index for infinite scroll load message.
327
+ * Make CSS reset for MarkItUp more specific.
328
+ * Add some bootstrap classes to the form.
329
+ * Add comments for translators.
330
+ * Cleanup changelog. Add changelog.txt for v0 and v1.
docs/filters/gwolle_gb_widget_search.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ ==Description==
4
+
5
+ The <b>"gwolle_gb_widget_search"</b> filter is used to edit the output for the search widget at the frontend.
6
+
7
+ You can use this filter as:
8
+
9
+ <code><?php add_filter( 'gwolle_gb_widget_search', 'filter_function_name' ) ?></code>
10
+
11
+ Where 'filter_function_name' is the function WordPress should call when the filter is being used.
12
+
13
+ '''filter_function_name''' should be a unique function name. It cannot match any other function name already declared.
14
+
15
+
16
+ ==Examples==
17
+
18
+
19
+ function my_gwolle_gb_widget_search( $widget_html ) {
20
+ // $widget_html is a string
21
+ $old = 'Old String';
22
+ $new = 'New String';
23
+ $widget_html = str_replace( $old, $new, $widget_html );
24
+ return $widget_html;
25
+ }
26
+ add_filter( 'gwolle_gb_widget_search', 'my_gwolle_gb_widget_search', 10, 1 );
27
+
frontend/{gb-ajax-infinite_scroll.php → gb-ajax-infinite-scroll.php} RENAMED
File without changes
frontend/gb-form.php CHANGED
@@ -55,7 +55,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
55
 
56
  // Only show old data when there are errors.
57
  if ( $gwolle_gb_errors ) {
58
- if ( is_array($gwolle_gb_formdata) && !empty($gwolle_gb_formdata) ) {
59
  if (isset($gwolle_gb_formdata['author_name'])) {
60
  $name = stripslashes($gwolle_gb_formdata['author_name']);
61
  }
@@ -79,9 +79,8 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
79
 
80
 
81
  /*
82
- * Handle Messaging to the user
83
  */
84
-
85
  $messageclass = '';
86
  if ( $gwolle_gb_errors ) {
87
  $messageclass = 'error';
@@ -319,11 +318,11 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
319
  if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
320
  $field_name = gwolle_gb_get_field_name( 'content' );
321
  $label = apply_filters( 'gwolle_gb_content_label', esc_html__('Guestbook entry', 'gwolle-gb') );
322
- $output .= '<div class="gwolle_gb_content">
323
- <div class="label"><label for="gwolle_gb_content" class="text-info">' . $label . ':';
324
  if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) { $output .= ' *';}
325
  $output .= '</label></div>
326
- <div class="input"><textarea name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji ';
327
  if (in_array($field_name, $gwolle_gb_error_fields)) {
328
  $output .= ' error';
329
  }
@@ -339,23 +338,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
339
 
340
  if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
341
  // BBcode and MarkItUp
342
- wp_enqueue_script( 'markitup', plugins_url('markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false );
343
- wp_enqueue_script( 'markitup_set', plugins_url('markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false );
344
- wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
345
-
346
- $dataToBePassed = array(
347
- 'bold' => /* translators: MarkItUp menu item */ esc_html__('Bold', 'gwolle-gb' ),
348
- 'italic' => /* translators: MarkItUp menu item */ esc_html__('Italic', 'gwolle-gb' ),
349
- 'bullet' => /* translators: MarkItUp menu item */ esc_html__('Bulleted List', 'gwolle-gb' ),
350
- 'numeric' => /* translators: MarkItUp menu item */ esc_html__('Numeric List', 'gwolle-gb' ),
351
- 'picture' => /* translators: MarkItUp menu item */ esc_html__('Picture', 'gwolle-gb' ),
352
- 'source' => /* translators: MarkItUp menu item */ esc_html__('Source', 'gwolle-gb' ),
353
- 'link' => /* translators: MarkItUp menu item */ esc_html__('Link', 'gwolle-gb' ),
354
- 'linktext' => /* translators: MarkItUp menu item */ esc_html__('Your text to link...', 'gwolle-gb' ),
355
- 'clean' => /* translators: MarkItUp menu item */ esc_html__('Clean', 'gwolle-gb' ),
356
- 'emoji' => /* translators: MarkItUp menu item */ esc_html__('Emoji', 'gwolle-gb' )
357
- );
358
- wp_localize_script( 'markitup_set', 'gwolle_gb_localize', $dataToBePassed );
359
 
360
  // Emoji symbols
361
  $output .= '<div class="gwolle_gb_emoji gwolle_gb_hide">';
@@ -437,7 +420,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
437
  $gwolle_gb_captcha_field_size = $gwolle_gb_captcha->char_length;
438
 
439
  // Enqueue and localize the frontend script for CAPTCHA.
440
- wp_enqueue_script('gwolle_gb_captcha_js', plugins_url('js/captcha.js', __FILE__), 'jquery', GWOLLE_GB_VER, true );
441
  $dataToBePassed = array(
442
  // URL to wp-admin/admin-ajax.php to process the request
443
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
@@ -514,6 +497,8 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
514
  $output .= '
515
  <div id="gwolle_gb_messages_bottom_container"></div>
516
 
 
 
517
  <div class="gwolle_gb_submit">
518
  <div class="label gwolle_gb_invisible text-muted">&nbsp;</div>
519
  <div class="input">
55
 
56
  // Only show old data when there are errors.
57
  if ( $gwolle_gb_errors ) {
58
+ if ( is_array($gwolle_gb_formdata) && ! empty($gwolle_gb_formdata) ) {
59
  if (isset($gwolle_gb_formdata['author_name'])) {
60
  $name = stripslashes($gwolle_gb_formdata['author_name']);
61
  }
79
 
80
 
81
  /*
82
+ * Handle Messaging to the user.
83
  */
 
84
  $messageclass = '';
85
  if ( $gwolle_gb_errors ) {
86
  $messageclass = 'error';
318
  if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' ) {
319
  $field_name = gwolle_gb_get_field_name( 'content' );
320
  $label = apply_filters( 'gwolle_gb_content_label', esc_html__('Guestbook entry', 'gwolle-gb') );
321
+ $output .= '<div class="' . $field_name . '">
322
+ <div class="label"><label for="' . $field_name . '" class="text-info">' . $label . ':';
323
  if ( isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) { $output .= ' *';}
324
  $output .= '</label></div>
325
+ <div class="input"><textarea name="' . $field_name . '" id="' . $field_name . '" class="wp-exclude-emoji ';
326
  if (in_array($field_name, $gwolle_gb_error_fields)) {
327
  $output .= ' error';
328
  }
338
 
339
  if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
340
  // BBcode and MarkItUp
341
+ gwolle_gb_enqueue_markitup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
 
343
  // Emoji symbols
344
  $output .= '<div class="gwolle_gb_emoji gwolle_gb_hide">';
420
  $gwolle_gb_captcha_field_size = $gwolle_gb_captcha->char_length;
421
 
422
  // Enqueue and localize the frontend script for CAPTCHA.
423
+ wp_enqueue_script('gwolle_gb_captcha_js', GWOLLE_GB_URL . 'frontend/js/captcha.js', 'jquery', GWOLLE_GB_VER, true );
424
  $dataToBePassed = array(
425
  // URL to wp-admin/admin-ajax.php to process the request
426
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
497
  $output .= '
498
  <div id="gwolle_gb_messages_bottom_container"></div>
499
 
500
+ <noscript><div class="no-js">' . esc_html__( 'Warning: This form can only be used if JavaScript is enabled in your browser.', 'gwolle-gb' ) . '</div></noscript>
501
+
502
  <div class="gwolle_gb_submit">
503
  <div class="label gwolle_gb_invisible text-muted">&nbsp;</div>
504
  <div class="input">
frontend/gb-pagination.php CHANGED
@@ -16,10 +16,16 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
16
  */
17
  function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
18
 
19
- $permalink = get_permalink(get_the_ID());
20
  $highDotsMade = false;
21
  $pages_done = array();
22
 
 
 
 
 
 
 
 
23
  $pagination = '<div class="page-navigation">';
24
 
25
  if ($pageNum > 1) {
@@ -85,7 +91,7 @@ function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
85
  }
86
 
87
  // 'All' link
88
- if ( $pages_total >= 2 && get_option( 'gwolle_gb-paginate_all', 'false' ) === 'true' ) {
89
  if ( isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
90
  $pagination .= '<span class="page-numbers all">' . esc_html__('All', 'gwolle-gb') . '</span>';
91
  } else {
16
  */
17
  function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
18
 
 
19
  $highDotsMade = false;
20
  $pages_done = array();
21
 
22
+ $permalink = get_permalink(get_the_ID());
23
+ $is_search = gwolle_gb_is_search();
24
+ if ( $is_search ) {
25
+ $search_query = trim($_GET['gwolle-gb-search-input']);
26
+ $permalink = add_query_arg( 'gwolle-gb-search-input', $search_query, $permalink );
27
+ }
28
+
29
  $pagination = '<div class="page-navigation">';
30
 
31
  if ($pageNum > 1) {
91
  }
92
 
93
  // 'All' link
94
+ if ( $pages_total >= 2 && get_option( 'gwolle_gb-paginate_all', 'false' ) === 'true' && ! $is_search ) {
95
  if ( isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
96
  $pagination .= '<span class="page-numbers all">' . esc_html__('All', 'gwolle-gb') . '</span>';
97
  } else {
frontend/gb-read.php CHANGED
@@ -18,8 +18,10 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
18
 
19
  $output = '';
20
 
21
- /* Show single entry if requested... */
22
- if ( ((int) $shortcode_atts['entry_id'] > 0) || ( isset($_GET['entry_id']) && (int) $_GET['entry_id'] > 0 ) ) {
 
 
23
 
24
  if ( (int) $shortcode_atts['entry_id'] > 0 ) {
25
  $entry_id = (int) $shortcode_atts['entry_id'];
@@ -63,10 +65,9 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
63
  $num_entries = (int) get_option('gwolle_gb-entriesPerPage', 20);
64
  $num_entries = (int) apply_filters( 'gwolle_gb_read_num_entries', $num_entries, $shortcode_atts );
65
 
66
- $key = 'gwolle_gb_frontend_pagination_book_' . $shortcode_atts['book_id'];
67
- $entries_total = get_transient( $key );
68
- if ( false === $entries_total ) {
69
- $entries_total = gwolle_gb_get_entry_count(
70
  array(
71
  'checked' => 'checked',
72
  'trash' => 'notrash',
@@ -74,7 +75,21 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
74
  'book_id' => $shortcode_atts['book_id']
75
  )
76
  );
77
- set_transient( $key, $entries_total, DAY_IN_SECONDS );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
  $pages_total = ceil( $entries_total / $num_entries );
80
 
@@ -98,7 +113,30 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
98
 
99
 
100
  /* Get the entries for the frontend */
101
- if ( isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  $entries = gwolle_gb_get_entries(
103
  array(
104
  'offset' => 0,
@@ -136,7 +174,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;
@@ -147,10 +185,10 @@ function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
147
  $output .= '<div id="gwolle_gb_entries" class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
148
 
149
  $args = array(
150
- 'checked' => 'checked',
151
- 'trash' => 'notrash',
152
- 'spam' => 'nospam',
153
- 'book_id' => $shortcode_atts['book_id']
154
  );
155
  $output .= apply_filters( 'gwolle_gb_entries_list_before', '', $args );
156
 
18
 
19
  $output = '';
20
 
21
+ $is_search = gwolle_gb_is_search();
22
+
23
+ /* Show single entry if requested and is not search. */
24
+ if ( ((int) $shortcode_atts['entry_id'] > 0 && ! $is_search ) || ( isset($_GET['entry_id']) && (int) $_GET['entry_id'] > 0 && ! $is_search ) ) {
25
 
26
  if ( (int) $shortcode_atts['entry_id'] > 0 ) {
27
  $entry_id = (int) $shortcode_atts['entry_id'];
65
  $num_entries = (int) get_option('gwolle_gb-entriesPerPage', 20);
66
  $num_entries = (int) apply_filters( 'gwolle_gb_read_num_entries', $num_entries, $shortcode_atts );
67
 
68
+ /* Get the total count for the frontend in case of search. */
69
+ if ( $is_search ) {
70
+ $entries_total = gwolle_gb_get_entry_count_from_search(
 
71
  array(
72
  'checked' => 'checked',
73
  'trash' => 'notrash',
75
  'book_id' => $shortcode_atts['book_id']
76
  )
77
  );
78
+ } else {
79
+ /* Get the total count from cache/transient or from database. */
80
+ $key = 'gwolle_gb_frontend_pagination_book_' . $shortcode_atts['book_id'];
81
+ $entries_total = get_transient( $key );
82
+ if ( false === $entries_total ) {
83
+ $entries_total = gwolle_gb_get_entry_count(
84
+ array(
85
+ 'checked' => 'checked',
86
+ 'trash' => 'notrash',
87
+ 'spam' => 'nospam',
88
+ 'book_id' => $shortcode_atts['book_id']
89
+ )
90
+ );
91
+ set_transient( $key, $entries_total, DAY_IN_SECONDS );
92
+ }
93
  }
94
  $pages_total = ceil( $entries_total / $num_entries );
95
 
113
 
114
 
115
  /* Get the entries for the frontend */
116
+ if ( $is_search ) {
117
+ $entries = gwolle_gb_get_entries_from_search(
118
+ array(
119
+ 'offset' => $offset,
120
+ 'num_entries' => $num_entries,
121
+ 'checked' => 'checked',
122
+ 'trash' => 'notrash',
123
+ 'spam' => 'nospam',
124
+ 'book_id' => $shortcode_atts['book_id']
125
+ )
126
+ );
127
+ } else if ( $is_search && isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
128
+ $entries = gwolle_gb_get_entries_from_search(
129
+ array(
130
+ 'offset' => 0,
131
+ 'num_entries' => -1,
132
+ 'checked' => 'checked',
133
+ 'trash' => 'notrash',
134
+ 'spam' => 'nospam',
135
+ 'book_id' => $shortcode_atts['book_id']
136
+ )
137
+ );
138
+ $pageNum = 0; // do not have it set to 1, this way the '1' will be clickable too.
139
+ } else if ( isset($_GET['show_all']) && $_GET['show_all'] == 'true' ) {
140
  $entries = gwolle_gb_get_entries(
141
  array(
142
  'offset' => 0,
174
  $entries_list_class = apply_filters( 'gwolle_gb_entries_list_class', $entries_list_class );
175
 
176
  /* Entries from the template */
177
+ if ( ! is_array( $entries ) || empty( $entries ) ) {
178
  $no_entries = apply_filters( 'gwolle_gb_read_no_entries', esc_html__('(no entries yet)', 'gwolle-gb') );
179
  $output .= '<div id="gwolle_gb_entries" class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
180
  $output .= $no_entries;
185
  $output .= '<div id="gwolle_gb_entries" class="' . $entries_list_class . '" data-book_id="' . $shortcode_atts['book_id'] . '">';
186
 
187
  $args = array(
188
+ 'checked' => 'checked',
189
+ 'trash' => 'notrash',
190
+ 'spam' => 'nospam',
191
+ 'book_id' => $shortcode_atts['book_id']
192
  );
193
  $output .= apply_filters( 'gwolle_gb_entries_list_before', '', $args );
194
 
frontend/gb-rss.php CHANGED
@@ -154,7 +154,6 @@ function gwolle_gb_rss() {
154
  <content:encoded><![CDATA[<?php echo wp_trim_words( $entry->get_content(), 25, '...' ) ?>]]></content:encoded>
155
  <?php rss_enclosure(); ?>
156
  <?php do_action('rss2_item'); ?>
157
-
158
  </item>
159
 
160
  <?php
154
  <content:encoded><![CDATA[<?php echo wp_trim_words( $entry->get_content(), 25, '...' ) ?>]]></content:encoded>
155
  <?php rss_enclosure(); ?>
156
  <?php do_action('rss2_item'); ?>
 
157
  </item>
158
 
159
  <?php
frontend/gb-total.php CHANGED
@@ -39,10 +39,9 @@ function gwolle_gb_get_total_entries( $html, $args ) {
39
  $args['book_id'] = 1; // default
40
  }
41
 
42
- $key = 'gwolle_gb_frontend_pagination_book_' . $args['book_id'];
43
- $entries_total = get_transient( $key );
44
- if ( false === $entries_total ) {
45
- $entries_total = gwolle_gb_get_entry_count(
46
  array(
47
  'checked' => 'checked',
48
  'trash' => 'notrash',
@@ -50,7 +49,20 @@ function gwolle_gb_get_total_entries( $html, $args ) {
50
  'book_id' => $args['book_id']
51
  )
52
  );
53
- set_transient( $key, $entries_total, DAY_IN_SECONDS );
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
  $html .= '<div id="gwolle-gb-total">' .
56
  sprintf( _n( '%d entry.', '%d entries.', $entries_total, 'gwolle-gb' ), $entries_total )
39
  $args['book_id'] = 1; // default
40
  }
41
 
42
+ $is_search = gwolle_gb_is_search();
43
+ if ( $is_search ) {
44
+ $entries_total = gwolle_gb_get_entry_count_from_search(
 
45
  array(
46
  'checked' => 'checked',
47
  'trash' => 'notrash',
49
  'book_id' => $args['book_id']
50
  )
51
  );
52
+ } else {
53
+ $key = 'gwolle_gb_frontend_pagination_book_' . $args['book_id'];
54
+ $entries_total = get_transient( $key );
55
+ if ( false === $entries_total ) {
56
+ $entries_total = gwolle_gb_get_entry_count(
57
+ array(
58
+ 'checked' => 'checked',
59
+ 'trash' => 'notrash',
60
+ 'spam' => 'nospam',
61
+ 'book_id' => $args['book_id']
62
+ )
63
+ );
64
+ set_transient( $key, $entries_total, DAY_IN_SECONDS );
65
+ }
66
  }
67
  $html .= '<div id="gwolle-gb-total">' .
68
  sprintf( _n( '%d entry.', '%d entries.', $entries_total, 'gwolle-gb' ), $entries_total )
frontend/gb-widget-search.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Gwolle-GB Search Widget.
4
+ *
5
+ * @since 3.0.0
6
+ */
7
+
8
+
9
+ // No direct calls to this script
10
+ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
11
+ die('No direct calls allowed!');
12
+ }
13
+
14
+
15
+ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
16
+ class GwolleGB_Widget_search extends WP_Widget {
17
+
18
+ /* Constructor */
19
+ function __construct() {
20
+ $widget_ops = array( 'classname' => 'gwolle_gb_search', 'description' => esc_html__('Search for guestbook entries.','gwolle-gb') );
21
+ parent::__construct('gwolle_gb_search', esc_html__('Guestbook Search', 'gwolle-gb'), $widget_ops);
22
+ $this->alt_option_name = 'gwolle_gb_search';
23
+ }
24
+
25
+ /** @see WP_Widget::widget */
26
+ function widget($args, $instance) {
27
+ extract($args);
28
+
29
+ $default_value = array(
30
+ 'title' => esc_html__('Guestbook Search', 'gwolle-gb'),
31
+ );
32
+ $instance = wp_parse_args( (array) $instance, $default_value );
33
+ $widget_title = esc_attr($instance['title']);
34
+ $widget_class = 'gwolle-gb-widget-search';
35
+
36
+ // Only show on singular post and when we are on a guestbook.
37
+ if ( ! is_singular() || ! gwolle_gb_post_is_guestbook( get_the_ID() ) ) {
38
+ return;
39
+ }
40
+
41
+ // Init
42
+ $widget_html = '';
43
+
44
+ $widget_html .= $before_widget;
45
+ $widget_html .= '
46
+ <div class="' . $widget_class . '">';
47
+
48
+ if ($widget_title !== FALSE) {
49
+ $widget_html .= $before_title . apply_filters('widget_title', $widget_title) . $after_title;
50
+ }
51
+
52
+ $widget_html .= '
53
+ <form id="gwolle-gb-widget-search" action="#" method="GET" class="' . $widget_class . '" role="search" aria-label="' . esc_html__( 'Guestbook', 'gwolle-gb' ) . '">
54
+ <div class="label">
55
+ <label for="gwolle-gb-search-input" class="text-info">' . esc_html__('Search:', 'gwolle-gb') . '</label>
56
+ </div>
57
+ <div class="input">
58
+ <input class="wp-exclude-emoji" value="" type="text" name="gwolle-gb-search-input" id="gwolle-gb-search-input" placeholder="' . esc_attr__('Search...', 'gwolle-gb') . '" />
59
+ </div>
60
+ <div class="gwolle-gb-search-submit">
61
+ <div class="input">
62
+ <input type="submit" class="button btn btn-primary" value="' . esc_attr__('Search', 'gwolle-gb') . '" />
63
+ </div>
64
+ </div>
65
+ </form>';
66
+
67
+ $widget_html .= '
68
+ </div>
69
+ ' . $after_widget;
70
+
71
+ // Add a filter for the widget, so devs can add or remove parts.
72
+ $widget_html = apply_filters( 'gwolle_gb_widget_search', $widget_html);
73
+
74
+ echo $widget_html;
75
+
76
+ // Load Frontend CSS in Footer, only when it's active.
77
+ wp_enqueue_style('gwolle_gb_frontend_css');
78
+ }
79
+
80
+ /** @see WP_Widget::update */
81
+ function update($new_instance, $old_instance) {
82
+ $instance = $old_instance;
83
+ $instance['title'] = strip_tags($new_instance['title']);
84
+
85
+ return $instance;
86
+ }
87
+
88
+ /** @see WP_Widget::form */
89
+ function form($instance) {
90
+
91
+ $default_value = array(
92
+ 'title' => esc_html__('Guestbook Search', 'gwolle-gb'),
93
+ );
94
+ $instance = wp_parse_args( (array) $instance, $default_value );
95
+ $title = esc_attr($instance['title']);
96
+ ?>
97
+
98
+ <p>
99
+ <label for="<?php echo $this->get_field_id('title'); ?>" /><?php esc_html_e('Title:', 'gwolle-gb'); ?></label>
100
+ <br />
101
+ <input type="text" id="<?php echo $this->get_field_id('title'); ?>" value="<?php echo $title; ?>" name="<?php echo $this->get_field_name('title'); ?>" />
102
+ </p>
103
+
104
+ <?php
105
+ }
106
+
107
+ }
108
+
109
+ function gwolle_gb_widget_search() {
110
+ register_widget('GwolleGB_Widget_search');
111
+ }
112
+ add_action('widgets_init', 'gwolle_gb_widget_search' );
113
+ }
frontend/gb-widget.php CHANGED
@@ -59,7 +59,7 @@ if (function_exists('register_sidebar') && class_exists('WP_Widget')) {
59
  // Prepare for SSS Slider. Registers Script with WordPress to wp_footer().
60
  $widget_class = 'gwolle_gb_widget';
61
  if ( $slider ) {
62
- wp_register_script( 'gwolle_gb_widget_sss', plugins_url( '/js/sss/sss.js', __FILE__ ), 'jquery', GWOLLE_GB_VER, true );
63
  wp_enqueue_script( 'gwolle_gb_widget_sss' );
64
  $widget_class .= ' gwolle_gb_widget_slider gwolle-gb-widget-slider';
65
  }
59
  // Prepare for SSS Slider. Registers Script with WordPress to wp_footer().
60
  $widget_class = 'gwolle_gb_widget';
61
  if ( $slider ) {
62
+ wp_register_script( 'gwolle_gb_widget_sss', GWOLLE_GB_URL . '/frontend/js/sss/sss.js', 'jquery', GWOLLE_GB_VER, true );
63
  wp_enqueue_script( 'gwolle_gb_widget_sss' );
64
  $widget_class .= ' gwolle_gb_widget_slider gwolle-gb-widget-slider';
65
  }
frontend/gwolle_gb-entry.php CHANGED
@@ -168,11 +168,13 @@ if ( ! function_exists('gwolle_gb_entry_template') ) {
168
  /* Admin Avatar */
169
  if ( isset($read_setting['read_aavatar']) && $read_setting['read_aavatar'] === 'true' ) {
170
  $user_info = get_userdata( $entry->get_admin_reply_uid() );
171
- $admin_reply_email = $user_info->user_email;
172
- $avatar = get_avatar( $admin_reply_email, 32, '', $admin_reply_name );
173
- if ($avatar) {
174
- $admin_reply .= '
175
- <span class="gb-admin-avatar">' . $avatar . '</span>';
 
 
176
  }
177
  }
178
  /* Admin Header */
168
  /* Admin Avatar */
169
  if ( isset($read_setting['read_aavatar']) && $read_setting['read_aavatar'] === 'true' ) {
170
  $user_info = get_userdata( $entry->get_admin_reply_uid() );
171
+ if ( is_object($user_info) ) {
172
+ $admin_reply_email = $user_info->user_email;
173
+ $avatar = get_avatar( $admin_reply_email, 32, '', $admin_reply_name );
174
+ if ($avatar) {
175
+ $admin_reply .= '
176
+ <span class="gb-admin-avatar">' . $avatar . '</span>';
177
+ }
178
  }
179
  }
180
  /* Admin Header */
frontend/js/gwolle-gb-frontend.js CHANGED
@@ -268,7 +268,7 @@ jQuery(document).ready(function($) {
268
  });
269
 
270
  // Reset content textarea.
271
- jQuery( '#gwolle_gb_content' ).val('');
272
 
273
  jQuery( '#gwolle_gb .gwolle_gb_submit_ajax_icon' ).css( 'display', 'none' );
274
 
@@ -299,8 +299,8 @@ jQuery(document).ready(function($) {
299
  document.getElementById( 'gwolle_gb_messages_bottom_container' ).innerHTML = '<div id="gwolle_gb_messages" class="error">' + data['gwolle_gb_messages'] + '</div>';
300
 
301
  // Add error class to failed input fields.
302
- jQuery( '#gwolle_gb_new_entry input' ).removeClass( 'error' );
303
- jQuery( '#gwolle_gb_new_entry textarea' ).removeClass( 'error' );
304
  jQuery.each( gwolle_gb_error_fields, function( index, value ) {
305
  jQuery( '#' + value ).addClass( 'error' );
306
  });
268
  });
269
 
270
  // Reset content textarea.
271
+ jQuery( '.gwolle_gb_form_ajax textarea' ).val('');
272
 
273
  jQuery( '#gwolle_gb .gwolle_gb_submit_ajax_icon' ).css( 'display', 'none' );
274
 
299
  document.getElementById( 'gwolle_gb_messages_bottom_container' ).innerHTML = '<div id="gwolle_gb_messages" class="error">' + data['gwolle_gb_messages'] + '</div>';
300
 
301
  // Add error class to failed input fields.
302
+ jQuery( '.gwolle_gb_form_ajax input' ).removeClass( 'error' );
303
+ jQuery( '.gwolle_gb_form_ajax textarea' ).removeClass( 'error' );
304
  jQuery.each( gwolle_gb_error_fields, function( index, value ) {
305
  jQuery( '#' + value ).addClass( 'error' );
306
  });
frontend/markitup/jquery.markitup.js CHANGED
@@ -663,3 +663,71 @@
663
  }
664
  };
665
  })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  }
664
  };
665
  })(jQuery);
666
+
667
+
668
+ // ----------------------------------------------------------------------------
669
+ // markItUp!
670
+ // ----------------------------------------------------------------------------
671
+ // Copyright (C) 2011 Jay Salvat
672
+ // http://markitup.jaysalvat.com/
673
+ // ----------------------------------------------------------------------------
674
+ // Html tags
675
+ // http://en.wikipedia.org/wiki/html
676
+ // ----------------------------------------------------------------------------
677
+ // Basic set. Feel free to add more tags
678
+ // ----------------------------------------------------------------------------
679
+ var marktitup_mySettings = {
680
+ onTab: { keepDefault:false, replaceWith:' ' },
681
+ markupSet: [
682
+ {name: gwolle_gb_localize.bold, key:'B', openWith:'(!([b]|!|<b>)!)', closeWith:'(!([/b]|!|</b>)!)' },
683
+ {name: gwolle_gb_localize.italic, key:'I', openWith:'(!([i]|!|<i>)!)', closeWith:'(!([/i]|!|</i>)!)' },
684
+ {separator:'---------------' },
685
+ {name: gwolle_gb_localize.bullet, openWith:'[li]', closeWith:'[/li]', multiline:true, openBlockWith:'[ul]\n', closeBlockWith:'\n[/ul]'},
686
+ {name: gwolle_gb_localize.numeric, openWith:'[li]', closeWith:'[/li]', multiline:true, openBlockWith:'[ol]\n', closeBlockWith:'\n[/ol]'},
687
+ {separator:'---------------' },
688
+ {name: gwolle_gb_localize.picture, key:'P', replaceWith:'[img][![' + gwolle_gb_localize.source + ':!:http://]!][/img]' },
689
+ {name: gwolle_gb_localize.link, key:'L', openWith:'[url href=[![' + gwolle_gb_localize.link + ':!:http://]!]]', closeWith:'[/url]', placeHolder: gwolle_gb_localize.linktext },
690
+ {separator:'---------------' },
691
+ {name: gwolle_gb_localize.clean, className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/\[(.*?)\]/g, "") } },
692
+ {separator:'---------------' },
693
+ {name: gwolle_gb_localize.emoji, className:'emoji' }
694
+ ]
695
+ }
696
+
697
+
698
+ jQuery(document).ready(function() {
699
+
700
+ /* Initialize BBcode editor */
701
+ jQuery('#gwolle_gb_content').markItUp(marktitup_mySettings);
702
+ jQuery('#gwolle_gb_admin_reply').markItUp(marktitup_mySettings);
703
+
704
+
705
+ /* Slide the Emoji rows (frontend, main editor) */
706
+ jQuery( '#markItUpGwolle_gb_content li.markItUpButton.emoji a' ).click(function() {
707
+ if ( jQuery('.gwolle_gb_emoji').css('display') == 'none' ) {
708
+ jQuery('.gwolle_gb_emoji').slideDown("slow");
709
+ } else {
710
+ jQuery('.gwolle_gb_emoji').slideUp("slow");
711
+ }
712
+ });
713
+ /* Slide the Emoji rows (admin_reply editor) */
714
+ jQuery( '#markItUpGwolle_gb_admin_reply li.markItUpButton.emoji a' ).click(function() {
715
+ if ( jQuery('.gwolle_gb_admin_reply_emoji').css('display') == 'none' ) {
716
+ jQuery('.gwolle_gb_admin_reply_emoji').slideDown("slow");
717
+ } else {
718
+ jQuery('.gwolle_gb_admin_reply_emoji').slideUp("slow");
719
+ }
720
+ });
721
+
722
+
723
+ /* Insert the Emoji symbol (frontend, main editor) */
724
+ jQuery('.gwolle_gb_emoji a').click(function() {
725
+ emoticon = jQuery(this).attr("title");
726
+ jQuery.markItUp( { target:'#gwolle_gb_content', replaceWith:emoticon } );
727
+ });
728
+ /* Insert the Emoji symbol (admin_reply editor) */
729
+ jQuery('.gwolle_gb_admin_reply_emoji a').click(function() {
730
+ emoticon = jQuery(this).attr("title");
731
+ jQuery.markItUp( { target:'#gwolle_gb_admin_reply', replaceWith:emoticon } );
732
+ });
733
+ });
frontend/markitup/set.js DELETED
@@ -1,67 +0,0 @@
1
- // ----------------------------------------------------------------------------
2
- // markItUp!
3
- // ----------------------------------------------------------------------------
4
- // Copyright (C) 2011 Jay Salvat
5
- // http://markitup.jaysalvat.com/
6
- // ----------------------------------------------------------------------------
7
- // Html tags
8
- // http://en.wikipedia.org/wiki/html
9
- // ----------------------------------------------------------------------------
10
- // Basic set. Feel free to add more tags
11
- // ----------------------------------------------------------------------------
12
- var marktitup_mySettings = {
13
- onTab: { keepDefault:false, replaceWith:' ' },
14
- markupSet: [
15
- {name: gwolle_gb_localize.bold, key:'B', openWith:'(!([b]|!|<b>)!)', closeWith:'(!([/b]|!|</b>)!)' },
16
- {name: gwolle_gb_localize.italic, key:'I', openWith:'(!([i]|!|<i>)!)', closeWith:'(!([/i]|!|</i>)!)' },
17
- {separator:'---------------' },
18
- {name: gwolle_gb_localize.bullet, openWith:'[li]', closeWith:'[/li]', multiline:true, openBlockWith:'[ul]\n', closeBlockWith:'\n[/ul]'},
19
- {name: gwolle_gb_localize.numeric, openWith:'[li]', closeWith:'[/li]', multiline:true, openBlockWith:'[ol]\n', closeBlockWith:'\n[/ol]'},
20
- {separator:'---------------' },
21
- {name: gwolle_gb_localize.picture, key:'P', replaceWith:'[img][![' + gwolle_gb_localize.source + ':!:http://]!][/img]' },
22
- {name: gwolle_gb_localize.link, key:'L', openWith:'[url href=[![' + gwolle_gb_localize.link + ':!:http://]!]]', closeWith:'[/url]', placeHolder: gwolle_gb_localize.linktext },
23
- {separator:'---------------' },
24
- {name: gwolle_gb_localize.clean, className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/\[(.*?)\]/g, "") } },
25
- {separator:'---------------' },
26
- {name: gwolle_gb_localize.emoji, className:'emoji' }
27
- ]
28
- }
29
-
30
-
31
- jQuery(document).ready(function() {
32
-
33
- /* Initialize BBcode editor */
34
- jQuery('#gwolle_gb_content').markItUp(marktitup_mySettings);
35
- jQuery('#gwolle_gb_admin_reply').markItUp(marktitup_mySettings);
36
-
37
-
38
- /* Slide the Emoji rows (frontend, main editor) */
39
- jQuery( '#markItUpGwolle_gb_content li.markItUpButton.emoji a' ).click(function() {
40
- if ( jQuery('.gwolle_gb_emoji').css('display') == 'none' ) {
41
- jQuery('.gwolle_gb_emoji').slideDown("slow");
42
- } else {
43
- jQuery('.gwolle_gb_emoji').slideUp("slow");
44
- }
45
- });
46
- /* Slide the Emoji rows (admin_reply editor) */
47
- jQuery( '#markItUpGwolle_gb_admin_reply li.markItUpButton.emoji a' ).click(function() {
48
- if ( jQuery('.gwolle_gb_admin_reply_emoji').css('display') == 'none' ) {
49
- jQuery('.gwolle_gb_admin_reply_emoji').slideDown("slow");
50
- } else {
51
- jQuery('.gwolle_gb_admin_reply_emoji').slideUp("slow");
52
- }
53
- });
54
-
55
-
56
- /* Insert the Emoji symbol (frontend, main editor) */
57
- jQuery('.gwolle_gb_emoji a').click(function() {
58
- emoticon = jQuery(this).attr("title");
59
- jQuery.markItUp( { target:'#gwolle_gb_content', replaceWith:emoticon } );
60
- });
61
- /* Insert the Emoji symbol (admin_reply editor) */
62
- jQuery('.gwolle_gb_admin_reply_emoji a').click(function() {
63
- emoticon = jQuery(this).attr("title");
64
- jQuery.markItUp( { target:'#gwolle_gb_admin_reply', replaceWith:emoticon } );
65
- });
66
- });
67
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/gb-bbcode_emoji.php CHANGED
@@ -20,23 +20,31 @@ function gwolle_gb_bbcode_parse( $str ){
20
  $html[] = "<i>\\1</i>";
21
  $bb[] = "#\[u\](.*?)\[/u\]#si";
22
  $html[] = "<u>\\1</u>";
 
23
  $bb[] = "#\[ul\](.*?)\[/ul\]#si";
24
  $html[] = "<ul>\\1</ul>";
 
 
 
 
25
  $bb[] = "#\[ol\](.*?)\[/ol\]#si";
26
  $html[] = "<ol>\\1</ol>";
27
  $bb[] = "#\[li\](.*?)\[/li\]#si";
28
  $html[] = "<li>\\1</li>";
 
 
29
  $str = preg_replace($bb, $html, $str);
30
 
 
 
 
 
 
31
  $pattern="#\[url href=([^\]]*)\]([^\[]*)\[/url\]#i";
32
  $bbcode_link_rel = apply_filters( 'gwolle_gb_bbcode_link_rel', 'nofollow' );
33
  $replace='<a href="\\1" target="_blank" rel="' . $bbcode_link_rel . '">\\2</a>';
34
  $str=preg_replace($pattern, $replace, $str);
35
 
36
- $pattern="#\[img\]([^\[]*)\[/img\]#i";
37
- $replace='<img src="\\1" alt=""/>';
38
- $str=preg_replace($pattern, $replace, $str);
39
-
40
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
41
  // fix nl2br adding <br />'s
42
  $str = str_replace( '<br /><ol>', '<ol>', $str );
20
  $html[] = "<i>\\1</i>";
21
  $bb[] = "#\[u\](.*?)\[/u\]#si";
22
  $html[] = "<u>\\1</u>";
23
+ // We run the regex on lists twice to support sublists.
24
  $bb[] = "#\[ul\](.*?)\[/ul\]#si";
25
  $html[] = "<ul>\\1</ul>";
26
+ $bb[] = "#\[ul\](.*?)\[/ul\]#si";
27
+ $html[] = "<ul>\\1</ul>";
28
+ $bb[] = "#\[ol\](.*?)\[/ol\]#si";
29
+ $html[] = "<ol>\\1</ol>";
30
  $bb[] = "#\[ol\](.*?)\[/ol\]#si";
31
  $html[] = "<ol>\\1</ol>";
32
  $bb[] = "#\[li\](.*?)\[/li\]#si";
33
  $html[] = "<li>\\1</li>";
34
+ $bb[] = "#\[li\](.*?)\[/li\]#si";
35
+ $html[] = "<li>\\1</li>";
36
  $str = preg_replace($bb, $html, $str);
37
 
38
+ // First images, then links, so we support images inside links.
39
+ $pattern="#\[img\]([^\[]*)\[/img\]#i";
40
+ $replace='<img src="\\1" alt=""/>';
41
+ $str=preg_replace($pattern, $replace, $str);
42
+
43
  $pattern="#\[url href=([^\]]*)\]([^\[]*)\[/url\]#i";
44
  $bbcode_link_rel = apply_filters( 'gwolle_gb_bbcode_link_rel', 'nofollow' );
45
  $replace='<a href="\\1" target="_blank" rel="' . $bbcode_link_rel . '">\\2</a>';
46
  $str=preg_replace($pattern, $replace, $str);
47
 
 
 
 
 
48
  if ( get_option( 'gwolle_gb-showLineBreaks', 'false' ) === 'true' ) {
49
  // fix nl2br adding <br />'s
50
  $str = str_replace( '<br /><ol>', '<ol>', $str );
functions/gb-fields.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 field name for the form fields that are different for each website.
12
+ *
13
+ * @param string field name of the requested field.
14
+ * @return string hashed fieldname or fieldname, prepended with gwolle_gb.
15
+ *
16
+ * @since 2.4.1
17
+ */
18
+ function gwolle_gb_get_field_name( $field ) {
19
+
20
+ if ( ! in_array( $field, array( 'name', 'city', 'email', 'website', 'honeypot', 'honeypot2', 'nonce', 'custom', 'timeout', 'timeout2' ) ) ) {
21
+ return 'gwolle_gb_' . $field;
22
+ }
23
+
24
+ $blog_url = get_bloginfo('wpurl');
25
+ $key = 'gwolle_gb_' . $field . '_field_name_' . $blog_url;
26
+ $field_name = wp_hash( $key, 'auth' );
27
+ $field_name = 'gwolle_gb_' . $field_name;
28
+
29
+ return $field_name;
30
+ }
functions/gb-get_entries.php CHANGED
@@ -9,7 +9,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
9
 
10
  /*
11
  * gwolle_gb_get_entries
12
- * Function to get guestbook entries from the database.
13
  *
14
  * @param array $args
15
  * - num_entries int: Number of requested entries. -1 will return all requested entries.
@@ -31,13 +31,13 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
31
  *
32
  * @since 1.0.0
33
  */
34
- function gwolle_gb_get_entries($args = array()) {
35
  global $wpdb;
36
 
37
  $where = " 1 = %d";
38
  $values = Array(1);
39
 
40
- if ( ! is_array($args) ) {
41
  return false;
42
  }
43
 
@@ -356,10 +356,6 @@ function gwolle_gb_get_entry_ids($args = array()) {
356
  $values[] = (int) $args['book_id'];
357
  }
358
 
359
- $limit = ' LIMIT 999999999999999 ';
360
- $offset = ' OFFSET 0 ';
361
-
362
-
363
  $tablename = $wpdb->prefix . "gwolle_gb_entries";
364
 
365
  $sql_nonprepared = "
@@ -371,7 +367,8 @@ function gwolle_gb_get_entry_ids($args = array()) {
371
  " . $where . "
372
  ORDER BY
373
  datetime DESC
374
- " . $limit . " " . $offset . "
 
375
  ;";
376
 
377
  $sql = $wpdb->prepare( $sql_nonprepared, $values );
@@ -472,3 +469,112 @@ function gwolle_gb_del_entries( $status ) {
472
  }
473
  return false;
474
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  /*
11
  * gwolle_gb_get_entries
12
+ * Get guestbook entries from the database.
13
  *
14
  * @param array $args
15
  * - num_entries int: Number of requested entries. -1 will return all requested entries.
31
  *
32
  * @since 1.0.0
33
  */
34
+ function gwolle_gb_get_entries( $args = array() ) {
35
  global $wpdb;
36
 
37
  $where = " 1 = %d";
38
  $values = Array(1);
39
 
40
+ if ( ! is_array( $args ) ) {
41
  return false;
42
  }
43
 
356
  $values[] = (int) $args['book_id'];
357
  }
358
 
 
 
 
 
359
  $tablename = $wpdb->prefix . "gwolle_gb_entries";
360
 
361
  $sql_nonprepared = "
367
  " . $where . "
368
  ORDER BY
369
  datetime DESC
370
+ LIMIT 999999999999999
371
+ OFFSET 0
372
  ;";
373
 
374
  $sql = $wpdb->prepare( $sql_nonprepared, $values );
469
  }
470
  return false;
471
  }
472
+
473
+
474
+ /*
475
+ * gwolle_gb_get_entry_count
476
+ * Get the number of entries from the database.
477
+ *
478
+ * @param array $args
479
+ * - checked string: 'checked' or 'unchecked', List the entries that are checked or not checked
480
+ * - trash string: 'trash' or 'notrash', List the entries that are deleted or not deleted
481
+ * - spam string: 'spam' or 'nospam', List the entries marked as spam or as no spam
482
+ * - all string: 'all', List all entries
483
+ * - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
484
+ *
485
+ * @return mixed int with the count of the entries, false if there's an error.
486
+ */
487
+ function gwolle_gb_get_entry_count($args) {
488
+
489
+ global $wpdb;
490
+
491
+
492
+ $where = " 1 = %d";
493
+ $values = Array(1);
494
+
495
+ if ( !is_array($args) ) {
496
+ return false;
497
+ }
498
+
499
+ if ( isset($args['checked']) ) {
500
+ if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
501
+ $where .= "
502
+ AND
503
+ ischecked = %d";
504
+ if ( $args['checked'] == 'checked' ) {
505
+ $values[] = 1;
506
+ } else if ( $args['checked'] == 'unchecked' ) {
507
+ $values[] = 0;
508
+ }
509
+ }
510
+ }
511
+ if ( isset($args['spam']) ) {
512
+ if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
513
+ $where .= "
514
+ AND
515
+ isspam = %d";
516
+ if ( $args['spam'] == 'spam' ) {
517
+ $values[] = 1;
518
+ } else if ( $args['spam'] == 'nospam' ) {
519
+ $values[] = 0;
520
+ }
521
+ }
522
+ }
523
+ if ( isset($args['trash']) ) {
524
+ if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
525
+ $where .= "
526
+ AND
527
+ istrash = %d";
528
+ if ( $args['trash'] == 'trash' ) {
529
+ $values[] = 1;
530
+ } else if ( $args['trash'] == 'notrash' ) {
531
+ $values[] = 0;
532
+ }
533
+ }
534
+ }
535
+ if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
536
+ $where .= "
537
+ AND
538
+ book_id = %d";
539
+ $values[] = (int) $args['book_id'];
540
+ }
541
+
542
+ $tablename = $wpdb->prefix . "gwolle_gb_entries";
543
+
544
+ $sql = "
545
+ SELECT
546
+ COUNT(id) AS count
547
+ FROM
548
+ " . $tablename . "
549
+ WHERE
550
+ " . $where . "
551
+ ;";
552
+
553
+ $sql = $wpdb->prepare( $sql, $values );
554
+
555
+
556
+ /* Support caching of the result. */
557
+ $key = md5( serialize( $sql ) );
558
+ $cache_key = "gwolle_gb_get_entry_count:$key";
559
+ $cache_value = wp_cache_get( $cache_key );
560
+
561
+ if ( false === $cache_value ) {
562
+
563
+ // Do a real query.
564
+ $data = $wpdb->get_results( $sql, ARRAY_A );
565
+
566
+ wp_cache_add( $cache_key, $data );
567
+
568
+ // $wpdb->print_error();
569
+ // echo "number of rows: " . $wpdb->num_rows;
570
+
571
+ } else {
572
+
573
+ // This is data from cache.
574
+ $data = $cache_value;
575
+
576
+ }
577
+
578
+ return (int) $data[0]['count'];
579
+
580
+ }
functions/gb-get_entries_from_search.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * gwolle_gb_get_entries_from_search
12
+ * Get guestbook entries from the database for a search query from the search widget.
13
+ *
14
+ * @param array $args
15
+ * - num_entries int: Number of requested entries. -1 will return all requested entries.
16
+ * - offset int: Start after this entry.
17
+ * - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
18
+ *
19
+ * @return mixed array of objects of gwolle_gb_entry, false if no entries found.
20
+ *
21
+ * @since 3.0.0
22
+ */
23
+ function gwolle_gb_get_entries_from_search( $args = array() ) {
24
+ global $wpdb;
25
+
26
+ $where = " 1 = %d";
27
+ $values = Array(1);
28
+
29
+ if ( ! is_array( $args ) ) {
30
+ return false;
31
+ }
32
+
33
+ $where .= "
34
+ AND
35
+ ischecked = %d";
36
+ $values[] = 1;
37
+
38
+ $where .= "
39
+ AND
40
+ isspam = %d";
41
+ $values[] = 0;
42
+
43
+ $where .= "
44
+ AND
45
+ istrash = %d";
46
+ $values[] = 0;
47
+
48
+ if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
49
+ $where .= "
50
+ AND
51
+ book_id = %d";
52
+ $values[] = (int) $args['book_id'];
53
+ }
54
+
55
+ $search_query = gwolle_gb_is_search();
56
+ $tablename = $wpdb->prefix . "gwolle_gb_entries";
57
+ foreach ( $search_query as $term ) {
58
+ $like = '%' . $wpdb->esc_like( $term ) . '%';
59
+ $where .= $wpdb->prepare( "
60
+ AND (
61
+ ($tablename . author_name LIKE %s)
62
+ OR
63
+ ($tablename . content LIKE %s)
64
+ OR
65
+ ($tablename . admin_reply LIKE %s))",
66
+ $like, $like, $like
67
+ );
68
+ }
69
+
70
+ // Offset
71
+ $offset = " OFFSET 0 "; // default
72
+ if ( isset($args['offset']) && (int) $args['offset'] > 0 ) {
73
+ $offset = " OFFSET " . (int) $args['offset'];
74
+ }
75
+
76
+ // Limit
77
+ if ( is_admin() ) {
78
+ $perpage_option = (int) get_option('gwolle_gb-entries_per_page', 20);
79
+ } else {
80
+ $perpage_option = (int) get_option('gwolle_gb-entriesPerPage', 20);
81
+ }
82
+
83
+ $limit = " LIMIT " . $perpage_option; // default
84
+ if ( isset($args['num_entries']) && (int) $args['num_entries'] > 0 ) {
85
+ $limit = " LIMIT " . (int) $args['num_entries'];
86
+ } else if ( isset($args['num_entries']) && (int) $args['num_entries'] == -1 ) {
87
+ $limit = ' LIMIT 999999999999999 ';
88
+ $offset = ' OFFSET 0 ';
89
+ }
90
+
91
+ $sql_nonprepared = "
92
+ SELECT
93
+ `id`,
94
+ `author_name`,
95
+ `author_id`,
96
+ `author_email`,
97
+ `author_origin`,
98
+ `author_website`,
99
+ `author_ip`,
100
+ `author_host`,
101
+ `content`,
102
+ `datetime`,
103
+ `ischecked`,
104
+ `checkedby`,
105
+ `istrash`,
106
+ `isspam`,
107
+ `admin_reply`,
108
+ `admin_reply_uid`,
109
+ `book_id`
110
+ FROM
111
+ " . $tablename . "
112
+ WHERE
113
+ " . $where . "
114
+ ORDER BY
115
+ datetime DESC
116
+ " . $limit . " " . $offset . "
117
+ ;";
118
+
119
+ $sql = $wpdb->prepare( $sql_nonprepared, $values );
120
+
121
+ // Do a real query, we don't cache anything from searches.
122
+ $datalist = $wpdb->get_results( $sql, ARRAY_A );
123
+
124
+ // $wpdb->print_error();
125
+ // echo "number of rows: " . $wpdb->num_rows;
126
+
127
+
128
+ if ( is_array($datalist) && ! empty($datalist) ) {
129
+ $entries = array();
130
+
131
+ foreach ( $datalist as $data ) {
132
+
133
+ // Use the fields that the setter method expects
134
+ $item = array(
135
+ 'id' => (int) $data['id'],
136
+ 'author_name' => stripslashes($data['author_name']),
137
+ 'author_id' => (int) $data['author_id'],
138
+ 'author_email' => stripslashes($data['author_email']),
139
+ 'author_origin' => stripslashes($data['author_origin']),
140
+ 'author_website' => stripslashes($data['author_website']),
141
+ 'author_ip' => $data['author_ip'],
142
+ 'author_host' => $data['author_host'],
143
+ 'content' => stripslashes($data['content']),
144
+ 'datetime' => $data['datetime'],
145
+ 'ischecked' => (int) $data['ischecked'],
146
+ 'checkedby' => (int) $data['checkedby'],
147
+ 'istrash' => (int) $data['istrash'],
148
+ 'isspam' => (int) $data['isspam'],
149
+ 'admin_reply' => stripslashes($data['admin_reply']),
150
+ 'admin_reply_uid' => (int) $data['admin_reply_uid'],
151
+ 'book_id' => (int) $data['book_id'],
152
+ );
153
+
154
+ $entry = new gwolle_gb_entry();
155
+
156
+ $entry->set_data( $item );
157
+
158
+ // Add entry to the array of all entries
159
+ $entries[] = $entry;
160
+ }
161
+ return $entries;
162
+ }
163
+ return false;
164
+ }
165
+
166
+
167
+ /*
168
+ * Function to set/get if this is a search query for guestbook entries.
169
+ *
170
+ * @param bool $is_search_input set the search to true.
171
+ *
172
+ * @return mixed
173
+ * array with strings with terms from the search query.
174
+ * bool false, this is not a search.
175
+ *
176
+ * @since 3.0.0
177
+ */
178
+ function gwolle_gb_is_search() {
179
+
180
+ static $search_query_static;
181
+
182
+ if ( $search_query_static ) {
183
+ return $search_query_static;
184
+ }
185
+
186
+ if (isset($_GET['gwolle-gb-search-input'])) {
187
+ $search_query = trim($_GET['gwolle-gb-search-input']);
188
+
189
+ if ( strlen( $search_query ) > 0 ) {
190
+
191
+ // added slashes screw with quote grouping when done early, so done later
192
+ $search_query = stripslashes( $search_query );
193
+ $search_query = urldecode( $search_query );
194
+ // there are no line breaks in <input /> fields
195
+ $search_query = str_replace( array( "\r", "\n" ), '', $search_query );
196
+ $search_query = sanitize_text_field( $search_query );
197
+
198
+ $search_query = explode( ' ', $search_query );
199
+
200
+ $search_query_static = $search_query; // use static var as cache.
201
+ return $search_query_static;
202
+
203
+ }
204
+ }
205
+
206
+ return false;
207
+
208
+ }
209
+
210
+
211
+ /*
212
+ * gwolle_gb_get_entry_count_from_search
213
+ * Get the number of entries from the database for a search query.
214
+ *
215
+ * @param array $args
216
+ * - checked string: 'checked' or 'unchecked', List the entries that are checked or not checked
217
+ * - trash string: 'trash' or 'notrash', List the entries that are deleted or not deleted
218
+ * - spam string: 'spam' or 'nospam', List the entries marked as spam or as no spam
219
+ * - all string: 'all', List all entries
220
+ * - book_id int: Only entries from this book. Default in the shortcode is 1.
221
+ *
222
+ * @return mixed int with the count of the entries, false if there's an error.
223
+ *
224
+ * @since 3.0.0
225
+ */
226
+ function gwolle_gb_get_entry_count_from_search( $args ) {
227
+
228
+ global $wpdb;
229
+
230
+ static $count_static;
231
+ if ( $count_static ) {
232
+ return $count_static;
233
+ }
234
+
235
+ $where = " 1 = %d";
236
+ $values = Array(1);
237
+
238
+ if ( ! is_array($args) ) {
239
+ return false;
240
+ }
241
+
242
+ if ( isset($args['checked']) ) {
243
+ if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
244
+ $where .= "
245
+ AND
246
+ ischecked = %d";
247
+ if ( $args['checked'] == 'checked' ) {
248
+ $values[] = 1;
249
+ } else if ( $args['checked'] == 'unchecked' ) {
250
+ $values[] = 0;
251
+ }
252
+ }
253
+ }
254
+ if ( isset($args['spam']) ) {
255
+ if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
256
+ $where .= "
257
+ AND
258
+ isspam = %d";
259
+ if ( $args['spam'] == 'spam' ) {
260
+ $values[] = 1;
261
+ } else if ( $args['spam'] == 'nospam' ) {
262
+ $values[] = 0;
263
+ }
264
+ }
265
+ }
266
+ if ( isset($args['trash']) ) {
267
+ if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
268
+ $where .= "
269
+ AND
270
+ istrash = %d";
271
+ if ( $args['trash'] == 'trash' ) {
272
+ $values[] = 1;
273
+ } else if ( $args['trash'] == 'notrash' ) {
274
+ $values[] = 0;
275
+ }
276
+ }
277
+ }
278
+ if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
279
+ $where .= "
280
+ AND
281
+ book_id = %d";
282
+ $values[] = (int) $args['book_id'];
283
+ }
284
+
285
+ $search_query = gwolle_gb_is_search();
286
+ $tablename = $wpdb->prefix . "gwolle_gb_entries";
287
+ foreach ( $search_query as $term ) {
288
+ $like = '%' . $wpdb->esc_like( $term ) . '%';
289
+ $where .= $wpdb->prepare( "
290
+ AND (
291
+ ($tablename . author_name LIKE %s)
292
+ OR
293
+ ($tablename . content LIKE %s)
294
+ OR
295
+ ($tablename . admin_reply LIKE %s))",
296
+ $like, $like, $like
297
+ );
298
+ }
299
+
300
+ $sql = "
301
+ SELECT
302
+ COUNT(id) AS count
303
+ FROM
304
+ " . $tablename . "
305
+ WHERE
306
+ " . $where . "
307
+ ;";
308
+
309
+ $sql = $wpdb->prepare( $sql, $values );
310
+
311
+ // Do a real query.
312
+ $data = $wpdb->get_results( $sql, ARRAY_A );
313
+
314
+ $count_static = (int) $data[0]['count']; // use static var as cache.
315
+ return $count_static;
316
+
317
+ }
functions/gb-get_entry_count.php DELETED
@@ -1,116 +0,0 @@
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
- * gwolle_gb_get_entry_count
12
- * Get the number of entries.
13
- *
14
- * @param array $args
15
- * - checked string: 'checked' or 'unchecked', List the entries that are checked or not checked
16
- * - trash string: 'trash' or 'notrash', List the entries that are deleted or not deleted
17
- * - spam string: 'spam' or 'nospam', List the entries marked as spam or as no spam
18
- * - all string: 'all', List all entries
19
- * - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
20
- *
21
- * @return mixed int with the count of the entries, false if there's an error.
22
- */
23
- function gwolle_gb_get_entry_count($args) {
24
-
25
- global $wpdb;
26
-
27
-
28
- $where = " 1 = %d";
29
- $values = Array(1);
30
-
31
- if ( !is_array($args) ) {
32
- return false;
33
- }
34
-
35
- if ( isset($args['checked']) ) {
36
- if ( $args['checked'] == 'checked' || $args['checked'] == 'unchecked' ) {
37
- $where .= "
38
- AND
39
- ischecked = %d";
40
- if ( $args['checked'] == 'checked' ) {
41
- $values[] = 1;
42
- } else if ( $args['checked'] == 'unchecked' ) {
43
- $values[] = 0;
44
- }
45
- }
46
- }
47
- if ( isset($args['spam']) ) {
48
- if ( $args['spam'] == 'spam' || $args['spam'] == 'nospam' ) {
49
- $where .= "
50
- AND
51
- isspam = %d";
52
- if ( $args['spam'] == 'spam' ) {
53
- $values[] = 1;
54
- } else if ( $args['spam'] == 'nospam' ) {
55
- $values[] = 0;
56
- }
57
- }
58
- }
59
- if ( isset($args['trash']) ) {
60
- if ( $args['trash'] == 'trash' || $args['trash'] == 'notrash' ) {
61
- $where .= "
62
- AND
63
- istrash = %d";
64
- if ( $args['trash'] == 'trash' ) {
65
- $values[] = 1;
66
- } else if ( $args['trash'] == 'notrash' ) {
67
- $values[] = 0;
68
- }
69
- }
70
- }
71
- if ( isset( $args['book_id']) && ((int) $args['book_id']) > 0 ) {
72
- $where .= "
73
- AND
74
- book_id = %d";
75
- $values[] = (int) $args['book_id'];
76
- }
77
-
78
- $tablename = $wpdb->prefix . "gwolle_gb_entries";
79
-
80
- $sql = "
81
- SELECT
82
- COUNT(id) AS count
83
- FROM
84
- " . $tablename . "
85
- WHERE
86
- " . $where . "
87
- ;";
88
-
89
- $sql = $wpdb->prepare( $sql, $values );
90
-
91
-
92
- /* Support caching of the result. */
93
- $key = md5( serialize( $sql ) );
94
- $cache_key = "gwolle_gb_get_entry_count:$key";
95
- $cache_value = wp_cache_get( $cache_key );
96
-
97
- if ( false === $cache_value ) {
98
-
99
- // Do a real query.
100
- $data = $wpdb->get_results( $sql, ARRAY_A );
101
-
102
- wp_cache_add( $cache_key, $data );
103
-
104
- // $wpdb->print_error();
105
- // echo "number of rows: " . $wpdb->num_rows;
106
-
107
- } else {
108
-
109
- // This is data from cache.
110
- $data = $cache_value;
111
-
112
- }
113
-
114
- return (int) $data[0]['count'];
115
-
116
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/gb-log.php CHANGED
@@ -214,33 +214,33 @@ function gwolle_gb_get_log_entries( $entry_id ) {
214
  * @return bool true or false, depending on succes
215
  */
216
  function gwolle_gb_del_log_entries( $entry_id ) {
217
- global $wpdb;
218
 
219
- $entry_id = intval( $entry_id );
220
 
221
- if ( $entry_id == 0 || $entry_id < 0 ) {
222
- return false;
223
- }
224
 
225
- $sql = "
226
- DELETE
227
- FROM
228
- $wpdb->gwolle_gb_log
229
- WHERE
230
- entry_id = %d";
231
 
232
- $values = array(
233
- $entry_id
234
- );
235
 
236
- $result = $wpdb->query(
237
- $wpdb->prepare( $sql, $values )
238
- );
239
 
240
 
241
- if ( $result > 0 ) {
242
- return true;
243
- }
244
- return false;
245
  }
246
  add_action( 'gwolle_gb_delete_entry', 'gwolle_gb_del_log_entries' );
214
  * @return bool true or false, depending on succes
215
  */
216
  function gwolle_gb_del_log_entries( $entry_id ) {
217
+ global $wpdb;
218
 
219
+ $entry_id = intval( $entry_id );
220
 
221
+ if ( $entry_id == 0 || $entry_id < 0 ) {
222
+ return false;
223
+ }
224
 
225
+ $sql = "
226
+ DELETE
227
+ FROM
228
+ $wpdb->gwolle_gb_log
229
+ WHERE
230
+ entry_id = %d";
231
 
232
+ $values = array(
233
+ $entry_id
234
+ );
235
 
236
+ $result = $wpdb->query(
237
+ $wpdb->prepare( $sql, $values )
238
+ );
239
 
240
 
241
+ if ( $result > 0 ) {
242
+ return true;
243
+ }
244
+ return false;
245
  }
246
  add_action( 'gwolle_gb_delete_entry', 'gwolle_gb_del_log_entries' );
functions/gb-messages.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- * Functions to handle global variables for messages and errors.
4
  */
5
 
6
 
@@ -17,31 +17,32 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
17
  * @param string $error if it is a validation error for the form (default false).
18
  * @param string $error_field which field does not validate.
19
  *
 
 
20
  * @since 1.5.6
21
  */
22
  function gwolle_gb_add_message( $message = false, $error = false, $error_field = false ) {
23
- global $gwolle_gb_messages, $gwolle_gb_errors, $gwolle_gb_error_fields;
24
 
25
- // Messages to show on the frontend.
26
- if ( ! isset( $gwolle_gb_messages ) ) {
 
27
  $gwolle_gb_messages = array();
28
  }
 
29
  if ( $message ) {
30
  $gwolle_gb_messages[] = $message;
31
  }
32
 
33
- // Error, true or false.
34
  if ( $error === true ) {
35
- $gwolle_gb_errors = true;
36
  }
37
 
38
- // Error fields in the form.
39
- if ( ! isset( $gwolle_gb_error_fields ) ) {
40
- $gwolle_gb_error_fields = array();
41
- }
42
  if ( $error_field ) {
43
- $gwolle_gb_error_fields[] = $error_field;
44
  }
 
 
 
45
  }
46
 
47
 
@@ -51,57 +52,101 @@ function gwolle_gb_add_message( $message = false, $error = false, $error_field =
51
  * @return string with html with messages
52
  *
53
  * @since 1.5.6
54
- *
55
  */
56
  function gwolle_gb_get_messages() {
57
- global $gwolle_gb_messages;
58
 
59
- // Messages to show on the frontend.
60
- if ( ! isset( $gwolle_gb_messages ) ) {
61
- $gwolle_gb_messages = array();
62
- }
63
 
64
  $messages = '';
65
- $returned_messages = array();
66
- $gwolle_gb_error_fields = gwolle_gb_get_error_fields();
67
- if ( is_array( $gwolle_gb_error_fields ) && !empty( $gwolle_gb_error_fields ) ) {
68
  // There was no data filled in, even though that was mandatory.
69
- $returned_messages[] = '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There were errors submitting your guestbook entry.', 'gwolle-gb') . '</strong></p>';
70
- $returned_messages[] = '<p class="error_fields gb-error-fields" style="display: none;">' . print_r( $gwolle_gb_error_fields, true ) . '</p>';
71
- }
72
- foreach ( $gwolle_gb_messages as $message ) {
73
- $returned_messages[] = $message;
74
  }
75
 
76
- $returned_messages = apply_filters( 'gwolle_gb_messages', $returned_messages );
77
 
78
- foreach ( $returned_messages as $message ) {
79
  $messages .= $message; // string
80
  }
81
 
82
  return $messages;
 
83
  }
84
 
85
 
86
  /*
87
- * Used for the frontend form, if errors were found.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  *
89
  * @return bool if errors were found.
90
  *
91
  * @since 1.5.6
92
- *
93
  */
94
  function gwolle_gb_get_errors() {
95
- global $gwolle_gb_errors;
96
 
97
- // Messages to show on the frontend.
 
98
  if ( ! isset( $gwolle_gb_errors ) ) {
99
  $gwolle_gb_errors = false;
100
  }
101
 
102
- $_gwolle_gb_errors = apply_filters( 'gwolle_gb_errors', $gwolle_gb_errors );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- return $_gwolle_gb_errors;
105
  }
106
 
107
 
@@ -111,16 +156,12 @@ function gwolle_gb_get_errors() {
111
  * @since 1.5.6
112
  */
113
  function gwolle_gb_get_error_fields() {
114
- global $gwolle_gb_error_fields;
115
 
116
- // Messages to show on the frontend.
117
- if ( ! isset( $gwolle_gb_error_fields ) ) {
118
- $gwolle_gb_error_fields = array();
119
- }
120
 
121
- $_gwolle_gb_error_fields = apply_filters( 'gwolle_gb_error_fields', $gwolle_gb_error_fields );
122
 
123
- return $_gwolle_gb_error_fields;
124
  }
125
 
126
 
@@ -130,35 +171,40 @@ function gwolle_gb_get_error_fields() {
130
  * @param string $field name of the formfield.
131
  * @param string $value value of the formfield to be used again.
132
  *
 
 
133
  * @since 1.5.6
134
  */
135
- function gwolle_gb_add_formdata( $field, $value = '' ) {
136
- global $gwolle_gb_formdata;
 
137
 
138
- if ( ! isset( $gwolle_gb_formdata ) ) {
139
  $gwolle_gb_formdata = array();
140
  }
141
- if ( $value ) {
142
- $gwolle_gb_formdata[ $field ] = $value;
 
143
  }
 
 
 
144
  }
145
 
146
 
147
  /*
148
  * formdata to be used again on the frontend form after submitting.
149
  *
150
- * @return string html with formdata to be used again on the frontend.
151
  *
152
  * @since 1.5.6
153
  */
154
  function gwolle_gb_get_formdata() {
155
- global $gwolle_gb_formdata;
156
 
157
- if ( ! isset( $gwolle_gb_formdata ) ) {
158
- $gwolle_gb_formdata = array();
159
- }
160
 
161
  $_gwolle_gb_formdata = apply_filters( 'gwolle_gb_formdata', $gwolle_gb_formdata );
162
 
163
  return $_gwolle_gb_formdata;
 
164
  }
1
  <?php
2
  /*
3
+ * Functions to handle static variables for messages and errors.
4
  */
5
 
6
 
17
  * @param string $error if it is a validation error for the form (default false).
18
  * @param string $error_field which field does not validate.
19
  *
20
+ * @return array list of messages that are already added.
21
+ *
22
  * @since 1.5.6
23
  */
24
  function gwolle_gb_add_message( $message = false, $error = false, $error_field = false ) {
 
25
 
26
+ static $gwolle_gb_messages;
27
+
28
+ if ( ! isset( $gwolle_gb_messages ) || ! is_array( $gwolle_gb_messages ) ) {
29
  $gwolle_gb_messages = array();
30
  }
31
+
32
  if ( $message ) {
33
  $gwolle_gb_messages[] = $message;
34
  }
35
 
 
36
  if ( $error === true ) {
37
+ gwolle_gb_add_error( true );
38
  }
39
 
 
 
 
 
40
  if ( $error_field ) {
41
+ gwolle_gb_add_error_field( $error_field );
42
  }
43
+
44
+ return $gwolle_gb_messages;
45
+
46
  }
47
 
48
 
52
  * @return string with html with messages
53
  *
54
  * @since 1.5.6
 
55
  */
56
  function gwolle_gb_get_messages() {
 
57
 
58
+ $gwolle_gb_messages = gwolle_gb_add_message();
59
+ $gwolle_gb_errors = gwolle_gb_get_errors();
60
+ $gwolle_gb_error_fields = gwolle_gb_get_error_fields();
 
61
 
62
  $messages = '';
63
+
64
+ if ( $gwolle_gb_errors && is_array( $gwolle_gb_error_fields ) && ! empty( $gwolle_gb_error_fields ) ) {
 
65
  // There was no data filled in, even though that was mandatory.
66
+ $gwolle_gb_messages[] = '<p class="error_fields gb-error-fields"><strong>' . esc_html__('There were errors submitting your guestbook entry.', 'gwolle-gb') . '</strong></p>';
67
+ $gwolle_gb_messages[] = '<p class="error_fields gb-error-fields" style="display: none;">' . print_r( $gwolle_gb_error_fields, true ) . '</p>';
 
 
 
68
  }
69
 
70
+ $gwolle_gb_messages = apply_filters( 'gwolle_gb_messages', $gwolle_gb_messages );
71
 
72
+ foreach ( $gwolle_gb_messages as $message ) {
73
  $messages .= $message; // string
74
  }
75
 
76
  return $messages;
77
+
78
  }
79
 
80
 
81
  /*
82
+ * Add errors to return the form after submitting an entry.
83
+ *
84
+ * @param bool $error is there a fatal error in submitting the form.
85
+ *
86
+ * @return bool if there was a fatal error already.
87
+ *
88
+ * @since 3.0.0
89
+ */
90
+ function gwolle_gb_add_error( $error = false ) {
91
+
92
+ static $gwolle_gb_errors;
93
+
94
+ if ( ! isset( $gwolle_gb_errors ) || ! is_bool( $gwolle_gb_errors ) ) {
95
+ $gwolle_gb_errors = false;
96
+ }
97
+
98
+ if ( $error === true ) {
99
+ $gwolle_gb_errors = $error;
100
+ }
101
+
102
+ return $gwolle_gb_errors;
103
+
104
+ }
105
+
106
+ /*
107
+ * Used for the frontend form, if fatal errors were found.
108
  *
109
  * @return bool if errors were found.
110
  *
111
  * @since 1.5.6
 
112
  */
113
  function gwolle_gb_get_errors() {
 
114
 
115
+ $gwolle_gb_errors = gwolle_gb_add_error();
116
+
117
  if ( ! isset( $gwolle_gb_errors ) ) {
118
  $gwolle_gb_errors = false;
119
  }
120
 
121
+ $gwolle_gb_errors = apply_filters( 'gwolle_gb_errors', $gwolle_gb_errors );
122
+
123
+ return $gwolle_gb_errors;
124
+ }
125
+
126
+
127
+ /*
128
+ * Add error_field to mark as red in the form after submitting an entry.
129
+ *
130
+ * @param string $field name of the formfield.
131
+ *
132
+ * @return array error_fields that were added to the static var.
133
+ *
134
+ * @since 3.0.0
135
+ */
136
+ function gwolle_gb_add_error_field( $error_field = false ) {
137
+
138
+ static $gwolle_gb_error_fields;
139
+
140
+ if ( ! isset( $gwolle_gb_error_fields ) || ! is_array( $gwolle_gb_error_fields ) ) {
141
+ $gwolle_gb_error_fields = array();
142
+ }
143
+
144
+ if ( $error_field ) {
145
+ $gwolle_gb_error_fields[] = $error_field;
146
+ }
147
+
148
+ return $gwolle_gb_error_fields;
149
 
 
150
  }
151
 
152
 
156
  * @since 1.5.6
157
  */
158
  function gwolle_gb_get_error_fields() {
 
159
 
160
+ $gwolle_gb_error_fields = gwolle_gb_add_error_field();
 
 
 
161
 
162
+ $gwolle_gb_error_fields = apply_filters( 'gwolle_gb_error_fields', $gwolle_gb_error_fields );
163
 
164
+ return $gwolle_gb_error_fields;
165
  }
166
 
167
 
171
  * @param string $field name of the formfield.
172
  * @param string $value value of the formfield to be used again.
173
  *
174
+ * @return array formdata that was added to the static var.
175
+ *
176
  * @since 1.5.6
177
  */
178
+ function gwolle_gb_add_formdata( $field = false, $value = false ) {
179
+
180
+ static $gwolle_gb_formdata;
181
 
182
+ if ( ! isset( $gwolle_gb_formdata ) || ! is_array( $gwolle_gb_formdata ) ) {
183
  $gwolle_gb_formdata = array();
184
  }
185
+
186
+ if ( $field && $value ) {
187
+ $gwolle_gb_formdata["$field"] = $value;
188
  }
189
+
190
+ return $gwolle_gb_formdata;
191
+
192
  }
193
 
194
 
195
  /*
196
  * formdata to be used again on the frontend form after submitting.
197
  *
198
+ * @return array formdata to be used again on the frontend.
199
  *
200
  * @since 1.5.6
201
  */
202
  function gwolle_gb_get_formdata() {
 
203
 
204
+ $gwolle_gb_formdata = gwolle_gb_add_formdata();
 
 
205
 
206
  $_gwolle_gb_formdata = apply_filters( 'gwolle_gb_formdata', $gwolle_gb_formdata );
207
 
208
  return $_gwolle_gb_formdata;
209
+
210
  }
functions/gb-misc.php DELETED
@@ -1,93 +0,0 @@
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
- * Taken from wp-admin/includes/template.php touch_time()
12
- * Adapted for simplicity.
13
- *
14
- * @param object $entry instance of the class gb_entry
15
- */
16
- function gwolle_gb_touch_time( $entry ) {
17
- global $wp_locale;
18
-
19
- $date = $entry->get_datetime();
20
- if ( !$date ) {
21
- $date = current_time('timestamp');
22
- }
23
-
24
- $dd = date( 'd', $date );
25
- $mm = date( 'm', $date );
26
- $yy = date( 'Y', $date );
27
- $hh = date( 'H', $date );
28
- $mn = date( 'i', $date );
29
-
30
- // Day
31
- echo '<label><span class="screen-reader-text">' . esc_html__( 'Day', 'gwolle-gb' ) . '</span><input type="text" id="dd" name="dd" value="' . $dd . '" size="2" maxlength="2" autocomplete="off" /></label>';
32
-
33
- // Month
34
- echo '<label for="mm"><span class="screen-reader-text">' . esc_html__( 'Month', 'gwolle-gb' ) . '</span><select id="mm" name="mm">\n';
35
- for ( $i = 1; $i < 13; $i = $i +1 ) {
36
- $monthnum = zeroise($i, 2);
37
- echo "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
38
- /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
39
- echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
40
- }
41
- echo '</select></label>';
42
-
43
- // Year
44
- echo '<label for="yy"><span class="screen-reader-text">' . esc_html__( 'Year', 'gwolle-gb' ) . '</span><input type="text" id="yy" name="yy" value="' . $yy . '" size="4" maxlength="4" autocomplete="off" /></label>';
45
- echo '<br />';
46
- // Hour
47
- echo '<label for="hh"><span class="screen-reader-text">' . esc_html__( 'Hour', 'gwolle-gb' ) . '</span><input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2" autocomplete="off" /></label>:';
48
- // Minute
49
- echo '<label for="mn"><span class="screen-reader-text">' . esc_html__( 'Minute', 'gwolle-gb' ) . '</span><input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2" autocomplete="off" /></label>';
50
- ?>
51
-
52
- <div class="gwolle_gb_timestamp">
53
- <!-- Clicking OK will place a timestamp here. -->
54
- <input type="hidden" id="gwolle_gb_timestamp" name="gwolle_gb_timestamp" value="" />
55
- </div>
56
-
57
- <p>
58
- <a href="#" class="gwolle_gb_save_timestamp hide-if-no-js button" title="<?php esc_attr_e('Save the date and time', 'gwolle-gb'); ?>">
59
- <?php esc_html_e('Save Date', 'gwolle-gb'); ?>
60
- </a>
61
- <a href="#" class="gwolle_gb_cancel_timestamp hide-if-no-js button-cancel" title="<?php esc_attr_e('Cancel saving date and time', 'gwolle-gb'); ?>">
62
- <?php esc_html_e('Cancel', 'gwolle-gb'); ?>
63
- </a>
64
- </p>
65
- <?php
66
- }
67
-
68
-
69
- /*
70
- * Use a custom field name for the form fields that are different for each website.
71
- *
72
- * @param string field name of the requested field.
73
- * @return string hashed fieldname or fieldname, prepended with gwolle_gb.
74
- *
75
- * @since 2.4.1
76
- */
77
- function gwolle_gb_get_field_name( $field ) {
78
-
79
- if ( ! in_array( $field, array( 'name', 'city', 'email', 'website', 'honeypot', 'honeypot2', 'nonce', 'custom', 'timeout', 'timeout2' ) ) ) {
80
- return 'gwolle_gb_' . $field;
81
- }
82
-
83
- $blog_url = get_bloginfo('wpurl');
84
- $key = 'gwolle_gb_' . $field . '_field_name_' . $blog_url;
85
- $field_name = get_transient( $key );
86
- if ( false === $field_name ) {
87
- $field_name = wp_hash( $key, 'auth' );
88
- set_transient( $key, $field_name, DAY_IN_SECONDS );
89
- }
90
- $field_name = 'gwolle_gb_' . $field_name;
91
-
92
- return $field_name;
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/gb-post-meta.php CHANGED
@@ -70,8 +70,8 @@ add_filter( 'is_protected_meta', 'gwolle_gb_is_protected_meta', 10, 3 );
70
  * Set Meta_keys so we can find the post with the shortcode back.
71
  * Gets called from frontend/gb-shortcodes.php.
72
  *
73
- * @param string $shortcode value 'write' or 'read'.
74
- * @param array $shortcode_atts array with the shortcode attributes.
75
  *
76
  * @since 1.5.6
77
  */
@@ -100,3 +100,24 @@ function gwolle_gb_set_meta_keys( $shortcode, $shortcode_atts ) {
100
  }
101
 
102
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  * Set Meta_keys so we can find the post with the shortcode back.
71
  * Gets called from frontend/gb-shortcodes.php.
72
  *
73
+ * @param string $shortcode value 'write' or 'read'.
74
+ * @param array $shortcode_atts array with the shortcode attributes.
75
  *
76
  * @since 1.5.6
77
  */
100
  }
101
 
102
  }
103
+
104
+
105
+ /*
106
+ * Check whether this post/page is a guestbook.
107
+ * Will test if the 'gwolle_gb_read' meta key is set to 'true'.
108
+ *
109
+ * @param bool $post_id the ID of the post to check.
110
+ * @return bool true if this post has a guestbook shortcode.
111
+ *
112
+ * @since 3.0.0
113
+ */
114
+ function gwolle_gb_post_is_guestbook( $post_id ) {
115
+
116
+ $meta_value_read = get_post_meta( $post_id, 'gwolle_gb_read', true );
117
+ if ( $meta_value_read == 'true' ) {
118
+ return true;
119
+ }
120
+
121
+ return false;
122
+
123
+ }
gwolle-gb-hooks.php CHANGED
@@ -64,7 +64,7 @@ function gwolle_gb_register() {
64
  wp_enqueue_script('jquery');
65
 
66
  // Register script for frontend. Load it later.
67
- wp_register_script( 'gwolle_gb_frontend_js', plugins_url('frontend/js/gwolle-gb-frontend.js', __FILE__), 'jquery', GWOLLE_GB_VER, true );
68
  $dataToBePassed = array(
69
  'ajax_url' => admin_url('admin-ajax.php'),
70
  'load_message' => /* translators: Infinite Scroll */ esc_html__('Loading more...', 'gwolle-gb'),
@@ -76,13 +76,37 @@ function gwolle_gb_register() {
76
  );
77
  wp_localize_script( 'gwolle_gb_frontend_js', 'gwolle_gb_frontend_script', $dataToBePassed );
78
 
79
-
80
  // Register style for frontend. Load it later.
81
- wp_register_style('gwolle_gb_frontend_css', plugins_url('frontend/css/gwolle-gb-frontend.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
82
  }
83
  add_action('wp_enqueue_scripts', 'gwolle_gb_register');
84
 
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /*
87
  * Load Language files for frontend and backend.
88
  */
64
  wp_enqueue_script('jquery');
65
 
66
  // Register script for frontend. Load it later.
67
+ wp_register_script( 'gwolle_gb_frontend_js', GWOLLE_GB_URL . 'frontend/js/gwolle-gb-frontend.js', 'jquery', GWOLLE_GB_VER, true );
68
  $dataToBePassed = array(
69
  'ajax_url' => admin_url('admin-ajax.php'),
70
  'load_message' => /* translators: Infinite Scroll */ esc_html__('Loading more...', 'gwolle-gb'),
76
  );
77
  wp_localize_script( 'gwolle_gb_frontend_js', 'gwolle_gb_frontend_script', $dataToBePassed );
78
 
 
79
  // Register style for frontend. Load it later.
80
+ wp_register_style('gwolle_gb_frontend_css', GWOLLE_GB_URL . 'frontend/css/gwolle-gb-frontend.css', false, GWOLLE_GB_VER, 'screen');
81
  }
82
  add_action('wp_enqueue_scripts', 'gwolle_gb_register');
83
 
84
 
85
+ /*
86
+ * Enqueue JS and CSS for marktitup editor functions.
87
+ *
88
+ * @since 3.0.0
89
+ */
90
+ function gwolle_gb_enqueue_markitup() {
91
+ wp_enqueue_script( 'markitup', GWOLLE_GB_URL . 'frontend/markitup/jquery.markitup.js', 'jquery', GWOLLE_GB_VER, false );
92
+ wp_enqueue_style('gwolle_gb_markitup_css', GWOLLE_GB_URL . 'frontend/markitup/style.css', false, GWOLLE_GB_VER, 'screen');
93
+
94
+ $dataToBePassed = array(
95
+ 'bold' => /* translators: MarkItUp menu item */ esc_html__('Bold', 'gwolle-gb' ),
96
+ 'italic' => /* translators: MarkItUp menu item */ esc_html__('Italic', 'gwolle-gb' ),
97
+ 'bullet' => /* translators: MarkItUp menu item */ esc_html__('Bulleted List', 'gwolle-gb' ),
98
+ 'numeric' => /* translators: MarkItUp menu item */ esc_html__('Numeric List', 'gwolle-gb' ),
99
+ 'picture' => /* translators: MarkItUp menu item */ esc_html__('Picture', 'gwolle-gb' ),
100
+ 'source' => /* translators: MarkItUp menu item */ esc_html__('Source', 'gwolle-gb' ),
101
+ 'link' => /* translators: MarkItUp menu item */ esc_html__('Link', 'gwolle-gb' ),
102
+ 'linktext' => /* translators: MarkItUp menu item */ esc_html__('Your text to link...', 'gwolle-gb' ),
103
+ 'clean' => /* translators: MarkItUp menu item */ esc_html__('Clean', 'gwolle-gb' ),
104
+ 'emoji' => /* translators: MarkItUp menu item */ esc_html__('Emoji', 'gwolle-gb' )
105
+ );
106
+ wp_localize_script( 'markitup', 'gwolle_gb_localize', $dataToBePassed );
107
+ }
108
+
109
+
110
  /*
111
  * Load Language files for frontend and backend.
112
  */
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.6.7
7
  Author: Marcel Pol
8
  Author URI: http://zenoweb.nl
9
  License: GPLv2 or later
@@ -13,7 +13,7 @@ Domain Path: /lang/
13
 
14
  /*
15
  Copyright 2009 - 2010 Wolfgang Timme (email: gwolle@wolfgangtimme.de)
16
- Copyright 2014 - 2018 Marcel Pol (email: marcel@timelord.nl)
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
@@ -32,40 +32,31 @@ Domain Path: /lang/
32
 
33
 
34
  // Plugin Version
35
- define('GWOLLE_GB_VER', '2.6.7');
36
 
37
 
38
  /*
39
- * Todo for 3.0:
40
- *
41
- * - All CSS classes use dashes, not underscores.
42
- *
43
- *
44
  * Todo List:
45
  *
46
  * - Entries Admin page, make columns sortable, add order parameters to get* functions.
47
  * - On Page editor, have a postbox with link to the guestbook admin entries.
48
- * - BBcode: have sublists work.
49
  * - BBcode: add width and height to images.
50
- * - On admin pages, have separate functions for $_POST update. (editor, entries)
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.
57
  * - Consider a functions/list-view.php refactoring.
58
- * - Really switch to InnoDB.
59
  * - Consider SQL IN when emptying spam/trash.
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
  * - Unify statuses in one status column like WP_Posts.
65
  * - Add status 'revision' to support that too. Add metabox to editor to restore old revision.
66
  * - More smooth import from third parties.
67
- * - Test and possibly add support for Gutenberg editor.
68
- * - Add <noscript> for when JS is disbaled.
 
 
 
 
 
69
  *
70
  */
71
 
@@ -89,7 +80,7 @@ $wpdb->gwolle_gb_log = $wpdb->prefix . 'gwolle_gb_log';
89
  include_once( GWOLLE_GB_DIR . '/functions/gb-class-entry.php' );
90
 
91
  // Functions for the frontend
92
- include_once( GWOLLE_GB_DIR . '/frontend/gb-ajax-infinite_scroll.php' );
93
  include_once( GWOLLE_GB_DIR . '/frontend/gb-ajax-captcha.php' );
94
  include_once( GWOLLE_GB_DIR . '/frontend/gb-form.php' );
95
  include_once( GWOLLE_GB_DIR . '/frontend/gb-form-ajax.php' );
@@ -101,6 +92,7 @@ include_once( GWOLLE_GB_DIR . '/frontend/gb-read.php' );
101
  include_once( GWOLLE_GB_DIR . '/frontend/gb-rss.php' );
102
  include_once( GWOLLE_GB_DIR . '/frontend/gb-total.php' );
103
  include_once( GWOLLE_GB_DIR . '/frontend/gb-widget.php' );
 
104
 
105
  // Functions and pages for the backend
106
  if ( is_admin() ) {
@@ -135,14 +127,14 @@ include_once( GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php' );
135
  include_once( GWOLLE_GB_DIR . '/functions/gb-book_id.php' );
136
  include_once( GWOLLE_GB_DIR . '/functions/gb-cache.php' );
137
  include_once( GWOLLE_GB_DIR . '/functions/gb-debug.php' );
 
138
  include_once( GWOLLE_GB_DIR . '/functions/gb-formatting.php' );
139
  include_once( GWOLLE_GB_DIR . '/functions/gb-get_entries.php' );
140
- include_once( GWOLLE_GB_DIR . '/functions/gb-get_entry_count.php' );
141
  include_once( GWOLLE_GB_DIR . '/functions/gb-log.php' );
142
  include_once( GWOLLE_GB_DIR . '/functions/gb-mail.php' );
143
  include_once( GWOLLE_GB_DIR . '/functions/gb-messages.php' );
144
  include_once( GWOLLE_GB_DIR . '/functions/gb-metabox.php' );
145
- include_once( GWOLLE_GB_DIR . '/functions/gb-misc.php' );
146
  include_once( GWOLLE_GB_DIR . '/functions/gb-post-meta.php' );
147
  include_once( GWOLLE_GB_DIR . '/functions/gb-privacy.php' );
148
  include_once( GWOLLE_GB_DIR . '/functions/gb-settings.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: 3.0.0
7
  Author: Marcel Pol
8
  Author URI: http://zenoweb.nl
9
  License: GPLv2 or later
13
 
14
  /*
15
  Copyright 2009 - 2010 Wolfgang Timme (email: gwolle@wolfgangtimme.de)
16
+ Copyright 2014 - 2019 Marcel Pol (email: marcel@timelord.nl)
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
32
 
33
 
34
  // Plugin Version
35
+ define('GWOLLE_GB_VER', '3.0.0');
36
 
37
 
38
  /*
 
 
 
 
 
39
  * Todo List:
40
  *
41
  * - Entries Admin page, make columns sortable, add order parameters to get* functions.
42
  * - On Page editor, have a postbox with link to the guestbook admin entries.
 
43
  * - BBcode: add width and height to images.
 
 
44
  * - Add Filter for get_entry_count SQL, like get_entries.
45
  * - Add filters similar to pre_get_posts.
 
46
  * - Add proper docblocks to filters in the code.
 
47
  * - Consider a functions/list-view.php refactoring.
 
48
  * - Consider SQL IN when emptying spam/trash.
 
 
 
49
  * - Someday, do something with the REST API. Someday.
50
  * - Unify statuses in one status column like WP_Posts.
51
  * - Add status 'revision' to support that too. Add metabox to editor to restore old revision.
52
  * - More smooth import from third parties.
53
+ * - Test and possibly add support for Gutenberg editor (shortcode block).
54
+ * - Support sticky entries.
55
+ * - Support mark-as-ham for Stop Forum Spam.
56
+ * - Do something to have less database queries for meta fields in add-on, especially export:
57
+ * - Use foreign keys for add-on, set meta var (add function). Test with frontend and export and isam db-engine.
58
+ * - Use foreign keys through a hook with SQL, and add a setter for meta.
59
+ * - Or add function to prepopulate metas for export.
60
  *
61
  */
62
 
80
  include_once( GWOLLE_GB_DIR . '/functions/gb-class-entry.php' );
81
 
82
  // Functions for the frontend
83
+ include_once( GWOLLE_GB_DIR . '/frontend/gb-ajax-infinite-scroll.php' );
84
  include_once( GWOLLE_GB_DIR . '/frontend/gb-ajax-captcha.php' );
85
  include_once( GWOLLE_GB_DIR . '/frontend/gb-form.php' );
86
  include_once( GWOLLE_GB_DIR . '/frontend/gb-form-ajax.php' );
92
  include_once( GWOLLE_GB_DIR . '/frontend/gb-rss.php' );
93
  include_once( GWOLLE_GB_DIR . '/frontend/gb-total.php' );
94
  include_once( GWOLLE_GB_DIR . '/frontend/gb-widget.php' );
95
+ include_once( GWOLLE_GB_DIR . '/frontend/gb-widget-search.php' );
96
 
97
  // Functions and pages for the backend
98
  if ( is_admin() ) {
127
  include_once( GWOLLE_GB_DIR . '/functions/gb-book_id.php' );
128
  include_once( GWOLLE_GB_DIR . '/functions/gb-cache.php' );
129
  include_once( GWOLLE_GB_DIR . '/functions/gb-debug.php' );
130
+ include_once( GWOLLE_GB_DIR . '/functions/gb-fields.php' );
131
  include_once( GWOLLE_GB_DIR . '/functions/gb-formatting.php' );
132
  include_once( GWOLLE_GB_DIR . '/functions/gb-get_entries.php' );
133
+ include_once( GWOLLE_GB_DIR . '/functions/gb-get_entries_from_search.php' );
134
  include_once( GWOLLE_GB_DIR . '/functions/gb-log.php' );
135
  include_once( GWOLLE_GB_DIR . '/functions/gb-mail.php' );
136
  include_once( GWOLLE_GB_DIR . '/functions/gb-messages.php' );
137
  include_once( GWOLLE_GB_DIR . '/functions/gb-metabox.php' );
 
138
  include_once( GWOLLE_GB_DIR . '/functions/gb-post-meta.php' );
139
  include_once( GWOLLE_GB_DIR . '/functions/gb-privacy.php' );
140
  include_once( GWOLLE_GB_DIR . '/functions/gb-settings.php' );
readme.txt CHANGED
@@ -2,9 +2,10 @@
2
  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.6.7
7
  License: GPLv2 or later
 
8
 
9
  Gwolle Guestbook is the WordPress guestbook you've just been looking for. Beautiful and easy.
10
 
@@ -96,6 +97,10 @@ You can buy the Add-On at [Mojo Marketplace](http://www.mojomarketplace.com/item
96
 
97
  Check out the demo with the Add-On enabled at [http://demo.zenoweb.nl](http://demo.zenoweb.nl/wordpress-plugins/gwolle-guestbook-the-add-on/).
98
 
 
 
 
 
99
 
100
  == Installation ==
101
 
@@ -122,6 +127,12 @@ With version 1.0 there have been some changes:
122
  The plugin itself is released under the GNU General Public License. A copy of this license can be found at the license homepage or
123
  in the gwolle-gb.php file at the top.
124
 
 
 
 
 
 
 
125
  = Hooks: Actions and Filters =
126
 
127
  There are many hooks available in this plugin. Documentation is included in the zip file in /docs/actions and /docs/filters. Examples are included. If you have a need for a hook, please request this in the support forum.
@@ -416,330 +427,25 @@ But if you don't use standard comments, you can just as easily use the comment s
416
 
417
  == Changelog ==
418
 
419
- = 2.6.7 =
420
- * 2018-11-07
421
- * Revert previous jQuery bugfix (incompatible with IE 11).
422
- * Slightly bigger icons for BBcode menu.
423
-
424
- = 2.6.6 =
425
- * 2018-10-30
426
- * Only load admin files on wp-admin.
427
- * Use jQuery to get data from input fields in form.
428
-
429
- = 2.6.5 =
430
- * 2018-09-23
431
- * Better CSS for Microsoft browsers.
432
-
433
- = 2.6.4 =
434
- * 2018-09-23
435
- * Add CSS for screen-readers for broken themes.
436
-
437
- = 2.6.3 =
438
- * 2018-09-07
439
- * Better test if akismet is active.
440
- * Set timeout check from 7s to 4s.
441
- * Break email address in entries list as well.
442
- * Better CSS colors in admin overview.
443
- * Add support for Dark Mode beta plugin.
444
-
445
- = 2.6.2 =
446
- * 2018-07-19
447
- * Fix form for "button = false" forms.
448
- * Don't replace author URL and email with anything (follow WP core 4.9.8).
449
-
450
- = 2.6.1 =
451
- * 2018-07-09
452
- * Add screen-reader-text to frontend metabox.
453
- * Hide 'hide this form' button when form was visible on page load.
454
- * Add a filter for button class 'gwolle_gb_button_class'.
455
- * Add 'no_email' parameter to 'gwolle_gb_get_entries' function.
456
- * Add second parameter $entry to filter for mail body notifications.
457
- * Admin entries page, change label to ID column.
458
- * Fix compatibility with Add-On version 1.0.0 till 1.1.2.
459
- * Updates for Add-On 1.2.1.
460
-
461
- = 2.6.0 =
462
- * 2018-06-11
463
- * Add option to permanently remove IP address and hostname from entries.
464
- * Add cancel button for the form.
465
- * Close metabox again after click event.
466
- * Remove %ip% from default notice text.
467
- * Add example text to the privacy policy.
468
- * Refactor link to privacy policy.
469
- * Included real fix for not handling form data on some installs.
470
- * Show on editor if author was logged in or not.
471
- * Add log message to mail notification with writing time like on editor.
472
- * Add guestbook entries to WordPress personal data exporter.
473
- * Add guestbook entries to WordPress personal data eraser.
474
- * Add anonymize option to mass edit.
475
- * Add 'gwolle_gb_privacy_anonymize_entry' function.
476
- * Add 'gwolle_gb_get_permalinks' function.
477
- * Add 'gwolle_gb_get_total_entries' function.
478
- * Deprecate 'gwolle_gb_addon_get_total_entries' function.
479
- * Use 'admin_url' everywhere.
480
- * Updates for Add-On 1.2.0.
481
-
482
- = 2.5.4 =
483
- * 2018-06-06
484
- * Fix XSS security issue on admin dashboard widget (thanks DefenseCode).
485
-
486
- = 2.5.3 =
487
- * 2018-06-04
488
- * Better testing if anti-spam functions are enabled when checking the form input.
489
- * Included possible fix for not handling form data on some installs.
490
-
491
- = 2.5.2 =
492
- * 2018-05-12
493
- * Support link to privacy policy (requires WordPress 4.9.6).
494
-
495
- = 2.5.1 =
496
- * 2018-05-01
497
- * Fix link checker.
498
- * Add default parameter 'book_id' to function 'gwolle_gb_addon_get_total_entries'.
499
-
500
- = 2.5.0 =
501
- * 2018-04-13
502
- * Improve custom quiz question.
503
- * Improve and extend Honeypot anti-spam.
504
- * Add Link Checker for anti-spam.
505
- * Add timeout for submitting the form for anti-spam.
506
- * Do not send IP Address to Akismet if disabled.
507
- * Add 'date_query' parameter to 'gwolle_gb_get_entries' function.
508
- * Set default settings upon install/upgrade, so we can cache them.
509
- * Add action 'gwolle_gb_uninstall'.
510
- * Switch multisite uninstall to 'admin_init' hook.
511
- * Flush transients from cache if no book_id is set.
512
- * Switch export to 3000 entries per part instead of 5000.
513
- * New file '/functions/gb-book_id.php'.
514
- * Improve comment blocks for functions.
515
-
516
- = 2.4.2 =
517
- * 2018-03-30
518
- * Close div element correctly.
519
-
520
- = 2.4.1 =
521
- * 2018-03-28
522
- * Improve features for anti-spam.
523
- * Add readmore link to admin reply excerpt.
524
- * More improvements to mobile CSS for the form.
525
- * Fix warning when sending mail to moderator.
526
-
527
- = 2.4.0 =
528
- * 2018-03-25
529
- * Add checkbox for privacy policy for GDPR compliance.
530
- * Add option to store or not store IP Address and hostname.
531
- * Add export for user based on ID or email.
532
- * Add search on entries page for user based on ID or email.
533
- * Support meta fields from the add-on in export/import (needs add-on > 1.1.0 ).
534
- * Fix CSS for mobile form and form in widget.
535
- * Remove book_id meta key when only one entry is shown.
536
- * Fix warning on entries page when no entries.
537
- * Add function 'gwolle_gb_get_postid_biggest_book'.
538
- * Add function 'gwolle_gb_get_books'.
539
- * Add hook 'gwolle_gb_delete_entry' when permanently deleting an entry.
540
- * Delete log entries in that hook.
541
- * Use correct URL in RSS feed.
542
- * Add filters for email body.
543
- * Fix docs for filters for email subject.
544
- * Drop support for Shortcake feature plugin.
545
- * Rephrase Cheating messages like WP Core.
546
-
547
- = 2.3.10 =
548
- * 2018-02-10
549
- * Small CSS update for login form.
550
- * Small CSS update for .gb-entry.
551
- * Small CSS update for Twenty Fifteen.
552
- * Update strings for add-on 1.0.7.
553
-
554
- = 2.3.9 =
555
- * 2018-01-26
556
- * Support book_id for export and import (thanks therab).
557
-
558
- = 2.3.8 =
559
- * 2018-01-18
560
- * Editor.php: Heading for City should really be City.
561
- * Improve and add translator comments.
562
-
563
- = 2.3.7 =
564
- * 2017-11-29
565
- * Rename header field in settingsform for compatibility.
566
- * Improve some text strings (thanks dedotombo).
567
- * Update strings for add-on 1.0.5.
568
-
569
- = 2.3.6 =
570
- * 2017-11-06
571
- * Update strings for add-on 1.0.4.
572
-
573
- = 2.3.5 =
574
- * 2017-11-04
575
- * Add classes with dashes.
576
- * Small text updates.
577
-
578
- = 2.3.4 =
579
- * 2017-10-19
580
- * When editing date, show new date after saving the date.
581
- * Add translations for Add-On to GlotPress of gwolle-gb.
582
-
583
- = 2.3.3 =
584
- * 2017-10-06
585
- * Use more of esc_html function in translatable strings.
586
- * Add advertisement page for Add-On.
587
-
588
- = 2.3.2 =
589
- * 2017-09-06
590
- * Editor: also save when no change was made.
591
- * Add total counter to frontend list.
592
-
593
- = 2.3.1 =
594
- * 2017-08-29
595
- * Use correct class for menu-counters.
596
-
597
- = 2.3.0 =
598
- * 2017-08-28
599
- * Add Stop Forum Spam service for anti-spam.
600
- * GET parameter entry_id with single view is back (back from the dead).
601
- * Set admin styling to off by default.
602
- * Remove "display:inline" for span elements, it is default.
603
- * Don't use 'strip_tags' anymore.
604
- * Add Metabox on frontend for more action links.
605
- * Move Edit link and add Ajax icon to metabox in new file gb-metabox.php.
606
- * Attach event listener to frontend metabox after posting with AJAX.
607
- * Add option for Admin Avatar (thanks roots84).
608
- * Add more filters to frontend form.
609
- * Add filter 'gwolle_gb_entry_read_add_content_before'.
610
- * Add filter 'gwolle_gb_entries_list_before'.
611
- * Add action 'gwolle_gb_notsaved_entry_frontend'.
612
- * Add filter 'gwolle_gb_get_emoji'.
613
- * Add function 'gwolle_gb_get_entry_ids'.
614
- * Add callbacks for infinite scroll and AJAX post.
615
- * Set border between entries to solid instead of dotted.
616
- * Fix counters on entries.php page.
617
- * Admin Editor.php uses less globals now.
618
- * Use esc_html functions for translatable strings.
619
- * Store entry total for frontend pagination in a transient.
620
- * Store counter for admin menu in a transient.
621
- * Add gwolle_gb_is_author function.
622
- * Small refactor of AJAX JS code.
623
- * Move functions for settings, user/author, cache and shortcake to their own files.
624
-
625
- = 2.2.1 =
626
- * 2017-05-24
627
- * Fix jQuery incompatibility in Super Simple Slider (for widget).
628
-
629
- = 2.2.0 =
630
- * 2017-05-03
631
- * Add setting to refuse spam entries.
632
- * Update counter in admin menu and toolbar after check of entry.
633
- * Add translator comments for Trash (in Trash / to Trash).
634
- * Add CSS text-color to pagination.
635
- * Add filter 'gwolle_gb_entries_list_class'.
636
- * Add filter 'gwolle_gb_entry_class'.
637
- * Add filter 'gwolle_gb_widget_list_class'.
638
- * Add filter 'gwolle_gb_widget_item_class'.
639
- * Add filter 'gwolle_gb_author_link_rel'.
640
- * Add filter 'gwolle_gb_bbcode_link_rel'.
641
- * Use wp_kses_post function for sanitizing content and admin_reply.
642
- * Use sanitize_text_field function for sanitizing other fields.
643
- * Better testing for 'post_id' in shortcodes.
644
- * Some better explanations at the Settingspage for anti-spam.
645
- * Do not concatenate strings, but use sprintf on about page.
646
- * Move functions for post-meta to own file.
647
-
648
- = 2.1.5 =
649
- * 2017-02-13
650
- * Add CSS for responsive design for the form.
651
- * Add CSS for the form inside a .widget and .widget-area.
652
- * Add class .button to buttons on frontend form.
653
- * Query for widgets checks on meta field.
654
- * Make our custom fields protected.
655
- * Only save custom fields on page edit.
656
- * Improve error handling on import with missing finfo_open.
657
- * On entries list, icon column gets header 'Status'.
658
- * Don't update caches on wp_query.
659
- * Remove Polish from zipfile, it is maintained in GlotPress.
660
-
661
- = 2.1.4 =
662
- * 2017-01-19
663
- * Borrow pagination CSS from bbPress.
664
- * Add shortcode for widget layout: [gwolle_gb_widget].
665
- * Improve HTML formatting of widget.
666
- * Remove Italian and Swedish from zipfile, they are at 100% in GlotPress.
667
-
668
- = 2.1.3 =
669
- * 2016-12-24
670
- * Add rel="nofollow" to website link.
671
- * Improve HTML formatting of entry.
672
- * Add filter gwolle_gb_author_link_to_buddypress.
673
- * Add filters for prefill of the form.
674
-
675
- = 2.1.2 =
676
- * 2016-11-06
677
- * Wrap text '(no entries yet)' inside the standard div#gwolle_gb_entries so we always list the submitted entry.
678
- * Add filter for gwolle_gb_admin_reply_header.
679
- * Long words check shouldn't match http, https or ftp strings.
680
- * Explain scan for long text better.
681
- * Again fix for Twenty Sixteen and Twenty Seventeen.
682
- * On import, run the clear_cache function only once.
683
- * Slightly improve error handling for admin AJAX.
684
-
685
- = 2.1.1 =
686
- * 2016-09-07
687
- * Security fix: fix XSS on editor view (Thanks Radjnies of securify.nl).
688
- * Security fix: fix CSRF on admin pages (Thanks Radjnies of securify.nl).
689
- * Use str_replace on quotes the right way (no need to escape).
690
- * Add Nonces to admin pages and check on them.
691
- * Check the max number of checked entries on bulk edit on admin list.
692
- * Flush cache on mass delete.
693
- * Update text of metaboxes on main admin page.
694
-
695
- = 2.1.0 =
696
- * 2016-08-23
697
- * Fix html validation in form buttons.
698
- * Add setting for the scan for long text.
699
- * Set that scan from 80 chars to 100 chars.
700
- * Support persistent object cache.
701
- * Flush cache on saving an entry on admin too.
702
- * Add save-hook to mass edit.
703
- * Add save-hook to AJAX admin actions.
704
- * Add save-hook to importer.
705
- * Load admin CSS on all pages (not JS).
706
- * Offer MultiSite uninstall through a filter.
707
- * Set wpdb prefix correctly on uninstall.
708
- * Rename most files with prefix.
709
-
710
- = 2.0.2 =
711
- * 2016-08-19
712
- * Fix loading images in CSS.
713
- * Better AJAX icon.
714
- * Improve a11y of toolbar menu-item.
715
-
716
- = 2.0.1 =
717
- * 2016-08-16
718
- * Fix upgrade in MultiSite.
719
- * More subtle styling of AJAX icon.
720
- * More consistent naming in error fields.
721
- * Append Infinite Scroll load message to div#gwolle_gb_entries.
722
- * Don't use 'focus()' in form ajax, no point to it.
723
- * Rename CSS and JS files.
724
- * Rename infinite_scroll.php to ajax-infinite_scroll.php.
725
- * Rename captcha-ajax.php to ajax-captcha.php.
726
- * Rename admin/upgrade.php to admin/gwolle-gb-upgrade.php.
727
-
728
- = 2.0.0 =
729
- * 2016-08-08
730
- * Add AJAX Form Submit (default).
731
- * Add container div around gwolle_gb_messages div.
732
- * Small adaptations to form-posthandling.php.
733
- * Function 'gwolle_gb_clear_cache()' is now hooked to 'gwolle_gb_save_entry_frontend' action.
734
- * Moderator and author mail are now hooked to 'gwolle_gb_save_entry_frontend' action.
735
- * Rename frontend/write.php to frontend/form.php.
736
- * Rename frontend/posthandling.php to frontend/form-posthandling.php.
737
- * Rename admin/ajax.php to admin/ajax-management.php.
738
- * Remove more br elements from BBcode lists.
739
- * Add a 'read more' link to each entry in the widget in the form of a '&raquo;'.
740
- * Set CSS width of '.input input[type="email"]' and '.input input[type="url"]' to 100%.
741
- * Set z-index for infinite scroll load message.
742
- * Make CSS reset for MarkItUp more specific.
743
- * Add some bootstrap classes to the form.
744
- * Add comments for translators.
745
- * Cleanup changelog. Add changelog.txt for v0 and v1.
2
  Contributors: Gwolle, mpol
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 3.7
5
+ Tested up to: 5.0
6
+ Stable tag: 3.0.0
7
  License: GPLv2 or later
8
+ Requires PHP: 5.3
9
 
10
  Gwolle Guestbook is the WordPress guestbook you've just been looking for. Beautiful and easy.
11
 
97
 
98
  Check out the demo with the Add-On enabled at [http://demo.zenoweb.nl](http://demo.zenoweb.nl/wordpress-plugins/gwolle-guestbook-the-add-on/).
99
 
100
+ = Compatibility =
101
+
102
+ This plugin is compatible with [ClassicPress](https://www.classicpress.net).
103
+
104
 
105
  == Installation ==
106
 
127
  The plugin itself is released under the GNU General Public License. A copy of this license can be found at the license homepage or
128
  in the gwolle-gb.php file at the top.
129
 
130
+ = Known Issues =
131
+
132
+ On some websites sending the data from the form doesn't work correctly. Some field data is being sent and some not.
133
+ If you are affected by this issue and can debug this to find the real problem, please do so and report it on the support forum.
134
+ Disabling AJAX for the form is a good workaround.
135
+
136
  = Hooks: Actions and Filters =
137
 
138
  There are many hooks available in this plugin. Documentation is included in the zip file in /docs/actions and /docs/filters. Examples are included. If you have a need for a hook, please request this in the support forum.
427
 
428
  == Changelog ==
429
 
430
+ = 3.0.0 =
431
+ * 2019-01-22
432
+ * Add search widget (only visible on guestbook pages).
433
+ * Add '[noscript]' to frontend form for when JavaScript is disabled.
434
+ * Add function 'gwolle_gb_post_is_guestbook'.
435
+ * Add function 'gwolle_gb_get_entries_from_search'.
436
+ * Add function 'gwolle_gb_enqueue_markitup'.
437
+ * Fix BBcode: support images inside links.
438
+ * Fix BBcode: have sublists work.
439
+ * Show new username and book ID after editing in editor postbox.
440
+ * Add some accessibility fixes.
441
+ * Switch database engine to InnoDB.
442
+ * Don't use transients for hashed field names, is faster this way.
443
+ * Better test if admin user exists for admin_reply.
444
+ * Use 'field-name' for gwolle_gb_content too.
445
+ * On admin pages, have separate functions for $_POST update. (settings, editor, entries).
446
+ * Use GWOLLE_GB_URL where appropriate.
447
+ * Use static vars instead of global vars.
448
+ * Integrate 2 JavaScript files for Markitup/BBcode.
449
+ * Switch export to 2000 entries per part instead of 3000.
450
+ * Add strings for add-on 1.3.0.
451
+ * Cleanup changelog. Add changelog-v2.txt.