Linux 软件免费装
Banner图

Antwork Field Code for ACF & SCF

开发者 antwork
更新时间 2026年11月2日 01:40
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPL-3.0-or-later
版权网址: 版权信息

标签

php snippets acf theme development code generator

下载

1.0.0 1.1.0

详情介绍:

Antwork Field Code is a code generator for Advanced Custom Fields and Secure Custom Fields. It adds a "Field Code" box under the settings of each field group, with the snippets that display the fields of the saved group in a theme template: the code of each covered field, chosen in the list of fields, coloured by WordPress's own code editor, with a Copy button. The code follows the documentation of Advanced Custom Fields: get_field() returns values that are not escaped, so every value is escaped for where it is printed (esc_html(), esc_url(), esc_attr(), wp_kses_post(), wp_get_attachment_image() for images), and nothing is printed when a field is empty. It follows the WordPress Coding Standards, runs on PHP 7.4 to 8.4, and names its variables after your fields. It works with Advanced Custom Fields (free or Pro, version 6) and with Secure Custom Fields. Features Covered field types Repeater, Flexible Content, Gallery, Clone and field types added by other plugins show "This field type is not covered yet." Where the code works The code reads the fields of the current post, inside the Loop of a template for posts, pages or custom post types. A field group shown elsewhere (an options page, a taxonomy, a user, ACF Blocks...) still gets its code, with a line that names the location that is not covered yet. Antwork Field Code Pro Antwork Field Code Pro is a separate plugin, sold at antwork.fr. It adds the code of Repeater, Flexible Content, Gallery and Clone fields, and of field groups shown on options pages, taxonomy terms, users, comments, attachments and widgets. Where it would apply, the Field Code box says so in one sentence that you can dismiss. Ideas and bugs Have an idea for the plugin? Suggest it in the support forum, where bugs are reported too. Privacy Privacy: this plugin makes no external request. It collects no data, adds no tracking and stores no option in the database, so there is nothing to clean up when you delete it. Antwork Field Code is an independent plugin. It is not affiliated with or endorsed by Advanced Custom Fields or Secure Custom Fields. If it saves you time, a review on WordPress.org helps other developers find it.

安装:

  1. Install and activate Advanced Custom Fields or Secure Custom Fields.
  2. Install Antwork Field Code from the Plugins screen (Plugins > Add New, search for "Antwork Field Code") and activate it.
  3. Edit a field group and save it: the "Field Code" box appears under its settings.
  4. Copy the code of a field, or "Copy all", and paste it into a template of your theme (for example single.php), inside the Loop.

屏幕截图:

  • The same box with Secure Custom Fields: the code of a Group field and its sub-fields.
  • The help menu: report a bug, suggest an idea, leave a review, or copy your system info.

升级注意事项:

1.1.0 Hooks for other plugins; a field named args is now read into $args_field. 1.0.0 First release.

常见问题:

Does it need Advanced Custom Fields?

It needs Advanced Custom Fields (free or Pro, version 6) or Secure Custom Fields. Without one of them, it only shows a notice on the Plugins screen and does nothing else.

Who sees the Field Code box?

The users who may manage field groups: by default, administrators (the capability set for Advanced Custom Fields or Secure Custom Fields, manage_options unless changed).

Why does the box ask me to save the field group?

The code is built from the saved field group, on the server. Save the field group after adding or changing fields to see their code.

Is the code safe to paste in my theme?

Yes: every value is escaped for where it is printed, as the documentation of Advanced Custom Fields recommends. Text goes through esc_html(), links through esc_url(), attributes through esc_attr(), HTML content (Wysiwyg, Text Area with new lines) through wp_kses_post(), images through wp_get_attachment_image(), and the oEmbed field keeps its iframe only. Field names are written as plain PHP strings, so an unusual field name cannot break the code.

Why is my field type not covered?

Repeater, Flexible Content, Gallery and Clone fields are covered by Antwork Field Code Pro, a separate plugin. The field types of other plugins are not covered yet: tell us which one you need in the support forum.

Does it change my field groups or my database?

No. It reads the field group and shows code. It writes nothing in the database, makes no external request and stores no settings.

Can another plugin change the code?

Yes. The filters awfc_field_renderers (cover or replace a field type), awfc_locations (add a location, such as an options page, with the post ID it passes to get_field()), awfc_location_post_id (change that post ID with the whole location rule), awfc_snippet_header and awfc_snippet_footer (add code before or after each snippet) are documented in the plugin's repository.

更新日志:

1.1.0 1.0.0