Linux 软件免费装
Banner图

Spintax

开发者 301st
更新时间 2026年5月15日 01:42
PHP版本: 8.0 及以上
WordPress版本: 6.9
版权: GPLv2 or later
版权网址: 版权信息

标签

seo templates dynamic content spintax content generation

下载

2.0.3 2.1.0 2.1.1 1.5.0 2.0.0 2.0.1 2.0.2

详情介绍:

Spintax is a content-generation toolkit for WordPress. Author reusable templates in spintax markup (enumerations, permutations, conditionals, plural agreement), then either embed them inline via shortcodes / PHP, or bind them to ACF and post-meta fields so every matching post gets its own rendered variant on save, on a cron schedule, or on demand. A built-in Logs page surfaces what each Bulk Apply / Run-now walk did; a WP-CLI surface covers staging-to-production sync. Key features: Syntax based on the GTW (Generating The Web) standard.

安装:

  1. Upload the spintax folder to /wp-content/plugins/
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Create templates under the "Spintax" menu in the admin sidebar
  4. Embed templates using [spintax slug="my-template"] in posts/pages or spintax_render('my-template') in theme files
Recommended optional dependency: install Action Scheduler if you plan to use the "Bulk Apply" button on ACF / post-meta bindings, or schedule bindings via per-binding cron on a site with many matching posts. The plugin works without it — admins can use the synchronous "Run now" button on each binding card, and the same walk is available as wp spintax bindings apply --binding=<id> --all. Action Scheduler turns those into one-click chunked async jobs that don't block the request. If you already use WooCommerce or another plugin that bundles Action Scheduler, you're already set; the Bindings page only shows the install notice when AS isn't loaded.

屏幕截图:

  • Settings page with global variables editor.
  • Template list with shortcode, cache status, and cron schedule.
  • Binding edit form: three-tab layout (Source & Target / Behavior / Test), ACF combobox with stable field-key autofill, post-type and status scope filters, shared-template vs per-post source modes.

升级注意事项:

2.1.1 Bindings UX polish: Bulk Apply disables with a tooltip when Action Scheduler is missing, the stale-source banner promotes Run-now in that case, the ACF picker no longer empties out after a selection, and clean Run-now walks write a Logs entry so the success notice's CTA always has something to show. 2.1.0 Admin UX overhaul. New Logs page closes the "check logs" gap. Bindings form is now three keyboard-friendly tabs with a real ACF combobox. TTL fields use presets. Stale banner + trigger warning + Run-now sync button on the list. No data migration; recommended for binding users. 2.0.3 Adds runtime ACF target validation (closes a wrong-field-write path under ACF reactivation / WP-CLI imports), cumulative-failure tracking across Bulk Apply chunks (Stale badge no longer clears on partial failures), and a per-binding walk lock that refuses concurrent walks. Strongly recommended. 2.0.2 Documentation refresh for the 2.0 binding surface (Action Scheduler as a recommended optional dependency, full WP-CLI command set, variable scopes, scheduling, manual edits) plus an admin notice on the Bindings page when Action Scheduler isn't loaded. No functional changes to the engine. 2.0.1 Hot-fix for 2.0.0: cross-kind binding collisions, missing ACF field_key validation, Test panel scope-filter parity, Bulk Apply Stale-badge gating, and form value preservation on validation errors. Highly recommended if you're on 2.0.0. 2.0.0 Major release — adds ACF / post-meta bindings, per-binding cron, Bulk Apply with Action Scheduler, full WP-CLI surface, and a one-shot migration wizard for nested-spintax-for-acf users. No breaking changes to the existing template / shortcode / render API. 1.4.0 New {?VAR?then|else} conditional syntax, smarter sentence-end capitalisation around abbreviations, and a fix for #set directives with empty values. 1.1.0 Per-element permutation separators, auto-spacing for word separators, improved input sanitization. 1.0.1 Fixes permutation config handling, preview rendering, and scope isolation. Recommended update. 1.0.0 Initial release.

常见问题:

How do I create a template?

Go to Spintax > Add New in the WordPress admin. Enter a title and your spintax markup in the editor.

What syntax does the plugin use?

  • {a|b|c} — randomly picks one option
  • [a|b|c] — permutation: picks N elements, shuffles, joins with space
  • [<minsize=2;maxsize=3;sep=", ";lastsep=" and "> a|b|c|d] — configured permutation
  • %variable% — variable reference
  • #set %var% = value — local variable definition
  • {?VAR?then|else} — conditional: render a branch by truthiness of %VAR% (also {?!VAR?then} inverted)
  • {plural %Count%: form1|form2|form3} — plural agreement: picks the correct grammatical form by count (RU 3-form, EN 2-form)
  • /#comment#/ — block comment (stripped from output)
  • #include "slug" — embed another template
