PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 3.3.10
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v3.3.10
3.3.10 3.3.9 3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 All 68 releases
← All changes | Core/Services/Logtivity_Logger.php +31 -4 3.3.9 → 3.3.10 View file →
@@ -66,8 +66,13 @@
66 66 */
67 67 public array $userMeta = [];
68 68
69 69 /**
70 + * @var bool
71 + */
72 + protected bool $includeInventory = false;
73 +
74 + /**
70 75 * @param ?int $userId
71 76 */
72 77 public function __construct(?int $userId = null)
73 78 {
@@ -255,10 +260,11 @@
255 260 * @return $this
256 261 */
257 262 public function addTrace(): self
258 263 {
259 - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
264 + $stack = (new Exception())->getTrace();
260 265 array_shift($stack);
266 + $stack = array_slice($stack, 0, 12);
261 267
262 268 $this->addMeta('Stack Trace', '**********');
263 269
264 270 foreach ($stack as $index => $stackItem) {
@@ -270,10 +276,23 @@
270 276 return $this;
271 277 }
272 278
273 279 /**
280 + * Send the current plugin/theme inventory with this log so the API's stored
281 + * copy stays in step with the change being logged. Captured at send time.
282 + *
274 283 * @return $this
275 284 */
285 + public function addInventory(): self
286 + {
287 + $this->includeInventory = true;
288 +
289 + return $this;
290 + }
291 +
292 + /**
293 + * @return $this
294 + */
276 295 public function stop(): self
277 296 {
278 297 $this->active = false;
279 298
@@ -300,9 +319,9 @@
300 319 * @return array
301 320 */
302 321 protected function getData(): array
303 322 {
304 - return [
323 + $data = [
305 324 'action' => $this->action,
306 325 'context' => $this->context,
307 326 'post_type' => $this->post_type,
308 327 'post_id' => $this->post_id,
@@ -311,8 +330,14 @@
311 330 'username' => $this->maybeGetUsersUsername(),
312 331 'user_meta' => $this->getUserMeta(),
313 332 'ip_address' => $this->maybeGetUsersIp(),
314 333 ];
334 +
335 + if ($this->includeInventory) {
336 + $data = array_merge($data, (new Logtivity_Site_Inventory())->get());
337 + }
338 +
339 + return $data;
315 340 }
316 341
317 342 /**
318 343 * Build the user meta array
@@ -341,11 +366,13 @@
341 366 {
342 367 if (
343 368 $this->options->shouldStoreProfileLink()
344 369 && $this->user->isLoggedIn()
345 - && ($profileLink = $this->user->profileLink())
346 370 ) {
347 - $this->addUserMeta('Profile Link', $profileLink);
371 + $profileLink = $this->user->profileLink();
372 + if ($profileLink) {
373 + $this->addUserMeta('Profile Link', $profileLink);
374 + }
348 375 }
349 376
350 377 return $this;
351 378 }