Μετάβαση στο περιεχόμενο

Early-bird άδεια εφ’ όρου ζωής: $199 εφάπαξ, μόνο για τους πρώτους 200 αγοραστές. Δείτε την προσφορά

Όλοι οι οδηγοί

Your first snippet

Αυτή η σελίδα δεν έχει μεταφραστεί ακόμη, γι' αυτό εμφανίζεται στα αγγλικά.

In this guide you'll add a small PHP snippet, save it, and switch it on. It takes about five minutes.

Open the editor

Go to Snipfire → Snippets. The editor has three parts:

  1. The sidebar on the left: your snippets and folders, + New, Search snippets…, and filters.
  2. The code editor in the middle, with the toolbar above it.
  3. The settings panel on the right: how, where and when the snippet runs.

Create a snippet

  1. Click + New and pick PHP.
  2. Give it a title in the box above the editor, for example Disable XML-RPC.
  3. Type this code:

    add_filter( 'xmlrpc_enabled', '__return_false' );
    

    While you type add_filter( ', Snipfire suggests WordPress hooks. Pick one and it writes the whole callback for you. More about autocomplete.

A PHP snippet can start with <?php or leave it off: both work.

Check the settings

In the settings panel:

  • How it runs: Automatically. (The other choices are As a shortcode and Only when I click Run.)
  • Where: Run immediately (like functions.php) is the default for PHP. That's right for add_filter() and add_action() calls.
  • Priority: leave it at 10. Lower numbers run first.
  • Conditions: leave empty. With no conditions, a snippet runs everywhere its location allows.

Everything in the panel is explained in How a snippet runs and Where snippets run.

Save and switch it on

  1. Turn on the Active switch in the toolbar.
  2. Click Save (or press Ctrl+S, Cmd+S on a Mac).

Before the snippet goes live, Snipfire checks the code for errors and test-loads your site with the snippet on. If everything is fine you'll see Saved and live. If the code has a problem, the snippet is saved but left switched off, and the problem is shown on its line so you can fix it. What Snipfire checks.

New snippets start switched off, so you can save work in progress without it running.

Switch it off again

Turn off Active and save, or use Switch off from the sidebar's bulk actions. Switching a snippet off or on never changes its code.

Where next

Κάτι δεν είναι σαφές ή λείπει; Πείτε μας