Full syntax reference with examples and a live playground: https://spintax.net/docs/syntax

Where can I learn more?

Does caching require Redis or Memcached?

The plugin uses the WordPress Object Cache API. With a persistent backend (Redis, Memcached), cached output persists across requests. Without one, templates are re-rendered on each page load.

Can I pass variables through shortcodes?

Yes: [spintax slug="greeting" name="Alice" city="Moscow"] makes %name% and %city% available inside the template.

What are ACF / post-meta bindings?

A binding pairs a Spintax template (or a per-post inline source) with one target field on one post type — for example "Posts → ACF: hero_subtitle". Configure it once under Spintax → Bindings and the plugin populates the field on every matching post on save, on a cron schedule, or on demand via Bulk Apply. Manual edits are preserved by default (hash-tracked); flags control whether the binding auto-seeds empty fields, regenerates on every save, or clears the field when the template renders to empty.

Can I bind to ACF fields?

Yes. Bindings support both ACF (text / textarea / wysiwyg, top-level fields) and plain post-meta keys. ACF Free and Pro are both supported; nested fields (repeater / flexible_content rows) are not supported in 2.0 — that lands in a later release. The form-side field picker auto-fills the stable ACF field key so writes work on the first save without ACF's reference-meta handshake.

Do I need Action Scheduler?

It's a recommended optional dependency for binding-heavy sites. The plugin works without it: admins can run a walk via the synchronous Run now button on each binding card, or wp spintax bindings apply --binding=<id> --all from the CLI. What Action Scheduler adds is chunked async execution, so:

  • The admin Bulk Apply button can dispatch a non-blocking background job instead of holding the request.
  • Per-binding cron schedules enqueue an async job instead of running the walk inline on the cron tick — useful on large catalogues where the synchronous path risks PHP-FPM timeouts.
Many WP shops already ship Action Scheduler bundled with WooCommerce or other plugins — check Plugins → Installed Plugins for "Action Scheduler" before installing it separately. If the Bindings admin page shows an "Action Scheduler is not installed" notice at the top, you don't have it loaded yet.

What's the difference between Bulk Apply and Run now?

Both walk every matching post for a binding and produce the same writes. They differ in how the walk runs:

  • Bulk Apply — dispatches the walk to Action Scheduler as chunked async jobs. The request returns immediately and you can watch progress on the Logs page. Requires Action Scheduler.
  • Run now — runs the entire walk synchronously in the current request. No async dependency, but the page blocks until the walk finishes. Available to administrators, and the recommended path on sites without Action Scheduler.
When Action Scheduler isn't loaded, the Bulk Apply button is disabled with a tooltip pointing at Run now / WP-CLI; the stale-source banner on the binding edit form promotes Run now to its primary action.

Where do I see Bulk Apply or Run now progress?

Spintax → Logs in the admin sidebar. Both paths log a completion entry per walk (e.g. Bulk Apply run_synchronously completed for binding <id> — wrote=N skipped=M cleared=K.), plus warnings for partial failures. The Logs page supports level filtering, substring search, and pagination; entries are kept in a ring buffer sized by Settings → Spintax → Max log entries.

What WP-CLI commands does the plugin add?

Five subcommands under wp spintax bindings:

  • wp spintax bindings list [--format=table|json|csv] — list all bindings on the site.
  • wp spintax bindings apply --binding=<id> [--all|--post=<id>] — run a binding against every matching post (--all) or a single post (--post=<id>). This is the synchronous fallback path for Bulk Apply.
  • wp spintax bindings test --binding=<id> --post=<id> — dry-run a binding against one post and report what would be written (target value, rendered preview, skip reason). Same logic as the admin Test panel; use this instead of apply when you want a preview.
  • wp spintax bindings export {--binding=<id>|--all} [> bindings.json] — emit one binding or the full store as JSON to stdout, deduped by (post_type, target.key).
  • wp spintax bindings import --file=bindings.json [--overwrite] [--dry-run] — import bindings from JSON. --overwrite updates matches on the same target triple; without it, duplicates are skipped. Use --dry-run to preview the plan without writing.
The export/import pair is the recommended staging→production sync path; bindings are not exposed over REST in 2.0.

What variables can I use inside a bound template?

