WP Manifestindependent plugin directory
manifest / performance / exclude-postmeta-form-keys

Exclude Postmeta Form Keys for WooCommerce WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

Prevent a slow query during product or order creation and editing within wp-admin

★ 0stars
24release downloads
≈10active sites
0.2.3latest · 2 years ago

Install

Download exclude-postmeta-form-keys.0.2.3.zip From the 0.2.3 release on GitHub, Apr 8, 2024

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/basecardhero/exclude-postmeta-form-keys/releases/download/0.2.3/exclude-postmeta-form-keys.0.2.3.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Prevent the postmeta_form_keys query from running on Product or Order admin pages within WordPress.

The Problem

When creating or editing a post type in WordPress, a query against the post meta table is ran that will populate the Custom Fields meta boxes. These can be toggled on and off using the Screen Options. However, the query is still ran when the Custom Fields are toggle off. The query becomes somewhat inefficient when the postmeta table gets "large" (4 million+ rows in our case), the query can take 10 to 20 seconds.

This is what the query looks like by default.

SELECT DISTINCT meta_key
FROM wp_postmeta
WHERE meta_key NOT BETWEEN '_' AND '_z'
HAVING meta_key NOT LIKE '_%'
ORDER BY meta_key
LIMIT 30

The Solution

WordPress provides the postmeta_form_keys filter allowing you to "pre-fetch" your own meta keys. By hooking into this filter and returning an empty array, WordPress will skip the costly query. In our case, we weren't using the custom post meta fields, so there was no harm done.

Installation

  1. Download the latest release
  2. Follow the instructions provided by the WordPress documentation.

Development

I usually develop on Mac using terminal. This is probably different on Windows.

  1. Clone the repository into the plugins directory of your WordPress develop site.
  2. Create a copy of the .makenv file. cp .makenv.sample .makenv.
  3. Update .makenv with your test database information.
  4. Run make setup-tests
  5. Run composer test to run integration tests.
  6. Run composer all to run php linting, WordPress code standards, and phpunit all in one.

Releases

4 releases. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
0.2.3 latest
Apr 8, 2024 2 years ago
exclude-postmeta-form-keys.0.2.3.zip
10
Dec 16, 2023 2 years ago
exclude-postmeta-form-keys.0.2.2.zip
6
Sep 8, 2023 3 years ago
exclude-postmeta-form-keys.0.2.1.zip
7
Jun 21, 2023 3 years ago
exclude-postmeta-form-keys.0.2.0.zip
1

Active-site estimate ≈10 comes from the median of recent superseded releases. Method.

A grade

Security

Exclude Postmeta Form Keys for WooCommerce 0.2.3 · audited by WP Registry

No security issues found.

Audited release
0.2.3
Findings
none
Worst severity
—
Content hash
7ae9da792653640569b788e8…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.