plugin = $plugin; } /** * Renders the page. */ public function render(): void { $channel_label = $this->plugin->channel()->label(); global $wpdb; if ( ! current_user_can( Plugin::CAPABILITY ) ) { return; } // phpcs:disable WordPress.Security.NonceVerification.Recommended -- read-only filters. $level = isset( $_GET['level'] ) ? sanitize_key( wp_unslash( $_GET['level'] ) ) : ''; $paged = isset( $_GET['paged'] ) ? max( 1, absint( $_GET['paged'] ) ) : 1; // phpcs:enable WordPress.Security.NonceVerification.Recommended $level = in_array( $level, self::LEVELS, true ) ? $level : ''; $table = DbLogger::table(); $offset = ( $paged - 1 ) * self::PER_PAGE; // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- own table. if ( '' !== $level ) { $total = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i WHERE level = %s', $table, $level ) ); $rows = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE level = %s ORDER BY id DESC LIMIT %d OFFSET %d', $table, $level, self::PER_PAGE, $offset ) ); } else { $total = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i', $table ) ); $rows = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i ORDER BY id DESC LIMIT %d OFFSET %d', $table, self::PER_PAGE, $offset ) ); } // phpcs:enable $format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); $base = admin_url( 'admin.php?page=' . Menu::LOG_SLUG ); ?>

created_at . ' UTC' ) ) ); ?> level_label( (string) $row->level ) ); ?> channel ); ?> message ); ?> context ) ) : ?>
pretty( (string) $row->context ) ); ?>
1 ) { echo '
'; echo wp_kses_post( paginate_links( array( 'base' => add_query_arg( 'paged', '%#%', '' !== $level ? add_query_arg( 'level', $level, $base ) : $base ), 'format' => '', 'current' => $paged, 'total' => $pages, ) ) ); echo '
'; } ?>
__( 'Debug', 'tidelist' ), 'info' => __( 'Info', 'tidelist' ), 'warning' => __( 'Warning', 'tidelist' ), 'error' => __( 'Error', 'tidelist' ), ); return $labels[ $level ] ?? $level; } /** * Pretty-prints stored JSON. * * @param string $json JSON. */ private function pretty( string $json ): string { $data = json_decode( $json, true ); return null === $data ? $json : (string) wp_json_encode( $data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); } }