| 开发者 | swilson23 |
|---|---|
| 更新时间 | 2026年10月13日 03:27 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
[companystack_search], with Contact Form 7, WPForms and Gravity Forms (add a CSS class to your fields), and with any HTML form (data attributes). In those forms only the suggestions list is styled, never the form itself.companystack folder to /wp-content/plugins/, then activate it.wp-config.php instead of the database:
define( 'COMPANYSTACK_API_KEY', 'cs_your_key_here' );The plugin is free and open source (GPL). It needs a CompanyStack API key; the free plan requires no card and runs every feature, with smaller limits. Paid plans are for busier sites that need more requests per day or bigger directories.
Yes: a CompanyStack API key, which is free and needs no payment card. Get one at companystack.co.uk/signup, paste it under Settings › CompanyStack and click Test connection.
No. CompanyStack is an independent service and is not affiliated with, or endorsed by, Companies House. The data originates from the public register under the Open Government Licence v3.0, and each card and badge links to the official record.
With WooCommerce active, the checkout Company field suggests UK companies, and choosing one fills in address line 1 and 2, town, county and postcode, plus the company registration number field. The number is validated and saved with the order and shown in the order screen and emails. With the Checkout block, first make the Company field visible in the block's settings. Both options can be switched off under Settings › CompanyStack.
A complete form supplied by the plugin, as the Company Lookup Form block or [companystack_form]. It has a company name field with suggestions and the fields it fills in: company number, two address lines, town, county, postcode and company status. In the block settings (or with shortcode attributes) you choose which fields show, their labels and the placeholder.
Switch on "Add a send button" (show_submit="true") and the form emails what the visitor entered to the site administrator. Nothing is saved in the database and nothing is sent to CompanyStack beyond the company search itself. Developers can handle submissions with the companystack_form_submitted action, change or reject them with the companystack_form_submission filter, change the email with companystack_form_email, or switch the email off with companystack_form_send_email. Without a send button the fields simply join any form they sit inside.
Three ways, from simplest to most flexible.
preset, size, accent, text, surface and radius, for example [companystack_form preset="card" accent="#0a7d5a" radius="12"].:root or on a wrapper: --cstk-accent, --cstk-on-accent, --cstk-text, --cstk-muted, --cstk-surface, --cstk-border, --cstk-radius, --cstk-font, --cstk-control-height, --cstk-shadow, --cstk-space, and for status colours --cstk-ok, --cstk-ok-bg, --cstk-bad, --cstk-bad-bg, --cstk-warn, --cstk-warn-bg.cstk plus its design (cstk--clean, cstk--soft, cstk--underline, cstk--card, cstk--inline, cstk--inherit) and size (cstk--size-compact, cstk--size-regular, cstk--size-large). Fields are .cstk-input, labels .cstk-label, buttons .cstk-button. Components are .companystack-form, .companystack-search, .companystack-card, .companystack-badge, .companystack-directory and the suggestions list .companystack-ac (options .companystack-ac__option, name .companystack-ac__name, details .companystack-ac__meta).
Filters: companystack_suggestion_template (the markup of one suggestion, with the placeholders {company_name}, {company_number}, {status}, {postcode} and {sic_description}), companystack_autofill_targets (which fields are filled, by CSS selector), companystack_form_fields (the lookup form's fields) and companystack_theme_accent (the accent borrowed from your theme).
The suggestions list attached to Contact Form 7, WPForms, Gravity Forms and WooCommerce fields uses the site-wide design and takes its colours from the field it belongs to, so it suits dark themes without any set-up. The plugin never restyles those forms.
Add CSS classes to the form tags:
[text company class:companystack-autocomplete]
[text company-number class:companystack-fill-company_number]
[text address class:companystack-fill-address_line_1]
[text town class:companystack-fill-town]
[text postcode class:companystack-fill-postcode]
The script loads automatically on pages with such a form.
Open the field's Advanced settings and enter companystack-autocomplete in "CSS Classes" for the company name field, and companystack-fill-postcode (etc.) for the fields to fill. Available fields: company_number, address_line_1, address_line_2, town, county, postcode, country, address (the whole address on one line), company_status, company_type, date_of_creation and sic_codes.
Mark the fields with data attributes and add [companystack_autofill] (or the Company Search block) to the page:
<input name="company" data-companystack-autocomplete>
<input name="number" data-companystack-fill="company_number">
<input name="postcode" data-companystack-fill="postcode">
Developers can also map fields by CSS selector with the companystack_autofill_targets filter, and listen for the companystack:select browser event, whose detail.company holds the chosen company.
[companystack_form preset="card" title="Find your company" show_number="true" show_address1="true" show_address2="true" show_town="true" show_county="false" show_postcode="true" show_status="false" show_contact="false" show_submit="false" submit_label="Send"] (labels: label, placeholder, label_number, label_address1, label_address2, label_town, label_county, label_postcode, label_status)[companystack_search label="Company name" name="company_name" number_name="company_number" show_details="true"][companystack_card number="00445790" show_address="true" show_sic="true" show_filings="true"][companystack_badge number="00445790" show_name="true" link="true" show_inactive="false"][companystack_directory sic="62012" postcode="M1" town="" query="" status="active" limit="10" layout="list" show_filter="false"][companystack_autofill]preset, size, accent, text, surface and radius.
No. The key is only used by your web server. Visitors' browsers call your site's own REST endpoints (/wp-json/companystack/v1/…), which are nonce-protected and rate limited per visitor.
Settings (including the API key) in one option, the appearance choices in a second, a note of which welcome messages you have dismissed in a third, cached API answers and short-lived rate-limit counters as transients, and, if enabled, the company registration number on WooCommerce orders. Company Lookup Form submissions are emailed, not stored. Deleting the plugin removes everything except order data.
Forms keep working as normal text fields, cards, badges and directories are simply left out for visitors, and administrators see an explanatory notice on the page and on the settings screen. The plugin pauses requests briefly after errors so it never slows your site down.
Search requests carry a WordPress nonce, which is valid for up to 24 hours. If your cache keeps pages longer than about 12 hours, exclude the pages with company search forms (for example the checkout) or lower the cache lifetime. Cards, badges and directories are rendered on the server and cache normally.
By default the limit uses the connecting IP address, which behind a proxy may be the proxy's. If your proxy sets a trusted header, return the real address with the companystack_client_ip filter.
--cstk-*). It inherits your theme's font and colours, picks an accent from the theme palette, and respects dark themes, right-to-left languages, high-contrast mode, zoom and reduced motion.[companystack_form] shortcode, with a choice of fields, labels and an optional send button that emails the site administrator (nothing is stored; developers get an action and filters).companystack_suggestion_template, companystack_form_fields, companystack_form_submission, companystack_form_email, companystack_form_send_email and companystack_theme_accent; action companystack_form_submitted.