[WordPress] 外掛分享: WST Data Tables

首頁 › 外掛目錄 › WST Data Tables
WordPress 外掛 WST Data Tables 的封面圖片
全新外掛
安裝啟用
—
尚無評分
4 天前
最後更新
—
問題解決
WordPress 6.0+ PHP 7.4+ v1.0.0 上架:2026-11-24

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「WST Data Tables」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

WST Data Tables lets you enter and manage data in a spreadsheet-like editor. It suits any data you keep in rows and columns: price lists, opening hours, schedules, staff lists, store locations, and more.
Data is stored in its own database tables, separate from posts and pages. The idea is that a developer designs the table and builds it into the theme, and the people who run the site update the cell values.
Use it in templates
Get the data as an array in your theme’s PHP and build the HTML. This example uses a table with the table key plans and the column keys name and price.

Values are not escaped. Use esc_html() or similar when you output them.
Use it with a shortcode
To use it without touching the theme, paste a shortcode into a Shortcode block in a post or page.
[wst_data_tables table="plans" show_labels="true"]

A single cell is output without a table wrapper. Line breaks become
tags. You can place it inside a sentence, such as The Standard plan is $[wst_data_tables table="plans" row="standard" column="price"] a month. A value shown on many pages is then updated in one place.
Features

Copy and paste from Excel or Google Sheets
Right-click to add or delete rows and columns, duplicate rows, and set column types (text, number, date)
Find and replace, and go to a row number or column letter
Column widths, row heights, and freezing 0 to 3 columns on the left
Right-click to copy the code (PHP or shortcode) for a cell, row, or column
Undo and redo, and Ctrl/Cmd+S to save
CSV import and export, optional row keys, and updates matched by row key (Shift_JIS files can be read too)
JSON export and import to move a table to another site
Public or private visibility per table, and locks that prevent changes to the column and row structure
Prompts for conflicting saves, reverting to the previous save, and Trash

Functions

wst_data_tables_get_data( $table, $key_style, $args ) returns an array of all rows
wst_data_tables_get_row( $table, $row, $key_style ) returns one row
wst_data_tables_get_column( $table, $column ) returns one column’s values from top to bottom
wst_data_tables_get_cell( $table, $cell ) / wst_data_tables_get_cell( $table, $column, $row ) returns one cell’s value
wst_data_tables_get_labels( $table, $key_style ) returns the column labels
wst_data_tables_get_columns( $table ) returns the label, key, and type of each column
wst_data_tables_get_row_keys( $table ) returns the row keys in saved order
wst_data_tables_get_info( $table ) returns the table’s ID, key, and name

wst_data_tables_get_list() returns the list of public tables
$table is a table key or table ID, $row is a row number (from 1) or row key, and $column is a column letter (A, B, C) or column key. Pass key as $key_style to use column keys as the array keys of each row.

Missing or private tables return an empty array or null.
Filtering and sorting
The third argument of get_data() filters (exact match, AND), sorts, and limits the rows. Sorting compares values by column type (text, number, date).
array( 'category' => 'business' ),
'orderby' => 'price',
'order' => 'asc',
'limit' => 10,
'keyed' => true,
) );
?>

With 'keyed' => true, row keys become the array keys of the rows. If row keys match post slugs, you can link from a list to detail pages.
In shortcodes, write where as column:value. && means all must match, and || means any matches.
[wst_data_tables table="plans" where="category:business && status:active" orderby="price" limit="10"]
[wst_data_tables table="plans" where="category:business || category:personal"]

REST API (read-only)
Disabled by default. To use it, add the following code to your theme’s functions.php or similar. There is no setting for it in the admin.
add_filter( 'wst_data_tables_rest_enabled', '__return_true' );

When enabled, anyone, even when logged out, can read public tables.
GET /wp-json/wst-data-tables/v1/tables/plans?keys=key&where[category]=business&orderby=price&limit=10

Writing is not possible. Private, trashed, and missing tables return 404.
Hooks for developers

wst_data_tables_changed (action) runs after a table changes, with the table ID and the reason. Use it to clear page caches, for example.
wst_data_tables_data (filter) changes values before they are output on the site, for example to format numbers or dates in one place.
wst_data_tables_capability (filter) changes the capability needed to edit data.
wst_data_tables_rest_enabled (filter) enables the REST API when it returns true.

Permissions

Administrators can do everything.
Data editors can edit cells, find and replace, export, and update existing rows from CSV by row key. Unless locked, they can also edit row keys, add, delete, and duplicate rows, and append rows from CSV.
Choose which roles are data editors on the Settings screen (Editor by default).
Only administrators can create, duplicate, and delete tables; change the table name, table key, and column settings; change visibility and locks; reorder the list; replace all rows from CSV; import JSON; and revert to the previous save.

Good to know

When the REST API is enabled, anyone can read every row and column of public tables, even if your pages show only some columns. Do not make a table public if it has columns that should stay private.
Text values are preserved when saved. Valid numbers and dates may be normalized on save. Escape them with esc_html() or similar when you output them in templates. The plugin escapes shortcode output.
Cell values are always returned as strings, whatever the column type.
Shortcode tables have no styling. Style them with your theme’s CSS.
Each table can have up to 1,000 rows and 100 columns. There is no limit on the number of tables.
The database must support the InnoDB engine.

Third-party libraries
The editor grid uses the following libraries, both under the MIT license.

Jspreadsheet CE 4.13.4: https://github.com/jspreadsheet/ce
jSuites 5.13.5: https://github.com/jsuites/jsuites

The bundled assets/vendor/jspreadsheet/index.js is the minified file published by its authors. The unminified source is available at the link above.
This plugin does not connect to any external services.

延伸相關外掛

文章
Filter
Mastodon