Fieldsweep for ACF

By anu771063

0+ active installationsVersion 1.0.0

Audit your custom fields: which hold data, which your theme reads, which are never filled in, left-behind data and broken links. Clean up safely.

Description

Sites that use Advanced Custom Fields collect fields over the years. Some were added for a design that was later dropped, some were deleted but left their values in the database, and some point to images or posts that were removed long ago. Nobody knows which fields are safe to delete, so they stay forever.

Fieldsweep answers that question for every field, then helps you clean up in a way that can always be undone.

What it tells you about each field

  • Status: used (holds data and your code reads it), data not in code, in code but never filled in, or unused.
  • Stored on: how many pages, posts, products, terms, users, comments, options pages and blocks hold a value.
  • Filled in: how often it is actually filled, for example “Subtitle: 2 of 4 pages (50%)”. Fields that are always saved empty are listed too.
  • Where the code reads it: each file and line in your theme where the field is read with get_field(), the_field(), have_rows(), get_sub_field(), get_post_meta() and similar calls, including Twig templates.
  • Stored values: the items that hold a value, with links to edit them.

Sub fields of repeaters, groups and flexible content layouts are covered, each with its full path, for example “Slides > Image”. Field groups saved in the database, in JSON files and in PHP code are all included.

What it finds

  • Left-behind data: values saved for fields that were later deleted. ACF does not remove them, so they stay in the database. Fieldsweep finds them on posts, terms, users, comments and options pages, and shows how much space they use.
  • Broken links: image, file, gallery, post object, page link, relationship, user and taxonomy fields that still point to media, posts, users or terms that were deleted or moved to the trash. These show up as broken images or empty links on the site.
  • Unused fields: fields with no data that your code never reads. These are usually safe to delete in ACF.

Safe clean-up

  • The scan only reads. Nothing changes until you choose a clean-up and confirm it.
  • Everything goes to a bin first. Each clean-up is kept with the exact stored values, and one click restores it.
  • Newer edits are never overwritten. If something new was saved in a place since the clean-up, restoring skips that value.
  • Broken link fixes keep the rest of the value. Only the missing IDs are removed; the other images in a gallery stay.
  • Only data of deleted fields counts as left behind. Fields in disabled or trashed field groups, and fields defined in JSON or PHP, are never treated as deleted. While ACF is inactive, nothing can be cleaned.
  • Uninstalling puts everything in the bin back, so removing the plugin never loses data.

For developers

WP-CLI commands:

  • wp fieldsweep scan
  • wp fieldsweep fields --status=unused --format=csv
  • wp fieldsweep orphans
  • wp fieldsweep clean-orphans --yes
  • wp fieldsweep fix-broken --yes
  • wp fieldsweep bin and wp fieldsweep restore <batch>

The Fields screen can be downloaded as a CSV file.

Privacy

Fieldsweep makes no requests to other servers, adds nothing to the front of your site and collects no data. It reads your field groups, the values stored for them and your theme’s code files, and keeps the result in your own database.

Advanced Custom Fields and ACF are trademarks of WP Engine. Fieldsweep is an independent plugin and is not affiliated with or endorsed by WP Engine.

Installation

  1. Install and activate Advanced Custom Fields, ACF Pro or Secure Custom Fields if it is not active already.
  2. Install Fieldsweep from the Plugins screen and activate it.
  3. Go to Tools > Fieldsweep and click “Scan now”.
  4. If your own code reads fields from a plugin folder, add that folder under Settings so it is searched too.

FAQ

Does it work with ACF Pro and Secure Custom Fields?

Yes. It reads field groups through the same functions, so ACF, ACF Pro and Secure Custom Fields all work. Repeaters, groups, flexible content, clones and options pages are supported.

A field says “Data, not in code”. Can I delete it?

Not without checking. It means the field has values but its name was not found in a call that reads fields in the code searched. It may still be read another way: through get_fields(), the REST API, GraphQL, a page builder, or a plugin folder you have not added in Settings. The Overview tells you when your code calls get_fields().

Does it delete fields from ACF?

No. Field groups and fields are managed in ACF. Fieldsweep only cleans stored values, and links to each field group so you can delete unused fields there.

Are clean-ups permanent?

No. Every clean-up goes to the bin and can be restored, until you choose “Delete permanently” in the bin.

Will it slow down my site?

No. Fieldsweep only runs when you open its screen or run a scan, and only for administrators. It adds nothing to the pages visitors see.

Changelog

1.0.0

  • First release.