Search by

messageagency / ma-default-content

messageagency

Seeds default demo content (pages, news, events, profiles, resources, listing pages, menus, and media) into fresh sites and PR multidevs.

Package info

bitbucket.org/messageagency/ma-default-content

Type:wordpress-plugin

pkg:composer/messageagency/ma-default-content

Statistics

Installs: 10

Dependents: 0

Suggesters: 0

1.4.0 2026-12-03 19:52 UTC

This package is auto-updated.

Last update: 2026-12-03 20:17:42 UTC


README

Seeds default demo content (pages, generic pages, news, events, profiles, resources, listing pages, menus, and media) so fresh sites and PR multidevs come up populated instead of empty.

Idempotent by design. Every seeded object is tagged, so re-runs and database clones never duplicate content:

  • Posts carry post meta _ma_seed_key (stable cross-site key, e.g. page:about).
  • Attachments carry post meta _ma_seed_ref (the source filename).
  • Menus created by the seeder carry term meta _ma_seed_menu (so unseed never touches a site's own menus that merely share a name).

Installation

Sites built from wp-composer-base install it with Composer from Packagist; no repositories entry is needed:

composer require messageagency/ma-default-content:^1.4

It lands in web/wp-content/plugins/ma-default-content/, the path the wp-composer-base Quicksilver script loads the seeder from. Packagist picks up new tags on its own: tag a release (1.4.1, 1.5.0) for changes to reach sites through composer update.

A site with its own demo content keeps that content outside the plugin and sets MA_DEFAULT_CONTENT_FIXTURES in wp-config.php (see A site's own fixture). Do not commit a copy of the plugin to edit its fixtures/: the copy stops getting updates.

Commands

wp ma-content seed [--dry-run]   # Create any missing default content.
wp ma-content status             # Count seeded posts / attachments.
wp ma-content unseed [--yes]     # Remove everything this plugin seeded.

seed is safe to run any number of times.

What ships in the box

  • fixtures/content.json: captured posts (core fields + raw ACF values keyed by ACF field key, featured image, taxonomy terms, page parent by slug), menus (items keyed by post seed-key, assigned to the three theme locations), and a media manifest.
  • fixtures/images/: the bundled media, sideloaded on seed.

A site's own fixture

A site with its own demo content keeps content.json and images/ in a folder of its own, so the plugin itself comes from Composer and updates normally. Point the seeder at it in wp-config.php:

define( 'MA_DEFAULT_CONTENT_FIXTURES', __DIR__ . '/private/default-content' );

or from code with the ma_default_content_fixture_dir filter. The constant wins when both are set; without either, the plugin's own fixtures/ is used. seed, status, unseed and the base's PR multidev hook all read the same folder.

  • search_forms in the fixture: the Search & Filter Pro widgets behind the News, Events and Resources listing pages (title, slug, and the widget's fields, settings and results path). They are seeded before posts and tagged with _ma_seed_key. Listing pages refer to them as {{sf:<slug>}}, which the seeder swaps for the new widget id, the same way {{form:<key>}} works for Gravity Forms.

On seed the media is sideloaded first, building old-id → new-id and old-url → new-url maps. Those maps rewrite post_content so that attachment IDs baked into ACF block JSON (e.g. "band_media":348), inline media URLs, and absolute links to the captured host all point at this site. Links to any other copy of the base (wp-composer-base.test, dev- or pr-N-wp-composer-base.pantheonsite.io) are rebased the same way. On Pantheon the target address is built from the environment (https://<env>-<site>.pantheonsite.io), because the seeder runs without a web request and home_url() would answer http. ACF fields are then resolved (media → new attachment id, relationship → new post id, taxonomy → term created if missing) and written with update_field() by field key.

Automatic triggers

  • New sites (terminus): composer.json → extra.build-env.install-cms runs wp plugin activate ma-default-content then wp ma-content seed after wp core install.
  • PR multidevs on wp-composer-base: the sync_code quicksilver hook (web/private/scripts/seed-default-content.php, wired in pantheon.yml) runs the seeder after each code push, in wipe mode, so every PR environment matches the current fixture exactly. It self-gates to the wp-composer-base site and to CI-created pr-<number> environments; live, test, dev and hand-made multidevs are left alone. Dev is excluded because its content predates the seeder and carries no _ma_seed_key meta, so seeding it would create a second copy of everything. Downstream sites created from this base ship the same hook but it no-ops for them; their PR multidevs inherit content by cloning their own dev environment.

Manual fallback for any environment:

terminus remote:wp wp-composer-base.<env> -- ma-content seed

Development

Bitbucket Pipelines runs two checks on every pull request and on master, both on PHP 8.2 and WordPress 6.9:

  • Lint: composer validate --strict, php -l, and WordPress Coding Standards with the rules in phpcs.xml.dist.
  • Smoke test: tests/smoke.sh seeds the fixture into a fresh WordPress install and checks the dry run, the counts, that a second seed changes nothing, that every {{ref:}}, {{sf:}}, __media__ and __term__ marker resolved to this site's ids, that no link still points at a wp-composer-base environment, the front page, the privacy policy page (Settings > Privacy) and menu locations, and --reset, --wipe and unseed.

CI has neither the MA theme nor ACF Pro, so tests/ci-stand-in.php goes into mu-plugins there: it registers the theme's post types, taxonomies and menu locations, and stubs update_field() / get_field() to store values as post meta under the field key.

To run them locally:

phpcs --standard=phpcs.xml.dist   # any WordPress Coding Standards 3 install
bash tests/smoke.sh --yes         # from the site's root, or set WP_PATH

The smoke test deletes every post of the fixture's types and every menu (--wipe), so run it on a throwaway site only; it refuses to start without --yes.

Re-capturing / refreshing the fixture

The fixture was captured from a reference environment with scripts/ma-capture.php. To refresh:

terminus remote:wp <site>.<env> -- eval-file - < scripts/ma-capture.php > /tmp/content-raw.json
# normalize menu -> location names, then download referenced media into fixtures/images/

Capturing ACF raw values (format_value=false) and keying them by field key is important: several field groups reuse names like files, so name-based writes would resolve to the wrong group.