| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // Include all the different event loggers. |
| 31 | - foreach ( array( 'posts', 'plugins', 'core', 'options', 'users', 'comments', 'attachment' ) as $event ) { | |
| 31 | + foreach ( [ 'posts', 'plugins', 'core', 'options', 'users', 'comments', 'attachment' ] as $event ) { | |
| 32 | 32 | require_once dirname( __FILE__ ) . '/events/' . $event . '.php'; |
| 33 | 33 | $class = 'P_Event_' . ucfirst( $event ); |
| 34 | 34 | new $class(); |
| 35 | 35 | } |
| @@ -45,8 +45,13 @@ | ||
| 45 | 45 | // Get the author name, if the user is logged in. |
| 46 | 46 | $user = get_user_by( 'id', get_current_user_id() ); |
| 47 | 47 | $author = ! $user ? 'Unauthenticated user' : $user->data->user_login; |
| 48 | 48 | |
| 49 | + // If it's a scheduled task running, we override the name. | |
| 50 | + if ( defined( 'DOING_CRON' ) && DOING_CRON ) { | |
| 51 | + $author = 'WPCron'; | |
| 52 | + } | |
| 53 | + | |
| 49 | 54 | // Exception for when the action is 'logged in'. |
| 50 | 55 | if ( $args['action'] == 'logged in' ) { |
| 51 | 56 | $author = $args['object_name']; |
| 52 | 57 | } |
| @@ -62,9 +67,9 @@ | ||
| 62 | 67 | // Insert into the logs. |
| 63 | 68 | global $wpdb; |
| 64 | 69 | $wpdb->insert( |
| 65 | 70 | $wpdb->prefix . 'patchstack_event_log', |
| 66 | - array( | |
| 71 | + [ | |
| 67 | 72 | 'author' => $author, |
| 68 | 73 | 'ip' => $this->get_ip(), |
| 69 | 74 | 'object' => isset( $args['object'] ) ? $args['object'] : '', |
| 70 | 75 | 'object_id' => isset( $args['object_id'] ) ? (int) $args['object_id'] : '', |
| @@ -71,10 +76,10 @@ | ||
| 71 | 76 | 'action' => isset( $args['action'] ) ? $args['action'] : '', |
| 72 | 77 | 'object_name' => isset( $args['object_name'] ) ? $args['object_name'] : '', |
| 73 | 78 | 'date' => current_time( 'mysql' ), |
| 74 | 79 | 'flag' => '', |
| 75 | - ), | |
| 76 | - array( '%s', '%s', '%s', '%d', '%s', '%s', '%s' ) | |
| 80 | + ], | |
| 81 | + [ '%s', '%s', '%s', '%d', '%s', '%s', '%s' ] | |
| 77 | 82 | ); |
| 78 | 83 | } |
| 79 | 84 | } |
| 80 | 85 | } |