Gwolle Guestbook - Version 3.1.1

Version Description

  • 2019-03-08
  • Drop check for mime-type on import, too many problems.
  • Small CSS fix for pagination.
Download this release

Release Info

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

Code changes from version 3.1.0 to 3.1.1

admin/gb-page-import.php CHANGED
@@ -487,190 +487,171 @@ function gwolle_gb_page_import_post() {
487
  $valid_file = false;
488
  gwolle_gb_add_message( '<p>' . esc_html__('Your file is too large.', 'gwolle-gb') . '</p>', true, false);
489
  } else {
490
- if ( function_exists('finfo_open') ) {
491
- // Check MIME Type. Only PHP >= 5.3.0 with the Fileinfo extension loaded.
492
- $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
493
- $mimetype = trim( finfo_file( $finfo, $_FILES['start_import_gwolle_file']['tmp_name'] ) );
494
- finfo_close($finfo);
495
- } else {
496
- gwolle_gb_add_message( '<p>' . esc_html__('Please check if your PHP installation has the Fileinfo extension. You can also contact your hosting provider about this and request for that extension to be installed.', 'gwolle-gb') . '</p>', false, false);
497
- }
498
- if ( version_compare( PHP_VERSION, '5.3', '<' ) && ( ! $mimetype ) ) {
499
- // PHP 5.2 is insecure anyway?
500
- $mimetype = 'text/csv';
501
  gwolle_gb_add_message( '<p>' . esc_html__('You have a very old version of PHP. Please contact your hosting provider and request an upgrade.', 'gwolle-gb') . '</p>', false, false);
502
  }
503
- $mimetypes = array(
504
- 'csv' => 'text/csv',
505
- 'txt' => 'text/plain',
506
- 'xls' => 'application/excel',
507
- 'ms' => 'application/ms-excel',
508
- 'vnd' => 'application/vnd.ms-excel',
509
- );
510
- if ( ! in_array( $mimetype, $mimetypes ) ) {
511
- gwolle_gb_add_message( '<p>' . esc_html__('Invalid file format. Mime-type:', 'gwolle-gb') . ' ' . print_r($mimetype, true) . '</p>', true, false);
512
- } else {
513
- $handle = fopen($_FILES['start_import_gwolle_file']['tmp_name'], "r");
514
- $row = 0;
515
-
516
- while ( ( $data = fgetcsv( $handle, 2000, ',', '"' ) ) !== FALSE ) {
517
- $num = count($data);
518
- if ($row == 0) {
519
- // Check the headerrow. $testrow_old is version 1.4.1 and older.
520
- $testrow_1_0 = array(
521
- 'id',
522
- 'author_name',
523
- 'author_email',
524
- 'author_origin',
525
- 'author_website',
526
- 'author_ip',
527
- 'author_host',
528
- 'content',
529
- 'date',
530
- 'isspam',
531
- 'ischecked',
532
- 'istrash'
533
- );
534
- $testrow_1_4_1 = array(
535
- 'id',
536
- 'author_name',
537
- 'author_email',
538
- 'author_origin',
539
- 'author_website',
540
- 'author_ip',
541
- 'author_host',
542
- 'content',
543
- 'datetime',
544
- 'isspam',
545
- 'ischecked',
546
- 'istrash'
547
- );
548
- $testrow_1_4_8 = array(
549
- 'id',
550
- 'author_name',
551
- 'author_email',
552
- 'author_origin',
553
- 'author_website',
554
- 'author_ip',
555
- 'author_host',
556
- 'content',
557
- 'datetime',
558
- 'isspam',
559
- 'ischecked',
560
- 'istrash',
561
- 'admin_reply'
562
- );
563
- $testrow_2_3_9 = array(
564
- 'id',
565
- 'author_name',
566
- 'author_email',
567
- 'author_origin',
568
- 'author_website',
569
- 'author_ip',
570
- 'author_host',
571
- 'content',
572
- 'datetime',
573
- 'isspam',
574
- 'ischecked',
575
- 'istrash',
576
- 'admin_reply',
577
- 'book_id'
578
- );
579
- $testrow_2_4_0 = array(
580
- 'id',
581
- 'author_name',
582
- 'author_email',
583
- 'author_origin',
584
- 'author_website',
585
- 'author_ip',
586
- 'author_host',
587
- 'content',
588
- 'datetime',
589
- 'isspam',
590
- 'ischecked',
591
- 'istrash',
592
- 'admin_reply',
593
- 'book_id',
594
- 'meta_fields'
595
- );
596
- if ( $data != $testrow_1_0 && $data != $testrow_1_4_1 && $data != $testrow_1_4_8 && $data != $testrow_2_3_9 && $data != $testrow_2_4_0 ) {
597
- gwolle_gb_add_message( '<p>' . esc_html__('It seems your CSV file is from an export that is not compatible with this version of Gwolle-GB.', 'gwolle-gb') . '</p>', true, false);
598
- break;
599
- }
600
- $row++;
601
- continue;
602
- }
603
 
604
- if ( $num != 12 && $num != 13 && $num != 14 && $num != 15 ) {
605
- gwolle_gb_add_message( '<p>' . esc_html__('Your data seems to be corrupt. Import failed.', 'gwolle-gb') . '</p>', true, false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606
  break;
607
  }
 
 
 
608
 
609
- /* New Instance of gwolle_gb_entry. */
610
- $entry = new gwolle_gb_entry();
 
 
611
 
612
- /* Check if the date is a timestamp, else convert */
613
- if ( ! is_numeric($data[8]) ) {
614
- $data[8] = strtotime($data[8]);
615
- }
616
 
617
- /* Set the data in the instance */
618
- // $entry->set_id( $data[0] ); // id of entry
619
- $entry->set_author_name( $data[1] );
620
- $entry->set_author_email( $data[2] );
621
- $entry->set_author_origin( $data[3] );
622
- $entry->set_author_website( $data[4] );
623
- $entry->set_author_ip( $data[5] );
624
- $entry->set_author_host( $data[6] );
625
- $entry->set_content( $data[7] );
626
- $entry->set_datetime( $data[8] );
627
- $entry->set_isspam( $data[9] );
628
- $entry->set_ischecked( $data[10] );
629
- $entry->set_istrash( $data[11] );
630
- if ( isset( $data[12] ) ) {
631
- $entry->set_admin_reply( $data[12] ); // admin_reply is only since 1.4.8
632
- }
633
- if ( isset( $data[13] ) ) {
634
- $entry->set_book_id( $data[13] ); // book_id is only since 2.3.9
635
- }
636
- $metas = ''; // reset
637
- if ( isset( $data[14] ) ) {
638
- $metas = $data[14]; // meta fields is only since is only since 2.4.0
639
- }
640
 
641
- /* Save the instance */
642
- $save = $entry->save();
643
- if ( $save ) {
644
- // We have been saved to the Database
645
- if ( isset( $metas ) && function_exists( 'gwolle_gb_addon_save_meta' ) ) {
646
- $metas = maybe_unserialize( $metas );
647
- if ( ! empty( $metas ) ) {
648
- foreach ( $metas as $meta ) {
649
- gwolle_gb_addon_save_meta( $entry->get_id(), $meta['meta_key'], $meta['meta_value'] );
650
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
  }
652
  }
653
- gwolle_gb_add_log_entry( $entry->get_id(), 'imported-from-gwolle' );
654
- $row++;
655
- } else {
656
- //$gwolle_gb_messages .= '<p>' . print_r( $entry, true ) . '</p>'; // Debug
657
- gwolle_gb_add_message( '<p>' . esc_html__('Your data seems to be corrupt. Saving failed and import failed.', 'gwolle-gb') . '</p>', true, false);
658
- break;
659
  }
660
-
661
- }
662
- $row--; // minus the header
663
-
664
- if ( $row == 0 ) {
665
- gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import entries from the CSV file.", 'gwolle-gb') . '</p>', true, false);
666
- } else if ( $row == 1 || $row > 1 ) {
667
- do_action( 'gwolle_gb_save_entry_admin' );
668
- /* translators: %s is the number of entries */
669
- gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from the CSV file.','%s entries imported successfully from the CSV file.', $row, 'gwolle-gb'), $row ) . '</p>', false, false);
670
  }
671
 
672
- fclose($handle);
673
  }
 
 
 
 
 
 
 
 
 
 
 
 
674
  }
675
  } else {
676
  // Set that to be the returned message.
487
  $valid_file = false;
488
  gwolle_gb_add_message( '<p>' . esc_html__('Your file is too large.', 'gwolle-gb') . '</p>', true, false);
489
  } else {
490
+ if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
 
 
 
 
 
 
 
 
 
 
491
  gwolle_gb_add_message( '<p>' . esc_html__('You have a very old version of PHP. Please contact your hosting provider and request an upgrade.', 'gwolle-gb') . '</p>', false, false);
492
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
 
494
+ $handle = fopen($_FILES['start_import_gwolle_file']['tmp_name'], "r");
495
+ $row = 0;
496
+
497
+ while ( ( $data = fgetcsv( $handle, 2000, ',', '"' ) ) !== FALSE ) {
498
+ $num = count($data);
499
+ if ($row == 0) {
500
+ // Check the headerrow. $testrow_old is version 1.4.1 and older.
501
+ $testrow_1_0 = array(
502
+ 'id',
503
+ 'author_name',
504
+ 'author_email',
505
+ 'author_origin',
506
+ 'author_website',
507
+ 'author_ip',
508
+ 'author_host',
509
+ 'content',
510
+ 'date',
511
+ 'isspam',
512
+ 'ischecked',
513
+ 'istrash'
514
+ );
515
+ $testrow_1_4_1 = array(
516
+ 'id',
517
+ 'author_name',
518
+ 'author_email',
519
+ 'author_origin',
520
+ 'author_website',
521
+ 'author_ip',
522
+ 'author_host',
523
+ 'content',
524
+ 'datetime',
525
+ 'isspam',
526
+ 'ischecked',
527
+ 'istrash'
528
+ );
529
+ $testrow_1_4_8 = array(
530
+ 'id',
531
+ 'author_name',
532
+ 'author_email',
533
+ 'author_origin',
534
+ 'author_website',
535
+ 'author_ip',
536
+ 'author_host',
537
+ 'content',
538
+ 'datetime',
539
+ 'isspam',
540
+ 'ischecked',
541
+ 'istrash',
542
+ 'admin_reply'
543
+ );
544
+ $testrow_2_3_9 = array(
545
+ 'id',
546
+ 'author_name',
547
+ 'author_email',
548
+ 'author_origin',
549
+ 'author_website',
550
+ 'author_ip',
551
+ 'author_host',
552
+ 'content',
553
+ 'datetime',
554
+ 'isspam',
555
+ 'ischecked',
556
+ 'istrash',
557
+ 'admin_reply',
558
+ 'book_id'
559
+ );
560
+ $testrow_2_4_0 = array(
561
+ 'id',
562
+ 'author_name',
563
+ 'author_email',
564
+ 'author_origin',
565
+ 'author_website',
566
+ 'author_ip',
567
+ 'author_host',
568
+ 'content',
569
+ 'datetime',
570
+ 'isspam',
571
+ 'ischecked',
572
+ 'istrash',
573
+ 'admin_reply',
574
+ 'book_id',
575
+ 'meta_fields'
576
+ );
577
+ if ( $data != $testrow_1_0 && $data != $testrow_1_4_1 && $data != $testrow_1_4_8 && $data != $testrow_2_3_9 && $data != $testrow_2_4_0 ) {
578
+ gwolle_gb_add_message( '<p>' . esc_html__('It seems your CSV file is from an export that is not compatible with this version of Gwolle-GB.', 'gwolle-gb') . '</p>', true, false);
579
  break;
580
  }
581
+ $row++;
582
+ continue;
583
+ }
584
 
585
+ if ( $num != 12 && $num != 13 && $num != 14 && $num != 15 ) {
586
+ gwolle_gb_add_message( '<p>' . esc_html__('Your data seems to be corrupt. Import failed.', 'gwolle-gb') . '</p>', true, false);
587
+ break;
588
+ }
589
 
590
+ /* New Instance of gwolle_gb_entry. */
591
+ $entry = new gwolle_gb_entry();
 
 
592
 
593
+ /* Check if the date is a timestamp, else convert */
594
+ if ( ! is_numeric($data[8]) ) {
595
+ $data[8] = strtotime($data[8]);
596
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
 
598
+ /* Set the data in the instance */
599
+ // $entry->set_id( $data[0] ); // id of entry
600
+ $entry->set_author_name( $data[1] );
601
+ $entry->set_author_email( $data[2] );
602
+ $entry->set_author_origin( $data[3] );
603
+ $entry->set_author_website( $data[4] );
604
+ $entry->set_author_ip( $data[5] );
605
+ $entry->set_author_host( $data[6] );
606
+ $entry->set_content( $data[7] );
607
+ $entry->set_datetime( $data[8] );
608
+ $entry->set_isspam( $data[9] );
609
+ $entry->set_ischecked( $data[10] );
610
+ $entry->set_istrash( $data[11] );
611
+ if ( isset( $data[12] ) ) {
612
+ $entry->set_admin_reply( $data[12] ); // admin_reply is only since 1.4.8
613
+ }
614
+ if ( isset( $data[13] ) ) {
615
+ $entry->set_book_id( $data[13] ); // book_id is only since 2.3.9
616
+ }
617
+ $metas = ''; // reset
618
+ if ( isset( $data[14] ) ) {
619
+ $metas = $data[14]; // meta fields is only since is only since 2.4.0
620
+ }
621
+
622
+ /* Save the instance */
623
+ $save = $entry->save();
624
+ if ( $save ) {
625
+ // We have been saved to the Database
626
+ if ( isset( $metas ) && function_exists( 'gwolle_gb_addon_save_meta' ) ) {
627
+ $metas = maybe_unserialize( $metas );
628
+ if ( ! empty( $metas ) ) {
629
+ foreach ( $metas as $meta ) {
630
+ gwolle_gb_addon_save_meta( $entry->get_id(), $meta['meta_key'], $meta['meta_value'] );
631
  }
632
  }
 
 
 
 
 
 
633
  }
634
+ gwolle_gb_add_log_entry( $entry->get_id(), 'imported-from-gwolle' );
635
+ $row++;
636
+ } else {
637
+ //$gwolle_gb_messages .= '<p>' . print_r( $entry, true ) . '</p>'; // Debug
638
+ gwolle_gb_add_message( '<p>' . esc_html__('Your data seems to be corrupt. Saving failed and import failed.', 'gwolle-gb') . '</p>', true, false);
639
+ break;
 
 
 
 
640
  }
641
 
 
642
  }
643
+ $row--; // minus the header
644
+
645
+ if ( $row == 0 ) {
646
+ gwolle_gb_add_message( '<p>' . esc_html__("I'm sorry, but I wasn't able to import entries from the CSV file.", 'gwolle-gb') . '</p>', true, false);
647
+ } else if ( $row == 1 || $row > 1 ) {
648
+ do_action( 'gwolle_gb_save_entry_admin' );
649
+ /* translators: %s is the number of entries */
650
+ gwolle_gb_add_message( '<p>' . sprintf( _n('%s entry imported successfully from the CSV file.','%s entries imported successfully from the CSV file.', $row, 'gwolle-gb'), $row ) . '</p>', false, false);
651
+ }
652
+
653
+ fclose($handle);
654
+
655
  }
656
  } else {
657
  // Set that to be the returned message.
frontend/css/gwolle-gb-frontend.css CHANGED
@@ -183,8 +183,8 @@ body .gwolle-gb-content a {
183
  }
184
 
185
  /* Border-radius for whole thing. */
186
- #gwolle_gb .page-navigation a:first-child,
187
- #gwolle_gb .page-navigation span:first-child {
188
  border-radius: 3px 0 0 3px;
189
  }
190
  #gwolle_gb .page-navigation a:last-child,
183
  }
