get_page( $page, $per_page ); $rows = $result['rows']; $total = $result['total']; $pages = max( 1, (int) ceil( $total / $per_page ) ); $pagination = array( 'current' => $page, 'total' => $pages, 'count' => $total, 'base' => admin_url( 'admin.php?page=' . self::PAGE_SLUG ), ); include PRAUTOBLOGGER_PLUGIN_DIR . 'templates/admin/gen-history-page.php'; } /** * Enqueue assets for the generation history page. * * @param string $hook_suffix Current admin page hook suffix. * @return void */ public function on_enqueue_assets( string $hook_suffix ): void { if ( 'admin_page_' . self::PAGE_SLUG !== $hook_suffix ) { return; } wp_enqueue_style( 'prautoblogger-admin', PRAUTOBLOGGER_PLUGIN_URL . 'assets/css/admin.css', array(), PRAUTOBLOGGER_VERSION ); wp_enqueue_style( 'prautoblogger-gen-history', PRAUTOBLOGGER_PLUGIN_URL . 'assets/css/gen-history.css', array( 'prautoblogger-admin' ), PRAUTOBLOGGER_VERSION ); wp_enqueue_script( 'prautoblogger-gen-history', PRAUTOBLOGGER_PLUGIN_URL . 'assets/js/gen-history.js', array(), PRAUTOBLOGGER_VERSION, true ); wp_localize_script( 'prautoblogger-gen-history', 'prabGenHistory', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'action' => 'prautoblogger_gen_run_io', 'nonce' => wp_create_nonce( self::IO_NONCE_ACTION ), 'strings' => array( 'loading' => __( 'Loading…', 'prautoblogger' ), 'error' => __( 'Failed to load stage I/O — try again.', 'prautoblogger' ), 'noStages' => __( 'No generation log entries for this run.', 'prautoblogger' ), 'pruned' => __( '[Output pruned by retention policy]', 'prautoblogger' ), 'noOutput' => __( '[No output stored for this stage]', 'prautoblogger' ), 'noInput' => __( '[No request payload stored for this stage]', 'prautoblogger' ), ), ) ); } /** * Build the URL to the generation history page. * * @param int $page Optional page number. * @return string Admin URL. */ public static function url( int $page = 1 ): string { $base = admin_url( 'admin.php?page=' . self::PAGE_SLUG ); return $page > 1 ? $base . '&paged=' . $page : $base; } }