Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

All docs

Writing code in the editor

The editor knows WordPress. It suggests functions and hooks as you type, explains them, writes boilerplate for you, and flags mistakes before you save.

Autocomplete

Start typing and the editor suggests:

  • 6,800+ functions from WordPress, WooCommerce and PHP, with their parameters and a short description.
  • Over 5,000 hooks from WordPress and WooCommerce inside add_action() and add_filter(): about 2,500 from WordPress and 2,600 from WooCommerce.

Press Ctrl+Space to open the suggestions at any time. Press Enter or Tab to accept one.

The hook picker writes the callback

This is the fastest way to write a hook. Type:

add_action( '

Pick a hook from the list, for example save_post. Snipfire writes the whole thing with the hook's parameters already named, and puts the cursor inside the function:

add_action( 'save_post', function( $post_id, $post, $update ) {

}, 10, 3 );

For filters, it adds the return too:

add_filter( 'the_title', function( $post_title, $post_id ) {

    return $post_title;
}, 10, 2 );

When a hook passes more than one parameter, the priority (10) and the number of parameters are added at the end, so WordPress passes them all. For a hook with one parameter, they're left out.

Not sure which hook? With Snipfire Pro, the visual hook finder shows every hook on a real page of your site.

Rather not write it at all? For common jobs such as a custom post type, redirects or structured data, a generator writes the snippet from a form.

WooCommerce hooks

WooCommerce's hooks are in the hook list too, marked WooCommerce, with the file that fires them. Where WooCommerce documents a hook, you see its description and parameters. For the main template hooks it doesn't document, such as woocommerce_before_single_product_summary, Snipfire adds a description of its own.

For template hooks, the hover also shows what WooCommerce itself puts there, with the priorities, for example WooCommerce adds here: woocommerce_show_product_sale_flash (10), woocommerce_show_product_images (20). Pick a priority between them to place your code exactly. The visual hook finder (Pro) shows the same descriptions.

Design tokens in CSS

In CSS, SCSS and LESS snippets, type -- where a value goes (or type inside var() and the editor suggests your site's design tokens: your theme's colours, font sizes, font families, spacing and shadows from theme.json, and Elementor's or Bricks' global colours, fonts and variables when you use them. Pick one and it writes var(--…) for you. See Design tokens in CSS autocomplete.

Hover documentation

Hover over a function or hook name to see its description, parameters, return value, the WordPress version it appeared in, and a Documentation link to the official reference. Deprecated functions are marked Deprecated.

Descriptions come from WordPress's and WooCommerce's own documentation and are in English.

Parameter hints

When you type the opening bracket of a function, a hint shows its parameters and highlights the one you're on.

Emmet (HTML and CSS)

Type an Emmet abbreviation and press Tab:

ul.menu>li*3>a

becomes

<ul class="menu">
    <li><a href=""></a></li>
    <li><a href=""></a></li>
    <li><a href=""></a></li>
</ul>

It works in HTML snippets and in CSS (for example m10 → margin: 10px;).

Formatting

Format (Shift+Alt+F) tidies the code with Prettier: indentation, spacing, line breaks. It works for PHP, CSS and JavaScript. Formatting only changes the layout, never what the code does.

Live error checking

The editor checks your code as you type:

  • PHP syntax errors
  • Functions or classes that already exist on the site (they'd crash it with "Cannot redeclare")
  • SCSS and LESS compile errors, even inside a partial (Pro)
  • Conditions that can't work at the chosen location

Problems are underlined on their line and listed in the Problems panel under the editor. With Snipfire Pro's AI assistant, Fix this error proposes a fix for them. No problems found. means you're clear. The same checks run again when you save: see How Snipfire keeps your site safe.

PHP tips

  • A PHP snippet can start with <?php or not, but leave off a closing ?> at the end: whitespace after it can break pages with "headers already sent". Snipfire warns you if you have one.
  • Error line numbers match the editor's line numbers.
  • Wrap functions you declare in if ( ! function_exists( 'my_function' ) ) if you plan to reuse the snippet on sites where it might already exist. Or use closures (function () { … }) in hooks, which can't clash.

Something unclear or missing? Tell us