184
 
185
  /* Border-radius for whole thing. */
186
+ #gwolle_gb .page-navigation a:nth-child(2),
187
+ #gwolle_gb .page-navigation span:nth-child(2) {
188
  border-radius: 3px 0 0 3px;
189
  }
190
  #gwolle_gb .page-navigation a:last-child,
functions/gb-messages.php CHANGED
@@ -121,6 +121,7 @@ function gwolle_gb_get_errors() {
121
  $gwolle_gb_errors = apply_filters( 'gwolle_gb_errors', $gwolle_gb_errors );
122
 
123
  return $gwolle_gb_errors;
 
124
  }
125
 
126
 
@@ -162,6 +163,7 @@ function gwolle_gb_get_error_fields() {
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
 
121
  $gwolle_gb_errors = apply_filters( 'gwolle_gb_errors', $gwolle_gb_errors );
122
 
123
  return $gwolle_gb_errors;
124
+
125
  }
126
 
127
 
163
  $gwolle_gb_error_fields = apply_filters( 'gwolle_gb_error_fields', $gwolle_gb_error_fields );
164
 
165
  return $gwolle_gb_error_fields;
166
+
167
  }
168
 
169
 
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: 3.1.0
7
  Author: Marcel Pol
8
  Author URI: http://zenoweb.nl
