Version Description
- 2018-04-13
- Improve custom quiz question.
- Improve and extend Honeypot anti-spam.
- Add Link Checker for anti-spam.
- Add timeout for submitting the form for anti-spam.
- Do not send IP Address to Akismet if disabled.
- Add 'date_query' parameter to 'gwolle_gb_get_entries' function.
- Set default settings upon install/upgrade, so we can cache them.
- Add action 'gwolle_gb_uninstall'.
- Switch multisite uninstall to 'admin_init' hook.
- Flush transients from cache if no book_id is set.
- Switch export to 3000 entries per part instead of 5000.
- New file '/functions/gb-book_id.php'.
- Improve comment blocks for functions.
Download this release
Release Info
Developer | mpol |
Plugin | Gwolle Guestbook |
Version | 2.5.0 |
Comparing to | |
See all releases |
Code changes from version 2.4.2 to 2.5.0
- add-on/gb-add-on.php +20 -0
- admin/gb-dashboard-widget.php +3 -1
- admin/gb-page-add-on.php +22 -2
- admin/gb-page-editor.php +28 -0
- admin/gb-page-entries.php +3 -0
- admin/gb-page-export.php +9 -9
- admin/gb-page-gwolle-gb.php +28 -3
- admin/gb-page-import.php +16 -4
- admin/gb-page-settings.php +19 -0
- admin/gb-pagination.php +5 -5
- admin/gb-upgrade.php +145 -4
- admin/js/gwolle-gb-admin.js +2 -2
- admin/tabs/gb-admintab.php +3 -0
- admin/tabs/gb-antispamtab.php +43 -2
- admin/tabs/gb-debugtab.php +4 -1
- admin/tabs/gb-emailtab.php +3 -0
- admin/tabs/gb-formtab.php +5 -1
- admin/tabs/gb-readingtab.php +3 -0
- admin/tabs/gb-uninstalltab.php +4 -2
- docs/actions/gwolle_gb_uninstall.txt +23 -0
- frontend/gb-ajax-captcha.php +7 -8
- frontend/gb-form-ajax.php +5 -6
- frontend/gb-form-posthandling.php +85 -11
- frontend/gb-form.php +35 -8
- frontend/gb-pagination.php +3 -3
- frontend/gb-read.php +6 -3
- frontend/gb-rss.php +9 -3
- frontend/gb-shortcode-widget.php +12 -4
- frontend/gb-shortcodes.php +15 -8
- frontend/gb-total.php +2 -2
- frontend/gwolle_gb-entry.php +8 -8
- frontend/js/gwolle-gb-frontend.js +35 -0
- functions/gb-akismet.php +19 -17
- functions/gb-bbcode_emoji.php +12 -4
- functions/gb-book_id.php +139 -0
- functions/gb-cache.php +15 -1
- functions/gb-debug.php +3 -0
- functions/gb-formatting.php +13 -7
- functions/gb-get_entries.php +29 -16
- functions/gb-get_entry_count.php +2 -5
- functions/gb-log.php +13 -15
- functions/gb-mail.php +6 -3
- functions/gb-messages.php +25 -17
- functions/gb-metabox.php +8 -0
- functions/gb-misc.php +4 -136
- functions/gb-post-meta.php +7 -5
- functions/gb-settings.php +5 -2
- functions/gb-single-view.php +3 -4
- functions/gb-stop-forum-spam.php +2 -4
- functions/gb-user.php +15 -18
- gwolle-gb-hooks.php +11 -4
- gwolle-gb.php +8 -4
- readme.txt +19 -2
add-on/gb-add-on.php
CHANGED
@@ -117,6 +117,26 @@ function gwolle_gb_addon_translation_strings() {
|
|
117 |
esc_html_e('Show delete link in Metabox for author.', 'gwolle-gb');
|
118 |
/* translators: Commercial Add-On */
|
119 |
esc_html_e('A link to delete the entry will be added to the metabox. Only visible for moderators and the author.', 'gwolle-gb');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
// function gwolle_gb_addon_page_settingstab_reading() {
|
122 |
/* translators: Commercial Add-On */
|
117 |
esc_html_e('Show delete link in Metabox for author.', 'gwolle-gb');
|
118 |
/* translators: Commercial Add-On */
|
119 |
esc_html_e('A link to delete the entry will be added to the metabox. Only visible for moderators and the author.', 'gwolle-gb');
|
120 |
+
/* translators: Commercial Add-On */
|
121 |
+
esc_html_e('Auto Delete', 'gwolle-gb');
|
122 |
+
/* translators: Commercial Add-On */
|
123 |
+
esc_html_e('Auto Delete entries after a certain time.', 'gwolle-gb');
|
124 |
+
/* translators: Commercial Add-On */
|
125 |
+
esc_html_e('This setting will enable automatic deletion of entries older than a certain date.', 'gwolle-gb');
|
126 |
+
/* translators: Commercial Add-On */
|
127 |
+
esc_html_e('Be very carefull with this option.', 'gwolle-gb');
|
128 |
+
/* translators: Commercial Add-On */
|
129 |
+
esc_html_e('Auto Delete entries older than:', 'gwolle-gb');
|
130 |
+
/* translators: Commercial Add-On */
|
131 |
+
esc_html_e('1 Day','gwolle-gb');
|
132 |
+
/* translators: Commercial Add-On */
|
133 |
+
esc_html_e('2 Days','gwolle-gb');
|
134 |
+
/* translators: Commercial Add-On */
|
135 |
+
esc_html_e('1 Week','gwolle-gb');
|
136 |
+
/* translators: Commercial Add-On */
|
137 |
+
esc_html_e('2 Weeks','gwolle-gb');
|
138 |
+
/* translators: Commercial Add-On */
|
139 |
+
esc_html_e('1 Month','gwolle-gb');
|
140 |
|
141 |
// function gwolle_gb_addon_page_settingstab_reading() {
|
142 |
/* translators: Commercial Add-On */
|
admin/gb-dashboard-widget.php
CHANGED
@@ -157,7 +157,9 @@ function gwolle_gb_dashboard() {
|
|
157 |
}
|
158 |
|
159 |
|
160 |
-
|
|
|
|
|
161 |
function gwolle_gb_dashboard_setup() {
|
162 |
|
163 |
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
157 |
}
|
158 |
|
159 |
|
160 |
+
/*
|
161 |
+
* The hook to add a dashboard widget to show the latest entries.
|
162 |
+
*/
|
163 |
function gwolle_gb_dashboard_setup() {
|
164 |
|
165 |
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
admin/gb-page-add-on.php
CHANGED
@@ -6,6 +6,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
6 |
}
|
7 |
|
8 |
|
|
|
|
|
|
|
9 |
function gwolle_gb_addon_menu_advertisement() {
|
10 |
|
11 |
$active = is_plugin_active( 'gwolle-gb-addon/gwolle-gb-addon.php' ); // true or false
|
@@ -16,7 +19,9 @@ function gwolle_gb_addon_menu_advertisement() {
|
|
16 |
add_action( 'admin_menu', 'gwolle_gb_addon_menu_advertisement', 11 );
|
17 |
|
18 |
|
19 |
-
/*
|
|
|
|
|
20 |
function gwolle_gb_addon_page_advertisement() {
|
21 |
|
22 |
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
@@ -52,6 +57,9 @@ function gwolle_gb_addon_page_advertisement() {
|
|
52 |
}
|
53 |
|
54 |
|
|
|
|
|
|
|
55 |
function gwolle_gb_addon_description(){
|
56 |
?>
|
57 |
<div class="table table_content gwolle_gb">
|
@@ -62,6 +70,9 @@ function gwolle_gb_addon_description(){
|
|
62 |
}
|
63 |
|
64 |
|
|
|
|
|
|
|
65 |
function gwolle_gb_addon_features() {
|
66 |
echo '<h3>
|
67 |
' . esc_html__('Current features include:', 'gwolle-gb').'</h3>
|
@@ -78,11 +89,14 @@ function gwolle_gb_addon_features() {
|
|
78 |
<li>' . esc_html__('Permalink button in each entry for easy access (optional).','gwolle-gb').'</li>
|
79 |
<li>' . esc_html__('Email button to contact each author (optional).','gwolle-gb').'</li>
|
80 |
<li>' . esc_html__('Sitemap support for popular SEO/Sitemap plugins.','gwolle-gb').'</li>
|
|
|
81 |
</ul>';
|
82 |
}
|
83 |
|
84 |
|
85 |
-
/*
|
|
|
|
|
86 |
function gwolle_gb_addon_buy() {
|
87 |
?>
|
88 |
<h3><?php esc_html_e('Buy the Add-On.', 'gwolle-gb'); ?></h3>
|
@@ -96,6 +110,9 @@ function gwolle_gb_addon_buy() {
|
|
96 |
}
|
97 |
|
98 |
|
|
|
|
|
|
|
99 |
function gwolle_gb_addon_demo() {
|
100 |
?>
|
101 |
<h3><?php esc_html_e('Demo with the Add-On.', 'gwolle-gb'); ?></h3>
|
@@ -115,6 +132,9 @@ function gwolle_gb_addon_demo() {
|
|
115 |
}
|
116 |
|
117 |
|
|
|
|
|
|
|
118 |
function gwolle_gb_addon_development() {
|
119 |
?>
|
120 |
<p><?php
|
6 |
}
|
7 |
|
8 |
|
9 |
+
/*
|
10 |
+
* Admin page for advertising the Add-On.
|
11 |
+
*/
|
12 |
function gwolle_gb_addon_menu_advertisement() {
|
13 |
|
14 |
$active = is_plugin_active( 'gwolle-gb-addon/gwolle-gb-addon.php' ); // true or false
|
19 |
add_action( 'admin_menu', 'gwolle_gb_addon_menu_advertisement', 11 );
|
20 |
|
21 |
|
22 |
+
/*
|
23 |
+
* Admin page for advertising the Add-On. Contains metaboxes.
|
24 |
+
*/
|
25 |
function gwolle_gb_addon_page_advertisement() {
|
26 |
|
27 |
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
57 |
}
|
58 |
|
59 |
|
60 |
+
/*
|
61 |
+
* Metabox with the main description of the add-on.
|
62 |
+
*/
|
63 |
function gwolle_gb_addon_description(){
|
64 |
?>
|
65 |
<div class="table table_content gwolle_gb">
|
70 |
}
|
71 |
|
72 |
|
73 |
+
/*
|
74 |
+
* Metabox with the feature list of the add-on.
|
75 |
+
*/
|
76 |
function gwolle_gb_addon_features() {
|
77 |
echo '<h3>
|
78 |
' . esc_html__('Current features include:', 'gwolle-gb').'</h3>
|
89 |
<li>' . esc_html__('Permalink button in each entry for easy access (optional).','gwolle-gb').'</li>
|
90 |
<li>' . esc_html__('Email button to contact each author (optional).','gwolle-gb').'</li>
|
91 |
<li>' . esc_html__('Sitemap support for popular SEO/Sitemap plugins.','gwolle-gb').'</li>
|
92 |
+
<li>' . esc_html__('Auto Delete timer (optional).','gwolle-gb').'</li>
|
93 |
</ul>';
|
94 |
}
|
95 |
|
96 |
|
97 |
+
/*
|
98 |
+
* Metabox with the link to the marketplace for the add-on.
|
99 |
+
*/
|
100 |
function gwolle_gb_addon_buy() {
|
101 |
?>
|
102 |
<h3><?php esc_html_e('Buy the Add-On.', 'gwolle-gb'); ?></h3>
|
110 |
}
|
111 |
|
112 |
|
113 |
+
/*
|
114 |
+
* Metabox with links to the demo site.
|
115 |
+
*/
|
116 |
function gwolle_gb_addon_demo() {
|
117 |
?>
|
118 |
<h3><?php esc_html_e('Demo with the Add-On.', 'gwolle-gb'); ?></h3>
|
132 |
}
|
133 |
|
134 |
|
135 |
+
/*
|
136 |
+
* Metabox with the motivational text of the add-on.
|
137 |
+
*/
|
138 |
function gwolle_gb_addon_development() {
|
139 |
?>
|
140 |
<p><?php
|
admin/gb-page-editor.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_editor() {
|
13 |
global $entry;
|
14 |
|
@@ -383,6 +386,9 @@ function gwolle_gb_page_editor() {
|
|
383 |
}
|
384 |
|
385 |
|
|
|
|
|
|
|
386 |
function gwolle_gb_editor_postbox_content( $entry ) {
|
387 |
?>
|
388 |
<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>
|
@@ -425,6 +431,9 @@ function gwolle_gb_editor_postbox_content( $entry ) {
|
|
425 |
}
|
426 |
|
427 |
|
|
|
|
|
|
|
428 |
function gwolle_gb_editor_postbox_website( $entry ) {
|
429 |
?>
|
430 |
<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'); ?>" />
|
@@ -436,6 +445,9 @@ function gwolle_gb_editor_postbox_website( $entry ) {
|
|
436 |
}
|
437 |
|
438 |
|
|
|
|
|
|
|
439 |
function gwolle_gb_editor_postbox_author_origin( $entry ) {
|
440 |
?>
|
441 |
<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" />
|
@@ -443,6 +455,9 @@ function gwolle_gb_editor_postbox_author_origin( $entry ) {
|
|
443 |
}
|
444 |
|
445 |
|
|
|
|
|
|
|
446 |
function gwolle_gb_editor_postbox_admin_reply( $entry ) {
|
447 |
$form_setting = gwolle_gb_get_setting( 'form' );
|
448 |
?>
|
@@ -487,6 +502,9 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
|
|
487 |
}
|
488 |
|
489 |
|
|
|
|
|
|
|
490 |
function gwolle_gb_editor_postbox_icons( $entry ) {
|
491 |
global $class;
|
492 |
|
@@ -616,6 +634,9 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
|
|
616 |
}
|
617 |
|
618 |
|
|
|
|
|
|
|
619 |
function gwolle_gb_editor_postbox_actions( $entry ) {
|
620 |
global $class;
|
621 |
if ( $entry->get_id() > 0 ) {
|
@@ -648,6 +669,9 @@ function gwolle_gb_editor_postbox_actions( $entry ) {
|
|
648 |
}
|
649 |
|
650 |
|
|
|
|
|
|
|
651 |
function gwolle_gb_editor_postbox_details( $entry ) {
|
652 |
?>
|
653 |
<p>
|
@@ -713,6 +737,10 @@ function gwolle_gb_editor_postbox_details( $entry ) {
|
|
713 |
<?php
|
714 |
}
|
715 |
|
|
|
|
|
|
|
|
|
716 |
function gwolle_gb_editor_postbox_logs( $entry ) {
|
717 |
?>
|
718 |
<ul>
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Admin page with the entry editor. Used for new and existing entries.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_editor() {
|
16 |
global $entry;
|
17 |
|
386 |
}
|
387 |
|
388 |
|
389 |
+
/*
|
390 |
+
* Metabox with the content of the entry.
|
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>
|
431 |
}
|
432 |
|
433 |
|
434 |
+
/*
|
435 |
+
* Metabox with the website of the entry.
|
436 |
+
*/
|
437 |
function gwolle_gb_editor_postbox_website( $entry ) {
|
438 |
?>
|
439 |
<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'); ?>" />
|
445 |
}
|
446 |
|
447 |
|
448 |
+
/*
|
449 |
+
* Metabox with the city/origin of the entry.
|
450 |
+
*/
|
451 |
function gwolle_gb_editor_postbox_author_origin( $entry ) {
|
452 |
?>
|
453 |
<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 |
}
|
456 |
|
457 |
|
458 |
+
/*
|
459 |
+
* Metabox with the admin reply of the entry.
|
460 |
+
*/
|
461 |
function gwolle_gb_editor_postbox_admin_reply( $entry ) {
|
462 |
$form_setting = gwolle_gb_get_setting( 'form' );
|
463 |
?>
|
502 |
}
|
503 |
|
504 |
|
505 |
+
/*
|
506 |
+
* Metabox with the icons and checkboxes for quick glancing at the visibility of the entry.
|
507 |
+
*/
|
508 |
function gwolle_gb_editor_postbox_icons( $entry ) {
|
509 |
global $class;
|
510 |
|
634 |
}
|
635 |
|
636 |
|
637 |
+
/*
|
638 |
+
* Metabox with quick actions for the entry (AJAX).
|
639 |
+
*/
|
640 |
function gwolle_gb_editor_postbox_actions( $entry ) {
|
641 |
global $class;
|
642 |
if ( $entry->get_id() > 0 ) {
|
669 |
}
|
670 |
|
671 |
|
672 |
+
/*
|
673 |
+
* Metabox with the small details of the entry.
|
674 |
+
*/
|
675 |
function gwolle_gb_editor_postbox_details( $entry ) {
|
676 |
?>
|
677 |
<p>
|
737 |
<?php
|
738 |
}
|
739 |
|
740 |
+
|
741 |
+
/*
|
742 |
+
* Metabox with the log of the entry.
|
743 |
+
*/
|
744 |
function gwolle_gb_editor_postbox_logs( $entry ) {
|
745 |
?>
|
746 |
<ul>
|
admin/gb-page-entries.php
CHANGED
@@ -10,6 +10,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
10 |
}
|
11 |
|
12 |
|
|
|
|
|
|
|
13 |
function gwolle_gb_page_entries() {
|
14 |
|
15 |
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) {
|
10 |
}
|
11 |
|
12 |
|
13 |
+
/*
|
14 |
+
* Admin page with lists of entries.
|
15 |
+
*/
|
16 |
function gwolle_gb_page_entries() {
|
17 |
|
18 |
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) {
|
admin/gb-page-export.php
CHANGED
@@ -11,6 +11,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
11 |
}
|
12 |
|
13 |
|
|
|
|
|
|
|
14 |
function gwolle_gb_page_export() {
|
15 |
|
16 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
@@ -45,7 +48,7 @@ function gwolle_gb_page_export() {
|
|
45 |
function gwolle_gb_export_postbox() {
|
46 |
|
47 |
$count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
|
48 |
-
$num_entries =
|
49 |
$parts = ceil( $count / $num_entries );
|
50 |
?>
|
51 |
|
@@ -59,9 +62,6 @@ function gwolle_gb_export_postbox() {
|
|
59 |
$nonce = wp_create_nonce( 'gwolle_gb_page_export' );
|
60 |
echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
|
61 |
|
62 |
-
$count = gwolle_gb_get_entry_count( array( 'all' => 'all' ) );
|
63 |
-
$num_entries = 5000;
|
64 |
-
$parts = ceil( $count / $num_entries );
|
65 |
if ( $count == 0 ) { ?>
|
66 |
<p><?php esc_html_e('No entries were found.', 'gwolle-gb'); ?></p><?php
|
67 |
} else {
|
@@ -119,7 +119,7 @@ add_action('admin_init', 'gwolle_gb_export_action');
|
|
119 |
|
120 |
|
121 |
/*
|
122 |
-
* Callback function for request generated from the Export page
|
123 |
*/
|
124 |
function gwolle_gb_export_callback() {
|
125 |
|
@@ -140,7 +140,7 @@ function gwolle_gb_export_callback() {
|
|
140 |
}
|
141 |
|
142 |
$count = gwolle_gb_get_entry_count(array( 'all' => 'all' ));
|
143 |
-
$num_entries =
|
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 *
|
152 |
|
153 |
$entries = gwolle_gb_get_entries(array(
|
154 |
'num_entries' => $num_entries,
|
@@ -230,7 +230,7 @@ function gwolle_gb_export_callback() {
|
|
230 |
|
231 |
|
232 |
/*
|
233 |
-
* Export entries for user
|
234 |
*
|
235 |
* @since 2.3.11
|
236 |
*/
|
@@ -284,7 +284,7 @@ add_action('admin_init', 'gwolle_gb_export_user_action');
|
|
284 |
|
285 |
|
286 |
/*
|
287 |
-
* Callback function for request generated from the Export page
|
288 |
*/
|
289 |
function gwolle_gb_export_user_callback() {
|
290 |
|
11 |
}
|
12 |
|
13 |
|
14 |
+
/*
|
15 |
+
* Admin page for export.
|
16 |
+
*/
|
17 |
function gwolle_gb_page_export() {
|
18 |
|
19 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
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 |
|
62 |
$nonce = wp_create_nonce( 'gwolle_gb_page_export' );
|
63 |
echo '<input type="hidden" id="gwolle_gb_wpnonce" name="gwolle_gb_wpnonce" value="' . $nonce . '" />';
|
64 |
|
|
|
|
|
|
|
65 |
if ( $count == 0 ) { ?>
|
66 |
<p><?php esc_html_e('No entries were found.', 'gwolle-gb'); ?></p><?php
|
67 |
} else {
|
119 |
|
120 |
|
121 |
/*
|
122 |
+
* Callback function for request generated from the Export page.
|
123 |
*/
|
124 |
function gwolle_gb_export_callback() {
|
125 |
|
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 |
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,
|
230 |
|
231 |
|
232 |
/*
|
233 |
+
* Export entries for user.
|
234 |
*
|
235 |
* @since 2.3.11
|
236 |
*/
|
284 |
|
285 |
|
286 |
/*
|
287 |
+
* Callback function for request generated from the Export page.
|
288 |
*/
|
289 |
function gwolle_gb_export_user_callback() {
|
290 |
|
admin/gb-page-gwolle-gb.php
CHANGED
@@ -9,7 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
12 |
-
/*
|
|
|
|
|
13 |
function gwolle_gb_welcome() {
|
14 |
|
15 |
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
@@ -67,7 +69,9 @@ function gwolle_gb_welcome() {
|
|
67 |
}
|
68 |
|
69 |
|
70 |
-
|
|
|
|
|
71 |
function gwolle_gb_overview(){
|
72 |
|
73 |
// Calculate the number of entries
|
@@ -187,6 +191,9 @@ function gwolle_gb_overview(){
|
|
187 |
<?php }
|
188 |
|
189 |
|
|
|
|
|
|
|
190 |
function gwolle_gb_overview_notification() {
|
191 |
|
192 |
// Check if function mail() exists. If not, display a hint to the user.
|
@@ -255,6 +262,9 @@ function gwolle_gb_overview_notification() {
|
|
255 |
}
|
256 |
|
257 |
|
|
|
|
|
|
|
258 |
function gwolle_gb_overview_thanks() {
|
259 |
echo '<h3>
|
260 |
' . esc_html__('This plugin uses the following scripts and services:', 'gwolle-gb') . '</h3>
|
@@ -268,7 +278,9 @@ function gwolle_gb_overview_thanks() {
|
|
268 |
}
|
269 |
|
270 |
|
271 |
-
/*
|
|
|
|
|
272 |
function gwolle_gb_overview_help() {
|
273 |
echo '<h3>
|
274 |
' . esc_html__('This is how you can get your guestbook displayed on your website:', 'gwolle-gb') . '</h3>
|
@@ -280,6 +292,9 @@ function gwolle_gb_overview_help() {
|
|
280 |
}
|
281 |
|
282 |
|
|
|
|
|
|
|
283 |
function gwolle_gb_overview_visibility() {
|
284 |
echo '<h3>
|
285 |
' . esc_html__('These entries will be visible for your visitors:', 'gwolle-gb').'</h3>
|
@@ -291,6 +306,9 @@ function gwolle_gb_overview_visibility() {
|
|
291 |
}
|
292 |
|
293 |
|
|
|
|
|
|
|
294 |
function gwolle_gb_overview_support() {
|
295 |
?>
|
296 |
<h3><?php esc_html_e('Support.', 'gwolle-gb'); ?></h3>
|
@@ -316,6 +334,10 @@ function gwolle_gb_overview_support() {
|
|
316 |
}
|
317 |
|
318 |
|
|
|
|
|
|
|
|
|
319 |
function gwolle_gb_overview_donate() {
|
320 |
?>
|
321 |
<h3><?php esc_html_e('Review this plugin.', 'gwolle-gb'); ?></h3>
|
@@ -328,6 +350,9 @@ function gwolle_gb_overview_donate() {
|
|
328 |
}
|
329 |
|
330 |
|
|
|
|
|
|
|
331 |
function gwolle_gb_welcome_post() {
|
332 |
|
333 |
/* Check Nonce */
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Main Admin page.
|
14 |
+
*/
|
15 |
function gwolle_gb_welcome() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
69 |
}
|
70 |
|
71 |
|
72 |
+
/*
|
73 |
+
* Metabox with overview.
|
74 |
+
*/
|
75 |
function gwolle_gb_overview(){
|
76 |
|
77 |
// Calculate the number of entries
|
191 |
<?php }
|
192 |
|
193 |
|
194 |
+
/*
|
195 |
+
* Metabox with checbox for subscribing this user to email notifications.
|
196 |
+
*/
|
197 |
function gwolle_gb_overview_notification() {
|
198 |
|
199 |
// Check if function mail() exists. If not, display a hint to the user.
|
262 |
}
|
263 |
|
264 |
|
265 |
+
/*
|
266 |
+
* Metabox with overview of third parties.
|
267 |
+
*/
|
268 |
function gwolle_gb_overview_thanks() {
|
269 |
echo '<h3>
|
270 |
' . esc_html__('This plugin uses the following scripts and services:', 'gwolle-gb') . '</h3>
|
278 |
}
|
279 |
|
280 |
|
281 |
+
/*
|
282 |
+
* Metabox with quick help text.
|
283 |
+
*/
|
284 |
function gwolle_gb_overview_help() {
|
285 |
echo '<h3>
|
286 |
' . esc_html__('This is how you can get your guestbook displayed on your website:', 'gwolle-gb') . '</h3>
|
292 |
}
|
293 |
|
294 |
|
295 |
+
/*
|
296 |
+
* Metabox with quick help text.
|
297 |
+
*/
|
298 |
function gwolle_gb_overview_visibility() {
|
299 |
echo '<h3>
|
300 |
' . esc_html__('These entries will be visible for your visitors:', 'gwolle-gb').'</h3>
|
306 |
}
|
307 |
|
308 |
|
309 |
+
/*
|
310 |
+
* Metabox with text about support and translations.
|
311 |
+
*/
|
312 |
function gwolle_gb_overview_support() {
|
313 |
?>
|
314 |
<h3><?php esc_html_e('Support.', 'gwolle-gb'); ?></h3>
|
334 |
}
|
335 |
|
336 |
|
337 |
+
/*
|
338 |
+
* Metabox with text about wp.org reviews.
|
339 |
+
* Call for donations is gone.
|
340 |
+
*/
|
341 |
function gwolle_gb_overview_donate() {
|
342 |
?>
|
343 |
<h3><?php esc_html_e('Review this plugin.', 'gwolle-gb'); ?></h3>
|
350 |
}
|
351 |
|
352 |
|
353 |
+
/*
|
354 |
+
* Subscribe this user to email notifications.
|
355 |
+
*/
|
356 |
function gwolle_gb_welcome_post() {
|
357 |
|
358 |
/* Check Nonce */
|
admin/gb-page-import.php
CHANGED
@@ -14,6 +14,10 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
14 |
}
|
15 |
|
16 |
|
|
|
|
|
|
|
|
|
17 |
function gwolle_gb_page_import() {
|
18 |
|
19 |
gwolle_gb_admin_enqueue();
|
@@ -27,10 +31,6 @@ function gwolle_gb_page_import() {
|
|
27 |
gwolle_gb_page_import_post();
|
28 |
}
|
29 |
|
30 |
-
|
31 |
-
/*
|
32 |
-
* Build the Page and the Form
|
33 |
-
*/
|
34 |
?>
|
35 |
<div class="wrap gwolle_gb">
|
36 |
<div id="icon-gwolle-gb"><br /></div>
|
@@ -67,6 +67,9 @@ function gwolle_gb_page_import() {
|
|
67 |
}
|
68 |
|
69 |
|
|
|
|
|
|
|
70 |
function gwolle_gb_import_postbox_dms() {
|
71 |
global $wpdb;
|
72 |
?>
|
@@ -137,6 +140,9 @@ function gwolle_gb_import_postbox_dms() {
|
|
137 |
}
|
138 |
|
139 |
|
|
|
|
|
|
|
140 |
function gwolle_gb_import_postbox_wp() {
|
141 |
?>
|
142 |
<form name="gwolle_gb_import_wp" id="gwolle_gb_import_wp" method="POST" action="#" accept-charset="UTF-8">
|
@@ -263,6 +269,9 @@ function gwolle_gb_import_postbox_wp() {
|
|
263 |
}
|
264 |
|
265 |
|
|
|
|
|
|
|
266 |
function gwolle_gb_import_postbox_gwolle() {
|
267 |
?>
|
268 |
<form name="gwolle_gb_import_gwolle" id="gwolle_gb_import_gwolle" method="POST" action="#" accept-charset="UTF-8" enctype="multipart/form-data">
|
@@ -287,6 +296,9 @@ function gwolle_gb_import_postbox_gwolle() {
|
|
287 |
}
|
288 |
|
289 |
|
|
|
|
|
|
|
290 |
function gwolle_gb_page_import_post() {
|
291 |
global $wpdb;
|
292 |
|
14 |
}
|
15 |
|
16 |
|
17 |
+
/*
|
18 |
+
* Admin page for import.
|
19 |
+
* Contains metaboxes with forms.
|
20 |
+
*/
|
21 |
function gwolle_gb_page_import() {
|
22 |
|
23 |
gwolle_gb_admin_enqueue();
|
31 |
gwolle_gb_page_import_post();
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
34 |
?>
|
35 |
<div class="wrap gwolle_gb">
|
36 |
<div id="icon-gwolle-gb"><br /></div>
|
67 |
}
|
68 |
|
69 |
|
70 |
+
/*
|
71 |
+
* Metabox with form for import from DMS Guestbook.
|
72 |
+
*/
|
73 |
function gwolle_gb_import_postbox_dms() {
|
74 |
global $wpdb;
|
75 |
?>
|
140 |
}
|
141 |
|
142 |
|
143 |
+
/*
|
144 |
+
* Metabox with form for import from WordPress comments.
|
145 |
+
*/
|
146 |
function gwolle_gb_import_postbox_wp() {
|
147 |
?>
|
148 |
<form name="gwolle_gb_import_wp" id="gwolle_gb_import_wp" method="POST" action="#" accept-charset="UTF-8">
|
269 |
}
|
270 |
|
271 |
|
272 |
+
/*
|
273 |
+
* Metabox with form for import from Gwolle through a CSV file.
|
274 |
+
*/
|
275 |
function gwolle_gb_import_postbox_gwolle() {
|
276 |
?>
|
277 |
<form name="gwolle_gb_import_gwolle" id="gwolle_gb_import_gwolle" method="POST" action="#" accept-charset="UTF-8" enctype="multipart/form-data">
|
296 |
}
|
297 |
|
298 |
|
299 |
+
/*
|
300 |
+
* Handle the submitted forms.
|
301 |
+
*/
|
302 |
function gwolle_gb_page_import_post() {
|
303 |
global $wpdb;
|
304 |
|
admin/gb-page-settings.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_settings() {
|
13 |
|
14 |
if ( function_exists('current_user_can') && !current_user_can('manage_options') ) {
|
@@ -292,6 +295,22 @@ function gwolle_gb_page_settings() {
|
|
292 |
$saved = true;
|
293 |
}
|
294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
if (isset($_POST['akismet-active']) && $_POST['akismet-active'] == 'on') {
|
296 |
update_option('gwolle_gb-akismet-active', 'true');
|
297 |
$saved = true;
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Admin Settings page. Uses the files under /tabs for filling the tabs. This file mostly does saving of the settings.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_settings() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && !current_user_can('manage_options') ) {
|
295 |
$saved = true;
|
296 |
}
|
297 |
|
298 |
+
if (isset($_POST['gwolle_gb_linkchecker']) && $_POST['gwolle_gb_linkchecker'] == 'on') {
|
299 |
+
update_option('gwolle_gb-linkchecker', 'true');
|
300 |
+
$saved = true;
|
301 |
+
} else {
|
302 |
+
update_option('gwolle_gb-linkchecker', 'false');
|
303 |
+
$saved = true;
|
304 |
+
}
|
305 |
+
|
306 |
+
if (isset($_POST['gwolle_gb_timeout']) && $_POST['gwolle_gb_timeout'] == 'on') {
|
307 |
+
update_option('gwolle_gb-timeout', 'true');
|
308 |
+
$saved = true;
|
309 |
+
} else {
|
310 |
+
update_option('gwolle_gb-timeout', 'false');
|
311 |
+
$saved = true;
|
312 |
+
}
|
313 |
+
|
314 |
if (isset($_POST['akismet-active']) && $_POST['akismet-active'] == 'on') {
|
315 |
update_option('gwolle_gb-akismet-active', 'true');
|
316 |
$saved = true;
|
admin/gb-pagination.php
CHANGED
@@ -10,11 +10,11 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
10 |
* gwolle_gb_pagination_admin
|
11 |
* Pagination of the entries for the page-entries.php
|
12 |
*
|
13 |
-
* @
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
*/
|
19 |
function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
|
20 |
|
10 |
* gwolle_gb_pagination_admin
|
11 |
* Pagination of the entries for the page-entries.php
|
12 |
*
|
13 |
+
* @param int $pageNum the number of the requested page.
|
14 |
+
* @param int $pages_total the total number of pages.
|
15 |
+
* @param int $count total number of entries. Relative to the $show variable.
|
16 |
+
* @param string $show the tab of the page that is shown.
|
17 |
+
* @return string $pagination the html of the pagination.
|
18 |
*/
|
19 |
function gwolle_gb_pagination_admin( $pageNum, $pages_total, $count, $show ) {
|
20 |
|
admin/gb-upgrade.php
CHANGED
@@ -14,6 +14,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
14 |
}
|
15 |
|
16 |
|
|
|
|
|
|
|
17 |
function gwolle_gb_install() {
|
18 |
global $wpdb;
|
19 |
|
@@ -76,19 +79,26 @@ function gwolle_gb_install() {
|
|
76 |
}
|
77 |
}
|
78 |
|
79 |
-
|
|
|
|
|
|
|
80 |
$result_after = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_entries'");
|
81 |
$result_after2 = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_log'");
|
82 |
if ( $result_after != 0 && $result_after2 != 0 ) {
|
83 |
add_option('gwolle_gb_version', GWOLLE_GB_VER);
|
84 |
}
|
85 |
|
86 |
-
|
87 |
global $wp_rewrite;
|
88 |
$wp_rewrite->flush_rules( false );
|
89 |
}
|
90 |
|
91 |
|
|
|
|
|
|
|
|
|
92 |
function gwolle_gb_uninstall() {
|
93 |
// Delete the plugin's tables
|
94 |
global $wpdb;
|
@@ -103,11 +113,16 @@ function gwolle_gb_uninstall() {
|
|
103 |
option_name LIKE 'gwolle_gb%'
|
104 |
");
|
105 |
|
|
|
|
|
106 |
// Deactivate ourselves
|
107 |
deactivate_plugins( GWOLLE_GB_FOLDER . '/gwolle-gb.php' );
|
108 |
}
|
109 |
|
110 |
|
|
|
|
|
|
|
111 |
function gwolle_gb_upgrade() {
|
112 |
global $wpdb;
|
113 |
$installed_ver = get_option('gwolle_gb_version');
|
@@ -480,7 +495,6 @@ function gwolle_gb_upgrade() {
|
|
480 |
");
|
481 |
}
|
482 |
|
483 |
-
|
484 |
/* Upgrade to new shiny db collation. Since WP 4.2 */
|
485 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
486 |
if ( function_exists('maybe_convert_table_to_utf8mb4') ) {
|
@@ -490,7 +504,134 @@ function gwolle_gb_upgrade() {
|
|
490 |
}
|
491 |
}
|
492 |
|
|
|
|
|
493 |
|
494 |
-
/* Update the plugin version option */
|
495 |
update_option('gwolle_gb_version', GWOLLE_GB_VER);
|
496 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
|
17 |
+
/*
|
18 |
+
* Install plugin structure.
|
19 |
+
*/
|
20 |
function gwolle_gb_install() {
|
21 |
global $wpdb;
|
22 |
|
79 |
}
|
80 |
}
|
81 |
|
82 |
+
/* Set default options if not set yet. */
|
83 |
+
gwolle_gb_set_defaults();
|
84 |
+
|
85 |
+
/* Save plugin version to database only when we did install. */
|
86 |
$result_after = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_entries'");
|
87 |
$result_after2 = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "gwolle_gb_log'");
|
88 |
if ( $result_after != 0 && $result_after2 != 0 ) {
|
89 |
add_option('gwolle_gb_version', GWOLLE_GB_VER);
|
90 |
}
|
91 |
|
92 |
+
/* Call flush_rules() as a method of the $wp_rewrite object for the RSS Feed. */
|
93 |
global $wp_rewrite;
|
94 |
$wp_rewrite->flush_rules( false );
|
95 |
}
|
96 |
|
97 |
|
98 |
+
/*
|
99 |
+
* Uninstall plugin structure.
|
100 |
+
* Called from the settingspage or from multisite uninstall function.
|
101 |
+
*/
|
102 |
function gwolle_gb_uninstall() {
|
103 |
// Delete the plugin's tables
|
104 |
global $wpdb;
|
113 |
option_name LIKE 'gwolle_gb%'
|
114 |
");
|
115 |
|
116 |
+
do_action( 'gwolle_gb_uninstall' );
|
117 |
+
|
118 |
// Deactivate ourselves
|
119 |
deactivate_plugins( GWOLLE_GB_FOLDER . '/gwolle-gb.php' );
|
120 |
}
|
121 |
|
122 |
|
123 |
+
/*
|
124 |
+
* Upgrade plugin structure.
|
125 |
+
*/
|
126 |
function gwolle_gb_upgrade() {
|
127 |
global $wpdb;
|
128 |
$installed_ver = get_option('gwolle_gb_version');
|
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') ) {
|
504 |
}
|
505 |
}
|
506 |
|
507 |
+
/* Set default options if not set yet. */
|
508 |
+
gwolle_gb_set_defaults();
|
509 |
|
510 |
+
/* Update the plugin version option. */
|
511 |
update_option('gwolle_gb_version', GWOLLE_GB_VER);
|
512 |
}
|
513 |
+
|
514 |
+
|
515 |
+
/*
|
516 |
+
* Set default options.
|
517 |
+
* Idea is to have all options in the database and thus cached, so we hit an empty cache less often.
|
518 |
+
*
|
519 |
+
* @since 2.5.0
|
520 |
+
*/
|
521 |
+
function gwolle_gb_set_defaults() {
|
522 |
+
if ( get_option('gwolle_gb-admin_style', false) == false ) {
|
523 |
+
update_option( 'gwolle_gb-admin_style', 'false' );
|
524 |
+
}
|
525 |
+
if ( get_option('gwolle_gb-akismet-active', false) == false ) {
|
526 |
+
update_option( 'gwolle_gb-akismet-active', 'false' );
|
527 |
+
}
|
528 |
+
if ( get_option('gwolle_gb-entries_per_page', false) == false ) {
|
529 |
+
update_option( 'gwolle_gb-entries_per_page', 20 );
|
530 |
+
}
|
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 ) {
|
538 |
+
$defaults = Array(
|
539 |
+
'form_name_enabled' => 'true',
|
540 |
+
'form_name_mandatory' => 'true',
|
541 |
+
'form_city_enabled' => 'true',
|
542 |
+
'form_city_mandatory' => 'false',
|
543 |
+
'form_email_enabled' => 'true',
|
544 |
+
'form_email_mandatory' => 'true',
|
545 |
+
'form_homepage_enabled' => 'true',
|
546 |
+
'form_homepage_mandatory' => 'false',
|
547 |
+
'form_message_enabled' => 'true',
|
548 |
+
'form_message_mandatory' => 'true',
|
549 |
+
'form_bbcode_enabled' => 'false',
|
550 |
+
'form_antispam_enabled' => 'false',
|
551 |
+
'form_recaptcha_enabled' => 'false',
|
552 |
+
'form_privacy_enabled' => 'false'
|
553 |
+
);
|
554 |
+
$defaults = serialize( $defaults );
|
555 |
+
update_option( 'gwolle_gb-form', $defaults );
|
556 |
+
}
|
557 |
+
if ( get_option('gwolle_gb-form_ajax', false) == false ) {
|
558 |
+
update_option( 'gwolle_gb-form_ajax', 'true' );
|
559 |
+
}
|
560 |
+
if ( get_option('gwolle_gb-honeypot', false) == false ) {
|
561 |
+
update_option( 'gwolle_gb-honeypot', 'true' );
|
562 |
+
}
|
563 |
+
if ( get_option('gwolle_gb-honeypot_value', false) == false ) {
|
564 |
+
$random = rand( 1, 99 );
|
565 |
+
update_option( 'gwolle_gb-honeypot_value', $random );
|
566 |
+
}
|
567 |
+
if ( get_option('gwolle_gb-labels_float', false) == false ) {
|
568 |
+
update_option( 'gwolle_gb-labels_float', 'true' );
|
569 |
+
}
|
570 |
+
if ( get_option('gwolle_gb-linkAuthorWebsite', false) == false ) {
|
571 |
+
update_option( 'gwolle_gb-linkAuthorWebsite', 'true' );
|
572 |
+
}
|
573 |
+
if ( get_option('gwolle_gb-linkchecker', false) == false ) {
|
574 |
+
update_option( 'gwolle_gb-linkchecker', 'true' );
|
575 |
+
}
|
576 |
+
if ( get_option('gwolle_gb-longtext', false) == false ) {
|
577 |
+
update_option( 'gwolle_gb-longtext', 'true' );
|
578 |
+
}
|
579 |
+
if ( get_option('gwolle_gb-mail_author', false) == false ) {
|
580 |
+
update_option( 'gwolle_gb-mail_author', 'false' );
|
581 |
+
}
|
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 ) {
|
589 |
+
update_option( 'gwolle_gb-nonce', 'true' );
|
590 |
+
}
|
591 |
+
if ( get_option('gwolle_gb-paginate_all', false) == false ) {
|
592 |
+
update_option( 'gwolle_gb-paginate_all', 'false' );
|
593 |
+
}
|
594 |
+
if ( get_option('gwolle_gb-read', false) == false ) {
|
595 |
+
if ( get_option('show_avatars') ) {
|
596 |
+
$avatar = 'true';
|
597 |
+
} else {
|
598 |
+
$avatar = 'false';
|
599 |
+
}
|
600 |
+
$defaults = Array(
|
601 |
+
'read_avatar' => $avatar,
|
602 |
+
'read_name' => 'true',
|
603 |
+
'read_city' => 'true',
|
604 |
+
'read_datetime' => 'true',
|
605 |
+
'read_date' => 'false',
|
606 |
+
'read_content' => 'true',
|
607 |
+
'read_aavatar' => 'false',
|
608 |
+
'read_editlink' => 'true'
|
609 |
+
);
|
610 |
+
$defaults = serialize( $defaults );
|
611 |
+
update_option( 'gwolle_gb-read', $defaults );
|
612 |
+
}
|
613 |
+
if ( get_option('gwolle_gb-refuse-spam', false) == false ) {
|
614 |
+
update_option( 'gwolle_gb-refuse-spam', 'false' );
|
615 |
+
}
|
616 |
+
if ( get_option('gwolle_gb-require_login', false) == false ) {
|
617 |
+
update_option( 'gwolle_gb-require_login', 'false' );
|
618 |
+
}
|
619 |
+
if ( get_option('gwolle_gb-sfs', false) == false ) {
|
620 |
+
update_option( 'gwolle_gb-sfs', 'false' );
|
621 |
+
}
|
622 |
+
if ( get_option('gwolle_gb-store_ip', false) == false ) {
|
623 |
+
update_option( 'gwolle_gb-store_ip', 'true' );
|
624 |
+
}
|
625 |
+
if ( get_option('gwolle_gb-showEntryIcons', false) == false ) {
|
626 |
+
update_option( 'gwolle_gb-showEntryIcons', 'true' );
|
627 |
+
}
|
628 |
+
if ( get_option('gwolle_gb-showLineBreaks', false) == false ) {
|
629 |
+
update_option( 'gwolle_gb-showLineBreaks', 'false' );
|
630 |
+
}
|
631 |
+
if ( get_option('gwolle_gb-showSmilies', false) == false ) {
|
632 |
+
update_option( 'gwolle_gb-showSmilies', 'true' );
|
633 |
+
}
|
634 |
+
if ( get_option('gwolle_gb-timeout', false) == false ) {
|
635 |
+
update_option( 'gwolle_gb-timeout', 'true' );
|
636 |
+
}
|
637 |
+
}
|
admin/js/gwolle-gb-admin.js
CHANGED
@@ -217,14 +217,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) *
|
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) *
|
228 |
);
|
229 |
|
230 |
event.preventDefault();
|
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();
|
admin/tabs/gb-admintab.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_settingstab_admin() {
|
13 |
|
14 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Admin tab of the Settings page.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_settingstab_admin() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
admin/tabs/gb-antispamtab.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_settingstab_antispam() {
|
13 |
|
14 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
@@ -60,7 +63,7 @@ function gwolle_gb_page_settingstab_antispam() {
|
|
60 |
<span class="setting-description">
|
61 |
<?php esc_html_e('Entries that are marked as spam will be placed in your spam folder by default.', 'gwolle-gb'); ?>
|
62 |
<br />
|
63 |
-
<?php esc_html_e('This option will refuse to accept entries marked by Honeypot, Nonce, Akismet and Stop Forum Spam. Users will see the form again after submit, with an error stating that it is recognized as spam.', 'gwolle-gb'); ?>
|
64 |
</span>
|
65 |
</td>
|
66 |
</tr>
|
@@ -129,6 +132,44 @@ function gwolle_gb_page_settingstab_antispam() {
|
|
129 |
</td>
|
130 |
</tr>
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
<tr valign="top">
|
133 |
<th scope="row">
|
134 |
<label for="akismet-active"><?php esc_html_e('Akismet', 'gwolle-gb'); ?></label>
|
@@ -161,7 +202,7 @@ function gwolle_gb_page_settingstab_antispam() {
|
|
161 |
<label for="akismet-active">
|
162 |
' . esc_html__('Use Akismet', 'gwolle-gb') . '
|
163 |
</label><br />';
|
164 |
-
esc_html_e('Akismet is an external service by Automattic that acts as a spamfilter for guestbook entries.', 'gwolle-gb')
|
165 |
esc_html_e('The WordPress API key has been found, so you can start using Akismet right now.', 'gwolle-gb');
|
166 |
}
|
167 |
?>
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Anti-spam tab of the Settings page.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_settingstab_antispam() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
63 |
<span class="setting-description">
|
64 |
<?php esc_html_e('Entries that are marked as spam will be placed in your spam folder by default.', 'gwolle-gb'); ?>
|
65 |
<br />
|
66 |
+
<?php esc_html_e('This option will refuse to accept entries marked by Honeypot, Nonce, Link Checker, Form Timeout, Akismet and Stop Forum Spam. Users will see the form again after submit, with an error stating that it is recognized as spam.', 'gwolle-gb'); ?>
|
67 |
</span>
|
68 |
</td>
|
69 |
</tr>
|
132 |
</td>
|
133 |
</tr>
|
134 |
|
135 |
+
<tr valign="top">
|
136 |
+
<th scope="row"><label for="gwolle_gb_linkchecker"><?php esc_html_e('Link Checker', 'gwolle-gb'); ?></label></th>
|
137 |
+
<td>
|
138 |
+
<input <?php
|
139 |
+
if (get_option( 'gwolle_gb-linkchecker', 'true') == 'true') {
|
140 |
+
echo 'checked="checked"';
|
141 |
+
} ?>
|
142 |
+
type="checkbox" name="gwolle_gb_linkchecker" id="gwolle_gb_linkchecker">
|
143 |
+
<label for="gwolle_gb_linkchecker">
|
144 |
+
<?php esc_html_e('Scan for multiple links.', 'gwolle-gb'); ?>
|
145 |
+
</label><br />
|
146 |
+
<span class="setting-description">
|
147 |
+
<?php
|
148 |
+
esc_html_e('This will scan entries for links, which are often part of spam. If there are 2 links found in the content, it will be automatically marked as spam.', 'gwolle-gb');
|
149 |
+
?>
|
150 |
+
</span>
|
151 |
+
</td>
|
152 |
+
</tr>
|
153 |
+
|
154 |
+
<tr valign="top">
|
155 |
+
<th scope="row"><label for="gwolle_gb_timeout"><?php esc_html_e('Form Timeout', 'gwolle-gb'); ?></label></th>
|
156 |
+
<td>
|
157 |
+
<input <?php
|
158 |
+
if (get_option( 'gwolle_gb-timeout', 'true') == 'true') {
|
159 |
+
echo 'checked="checked"';
|
160 |
+
} ?>
|
161 |
+
type="checkbox" name="gwolle_gb_timeout" id="gwolle_gb_timeout">
|
162 |
+
<label for="gwolle_gb_timeout">
|
163 |
+
<?php esc_html_e('Set timeout for form submit.', 'gwolle-gb'); ?>
|
164 |
+
</label><br />
|
165 |
+
<span class="setting-description">
|
166 |
+
<?php
|
167 |
+
esc_html_e('This will enable a timer function for the form. If the form is submitted faster than the timeout the entry will be marked as spam.', 'gwolle-gb');
|
168 |
+
?>
|
169 |
+
</span>
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
|
173 |
<tr valign="top">
|
174 |
<th scope="row">
|
175 |
<label for="akismet-active"><?php esc_html_e('Akismet', 'gwolle-gb'); ?></label>
|
202 |
<label for="akismet-active">
|
203 |
' . esc_html__('Use Akismet', 'gwolle-gb') . '
|
204 |
</label><br />';
|
205 |
+
esc_html_e('Akismet is an external service by Automattic that acts as a spamfilter for guestbook entries.', 'gwolle-gb'); echo '<br />';
|
206 |
esc_html_e('The WordPress API key has been found, so you can start using Akismet right now.', 'gwolle-gb');
|
207 |
}
|
208 |
?>
|
admin/tabs/gb-debugtab.php
CHANGED
@@ -8,8 +8,11 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
8 |
die('No direct calls allowed!');
|
9 |
}
|
10 |
|
|
|
11 |
/*
|
12 |
-
*
|
|
|
|
|
13 |
*/
|
14 |
function gwolle_gb_page_settingstab_debug( $debug_test ) {
|
15 |
|
8 |
die('No direct calls allowed!');
|
9 |
}
|
10 |
|
11 |
+
|
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 |
|
admin/tabs/gb-emailtab.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_settingstab_email() {
|
13 |
|
14 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Notifications tab of the Settings page.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_settingstab_email() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
admin/tabs/gb-formtab.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_settingstab_form() {
|
13 |
|
14 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
@@ -123,7 +126,8 @@ We reserve the right to edit, delete, or not publish entries.
|
|
123 |
<br />
|
124 |
<span class="setting-description"><?php /* translators: The GDPR law often has a country specific name */
|
125 |
esc_html_e('Since May 2018 there is a GDPR law in the EU about privacy and personal information that is being stored.', 'gwolle-gb'); echo '<br />';
|
126 |
-
esc_html_e('Disabling this option will still
|
|
|
127 |
</td>
|
128 |
</tr>
|
129 |
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Form tab of the Settings page.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_settingstab_form() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
126 |
<br />
|
127 |
<span class="setting-description"><?php /* translators: The GDPR law often has a country specific name */
|
128 |
esc_html_e('Since May 2018 there is a GDPR law in the EU about privacy and personal information that is being stored.', 'gwolle-gb'); echo '<br />';
|
129 |
+
esc_html_e('Disabling this option will still have the IP Address used for spamfiltering in Stop Forum Spam.', 'gwolle-gb'); echo '<br />';
|
130 |
+
esc_html_e('Disabling this option will probably make the Akismet spamfilter less effective.', 'gwolle-gb'); ?></span>
|
131 |
</td>
|
132 |
</tr>
|
133 |
|
admin/tabs/gb-readingtab.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
}
|
10 |
|
11 |
|
|
|
|
|
|
|
12 |
function gwolle_gb_page_settingstab_reading() {
|
13 |
|
14 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
9 |
}
|
10 |
|
11 |
|
12 |
+
/*
|
13 |
+
* Reading tab of the Settings page.
|
14 |
+
*/
|
15 |
function gwolle_gb_page_settingstab_reading() {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
admin/tabs/gb-uninstalltab.php
CHANGED
@@ -8,10 +8,12 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
8 |
die('No direct calls allowed!');
|
9 |
}
|
10 |
|
|
|
11 |
/*
|
12 |
-
*
|
|
|
|
|
13 |
*/
|
14 |
-
|
15 |
function gwolle_gb_page_settingstab_uninstall( $uninstalled ) {
|
16 |
|
17 |
if ( function_exists('current_user_can') && ! current_user_can('manage_options') ) {
|
8 |
die('No direct calls allowed!');
|
9 |
}
|
10 |
|
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') ) {
|
docs/actions/gwolle_gb_uninstall.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
==Description==
|
4 |
+
|
5 |
+
The <b>"gwolle_gb_uninstall"</b> action is used to execute a function when the plugin is uninstalled and deactivated.
|
6 |
+
|
7 |
+
You can use this action as:
|
8 |
+
|
9 |
+
<code><?php add_action( 'gwolle_gb_uninstall', 'action_function_name' ) ?></code>
|
10 |
+
|
11 |
+
Where 'action_function_name' is the function WordPress should call when the action is being used.
|
12 |
+
|
13 |
+
'''action_function_name''' should be a unique function name. It cannot match any other function name already declared.
|
14 |
+
|
15 |
+
|
16 |
+
==Examples==
|
17 |
+
|
18 |
+
function my_gwolle_gb_uninstall( $args = '' ) {
|
19 |
+
|
20 |
+
// Do something
|
21 |
+
|
22 |
+
}
|
23 |
+
add_action( 'gwolle_gb_uninstall', 'my_gwolle_gb_uninstall' );
|
frontend/gb-ajax-captcha.php
CHANGED
@@ -1,13 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
/*
|
4 |
-
* Handles AJAX request from Gwolle-GB Captcha AJAX check.
|
5 |
-
* Expects that the plugin Really Simple Captcha is enabled.
|
6 |
-
*
|
7 |
-
* Returns 'true' or 'false', if the CAPTCHA is filled in correctly.
|
8 |
-
* This response is not required for validation and being able to submit the form.
|
9 |
-
*/
|
10 |
-
|
11 |
|
12 |
// No direct calls to this script
|
13 |
if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
@@ -15,6 +7,13 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
15 |
}
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
function gwolle_gb_captcha_ajax_callback() {
|
19 |
|
20 |
if ( class_exists('ReallySimpleCaptcha') ) {
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
// No direct calls to this script
|
5 |
if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
7 |
}
|
8 |
|
9 |
|
10 |
+
/*
|
11 |
+
* Handles AJAX request from Gwolle-GB Captcha AJAX check.
|
12 |
+
* Expects that the plugin Really Simple Captcha is enabled.
|
13 |
+
*
|
14 |
+
* @return bool 'true' or 'false', if the CAPTCHA is filled in correctly.
|
15 |
+
* This response is not required for validation and being able to submit the form.
|
16 |
+
*/
|
17 |
function gwolle_gb_captcha_ajax_callback() {
|
18 |
|
19 |
if ( class_exists('ReallySimpleCaptcha') ) {
|
frontend/gb-form-ajax.php
CHANGED
@@ -1,11 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
/*
|
4 |
-
* Handles AJAX request from Gwolle-GB AJAX Submit.
|
5 |
-
*
|
6 |
-
* Returns json encoded data, which is handled with by frontend/js/script.js.
|
7 |
-
*/
|
8 |
-
|
9 |
|
10 |
// No direct calls to this script
|
11 |
if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
@@ -13,6 +7,11 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
13 |
}
|
14 |
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
function gwolle_gb_form_ajax_callback() {
|
17 |
|
18 |
$saved = gwolle_gb_frontend_posthandling();
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
// No direct calls to this script
|
5 |
if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
7 |
}
|
8 |
|
9 |
|
10 |
+
/*
|
11 |
+
* Handles AJAX request from Gwolle-GB AJAX Submit.
|
12 |
+
*
|
13 |
+
* @return string json encoded data, which is handled with by frontend/js/script.js.
|
14 |
+
*/
|
15 |
function gwolle_gb_form_ajax_callback() {
|
16 |
|
17 |
$saved = gwolle_gb_frontend_posthandling();
|
frontend/gb-form-posthandling.php
CHANGED
@@ -11,7 +11,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
11 |
* Use this action, since $post is populated and we can use get_the_ID().
|
12 |
*/
|
13 |
function gwolle_gb_handle_post() {
|
14 |
-
if ( !is_admin() ) {
|
15 |
// Frontend Handling of $_POST, only one form
|
16 |
if ( isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] == 'add_entry' ) {
|
17 |
gwolle_gb_frontend_posthandling();
|
@@ -28,8 +28,8 @@ add_action('wp', 'gwolle_gb_handle_post');
|
|
28 |
* global vars used:
|
29 |
* $gwolle_gb_formdata: the data that was submitted, and will be used to fill the form for resubmit.
|
30 |
*
|
31 |
-
*
|
32 |
-
*
|
33 |
*/
|
34 |
function gwolle_gb_frontend_posthandling() {
|
35 |
|
@@ -159,18 +159,19 @@ function gwolle_gb_frontend_posthandling() {
|
|
159 |
|
160 |
/* Custom Anti-Spam */
|
161 |
if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
|
|
|
162 |
$antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
|
163 |
$antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
|
164 |
|
165 |
if ( isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0 ) {
|
166 |
-
if ( isset($_POST[
|
167 |
//echo "You got it!";
|
168 |
} else {
|
169 |
-
gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('The anti-spam question was not answered correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true,
|
170 |
}
|
171 |
}
|
172 |
-
if ( isset($_POST[
|
173 |
-
$antispam = trim($_POST[
|
174 |
$gwolle_gb_formdata['antispam_answer'] = $antispam;
|
175 |
gwolle_gb_add_formdata( 'antispam_answer', $antispam );
|
176 |
}
|
@@ -263,9 +264,11 @@ function gwolle_gb_frontend_posthandling() {
|
|
263 |
}
|
264 |
|
265 |
|
266 |
-
/* Honeypot: check for spam and set accordingly */
|
267 |
$marked_by_honeypot = false;
|
268 |
$field_name = gwolle_gb_get_field_name( 'honeypot' );
|
|
|
|
|
269 |
if ( isset($_POST[$field_name]) && strlen($_POST[$field_name]) > 0 ) {
|
270 |
// Input field was filled in, so considered spam
|
271 |
$entry->set_isspam(true);
|
@@ -276,9 +279,19 @@ function gwolle_gb_frontend_posthandling() {
|
|
276 |
return false;
|
277 |
}
|
278 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
|
280 |
|
281 |
-
/* Nonce: check for spam and set accordingly */
|
282 |
$marked_by_nonce = false;
|
283 |
if (get_option( 'gwolle_gb-nonce', 'true') == 'true') {
|
284 |
$field_name = gwolle_gb_get_field_name( 'nonce' );
|
@@ -348,7 +361,62 @@ function gwolle_gb_frontend_posthandling() {
|
|
348 |
}
|
349 |
|
350 |
|
351 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
$entry->set_author_id( $user_id );
|
353 |
|
354 |
|
@@ -418,7 +486,7 @@ function gwolle_gb_frontend_posthandling() {
|
|
418 |
|
419 |
|
420 |
/*
|
421 |
-
* No Log for the Entry needed, it has a default post date in the Entry itself.
|
422 |
* Only log when something specific happened:
|
423 |
*/
|
424 |
if ( $marked_by_akismet ) {
|
@@ -436,6 +504,12 @@ function gwolle_gb_frontend_posthandling() {
|
|
436 |
if ( $marked_by_longtext ) {
|
437 |
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-by-longtext' );
|
438 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
|
440 |
|
441 |
/*
|
11 |
* Use this action, since $post is populated and we can use get_the_ID().
|
12 |
*/
|
13 |
function gwolle_gb_handle_post() {
|
14 |
+
if ( ! is_admin() ) {
|
15 |
// Frontend Handling of $_POST, only one form
|
16 |
if ( isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] == 'add_entry' ) {
|
17 |
gwolle_gb_frontend_posthandling();
|
28 |
* global vars used:
|
29 |
* $gwolle_gb_formdata: the data that was submitted, and will be used to fill the form for resubmit.
|
30 |
*
|
31 |
+
* @return int entry->ID when saved.
|
32 |
+
* @return bool false when not saved, and should return the form with an error.
|
33 |
*/
|
34 |
function gwolle_gb_frontend_posthandling() {
|
35 |
|
159 |
|
160 |
/* Custom Anti-Spam */
|
161 |
if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
|
162 |
+
$field_name = gwolle_gb_get_field_name( 'custom' );
|
163 |
$antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
|
164 |
$antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
|
165 |
|
166 |
if ( isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0 ) {
|
167 |
+
if ( isset($_POST[$field_name]) && trim($_POST[$field_name]) == trim($antispam_answer) ) {
|
168 |
//echo "You got it!";
|
169 |
} else {
|
170 |
+
gwolle_gb_add_message( '<p class="error_fields gb-error-fields"><strong>' . esc_html__('The anti-spam question was not answered correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>', true, $field_name); // mandatory
|
171 |
}
|
172 |
}
|
173 |
+
if ( isset($_POST[$field_name]) ) {
|
174 |
+
$antispam = trim($_POST[$field_name]);
|
175 |
$gwolle_gb_formdata['antispam_answer'] = $antispam;
|
176 |
gwolle_gb_add_formdata( 'antispam_answer', $antispam );
|
177 |
}
|
264 |
}
|
265 |
|
266 |
|
267 |
+
/* Honeypot: check for spam and set accordingly. */
|
268 |
$marked_by_honeypot = false;
|
269 |
$field_name = gwolle_gb_get_field_name( 'honeypot' );
|
270 |
+
$field_name2 = gwolle_gb_get_field_name( 'honeypot2' );
|
271 |
+
$honeypot_value = get_option( 'gwolle_gb-honeypot_value', 15 );
|
272 |
if ( isset($_POST[$field_name]) && strlen($_POST[$field_name]) > 0 ) {
|
273 |
// Input field was filled in, so considered spam
|
274 |
$entry->set_isspam(true);
|
279 |
return false;
|
280 |
}
|
281 |
}
|
282 |
+
if ( ! isset($_POST[$field_name2]) || $_POST[$field_name2] != $honeypot_value ) {
|
283 |
+
// Input field was not filled in correctly, so considered spam
|
284 |
+
$entry->set_isspam(true);
|
285 |
+
$marked_by_honeypot = true;
|
286 |
+
if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
|
287 |
+
gwolle_gb_add_message( '<p class="refuse-spam-honeypot2"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
|
288 |
+
do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
|
289 |
+
return false;
|
290 |
+
}
|
291 |
+
}
|
292 |
|
293 |
|
294 |
+
/* Nonce: check for spam and set accordingly. */
|
295 |
$marked_by_nonce = false;
|
296 |
if (get_option( 'gwolle_gb-nonce', 'true') == 'true') {
|
297 |
$field_name = gwolle_gb_get_field_name( 'nonce' );
|
361 |
}
|
362 |
|
363 |
|
364 |
+
/* Scan with Link Checker. */
|
365 |
+
$marked_by_linkchecker = false;
|
366 |
+
$marker_for_linkchecker = 0;
|
367 |
+
if ( get_option( 'gwolle_gb-linkchecker', 'true') == 'true' ) {
|
368 |
+
$words = explode( " ", $entry->get_content() );
|
369 |
+
foreach ( $words as $word ) {
|
370 |
+
if ( preg_match( '/(http|https)\:\/\/?/', $content, $matches) ) {
|
371 |
+
// Match
|
372 |
+
$marker_for_linkchecker++;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
if ( $marker_for_linkchecker > 1 ) {
|
376 |
+
$entry->set_isspam( true );
|
377 |
+
$marked_by_linkchecker = true;
|
378 |
+
if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
|
379 |
+
gwolle_gb_add_message( '<p class="refuse-spam-linkchecker"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
|
380 |
+
do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
|
381 |
+
return false;
|
382 |
+
}
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
/* Form Timeout: check for spam and set accordingly. */
|
388 |
+
$marked_by_timeout = false;
|
389 |
+
if (get_option( 'gwolle_gb-timeout', 'true') == 'true') {
|
390 |
+
$field_name = gwolle_gb_get_field_name( 'timeout' );
|
391 |
+
$field_name2 = gwolle_gb_get_field_name( 'timeout2' );
|
392 |
+
if ( isset($_POST[$field_name]) && strlen($_POST[$field_name]) > 0 && isset($_POST[$field_name2]) && strlen($_POST[$field_name2]) > 0 ) {
|
393 |
+
// Input fields were filled in, so continue.
|
394 |
+
$timeout = (int) $_POST[$field_name];
|
395 |
+
$timeout2 = (int) $_POST[$field_name2];
|
396 |
+
if ( ($timeout2 - $timeout) < 14 ) {
|
397 |
+
// Submitted less then 7 seconds after loading. Considered spam.
|
398 |
+
$entry->set_isspam(true);
|
399 |
+
$marked_by_timeout = true;
|
400 |
+
if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
|
401 |
+
gwolle_gb_add_message( '<p class="refuse-spam-timeout"><strong>' . esc_html__('Your entry was submitted too fast, please slow down and try again.', 'gwolle-gb') . '</strong></p>', true, false );
|
402 |
+
do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
|
403 |
+
return false;
|
404 |
+
}
|
405 |
+
}
|
406 |
+
} else {
|
407 |
+
// Input fields were not filled in correctly. Considered spam.
|
408 |
+
$entry->set_isspam(true);
|
409 |
+
$marked_by_timeout = true;
|
410 |
+
if (get_option( 'gwolle_gb-refuse-spam', 'false') == 'true') {
|
411 |
+
gwolle_gb_add_message( '<p class="refuse-spam-timeout"><strong>' . esc_html__('Your entry was marked as spam. Please try again.', 'gwolle-gb') . '</strong></p>', true, false );
|
412 |
+
do_action( 'gwolle_gb_notsaved_entry_frontend', $entry );
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
|
419 |
+
/* Check for logged in user, and set the userid as author_id, just in case someone is also admin, or gets promoted some day. */
|
420 |
$entry->set_author_id( $user_id );
|
421 |
|
422 |
|
486 |
|
487 |
|
488 |
/*
|
489 |
+
* No initial Log for the Entry needed, it has a default post date in the Entry itself.
|
490 |
* Only log when something specific happened:
|
491 |
*/
|
492 |
if ( $marked_by_akismet ) {
|
504 |
if ( $marked_by_longtext ) {
|
505 |
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-by-longtext' );
|
506 |
}
|
507 |
+
if ( $marked_by_linkchecker ) {
|
508 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-by-linkchecker' );
|
509 |
+
}
|
510 |
+
if ( $marked_by_timeout ) {
|
511 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-by-timeout' );
|
512 |
+
}
|
513 |
|
514 |
|
515 |
/*
|
frontend/gb-form.php
CHANGED
@@ -8,8 +8,12 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
8 |
|
9 |
/*
|
10 |
* Build up a form for the user, including possible error_fields
|
|
|
|
|
|
|
|
|
|
|
11 |
*/
|
12 |
-
|
13 |
function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
|
14 |
|
15 |
/* Get the messages and formdata from the form handling in posthandling.php. */
|
@@ -271,14 +275,36 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
|
|
271 |
$output .= apply_filters( 'gwolle_gb_write_add_after_website', '' );
|
272 |
|
273 |
/* Honeypot */
|
274 |
-
if (get_option( 'gwolle_gb-honeypot', 'true') == 'true') {
|
275 |
$field_name = gwolle_gb_get_field_name( 'honeypot' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
$output .= '
|
277 |
<div class="' . $field_name . '" style="display:none;">
|
278 |
-
<div class="label"><label for="' . $field_name . '" class="text-primary">' . esc_html__('Do not
|
|
|
279 |
</label></div>
|
280 |
<div class="input">
|
281 |
-
<input value="" type="text" name="' . $field_name . '" id="' . $field_name . '" placeholder="" />
|
|
|
282 |
</div>
|
283 |
</div>
|
284 |
<div class="clearBoth"></div>';
|
@@ -342,6 +368,7 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
|
|
342 |
|
343 |
/* Custom Anti-Spam */
|
344 |
if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
|
|
|
345 |
$label = apply_filters( 'gwolle_gb_antispam_label', esc_html__('Anti-spam', 'gwolle-gb') );
|
346 |
$antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
|
347 |
$antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
|
@@ -350,15 +377,15 @@ function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
|
|
350 |
$output .= '
|
351 |
<div class="gwolle_gb_antispam">
|
352 |
<div class="label">
|
353 |
-
<label for="
|
354 |
' . esc_html__('Question:', 'gwolle-gb') . ' ' . $antispam_question . '</label>
|
355 |
</div>
|
356 |
<div class="input"><input class="';
|
357 |
-
if (in_array(
|
358 |
$output .= ' error';
|
359 |
}
|
360 |
-
$output .= '" value="' . $antispam . '" type="text" name="
|
361 |
-
if ( in_array(
|
362 |
$output .= $autofocus;
|
363 |
$autofocus = false; // disable it for the next error.
|
364 |
}
|
8 |
|
9 |
/*
|
10 |
* Build up a form for the user, including possible error_fields
|
11 |
+
* Called by shortcode or template function
|
12 |
+
*
|
13 |
+
* @param array $shortcode_atts shortcode attributes
|
14 |
+
* @param string $shortcode the shortcode that was used
|
15 |
+
* @return string html with the form and messages
|
16 |
*/
|
|
|
17 |
function gwolle_gb_frontend_write( $shortcode_atts, $shortcode ) {
|
18 |
|
19 |
/* Get the messages and formdata from the form handling in posthandling.php. */
|
275 |
$output .= apply_filters( 'gwolle_gb_write_add_after_website', '' );
|
276 |
|
277 |
/* Honeypot */
|
278 |
+
if ( get_option( 'gwolle_gb-honeypot', 'true') == 'true' ) {
|
279 |
$field_name = gwolle_gb_get_field_name( 'honeypot' );
|
280 |
+
$field_name2 = gwolle_gb_get_field_name( 'honeypot2' );
|
281 |
+
$honeypot_value = get_option( 'gwolle_gb-honeypot_value', 15 );
|
282 |
+
$output .= '
|
283 |
+
<div class="' . $field_name . '" style="display:none;">
|
284 |
+
<div class="label"><label for="' . $field_name . '" class="text-primary">' . esc_html__('Do not fill this in', 'gwolle-gb') . ':</label>
|
285 |
+
<label for="' . $field_name2 . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . ':
|
286 |
+
</label></div>
|
287 |
+
<div class="input">
|
288 |
+
<input value="' . $honeypot_value . '" type="text" name="' . $field_name . '" id="' . $field_name . '" placeholder="" />
|
289 |
+
<input value="" type="text" name="' . $field_name2 . '" id="' . $field_name2 . '" placeholder="" />
|
290 |
+
</div>
|
291 |
+
</div>
|
292 |
+
<div class="clearBoth"></div>';
|
293 |
+
}
|
294 |
+
|
295 |
+
/* Form Timeout */
|
296 |
+
if ( get_option( 'gwolle_gb-timeout', 'true') == 'true' ) {
|
297 |
+
$field_name = gwolle_gb_get_field_name( 'timeout' );
|
298 |
+
$field_name2 = gwolle_gb_get_field_name( 'timeout2' );
|
299 |
+
$random = rand( 100, 100000 );
|
300 |
$output .= '
|
301 |
<div class="' . $field_name . '" style="display:none;">
|
302 |
+
<div class="label"><label for="' . $field_name . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . ':</label>
|
303 |
+
<label for="' . $field_name2 . '" class="text-primary">' . esc_html__('Do not touch this', 'gwolle-gb') . ':
|
304 |
</label></div>
|
305 |
<div class="input">
|
306 |
+
<input value="' . $random . '" type="text" name="' . $field_name . '" id="' . $field_name . '" placeholder="" />
|
307 |
+
<input value="' . $random . '" type="text" name="' . $field_name2 . '" id="' . $field_name2 . '" placeholder="" />
|
308 |
</div>
|
309 |
</div>
|
310 |
<div class="clearBoth"></div>';
|
368 |
|
369 |
/* Custom Anti-Spam */
|
370 |
if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true' ) {
|
371 |
+
$field_name = gwolle_gb_get_field_name( 'custom' );
|
372 |
$label = apply_filters( 'gwolle_gb_antispam_label', esc_html__('Anti-spam', 'gwolle-gb') );
|
373 |
$antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
|
374 |
$antispam_answer = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
|
377 |
$output .= '
|
378 |
<div class="gwolle_gb_antispam">
|
379 |
<div class="label">
|
380 |
+
<label for="' . $field_name . '" class="text-info">' . $label . ': *<br />
|
381 |
' . esc_html__('Question:', 'gwolle-gb') . ' ' . $antispam_question . '</label>
|
382 |
</div>
|
383 |
<div class="input"><input class="';
|
384 |
+
if (in_array( $field_name, $gwolle_gb_error_fields)) {
|
385 |
$output .= ' error';
|
386 |
}
|
387 |
+
$output .= '" value="' . $antispam . '" type="text" name="' . $field_name . '" id="' . $field_name . '" placeholder="' . esc_attr__('Answer', 'gwolle-gb') . '" ';
|
388 |
+
if ( in_array( $field_name, $gwolle_gb_error_fields) && isset($autofocus) ) {
|
389 |
$output .= $autofocus;
|
390 |
$autofocus = false; // disable it for the next error.
|
391 |
}
|
frontend/gb-pagination.php
CHANGED
@@ -10,9 +10,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
10 |
* gwolle_gb_pagination_frontend
|
11 |
* Pagination of the entries for the guestbook frontend
|
12 |
*
|
13 |
-
* @
|
14 |
-
*
|
15 |
-
*
|
16 |
*/
|
17 |
function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
|
18 |
|
10 |
* gwolle_gb_pagination_frontend
|
11 |
* Pagination of the entries for the guestbook frontend
|
12 |
*
|
13 |
+
* @param int $pageNum the number of the requested page.
|
14 |
+
* @param int $pages_total the total number of pages.
|
15 |
+
* @return string $pagination the html of the pagination.
|
16 |
*/
|
17 |
function gwolle_gb_pagination_frontend( $pageNum, $pages_total ) {
|
18 |
|
frontend/gb-read.php
CHANGED
@@ -7,10 +7,13 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
7 |
|
8 |
|
9 |
/*
|
10 |
-
*
|
11 |
-
* Reading mode of the guestbook frontend
|
|
|
|
|
|
|
|
|
12 |
*/
|
13 |
-
|
14 |
function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
|
15 |
|
16 |
$output = '';
|
7 |
|
8 |
|
9 |
/*
|
10 |
+
* Called by the shortcode or template function.
|
11 |
+
* Reading mode of the guestbook frontend.
|
12 |
+
*
|
13 |
+
* @param array $shortcode_atts shortcode attributes
|
14 |
+
* @param string $shortcode the shortcode that was used
|
15 |
+
* @return string html with the list of entries
|
16 |
*/
|
|
|
17 |
function gwolle_gb_frontend_read( $shortcode_atts, $shortcode ) {
|
18 |
|
19 |
$output = '';
|
frontend/gb-rss.php
CHANGED
@@ -7,7 +7,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
7 |
}
|
8 |
|
9 |
|
10 |
-
/*
|
|
|
|
|
11 |
function gwolle_gb_rss_init(){
|
12 |
add_feed('gwolle_gb', 'gwolle_gb_rss');
|
13 |
}
|
@@ -45,7 +47,9 @@ function gwolle_gb_rss_head() {
|
|
45 |
add_action('wp_head', 'gwolle_gb_rss_head', 1);
|
46 |
|
47 |
|
48 |
-
/*
|
|
|
|
|
49 |
function gwolle_gb_rss_content_type( $content_type, $type ) {
|
50 |
if ( 'gwolle_gb' === $type ) {
|
51 |
return feed_content_type( 'rss2' );
|
@@ -55,7 +59,9 @@ function gwolle_gb_rss_content_type( $content_type, $type ) {
|
|
55 |
add_filter( 'feed_content_type', 'gwolle_gb_rss_content_type', 10, 2 );
|
56 |
|
57 |
|
58 |
-
/*
|
|
|
|
|
59 |
function gwolle_gb_rss() {
|
60 |
|
61 |
// Only show the first page of entries.
|
7 |
}
|
8 |
|
9 |
|
10 |
+
/*
|
11 |
+
* Add the feed.
|
12 |
+
*/
|
13 |
function gwolle_gb_rss_init(){
|
14 |
add_feed('gwolle_gb', 'gwolle_gb_rss');
|
15 |
}
|
47 |
add_action('wp_head', 'gwolle_gb_rss_head', 1);
|
48 |
|
49 |
|
50 |
+
/*
|
51 |
+
* Set the correct HTTP header for Content-type.
|
52 |
+
*/
|
53 |
function gwolle_gb_rss_content_type( $content_type, $type ) {
|
54 |
if ( 'gwolle_gb' === $type ) {
|
55 |
return feed_content_type( 'rss2' );
|
59 |
add_filter( 'feed_content_type', 'gwolle_gb_rss_content_type', 10, 2 );
|
60 |
|
61 |
|
62 |
+
/*
|
63 |
+
* Show the XML Feed
|
64 |
+
*/
|
65 |
function gwolle_gb_rss() {
|
66 |
|
67 |
// Only show the first page of entries.
|
frontend/gb-shortcode-widget.php
CHANGED
@@ -6,21 +6,29 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
6 |
}
|
7 |
|
8 |
|
9 |
-
/*
|
|
|
10 |
*
|
11 |
* For multiple guestbooks, use it like this:
|
12 |
* gwolle_gb_shortcode_widget( array('book_id'=>2) );
|
13 |
* which will show Book ID 2 in widget layout.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
*/
|
15 |
-
|
16 |
function gwolle_gb_shortcode_widget( $atts ) {
|
17 |
echo get_gwolle_gb_shortcode_widget( $atts );
|
18 |
}
|
19 |
|
20 |
|
21 |
-
/*
|
|
|
22 |
*
|
23 |
-
*
|
24 |
* - book_id, int with an ID.
|
25 |
* - num_entries, int with the shown number of messages.
|
26 |
* - num_words, int with the shown number of words per entry.
|
6 |
}
|
7 |
|
8 |
|
9 |
+
/*
|
10 |
+
* Widget Function for simple layout.
|
11 |
*
|
12 |
* For multiple guestbooks, use it like this:
|
13 |
* gwolle_gb_shortcode_widget( array('book_id'=>2) );
|
14 |
* which will show Book ID 2 in widget layout.
|
15 |
+
*
|
16 |
+
* @since 2.1.4
|
17 |
+
*
|
18 |
+
* @param array $atts array with the shortcode attributes.
|
19 |
+
* - book_id, int with an ID.
|
20 |
+
* - num_entries, int with the shown number of messages.
|
21 |
+
* - num_words, int with the shown number of words per entry.
|
22 |
*/
|
|
|
23 |
function gwolle_gb_shortcode_widget( $atts ) {
|
24 |
echo get_gwolle_gb_shortcode_widget( $atts );
|
25 |
}
|
26 |
|
27 |
|
28 |
+
/*
|
29 |
+
* Frontend function to show the list of entries in widget layout.
|
30 |
*
|
31 |
+
* @param array $atts array with the shortcode attributes.
|
32 |
* - book_id, int with an ID.
|
33 |
* - num_entries, int with the shown number of messages.
|
34 |
* - num_words, int with the shown number of words per entry.
|
frontend/gb-shortcodes.php
CHANGED
@@ -12,28 +12,27 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
12 |
}
|
13 |
|
14 |
|
15 |
-
/*
|
|
|
16 |
* Use this to display the guestbook on a page without using a shortcode.
|
17 |
*
|
18 |
* For multiple guestbooks, use it like this:
|
19 |
* show_gwolle_gb( array('book_id'=>2) );
|
20 |
* which will show Book ID 2.
|
21 |
*/
|
22 |
-
|
23 |
function show_gwolle_gb( $atts ) {
|
24 |
echo get_gwolle_gb( $atts );
|
25 |
}
|
26 |
|
27 |
|
28 |
-
/*
|
|
|
29 |
* Used for the main shortcode.
|
30 |
*
|
31 |
-
*
|
32 |
-
* shortcode_atts:
|
33 |
* - book_id = 1 (default)
|
34 |
* Can be any integer. Can also be post_id, which will set it to the ID of that post.
|
35 |
*/
|
36 |
-
|
37 |
function get_gwolle_gb( $atts ) {
|
38 |
|
39 |
$shortcode = 'gwolle_gb';
|
@@ -75,7 +74,11 @@ add_shortcode( 'gwolle-gb', 'get_gwolle_gb' ); // deprecated, do not use dashes
|
|
75 |
add_shortcode( 'gwolle_gb', 'get_gwolle_gb' );
|
76 |
|
77 |
|
78 |
-
/*
|
|
|
|
|
|
|
|
|
79 |
function get_gwolle_gb_write( $atts ) {
|
80 |
|
81 |
$shortcode = 'gwolle_gb_write';
|
@@ -112,7 +115,11 @@ function get_gwolle_gb_write( $atts ) {
|
|
112 |
add_shortcode( 'gwolle_gb_write', 'get_gwolle_gb_write' );
|
113 |
|
114 |
|
115 |
-
/*
|
|
|
|
|
|
|
|
|
116 |
function get_gwolle_gb_read( $atts ) {
|
117 |
|
118 |
$shortcode = 'gwolle_gb_read';
|
12 |
}
|
13 |
|
14 |
|
15 |
+
/*
|
16 |
+
* Frontend Function
|
17 |
* Use this to display the guestbook on a page without using a shortcode.
|
18 |
*
|
19 |
* For multiple guestbooks, use it like this:
|
20 |
* show_gwolle_gb( array('book_id'=>2) );
|
21 |
* which will show Book ID 2.
|
22 |
*/
|
|
|
23 |
function show_gwolle_gb( $atts ) {
|
24 |
echo get_gwolle_gb( $atts );
|
25 |
}
|
26 |
|
27 |
|
28 |
+
/*
|
29 |
+
* Frontend Function
|
30 |
* Used for the main shortcode.
|
31 |
*
|
32 |
+
* @param array $atts array with the shortcode attributes.
|
|
|
33 |
* - book_id = 1 (default)
|
34 |
* Can be any integer. Can also be post_id, which will set it to the ID of that post.
|
35 |
*/
|
|
|
36 |
function get_gwolle_gb( $atts ) {
|
37 |
|
38 |
$shortcode = 'gwolle_gb';
|
74 |
add_shortcode( 'gwolle_gb', 'get_gwolle_gb' );
|
75 |
|
76 |
|
77 |
+
/*
|
78 |
+
* Frontend function to show just the form.
|
79 |
+
*
|
80 |
+
* @param array $atts array with the shortcode attributes.
|
81 |
+
*/
|
82 |
function get_gwolle_gb_write( $atts ) {
|
83 |
|
84 |
$shortcode = 'gwolle_gb_write';
|
115 |
add_shortcode( 'gwolle_gb_write', 'get_gwolle_gb_write' );
|
116 |
|
117 |
|
118 |
+
/*
|
119 |
+
* Frontend function to show just the list of entries
|
120 |
+
*
|
121 |
+
* @param array $atts array with the shortcode attributes.
|
122 |
+
*/
|
123 |
function get_gwolle_gb_read( $atts ) {
|
124 |
|
125 |
$shortcode = 'gwolle_gb_read';
|
frontend/gb-total.php
CHANGED
@@ -14,8 +14,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
14 |
* Display the total number of entries.
|
15 |
*
|
16 |
* @param string $html html content of the filter.
|
17 |
-
*
|
18 |
-
* @return
|
19 |
*
|
20 |
* @since 2.3.2
|
21 |
*/
|
14 |
* Display the total number of entries.
|
15 |
*
|
16 |
* @param string $html html content of the filter.
|
17 |
+
* @param array $args the parameters of the query for visible entries
|
18 |
+
* @return string $html new html content of the filter.
|
19 |
*
|
20 |
* @since 2.3.2
|
21 |
*/
|
frontend/gwolle_gb-entry.php
CHANGED
@@ -6,13 +6,6 @@
|
|
6 |
* By default this file will be loaded from /wp-content/plugins/gwolle-gb-frontend/gwolle_gb-entry.php.
|
7 |
* If you place it in your childtheme or parenttheme, it will be overridden.
|
8 |
* Make sure you only return values, and not to use echo statements.
|
9 |
-
*
|
10 |
-
*
|
11 |
-
* $args: $entry, instance of gwolle_gb_entry.
|
12 |
-
* $first, boolean with true if it is the first entry.
|
13 |
-
* $counter,int with the number of the entry. (since 1.4.7)
|
14 |
-
*
|
15 |
-
* return: string, html with a single guestbook entry.
|
16 |
*/
|
17 |
|
18 |
|
@@ -21,7 +14,14 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
21 |
die('No direct calls allowed!');
|
22 |
}
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if ( ! function_exists('gwolle_gb_entry_template') ) {
|
26 |
function gwolle_gb_entry_template( $entry, $first, $counter ) {
|
27 |
|
6 |
* By default this file will be loaded from /wp-content/plugins/gwolle-gb-frontend/gwolle_gb-entry.php.
|
7 |
* If you place it in your childtheme or parenttheme, it will be overridden.
|
8 |
* Make sure you only return values, and not to use echo statements.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
|
14 |
die('No direct calls allowed!');
|
15 |
}
|
16 |
|
17 |
+
/*
|
18 |
+
* Template file for s single guestbook entry.
|
19 |
+
*
|
20 |
+
* @param object $entry instance of gwolle_gb_entry.
|
21 |
+
* @param bool $first true if it is the first entry.
|
22 |
+
* @param int $counter the number of the entry. (since 1.4.7)
|
23 |
+
* @return: string, html with a single guestbook entry.
|
24 |
+
*/
|
25 |
if ( ! function_exists('gwolle_gb_entry_template') ) {
|
26 |
function gwolle_gb_entry_template( $entry, $first, $counter ) {
|
27 |
|
frontend/js/gwolle-gb-frontend.js
CHANGED
@@ -136,6 +136,41 @@ jQuery(document).ready(function($) {
|
|
136 |
});
|
137 |
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
/*
|
140 |
* AJAX Submit for Gwolle Guestbook Frontend.
|
141 |
*/
|
136 |
});
|
137 |
|
138 |
|
139 |
+
/*
|
140 |
+
* Mangle data for the honeypot.
|
141 |
+
*/
|
142 |
+
jQuery(document).ready(function($) {
|
143 |
+
var honeypot = gwolle_gb_frontend_script.honeypot;
|
144 |
+
var honeypot2 = gwolle_gb_frontend_script.honeypot2;
|
145 |
+
var val = jQuery( '#' + honeypot ).val();
|
146 |
+
if ( val > 0 ) {
|
147 |
+
jQuery( '#' + honeypot2 ).val( val );
|
148 |
+
jQuery( '#' + honeypot ).val( '' );
|
149 |
+
}
|
150 |
+
});
|
151 |
+
|
152 |
+
|
153 |
+
/*
|
154 |
+
* Mangle data for the form timeout.
|
155 |
+
*/
|
156 |
+
jQuery(document).ready(function($) {
|
157 |
+
setInterval('gwolle_gb_timout_clock()', 1000 );
|
158 |
+
});
|
159 |
+
function gwolle_gb_timout_clock() {
|
160 |
+
var timeout = gwolle_gb_frontend_script.timeout;
|
161 |
+
var timeout2 = gwolle_gb_frontend_script.timeout2;
|
162 |
+
|
163 |
+
var timer = new Number( jQuery( '#' + timeout ).val() );
|
164 |
+
var timer2 = new Number( jQuery( '#' + timeout2 ).val() );
|
165 |
+
|
166 |
+
var timer = timer - 1
|
167 |
+
var timer2 = timer2 + 1
|
168 |
+
|
169 |
+
jQuery( '#' + timeout ).val( timer );
|
170 |
+
jQuery( '#' + timeout2 ).val( timer2 );
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
/*
|
175 |
* AJAX Submit for Gwolle Guestbook Frontend.
|
176 |
*/
|
functions/gb-akismet.php
CHANGED
@@ -13,18 +13,15 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
13 |
|
14 |
|
15 |
/*
|
16 |
-
* $
|
17 |
-
*
|
18 |
-
* should be an instance of the gwolle_gb_entry class
|
19 |
-
* $action: string with the requested action
|
20 |
* - comment-check: check with Akismet service if entry is considered spam or not
|
21 |
* - submit-ham: submit as ham to Akismet service
|
22 |
* - submit-spam: submit as spam to Akismet service
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
*/
|
27 |
-
|
28 |
function gwolle_gb_akismet( $entry, $action ) {
|
29 |
|
30 |
$actions = array(
|
@@ -74,8 +71,11 @@ function gwolle_gb_akismet( $entry, $action ) {
|
|
74 |
$comment['blog'] = get_option( 'home' );
|
75 |
$comment['blog_lang'] = get_locale();
|
76 |
$comment['blog_charset'] = get_option( 'blog_charset' );
|
77 |
-
$
|
78 |
-
$
|
|
|
|
|
|
|
79 |
if ( isset($_SERVER['HTTP_REFERER']) ) {
|
80 |
$comment['referrer'] = $_SERVER['HTTP_REFERER'];
|
81 |
}
|
@@ -88,7 +88,7 @@ function gwolle_gb_akismet( $entry, $action ) {
|
|
88 |
$comment['permalink'] = $permalink;
|
89 |
}
|
90 |
|
91 |
-
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
|
92 |
foreach ( $_SERVER as $key => $value ) {
|
93 |
if ( ! in_array( $key, (array) $ignore ) )
|
94 |
$comment["$key"] = $value;
|
@@ -103,13 +103,15 @@ function gwolle_gb_akismet( $entry, $action ) {
|
|
103 |
/*
|
104 |
* Check the $comment against Akismet service
|
105 |
*
|
106 |
-
*
|
107 |
-
*
|
108 |
-
*
|
109 |
-
*
|
110 |
-
*
|
|
|
|
|
|
|
111 |
*/
|
112 |
-
|
113 |
function gwolle_gb_akismet_entry_check( $comment, $action ) {
|
114 |
global $akismet_api_host, $akismet_api_port;
|
115 |
|
13 |
|
14 |
|
15 |
/*
|
16 |
+
* @param object $entry instance of gwolle_gb_entry with a guestbook entry to be checked
|
17 |
+
* @param string $action the requested action
|
|
|
|
|
18 |
* - comment-check: check with Akismet service if entry is considered spam or not
|
19 |
* - submit-ham: submit as ham to Akismet service
|
20 |
* - submit-spam: submit as spam to Akismet service
|
21 |
+
* @return bool
|
22 |
+
* - true if the entry is considered spam by akismet
|
23 |
+
* - false if no spam, or no akismet functionality is found
|
24 |
*/
|
|
|
25 |
function gwolle_gb_akismet( $entry, $action ) {
|
26 |
|
27 |
$actions = array(
|
71 |
$comment['blog'] = get_option( 'home' );
|
72 |
$comment['blog_lang'] = get_locale();
|
73 |
$comment['blog_charset'] = get_option( 'blog_charset' );
|
74 |
+
$store_author_ip = get_option('gwolle_gb-store_ip', 'true');
|
75 |
+
if ( $store_author_ip == 'true' ) {
|
76 |
+
$comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
|
77 |
+
$comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
78 |
+
}
|
79 |
if ( isset($_SERVER['HTTP_REFERER']) ) {
|
80 |
$comment['referrer'] = $_SERVER['HTTP_REFERER'];
|
81 |
}
|
88 |
$comment['permalink'] = $permalink;
|
89 |
}
|
90 |
|
91 |
+
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW', 'REMOTE_ADDR', 'HTTP_USER_AGENT', 'PATH' );
|
92 |
foreach ( $_SERVER as $key => $value ) {
|
93 |
if ( ! in_array( $key, (array) $ignore ) )
|
94 |
$comment["$key"] = $value;
|
103 |
/*
|
104 |
* Check the $comment against Akismet service
|
105 |
*
|
106 |
+
* @param array $comment array with data fields to be checked on
|
107 |
+
* @param string $action the requested action
|
108 |
+
* - comment-check: check with Akismet service if entry is considered spam or not
|
109 |
+
* - submit-ham: submit as ham to Akismet service
|
110 |
+
* - submit-spam: submit as spam to Akismet service
|
111 |
+
* @return bool
|
112 |
+
* - true if the entry is considered spam by akismet
|
113 |
+
* - false if no spam, or no akismet functionality is found
|
114 |
*/
|
|
|
115 |
function gwolle_gb_akismet_entry_check( $comment, $action ) {
|
116 |
global $akismet_api_host, $akismet_api_port;
|
117 |
|
functions/gb-bbcode_emoji.php
CHANGED
@@ -9,6 +9,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
|
10 |
/*
|
11 |
* Parse the BBcode into HTML for output.
|
|
|
|
|
|
|
12 |
*/
|
13 |
function gwolle_gb_bbcode_parse( $str ){
|
14 |
$bb[] = "#\[b\](.*?)\[/b\]#si";
|
@@ -51,6 +54,9 @@ function gwolle_gb_bbcode_parse( $str ){
|
|
51 |
|
52 |
/*
|
53 |
* Strip the BBcode from the output.
|
|
|
|
|
|
|
54 |
*/
|
55 |
function gwolle_gb_bbcode_strip( $str ){
|
56 |
$bb[] = "#\[b\](.*?)\[/b\]#si";
|
@@ -81,6 +87,8 @@ function gwolle_gb_bbcode_strip( $str ){
|
|
81 |
|
82 |
/*
|
83 |
* Get the list of Emoji for the form.
|
|
|
|
|
84 |
*/
|
85 |
function gwolle_gb_get_emoji() {
|
86 |
$emoji = '
|
@@ -149,6 +157,7 @@ function gwolle_gb_get_emoji() {
|
|
149 |
<a title="🌜" class="gwolle_gb_emoji_63 noslimstat">🌜</a>
|
150 |
<a title="🌈" class="gwolle_gb_emoji_64 noslimstat">🌈</a>
|
151 |
<a title="🏝" class="gwolle_gb_emoji_65 noslimstat">🏝</a>
|
|
|
152 |
';
|
153 |
/*
|
154 |
* Filters the list of emoji shown on textarea/bbcode/emoji at the frontend form.
|
@@ -168,10 +177,9 @@ function gwolle_gb_get_emoji() {
|
|
168 |
/*
|
169 |
* Convert to 3byte Emoji for storing in db, if db-charset is not utf8mb4.
|
170 |
*
|
171 |
-
*
|
172 |
-
*
|
173 |
-
*
|
174 |
-
* Return: string, encoded or not.
|
175 |
*/
|
176 |
function gwolle_gb_maybe_encode_emoji( $string, $field ) {
|
177 |
global $wpdb;
|
9 |
|
10 |
/*
|
11 |
* Parse the BBcode into HTML for output.
|
12 |
+
*
|
13 |
+
* @param string $str content that needs to be parsed
|
14 |
+
* @return string parsed content
|
15 |
*/
|
16 |
function gwolle_gb_bbcode_parse( $str ){
|
17 |
$bb[] = "#\[b\](.*?)\[/b\]#si";
|
54 |
|
55 |
/*
|
56 |
* Strip the BBcode from the output.
|
57 |
+
*
|
58 |
+
* @param string $str content that needs to be stripped
|
59 |
+
* @return string stripped content
|
60 |
*/
|
61 |
function gwolle_gb_bbcode_strip( $str ){
|
62 |
$bb[] = "#\[b\](.*?)\[/b\]#si";
|
87 |
|
88 |
/*
|
89 |
* Get the list of Emoji for the form.
|
90 |
+
*
|
91 |
+
* @return string html with a elements with emoji
|
92 |
*/
|
93 |
function gwolle_gb_get_emoji() {
|
94 |
$emoji = '
|
157 |
<a title="🌜" class="gwolle_gb_emoji_63 noslimstat">🌜</a>
|
158 |
<a title="🌈" class="gwolle_gb_emoji_64 noslimstat">🌈</a>
|
159 |
<a title="🏝" class="gwolle_gb_emoji_65 noslimstat">🏝</a>
|
160 |
+
<a title="🎅" class="gwolle_gb_emoji_66 noslimstat">🎅</a>
|
161 |
';
|
162 |
/*
|
163 |
* Filters the list of emoji shown on textarea/bbcode/emoji at the frontend form.
|
177 |
/*
|
178 |
* Convert to 3byte Emoji for storing in db, if db-charset is not utf8mb4.
|
179 |
*
|
180 |
+
* @param string $string text string to encode
|
181 |
+
* @param string $field the database field that is used for that string, will be checked on charset.
|
182 |
+
* @return string original input string encoded or not.
|
|
|
183 |
*/
|
184 |
function gwolle_gb_maybe_encode_emoji( $string, $field ) {
|
185 |
global $wpdb;
|
functions/gb-book_id.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Uses intermittent meta_key to determine the post ID. See functions/gb-post-meta.php and gwolle_gb_set_meta_keys().
|
12 |
+
*
|
13 |
+
* @param int book_id integer of the guestbook ID. Not required for backwards compatibility, but suggested to use the parameter.
|
14 |
+
* @return int postid if found, else 0.
|
15 |
+
*/
|
16 |
+
function gwolle_gb_get_postid( $book_id = 1 ) {
|
17 |
+
|
18 |
+
$the_query = new WP_Query( array(
|
19 |
+
'post_type' => 'any',
|
20 |
+
'ignore_sticky_posts' => true, // do not use sticky posts.
|
21 |
+
'meta_query' => array(
|
22 |
+
array(
|
23 |
+
'key' => 'gwolle_gb_read',
|
24 |
+
'value' => 'true',
|
25 |
+
),
|
26 |
+
array(
|
27 |
+
'key' => 'gwolle_gb_book_id',
|
28 |
+
'value' => $book_id,
|
29 |
+
),
|
30 |
+
),
|
31 |
+
'update_post_term_cache' => false,
|
32 |
+
'update_post_meta_cache' => false
|
33 |
+
));
|
34 |
+
|
35 |
+
if ( $the_query->have_posts() ) {
|
36 |
+
while ( $the_query->have_posts() ) : $the_query->the_post();
|
37 |
+
$postid = get_the_ID();
|
38 |
+
return $postid;
|
39 |
+
break; // only one postid is needed.
|
40 |
+
endwhile;
|
41 |
+
wp_reset_postdata();
|
42 |
+
}
|
43 |
+
return 0;
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
/*
|
49 |
+
* Uses intermittent meta_key to determine the post ID. See functions/gb-post-meta.php and gwolle_gb_set_meta_keys().
|
50 |
+
*
|
51 |
+
* @return int postid if found, else 0.
|
52 |
+
*
|
53 |
+
* @since 2.4.0
|
54 |
+
*/
|
55 |
+
function gwolle_gb_get_postid_biggest_book() {
|
56 |
+
|
57 |
+
$postids = gwolle_gb_get_books();
|
58 |
+
if ( is_array($postids) && ! empty($postids) ) {
|
59 |
+
|
60 |
+
if ( count( $postids ) == 1 ) {
|
61 |
+
return $postids[0]; // just one guestbook, return it.
|
62 |
+
}
|
63 |
+
|
64 |
+
$books = array();
|
65 |
+
$totals = array();
|
66 |
+
foreach ( $postids as $postid ) {
|
67 |
+
$bookid = (int) get_post_meta( $postid, 'gwolle_gb_book_id', true );
|
68 |
+
if ( empty( $bookid ) ) {
|
69 |
+
continue;
|
70 |
+
}
|
71 |
+
$key = 'gwolle_gb_frontend_pagination_book_' . $bookid;
|
72 |
+
$entries_total = (int) get_transient( $key );
|
73 |
+
if ( false === $entries_total ) {
|
74 |
+
$entries_total = gwolle_gb_get_entry_count(
|
75 |
+
array(
|
76 |
+
'checked' => 'checked',
|
77 |
+
'trash' => 'notrash',
|
78 |
+
'spam' => 'nospam',
|
79 |
+
'book_id' => $bookid
|
80 |
+
)
|
81 |
+
);
|
82 |
+
set_transient( $key, $entries_total, DAY_IN_SECONDS );
|
83 |
+
}
|
84 |
+
$book = array();
|
85 |
+
$book['postid'] = $postid;
|
86 |
+
$book['bookid'] = $bookid;
|
87 |
+
$book['entries_total'] = $entries_total;
|
88 |
+
$books[] = $book;
|
89 |
+
$totals[] = $entries_total;
|
90 |
+
}
|
91 |
+
|
92 |
+
// First check what the biggest total is, then find the post_id that belongs to it.
|
93 |
+
rsort( $totals );
|
94 |
+
|
95 |
+
foreach ( $books as $book ) {
|
96 |
+
if ( $book['entries_total'] == $totals[0] ) {
|
97 |
+
return $book['postid'];
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
return 0;
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/*
|
108 |
+
* Uses intermittent meta_key to determine the post IDs. See functions/gb-post-meta.php and gwolle_gb_set_meta_keys().
|
109 |
+
*
|
110 |
+
* @return array with post IDs that contain a guestbook.
|
111 |
+
*
|
112 |
+
* @since 2.4.0
|
113 |
+
*/
|
114 |
+
function gwolle_gb_get_books() {
|
115 |
+
|
116 |
+
$the_query = new WP_Query( array(
|
117 |
+
'post_type' => 'any',
|
118 |
+
'ignore_sticky_posts' => true, // do not use sticky posts.
|
119 |
+
'meta_query' => array(
|
120 |
+
array(
|
121 |
+
'key' => 'gwolle_gb_read',
|
122 |
+
'value' => 'true',
|
123 |
+
),
|
124 |
+
),
|
125 |
+
'update_post_term_cache' => false,
|
126 |
+
'update_post_meta_cache' => false
|
127 |
+
));
|
128 |
+
|
129 |
+
$postids = array();
|
130 |
+
if ( $the_query->have_posts() ) {
|
131 |
+
while ( $the_query->have_posts() ) : $the_query->the_post();
|
132 |
+
$postids[] = get_the_ID();
|
133 |
+
endwhile;
|
134 |
+
wp_reset_postdata();
|
135 |
+
}
|
136 |
+
|
137 |
+
return $postids;
|
138 |
+
|
139 |
+
}
|
functions/gb-cache.php
CHANGED
@@ -9,6 +9,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
|
10 |
/*
|
11 |
* Clear the cache of the most common Cache plugins.
|
|
|
|
|
12 |
*/
|
13 |
function gwolle_gb_clear_cache( $entry = false ) {
|
14 |
|
@@ -24,9 +26,21 @@ function gwolle_gb_clear_cache( $entry = false ) {
|
|
24 |
$book_id = $entry->get_book_id();
|
25 |
$key = 'gwolle_gb_frontend_pagination_book_' . $book_id;
|
26 |
delete_transient( $key );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
-
|
30 |
/* Cachify */
|
31 |
if ( class_exists('Cachify') ) {
|
32 |
$cachify = new Cachify();
|
9 |
|
10 |
/*
|
11 |
* Clear the cache of the most common Cache plugins.
|
12 |
+
*
|
13 |
+
* @param object $entry instance of gb_entry class
|
14 |
*/
|
15 |
function gwolle_gb_clear_cache( $entry = false ) {
|
16 |
|
26 |
$book_id = $entry->get_book_id();
|
27 |
$key = 'gwolle_gb_frontend_pagination_book_' . $book_id;
|
28 |
delete_transient( $key );
|
29 |
+
} else {
|
30 |
+
// no book_id available, clear all transients.
|
31 |
+
$postids = gwolle_gb_get_books();
|
32 |
+
if ( is_array($postids) && ! empty($postids) ) {
|
33 |
+
foreach ( $postids as $postid ) {
|
34 |
+
$bookid = (int) get_post_meta( $postid, 'gwolle_gb_book_id', true );
|
35 |
+
if ( empty( $bookid ) ) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
$key = 'gwolle_gb_frontend_pagination_book_' . $bookid;
|
39 |
+
delete_transient( $key );
|
40 |
+
}
|
41 |
+
}
|
42 |
}
|
43 |
|
|
|
44 |
/* Cachify */
|
45 |
if ( class_exists('Cachify') ) {
|
46 |
$cachify = new Cachify();
|
functions/gb-debug.php
CHANGED
@@ -111,6 +111,9 @@ function gwolle_gb_debug_info() {
|
|
111 |
/*
|
112 |
* Test adding an entry.
|
113 |
*
|
|
|
|
|
|
|
114 |
* @since 1.6.2
|
115 |
*/
|
116 |
function gwolle_gb_test_add_entry( $emoji = false ) {
|
111 |
/*
|
112 |
* Test adding an entry.
|
113 |
*
|
114 |
+
* @param bool $emoji save text with or without emoji characters
|
115 |
+
* @return int ID of the saved entry, 0 if not saved
|
116 |
+
*
|
117 |
* @since 1.6.2
|
118 |
*/
|
119 |
function gwolle_gb_test_add_entry( $emoji = false ) {
|
functions/gb-formatting.php
CHANGED
@@ -9,7 +9,10 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
|
10 |
/*
|
11 |
* Function to sanitize values from input fields for the database.
|
12 |
-
*
|
|
|
|
|
|
|
13 |
*/
|
14 |
function gwolle_gb_sanitize_input( $input, $field = '' ) {
|
15 |
$input = strval($input);
|
@@ -30,7 +33,10 @@ function gwolle_gb_sanitize_input( $input, $field = '' ) {
|
|
30 |
|
31 |
/*
|
32 |
* Function to sanitize values for output in a form or div.
|
33 |
-
*
|
|
|
|
|
|
|
34 |
*/
|
35 |
function gwolle_gb_sanitize_output( $output, $field = '' ) {
|
36 |
$output = strval($output);
|
@@ -52,8 +58,9 @@ function gwolle_gb_sanitize_output( $output, $field = '' ) {
|
|
52 |
|
53 |
/*
|
54 |
* Function to format values for beeing send by mail.
|
55 |
-
*
|
56 |
-
*
|
|
|
57 |
*/
|
58 |
function gwolle_gb_format_values_for_mail($value) {
|
59 |
$value = htmlspecialchars_decode($value, ENT_COMPAT);
|
@@ -74,9 +81,8 @@ function gwolle_gb_format_values_for_mail($value) {
|
|
74 |
/*
|
75 |
* Function to build the excerpt
|
76 |
*
|
77 |
-
* @param $content
|
78 |
-
*
|
79 |
-
*
|
80 |
* @return $excerpt string the shortened content
|
81 |
*/
|
82 |
function gwolle_gb_get_excerpt( $content, $excerpt_length = 20 ) {
|
9 |
|
10 |
/*
|
11 |
* Function to sanitize values from input fields for the database.
|
12 |
+
*
|
13 |
+
* @param string $input string to sanitize
|
14 |
+
* @param string $field string to check which sanitizing to do
|
15 |
+
* @return string $input sanitized string
|
16 |
*/
|
17 |
function gwolle_gb_sanitize_input( $input, $field = '' ) {
|
18 |
$input = strval($input);
|
33 |
|
34 |
/*
|
35 |
* Function to sanitize values for output in a form or div.
|
36 |
+
*
|
37 |
+
* @param string $input string to sanitize
|
38 |
+
* @param string $field string to check which sanitizing to do
|
39 |
+
* @return string $input sanitized string
|
40 |
*/
|
41 |
function gwolle_gb_sanitize_output( $output, $field = '' ) {
|
42 |
$output = strval($output);
|
58 |
|
59 |
/*
|
60 |
* Function to format values for beeing send by mail.
|
61 |
+
*
|
62 |
+
* @param string $value string to sanitize
|
63 |
+
* @return string $value sanitized string
|
64 |
*/
|
65 |
function gwolle_gb_format_values_for_mail($value) {
|
66 |
$value = htmlspecialchars_decode($value, ENT_COMPAT);
|
81 |
/*
|
82 |
* Function to build the excerpt
|
83 |
*
|
84 |
+
* @param string $content content of the entry to be shortened
|
85 |
+
* @param int $excerpt_length the maximum length to return in number of words (uses wp_trim_words)
|
|
|
86 |
* @return $excerpt string the shortened content
|
87 |
*/
|
88 |
function gwolle_gb_get_excerpt( $content, $excerpt_length = 20 ) {
|
functions/gb-get_entries.php
CHANGED
@@ -11,7 +11,7 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
11 |
* gwolle_gb_get_entries
|
12 |
* Function to get guestbook entries from the database.
|
13 |
*
|
14 |
-
*
|
15 |
* - num_entries int: Number of requested entries. -1 will return all requested entries.
|
16 |
* - offset int: Start after this entry.
|
17 |
* - checked string: 'checked' or 'unchecked', List the entries that are checked or unchecked.
|
@@ -21,13 +21,14 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
21 |
* - email string: All entries associated with this emailaddress.
|
22 |
* - no_moderators string: 'true', Only entries not written by a moderator (might be expensive with many users) (since 1.5.0).
|
23 |
* - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
|
|
|
|
|
|
|
|
|
24 |
*
|
25 |
-
*
|
26 |
-
* - Array of objects of gwolle_gb_entry
|
27 |
-
* - false if no entries found.
|
28 |
*
|
29 |
* @since 1.0.0
|
30 |
-
*
|
31 |
*/
|
32 |
function gwolle_gb_get_entries($args = array()) {
|
33 |
global $wpdb;
|
@@ -35,7 +36,7 @@ function gwolle_gb_get_entries($args = array()) {
|
|
35 |
$where = " 1 = %d";
|
36 |
$values = Array(1);
|
37 |
|
38 |
-
if ( !is_array($args) ) {
|
39 |
return false;
|
40 |
}
|
41 |
|
@@ -108,6 +109,24 @@ function gwolle_gb_get_entries($args = array()) {
|
|
108 |
$values[] = (int) $args['book_id'];
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
// Offset
|
112 |
$offset = " OFFSET 0 "; // default
|
113 |
if ( isset($args['offset']) && (int) $args['offset'] > 0 ) {
|
@@ -238,7 +257,7 @@ function gwolle_gb_get_entries($args = array()) {
|
|
238 |
* gwolle_gb_get_entry_ids
|
239 |
* Function to get guestbook entry IDs from the database.
|
240 |
*
|
241 |
-
*
|
242 |
* - checked string: 'checked' or 'unchecked', List the entries that are checked or unchecked.
|
243 |
* - trash string: 'trash' or 'notrash', List the entries that are in trash or not in trash.
|
244 |
* - spam string: 'spam' or 'nospam', List the entries marked as spam or as no spam.
|
@@ -247,12 +266,9 @@ function gwolle_gb_get_entries($args = array()) {
|
|
247 |
* - no_moderators string: 'true', Only entries not written by a moderator (might be expensive with many users) (since 1.5.0).
|
248 |
* - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
|
249 |
*
|
250 |
-
*
|
251 |
-
* - Array of ids of gwolle_gb_entry
|
252 |
-
* - false if no entries found.
|
253 |
*
|
254 |
* @since 2.3.0
|
255 |
-
*
|
256 |
*/
|
257 |
function gwolle_gb_get_entry_ids($args = array()) {
|
258 |
global $wpdb;
|
@@ -382,16 +398,13 @@ function gwolle_gb_get_entry_ids($args = array()) {
|
|
382 |
* Function to delete guestbook entries from the database.
|
383 |
* Removes the log entries as well.
|
384 |
*
|
385 |
-
*
|
386 |
* - spam string: 'spam', delete the entries marked as spam
|
387 |
* - trash string: 'trash', delete the entries that are in trash
|
388 |
*
|
389 |
-
*
|
390 |
-
* - int: Number of deleted entries
|
391 |
-
* - bool: false if no entries found.
|
392 |
*
|
393 |
* @since 1.0.0
|
394 |
-
*
|
395 |
*/
|
396 |
function gwolle_gb_del_entries( $status ) {
|
397 |
global $wpdb;
|
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.
|
16 |
* - offset int: Start after this entry.
|
17 |
* - checked string: 'checked' or 'unchecked', List the entries that are checked or unchecked.
|
21 |
* - email string: All entries associated with this emailaddress.
|
22 |
* - no_moderators string: 'true', Only entries not written by a moderator (might be expensive with many users) (since 1.5.0).
|
23 |
* - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
|
24 |
+
* - date_query array:
|
25 |
+
* - datetime int: timestamp (non-inclusive)
|
26 |
+
* - before bool: before this datetime
|
27 |
+
* - after bool: after this datetime
|
28 |
*
|
29 |
+
* @return mixed array of objects of gwolle_gb_entry, false if no entries found.
|
|
|
|
|
30 |
*
|
31 |
* @since 1.0.0
|
|
|
32 |
*/
|
33 |
function gwolle_gb_get_entries($args = array()) {
|
34 |
global $wpdb;
|
36 |
$where = " 1 = %d";
|
37 |
$values = Array(1);
|
38 |
|
39 |
+
if ( ! is_array($args) ) {
|
40 |
return false;
|
41 |
}
|
42 |
|
109 |
$values[] = (int) $args['book_id'];
|
110 |
}
|
111 |
|
112 |
+
if ( isset( $args['date_query'] ) && is_array( $args['date_query'] ) && ! empty( $args['date_query'] ) ) {
|
113 |
+
$date_query = $args['date_query'];
|
114 |
+
if ( isset( $date_query['datetime'] ) && ((int) $date_query['datetime'] > 0 ) ) {
|
115 |
+
$datetime = $date_query['datetime'];
|
116 |
+
if ( isset( $date_query['before'] ) && $date_query['before'] === true ) {
|
117 |
+
$where .= "
|
118 |
+
AND
|
119 |
+
datetime < %d";
|
120 |
+
$values[] = (int) $datetime;
|
121 |
+
} else if ( isset( $date_query['after'] ) && $date_query['after'] === true ) {
|
122 |
+
$where .= "
|
123 |
+
AND
|
124 |
+
datetime > %d";
|
125 |
+
$values[] = (int) $datetime;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
// Offset
|
131 |
$offset = " OFFSET 0 "; // default
|
132 |
if ( isset($args['offset']) && (int) $args['offset'] > 0 ) {
|
257 |
* gwolle_gb_get_entry_ids
|
258 |
* Function to get guestbook entry IDs from the database.
|
259 |
*
|
260 |
+
* @param array $args
|
261 |
* - checked string: 'checked' or 'unchecked', List the entries that are checked or unchecked.
|
262 |
* - trash string: 'trash' or 'notrash', List the entries that are in trash or not in trash.
|
263 |
* - spam string: 'spam' or 'nospam', List the entries marked as spam or as no spam.
|
266 |
* - no_moderators string: 'true', Only entries not written by a moderator (might be expensive with many users) (since 1.5.0).
|
267 |
* - book_id int: Only entries from this book. Default in the shortcode is 1 (since 1.5.1).
|
268 |
*
|
269 |
+
* @return mixed array of ids of gwolle_gb_entry, bool false if no entries found.
|
|
|
|
|
270 |
*
|
271 |
* @since 2.3.0
|
|
|
272 |
*/
|
273 |
function gwolle_gb_get_entry_ids($args = array()) {
|
274 |
global $wpdb;
|
398 |
* Function to delete guestbook entries from the database.
|
399 |
* Removes the log entries as well.
|
400 |
*
|
401 |
+
* @param string $status 'spam' or 'trash'
|
402 |
* - spam string: 'spam', delete the entries marked as spam
|
403 |
* - trash string: 'trash', delete the entries that are in trash
|
404 |
*
|
405 |
+
* @return mixed int Number of deleted entries, bool false if no entries found.
|
|
|
|
|
406 |
*
|
407 |
* @since 1.0.0
|
|
|
408 |
*/
|
409 |
function gwolle_gb_del_entries( $status ) {
|
410 |
global $wpdb;
|
functions/gb-get_entry_count.php
CHANGED
@@ -11,18 +11,15 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
11 |
* gwolle_gb_get_entry_count
|
12 |
* Get the number of entries.
|
13 |
*
|
14 |
-
*
|
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 |
-
*
|
22 |
-
* - int with the count of the entries
|
23 |
-
* - false if there's an error.
|
24 |
*/
|
25 |
-
|
26 |
function gwolle_gb_get_entry_count($args) {
|
27 |
|
28 |
global $wpdb;
|
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;
|
functions/gb-log.php
CHANGED
@@ -11,17 +11,14 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
11 |
* gwolle_gb_add_log_entry()
|
12 |
* Add a new log entry
|
13 |
*
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* Return: (bool) true or false, depending on succes
|
19 |
*/
|
20 |
-
|
21 |
function gwolle_gb_add_log_entry( $entry_id, $subject ) {
|
22 |
global $wpdb;
|
23 |
|
24 |
-
if ( !isset($subject) || !isset($entry_id) || (int) $entry_id === 0 ) {
|
25 |
return false;
|
26 |
}
|
27 |
|
@@ -35,6 +32,8 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
|
|
35 |
'marked-by-akismet',
|
36 |
'marked-by-sfs',
|
37 |
'marked-by-longtext',
|
|
|
|
|
38 |
'entry-edited',
|
39 |
'imported-from-dmsguestbook',
|
40 |
'imported-from-wp',
|
@@ -84,9 +83,9 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
|
|
84 |
* gwolle_gb_get_log_entries
|
85 |
* Function to get log entries.
|
86 |
*
|
87 |
-
*
|
88 |
*
|
89 |
-
*
|
90 |
* id => (int) id
|
91 |
* subject => (string) subject of the log, what happened
|
92 |
* author_id => (int) author_id of the user responsible for this log entry
|
@@ -96,11 +95,10 @@ function gwolle_gb_add_log_entry( $entry_id, $subject ) {
|
|
96 |
* msg_html => (string) string of html-text ready for displayed
|
97 |
*
|
98 |
*/
|
99 |
-
|
100 |
function gwolle_gb_get_log_entries( $entry_id ) {
|
101 |
global $wpdb;
|
102 |
|
103 |
-
if ( !isset($entry_id) || (int) $entry_id === 0 ) {
|
104 |
return false;
|
105 |
}
|
106 |
|
@@ -115,6 +113,8 @@ function gwolle_gb_get_log_entries( $entry_id ) {
|
|
115 |
'marked-by-akismet' => /* translators: Log message */ esc_html__('Entry marked by Akismet.', 'gwolle-gb'),
|
116 |
'marked-by-sfs' => /* translators: Log message */ esc_html__('Entry marked by Stop Forum Spam.', 'gwolle-gb'),
|
117 |
'marked-by-longtext' => /* translators: Log message */ esc_html__('Entry marked for too long text.', 'gwolle-gb'),
|
|
|
|
|
118 |
'entry-edited' => /* translators: Log message */ esc_html__('Entry has been edited.', 'gwolle-gb'),
|
119 |
'imported-from-dmsguestbook' => /* translators: Log message */ esc_html__('Imported from DMSGuestbook', 'gwolle-gb'),
|
120 |
'imported-from-wp' => /* translators: Log message */ esc_html__('Imported from WordPress comments', 'gwolle-gb'),
|
@@ -211,12 +211,10 @@ function gwolle_gb_get_log_entries( $entry_id ) {
|
|
211 |
* gwolle_gb_del_log_entries()
|
212 |
* Delete the log entries for a guestbook entry
|
213 |
*
|
214 |
-
*
|
215 |
-
* - entry_id: (int) the id of the entry
|
216 |
*
|
217 |
-
*
|
218 |
*/
|
219 |
-
|
220 |
function gwolle_gb_del_log_entries( $entry_id ) {
|
221 |
global $wpdb;
|
222 |
|
11 |
* gwolle_gb_add_log_entry()
|
12 |
* Add a new log entry
|
13 |
*
|
14 |
+
* @param int $entry_id ID of the entry
|
15 |
+
* @param string $subject one of the possible log_messages
|
16 |
+
* @return bool true or false, depending on succes
|
|
|
|
|
17 |
*/
|
|
|
18 |
function gwolle_gb_add_log_entry( $entry_id, $subject ) {
|
19 |
global $wpdb;
|
20 |
|
21 |
+
if ( ! isset($subject) || ! isset($entry_id) || (int) $entry_id === 0 ) {
|
22 |
return false;
|
23 |
}
|
24 |
|
32 |
'marked-by-akismet',
|
33 |
'marked-by-sfs',
|
34 |
'marked-by-longtext',
|
35 |
+
'marked-by-linkchecker',
|
36 |
+
'marked-by-timeout',
|
37 |
'entry-edited',
|
38 |
'imported-from-dmsguestbook',
|
39 |
'imported-from-wp',
|
83 |
* gwolle_gb_get_log_entries
|
84 |
* Function to get log entries.
|
85 |
*
|
86 |
+
* @param int $entry_id ID of the guestbook entry where the log belongs to
|
87 |
*
|
88 |
+
* @return array with log_entries, each is an array:
|
89 |
* id => (int) id
|
90 |
* subject => (string) subject of the log, what happened
|
91 |
* author_id => (int) author_id of the user responsible for this log entry
|
95 |
* msg_html => (string) string of html-text ready for displayed
|
96 |
*
|
97 |
*/
|
|
|
98 |
function gwolle_gb_get_log_entries( $entry_id ) {
|
99 |
global $wpdb;
|
100 |
|
101 |
+
if ( ! isset($entry_id) || (int) $entry_id === 0 ) {
|
102 |
return false;
|
103 |
}
|
104 |
|
113 |
'marked-by-akismet' => /* translators: Log message */ esc_html__('Entry marked by Akismet.', 'gwolle-gb'),
|
114 |
'marked-by-sfs' => /* translators: Log message */ esc_html__('Entry marked by Stop Forum Spam.', 'gwolle-gb'),
|
115 |
'marked-by-longtext' => /* translators: Log message */ esc_html__('Entry marked for too long text.', 'gwolle-gb'),
|
116 |
+
'marked-by-linkchecker' => /* translators: Log message */ esc_html__('Entry marked for too many links.', 'gwolle-gb'),
|
117 |
+
'marked-by-timeout' => /* translators: Log message */ esc_html__('Entry marked for being submitted too fast.', 'gwolle-gb'),
|
118 |
'entry-edited' => /* translators: Log message */ esc_html__('Entry has been edited.', 'gwolle-gb'),
|
119 |
'imported-from-dmsguestbook' => /* translators: Log message */ esc_html__('Imported from DMSGuestbook', 'gwolle-gb'),
|
120 |
'imported-from-wp' => /* translators: Log message */ esc_html__('Imported from WordPress comments', 'gwolle-gb'),
|
211 |
* gwolle_gb_del_log_entries()
|
212 |
* Delete the log entries for a guestbook entry
|
213 |
*
|
214 |
+
* @param int $entry_id ID of the entry
|
|
|
215 |
*
|
216 |
+
* @return bool true or false, depending on succes
|
217 |
*/
|
|
|
218 |
function gwolle_gb_del_log_entries( $entry_id ) {
|
219 |
global $wpdb;
|
220 |
|
functions/gb-mail.php
CHANGED
@@ -13,7 +13,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
13 |
/*
|
14 |
* Send the Notification Mail to moderators that have subscribed (only when it is not Spam).
|
15 |
*
|
16 |
-
* @
|
|
|
17 |
* @since 1.4.9
|
18 |
*/
|
19 |
function gwolle_gb_mail_moderators( $entry ) {
|
@@ -135,7 +136,8 @@ add_action( 'gwolle_gb_save_entry_frontend', 'gwolle_gb_mail_moderators' );
|
|
135 |
/*
|
136 |
* Send Notification Mail to the author if set to true in an option (only when it is not Spam).
|
137 |
*
|
138 |
-
* @
|
|
|
139 |
* @since 1.4.9
|
140 |
*/
|
141 |
function gwolle_gb_mail_author( $entry ) {
|
@@ -210,7 +212,8 @@ add_action( 'gwolle_gb_save_entry_frontend', 'gwolle_gb_mail_author' );
|
|
210 |
/*
|
211 |
* Send Notification Mail to the author that there is an admin_reply (only when it is not Spam).
|
212 |
*
|
213 |
-
* @
|
|
|
214 |
* @since 1.4.9
|
215 |
*/
|
216 |
function gwolle_gb_mail_author_on_admin_reply( $entry ) {
|
13 |
/*
|
14 |
* Send the Notification Mail to moderators that have subscribed (only when it is not Spam).
|
15 |
*
|
16 |
+
* @param object $entry instance of gwolle_gb_entry
|
17 |
+
*
|
18 |
* @since 1.4.9
|
19 |
*/
|
20 |
function gwolle_gb_mail_moderators( $entry ) {
|
136 |
/*
|
137 |
* Send Notification Mail to the author if set to true in an option (only when it is not Spam).
|
138 |
*
|
139 |
+
* @param object $entry instance of gwolle_gb_entry
|
140 |
+
*
|
141 |
* @since 1.4.9
|
142 |
*/
|
143 |
function gwolle_gb_mail_author( $entry ) {
|
212 |
/*
|
213 |
* Send Notification Mail to the author that there is an admin_reply (only when it is not Spam).
|
214 |
*
|
215 |
+
* @param object $entry instance of gwolle_gb_entry
|
216 |
+
*
|
217 |
* @since 1.4.9
|
218 |
*/
|
219 |
function gwolle_gb_mail_author_on_admin_reply( $entry ) {
|
functions/gb-messages.php
CHANGED
@@ -12,12 +12,12 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
12 |
|
13 |
/*
|
14 |
* Add messages from the form to show again after submitting an entry.
|
15 |
-
* Parameters:
|
16 |
-
* - message: string with html and text to show.
|
17 |
-
* - error: if it is a validation error for the form (default false).
|
18 |
-
* - error_field: which field does not validate.
|
19 |
-
* Since 1.5.6
|
20 |
*
|
|
|
|
|
|
|
|
|
|
|
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;
|
@@ -46,8 +46,11 @@ function gwolle_gb_add_message( $message = false, $error = false, $error_field =
|
|
46 |
|
47 |
|
48 |
/*
|
49 |
-
*
|
50 |
-
*
|
|
|
|
|
|
|
51 |
*
|
52 |
*/
|
53 |
function gwolle_gb_get_messages() {
|
@@ -81,8 +84,11 @@ function gwolle_gb_get_messages() {
|
|
81 |
|
82 |
|
83 |
/*
|
84 |
-
*
|
85 |
-
*
|
|
|
|
|
|
|
86 |
*
|
87 |
*/
|
88 |
function gwolle_gb_get_errors() {
|
@@ -100,9 +106,9 @@ function gwolle_gb_get_errors() {
|
|
100 |
|
101 |
|
102 |
/*
|
103 |
-
*
|
104 |
-
* Since 1.5.6
|
105 |
*
|
|
|
106 |
*/
|
107 |
function gwolle_gb_get_error_fields() {
|
108 |
global $gwolle_gb_error_fields;
|
@@ -120,11 +126,11 @@ function gwolle_gb_get_error_fields() {
|
|
120 |
|
121 |
/*
|
122 |
* Add formdata from the form to show again after submitting an entry.
|
123 |
-
* Parameters:
|
124 |
-
* - field: string with name of the formfield.
|
125 |
-
* - value: value of the formfield to be used again.
|
126 |
-
* Since 1.5.6
|
127 |
*
|
|
|
|
|
|
|
|
|
128 |
*/
|
129 |
function gwolle_gb_add_formdata( $field, $value = '' ) {
|
130 |
global $gwolle_gb_formdata;
|
@@ -139,9 +145,11 @@ function gwolle_gb_add_formdata( $field, $value = '' ) {
|
|
139 |
|
140 |
|
141 |
/*
|
142 |
-
*
|
143 |
-
*
|
|
|
144 |
*
|
|
|
145 |
*/
|
146 |
function gwolle_gb_get_formdata() {
|
147 |
global $gwolle_gb_formdata;
|
12 |
|
13 |
/*
|
14 |
* Add messages from the form to show again after submitting an entry.
|
|
|
|
|
|
|
|
|
|
|
15 |
*
|
16 |
+
* @param string $message html and text to show.
|
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;
|
46 |
|
47 |
|
48 |
/*
|
49 |
+
* Used for the frontend form, html with messages.
|
50 |
+
*
|
51 |
+
* @return string with html with messages
|
52 |
+
*
|
53 |
+
* @since 1.5.6
|
54 |
*
|
55 |
*/
|
56 |
function gwolle_gb_get_messages() {
|
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() {
|
106 |
|
107 |
|
108 |
/*
|
109 |
+
* @return array with the fields that did not validate.
|
|
|
110 |
*
|
111 |
+
* @since 1.5.6
|
112 |
*/
|
113 |
function gwolle_gb_get_error_fields() {
|
114 |
global $gwolle_gb_error_fields;
|
126 |
|
127 |
/*
|
128 |
* Add formdata from the form to show again after submitting an entry.
|
|
|
|
|
|
|
|
|
129 |
*
|
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;
|
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;
|
functions/gb-metabox.php
CHANGED
@@ -10,6 +10,10 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
10 |
/*
|
11 |
* Edit Link for Moderators for in the Metabox.
|
12 |
*
|
|
|
|
|
|
|
|
|
13 |
* @since 2.3.0
|
14 |
*/
|
15 |
function gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
|
@@ -28,6 +32,10 @@ add_filter( 'gwolle_gb_entry_metabox_lines', 'gwolle_gb_entry_metabox_lines_edit
|
|
28 |
* Ajax Icon for in the Metabox.
|
29 |
* Only shown when there is already content.
|
30 |
*
|
|
|
|
|
|
|
|
|
31 |
* @since 2.3.0
|
32 |
*/
|
33 |
function gwolle_gb_entry_metabox_lines_ajax_icon( $gb_metabox, $entry ) {
|
10 |
/*
|
11 |
* Edit Link for Moderators for in the Metabox.
|
12 |
*
|
13 |
+
* @param string $gb_metabox html for the metabox of this entry
|
14 |
+
* @param object $entry instance of class gb_entry
|
15 |
+
* @return string $gb_metabox new html for the metabox of this entry
|
16 |
+
*
|
17 |
* @since 2.3.0
|
18 |
*/
|
19 |
function gwolle_gb_entry_metabox_lines_edit_link( $gb_metabox, $entry ) {
|
32 |
* Ajax Icon for in the Metabox.
|
33 |
* Only shown when there is already content.
|
34 |
*
|
35 |
+
* @param string $gb_metabox html for the metabox of this entry
|
36 |
+
* @param object $entry instance of class gb_entry
|
37 |
+
* @return string $gb_metabox new html for the metabox of this entry
|
38 |
+
*
|
39 |
* @since 2.3.0
|
40 |
*/
|
41 |
function gwolle_gb_entry_metabox_lines_ajax_icon( $gb_metabox, $entry ) {
|
functions/gb-misc.php
CHANGED
@@ -7,142 +7,11 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
7 |
}
|
8 |
|
9 |
|
10 |
-
/*
|
11 |
-
* Uses intermittent meta_key to determine the post ID. See functions/gb-post-meta.php and gwolle_gb_set_meta_keys().
|
12 |
-
*
|
13 |
-
* @param int book_id integer of the guestbook ID. Not required for backwards compatibility, but suggested to use the parameter.
|
14 |
-
*
|
15 |
-
* @return (int) postid if found, else 0.
|
16 |
-
*/
|
17 |
-
function gwolle_gb_get_postid( $book_id = 1 ) {
|
18 |
-
|
19 |
-
$the_query = new WP_Query( array(
|
20 |
-
'post_type' => 'any',
|
21 |
-
'ignore_sticky_posts' => true, // do not use sticky posts.
|
22 |
-
'meta_query' => array(
|
23 |
-
array(
|
24 |
-
'key' => 'gwolle_gb_read',
|
25 |
-
'value' => 'true',
|
26 |
-
),
|
27 |
-
array(
|
28 |
-
'key' => 'gwolle_gb_book_id',
|
29 |
-
'value' => $book_id,
|
30 |
-
),
|
31 |
-
),
|
32 |
-
'update_post_term_cache' => false,
|
33 |
-
'update_post_meta_cache' => false
|
34 |
-
));
|
35 |
-
|
36 |
-
if ( $the_query->have_posts() ) {
|
37 |
-
while ( $the_query->have_posts() ) : $the_query->the_post();
|
38 |
-
$postid = get_the_ID();
|
39 |
-
return $postid;
|
40 |
-
break; // only one postid is needed.
|
41 |
-
endwhile;
|
42 |
-
wp_reset_postdata();
|
43 |
-
}
|
44 |
-
return 0;
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
/*
|
50 |
-
* Uses intermittent meta_key to determine the post ID. See functions/gb-post-meta.php and gwolle_gb_set_meta_keys().
|
51 |
-
*
|
52 |
-
* @return int postid if found, else 0.
|
53 |
-
*
|
54 |
-
* @since 2.4.0
|
55 |
-
*/
|
56 |
-
function gwolle_gb_get_postid_biggest_book() {
|
57 |
-
|
58 |
-
$postids = gwolle_gb_get_books();
|
59 |
-
if ( is_array($postids) && ! empty($postids) ) {
|
60 |
-
|
61 |
-
if ( count( $postids ) == 1 ) {
|
62 |
-
return $postids[0]; // just one guestbook, return it.
|
63 |
-
}
|
64 |
-
|
65 |
-
$books = array();
|
66 |
-
$totals = array();
|
67 |
-
foreach ( $postids as $postid ) {
|
68 |
-
$bookid = (int) get_post_meta( $postid, 'gwolle_gb_book_id', true );
|
69 |
-
if ( empty( $bookid ) ) {
|
70 |
-
continue;
|
71 |
-
}
|
72 |
-
$key = 'gwolle_gb_frontend_pagination_book_' . $bookid;
|
73 |
-
$entries_total = (int) get_transient( $key );
|
74 |
-
if ( false === $entries_total ) {
|
75 |
-
$entries_total = gwolle_gb_get_entry_count(
|
76 |
-
array(
|
77 |
-
'checked' => 'checked',
|
78 |
-
'trash' => 'notrash',
|
79 |
-
'spam' => 'nospam',
|
80 |
-
'book_id' => $bookid
|
81 |
-
)
|
82 |
-
);
|
83 |
-
set_transient( $key, $entries_total, DAY_IN_SECONDS );
|
84 |
-
}
|
85 |
-
$book = array();
|
86 |
-
$book['postid'] = $postid;
|
87 |
-
$book['bookid'] = $bookid;
|
88 |
-
$book['entries_total'] = $entries_total;
|
89 |
-
$books[] = $book;
|
90 |
-
$totals[] = $entries_total;
|
91 |
-
}
|
92 |
-
|
93 |
-
// First check what the biggest total is, then find the post_id that belongs to it.
|
94 |
-
rsort( $totals );
|
95 |
-
|
96 |
-
foreach ( $books as $book ) {
|
97 |
-
if ( $book['entries_total'] == $totals[0] ) {
|
98 |
-
return $book['postid'];
|
99 |
-
}
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
return 0;
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
/*
|
109 |
-
* Uses intermittent meta_key to determine the post IDs. See functions/gb-post-meta.php and gwolle_gb_set_meta_keys().
|
110 |
-
*
|
111 |
-
* @return array with post IDs that contain a guestbook.
|
112 |
-
*
|
113 |
-
* @since 2.4.0
|
114 |
-
*/
|
115 |
-
function gwolle_gb_get_books() {
|
116 |
-
|
117 |
-
$the_query = new WP_Query( array(
|
118 |
-
'post_type' => 'any',
|
119 |
-
'ignore_sticky_posts' => true, // do not use sticky posts.
|
120 |
-
'meta_query' => array(
|
121 |
-
array(
|
122 |
-
'key' => 'gwolle_gb_read',
|
123 |
-
'value' => 'true',
|
124 |
-
),
|
125 |
-
),
|
126 |
-
'update_post_term_cache' => false,
|
127 |
-
'update_post_meta_cache' => false
|
128 |
-
));
|
129 |
-
|
130 |
-
$postids = array();
|
131 |
-
if ( $the_query->have_posts() ) {
|
132 |
-
while ( $the_query->have_posts() ) : $the_query->the_post();
|
133 |
-
$postids[] = get_the_ID();
|
134 |
-
endwhile;
|
135 |
-
wp_reset_postdata();
|
136 |
-
}
|
137 |
-
|
138 |
-
return $postids;
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
/*
|
144 |
* Taken from wp-admin/includes/template.php touch_time()
|
145 |
* Adapted for simplicity.
|
|
|
|
|
146 |
*/
|
147 |
function gwolle_gb_touch_time( $entry ) {
|
148 |
global $wp_locale;
|
@@ -201,14 +70,13 @@ function gwolle_gb_touch_time( $entry ) {
|
|
201 |
* Use a custom field name for the form fields that are different for each website.
|
202 |
*
|
203 |
* @param string field name of the requested field.
|
204 |
-
*
|
205 |
-
* @return hashed fieldname or fieldname, prepended with gwolle_gb.
|
206 |
*
|
207 |
* @since 2.4.1
|
208 |
*/
|
209 |
function gwolle_gb_get_field_name( $field ) {
|
210 |
|
211 |
-
if ( ! in_array( $field, array('name', 'city', 'email', 'website', 'honeypot', 'nonce') ) ) {
|
212 |
return 'gwolle_gb_' . $field;
|
213 |
}
|
214 |
|
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;
|
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 |
|
functions/gb-post-meta.php
CHANGED
@@ -9,6 +9,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
9 |
|
10 |
/*
|
11 |
* Set meta_keys so we can find the post with the shortcode back.
|
|
|
|
|
12 |
*/
|
13 |
function gwolle_gb_save_post($id) {
|
14 |
|
@@ -46,7 +48,7 @@ add_action('save_post', 'gwolle_gb_save_post');
|
|
46 |
/*
|
47 |
* Make our meta fields protected, so they are not in the custom fields metabox.
|
48 |
*
|
49 |
-
*
|
50 |
*/
|
51 |
function gwolle_gb_is_protected_meta( $protected, $meta_key, $meta_type ) {
|
52 |
|
@@ -66,12 +68,12 @@ add_filter( 'is_protected_meta', 'gwolle_gb_is_protected_meta', 10, 3 );
|
|
66 |
|
67 |
/*
|
68 |
* Set Meta_keys so we can find the post with the shortcode back.
|
69 |
-
* Args: $shortcode, string with value 'write' or 'read'.
|
70 |
-
* $shortcode_atts, array with the shortcode attributes.
|
71 |
-
*
|
72 |
* Gets called from frontend/gb-shortcodes.php.
|
73 |
*
|
74 |
-
*
|
|
|
|
|
|
|
75 |
*/
|
76 |
function gwolle_gb_set_meta_keys( $shortcode, $shortcode_atts ) {
|
77 |
|
9 |
|
10 |
/*
|
11 |
* Set meta_keys so we can find the post with the shortcode back.
|
12 |
+
*
|
13 |
+
* @param int $id ID of the post
|
14 |
*/
|
15 |
function gwolle_gb_save_post($id) {
|
16 |
|
48 |
/*
|
49 |
* Make our meta fields protected, so they are not in the custom fields metabox.
|
50 |
*
|
51 |
+
* @since 2.1.5
|
52 |
*/
|
53 |
function gwolle_gb_is_protected_meta( $protected, $meta_key, $meta_type ) {
|
54 |
|
68 |
|
69 |
/*
|
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 |
*/
|
78 |
function gwolle_gb_set_meta_keys( $shortcode, $shortcode_atts ) {
|
79 |
|
functions/gb-settings.php
CHANGED
@@ -24,8 +24,10 @@ function gwolle_gb_register_settings() {
|
|
24 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-form_ajax', 'strval' ); // 'true'
|
25 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-header', 'strval' ); // string, but initially empty
|
26 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-honeypot', 'strval' ); // 'true'
|
|
|
27 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-labels_float', 'strval' ); // 'true'
|
28 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-linkAuthorWebsite', 'strval' ); // 'true'
|
|
|
29 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-longtext', 'strval' ); // 'true'
|
30 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-mail-from', 'strval' ); // empty string
|
31 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-mail_admin_replyContent', 'strval' ); // 'false'
|
@@ -44,6 +46,7 @@ function gwolle_gb_register_settings() {
|
|
44 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-showEntryIcons', 'strval' ); // 'true'
|
45 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-showLineBreaks', 'strval' ); // 'false'
|
46 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-showSmilies', 'strval' ); // 'true'
|
|
|
47 |
register_setting( 'gwolle_gb_options', 'gwolle_gb_version', 'strval' ); // string, mind the underscore
|
48 |
}
|
49 |
add_action( 'admin_init', 'gwolle_gb_register_settings' );
|
@@ -52,9 +55,9 @@ add_action( 'admin_init', 'gwolle_gb_register_settings' );
|
|
52 |
/*
|
53 |
* Get the setting for Gwolle-GB that is saved as serialized data.
|
54 |
*
|
55 |
-
*
|
56 |
*
|
57 |
-
*
|
58 |
* - Array with settings for that request.
|
59 |
* - or false if no setting.
|
60 |
*/
|
24 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-form_ajax', 'strval' ); // 'true'
|
25 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-header', 'strval' ); // string, but initially empty
|
26 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-honeypot', 'strval' ); // 'true'
|
27 |
+
register_setting( 'gwolle_gb_options', 'gwolle_gb-honeypot_value', 'intval' ); // random 1 - 100
|
28 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-labels_float', 'strval' ); // 'true'
|
29 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-linkAuthorWebsite', 'strval' ); // 'true'
|
30 |
+
register_setting( 'gwolle_gb_options', 'gwolle_gb-linkchecker', 'strval' ); // 'true'
|
31 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-longtext', 'strval' ); // 'true'
|
32 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-mail-from', 'strval' ); // empty string
|
33 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-mail_admin_replyContent', 'strval' ); // 'false'
|
46 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-showEntryIcons', 'strval' ); // 'true'
|
47 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-showLineBreaks', 'strval' ); // 'false'
|
48 |
register_setting( 'gwolle_gb_options', 'gwolle_gb-showSmilies', 'strval' ); // 'true'
|
49 |
+
register_setting( 'gwolle_gb_options', 'gwolle_gb-timeout', 'strval' ); // 'true'
|
50 |
register_setting( 'gwolle_gb_options', 'gwolle_gb_version', 'strval' ); // string, mind the underscore
|
51 |
}
|
52 |
add_action( 'admin_init', 'gwolle_gb_register_settings' );
|
55 |
/*
|
56 |
* Get the setting for Gwolle-GB that is saved as serialized data.
|
57 |
*
|
58 |
+
* @param string $request value 'form' or 'read'.
|
59 |
*
|
60 |
+
* @return
|
61 |
* - Array with settings for that request.
|
62 |
* - or false if no setting.
|
63 |
*/
|
functions/gb-single-view.php
CHANGED
@@ -11,10 +11,9 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
11 |
* Give a single view of the entry.
|
12 |
* Uses the template 'gwolle_gb-entry.php', either in the themedir or the plugin.
|
13 |
*
|
14 |
-
* @param $entry
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
* @return string with html formatted entry.
|
19 |
*
|
20 |
* @since 2.3.0
|
11 |
* Give a single view of the entry.
|
12 |
* Uses the template 'gwolle_gb-entry.php', either in the themedir or the plugin.
|
13 |
*
|
14 |
+
* @param object $entry instance of the class gb_entry.
|
15 |
+
* @param bool $first if it is the first entry in the list
|
16 |
+
* @param int $counter the number in the list.
|
|
|
17 |
* @return string with html formatted entry.
|
18 |
*
|
19 |
* @since 2.3.0
|
functions/gb-stop-forum-spam.php
CHANGED
@@ -15,10 +15,8 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
15 |
/*
|
16 |
* Check the $entry against Stop Forum Spam service
|
17 |
*
|
18 |
-
*
|
19 |
-
*
|
20 |
-
*
|
21 |
-
* Return: true or false
|
22 |
*
|
23 |
* @since 2.3.0
|
24 |
*/
|
15 |
/*
|
16 |
* Check the $entry against Stop Forum Spam service
|
17 |
*
|
18 |
+
* @param object $entry instance of gb_entry class
|
19 |
+
* @return bool true or false
|
|
|
|
|
20 |
*
|
21 |
* @since 2.3.0
|
22 |
*/
|
functions/gb-user.php
CHANGED
@@ -8,13 +8,10 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
8 |
|
9 |
|
10 |
/*
|
11 |
-
* Is User also Author of the entry
|
12 |
*
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* Return:
|
16 |
-
* - true if author
|
17 |
-
* - false if not author
|
18 |
*
|
19 |
* @since 2.3.0
|
20 |
*/
|
@@ -33,13 +30,12 @@ function gwolle_gb_is_author( $entry ) {
|
|
33 |
|
34 |
|
35 |
/*
|
36 |
-
* Is User allowed to manage comments
|
37 |
-
*
|
38 |
-
* Args: $user_id
|
39 |
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
* -
|
|
|
43 |
*/
|
44 |
function gwolle_gb_is_moderator($user_id) {
|
45 |
|
@@ -63,7 +59,7 @@ function gwolle_gb_is_moderator($user_id) {
|
|
63 |
/*
|
64 |
* Get all the users with capability 'moderate_comments'.
|
65 |
*
|
66 |
-
*
|
67 |
*/
|
68 |
function gwolle_gb_get_moderators() {
|
69 |
|
@@ -102,8 +98,10 @@ function gwolle_gb_get_moderators() {
|
|
102 |
|
103 |
|
104 |
/*
|
105 |
-
* Delete author_id (and maybe checkedby) after deletion of user.
|
106 |
-
* Will trim down db requests, because non-existent
|
|
|
|
|
107 |
*/
|
108 |
function gwolle_gb_deleted_user( $user_id ) {
|
109 |
$entries = gwolle_gb_get_entries(array(
|
@@ -123,9 +121,8 @@ add_action( 'deleted_user', 'gwolle_gb_deleted_user' );
|
|
123 |
/*
|
124 |
* Get Author name in the right format as html
|
125 |
*
|
126 |
-
*
|
127 |
-
*
|
128 |
-
* Return: $author_name_html string with html
|
129 |
*/
|
130 |
function gwolle_gb_get_author_name_html($entry) {
|
131 |
|
8 |
|
9 |
|
10 |
/*
|
11 |
+
* Is User also Author of the entry.
|
12 |
*
|
13 |
+
* @param object $entry instance of gwolle_gb_entry
|
14 |
+
* @return bool true if author, false if not author
|
|
|
|
|
|
|
15 |
*
|
16 |
* @since 2.3.0
|
17 |
*/
|
30 |
|
31 |
|
32 |
/*
|
33 |
+
* Is User allowed to manage comments.
|
|
|
|
|
34 |
*
|
35 |
+
* $param int $user_id ID of the user in question.
|
36 |
+
* @return
|
37 |
+
* - string user_nicename or user_login if allowed
|
38 |
+
* - bool false if not allowed
|
39 |
*/
|
40 |
function gwolle_gb_is_moderator($user_id) {
|
41 |
|
59 |
/*
|
60 |
* Get all the users with capability 'moderate_comments'.
|
61 |
*
|
62 |
+
* @return array User objects.
|
63 |
*/
|
64 |
function gwolle_gb_get_moderators() {
|
65 |
|
98 |
|
99 |
|
100 |
/*
|
101 |
+
* Delete author_id (and maybe checkedby) from stored entries after deletion of user.
|
102 |
+
* Will trim down db requests, because non-existent users do not get cached.
|
103 |
+
*
|
104 |
+
* @param int $user_id ID of the deleted user.
|
105 |
*/
|
106 |
function gwolle_gb_deleted_user( $user_id ) {
|
107 |
$entries = gwolle_gb_get_entries(array(
|
121 |
/*
|
122 |
* Get Author name in the right format as html
|
123 |
*
|
124 |
+
* @param object $entry instance of gb_entry class.
|
125 |
+
* @return string $author_name_html html with formatted username
|
|
|
126 |
*/
|
127 |
function gwolle_gb_get_author_name_html($entry) {
|
128 |
|
gwolle-gb-hooks.php
CHANGED
@@ -135,7 +135,8 @@ add_action('admin_init', 'gwolle_gb_init');
|
|
135 |
|
136 |
/*
|
137 |
* Install database tables for new blog on MultiSite.
|
138 |
-
*
|
|
|
139 |
*/
|
140 |
function gwolle_gb_activate_new_site($blog_id) {
|
141 |
switch_to_blog($blog_id);
|
@@ -148,7 +149,9 @@ add_action( 'wpmu_new_blog', 'gwolle_gb_activate_new_site' );
|
|
148 |
/*
|
149 |
* Support uninstall for MultiSite through a filter.
|
150 |
* Take Note: This will do an uninstall on all sites.
|
151 |
-
*
|
|
|
|
|
152 |
*/
|
153 |
function gwolle_gb_multisite_uninstall() {
|
154 |
global $wpdb;
|
@@ -171,7 +174,7 @@ function gwolle_gb_multisite_uninstall() {
|
|
171 |
}
|
172 |
}
|
173 |
}
|
174 |
-
add_action('
|
175 |
|
176 |
|
177 |
/*
|
@@ -188,7 +191,11 @@ function gwolle_gb_register() {
|
|
188 |
$dataToBePassed = array(
|
189 |
'ajax_url' => admin_url('admin-ajax.php'),
|
190 |
'load_message' => /* translators: Infinite Scroll */ esc_html__('Loading more...', 'gwolle-gb'),
|
191 |
-
'end_message' => /* translators: Infinite Scroll */ esc_html__('No more entries.', 'gwolle-gb')
|
|
|
|
|
|
|
|
|
192 |
);
|
193 |
wp_localize_script( 'gwolle_gb_frontend_js', 'gwolle_gb_frontend_script', $dataToBePassed );
|
194 |
|
135 |
|
136 |
/*
|
137 |
* Install database tables for new blog on MultiSite.
|
138 |
+
*
|
139 |
+
* @since 1.5.2
|
140 |
*/
|
141 |
function gwolle_gb_activate_new_site($blog_id) {
|
142 |
switch_to_blog($blog_id);
|
149 |
/*
|
150 |
* Support uninstall for MultiSite through a filter.
|
151 |
* Take Note: This will do an uninstall on all sites.
|
152 |
+
* Only run on admin_init, no need for the frontend.
|
153 |
+
*
|
154 |
+
* @since 2.1.0
|
155 |
*/
|
156 |
function gwolle_gb_multisite_uninstall() {
|
157 |
global $wpdb;
|
174 |
}
|
175 |
}
|
176 |
}
|
177 |
+
add_action('admin_init', 'gwolle_gb_multisite_uninstall', 99);
|
178 |
|
179 |
|
180 |
/*
|
191 |
$dataToBePassed = array(
|
192 |
'ajax_url' => admin_url('admin-ajax.php'),
|
193 |
'load_message' => /* translators: Infinite Scroll */ esc_html__('Loading more...', 'gwolle-gb'),
|
194 |
+
'end_message' => /* translators: Infinite Scroll */ esc_html__('No more entries.', 'gwolle-gb'),
|
195 |
+
'honeypot' => gwolle_gb_get_field_name( 'honeypot' ),
|
196 |
+
'honeypot2' => gwolle_gb_get_field_name( 'honeypot2' ),
|
197 |
+
'timeout' => gwolle_gb_get_field_name( 'timeout' ),
|
198 |
+
'timeout2' => gwolle_gb_get_field_name( 'timeout2' )
|
199 |
);
|
200 |
wp_localize_script( 'gwolle_gb_frontend_js', 'gwolle_gb_frontend_script', $dataToBePassed );
|
201 |
|
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.
|
7 |
Author: Marcel Pol
|
8 |
Author URI: http://zenoweb.nl
|
9 |
License: GPLv2 or later
|
@@ -32,7 +32,7 @@ Domain Path: /lang/
|
|
32 |
|
33 |
|
34 |
// Plugin Version
|
35 |
-
define('GWOLLE_GB_VER', '2.
|
36 |
|
37 |
|
38 |
/*
|
@@ -51,10 +51,9 @@ define('GWOLLE_GB_VER', '2.4.2');
|
|
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 |
-
* - Add datetime WHERE clause in get_functions? Support filter for the function parameters inside the function?
|
55 |
* - Think about a cancel button for the form:
|
56 |
* https://wordpress.org/support/topic/missing-cancel-button-in-new-entry-from/
|
57 |
-
* Consider
|
58 |
* - Better support for aria attributes.
|
59 |
* - Add proper docblocks to filters in the code.
|
60 |
* - Use GWOLLE_GB_URL where appropriate.
|
@@ -62,6 +61,10 @@ define('GWOLLE_GB_VER', '2.4.2');
|
|
62 |
* - Really switch to InnoDB.
|
63 |
* - Consider SQL IN when emptying spam/trash.
|
64 |
* - Support mark-as-spam and mark-as-ham for Stop Forum Spam.
|
|
|
|
|
|
|
|
|
65 |
*
|
66 |
*/
|
67 |
|
@@ -123,6 +126,7 @@ include_once( GWOLLE_GB_DIR . '/admin/tabs/gb-uninstalltab.php' );
|
|
123 |
// General Functions
|
124 |
include_once( GWOLLE_GB_DIR . '/functions/gb-akismet.php' );
|
125 |
include_once( GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php' );
|
|
|
126 |
include_once( GWOLLE_GB_DIR . '/functions/gb-cache.php' );
|
127 |
include_once( GWOLLE_GB_DIR . '/functions/gb-debug.php' );
|
128 |
include_once( GWOLLE_GB_DIR . '/functions/gb-formatting.php' );
|
3 |
Plugin Name: Gwolle Guestbook
|
4 |
Plugin URI: http://zenoweb.nl
|
5 |
Description: Gwolle Guestbook is not just another guestbook for WordPress. The goal is to provide an easy and slim way to integrate a guestbook into your WordPress powered site. Don't use your 'comment' section the wrong way - install Gwolle Guestbook and have a real guestbook.
|
6 |
+
Version: 2.5.0
|
7 |
Author: Marcel Pol
|
8 |
Author URI: http://zenoweb.nl
|
9 |
License: GPLv2 or later
|
32 |
|
33 |
|
34 |
// Plugin Version
|
35 |
+
define('GWOLLE_GB_VER', '2.5.0');
|
36 |
|
37 |
|
38 |
/*
|
51 |
* - Localize admin ajax script.
|
52 |
* - Add Filter for get_entry_count SQL, like get_entries.
|
53 |
* - Add filters similar to pre_get_posts.
|
|
|
54 |
* - Think about a cancel button for the form:
|
55 |
* https://wordpress.org/support/topic/missing-cancel-button-in-new-entry-from/
|
56 |
+
* Consider making the messages and the expanded form dismissible with an 'x' and a jQuery.slideUp().
|
57 |
* - Better support for aria attributes.
|
58 |
* - Add proper docblocks to filters in the code.
|
59 |
* - Use GWOLLE_GB_URL where appropriate.
|
61 |
* - Really switch to InnoDB.
|
62 |
* - Consider SQL IN when emptying spam/trash.
|
63 |
* - Support mark-as-spam and mark-as-ham for Stop Forum Spam.
|
64 |
+
* - Consider adding a checkbox to honeypot.
|
65 |
+
* - Emoji: Sinterklaas and Zwarte Piet.
|
66 |
+
* - Add %privacy_policy% to form notice. Use a WP Core function to get it. Remove %ip% from default text.
|
67 |
+
* - Someday, do something with the REST API. Someday.
|
68 |
*
|
69 |
*/
|
70 |
|
126 |
// General Functions
|
127 |
include_once( GWOLLE_GB_DIR . '/functions/gb-akismet.php' );
|
128 |
include_once( GWOLLE_GB_DIR . '/functions/gb-bbcode_emoji.php' );
|
129 |
+
include_once( GWOLLE_GB_DIR . '/functions/gb-book_id.php' );
|
130 |
include_once( GWOLLE_GB_DIR . '/functions/gb-cache.php' );
|
131 |
include_once( GWOLLE_GB_DIR . '/functions/gb-debug.php' );
|
132 |
include_once( GWOLLE_GB_DIR . '/functions/gb-formatting.php' );
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Gwolle Guestbook ===
|
2 |
Contributors: Gwolle, mpol
|
3 |
-
Tags: guestbook, guest book, livre d'or, Gästebuch,
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 2.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
Gwolle Guestbook is the WordPress guestbook you've just been looking for. Beautiful and easy.
|
@@ -86,6 +86,7 @@ Current features include:
|
|
86 |
* Permalink button in each entry for easy access (optional).
|
87 |
* Email button to contact each author (optional).
|
88 |
* Sitemap support for popular SEO/Sitemap plugins.
|
|
|
89 |
|
90 |
You can buy the Add-On at [Mojo Marketplace](http://www.mojomarketplace.com/item/gwolle-gb-add-on) for only $ 9.
|
91 |
|
@@ -404,6 +405,22 @@ But if you don't use standard comments, you can just as easily use the comment s
|
|
404 |
|
405 |
== Changelog ==
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
= 2.4.2 =
|
408 |
* 2018-03-30
|
409 |
* Close div element correctly.
|
1 |
=== Gwolle Guestbook ===
|
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.5.0
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
Gwolle Guestbook is the WordPress guestbook you've just been looking for. Beautiful and easy.
|
86 |
* Permalink button in each entry for easy access (optional).
|
87 |
* Email button to contact each author (optional).
|
88 |
* Sitemap support for popular SEO/Sitemap plugins.
|
89 |
+
* Auto Delete timer (optional).
|
90 |
|
91 |
You can buy the Add-On at [Mojo Marketplace](http://www.mojomarketplace.com/item/gwolle-gb-add-on) for only $ 9.
|
92 |
|
405 |
|
406 |
== Changelog ==
|
407 |
|
408 |
+
= 2.5.0 =
|
409 |
+
* 2018-04-13
|
410 |
+
* Improve custom quiz question.
|
411 |
+
* Improve and extend Honeypot anti-spam.
|
412 |
+
* Add Link Checker for anti-spam.
|
413 |
+
* Add timeout for submitting the form for anti-spam.
|
414 |
+
* Do not send IP Address to Akismet if disabled.
|
415 |
+
* Add 'date_query' parameter to 'gwolle_gb_get_entries' function.
|
416 |
+
* Set default settings upon install/upgrade, so we can cache them.
|
417 |
+
* Add action 'gwolle_gb_uninstall'.
|
418 |
+
* Switch multisite uninstall to 'admin_init' hook.
|
419 |
+
* Flush transients from cache if no book_id is set.
|
420 |
+
* Switch export to 3000 entries per part instead of 5000.
|
421 |
+
* New file '/functions/gb-book_id.php'.
|
422 |
+
* Improve comment blocks for functions.
|
423 |
+
|
424 |
= 2.4.2 =
|
425 |
* 2018-03-30
|
426 |
* Close div element correctly.
|