';
152 | }
153 |
154 |
155 | }
156 |
157 | }
--------------------------------------------------------------------------------
/includes/wp-cli/class-wp-rest-api-log-wp-cli-log.php:
--------------------------------------------------------------------------------
1 | get_log_ids_to_migrate();
92 |
93 | $count = count( $ids );
94 | if ( 0 === $count ) {
95 | WP_CLI::Line( "There are no more log entries that need to be migrated." );
96 | return;
97 | }
98 |
99 | $progress_bar = WP_CLI\Utils\make_progress_bar( "Migrating {$count} entries:", $count, 1 );
100 | $progress_bar->display();
101 |
102 | foreach ( $ids as $id ) {
103 | $db->migrate_db_record( $id );
104 | $progress_bar->tick();
105 | }
106 |
107 | $progress_bar->finish();
108 |
109 | WP_CLI::Success( "Log entries migrated" );
110 |
111 | }
112 |
113 | // phpcs:ignore
114 | /**
115 | * Purges old REST API Log records.
116 | *
117 | * ## OPTIONS
118 | *
119 | * []
120 | * Delete entries older than this many days, defaults to whatever you
121 | * have configured in the plugin settings
122 | *
123 | * --dry-run
124 | * Shows number of entries that would be deleted but does not
125 | * delete them
126 | *
127 | * ## EXAMPLES
128 | *
129 | * wp rest-api-log purge
130 | *
131 | * wp rest-api-log purge 90
132 | *
133 | * @synopsis [] [--dry-run]
134 | */
135 | function purge( $positional_args, $assoc_args = array() ) { // phpcs:ignore
136 |
137 | $days_old = absint( ! empty( $positional_args[0] ) ? $positional_args[0] : 0 );
138 | $dry_run = ! empty( $assoc_args['dry-run'] );
139 |
140 | WP_CLI::Line( 'Getting old REST API log entries...' );
141 |
142 | $ids = WP_REST_API_Log::get_old_log_ids( $days_old );
143 |
144 | $count = count( $ids );
145 | $number_deleted = 0;
146 |
147 | $progress = \WP_CLI\Utils\make_progress_bar( sprintf( 'Deleting %d old log entries', $count ), $count );
148 |
149 | foreach ( $ids as $id ) {
150 | if ( ! $dry_run ) {
151 | wp_delete_post( $id, true );
152 | $number_deleted++;
153 | }
154 |
155 | $progress->tick();
156 | }
157 |
158 | $progress->finish();
159 |
160 | WP_CLI::Success( sprintf( '%d entries purged', $number_deleted ) );
161 |
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/includes/wp-cli/setup.php:
--------------------------------------------------------------------------------
1 | array( 'command' => 'rest-api-log', 'class' => 'WP_REST_API_Log_WP_CLI_Log' ),
5 | );
6 |
7 | foreach ( $commands as $file => $command_info ) {
8 | require_once WP_REST_API_LOG_PATH . 'includes/wp-cli/' . $file;
9 | extract( $command_info );
10 | WP_CLI::add_command( $command, $class );
11 | }
12 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | \n"
13 | "Language-Team: LANGUAGE \n"
14 | "X-Generator: grunt-wp-i18n 0.5.4\n"
15 |
16 | #: admin/class-wp-rest-api-log-admin-list-table.php:56
17 | #: admin/partials/wp-rest-api-log-view-entry.php:73
18 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:56
19 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:71
20 | msgid "Date"
21 | msgstr ""
22 |
23 | #: admin/class-wp-rest-api-log-admin-list-table.php:57
24 | #: admin/class-wp-rest-api-log-admin-list-table.php:122
25 | #: admin/partials/wp-rest-api-log-view-entry.php:75
26 | #: includes/class-wp-rest-api-log-post-type.php:82
27 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:57
28 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:122
29 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:73
30 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:82
31 | msgid "Method"
32 | msgstr ""
33 |
34 | #: admin/class-wp-rest-api-log-admin-list-table.php:58
35 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:58
36 | msgid "Title"
37 | msgstr ""
38 |
39 | #: admin/class-wp-rest-api-log-admin-list-table.php:59
40 | #: admin/class-wp-rest-api-log-admin-list-table.php:137
41 | #: admin/partials/wp-rest-api-log-view-entry.php:76
42 | #: includes/class-wp-rest-api-log-post-type.php:104
43 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:59
44 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:137
45 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:74
46 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:104
47 | msgid "Status"
48 | msgstr ""
49 |
50 | #: admin/class-wp-rest-api-log-admin-list-table.php:60
51 | #: admin/partials/wp-rest-api-log-view-entry.php:77
52 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:60
53 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:75
54 | msgid "Elapsed Time"
55 | msgstr ""
56 |
57 | #: admin/class-wp-rest-api-log-admin-list-table.php:61
58 | #: admin/partials/wp-rest-api-log-view-entry.php:78
59 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:61
60 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:76
61 | msgid "Response Length"
62 | msgstr ""
63 |
64 | #: admin/class-wp-rest-api-log-admin-list-table.php:62
65 | #: admin/partials/wp-rest-api-log-view-entry.php:80
66 | #: includes/settings/class-wp-rest-api-log-settings-general.php:75
67 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:62
68 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:78
69 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:75
70 | msgid "IP Address"
71 | msgstr ""
72 |
73 | #: admin/class-wp-rest-api-log-admin-list-table.php:63
74 | #: admin/partials/wp-rest-api-log-view-entry.php:79
75 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:63
76 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:77
77 | msgid "User"
78 | msgstr ""
79 |
80 | #: admin/class-wp-rest-api-log-admin-list-table.php:123
81 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:123
82 | msgid "All Methods"
83 | msgstr ""
84 |
85 | #: admin/class-wp-rest-api-log-admin-list-table.php:138
86 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:138
87 | msgid "All Statuses"
88 | msgstr ""
89 |
90 | #: admin/class-wp-rest-api-log-admin-list-table.php:152
91 | #: admin/partials/wp-rest-api-log-view-entry.php:74
92 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:152
93 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:72
94 | msgid "Source"
95 | msgstr ""
96 |
97 | #: admin/class-wp-rest-api-log-admin-list-table.php:153
98 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin-list-table.php:153
99 | msgid "All Sources"
100 | msgstr ""
101 |
102 | #: admin/class-wp-rest-api-log-admin.php:39
103 | #: includes/class-wp-rest-api-log-post-type.php:26
104 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin.php:27
105 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:26
106 | msgid "REST API Log Entries"
107 | msgstr ""
108 |
109 | #. Plugin Name of the plugin/theme
110 | msgid "REST API Log"
111 | msgstr ""
112 |
113 | #: admin/class-wp-rest-api-log-admin.php:177
114 | #: includes/class-wp-rest-api-log-post-type.php:27
115 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin.php:142
116 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:27
117 | msgid "REST API Log Entry"
118 | msgstr ""
119 |
120 | #: admin/class-wp-rest-api-log-admin.php:239
121 | #: includes/settings/class-wp-rest-api-log-settings.php:115
122 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin.php:204
123 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings.php:115
124 | msgid "Settings"
125 | msgstr ""
126 |
127 | #: admin/class-wp-rest-api-log-admin.php:243
128 | #: release/wp-rest-api-log/admin/class-wp-rest-api-log-admin.php:208
129 | msgid "Log"
130 | msgstr ""
131 |
132 | #: admin/partials/admin-help.php:7
133 | #: release/wp-rest-api-log/admin/partials/admin-help.php:7
134 | msgid "Contact"
135 | msgstr ""
136 |
137 | #: admin/partials/admin-help.php:9
138 | #: release/wp-rest-api-log/admin/partials/admin-help.php:9
139 | msgid "E-Mail"
140 | msgstr ""
141 |
142 | #: admin/partials/admin-help.php:10
143 | #: release/wp-rest-api-log/admin/partials/admin-help.php:10
144 | msgid "Twitter"
145 | msgstr ""
146 |
147 | #: admin/partials/admin-help.php:11
148 | #: release/wp-rest-api-log/admin/partials/admin-help.php:11
149 | msgid "GitHub"
150 | msgstr ""
151 |
152 | #: admin/partials/entry-property-links.php:6
153 | msgid "Download"
154 | msgstr ""
155 |
156 | #: admin/partials/entry-property-links.php:7
157 | msgid "Copy"
158 | msgstr ""
159 |
160 | #: admin/partials/wp-rest-api-log-api-is-disabled.php:3
161 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-api-is-disabled.php:3
162 | msgid "WP REST API Log"
163 | msgstr ""
164 |
165 | #: admin/partials/wp-rest-api-log-api-is-disabled.php:6
166 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-api-is-disabled.php:6
167 | msgid "The WP REST API is not enabled"
168 | msgstr ""
169 |
170 | #: admin/partials/wp-rest-api-log-view-entry.php:10
171 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:10
172 | msgid "Cheatin’ uh?"
173 | msgstr ""
174 |
175 | #: admin/partials/wp-rest-api-log-view-entry.php:11
176 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:11
177 | msgid "You are not allowed to read posts in this post type."
178 | msgstr ""
179 |
180 | #: admin/partials/wp-rest-api-log-view-entry.php:22
181 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:22
182 | msgid "Invalid WP REST API Log Entry ID"
183 | msgstr ""
184 |
185 | #: admin/partials/wp-rest-api-log-view-entry.php:62
186 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:60
187 | msgid "Route:"
188 | msgstr ""
189 |
190 | #: admin/partials/wp-rest-api-log-view-entry.php:69
191 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:67
192 | msgid "Details"
193 | msgstr ""
194 |
195 | #: admin/partials/wp-rest-api-log-view-entry.php:82
196 | #: includes/settings/class-wp-rest-api-log-settings-general.php:76
197 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:80
198 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:76
199 | msgid "HTTP X Forwarded For"
200 | msgstr ""
201 |
202 | #: admin/partials/wp-rest-api-log-view-entry.php:91
203 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:89
204 | msgid "Request Headers"
205 | msgstr ""
206 |
207 | #: admin/partials/wp-rest-api-log-view-entry.php:107
208 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:96
209 | msgid "Query Parameters"
210 | msgstr ""
211 |
212 | #: admin/partials/wp-rest-api-log-view-entry.php:123
213 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:103
214 | msgid "Body Parameters"
215 | msgstr ""
216 |
217 | #: admin/partials/wp-rest-api-log-view-entry.php:141
218 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:112
219 | msgid "Body Content"
220 | msgstr ""
221 |
222 | #: admin/partials/wp-rest-api-log-view-entry.php:172
223 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:125
224 | msgid "Response Headers"
225 | msgstr ""
226 |
227 | #: admin/partials/wp-rest-api-log-view-entry.php:188
228 | msgid "Response Body"
229 | msgstr ""
230 |
231 | #: includes/class-wp-rest-api-log-controller.php:219
232 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-controller.php:141
233 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-controller.php:149
234 | msgid "Invalid REST API Log ID %d."
235 | msgstr ""
236 |
237 | #: includes/class-wp-rest-api-log-filters.php:14
238 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-filters.php:14
239 | msgid "All"
240 | msgstr ""
241 |
242 | #: includes/class-wp-rest-api-log-filters.php:15
243 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-filters.php:15
244 | msgid "Only Matching Filters"
245 | msgstr ""
246 |
247 | #: includes/class-wp-rest-api-log-filters.php:16
248 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-filters.php:16
249 | msgid "Exclude Matching Filters"
250 | msgstr ""
251 |
252 | #: includes/class-wp-rest-api-log-post-type.php:28
253 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:28
254 | msgid "Add New REST API Log Entries"
255 | msgstr ""
256 |
257 | #: includes/class-wp-rest-api-log-post-type.php:29
258 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:29
259 | msgid "Add New REST API Log Entry"
260 | msgstr ""
261 |
262 | #: includes/class-wp-rest-api-log-post-type.php:30
263 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:30
264 | msgid "New REST API Log Entry"
265 | msgstr ""
266 |
267 | #: includes/class-wp-rest-api-log-post-type.php:31
268 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:31
269 | msgid "Edit Publication Page"
270 | msgstr ""
271 |
272 | #: includes/class-wp-rest-api-log-post-type.php:32
273 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:32
274 | msgid "View REST API Log Entry"
275 | msgstr ""
276 |
277 | #: includes/class-wp-rest-api-log-post-type.php:33
278 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:33
279 | msgid "All REST API Log Entries"
280 | msgstr ""
281 |
282 | #: includes/class-wp-rest-api-log-post-type.php:34
283 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:34
284 | msgid "Search Entries"
285 | msgstr ""
286 |
287 | #: includes/class-wp-rest-api-log-post-type.php:35
288 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:35
289 | msgid "No REST API Log Entries found"
290 | msgstr ""
291 |
292 | #: includes/class-wp-rest-api-log-post-type.php:36
293 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:36
294 | msgid "No REST API Log Entries found in Trash"
295 | msgstr ""
296 |
297 | #: includes/class-wp-rest-api-log-post-type.php:83
298 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:83
299 | msgid "Methods"
300 | msgstr ""
301 |
302 | #: includes/class-wp-rest-api-log-post-type.php:105
303 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:105
304 | msgid "Statuses"
305 | msgstr ""
306 |
307 | #: includes/class-wp-rest-api-log-post-type.php:110
308 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:110
309 | msgid "Log Source"
310 | msgstr ""
311 |
312 | #: includes/class-wp-rest-api-log-post-type.php:111
313 | #: release/wp-rest-api-log/includes/class-wp-rest-api-log-post-type.php:111
314 | msgid "Log Sources"
315 | msgstr ""
316 |
317 | #: includes/settings/class-wp-rest-api-log-settings-base.php:54
318 | #: includes/settings/class-wp-rest-api-log-settings-general.php:19
319 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-base.php:54
320 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:19
321 | msgid "General"
322 | msgstr ""
323 |
324 | #: includes/settings/class-wp-rest-api-log-settings-base.php:235
325 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-base.php:235
326 | msgid "Yes"
327 | msgstr ""
328 |
329 | #: includes/settings/class-wp-rest-api-log-settings-base.php:236
330 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-base.php:236
331 | msgid "No"
332 | msgstr ""
333 |
334 | #: includes/settings/class-wp-rest-api-log-settings-elasticpress.php:19
335 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-elasticpress.php:19
336 | msgid "ElasticPress"
337 | msgstr ""
338 |
339 | #: includes/settings/class-wp-rest-api-log-settings-elasticpress.php:40
340 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-elasticpress.php:40
341 | msgid "Log ElasticPress API Calls"
342 | msgstr ""
343 |
344 | #: includes/settings/class-wp-rest-api-log-settings-general.php:40
345 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:40
346 | msgid "Enabled"
347 | msgstr ""
348 |
349 | #: includes/settings/class-wp-rest-api-log-settings-general.php:50
350 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:50
351 | msgid "Purge All %1$s Entries Now"
352 | msgstr ""
353 |
354 | #: includes/settings/class-wp-rest-api-log-settings-general.php:54
355 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:54
356 | msgid "Days to Retain Old Entries"
357 | msgstr ""
358 |
359 | #: includes/settings/class-wp-rest-api-log-settings-general.php:59
360 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:59
361 | msgid ""
362 | "Entries older than this will be automatically cleaned up, leave blank to "
363 | "keep all entries. %1$s"
364 | msgstr ""
365 |
366 | #: includes/settings/class-wp-rest-api-log-settings-general.php:68
367 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:68
368 | msgid "IP Address Display"
369 | msgstr ""
370 |
371 | #: includes/settings/class-wp-rest-api-log-settings-general.php:73
372 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-general.php:73
373 | msgid "Sets the IP address displayed in the list of log entries."
374 | msgstr ""
375 |
376 | #: includes/settings/class-wp-rest-api-log-settings-help.php:19
377 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-help.php:19
378 | msgid "Help"
379 | msgstr ""
380 |
381 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:28
382 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:28
383 | msgid "Routes"
384 | msgstr ""
385 |
386 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:61
387 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:61
388 | msgid "Ignore core oEmbed"
389 | msgstr ""
390 |
391 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:68
392 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:68
393 | msgid "Built-in /oembed/1.0/embed route"
394 | msgstr ""
395 |
396 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:74
397 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:74
398 | msgid "Route Logging Mode"
399 | msgstr ""
400 |
401 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:89
402 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:89
403 | msgid "Route Filters"
404 | msgstr ""
405 |
406 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:97
407 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:97
408 | msgid "One route per line, examples"
409 | msgstr ""
410 |
411 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:99
412 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:99
413 | msgid "Exact Match"
414 | msgstr ""
415 |
416 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:100
417 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:100
418 | msgid "Wildcard Match"
419 | msgstr ""
420 |
421 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:101
422 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:101
423 | msgid "Regex"
424 | msgstr ""
425 |
426 | #: includes/settings/class-wp-rest-api-log-settings-routes.php:103
427 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings-routes.php:103
428 | msgid "Regex matches must start with ^"
429 | msgstr ""
430 |
431 | #: includes/settings/class-wp-rest-api-log-settings.php:35
432 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings.php:35
433 | msgid ""
434 | "REST API Log activated! Please visit the "
435 | "Settings page to customize the settings."
436 | msgstr ""
437 |
438 | #: includes/settings/class-wp-rest-api-log-settings.php:66
439 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings.php:66
440 | msgid "REST API Log Settings"
441 | msgstr ""
442 |
443 | #: includes/settings/class-wp-rest-api-log-settings.php:90
444 | #: release/wp-rest-api-log/includes/settings/class-wp-rest-api-log-settings.php:90
445 | msgid "Save Changes"
446 | msgstr ""
447 |
448 | #: release/wp-rest-api-log/admin/partials/wp-rest-api-log-view-entry.php:132
449 | msgid "Response"
450 | msgstr ""
451 |
452 | #. Plugin URI of the plugin/theme
453 | msgid "https://github.com/petenelson/wp-rest-api-log"
454 | msgstr ""
455 |
456 | #. Description of the plugin/theme
457 | msgid "Logs requests and responses for the REST API"
458 | msgstr ""
459 |
460 | #. Author of the plugin/theme
461 | msgid "Pete Nelson"
462 | msgstr ""
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6 |
7 | Everyone is permitted to copy and distribute verbatim copies
8 | of this license document, but changing it is not allowed.
9 |
10 | Preamble
11 |
12 | The licenses for most software are designed to take away your
13 | freedom to share and change it. By contrast, the GNU General Public
14 | License is intended to guarantee your freedom to share and change free
15 | software--to make sure the software is free for all its users. This
16 | General Public License applies to most of the Free Software
17 | Foundation's software and to any other program whose authors commit to
18 | using it. (Some other Free Software Foundation software is covered by
19 | the GNU Library General Public License instead.) You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | this service if you wish), that you receive source code or can get it
26 | if you want it, that you can change the software or use pieces of it
27 | in new free programs; and that you know you can do these things.
28 |
29 | To protect your rights, we need to make restrictions that forbid
30 | anyone to deny you these rights or to ask you to surrender the rights.
31 | These restrictions translate to certain responsibilities for you if you
32 | distribute copies of the software, or if you modify it.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must give the recipients all the rights that
36 | you have. You must make sure that they, too, receive or can get the
37 | source code. And you must show them these terms so they know their
38 | rights.
39 |
40 | We protect your rights with two steps: (1) copyright the software, and
41 | (2) offer you this license which gives you legal permission to copy,
42 | distribute and/or modify the software.
43 |
44 | Also, for each author's protection and ours, we want to make certain
45 | that everyone understands that there is no warranty for this free
46 | software. If the software is modified by someone else and passed on, we
47 | want its recipients to know that what they have is not the original, so
48 | that any problems introduced by others will not reflect on the original
49 | authors' reputations.
50 |
51 | Finally, any free program is threatened constantly by software
52 | patents. We wish to avoid the danger that redistributors of a free
53 | program will individually obtain patent licenses, in effect making the
54 | program proprietary. To prevent this, we have made it clear that any
55 | patent must be licensed for everyone's free use or not licensed at all.
56 |
57 | The precise terms and conditions for copying, distribution and
58 | modification follow.
59 |
60 | GNU GENERAL PUBLIC LICENSE
61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62 |
63 | 0. This License applies to any program or other work which contains
64 | a notice placed by the copyright holder saying it may be distributed
65 | under the terms of this General Public License. The "Program", below,
66 | refers to any such program or work, and a "work based on the Program"
67 | means either the Program or any derivative work under copyright law:
68 | that is to say, a work containing the Program or a portion of it,
69 | either verbatim or with modifications and/or translated into another
70 | language. (Hereinafter, translation is included without limitation in
71 | the term "modification".) Each licensee is addressed as "you".
72 |
73 | Activities other than copying, distribution and modification are not
74 | covered by this License; they are outside its scope. The act of
75 | running the Program is not restricted, and the output from the Program
76 | is covered only if its contents constitute a work based on the
77 | Program (independent of having been made by running the Program).
78 | Whether that is true depends on what the Program does.
79 |
80 | 1. You may copy and distribute verbatim copies of the Program's
81 | source code as you receive it, in any medium, provided that you
82 | conspicuously and appropriately publish on each copy an appropriate
83 | copyright notice and disclaimer of warranty; keep intact all the
84 | notices that refer to this License and to the absence of any warranty;
85 | and give any other recipients of the Program a copy of this License
86 | along with the Program.
87 |
88 | You may charge a fee for the physical act of transferring a copy, and
89 | you may at your option offer warranty protection in exchange for a fee.
90 |
91 | 2. You may modify your copy or copies of the Program or any portion
92 | of it, thus forming a work based on the Program, and copy and
93 | distribute such modifications or work under the terms of Section 1
94 | above, provided that you also meet all of these conditions:
95 |
96 | a) You must cause the modified files to carry prominent notices
97 | stating that you changed the files and the date of any change.
98 |
99 | b) You must cause any work that you distribute or publish, that in
100 | whole or in part contains or is derived from the Program or any
101 | part thereof, to be licensed as a whole at no charge to all third
102 | parties under the terms of this License.
103 |
104 | c) If the modified program normally reads commands interactively
105 | when run, you must cause it, when started running for such
106 | interactive use in the most ordinary way, to print or display an
107 | announcement including an appropriate copyright notice and a
108 | notice that there is no warranty (or else, saying that you provide
109 | a warranty) and that users may redistribute the program under
110 | these conditions, and telling the user how to view a copy of this
111 | License. (Exception: if the Program itself is interactive but
112 | does not normally print such an announcement, your work based on
113 | the Program is not required to print an announcement.)
114 |
115 | These requirements apply to the modified work as a whole. If
116 | identifiable sections of that work are not derived from the Program,
117 | and can be reasonably considered independent and separate works in
118 | themselves, then this License, and its terms, do not apply to those
119 | sections when you distribute them as separate works. But when you
120 | distribute the same sections as part of a whole which is a work based
121 | on the Program, the distribution of the whole must be on the terms of
122 | this License, whose permissions for other licensees extend to the
123 | entire whole, and thus to each and every part regardless of who wrote it.
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wp-rest-api-log",
3 | "version": "1.6.6",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "minimist": {
8 | "version": "1.2.6",
9 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
10 | "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
11 | "dev": true
12 | },
13 | "wp-readme-to-markdown": {
14 | "version": "1.0.1",
15 | "resolved": "https://registry.npmjs.org/wp-readme-to-markdown/-/wp-readme-to-markdown-1.0.1.tgz",
16 | "integrity": "sha512-5ZmQzhNZIBcTLYhIovyhBXucDD+JUhL7YAqfmLzPudCLFRodSLbsWtoiYREG/Z55TN1Zn+Rko5eKH965m1L8SA==",
17 | "dev": true,
18 | "requires": {
19 | "minimist": "^1.2.0"
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wp-rest-api-log",
3 | "version": "1.6.9",
4 | "repository": {
5 | "type": "git",
6 | "url": "https://github.com/petenelson/wp-rest-api-log.git"
7 | },
8 | "license": "GPL-2.0-or-later",
9 | "homepage": "https://github.com/petenelson/wp-rest-api-log",
10 | "scripts": {
11 | "clean": "rm -rf release && mkdir release",
12 | "build": "npm run clean && npm run readme-to-md && npm run copy",
13 | "copy": "npm run copy:php && npm run copy:txt && npm run copy:dist",
14 | "readme-to-md": "wp-readme-to-md --screenshot-url=https://raw.githubusercontent.com/petenelson/wp-rest-api-log/master/assets/{screenshot}.png && npm run badges",
15 | "badges": "awk '/WordPress plugin to log REST API requests and responses/{while(getline line<\"badges.md\"){print line}} //' readme.md >readmetmp && mv readmetmp readme.md",
16 | "copy:php": "cp *.php release && cp -R admin release && cp -R includes release",
17 | "copy:txt": "cp *.txt release",
18 | "copy:dist": "cp -R dist release"
19 | },
20 | "dependencies": {},
21 | "devDependencies": {
22 | "wp-readme-to-markdown": "^1.0.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 | ./tests/
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # REST API Log #
2 | **Contributors:** [gungeekatx](https://profiles.wordpress.org/gungeekatx/)
3 | **Tags:** wp rest api, rest api, wp api, api, json, json api, log, logging, elasticpress, elasticsearch
4 | **Donate link:** https://github.com/petenelson/wp-rest-api-log
5 | **Requires at least:** 4.7
6 | **Tested up to:** 6.2
7 | **Stable tag:** 1.7.0
8 | **License:** GPLv2 or later
9 | **License URI:** http://www.gnu.org/licenses/gpl-2.0.html
10 |
11 | [](https://codeclimate.com/github/petenelson/wp-rest-api-log)
12 | [](https://travis-ci.org/petenelson/wp-rest-api-log)
13 |
14 | WordPress plugin to log REST API requests and responses
15 |
16 | ## Description ##
17 |
18 | WordPress plugin to log [REST API](http://v2.wp-api.org/) requests and responses (for v2 of the API).
19 |
20 | Includes:
21 |
22 | * WordPress admin page to view and search log entries
23 | * API endpoint to access log entries via JSON
24 | * Filters to customize logging
25 | * Custom endpoint logging
26 | * ElasticPress logging
27 |
28 | Find us on [GitHub](https://github.com/petenelson/wp-rest-api-log)!
29 |
30 | Roadmap
31 |
32 | * Better search capabilities for log entries via the REST API endpoint
33 |
34 |
35 | ## Installation ##
36 |
37 | 1. Upload the wp-rest-api-log directory to the `/wp-content/plugins/` directory
38 | 2. Activate the plugin through the 'Plugins' menu in WordPress
39 | 3. Go to Settings -> REST API Log to enable or disable logging
40 | 4. Go to Tools -> REST API Log to start viewing log entries
41 |
42 |
43 | ## Changelog ##
44 |
45 | ### v1.7.0 May 8, 2023 ###
46 | * Fixed bugs related to Method and Status filtering.
47 | * Removed deprecated FILTER_SANITIZE_STRING calls.
48 | * Updated highlight.js version
49 | * Updated clipboard.js version
50 |
51 | ### v1.6.9 September 9, 2022 ###
52 | * Updated highlight.js version
53 | * Updated clipboard.js version
54 |
55 | ### v1.6.8 October 30, 2020 ###
56 | * Updated the Purge All Entries functionality in the admin to purge batches of 25 at a time.
57 | * Updated CLI purge command with a progress bar.
58 | * Fixed ClipboardJS error (props itowhid06)
59 |
60 | ### v1.6.7 March 31, 2019 ###
61 | * Added admin notice about running the plugin on a production server
62 | * Set the default purge days to 7
63 | * Updated clipboard.js version
64 |
65 | ### v1.6.6 November 9, 2018 ###
66 | * Moved taxonomy registration to a separate file, made taxonomies not public to prevent them from automatically showing in Yoast SEO sitemaps
67 | * Updated highlight.js version
68 | * Updated minimum WP version to 4.7
69 | * Updated unit test framework
70 |
71 | ### v1.6.5 July 26, 2017 ###
72 | * Fixed some escaping issues in admin and new-line characters when saving to database (props davidanderson)
73 | * Updated highlight.js and clipboard.js versions
74 |
75 | ### v1.6.4 May 26, 2017 ###
76 | * Fixed an issue with the URL in the settings tabs (props davidanderson)
77 |
78 | ### v1.6.3 March 28, 2017 ###
79 | * Updated logging for multidimensional query parameters (props mnelson4)
80 |
81 | ### v1.6.2 March 10, 2017 ###
82 | * Fixed bug in HTTPS download URLs.
83 | * Fixed bug in download URL permissions.
84 |
85 | ### v1.6.0 March 9, 2017 ###
86 | * Added ability to download request and response fields as JSON files, as well as copy to clipboard.
87 | * Added button on settings page to Purge All Log Entries.
88 | * Tweaked some of the ElasticPress routes that skip logging.
89 |
90 | ### v1.5.2 February 21, 2017 ###
91 | * Fixed a bug with ElasticPress logging getting stuck in a loop regarding the _nodes/plugins URL.
92 |
93 | ### v1.5.1 February 15, 2017 ###
94 | * Removed hidden custom taxonomies from the navigation menu admin (props [phh](https://github.com/phh) for the pull request).
95 |
96 | ### v1.5.0 February 2, 2017 ###
97 | * Added logging for the user making the request (props [drsdre](https://github.com/drsdre) for the pull request).
98 | * Added Settings and Log links from the Plugins page.
99 | * Updated term fetching when viewing log entries for fewer database queries and better performance.
100 | * Updated highlight.js to 9.9.0
101 |
102 | ### v1.4.0 January 23, 2017 ###
103 | * Added the ability to filter routes for logging, either include or exclude specific routes.
104 |
105 | ### v1.3.0 December 5, 2016 ###
106 | * Added support for logging HTTP_X_FORWARDED_FOR, useful for servers behind a proxy or load balancer.
107 | * Changed plugin name to REST API Log
108 | * Changed the wp-rest-api-log post type 'public' setting to false to prevent it from showing up in searches.
109 | * Updated Highlight JS version to 9.7.0
110 | * Updated the internal process for granting administrator role access to the custom post type
111 | * Bug fix: Header values with colons were not being stored correctly.
112 | * Bug fix: Use proper HTML escaping when viewing log entries.
113 |
114 | ### v1.2.0 July 6, 2016 ###
115 | * Added support for [ElasticPress](https://wordpress.org/plugins/elasticpress/) logging
116 | * Fixed undefined constant error on Help page (props vinigarcia87)
117 |
118 | ### v1.1.1 May 15, 2016 ###
119 | * Fixed error during activation (props pavelevap)
120 |
121 | ### v1.1.0 April 28, 2016 ###
122 | * Added cron job to cleanup old log entries
123 | * Added setting to exclude the WP core /oembed API endpoint
124 | * Don't diplay log entries in the Insert Link modal
125 |
126 | ### v1.0.0-beta2 April 10, 2016 ###
127 | * Switched from custom tables to built-in WordPress tables using a custom post type (wp-rest-api-log)
128 | * Method, status, and source are now tracked using taxonomies
129 | * Viewing log entries now uses the standard WordPress admin UI, includes filters for method, status, and source
130 | * Added admin settings with the option to enable or disable logging
131 | * Added WP-CLI support: wp rest-api-log
132 | * Added .pot file to support translations
133 |
134 | **NOTE: if you are upgrading from the previous version, you can run the "wp rest-api-log migrate" WP-CLI command to migrate your existing logs into the new custom post type**
135 |
136 | ### v1.0.0-beta1 July 9, 2015 ###
137 | * Initial release
138 |
139 |
140 | ## Upgrade Notice ##
141 |
142 | ### v1.7.0 May 8, 2023 ###
143 | * Fixed bugs related to Method and Status filtering.
144 | * Removed deprecated FILTER_SANITIZE_STRING calls.
145 | * Updated highlight.js version
146 | * Updated clipboard.js version
147 |
148 | ## Frequently Asked Questions ##
149 |
150 | ### How do I use ElasticPress logging? ###
151 |
152 | [ElasticPress](https://wordpress.org/plugins/elasticpress/) is a plugin than interfaces WordPress to the [ElasticSearch](https://www.elastic.co/products/elasticsearch) search service. Because ElasticSearch has its own REST API for indexing and searching data, it was a natural fit to extend logging support via this REST API Logging plugin.
153 |
154 | You can go into Settings > ElasticPress to enable logging for requests & responses. You can also disable REST API logging if you only need ElasticPress logging.
155 |
156 |
157 | ## Screenshots ##
158 |
159 | ### 1. Sample list of log entries ###
160 | 
161 |
162 | ### 2. Sample log entry details ###
163 | 
164 |
165 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === REST API Log ===
2 | Contributors: gungeekatx
3 | Tags: wp rest api, rest api, wp api, api, json, json api, log, logging, elasticpress, elasticsearch
4 | Donate link: https://github.com/petenelson/wp-rest-api-log
5 | Requires at least: 4.7
6 | Tested up to: 6.2
7 | Stable tag: 1.7.0
8 | License: GPLv2 or later
9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html
10 |
11 | WordPress plugin to log REST API requests and responses
12 |
13 | == Description ==
14 |
15 | WordPress plugin to log [REST API](http://v2.wp-api.org/) requests and responses (for v2 of the API).
16 |
17 | Includes:
18 |
19 | * WordPress admin page to view and search log entries
20 | * API endpoint to access log entries via JSON
21 | * Filters to customize logging
22 | * Custom endpoint logging
23 | * ElasticPress logging
24 |
25 | Find us on [GitHub](https://github.com/petenelson/wp-rest-api-log)!
26 |
27 | Roadmap
28 |
29 | * Better search capabilities for log entries via the REST API endpoint
30 |
31 |
32 | == Installation ==
33 |
34 | 1. Upload the wp-rest-api-log directory to the `/wp-content/plugins/` directory
35 | 2. Activate the plugin through the 'Plugins' menu in WordPress
36 | 3. Go to Settings -> REST API Log to enable or disable logging
37 | 4. Go to Tools -> REST API Log to start viewing log entries
38 |
39 |
40 | == Changelog ==
41 |
42 | = v1.7.0 May 8, 2023 =
43 | * Fixed bugs related to Method and Status filtering.
44 | * Removed deprecated FILTER_SANITIZE_STRING calls.
45 | * Updated highlight.js version
46 | * Updated clipboard.js version
47 |
48 | = v1.6.9 September 9, 2022 =
49 | * Updated highlight.js version
50 | * Updated clipboard.js version
51 |
52 | = v1.6.8 October 30, 2020 =
53 | * Updated the Purge All Entries functionality in the admin to purge batches of 25 at a time.
54 | * Updated CLI purge command with a progress bar.
55 | * Fixed ClipboardJS error (props itowhid06)
56 |
57 | = v1.6.7 March 31, 2019 =
58 | * Added admin notice about running the plugin on a production server
59 | * Set the default purge days to 7
60 | * Updated clipboard.js version
61 |
62 | = v1.6.6 November 9, 2018 =
63 | * Moved taxonomy registration to a separate file, made taxonomies not public to prevent them from automatically showing in Yoast SEO sitemaps
64 | * Updated highlight.js version
65 | * Updated minimum WP version to 4.7
66 | * Updated unit test framework
67 |
68 | = v1.6.5 July 26, 2017 =
69 | * Fixed some escaping issues in admin and new-line characters when saving to database (props davidanderson)
70 | * Updated highlight.js and clipboard.js versions
71 |
72 | = v1.6.4 May 26, 2017 =
73 | * Fixed an issue with the URL in the settings tabs (props davidanderson)
74 |
75 | = v1.6.3 March 28, 2017 =
76 | * Updated logging for multidimensional query parameters (props mnelson4)
77 |
78 | = v1.6.2 March 10, 2017 =
79 | * Fixed bug in HTTPS download URLs.
80 | * Fixed bug in download URL permissions.
81 |
82 | = v1.6.0 March 9, 2017 =
83 | * Added ability to download request and response fields as JSON files, as well as copy to clipboard.
84 | * Added button on settings page to Purge All Log Entries.
85 | * Tweaked some of the ElasticPress routes that skip logging.
86 |
87 | = v1.5.2 February 21, 2017 =
88 | * Fixed a bug with ElasticPress logging getting stuck in a loop regarding the _nodes/plugins URL.
89 |
90 | = v1.5.1 February 15, 2017 =
91 | * Removed hidden custom taxonomies from the navigation menu admin (props [phh](https://github.com/phh) for the pull request).
92 |
93 | = v1.5.0 February 2, 2017 =
94 | * Added logging for the user making the request (props [drsdre](https://github.com/drsdre) for the pull request).
95 | * Added Settings and Log links from the Plugins page.
96 | * Updated term fetching when viewing log entries for fewer database queries and better performance.
97 | * Updated highlight.js to 9.9.0
98 |
99 | = v1.4.0 January 23, 2017 =
100 | * Added the ability to filter routes for logging, either include or exclude specific routes.
101 |
102 | = v1.3.0 December 5, 2016 =
103 | * Added support for logging HTTP_X_FORWARDED_FOR, useful for servers behind a proxy or load balancer.
104 | * Changed plugin name to REST API Log
105 | * Changed the wp-rest-api-log post type 'public' setting to false to prevent it from showing up in searches.
106 | * Updated Highlight JS version to 9.7.0
107 | * Updated the internal process for granting administrator role access to the custom post type
108 | * Bug fix: Header values with colons were not being stored correctly.
109 | * Bug fix: Use proper HTML escaping when viewing log entries.
110 |
111 | = v1.2.0 July 6, 2016 =
112 | * Added support for [ElasticPress](https://wordpress.org/plugins/elasticpress/) logging
113 | * Fixed undefined constant error on Help page (props vinigarcia87)
114 |
115 | = v1.1.1 May 15, 2016 =
116 | * Fixed error during activation (props pavelevap)
117 |
118 | = v1.1.0 April 28, 2016 =
119 | * Added cron job to cleanup old log entries
120 | * Added setting to exclude the WP core /oembed API endpoint
121 | * Don't diplay log entries in the Insert Link modal
122 |
123 | = v1.0.0-beta2 April 10, 2016 =
124 | * Switched from custom tables to built-in WordPress tables using a custom post type (wp-rest-api-log)
125 | * Method, status, and source are now tracked using taxonomies
126 | * Viewing log entries now uses the standard WordPress admin UI, includes filters for method, status, and source
127 | * Added admin settings with the option to enable or disable logging
128 | * Added WP-CLI support: wp rest-api-log
129 | * Added .pot file to support translations
130 |
131 | **NOTE: if you are upgrading from the previous version, you can run the "wp rest-api-log migrate" WP-CLI command to migrate your existing logs into the new custom post type**
132 |
133 | = v1.0.0-beta1 July 9, 2015 =
134 | * Initial release
135 |
136 |
137 | == Upgrade Notice ==
138 |
139 | = v1.7.0 May 8, 2023 =
140 | * Fixed bugs related to Method and Status filtering.
141 | * Removed deprecated FILTER_SANITIZE_STRING calls.
142 | * Updated highlight.js version
143 | * Updated clipboard.js version
144 |
145 | == Frequently Asked Questions ==
146 |
147 | = How do I use ElasticPress logging? =
148 |
149 | [ElasticPress](https://wordpress.org/plugins/elasticpress/) is a plugin than interfaces WordPress to the [ElasticSearch](https://www.elastic.co/products/elasticsearch) search service. Because ElasticSearch has its own REST API for indexing and searching data, it was a natural fit to extend logging support via this REST API Logging plugin.
150 |
151 | You can go into Settings > ElasticPress to enable logging for requests & responses. You can also disable REST API logging if you only need ElasticPress logging.
152 |
153 |
154 | == Screenshots ==
155 |
156 | 1. Sample list of log entries
157 | 2. Sample log entry details
158 |
--------------------------------------------------------------------------------
/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 | plugin_root = dirname( dirname( __FILE__ ) );
28 | if ( ! file_exists( $this->plugin_root . '/vendor/autoload.php' ) ) {
29 | throw new Exception(
30 | 'ERROR' . PHP_EOL . PHP_EOL .
31 | 'You must use Composer to install the test suite\'s dependencies.' . PHP_EOL
32 | );
33 | }
34 | $autoloader = require_once $this->plugin_root . '/vendor/autoload.php';
35 |
36 | // Give access to tests_add_filter() function.
37 | require_once $wp_develop_dir . '/tests/phpunit/includes/functions.php';
38 |
39 | tests_add_filter( 'muplugins_loaded', [ $this, 'manually_load_plugin' ] );
40 |
41 | // Start up the WP testing environment.
42 | require $wp_develop_dir . '/tests/phpunit/includes/bootstrap.php';
43 | }
44 |
45 | /**
46 | * Manually load the plugin being tested.
47 | */
48 | public function manually_load_plugin() {
49 | require $this->plugin_root . '/wp-rest-api-log.php';
50 | }
51 | }
52 |
53 | $wp_rest_api_log_tests = new WP_REST_API_Log_Tests_Bootstrap();
54 | $wp_rest_api_log_tests->bootstrap();
55 |
--------------------------------------------------------------------------------
/tests/test-common.php:
--------------------------------------------------------------------------------
1 | assertTrue( ! empty( $valid_methods ) );
19 | $this->assertContains( 'GET', $valid_methods );
20 | }
21 |
22 | /**
23 | * Test that GET is a valid method
24 | */
25 | function test_valid_method() {
26 | $valid_methods = WP_REST_API_Log_Common::valid_methods();
27 | $this->assertTrue( WP_REST_API_Log_Common::is_valid_method( 'GET' ) );
28 | }
29 |
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/tests/test-filters.php:
--------------------------------------------------------------------------------
1 | assertEquals( "^\/wp\/v2$", $route_regex );
19 |
20 | // Wildcard matches.
21 | $route_regex = WP_REST_API_Log_Filters::route_to_regex( '/wp/*' );
22 | $this->assertEquals( "^\/wp\/.*$", $route_regex );
23 |
24 | $route_regex = WP_REST_API_Log_Filters::route_to_regex( '/wp/v2/*' );
25 | $this->assertEquals( "^\/wp\/v2\/.*$", $route_regex, '/wp/v2/*' );
26 |
27 | // Regex should have no changes.
28 | $route_regex = WP_REST_API_Log_Filters::route_to_regex( '^/wp/v2/.*' );
29 | $this->assertEquals( '^/wp/v2/.*', $route_regex );
30 |
31 | // This is not treated as regex, so it get mangled.
32 | $route_regex = WP_REST_API_Log_Filters::route_to_regex( '.*/wp/v2/$' );
33 | $this->assertEquals( "^..*\/wp\/v2\/$$", $route_regex );
34 | }
35 |
36 | public function test_filter_modes() {
37 | $modes = WP_REST_API_Log_Filters::filter_modes();
38 | $this->assertArrayHasKey( '', $modes );
39 | $this->assertArrayHasKey( 'log_matches', $modes );
40 | $this->assertArrayHasKey( 'exclude_matches', $modes );
41 | }
42 |
43 | public function test_route_logging_all_routes() {
44 |
45 | $option_key = 'wp-rest-api-log-settings-routes';
46 |
47 | // Set the options to log everything.
48 | $option_value = array(
49 | 'route-log-matching-mode' => '',
50 | );
51 |
52 | update_option( 'wp-rest-api-log-settings-routes', $option_value );
53 |
54 | // Make sure we can log any route.
55 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/wp/v2' ) );
56 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/wp/v2/posts' ) );
57 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/wp/v2/users' ) );
58 |
59 | }
60 |
61 |
62 | public function test_route_logging_only_matched_routes() {
63 |
64 | $option_key = 'wp-rest-api-log-settings-routes';
65 |
66 | // Set the options to log only matching routes.
67 | $option_value = array(
68 | 'route-log-matching-mode' => 'log_matches',
69 | 'route-filters' =>
70 | "/wp/v2
71 | /route/wildcard*
72 | ^\/route\/regex-exact$
73 | ^\/route\/regex-wildcard.*$"
74 | );
75 |
76 | update_option( 'wp-rest-api-log-settings-routes', $option_value );
77 |
78 | // Exact match.
79 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/wp/v2' ), '/wp/v2' );
80 |
81 | // Basic wildcard.
82 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/route/wildcard-route' ), '/route/wildcard-route' );
83 |
84 | // Exact regex
85 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/route/regex-exact' ), '/route/regex-exact' );
86 |
87 | // Wildcard regex
88 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/route/regex-wildcard/test' ), '/route/regex-wildcard/test' );
89 |
90 | // Test non-matching routes.
91 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/some/route' ), '/some/route' );
92 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/route/wildercard' ), '/route/wildercard' );
93 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/route/exact-regex' ), '/route/exact-regex' );
94 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/route/regexwildcard' ), '/route/regexwildcard' );
95 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/wp/v2/posts' ), '/wp/v2/posts' );
96 |
97 | }
98 |
99 | public function test_route_logging_excluded_matched_routes() {
100 |
101 | $option_key = 'wp-rest-api-log-settings-routes';
102 |
103 | // Set the options to log only matching routes.
104 | $option_value = array(
105 | 'route-log-matching-mode' => 'exclude_matches',
106 | 'route-filters' =>
107 | "/wp/v2
108 | /route/wildcard*
109 | ^\/route\/regex-exact$
110 | ^\/route\/regex-wildcard.*$"
111 | );
112 |
113 | update_option( 'wp-rest-api-log-settings-routes', $option_value );
114 |
115 | // Exact match.
116 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/wp/v2' ), '/wp/v2' );
117 |
118 | // Basic wildcard.
119 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/route/wildcard-route' ), '/route/wildcard-route' );
120 |
121 | // Exact regex
122 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/route/regex-exact' ), '/route/regex-exact' );
123 |
124 | // Wildcard regex
125 | $this->assertFalse( WP_REST_API_Log_Filters::can_log_route( '/route/regex-wildcard/test' ), '/route/regex-wildcard/test' );
126 |
127 | // Test non-matching routes, should all be logged.
128 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/some/route' ), '/some/route' );
129 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/route/wildercard' ), '/route/wildercard' );
130 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/route/exact-regex' ), '/route/exact-regex' );
131 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/route/regexwildcard' ), '/route/regexwildcard' );
132 | $this->assertTrue( WP_REST_API_Log_Filters::can_log_route( '/wp/v2/posts' ), '/wp/v2/posts' );
133 |
134 | }
135 |
136 | }
137 |
--------------------------------------------------------------------------------
/tests/test-settings.php:
--------------------------------------------------------------------------------
1 | assertNotEmpty( $settings );
20 | $this->assertNotEmpty( $settings['logging-enabled'], 'logging-enabled is empty' );
21 |
22 | }
23 |
24 | /**
25 | * Test that routes have default settings
26 | */
27 | function test_default_routes_settings() {
28 |
29 | $settings = WP_REST_API_Log_Settings_Routes::get_default_settings();
30 | $this->assertNotEmpty( $settings );
31 | $this->assertNotEmpty( $settings['ignore-core-oembed'], 'ignore-core-oembed is empty' );
32 |
33 | }
34 |
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/tests/test-taxonomies.php:
--------------------------------------------------------------------------------
1 | assertInstanceOf( '\WP_Taxonomy', get_taxonomy( $taxonomy ) );
24 | }
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/uninstall.php:
--------------------------------------------------------------------------------
1 | prefix . 'wp_rest_api_log',
11 | $wpdb->prefix . 'wp_rest_api_logmeta',
12 | );
13 |
14 | foreach ( $tables as $table_name ) {
15 | $wpdb->query( "drop table if exists $table_name");
16 | }
17 |
18 |
19 | $options = array(
20 | 'wp-rest-api-log-meta-dbversion',
21 | 'wp-rest-api-log-entries-dbversion',
22 | 'wp-rest-api-log-settings-general',
23 | );
24 |
25 | foreach ( $options as $option ) {
26 | delete_option( $option );
27 | }
28 |
--------------------------------------------------------------------------------
/wp-rest-api-log.php:
--------------------------------------------------------------------------------
1 |