Version Description
- 2019-01-22
- Add search widget (only visible on guestbook pages).
- Add '[noscript]' to frontend form for when JavaScript is disabled.
- Add function 'gwolle_gb_post_is_guestbook'.
- Add function 'gwolle_gb_get_entries_from_search'.
- Add function 'gwolle_gb_enqueue_markitup'.
- Fix BBcode: support images inside links.
- Fix BBcode: have sublists work.
- Show new username and book ID after editing in editor postbox.
- Add some accessibility fixes.
- Switch database engine to InnoDB.
- Don't use transients for hashed field names, is faster this way.
- Better test if admin user exists for admin_reply.
- Use 'field-name' for gwolle_gb_content too.
- On admin pages, have separate functions for $_POST update. (settings, editor, entries).
- Use GWOLLE_GB_URL where appropriate.
- Use static vars instead of global vars.
- Integrate 2 JavaScript files for Markitup/BBcode.
- Switch export to 2000 entries per part instead of 3000.
- Add strings for add-on 1.3.0.
- Cleanup changelog. Add changelog-v2.txt.
Download this release
Release Info
Developer | mpol |
Plugin | ![]() |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.6.7 to 3.0.0
- add-on/gb-add-on.php +4 -0
- admin/css/gwolle-gb-admin.css +2 -2
- admin/gb-ajax-management.php +4 -4
- admin/gb-page-editor.php +438 -356
- admin/gb-page-entries.php +320 -301
- admin/gb-page-export.php +5 -5
- admin/gb-page-import.php +4 -6
- admin/gb-page-settings.php +126 -174
- admin/gb-upgrade.php +18 -5
- admin/gfx/{entry-admin_reply.png → entry-admin-reply.png} +0 -0
- admin/gwolle-gb-hooks.php +2 -2
- admin/js/gwolle-gb-admin.js +13 -6
- admin/tabs/gb-debugtab.php +8 -3
- admin/tabs/gb-uninstalltab.php +3 -29
- changelog-v2.txt +330 -0
- docs/filters/gwolle_gb_widget_search.txt +27 -0
- frontend/{gb-ajax-infinite_scroll.php → gb-ajax-infinite-scroll.php} +0 -0
- frontend/gb-form.php +9 -24
- frontend/gb-pagination.php +8 -2
- frontend/gb-read.php +51 -13
- frontend/gb-rss.php +0 -1
- frontend/gb-total.php +17 -5
- frontend/gb-widget-search.php +113 -0
- frontend/gb-widget.php +1 -1
- frontend/gwolle_gb-entry.php +7 -5
- frontend/js/gwolle-gb-frontend.js +3 -3
- frontend/markitup/jquery.markitup.js +68 -0
- frontend/markitup/set.js +0 -67
- functions/gb-bbcode_emoji.php +12 -4
- functions/gb-fields.php +30 -0
- functions/gb-get_entries.php +114 -8
- functions/gb-get_entries_from_search.php +317 -0
- functions/gb-get_entry_count.php +0 -116
- functions/gb-log.php +21 -21
- functions/gb-messages.php +96 -50
- functions/gb-misc.php +0 -93
- functions/gb-post-meta.php +23 -2
- gwolle-gb-hooks.php +27 -3
- gwolle-gb.php +14 -22
- readme.txt +35 -329
add-on/gb-add-on.php
CHANGED
@@ -136,6 +136,10 @@ Entry content:
|
|
136 |
|
137 |
|
138 |
// function gwolle_gb_addon_page_settingstab_misc() {
|
|
|
|
|
|
|
|
|
139 |
/* translators: Settings page, option for permalink */
|
140 |
esc_html_e('Permalink', 'gwolle-gb');
|
141 |
/* translators: Commercial Add-On */
|
136 |
|
137 |
|
138 |
// function gwolle_gb_addon_page_settingstab_misc() {
|
139 |
+
/* translators: Settings page, option for preview */
|
140 |
+
esc_html_e('Show Preview button in Form.', 'gwolle-gb');
|
141 |
+
/* translators: Settings page, option for preview */
|
142 |
+
esc_html_e('Adds a button to the form where visitors can preview their entry before posting.', 'gwolle-gb');
|
143 |
/* translators: Settings page, option for permalink */
|
144 |
esc_html_e('Permalink', 'gwolle-gb');
|
145 |
/* translators: Commercial Add-On */
|
admin/css/gwolle-gb-admin.css
CHANGED
@@ -85,7 +85,7 @@ body #dashboard-widgets .postbox#gwolle_gb_notification ul {
|
|
85 |
margin-top: 1em;
|
86 |
}
|
87 |
|
88 |
-
#gwolle_gb_editor .
|
89 |
display: none;
|
90 |
}
|
91 |
|
@@ -222,7 +222,7 @@ span.book-icon a {
|
|
222 |
width: 16px;
|
223 |
height: 16px;
|
224 |
margin-right: 5px;
|
225 |
-
background-image: url('../gfx/entry-
|
226 |
}
|
227 |
|
228 |
/* AJAX */
|
85 |
margin-top: 1em;
|
86 |
}
|
87 |
|
88 |
+
#gwolle_gb_editor .gwolle_gb_editor_meta_inputs {
|
89 |
display: none;
|
90 |
}
|
91 |
|
222 |
width: 16px;
|
223 |
height: 16px;
|
224 |
margin-right: 5px;
|
225 |
+
background-image: url('../gfx/entry-admin-reply.png');
|
226 |
}
|
227 |
|
228 |
/* AJAX */
|
admin/gb-ajax-management.php
CHANGED
@@ -234,13 +234,13 @@ function gwolle_gb_ajax_javascript() {
|
|
234 |
if ( jQuery( '.gwolle_gb_actions' ).hasClass('checked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
|
235 |
jQuery( '.entry-icons' ).addClass('visible').removeClass('invisible');
|
236 |
jQuery( '.gwolle_gb_actions' ).addClass('visible').removeClass('invisible');
|
237 |
-
jQuery( '.
|
238 |
-
jQuery( '.
|
239 |
} else {
|
240 |
jQuery( '.entry-icons' ).addClass('invisible').removeClass('visible');
|
241 |
jQuery( '.gwolle_gb_actions' ).addClass('invisible').removeClass('visible');
|
242 |
-
jQuery( '.
|
243 |
-
jQuery( '.
|
244 |
}
|
245 |
|
246 |
// Countup counter in admin menu, toolbar
|
234 |
if ( jQuery( '.gwolle_gb_actions' ).hasClass('checked') && jQuery( '.gwolle_gb_actions' ).hasClass('nospam') && jQuery( '.gwolle_gb_actions' ).hasClass('notrash') ) {
|
235 |
jQuery( '.entry-icons' ).addClass('visible').removeClass('invisible');
|
236 |
jQuery( '.gwolle_gb_actions' ).addClass('visible').removeClass('invisible');
|
237 |
+
jQuery( '.h3-invisible' ).css('display', 'none');
|
238 |
+
jQuery( '.h3-visible' ).css('display', 'block');
|
239 |
} else {
|
240 |
jQuery( '.entry-icons' ).addClass('invisible').removeClass('visible');
|
241 |
jQuery( '.gwolle_gb_actions' ).addClass('invisible').removeClass('visible');
|
242 |
+
jQuery( '.h3-visible' ).css('display', 'none');
|
243 |
+
jQuery( '.h3-invisible' ).css('display', 'block');
|
244 |
}
|
245 |
|
246 |
// Countup counter in admin menu, toolbar
|
admin/gb-page-editor.php
CHANGED
@@ -13,18 +13,15 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
13 |
* Admin page with the entry editor. Used for new and existing entries.
|
14 |
*/
|
15 |
function gwolle_gb_page_editor() {
|
16 |
-
global $entry;
|
17 |
|
18 |
-
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) {
|
19 |
die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
|
20 |
}
|
21 |
|
22 |
gwolle_gb_admin_enqueue();
|
23 |
gwolle_gb_register();
|
24 |
|
25 |
-
$gwolle_gb_errors =
|
26 |
-
$gwolle_gb_messages = '';
|
27 |
-
|
28 |
$sectionHeading = esc_html__('Edit guestbook entry', 'gwolle-gb');
|
29 |
|
30 |
// Always fetch the requested entry, so we can compare the $entry and the $_POST.
|
@@ -38,287 +35,26 @@ function gwolle_gb_page_editor() {
|
|
38 |
if ( isset($entry_id) && $entry_id > 0 ) {
|
39 |
$result = $entry->load( $entry_id );
|
40 |
if ( ! $result ) {
|
41 |
-
|
42 |
-
$gwolle_gb_errors =
|
43 |
$sectionHeading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
|
44 |
}
|
45 |
} else {
|
46 |
$sectionHeading = esc_html__('New guestbook entry', 'gwolle-gb');
|
47 |
}
|
48 |
|
49 |
-
|
50 |
/*
|
51 |
* Handle the $_POST
|
52 |
*/
|
53 |
-
if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'editor' && $gwolle_gb_errors
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
} else {
|
62 |
-
// Nonce is invalid, so considered spam
|
63 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
|
64 |
-
$gwolle_gb_errors = 'error';
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
if ( !isset($_POST['entry_id']) || $_POST['entry_id'] != $entry->get_id() ) {
|
69 |
-
$gwolle_gb_messages .= '<p class="error">' . esc_html__('Something strange happened.', 'gwolle-gb') . '</p>';
|
70 |
-
$gwolle_gb_errors = 'error';
|
71 |
-
} else if ( $_POST['entry_id'] > 0 && $entry->get_id() > 0 && $continue_on_nonce_checked ) {
|
72 |
-
|
73 |
-
/* Set as checked or unchecked, and by whom */
|
74 |
-
if ( isset($_POST['ischecked']) && $_POST['ischecked'] == 'on' ) {
|
75 |
-
if ( $_POST['ischecked'] == 'on' && $entry->get_ischecked() == 0 ) {
|
76 |
-
$entry->set_ischecked( true );
|
77 |
-
$user_id = get_current_user_id(); // returns 0 if no current user
|
78 |
-
$entry->set_checkedby( $user_id );
|
79 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
|
80 |
-
gwolle_gb_clear_cache( $entry );
|
81 |
-
}
|
82 |
-
} else if ( $entry->get_ischecked() == 1 ) {
|
83 |
-
$entry->set_ischecked( false );
|
84 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
|
85 |
-
}
|
86 |
-
|
87 |
-
/* Set as spam or not, and submit as ham or spam to Akismet service */
|
88 |
-
if ( isset($_POST['isspam']) && $_POST['isspam'] == 'on' ) {
|
89 |
-
if ( $_POST['isspam'] == 'on' && $entry->get_isspam() == 0 ) {
|
90 |
-
$entry->set_isspam( true );
|
91 |
-
$result = gwolle_gb_akismet( $entry, 'submit-spam' );
|
92 |
-
if ( $result ) {
|
93 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>';
|
94 |
-
}
|
95 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
|
96 |
-
}
|
97 |
-
} else if ( $entry->get_isspam() == 1 ) {
|
98 |
-
$entry->set_isspam( false );
|
99 |
-
$result = gwolle_gb_akismet( $entry, 'submit-ham' );
|
100 |
-
if ( $result ) {
|
101 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>';
|
102 |
-
}
|
103 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
|
104 |
-
}
|
105 |
-
|
106 |
-
/* Set as trash or not */
|
107 |
-
if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' ) {
|
108 |
-
if ( $_POST['istrash'] == 'on' && $entry->get_istrash() == 0 ) {
|
109 |
-
$entry->set_istrash( true );
|
110 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
|
111 |
-
}
|
112 |
-
} else if ( $entry->get_istrash() == 1 ) {
|
113 |
-
$entry->set_istrash( false );
|
114 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
|
115 |
-
}
|
116 |
-
|
117 |
-
/* Check if the content changed, and update accordingly */
|
118 |
-
if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
|
119 |
-
if ( trim($_POST['gwolle_gb_content']) != $entry->get_content() ) {
|
120 |
-
$entry_content = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_content'], 'content' );
|
121 |
-
$entry->set_content( $entry_content );
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
/* Check if the website changed, and update accordingly */
|
126 |
-
if ( isset( $_POST['gwolle_gb_author_website'] ) ) {
|
127 |
-
$website = trim( $_POST['gwolle_gb_author_website'] );
|
128 |
-
} else {
|
129 |
-
$website = '';
|
130 |
-
}
|
131 |
-
if ( $website != $entry->get_author_website() ) {
|
132 |
-
$entry->set_author_website( $website );
|
133 |
-
}
|
134 |
-
|
135 |
-
/* Check if the author_origin changed, and update accordingly */
|
136 |
-
if ( isset($_POST['gwolle_gb_author_origin']) ) {
|
137 |
-
if ( $_POST['gwolle_gb_author_origin'] != $entry->get_author_origin() ) {
|
138 |
-
$entry_origin = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_origin'], 'author_origin' );
|
139 |
-
$entry->set_author_origin( $entry_origin );
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
/* Check if the admin_reply changed, and update and log accordingly */
|
144 |
-
if ( isset($_POST['gwolle_gb_admin_reply']) ) {
|
145 |
-
if ( trim($_POST['gwolle_gb_admin_reply']) != $entry->get_admin_reply() ) {
|
146 |
-
$gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
|
147 |
-
if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
|
148 |
-
$entry->set_admin_reply_uid( get_current_user_id() );
|
149 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
|
150 |
-
} else if ( $gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '' ) {
|
151 |
-
$entry->set_admin_reply_uid( 0 );
|
152 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-removed' );
|
153 |
-
} else if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '' ) {
|
154 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-updated' );
|
155 |
-
}
|
156 |
-
$entry->set_admin_reply( $gwolle_gb_admin_reply );
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
/* Mail the author about the Admin Reply, if so requested */
|
161 |
-
if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
|
162 |
-
if ( $_POST['gwolle_gb_admin_reply_mail_author'] == 'on' ) {
|
163 |
-
gwolle_gb_mail_author_on_admin_reply( $entry );
|
164 |
-
}
|
165 |
-
}
|
166 |
-
|
167 |
-
/* Check if the author_name changed, and update accordingly */
|
168 |
-
if ( isset($_POST['gwolle_gb_author_name']) ) {
|
169 |
-
if ( $_POST['gwolle_gb_author_name'] != $entry->get_author_name() ) {
|
170 |
-
$entry_name = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_name'], 'author_name' );
|
171 |
-
$entry->set_author_name( $entry_name );
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
/* Check if the datetime changed, and update accordingly */
|
176 |
-
if ( isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp']) ) {
|
177 |
-
if ( $_POST['gwolle_gb_timestamp'] != $entry->get_datetime() ) {
|
178 |
-
$entry->set_datetime( (int) $_POST['gwolle_gb_timestamp'] );
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
/* Check if the book_id changed, and update accordingly */
|
183 |
-
if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
|
184 |
-
if ( $_POST['gwolle_gb_book_id'] != $entry->get_book_id() ) {
|
185 |
-
$entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
/* Save the entry */
|
190 |
-
$result = $entry->save();
|
191 |
-
if ($result ) {
|
192 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
|
193 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>';
|
194 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
195 |
-
} else {
|
196 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>';
|
197 |
-
$gwolle_gb_errors = 'error';
|
198 |
-
}
|
199 |
-
|
200 |
-
|
201 |
-
/* Remove permanently */
|
202 |
-
if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' && isset($_POST['remove']) && $_POST['remove'] == 'on' ) {
|
203 |
-
if ( $entry->get_istrash() == 1 ) {
|
204 |
-
$entry->delete();
|
205 |
-
$entry->set_id(0);
|
206 |
-
$changed = true;
|
207 |
-
// Overwrite any other message, only removal is relevant.
|
208 |
-
$gwolle_gb_messages = '<p>' . esc_html__('Entry removed.', 'gwolle-gb') . '</p>';
|
209 |
-
$entry = new gwolle_gb_entry();
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
} else if ( $_POST['entry_id'] == 0 && $entry->get_id() == 0 && $continue_on_nonce_checked ) {
|
214 |
-
|
215 |
-
/*
|
216 |
-
* Check for input, and save accordingly. This is on a New Entry! (So no logging)
|
217 |
-
*/
|
218 |
-
|
219 |
-
$saved = false;
|
220 |
-
$data = Array();
|
221 |
-
|
222 |
-
/* Set as checked anyway, new entry is always by an admin */
|
223 |
-
$data['ischecked'] = true;
|
224 |
-
$user_id = get_current_user_id(); // returns 0 if no current user
|
225 |
-
$data['checkedby'] = $user_id;
|
226 |
-
$data['author_id'] = $user_id;
|
227 |
-
|
228 |
-
/* Set metadata of the admin */
|
229 |
-
$userdata = get_userdata( $user_id );
|
230 |
-
|
231 |
-
if (is_object($userdata)) {
|
232 |
-
if ( isset( $userdata->display_name ) ) {
|
233 |
-
$author_name = $userdata->display_name;
|
234 |
-
} else {
|
235 |
-
$author_name = $userdata->user_login;
|
236 |
-
}
|
237 |
-
$author_email = $userdata->user_email;
|
238 |
-
}
|
239 |
-
$data['author_name'] = $author_name;
|
240 |
-
$data['author_name'] = gwolle_gb_maybe_encode_emoji( $data['author_name'], 'author_name' );
|
241 |
-
$data['author_email'] = $author_email;
|
242 |
-
|
243 |
-
/* Set as Not Spam */
|
244 |
-
$data['isspam'] = false;
|
245 |
-
|
246 |
-
/* Do not set as trash */
|
247 |
-
$data['istrash'] = false;
|
248 |
-
|
249 |
-
/* Check if the content is filled in, and save accordingly */
|
250 |
-
if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
|
251 |
-
$data['content'] = $_POST['gwolle_gb_content'];
|
252 |
-
$data['content'] = gwolle_gb_maybe_encode_emoji( $data['content'], 'content' );
|
253 |
-
$saved = true;
|
254 |
-
} else {
|
255 |
-
$form_setting = gwolle_gb_get_setting( 'form' );
|
256 |
-
if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' && isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
|
257 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>';
|
258 |
-
$gwolle_gb_errors = 'error';
|
259 |
-
} else {
|
260 |
-
$data['content'] = '';
|
261 |
-
$saved = true;
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
/* Check if the website is set, and save accordingly */
|
266 |
-
if ( isset($_POST['gwolle_gb_author_website']) ) {
|
267 |
-
if ( $_POST['gwolle_gb_author_website'] != '' ) {
|
268 |
-
$data['author_website'] = $_POST['gwolle_gb_author_website'];
|
269 |
-
} else {
|
270 |
-
$data['author_website'] = home_url();
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
-
/* Check if the author_origin is set, and save accordingly */
|
275 |
-
if ( isset($_POST['gwolle_gb_author_origin']) ) {
|
276 |
-
if ( $_POST['gwolle_gb_author_origin'] != '' ) {
|
277 |
-
$data['author_origin'] = $_POST['gwolle_gb_author_origin'];
|
278 |
-
$data['author_origin'] = gwolle_gb_maybe_encode_emoji( $data['author_origin'], 'author_origin' );
|
279 |
-
}
|
280 |
-
}
|
281 |
-
|
282 |
-
/* Check if the admin_reply is set, and save accordingly */
|
283 |
-
if ( isset($_POST['gwolle_gb_admin_reply']) ) {
|
284 |
-
if ( $_POST['gwolle_gb_admin_reply'] != '' ) {
|
285 |
-
$data['admin_reply'] = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
|
286 |
-
$data['admin_reply_uid'] = get_current_user_id();
|
287 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
|
288 |
-
}
|
289 |
-
}
|
290 |
-
|
291 |
-
/* Check if the book_id is set, and save accordingly */
|
292 |
-
if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
|
293 |
-
$entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
|
294 |
-
}
|
295 |
-
|
296 |
-
/* Network Information */
|
297 |
-
$set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
|
298 |
-
$set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
|
299 |
-
if ( $set_author_ip && ($set_author_ip2 == 'true') ) {
|
300 |
-
$entry->set_author_ip( $_SERVER['REMOTE_ADDR'] );
|
301 |
-
$entry->set_author_host( gethostbyaddr( $_SERVER['REMOTE_ADDR'] ) );
|
302 |
-
}
|
303 |
-
|
304 |
-
$result1 = $entry->set_data( $data );
|
305 |
-
if ( $saved ) {
|
306 |
-
$result2 = $entry->save();
|
307 |
-
if ( $result1 && $result2 ) {
|
308 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Entry saved.', 'gwolle-gb') . '</p>';
|
309 |
-
gwolle_gb_clear_cache( $entry );
|
310 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
311 |
-
} else {
|
312 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>';
|
313 |
-
$gwolle_gb_errors = 'error';
|
314 |
-
}
|
315 |
-
} else {
|
316 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Entry was not saved.', 'gwolle-gb') . '</p>';
|
317 |
-
}
|
318 |
-
|
319 |
-
}
|
320 |
}
|
321 |
-
|
322 |
|
323 |
/*
|
324 |
* Build the Page and the Form
|
@@ -331,7 +67,7 @@ function gwolle_gb_page_editor() {
|
|
331 |
<?php
|
332 |
if ( $gwolle_gb_messages ) {
|
333 |
echo '
|
334 |
-
<div id="message" class="updated fade notice is-dismissible ' . $
|
335 |
$gwolle_gb_messages .
|
336 |
'</div>';
|
337 |
}
|
@@ -391,7 +127,7 @@ function gwolle_gb_page_editor() {
|
|
391 |
*/
|
392 |
function gwolle_gb_editor_postbox_content( $entry ) {
|
393 |
?>
|
394 |
-
<textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji"
|
395 |
<?php
|
396 |
if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
|
397 |
$settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
|
@@ -401,23 +137,7 @@ function gwolle_gb_editor_postbox_content( $entry ) {
|
|
401 |
$form_setting = gwolle_gb_get_setting( 'form' );
|
402 |
|
403 |
if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
|
404 |
-
|
405 |
-
wp_enqueue_script( 'markitup_set', plugins_url('../frontend/markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false );
|
406 |
-
wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('../frontend/markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
|
407 |
-
|
408 |
-
$dataToBePassed = array(
|
409 |
-
'bold' => /* translators: MarkItUp menu item */ esc_html__('Bold', 'gwolle-gb' ),
|
410 |
-
'italic' => /* translators: MarkItUp menu item */ esc_html__('Italic', 'gwolle-gb' ),
|
411 |
-
'bullet' => /* translators: MarkItUp menu item */ esc_html__('Bulleted List', 'gwolle-gb' ),
|
412 |
-
'numeric' => /* translators: MarkItUp menu item */ esc_html__('Numeric List', 'gwolle-gb' ),
|
413 |
-
'picture' => /* translators: MarkItUp menu item */ esc_html__('Picture', 'gwolle-gb' ),
|
414 |
-
'source' => /* translators: MarkItUp menu item */ esc_html__('Source', 'gwolle-gb' ),
|
415 |
-
'link' => /* translators: MarkItUp menu item */ esc_html__('Link', 'gwolle-gb' ),
|
416 |
-
'linktext' => /* translators: MarkItUp menu item */ esc_html__('Your text to link...', 'gwolle-gb' ),
|
417 |
-
'clean' => /* translators: MarkItUp menu item */ esc_html__('Clean', 'gwolle-gb' ),
|
418 |
-
'emoji' => /* translators: MarkItUp menu item */ esc_html__('Emoji', 'gwolle-gb' )
|
419 |
-
);
|
420 |
-
wp_localize_script( 'markitup_set', 'gwolle_gb_localize', $dataToBePassed );
|
421 |
|
422 |
// Emoji symbols
|
423 |
echo '<div class="gwolle_gb_emoji gwolle_gb_hide">';
|
@@ -437,7 +157,7 @@ function gwolle_gb_editor_postbox_content( $entry ) {
|
|
437 |
*/
|
438 |
function gwolle_gb_editor_postbox_website( $entry ) {
|
439 |
?>
|
440 |
-
<input type="url" name="gwolle_gb_author_website"
|
441 |
<p><?php
|
442 |
/* translators: %s is a code element */
|
443 |
echo sprintf( esc_html__('Example: %shttp://www.example.com/%s', 'gwolle-gb'), '<code>', '</code>' ); ?>
|
@@ -451,7 +171,7 @@ function gwolle_gb_editor_postbox_website( $entry ) {
|
|
451 |
*/
|
452 |
function gwolle_gb_editor_postbox_author_origin( $entry ) {
|
453 |
?>
|
454 |
-
<input type="text" name="gwolle_gb_author_origin"
|
455 |
<?php
|
456 |
}
|
457 |
|
@@ -463,7 +183,7 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
|
|
463 |
$form_setting = gwolle_gb_get_setting( 'form' );
|
464 |
?>
|
465 |
|
466 |
-
<textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" class="wp-exclude-emoji"
|
467 |
|
468 |
<?php
|
469 |
if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
|
@@ -482,7 +202,7 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
|
|
482 |
$admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
|
483 |
if ( $admin_reply_name ) { ?>
|
484 |
<p class="gb-admin_reply_uid"><?php
|
485 |
-
$admin_reply_header = '<em>' . esc_html__('Admin Reply by:', 'gwolle-gb')
|
486 |
echo apply_filters( 'gwolle_gb_admin_reply_header', $admin_reply_header, $entry );
|
487 |
?>
|
488 |
</p><?php
|
@@ -508,43 +228,8 @@ function gwolle_gb_editor_postbox_admin_reply( $entry ) {
|
|
508 |
* Metabox with the icons and checkboxes for quick glancing at the visibility of the entry.
|
509 |
*/
|
510 |
function gwolle_gb_editor_postbox_icons( $entry ) {
|
511 |
-
global $class;
|
512 |
-
|
513 |
-
$class = '';
|
514 |
-
// Attach 'spam' to class if the entry is spam
|
515 |
-
if ( $entry->get_isspam() === 1 ) {
|
516 |
-
$class .= ' spam';
|
517 |
-
} else {
|
518 |
-
$class .= ' nospam';
|
519 |
-
}
|
520 |
-
|
521 |
-
// Attach 'trash' to class if the entry is in trash
|
522 |
-
if ( $entry->get_istrash() === 1 ) {
|
523 |
-
$class .= ' trash';
|
524 |
-
} else {
|
525 |
-
$class .= ' notrash';
|
526 |
-
}
|
527 |
|
528 |
-
|
529 |
-
if ( $entry->get_ischecked() === 1 ) {
|
530 |
-
$class .= ' checked';
|
531 |
-
} else {
|
532 |
-
$class .= ' unchecked';
|
533 |
-
}
|
534 |
-
|
535 |
-
// Attach 'visible/invisible' to class
|
536 |
-
if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
|
537 |
-
$class .= ' invisible';
|
538 |
-
} else {
|
539 |
-
$class .= ' visible';
|
540 |
-
}
|
541 |
-
|
542 |
-
// Add admin-entry class to an entry from an admin
|
543 |
-
$author_id = $entry->get_author_id();
|
544 |
-
$is_moderator = gwolle_gb_is_moderator( $author_id );
|
545 |
-
if ( $is_moderator ) {
|
546 |
-
$class .= ' admin-entry';
|
547 |
-
}
|
548 |
|
549 |
$postid = gwolle_gb_get_postid( (int) $entry->get_book_id() );
|
550 |
if ( $postid ) {
|
@@ -574,17 +259,17 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
|
|
574 |
}
|
575 |
|
576 |
if ( $entry->get_id() == 0 ) {
|
577 |
-
echo '<h3 class="
|
578 |
} else {
|
579 |
if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
|
580 |
echo '
|
581 |
-
<h3 class="
|
582 |
-
<h3 class="
|
583 |
';
|
584 |
} else {
|
585 |
echo '
|
586 |
-
<h3 class="
|
587 |
-
<h3 class="
|
588 |
';
|
589 |
} ?>
|
590 |
|
@@ -629,7 +314,7 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
|
|
629 |
} ?>
|
630 |
|
631 |
<div id="publishing-action">
|
632 |
-
<input name="save" type="submit" class="button-primary" id="publish"
|
633 |
</div> <!-- .publishing-action -->
|
634 |
<div class="clear"></div>
|
635 |
<?php
|
@@ -640,7 +325,9 @@ function gwolle_gb_editor_postbox_icons( $entry ) {
|
|
640 |
* Metabox with quick actions for the entry (AJAX).
|
641 |
*/
|
642 |
function gwolle_gb_editor_postbox_actions( $entry ) {
|
643 |
-
|
|
|
|
|
644 |
if ( $entry->get_id() > 0 ) {
|
645 |
echo '
|
646 |
<p class="gwolle_gb_actions ' . $class . '">
|
@@ -677,7 +364,7 @@ function gwolle_gb_editor_postbox_actions( $entry ) {
|
|
677 |
function gwolle_gb_editor_postbox_details( $entry ) {
|
678 |
?>
|
679 |
<p>
|
680 |
-
<?php esc_html_e('Author', 'gwolle-gb'); ?>: <span><?php
|
681 |
if ( $entry->get_author_name() ) {
|
682 |
echo gwolle_gb_sanitize_output( $entry->get_author_name() );
|
683 |
} else {
|
@@ -691,7 +378,7 @@ function gwolle_gb_editor_postbox_details( $entry ) {
|
|
691 |
echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
|
692 |
} ?>
|
693 |
</span><br />
|
694 |
-
<?php esc_html_e('Date and time', 'gwolle-gb'); ?>: <span class="gb-datetime"><?php
|
695 |
if ( $entry->get_datetime() > 0 ) {
|
696 |
echo date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
|
697 |
echo date_i18n( get_option('time_format'), $entry->get_datetime() );
|
@@ -723,24 +410,15 @@ function gwolle_gb_editor_postbox_details( $entry ) {
|
|
723 |
echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
|
724 |
} ?>
|
725 |
</span><br />
|
726 |
-
<?php esc_html_e('Book', 'gwolle-gb'); ?>: <span><?php echo $entry->get_book_id(); ?>
|
727 |
</span><br />
|
728 |
<span class="gwolle_gb_edit_meta">
|
729 |
<a href="#" title="<?php esc_attr_e('Edit metadata', 'gwolle-gb'); ?>"><?php esc_html_e('Edit', 'gwolle-gb'); ?></a>
|
730 |
</span>
|
731 |
</p>
|
732 |
|
733 |
-
<div class="
|
734 |
-
|
735 |
-
<input type="text" name="gwolle_gb_author_name" size="24" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_name() ); ?>" id="gwolle_gb_author_name" class="wp-exclude-emoji" /><br />
|
736 |
-
|
737 |
-
<span><?php esc_html_e('Date and time', 'gwolle-gb'); ?>: </span><br />
|
738 |
-
<div class="gwolle_gb_date"><?php
|
739 |
-
gwolle_gb_touch_time( $entry ); ?>
|
740 |
-
</div>
|
741 |
-
|
742 |
-
<label for="gwolle_gb_book_id"><?php esc_html_e('Book ID', 'gwolle-gb'); ?>: </label><br />
|
743 |
-
<input type="text" name="gwolle_gb_book_id" size="4" value="<?php echo (int) $entry->get_book_id(); ?>" id="gwolle_gb_book_id" />
|
744 |
</div>
|
745 |
|
746 |
<?php
|
@@ -773,3 +451,407 @@ function gwolle_gb_editor_postbox_logs( $entry ) {
|
|
773 |
</ul>
|
774 |
<?php
|
775 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
* Admin page with the entry editor. Used for new and existing entries.
|
14 |
*/
|
15 |
function gwolle_gb_page_editor() {
|
|
|
16 |
|
17 |
+
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
18 |
die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
|
19 |
}
|
20 |
|
21 |
gwolle_gb_admin_enqueue();
|
22 |
gwolle_gb_register();
|
23 |
|
24 |
+
$gwolle_gb_errors = false;
|
|
|
|
|
25 |
$sectionHeading = esc_html__('Edit guestbook entry', 'gwolle-gb');
|
26 |
|
27 |
// Always fetch the requested entry, so we can compare the $entry and the $_POST.
|
35 |
if ( isset($entry_id) && $entry_id > 0 ) {
|
36 |
$result = $entry->load( $entry_id );
|
37 |
if ( ! $result ) {
|
38 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Entry could not be found.', 'gwolle-gb') . '</p>', true, false);
|
39 |
+
$gwolle_gb_errors = true;
|
40 |
$sectionHeading = esc_html__('Guestbook entry (error)', 'gwolle-gb');
|
41 |
}
|
42 |
} else {
|
43 |
$sectionHeading = esc_html__('New guestbook entry', 'gwolle-gb');
|
44 |
}
|
45 |
|
|
|
46 |
/*
|
47 |
* Handle the $_POST
|
48 |
*/
|
49 |
+
if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'editor' && $gwolle_gb_errors === false ) {
|
50 |
+
$entry = gwolle_gb_page_editor_update( $entry );
|
51 |
+
}
|
52 |
+
$gwolle_gb_messages = gwolle_gb_get_messages();
|
53 |
+
$gwolle_gb_errors = gwolle_gb_get_errors();
|
54 |
+
$messageclass = '';
|
55 |
+
if ( $gwolle_gb_errors ) {
|
56 |
+
$messageclass = 'error';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
|
|
58 |
|
59 |
/*
|
60 |
* Build the Page and the Form
|
67 |
<?php
|
68 |
if ( $gwolle_gb_messages ) {
|
69 |
echo '
|
70 |
+
<div id="message" class="updated fade notice is-dismissible ' . $messageclass . ' ">' .
|
71 |
$gwolle_gb_messages .
|
72 |
'</div>';
|
73 |
}
|
127 |
*/
|
128 |
function gwolle_gb_editor_postbox_content( $entry ) {
|
129 |
?>
|
130 |
+
<textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" class="wp-exclude-emoji" placeholder="<?php esc_html_e('Message', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_content(), 'content' ); ?></textarea>
|
131 |
<?php
|
132 |
if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
|
133 |
$settingslink = '<a href="' . admin_url( 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php' ) . '">';
|
137 |
$form_setting = gwolle_gb_get_setting( 'form' );
|
138 |
|
139 |
if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
|
140 |
+
gwolle_gb_enqueue_markitup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
// Emoji symbols
|
143 |
echo '<div class="gwolle_gb_emoji gwolle_gb_hide">';
|
157 |
*/
|
158 |
function gwolle_gb_editor_postbox_website( $entry ) {
|
159 |
?>
|
160 |
+
<input type="url" name="gwolle_gb_author_website" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_website() ); ?>" id="author_website" placeholder="<?php esc_attr_e('Website', 'gwolle-gb'); ?>" />
|
161 |
<p><?php
|
162 |
/* translators: %s is a code element */
|
163 |
echo sprintf( esc_html__('Example: %shttp://www.example.com/%s', 'gwolle-gb'), '<code>', '</code>' ); ?>
|
171 |
*/
|
172 |
function gwolle_gb_editor_postbox_author_origin( $entry ) {
|
173 |
?>
|
174 |
+
<input type="text" name="gwolle_gb_author_origin" class="wp-exclude-emoji" placeholder="<?php esc_attr_e('City', 'gwolle-gb'); ?>" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_origin() ); ?>" id="author_origin" />
|
175 |
<?php
|
176 |
}
|
177 |
|
183 |
$form_setting = gwolle_gb_get_setting( 'form' );
|
184 |
?>
|
185 |
|
186 |
+
<textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" class="wp-exclude-emoji" placeholder="<?php esc_attr_e('Admin Reply', 'gwolle-gb'); ?>"><?php echo gwolle_gb_sanitize_output( $entry->get_admin_reply(), 'admin_reply' ); ?></textarea>
|
187 |
|
188 |
<?php
|
189 |
if ( isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true' ) {
|
202 |
$admin_reply_name = gwolle_gb_is_moderator( $entry->get_admin_reply_uid() );
|
203 |
if ( $admin_reply_name ) { ?>
|
204 |
<p class="gb-admin_reply_uid"><?php
|
205 |
+
$admin_reply_header = '<em>' . sprintf( esc_html__('Admin Reply by: %s', 'gwolle-gb'), $admin_reply_name ) . '</em>';
|
206 |
echo apply_filters( 'gwolle_gb_admin_reply_header', $admin_reply_header, $entry );
|
207 |
?>
|
208 |
</p><?php
|
228 |
* Metabox with the icons and checkboxes for quick glancing at the visibility of the entry.
|
229 |
*/
|
230 |
function gwolle_gb_editor_postbox_icons( $entry ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
+
$class = gwolle_gb_editor_get_class( $entry );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
$postid = gwolle_gb_get_postid( (int) $entry->get_book_id() );
|
235 |
if ( $postid ) {
|
259 |
}
|
260 |
|
261 |
if ( $entry->get_id() == 0 ) {
|
262 |
+
echo '<h3 class="h3-invisible">' . esc_html__('This entry is not yet visible.', 'gwolle-gb') . '</h3>';
|
263 |
} else {
|
264 |
if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0 ) {
|
265 |
echo '
|
266 |
+
<h3 class="h3-visible">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
|
267 |
+
<h3 class="h3-invisible" style="display:none;">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
|
268 |
';
|
269 |
} else {
|
270 |
echo '
|
271 |
+
<h3 class="h3-visible" style="display:none;">' . esc_html__('This entry is Visible.', 'gwolle-gb') . '</h3>
|
272 |
+
<h3 class="h3-invisible">' . esc_html__('This entry is Not Visible.', 'gwolle-gb') . '</h3>
|
273 |
';
|
274 |
} ?>
|
275 |
|
314 |
} ?>
|
315 |
|
316 |
<div id="publishing-action">
|
317 |
+
<input name="save" type="submit" class="button-primary" id="publish" value="<?php esc_attr_e('Save', 'gwolle-gb'); ?>" />
|
318 |
</div> <!-- .publishing-action -->
|
319 |
<div class="clear"></div>
|
320 |
<?php
|
325 |
* Metabox with quick actions for the entry (AJAX).
|
326 |
*/
|
327 |
function gwolle_gb_editor_postbox_actions( $entry ) {
|
328 |
+
|
329 |
+
$class = gwolle_gb_editor_get_class( $entry );
|
330 |
+
|
331 |
if ( $entry->get_id() > 0 ) {
|
332 |
echo '
|
333 |
<p class="gwolle_gb_actions ' . $class . '">
|
364 |
function gwolle_gb_editor_postbox_details( $entry ) {
|
365 |
?>
|
366 |
<p>
|
367 |
+
<?php esc_html_e('Author', 'gwolle-gb'); ?>: <span class="gb-editor-author-name"><?php
|
368 |
if ( $entry->get_author_name() ) {
|
369 |
echo gwolle_gb_sanitize_output( $entry->get_author_name() );
|
370 |
} else {
|
378 |
echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
|
379 |
} ?>
|
380 |
</span><br />
|
381 |
+
<?php esc_html_e('Date and time', 'gwolle-gb'); ?>: <span class="gb-editor-datetime"><?php
|
382 |
if ( $entry->get_datetime() > 0 ) {
|
383 |
echo date_i18n( get_option('date_format'), $entry->get_datetime() ) . ', ';
|
384 |
echo date_i18n( get_option('time_format'), $entry->get_datetime() );
|
410 |
echo '<i>(' . esc_html__('Unknown', 'gwolle-gb') . ')</i>';
|
411 |
} ?>
|
412 |
</span><br />
|
413 |
+
<?php esc_html_e('Book', 'gwolle-gb'); ?>: <span class="gb-editor-book-id"><?php echo $entry->get_book_id(); ?>
|
414 |
</span><br />
|
415 |
<span class="gwolle_gb_edit_meta">
|
416 |
<a href="#" title="<?php esc_attr_e('Edit metadata', 'gwolle-gb'); ?>"><?php esc_html_e('Edit', 'gwolle-gb'); ?></a>
|
417 |
</span>
|
418 |
</p>
|
419 |
|
420 |
+
<div class="gwolle_gb_editor_meta_inputs">
|
421 |
+
<?php gwolle_gb_editor_meta_inputs( $entry ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
</div>
|
423 |
|
424 |
<?php
|
451 |
</ul>
|
452 |
<?php
|
453 |
}
|
454 |
+
|
455 |
+
|
456 |
+
/*
|
457 |
+
* Taken from wp-admin/includes/template.php touch_time()
|
458 |
+
* Adapted for simplicity.
|
459 |
+
*
|
460 |
+
* @param object $entry instance of the class gb_entry
|
461 |
+
*/
|
462 |
+
function gwolle_gb_editor_meta_inputs( $entry ) {
|
463 |
+
global $wp_locale;
|
464 |
+
|
465 |
+
?>
|
466 |
+
<label for="gwolle_gb_author_name"><?php esc_html_e('Author', 'gwolle-gb'); ?>: </label><br />
|
467 |
+
<input type="text" name="gwolle_gb_author_name" size="24" value="<?php echo gwolle_gb_sanitize_output( $entry->get_author_name() ); ?>" id="gwolle_gb_author_name" class="wp-exclude-emoji" /><br />
|
468 |
+
|
469 |
+
<span><?php esc_html_e('Date and time', 'gwolle-gb'); ?>: </span><br />
|
470 |
+
<div class="gwolle_gb_date"><?php
|
471 |
+
|
472 |
+
$date = $entry->get_datetime();
|
473 |
+
if ( ! $date ) {
|
474 |
+
$date = current_time('timestamp');
|
475 |
+
}
|
476 |
+
|
477 |
+
$dd = date( 'd', $date );
|
478 |
+
$mm = date( 'm', $date );
|
479 |
+
$yy = date( 'Y', $date );
|
480 |
+
$hh = date( 'H', $date );
|
481 |
+
$mn = date( 'i', $date );
|
482 |
+
|
483 |
+
// Day
|
484 |
+
echo '<label><span class="screen-reader-text">' . esc_html__( 'Day', 'gwolle-gb' ) . '</span><input type="text" id="dd" name="dd" value="' . $dd . '" size="2" maxlength="2" autocomplete="off" /></label>';
|
485 |
+
|
486 |
+
// Month
|
487 |
+
echo '<label for="mm"><span class="screen-reader-text">' . esc_html__( 'Month', 'gwolle-gb' ) . '</span><select id="mm" name="mm">\n';
|
488 |
+
for ( $i = 1; $i < 13; $i = $i +1 ) {
|
489 |
+
$monthnum = zeroise($i, 2);
|
490 |
+
echo "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
|
491 |
+
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
|
492 |
+
echo sprintf( esc_html__( '%1$s-%2$s', 'gwolle-gb' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
|
493 |
+
}
|
494 |
+
echo '</select></label>';
|
495 |
+
|
496 |
+
// Year
|
497 |
+
echo '<label for="yy"><span class="screen-reader-text">' . esc_html__( 'Year', 'gwolle-gb' ) . '</span><input type="text" id="yy" name="yy" value="' . $yy . '" size="4" maxlength="4" autocomplete="off" /></label>';
|
498 |
+
echo '<br />';
|
499 |
+
// Hour
|
500 |
+
echo '<label for="hh"><span class="screen-reader-text">' . esc_html__( 'Hour', 'gwolle-gb' ) . '</span><input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2" autocomplete="off" /></label>:';
|
501 |
+
// Minute
|
502 |
+
echo '<label for="mn"><span class="screen-reader-text">' . esc_html__( 'Minute', 'gwolle-gb' ) . '</span><input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2" autocomplete="off" /></label>';
|
503 |
+
?>
|
504 |
+
|
505 |
+
<div class="gwolle_gb_timestamp">
|
506 |
+
<!-- Clicking OK will place a timestamp here. -->
|
507 |
+
<input type="hidden" id="gwolle_gb_timestamp" name="gwolle_gb_timestamp" value="" />
|
508 |
+
</div>
|
509 |
+
</div>
|
510 |
+
|
511 |
+
<label for="gwolle_gb_book_id"><?php esc_html_e('Book ID', 'gwolle-gb'); ?>: </label><br />
|
512 |
+
<input type="text" name="gwolle_gb_book_id" size="4" value="<?php echo (int) $entry->get_book_id(); ?>" id="gwolle_gb_book_id" />
|
513 |
+
|
514 |
+
<p>
|
515 |
+
<a href="#" class="gwolle_gb_save_timestamp hide-if-no-js button" title="<?php esc_attr_e('Save the date and time', 'gwolle-gb'); ?>">
|
516 |
+
<?php esc_html_e('Save', 'gwolle-gb'); ?>
|
517 |
+
</a>
|
518 |
+
<a href="#" class="gwolle_gb_cancel_timestamp hide-if-no-js button-cancel" title="<?php esc_attr_e('Cancel saving date and time', 'gwolle-gb'); ?>">
|
519 |
+
<?php esc_html_e('Cancel', 'gwolle-gb'); ?>
|
520 |
+
</a>
|
521 |
+
</p>
|
522 |
+
|
523 |
+
<?php
|
524 |
+
}
|
525 |
+
|
526 |
+
|
527 |
+
/*
|
528 |
+
* Update admin page with the entry editor. Used for new and existing entries.
|
529 |
+
*
|
530 |
+
* @since 3.0.0
|
531 |
+
*/
|
532 |
+
function gwolle_gb_page_editor_update( $entry ) {
|
533 |
+
|
534 |
+
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
535 |
+
die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
|
536 |
+
}
|
537 |
+
|
538 |
+
/* Check Nonce */
|
539 |
+
$verified = false;
|
540 |
+
if ( isset($_POST['gwolle_gb_wpnonce']) ) {
|
541 |
+
$verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_editor' );
|
542 |
+
if ( $verified === false ) {
|
543 |
+
// Nonce is invalid, so considered spam
|
544 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
|
545 |
+
return $entry;
|
546 |
+
}
|
547 |
+
}
|
548 |
+
if ( $verified === false ) {
|
549 |
+
// Nonce is invalid.
|
550 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>', true, false);
|
551 |
+
return $entry;
|
552 |
+
}
|
553 |
+
|
554 |
+
if ( ! isset($_POST['entry_id']) || $_POST['entry_id'] != $entry->get_id() ) {
|
555 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Something strange happened.', 'gwolle-gb') . '</p>', true, false);
|
556 |
+
return $entry;
|
557 |
+
} else if ( $_POST['entry_id'] > 0 && $entry->get_id() > 0 ) {
|
558 |
+
|
559 |
+
/* Remove permanently and return early. */
|
560 |
+
if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' && isset($_POST['remove']) && $_POST['remove'] == 'on' ) {
|
561 |
+
if ( $entry->get_istrash() == 1 ) {
|
562 |
+
$entry->delete();
|
563 |
+
$entry->set_id(0);
|
564 |
+
$changed = true;
|
565 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Entry removed.', 'gwolle-gb') . '</p>', false, false);
|
566 |
+
$entry = new gwolle_gb_entry();
|
567 |
+
return $entry;
|
568 |
+
}
|
569 |
+
}
|
570 |
+
|
571 |
+
/* Set as checked or unchecked, and by whom */
|
572 |
+
if ( isset($_POST['ischecked']) && $_POST['ischecked'] == 'on' ) {
|
573 |
+
if ( $_POST['ischecked'] == 'on' && $entry->get_ischecked() == 0 ) {
|
574 |
+
$entry->set_ischecked( true );
|
575 |
+
$user_id = get_current_user_id(); // returns 0 if no current user
|
576 |
+
$entry->set_checkedby( $user_id );
|
577 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
|
578 |
+
gwolle_gb_clear_cache( $entry );
|
579 |
+
}
|
580 |
+
} else if ( $entry->get_ischecked() == 1 ) {
|
581 |
+
$entry->set_ischecked( false );
|
582 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
|
583 |
+
}
|
584 |
+
|
585 |
+
/* Set as spam or not, and submit as ham or spam to Akismet service */
|
586 |
+
if ( isset($_POST['isspam']) && $_POST['isspam'] == 'on' ) {
|
587 |
+
if ( $_POST['isspam'] == 'on' && $entry->get_isspam() == 0 ) {
|
588 |
+
$entry->set_isspam( true );
|
589 |
+
$result = gwolle_gb_akismet( $entry, 'submit-spam' );
|
590 |
+
if ( $result ) {
|
591 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
|
592 |
+
}
|
593 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
|
594 |
+
}
|
595 |
+
} else if ( $entry->get_isspam() == 1 ) {
|
596 |
+
$entry->set_isspam( false );
|
597 |
+
$result = gwolle_gb_akismet( $entry, 'submit-ham' );
|
598 |
+
if ( $result ) {
|
599 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>', false, false);
|
600 |
+
}
|
601 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
|
602 |
+
}
|
603 |
+
|
604 |
+
/* Set as trash or not */
|
605 |
+
if ( isset($_POST['istrash']) && $_POST['istrash'] == 'on' ) {
|
606 |
+
if ( $_POST['istrash'] == 'on' && $entry->get_istrash() == 0 ) {
|
607 |
+
$entry->set_istrash( true );
|
608 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
|
609 |
+
}
|
610 |
+
} else if ( $entry->get_istrash() == 1 ) {
|
611 |
+
$entry->set_istrash( false );
|
612 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
|
613 |
+
}
|
614 |
+
|
615 |
+
/* Check if the content changed, and update accordingly */
|
616 |
+
if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
|
617 |
+
if ( trim($_POST['gwolle_gb_content']) != $entry->get_content() ) {
|
618 |
+
$entry_content = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_content'], 'content' );
|
619 |
+
$entry->set_content( $entry_content );
|
620 |
+
}
|
621 |
+
}
|
622 |
+
|
623 |
+
/* Check if the website changed, and update accordingly */
|
624 |
+
if ( isset( $_POST['gwolle_gb_author_website'] ) ) {
|
625 |
+
$website = trim( $_POST['gwolle_gb_author_website'] );
|
626 |
+
} else {
|
627 |
+
$website = '';
|
628 |
+
}
|
629 |
+
if ( $website != $entry->get_author_website() ) {
|
630 |
+
$entry->set_author_website( $website );
|
631 |
+
}
|
632 |
+
|
633 |
+
/* Check if the author_origin changed, and update accordingly */
|
634 |
+
if ( isset($_POST['gwolle_gb_author_origin']) ) {
|
635 |
+
if ( $_POST['gwolle_gb_author_origin'] != $entry->get_author_origin() ) {
|
636 |
+
$entry_origin = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_origin'], 'author_origin' );
|
637 |
+
$entry->set_author_origin( $entry_origin );
|
638 |
+
}
|
639 |
+
}
|
640 |
+
|
641 |
+
/* Check if the admin_reply changed, and update and log accordingly */
|
642 |
+
if ( isset($_POST['gwolle_gb_admin_reply']) ) {
|
643 |
+
if ( trim($_POST['gwolle_gb_admin_reply']) != $entry->get_admin_reply() ) {
|
644 |
+
$gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
|
645 |
+
if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '' ) {
|
646 |
+
$entry->set_admin_reply_uid( get_current_user_id() );
|
647 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
|
648 |
+
} else if ( $gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '' ) {
|
649 |
+
$entry->set_admin_reply_uid( 0 );
|
650 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-removed' );
|
651 |
+
} else if ( $gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '' ) {
|
652 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-updated' );
|
653 |
+
}
|
654 |
+
$entry->set_admin_reply( $gwolle_gb_admin_reply );
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
/* Mail the author about the Admin Reply, if so requested */
|
659 |
+
if ( isset($_POST['gwolle_gb_admin_reply_mail_author']) ) {
|
660 |
+
if ( $_POST['gwolle_gb_admin_reply_mail_author'] == 'on' ) {
|
661 |
+
gwolle_gb_mail_author_on_admin_reply( $entry );
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
/* Check if the author_name changed, and update accordingly */
|
666 |
+
if ( isset($_POST['gwolle_gb_author_name']) ) {
|
667 |
+
if ( $_POST['gwolle_gb_author_name'] != $entry->get_author_name() ) {
|
668 |
+
$entry_name = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_author_name'], 'author_name' );
|
669 |
+
$entry->set_author_name( $entry_name );
|
670 |
+
}
|
671 |
+
}
|
672 |
+
|
673 |
+
/* Check if the datetime changed, and update accordingly */
|
674 |
+
if ( isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp']) ) {
|
675 |
+
if ( $_POST['gwolle_gb_timestamp'] != $entry->get_datetime() ) {
|
676 |
+
$entry->set_datetime( (int) $_POST['gwolle_gb_timestamp'] );
|
677 |
+
}
|
678 |
+
}
|
679 |
+
|
680 |
+
/* Check if the book_id changed, and update accordingly */
|
681 |
+
if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
|
682 |
+
if ( $_POST['gwolle_gb_book_id'] != $entry->get_book_id() ) {
|
683 |
+
$entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
|
684 |
+
}
|
685 |
+
}
|
686 |
+
|
687 |
+
/* Save the entry */
|
688 |
+
$result = $entry->save();
|
689 |
+
if ($result ) {
|
690 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-edited' );
|
691 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Changes saved.', 'gwolle-gb') . '</p>', false, false);
|
692 |
+
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
693 |
+
} else {
|
694 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
|
695 |
+
}
|
696 |
+
|
697 |
+
} else if ( $_POST['entry_id'] == 0 && $entry->get_id() == 0 ) {
|
698 |
+
|
699 |
+
/*
|
700 |
+
* Check for input, and save accordingly. This is on a New Entry! (So no logging)
|
701 |
+
*/
|
702 |
+
|
703 |
+
$data = Array();
|
704 |
+
|
705 |
+
/* Set as checked anyway, new entry is always by an admin */
|
706 |
+
$data['ischecked'] = true;
|
707 |
+
$user_id = get_current_user_id(); // returns 0 if no current user
|
708 |
+
$data['checkedby'] = $user_id;
|
709 |
+
$data['author_id'] = $user_id;
|
710 |
+
|
711 |
+
/* Set metadata of the admin */
|
712 |
+
$userdata = get_userdata( $user_id );
|
713 |
+
|
714 |
+
if (is_object($userdata)) {
|
715 |
+
if ( isset( $userdata->display_name ) ) {
|
716 |
+
$author_name = $userdata->display_name;
|
717 |
+
} else {
|
718 |
+
$author_name = $userdata->user_login;
|
719 |
+
}
|
720 |
+
$author_email = $userdata->user_email;
|
721 |
+
}
|
722 |
+
$data['author_name'] = $author_name;
|
723 |
+
$data['author_name'] = gwolle_gb_maybe_encode_emoji( $data['author_name'], 'author_name' );
|
724 |
+
$data['author_email'] = $author_email;
|
725 |
+
|
726 |
+
/* Set as Not Spam */
|
727 |
+
$data['isspam'] = false;
|
728 |
+
|
729 |
+
/* Do not set as trash */
|
730 |
+
$data['istrash'] = false;
|
731 |
+
|
732 |
+
/* Check if the content is filled in, and save accordingly */
|
733 |
+
if ( isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '' ) {
|
734 |
+
$data['content'] = $_POST['gwolle_gb_content'];
|
735 |
+
$data['content'] = gwolle_gb_maybe_encode_emoji( $data['content'], 'content' );
|
736 |
+
} else {
|
737 |
+
$form_setting = gwolle_gb_get_setting( 'form' );
|
738 |
+
if ( isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' && isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true' ) {
|
739 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>', true, false);
|
740 |
+
} else {
|
741 |
+
$data['content'] = '';
|
742 |
+
}
|
743 |
+
}
|
744 |
+
|
745 |
+
/* Check if the website is set, and save accordingly */
|
746 |
+
if ( isset($_POST['gwolle_gb_author_website']) ) {
|
747 |
+
if ( $_POST['gwolle_gb_author_website'] != '' ) {
|
748 |
+
$data['author_website'] = $_POST['gwolle_gb_author_website'];
|
749 |
+
} else {
|
750 |
+
$data['author_website'] = home_url();
|
751 |
+
}
|
752 |
+
}
|
753 |
+
|
754 |
+
/* Check if the author_origin is set, and save accordingly */
|
755 |
+
if ( isset($_POST['gwolle_gb_author_origin']) ) {
|
756 |
+
if ( $_POST['gwolle_gb_author_origin'] != '' ) {
|
757 |
+
$data['author_origin'] = $_POST['gwolle_gb_author_origin'];
|
758 |
+
$data['author_origin'] = gwolle_gb_maybe_encode_emoji( $data['author_origin'], 'author_origin' );
|
759 |
+
}
|
760 |
+
}
|
761 |
+
|
762 |
+
/* Check if the admin_reply is set, and save accordingly */
|
763 |
+
if ( isset($_POST['gwolle_gb_admin_reply']) ) {
|
764 |
+
if ( $_POST['gwolle_gb_admin_reply'] != '' ) {
|
765 |
+
$data['admin_reply'] = gwolle_gb_maybe_encode_emoji( $_POST['gwolle_gb_admin_reply'], 'admin_reply' );
|
766 |
+
$data['admin_reply_uid'] = get_current_user_id();
|
767 |
+
gwolle_gb_add_log_entry( $entry->get_id(), 'admin-reply-added' );
|
768 |
+
}
|
769 |
+
}
|
770 |
+
|
771 |
+
/* Check if the book_id is set, and save accordingly */
|
772 |
+
if ( isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id']) ) {
|
773 |
+
$entry->set_book_id( (int) $_POST['gwolle_gb_book_id'] );
|
774 |
+
}
|
775 |
+
|
776 |
+
/* Network Information */
|
777 |
+
$set_author_ip = apply_filters( 'gwolle_gb_set_author_ip', true );
|
778 |
+
$set_author_ip2 = get_option('gwolle_gb-store_ip', 'true');
|
779 |
+
if ( $set_author_ip && ($set_author_ip2 == 'true') ) {
|
780 |
+
$entry->set_author_ip( $_SERVER['REMOTE_ADDR'] );
|
781 |
+
$entry->set_author_host( gethostbyaddr( $_SERVER['REMOTE_ADDR'] ) );
|
782 |
+
}
|
783 |
+
|
784 |
+
$result1 = $entry->set_data( $data );
|
785 |
+
if ( $result1 ) {
|
786 |
+
$result2 = $entry->save();
|
787 |
+
if ( $result1 && $result2 ) {
|
788 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Entry saved.', 'gwolle-gb') . '</p>', false, false);
|
789 |
+
gwolle_gb_clear_cache( $entry );
|
790 |
+
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
791 |
+
} else {
|
792 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Error happened during saving.', 'gwolle-gb') . '</p>', true, false);
|
793 |
+
}
|
794 |
+
} else {
|
795 |
+
gwolle_gb_add_message( '<p>' . esc_html__('Entry was not saved.', 'gwolle-gb') . '</p>', true, false);
|
796 |
+
}
|
797 |
+
}
|
798 |
+
return $entry;
|
799 |
+
}
|
800 |
+
|
801 |
+
|
802 |
+
/*
|
803 |
+
* Get editor class for this entry.
|
804 |
+
*
|
805 |
+
* @param object $entry instance of gwolle_gb_entry class.
|
806 |
+
* @return string text string with CSS classes.
|
807 |
+
*
|
808 |
+
* @since 3.0.0
|
809 |
+
*/
|
810 |
+
function gwolle_gb_editor_get_class( $entry ) {
|
811 |
+
|
812 |
+
static $class_static;
|
813 |
+
|
814 |
+
if ( $class_static ) {
|
815 |
+
return $class_static;
|
816 |
+
}
|
817 |
+
|
818 |
+
$class = '';
|
819 |
+
// Attach 'spam' to class if the entry is spam
|
820 |
+
if ( $entry->get_isspam() === 1 ) {
|
821 |
+
$class .= 'spam';
|
822 |
+
} else {
|
823 |
+
$class .= 'nospam';
|
824 |
+
}
|
825 |
+
|
826 |
+
// Attach 'trash' to class if the entry is in trash
|
827 |
+
if ( $entry->get_istrash() === 1 ) {
|
828 |
+
$class .= ' trash';
|
829 |
+
} else {
|
830 |
+
$class .= ' notrash';
|
831 |
+
}
|
832 |
+
|
833 |
+
// Attach 'checked/unchecked' to class
|
834 |
+
if ( $entry->get_ischecked() === 1 ) {
|
835 |
+
$class .= ' checked';
|
836 |
+
} else {
|
837 |
+
$class .= ' unchecked';
|
838 |
+
}
|
839 |
+
|
840 |
+
// Attach 'visible/invisible' to class
|
841 |
+
if ( $entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0 ) {
|
842 |
+
$class .= ' invisible';
|
843 |
+
} else {
|
844 |
+
$class .= ' visible';
|
845 |
+
}
|
846 |
+
|
847 |
+
// Add admin-entry class to an entry from an admin
|
848 |
+
$author_id = $entry->get_author_id();
|
849 |
+
$is_moderator = gwolle_gb_is_moderator( $author_id );
|
850 |
+
if ( $is_moderator ) {
|
851 |
+
$class .= ' admin-entry';
|
852 |
+
}
|
853 |
+
|
854 |
+
$class_static = $class;
|
855 |
+
return $class_static;
|
856 |
+
|
857 |
+
}
|
admin/gb-page-entries.php
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
* entries.php
|
4 |
* Displays the guestbook entries in a list.
|
5 |
*/
|
6 |
|
@@ -15,309 +14,23 @@ if ( strpos($_SERVER['PHP_SELF'], basename(__FILE__) )) {
|
|
15 |
*/
|
16 |
function gwolle_gb_page_entries() {
|
17 |
|
18 |
-
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) {
|
19 |
die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
|
20 |
}
|
21 |
|
22 |
gwolle_gb_admin_enqueue();
|
23 |
|
24 |
-
$gwolle_gb_errors = '';
|
25 |
-
$gwolle_gb_messages = '';
|
26 |
$show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
|
27 |
|
28 |
if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
} else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'no-spam' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'no-spam' ) ) {
|
37 |
-
$action = 'no-spam';
|
38 |
-
} else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'akismet' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'akismet' ) ) {
|
39 |
-
$action = 'akismet';
|
40 |
-
} else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'trash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'trash' ) ) {
|
41 |
-
$action = 'trash';
|
42 |
-
} else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'untrash' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'untrash' ) ) {
|
43 |
-
$action = 'untrash';
|
44 |
-
} else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'remove' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'remove' ) ) {
|
45 |
-
$action = 'remove';
|
46 |
-
} else if ( ( isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'anon' ) || ( isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'anon' ) ) {
|
47 |
-
$action = 'anon';
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
/* Check if we are not sending in more entries than were even listed... */
|
52 |
-
$continue_on_entries_checked = false;
|
53 |
-
$entries_checked = 0;
|
54 |
-
$num_entries = get_option('gwolle_gb-entries_per_page', 20);
|
55 |
-
foreach( array_keys($_POST) as $postElementName ) {
|
56 |
-
if (strpos($postElementName, 'check') > -1 && !strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
|
57 |
-
$entries_checked++;
|
58 |
-
}
|
59 |
-
}
|
60 |
-
if ( $entries_checked < ( $num_entries + 1 ) ) {
|
61 |
-
$continue_on_entries_checked = true;
|
62 |
-
} else if ( $show == 'user' ) {
|
63 |
-
// special case for mass edit all entries from user.
|
64 |
-
$continue_on_entries_checked = true;
|
65 |
-
} else {
|
66 |
-
$gwolle_gb_messages .= '<p>' . /* translators: Someone seems to be abusing the website in strange ways. */ esc_html__('It seems you checked more entries then were even listed on the page.', 'gwolle-gb') . '</p>';
|
67 |
-
$gwolle_gb_errors = 'error';
|
68 |
-
}
|
69 |
-
|
70 |
-
/* Check Nonce */
|
71 |
-
$continue_on_nonce_checked = false;
|
72 |
-
if ( isset($_POST['gwolle_gb_wpnonce']) ) {
|
73 |
-
$verified = wp_verify_nonce( $_POST['gwolle_gb_wpnonce'], 'gwolle_gb_page_entries' );
|
74 |
-
if ( $verified == true ) {
|
75 |
-
$continue_on_nonce_checked = true;
|
76 |
-
} else {
|
77 |
-
// Nonce is invalid, so considered spam
|
78 |
-
$gwolle_gb_messages .= '<p>' . esc_html__('Nonce check failed. Please try again.', 'gwolle-gb') . '</p>';
|
79 |
-
$gwolle_gb_errors = 'error';
|
80 |
-
}
|
81 |
-
}
|
82 |
-
/* End of security checks. */
|
83 |
-
|
84 |
-
|
85 |
-
if ( $action != '' && $continue_on_entries_checked && $continue_on_nonce_checked ) {
|
86 |
-
// Initialize variables to generate messages with
|
87 |
-
$entries_handled = 0;
|
88 |
-
$entries_not_handled = 0;
|
89 |
-
$akismet_spam = 0;
|
90 |
-
$akismet_not_spam = 0;
|
91 |
-
$akismet_already_spam = 0;
|
92 |
-
$akismet_already_not_spam = 0;
|
93 |
-
|
94 |
-
/* Handle the $_POST entries */
|
95 |
-
foreach( array_keys($_POST) as $postElementName ) {
|
96 |
-
if (strpos($postElementName, 'check') > -1 && !strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
|
97 |
-
$entry_id = str_replace('check-','',$postElementName);
|
98 |
-
$entry_id = intval($entry_id);
|
99 |
-
if ( isset($entry_id) && $entry_id > 0 ) {
|
100 |
-
$entry = new gwolle_gb_entry();
|
101 |
-
$result = $entry->load( $entry_id );
|
102 |
-
if ( $result ) {
|
103 |
-
|
104 |
-
if ( $action == 'check' ) {
|
105 |
-
if ( $entry->get_ischecked() == 0 ) {
|
106 |
-
$entry->set_ischecked( true );
|
107 |
-
$user_id = get_current_user_id(); // returns 0 if no current user
|
108 |
-
$entry->set_checkedby( $user_id );
|
109 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-checked' );
|
110 |
-
$result = $entry->save();
|
111 |
-
if ( $result ) {
|
112 |
-
$entries_handled++;
|
113 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
114 |
-
} else {
|
115 |
-
$entries_not_handled++;
|
116 |
-
}
|
117 |
-
} else {
|
118 |
-
$entries_not_handled++;
|
119 |
-
}
|
120 |
-
} else if ( $action == 'uncheck' ) {
|
121 |
-
if ( $entry->get_ischecked() == 1 ) {
|
122 |
-
$entry->set_ischecked( false );
|
123 |
-
$user_id = get_current_user_id(); // returns 0 if no current user
|
124 |
-
$entry->set_checkedby( $user_id );
|
125 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-unchecked' );
|
126 |
-
$result = $entry->save();
|
127 |
-
if ( $result ) {
|
128 |
-
$entries_handled++;
|
129 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
130 |
-
} else {
|
131 |
-
$entries_not_handled++;
|
132 |
-
}
|
133 |
-
} else {
|
134 |
-
$entries_not_handled++;
|
135 |
-
}
|
136 |
-
} else if ( $action == 'spam' ) {
|
137 |
-
|
138 |
-
if ( $entry->get_isspam() == 0 ) {
|
139 |
-
$entry->set_isspam( true );
|
140 |
-
if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
|
141 |
-
gwolle_gb_akismet( $entry, 'submit-spam' );
|
142 |
-
}
|
143 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
|
144 |
-
$result = $entry->save();
|
145 |
-
if ( $result ) {
|
146 |
-
$entries_handled++;
|
147 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
148 |
-
} else {
|
149 |
-
$entries_not_handled++;
|
150 |
-
}
|
151 |
-
} else {
|
152 |
-
$entries_not_handled++;
|
153 |
-
}
|
154 |
-
} else if ( $action == 'no-spam' ) {
|
155 |
-
if ( $entry->get_isspam() == 1 ) {
|
156 |
-
$entry->set_isspam( false );
|
157 |
-
if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
|
158 |
-
gwolle_gb_akismet( $entry, 'submit-ham' );
|
159 |
-
}
|
160 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
|
161 |
-
$result = $entry->save();
|
162 |
-
if ( $result ) {
|
163 |
-
$entries_handled++;
|
164 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
165 |
-
} else {
|
166 |
-
$entries_not_handled++;
|
167 |
-
}
|
168 |
-
} else {
|
169 |
-
$entries_not_handled++;
|
170 |
-
}
|
171 |
-
} else if ( $action == 'akismet' ) {
|
172 |
-
/* Check for spam and set accordingly */
|
173 |
-
if ( get_option('gwolle_gb-akismet-active', 'false') == 'true' ) {
|
174 |
-
$isspam = gwolle_gb_akismet( $entry, 'comment-check' );
|
175 |
-
if ( $isspam ) {
|
176 |
-
// Returned true, so considered spam
|
177 |
-
if ( $entry->get_isspam() == 0 ) {
|
178 |
-
$entry->set_isspam( true );
|
179 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-spam' );
|
180 |
-
$result = $entry->save();
|
181 |
-
if ( $result ) {
|
182 |
-
$akismet_spam++;
|
183 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
184 |
-
} else {
|
185 |
-
$akismet_not_spam++;
|
186 |
-
}
|
187 |
-
} else {
|
188 |
-
$akismet_already_spam++;
|
189 |
-
}
|
190 |
-
} else {
|
191 |
-
if ( $entry->get_isspam() == 1 ) {
|
192 |
-
$entry->set_isspam( false );
|
193 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'marked-as-not-spam' );
|
194 |
-
$result = $entry->save();
|
195 |
-
if ( $result ) {
|
196 |
-
$akismet_not_spam++;
|
197 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
198 |
-
} else {
|
199 |
-
$akismet_spam++;
|
200 |
-
}
|
201 |
-
} else {
|
202 |
-
$akismet_already_not_spam++;
|
203 |
-
}
|
204 |
-
}
|
205 |
-
}
|
206 |
-
} else if ( $action == 'trash' ) {
|
207 |
-
if ( $entry->get_istrash() == 0 ) {
|
208 |
-
$entry->set_istrash( true );
|
209 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-trashed' );
|
210 |
-
$result = $entry->save();
|
211 |
-
if ( $result ) {
|
212 |
-
$entries_handled++;
|
213 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
214 |
-
} else {
|
215 |
-
$entries_not_handled++;
|
216 |
-
}
|
217 |
-
} else {
|
218 |
-
$entries_not_handled++;
|
219 |
-
}
|
220 |
-
} else if ( $action == 'untrash' ) {
|
221 |
-
if ( $entry->get_istrash() == 1 ) {
|
222 |
-
$entry->set_istrash( false );
|
223 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-untrashed' );
|
224 |
-
$result = $entry->save();
|
225 |
-
if ( $result ) {
|
226 |
-
$entries_handled++;
|
227 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
228 |
-
} else {
|
229 |
-
$entries_not_handled++;
|
230 |
-
}
|
231 |
-
} else {
|
232 |
-
$entries_not_handled++;
|
233 |
-
}
|
234 |
-
} else if ( $action == 'remove' ) {
|
235 |
-
$result = $entry->delete();
|
236 |
-
if ( $result ) {
|
237 |
-
$entries_handled++;
|
238 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
239 |
-
} else {
|
240 |
-
$entries_not_handled++;
|
241 |
-
}
|
242 |
-
} else if ( $action == 'anon' ) {
|
243 |
-
$entry = gwolle_gb_privacy_anonymize_entry( $entry );
|
244 |
-
$result = $entry->save();
|
245 |
-
if ( $result ) {
|
246 |
-
$entries_handled++;
|
247 |
-
do_action( 'gwolle_gb_save_entry_admin', $entry );
|
248 |
-
gwolle_gb_add_log_entry( $entry->get_id(), 'entry-anonymized' );
|
249 |
-
} else {
|
250 |
-
$entries_not_handled++;
|
251 |
-
}
|
252 |
-
}
|
253 |
-
} else { // no result on load()
|
254 |
-
$entries_not_handled++;
|
255 |
-
}
|
256 |
-
} else { // entry_id is not set or not > 0
|
257 |
-
$entries_not_handled++;
|
258 |
-
}
|
259 |
-
} // no entry with the check-'entry_id' input, continue
|
260 |
-
} // foreach
|
261 |
-
|
262 |
-
|
263 |
-
/* Construct Message */
|
264 |
-
if ( $action == 'check' ) {
|
265 |
-
/* translators: %s is the number of entries */
|
266 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry checked.','%s entries checked.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
267 |
-
} else if ( $action == 'uncheck' ) {
|
268 |
-
/* translators: %s is the number of entries */
|
269 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry unchecked.','%s entries unchecked.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
270 |
-
} else if ( $action == 'spam' ) {
|
271 |
-
/* translators: %s is the number of entries */
|
272 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry marked as spam and submitted to Akismet as spam (if Akismet was enabled).','%s entries marked as spam and submitted to Akismet as spam (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
273 |
-
} else if ( $action == 'no-spam' ) {
|
274 |
-
/* translators: %s is the number of entries */
|
275 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry marked as not spam and submitted to Akismet as ham (if Akismet was enabled).','%s entries marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
276 |
-
} else if ( $action == 'akismet' ) {
|
277 |
-
if ( $akismet_spam > 0 ) {
|
278 |
-
/* translators: %s is the number of entries */
|
279 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry considered spam and marked as such.','%s entries considered spam and marked as such.', $akismet_spam, 'gwolle-gb'), $akismet_spam ). '</p>';
|
280 |
-
}
|
281 |
-
if ( $akismet_not_spam > 0 ) {
|
282 |
-
/* translators: %s is the number of entries */
|
283 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry considered not spam and marked as such.','%s entries considered not spam and marked as such.', $akismet_not_spam, 'gwolle-gb'), $akismet_not_spam ). '</p>';
|
284 |
-
}
|
285 |
-
if ( $akismet_already_spam > 0 ) {
|
286 |
-
/* translators: %s is the number of entries */
|
287 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry already considered spam and not changed.','%s entries already considered spam and not changed.', $akismet_already_spam, 'gwolle-gb'), $akismet_already_spam ). '</p>';
|
288 |
-
}
|
289 |
-
if ( $akismet_already_not_spam > 0 ) {
|
290 |
-
/* translators: %s is the number of entries */
|
291 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry already considered not spam and not changed.','%s entries already considered not spam and not changed.', $akismet_already_not_spam, 'gwolle-gb'), $akismet_already_not_spam ). '</p>';
|
292 |
-
}
|
293 |
-
} else if ( $action == 'trash' ) {
|
294 |
-
/* translators: %s is the number of entries */
|
295 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry moved to trash.','%s entries moved to trash.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
296 |
-
} else if ( $action == 'untrash' ) {
|
297 |
-
/* translators: %s is the number of entries */
|
298 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry recovered from trash.','%s entries recovered from trash.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
299 |
-
} else if ( $action == 'remove' ) {
|
300 |
-
/* translators: %s is the number of entries */
|
301 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
302 |
-
} else if ( $action == 'anon' ) {
|
303 |
-
/* translators: %s is the number of entries */
|
304 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry anonymized.','%s entries anonymized.', $entries_handled, 'gwolle-gb'), $entries_handled ). '</p>';
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
if ( isset( $_POST['delete_all'] ) || isset( $_POST['delete_all2'] ) ) {
|
309 |
-
if ( $continue_on_nonce_checked ) {
|
310 |
-
// Delete all entries in spam or trash
|
311 |
-
if ( isset($_POST['show']) && in_array($_POST['show'], array('spam', 'trash')) ) {
|
312 |
-
$delstatus = $_POST['show'];
|
313 |
-
$deleted = gwolle_gb_del_entries( $delstatus );
|
314 |
-
/* translators: %s is the number of entries */
|
315 |
-
$gwolle_gb_messages .= '<p>' . sprintf( _n('%s entry removed permanently.','%s entries removed permanently.', $deleted, 'gwolle-gb'), $deleted ). '</p>';
|
316 |
-
}
|
317 |
-
}
|
318 |
-
}
|
319 |
}
|
320 |
-
|
321 |
|
322 |
// Get entry counts
|
323 |
$count = Array();
|
@@ -343,10 +56,10 @@ function gwolle_gb_page_entries() {
|
|
343 |
|
344 |
$pages_total = ceil( $count[$show] / $num_entries );
|
345 |
if ($pageNum > $pages_total) {
|
346 |
-
$pageNum = 1; // page
|
347 |
}
|
348 |
|
349 |
-
// Calculate
|
350 |
if ($pageNum == 1 && $count[$show] > 0) {
|
351 |
$offset = 0;
|
352 |
} elseif ($count[$show] == 0) {
|
@@ -360,7 +73,7 @@ function gwolle_gb_page_entries() {
|
|
360 |
$book_id = (int) $_GET['book_id'];
|
361 |
}
|
362 |
|
363 |
-
// Get the entries
|
364 |
if ( $show == 'checked' ) {
|
365 |
$entries = gwolle_gb_get_entries(array(
|
366 |
'num_entries' => $num_entries,
|
@@ -464,7 +177,7 @@ function gwolle_gb_page_entries() {
|
|
464 |
<?php
|
465 |
if ( $gwolle_gb_messages ) {
|
466 |
echo '
|
467 |
-
<div id="message" class="updated fade notice is-dismissible ' . $
|
468 |
$gwolle_gb_messages .
|
469 |
'</div>';
|
470 |
} ?>
|
@@ -628,7 +341,7 @@ function gwolle_gb_page_entries() {
|
|
628 |
$request_uri = $_SERVER['REQUEST_URI'];
|
629 |
$rowOdd = true;
|
630 |
$html_output = '';
|
631 |
-
if ( !is_array($entries) || empty($entries) ) {
|
632 |
$colspan = (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') ? 8 : 7;
|
633 |
$html_output .= '
|
634 |
<tr>
|
@@ -795,7 +508,7 @@ function gwolle_gb_page_entries() {
|
|
795 |
}
|
796 |
|
797 |
// Only show controls when there are entries
|
798 |
-
if ( is_array($entries) && !empty($entries) ) {
|
799 |
echo $massEditControls_select . $massEditControls . $empty_button;
|
800 |
} ?>
|
801 |
</div>
|
@@ -810,3 +523,309 @@ function gwolle_gb_page_entries() {
|
|
810 |
</div>
|
811 |
<?php
|
812 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/*
|
|
|
3 |
* Displays the guestbook entries in a list.
|
4 |
*/
|
5 |
|
14 |
*/
|
15 |
function gwolle_gb_page_entries() {
|
16 |
|
17 |
+
if ( function_exists('current_user_can') && ! current_user_can('moderate_comments') ) {
|
18 |
die(esc_html__('You need a higher level of permission.', 'gwolle-gb'));
|
19 |
}
|
20 |
|
21 |
gwolle_gb_admin_enqueue();
|
22 |
|
|
|
|
|
23 |
$show = (isset($_REQUEST['show']) && in_array($_REQUEST['show'], array( 'checked', 'unchecked', 'spam', 'trash', 'user' ))) ? $_REQUEST['show'] : 'all';
|
24 |
|
25 |
if ( isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries' ) {
|
26 |
+
gwolle_gb_page_entries_update();
|
27 |
+
}
|
28 |
+
$gwolle_gb_messages = gwolle_gb_get_messages();
|
29 |
+
$gwolle_gb_errors = gwolle_gb_get_errors();
|
30 |
+
$messageclass = '';
|
31 |
+
if ( $gwolle_gb_errors ) {
|
32 |
+
$messageclass = 'error';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|