9
  License: GPLv2 or later
@@ -32,7 +32,7 @@ Domain Path: /lang/
32
 
33
 
34
  // Plugin Version
35
- define('GWOLLE_GB_VER', '3.1.0');
36
 
37
 
38
  /*
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.1.1
7
  Author: Marcel Pol
8
  Author URI: http://zenoweb.nl
9
  License: GPLv2 or later
32
 
33
 
34
  // Plugin Version
35
+ define('GWOLLE_GB_VER', '3.1.1');
36
 
37
 
38
  /*
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Gwolle, mpol
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 3.7
5
  Tested up to: 5.1
6
- Stable tag: 3.1.0
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
@@ -212,6 +212,7 @@ With version 1.4.1 and older, the field datetime was called date.
212
  You could make a test-entry, export that, and look to see what the importer expects from the CSV.
213
  There is also an example CSV file included in the zipfile of the plugin under '/docs/import_example/'.
214
 
 
215
 
216
  == Frequently Asked Questions ==
217
 
@@ -383,7 +384,7 @@ For managing options you need the capability 'manage_options'.
383
  = Can I override a template? =
384
 
385
  You can look at 'frontend/gwolle_gb-entry.php', and copy it to your theme folder. Then it will be loaded by the plugin.
386
- Make sure you keep track of changes in the default templatefile though.
387
 
388
  = What hooks are available for customization? =
389
 
@@ -398,6 +399,11 @@ You are probably wanting to use the hooks for 'gwolle_gb_write' and 'gwolle_gb_b
398
 
399
  This question gets asked a lot. You can also take a look at the [support forum](https://wordpress.org/support/topic/change-button-text-20/). Also, the add-on has options for text changes.
400
 
 
 
 
 
 
401
  = Should I really not use WordPress comments for a guestbook? =
402
 
403
  Sure you can if you want to. In my personal opinion however it can be a good thing to keep comments and guestbook entries separated.
@@ -418,6 +424,11 @@ But if you don't use standard comments, you can just as easily use the comment s
418
 
419
  == Changelog ==
420
 
 
 
 
 
 
421
  = 3.1.0 =
422
  * 2019-02-19
423
  * Remove support for Really Simple Captcha plugin, since it is ineffective.
3
  Tags: guestbook, guest book, livre d'or, Gästebuch, review
4
  Requires at least: 3.7
5
  Tested up to: 5.1
6
+ Stable tag: 3.1.1
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
212
  You could make a test-entry, export that, and look to see what the importer expects from the CSV.
213
  There is also an example CSV file included in the zipfile of the plugin under '/docs/import_example/'.
214
 
215
+ If you want to prepare a CSV file from other software, plaese be aware that Microsoft Excel is terrible in dealing with CSV files. You will not manage to create a working CSV file with this. Please use LibreOffice Calc for this.
216
 
217
  == Frequently Asked Questions ==
218
 
384
  = Can I override a template? =
385
 
386
  You can look at 'frontend/gwolle_gb-entry.php', and copy it to your theme folder. Then it will be loaded by the plugin.
387
+ Make sure you keep track of changes in the default templatefile though. It is often better to use filters, that way you are more forward-compatible.
388
 
389
  = What hooks are available for customization? =
390
 
399
 
400
  This question gets asked a lot. You can also take a look at the [support forum](https://wordpress.org/support/topic/change-button-text-20/). Also, the add-on has options for text changes.
401
 
402
+ = I have a one-page design and want to use links with the right anchor. =
403
+
404
+ It should be possible by using a filter.
405
+ Have a look at this [example code](https://plugins.trac.wordpress.org/browser/gwolle-gb/trunk/docs/filters/gwolle_gb_get_permalink.txt). Make sure to use the correct anchor tag for your website.
406
+
407
  = Should I really not use WordPress comments for a guestbook? =
408
 
409
  Sure you can if you want to. In my personal opinion however it can be a good thing to keep comments and guestbook entries separated.
424
 
425
  == Changelog ==
426
 
427
+ = 3.1.1 =
428
+ * 2019-03-08
429
+ * Drop check for mime-type on import, too many problems.
430
+ * Small CSS fix for pagination.
431
+
432
  = 3.1.0 =
433
  * 2019-02-19
434
  * Remove support for Really Simple Captcha plugin, since it is ineffective.