A binding template sees four layered variable sources (later layers override earlier ones):

  • Global variables — the #set block in Settings → Spintax. Site-wide.
  • Per-binding overrides — a #set block in the binding's Variables tab. Applies to that binding only.
  • Post context (opt-in checkbox) — %post_id%, %post_title%, %post_url%, %post_slug%, %post_date%, %post_modified%, %author_id%, %author_name%.
  • ACF sibling fields (opt-in checkbox, ACF-target bindings only) — every top-level text / textarea / wysiwyg field in the same ACF group, available as %acf_<field_name>%. Siblings are always fresh on save: the binding runs after ACF persists.
The binding's source can also use the rest of the Spintax syntax ({a|b|c}, [a|b], {?VAR?then|else}, {plural %N%: …}, #include "slug", /#comment#/).

How do I schedule bindings to run automatically?

Two trigger paths, both configurable per binding under "Triggers":

  • Fire on post save (checkbox, default on) — runs after the post (and ACF, if present) finishes saving. Skipped on autosaves, bulk-edits, batch REST imports, revisions, and trash flips.
  • Cron schedule (dropdown: disabled / hourly / twicedaily / daily) — each binding gets its own scheduled tick. With Action Scheduler installed the tick enqueues an async walk; without it, the walk runs synchronously on the cron worker.
For a one-off "apply now", click Bulk Apply (async, needs Action Scheduler) or Run now (synchronous, admins) on the binding card.

How does the plugin handle manual edits to bound fields?

Each binding signs its last-rendered value and re-checks the target before every write. With Preserve manual edits enabled (default):

  • If the current value still matches the last render, the binding is free to regenerate.
  • If the value has been edited outside the binding, the run is skipped and the skip is logged.
Pair this with Regenerate on every save for a "refresh on save unless edited" workflow. With Auto-seed empty fields alone, the binding only writes when the target is empty — manual edits are preserved by definition. Cold-start safety net: when a binding first sees a post with non-empty target content and no prior render on file, it treats the existing value as a manual baseline and skips that post until the field is cleared or the binding's "Initialize from current value" flow is run.

I edited a template. Why aren't the changes showing up on the front end?

Bindings are a pre-generation system, not a render-on-read layer. The rendered string is stored in the target field; consumers (themes, blocks, REST readers) get that stored value directly. Editing the source template doesn't propagate to existing posts until a trigger writes a fresh value to each one. When you edit a template that has bindings pointing at it, the plugin:

  1. Bumps an internal render-cache version on each affected binding.
  2. Surfaces an admin notice on the template-edit screen ("N bindings depend on this template").
  3. Shows a "Stale: source template edited" badge on each affected binding's card.
To push the new content to existing posts, click Bulk Apply on each affected binding (or run wp spintax bindings apply --binding=<id> --all from the CLI). The Stale badge only clears when the entire walk completes with zero failures — partial-failure walks keep the badge so you notice the divergence and retry.

Is there a hard cap on bindings?

200 bindings per site. The store is a single autoloaded option (~500 bytes per binding), and the cap keeps autoload memory bounded. If you genuinely need more, please open an issue with your use case.

Which fields can't I bind to?

The form rejects a handful of unsafe targets at save time:

  • WordPress-internal meta keys (anything starting with _wp_, _edit_, _oembed_, etc.).
  • Plugin-internal _spintax_* slots used to store source, signatures, and cache versions.
  • wp_posts columns like post_title, post_content, post_excerpt. These are not post-meta and writing to them via the meta API would silently create shadow rows.
  • The same target name already bound by another binding — one binding per (post type, target field), whether the kind is ACF or post-meta.
  • For ACF targets: the stable ACF field key must be present and resolvable when ACF is loaded.

On multisite, are bindings shared across the network?

No — bindings are per-site. Each subsite manages its own. Use wp --url=site2 spintax bindings import --file=site1-bindings.json to copy bindings between subsites via the WP-CLI export/import round-trip.

Can I manage bindings via REST?

Not in 2.0; bindings are admin-only. The wp spintax bindings WP-CLI surface covers staging→production sync scenarios. REST API exposure is tracked for a later release.

I'm coming from nested-spintax-for-acf. Is there a migration path?

Yes. After activating Spintax 2.0, a dismissible admin banner points to Tools → Spintax Migration. The wizard scans for predecessor data, shows a per-row preview, and creates bindings deduped by (post type, target field). Per-post sources and variables are copied non-destructively — the old plugin's data stays in place until you delete it.

更新日志:

2.1.1 2.1.0 2.0.3 2.0.2 2.0.1 2.0.0 1.5.0 1.4.0 1.1.0 1.0.1 1.0.0