內容簡介
總結:Site Stats Dashboard 是一個簡單的 WordPress 外掛,可以在管理面板中顯示您網站的統計數據,包括已發布的文章數量、已批准的評論數量和總訪問計數。
問題與回答:
1. Site Stats Dashboard 提供了哪些統計信息?
- 已發布的文章數量
- 已批准的評論數量
- 總訪問計數(每個前端頁面加載都被計算)
2. Site Stats Dashboard 使用哪些技術來提供統計數據並呈現管理儀表板?
- 使用 WordPress REST API 提供統計數據
- 使用 React 通過 wp.element package 渲染管理儀表板
3. 如何使用 Site Stats Dashboard 外掛?
- 在啟用後,點擊 WordPress 管理面板中的“Site Stats”菜單項目查看統計信息
4. Site Stats Dashboard 提供了哪個自定義的 REST API 端點?返回哪些統計信息?
- REST API 端點:http://your-site-url/wp-json/ssds/v1/stats
- 返回 JSON 響應,包含 post_count、comment_count 和 visit_count 關鍵字
5. 每次前端頁面加載時,Site Stats Dashboard 會做什麼?
- 跟蹤每次前端頁面加載以增加訪問計數,這意味著訪問計數在每次頁面加載時增加,而不僅僅是對唯一訪客。
6. Site Stats Dashboard 的授權是什麼?
- 本外掛授權為 GPLv2 或更新版本
7. 如何訪問 Site Stats Dashboard 的 REST API 端點?
- 需要擁有 manage_options 權限的使用者(通常為管理員)才可以訪問REST API端點
8. 使用 Site Stats Dashboard 的管理儀表板或 REST API 端點時,應該注意什麼?
- 確保您已登錄為管理員(或具有 manage_options 能力的用戶)
外掛標籤
開發者團隊
原文外掛簡介
Site Stats Dashboard is a simple WordPress plugin that displays your website’s statistics in the admin panel. It shows:
The number of published posts.
The number of approved comments.
The total visit count (each front-end page load is counted).
The plugin uses the WordPress REST API to provide the statistics and renders the admin dashboard using React via the wp.element package.
Features
Admin Dashboard: A dedicated admin page accessible from the WordPress dashboard under the “Site Stats” menu.
Live Statistics: Displays post count, comment count, and visit count.
REST API Integration: Provides a custom REST API endpoint (ssds/v1/stats) that returns the site statistics.
React-Based UI: Uses React (via the built-in wp.element library) for the admin dashboard interface.
Visit Tracking: Tracks every front-end page load to increment the visit counter.
Usage
Admin Panel: Once activated, click on the “Site Stats” menu item in the WordPress admin sidebar to see the statistics.
REST API:
The plugin registers a REST API endpoint at:
http://your-site-url/wp-json/ssds/v1/stats
This endpoint returns a JSON response with the keys post_count, comment_count, and visit_count.
Note: Access to the REST API endpoint is restricted to users with the manage_options capability (typically administrators).
Visit Tracking:
Every time a front-end page is loaded (excluding admin pages and AJAX requests), the plugin increments the visit counter. This means the visit count increases on every page load, not only for unique visitors.
License
This plugin is licensed under the GPLv2 or later.
Additional Notes
The admin dashboard interface is built using React without a build process (JSX is not used). If you later decide to use JSX or more advanced React features, you’ll need to integrate a build system (e.g., webpack with Babel).
Ensure you are logged in as an administrator (or a user with the manage_options capability) when accessing the plugin dashboard or the REST API endpoint.
