time(), 'user' => get_current_user_id(), 'a' => sanitize_key( $action ), 'm' => $message, 'post' => $post_id, ) ); update_option( self::OPTION, array_slice( $log, 0, self::MAX ), false ); } /** * The log, newest first. * * @return array> */ public static function all(): array { $log = get_option( self::OPTION, array() ); return is_array( $log ) ? $log : array(); } /** * The activity tab on the settings screen. */ public static function render(): void { $log = self::all(); echo '

' . esc_html__( 'Activity', 'outercite' ) . '

'; echo '

' . esc_html__( 'What the plugin did on this site: drafts made, changes marked live, fixes applied. The last 200 entries.', 'outercite' ) . '

'; if ( ! $log ) { echo '

' . esc_html__( 'Nothing yet.', 'outercite' ) . '

'; return; } echo ''; foreach ( $log as $row ) { $user = ! empty( $row['user'] ) ? get_userdata( (int) $row['user'] ) : null; $post = ! empty( $row['post'] ) ? get_post( (int) $row['post'] ) : null; echo ''; echo ''; echo ''; } echo '
' . esc_html__( 'When', 'outercite' ) . '' . esc_html__( 'Who', 'outercite' ) . '' . esc_html__( 'What', 'outercite' ) . '' . esc_html__( 'Page', 'outercite' ) . '
' . esc_html( wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), (int) $row['t'] ) ) . '' . esc_html( $user ? $user->display_name : __( 'WordPress (automatic)', 'outercite' ) ) . '' . esc_html( (string) $row['m'] ) . ''; if ( $post ) { $link = get_edit_post_link( $post->ID ); echo $link ? '' . esc_html( get_the_title( $post ) ) . '' : esc_html( get_the_title( $post ) ); } echo '
'; } }