Install a plugin when the problem is common and someone else maintains a good answer. Build a custom WordPress plugin when the job is small, specific to your business, and the plugin you'd otherwise install brings far more code than the job needs. Most sites need both. The mistake is choosing by habit, in either direction.

The short version
  • Every plugin is code with deep access to your site. Count the code you have to trust, not the number of plugins.
  • Install for common, security-sensitive or fast-changing jobs with an active maintainer: forms with spam handling, SEO, commerce, security scanning.
  • Build for small, specific jobs: a shortcode, a custom post type, a page template, glue between two of your systems, or the one feature you'd use from a large plugin.
  • Owning code is a cost too. PHP upgrades, WordPress releases, security review, and someone who can still read it in three years.
  • Abandoned plugins are findable. WP-CLI can list which installed plugins have been closed on WordPress.org.
  • A correct custom plugin is short: a header, a prefix, a hook, escaping on output, and a capability check plus a nonce on anything that saves.

Custom WordPress plugin vs off-the-shelf: the real trade

The choice isn't free versus paid, or quick versus slow. It's about who carries the code from now on.

Off-the-shelf plugin Custom WordPress plugin
Who maintains it The vendor, as long as they choose to You, or whoever you pay
Code you carry Everything the plugin does, used or not Only what you need
Security review Public: many users, researchers and the directory team look at it Private: only as good as its author
Updates Arrive automatically, and can change behaviour you rely on Arrive when you write them
Features Many, including ones you'll never use Exactly the ones you asked for
When it breaks You wait for the vendor, or work around it You fix it, if someone can read it
Exit Switching means migrating its data and settings It's yours to keep, change or retire

Neither column wins outright. A well-maintained plugin from a vendor with a security team is usually safer than code you wrote last month. A sprawling plugin bought for one feature is usually worse than forty lines that do that feature and nothing else.

What an installed plugin really costs

WordPress's own Site Health screen puts the risk plainly: plugins "have deep access to your site, so it's vital to keep them up to date." Every plugin you install runs with the same access as WordPress itself. That's the first cost, and it applies to every plugin, good or bad.

The second is everything you didn't ask for. Large plugins can load scripts and styles on pages that never use them, add admin screens and notices, and create settings and database tables that stay behind after the plugin is gone. None of that is a bug. It's the price of a product built for thousands of sites, and your site pays for all of it to use one part.

The third is abandonment. The plugin developer FAQ says plugins on WordPress.org "are closed for guideline violations, security issues, or by author requests," and that once a plugin is closed "the zips are no longer generated." Sites that already run it carry on running it, with no fixes arriving through the directory. The code repository stays readable, so someone can fork it, but that someone may have to be you. After 60 days the closure notice shows the broad reason.

You can find these plugins in seconds. WP-CLI's wp plugin list takes two fields most people never ask for:

wp plugin list --fields=name,status,version,wporg_status,wporg_last_updated

A wporg_status of closed is a plugin to replace, urgently if the reason was security. A wporg_last_updated date years in the past is a question worth asking. Premium and custom plugins show blank, because they were never in the directory. One caution from running this ourselves: on a machine with no route to WordPress.org, WP-CLI marked every plugin as closed, including ones that plainly aren't, so check the result against a plugin you know is active. Our WordPress maintenance checklist puts this command in a monthly routine.

Before you install one

Every plugin's page in the WordPress.org directory shows most of the basics: when it was last updated, how many sites run it, the WordPress version it's tested up to, the PHP version it needs, and how many recent support threads were resolved. Read those first. Then ask the three questions the page can't answer, ideally on a staging copy of your site:

  • What does it load on pages that don't use it? Open a page that has nothing to do with the plugin and see which of its scripts and styles arrive anyway.
  • What does it leave behind? Look for an uninstall routine, or remove it on staging and check what stays in the database.
  • What would leaving cost? If it stores your content in its own format, such as shortcodes or custom tables, switching later is a migration, not a deactivation.

A plugin that passes all three, from a maintainer with a track record, is usually a better choice than writing your own.

What owning code really costs

Building your own doesn't make maintenance disappear. It makes you the maintainer.

  • PHP moves under you. As of December 2026, PHP 8.2 loses security support on 31 December 2026 and WordPress recommends 8.3 or newer. Code written for an old PHP version has to be tested, and sometimes fixed, on the new one.
  • WordPress moves too. Major releases change the editor, deprecate functions and tighten defaults. Custom code needs someone to read the release notes.
  • Nobody else reviews it. There's no directory team and no crowd of users reporting bugs. The security basics are well documented, and the skeleton below follows them, but they only work if someone applies them every time.
  • Updates don't come from WordPress.org. That's mostly good, but it has one trap: a directory plugin with the same folder name can be offered as an "update" and overwrite yours. The header requirements include an Update URI field for exactly this, which "allows third-party plugins to avoid accidentally being overwritten with an update of a plugin of a similar name." The core developer note that introduced it says Update URI: false also works.
  • Deployment is yours to design. The REST API's plugin endpoint installs by WordPress.org directory slug only, so a custom plugin goes in by uploading a zip in wp-admin, with wp plugin install ./your-plugin.zip, or, better, from version control through a deploy pipeline.
  • Someone has to be able to read it in three years. Keep it in a repository, give it a short README, and keep it small enough that a stranger could understand it in an afternoon.

If none of that has an owner, the custom plugin is a liability with your name on it.

When to build and when to install

Situation Our call
A problem every site has (SEO metadata, caching, forms with spam protection) Install a well-maintained plugin
Money or security at stake, and the rules keep changing (payments, malware scanning) Install, from a vendor with a team behind it
You'd use one feature of a large plugin Build that feature
Logic specific to your business (a pricing rule, a calculator, a listing type) Build
Glue between your own systems, such as form entries into a CRM Build, or use a webhook pipeline
You need an installed plugin to behave differently Build a small plugin that uses its hooks; never edit its files, because the next update overwrites them
A plugin you rely on has been closed Replace it with a maintained one, or rebuild the part you used if it's small

For glue in particular, compare the plugin route with an outside pipeline; our post on Zapier vs custom webhooks covers when each pays.

We've built small custom plugins for client landing pages, where the job was narrow: give the client's team a page template they can choose in the normal editor, and render those pages lean, without the weight of the full theme. That's the shape of a good custom plugin. One job, a few files, nothing the client has to think about once it's installed.

A minimal custom WordPress plugin, done properly

Here's a complete small plugin: one setting, edited in the dashboard, printed wherever a shortcode sits. It's deliberately boring, because the point is the structure. Three files:

rwnote-site-notice/
  rwnote-site-notice.php   (header, guard, shortcode)
  admin/settings.php       (the settings screen and save handler)
  uninstall.php            (removes the setting when the plugin is deleted)

The main file:

<?php
/**
 * Plugin Name:       Site Notice
 * Description:       One editable notice, printed wherever the [rwnote_notice] shortcode sits.
 * Version:           1.0.0
 * Requires at least: 6.5
 * Requires PHP:      7.4
 * Author:            Rough Works
 * License:           GPL-2.0-or-later
 * Text Domain:       rwnote-site-notice
 * Update URI:        false
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Loaded directly, not by WordPress.
}

require_once __DIR__ . '/admin/settings.php';

add_shortcode( 'rwnote_notice', 'rwnote_notice_shortcode' );

function rwnote_notice_shortcode( $atts = array(), $content = null, $tag = '' ) {
    $atts = shortcode_atts( array( 'label' => __( 'Notice', 'rwnote-site-notice' ) ), $atts, $tag );
    $text = get_option( 'rwnote_notice_text', '' );

    if ( '' === $text ) {
        return ''; // Nothing set: print nothing, not an empty box.
    }

    // Escape late, at output. Shortcodes return; they never echo.
    return sprintf(
        '<p class="rwnote-notice"><strong>%1$s:</strong> %2$s</p>',
        esc_html( $atts['label'] ),
        esc_html( $text )
    );
}

What each part is doing, and where the rule comes from:

  • The header. Only Plugin Name is required. Requires at least and Requires PHP stop WordPress activating the plugin on a version too old for it, and Update URI: false keeps directory updates away from it.
  • The ABSPATH guard. The plugin handbook's best practices recommend it in any file with code outside a function, so the file does nothing if someone requests it directly.
  • The prefix. The same page says all globally accessible code "should be prefixed with a unique identifier," of at least four letters and preferably five, and not wp_. Functions, the shortcode and the option all start with rwnote.
  • Return, don't echo. The shortcode handbook's first best practice is "Always return!" Shortcodes are filters, and echoing prints in the wrong place.
  • shortcode_atts with the tag. Passing the shortcode's name as the third argument applies the shortcode_atts_rwnote_notice filter, so other code can change the defaults without editing this file.
  • Escape late. The escaping guide says to escape "as late as possible, ideally as data is being outputted." The setting is escaped where it's printed, not when it's saved, so a mistake upstream can't become a script on the page.

Saving a setting: capability, nonce, sanitise, escape

The settings screen is where most plugin security goes wrong, so here it is in full.

<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

add_action( 'admin_menu', 'rwnote_add_settings_page' );
add_action( 'admin_post_rwnote_save', 'rwnote_save_settings' );

function rwnote_add_settings_page() {
    add_options_page( 'Site Notice', 'Site Notice', 'manage_options', 'rwnote-site-notice', 'rwnote_render_settings_page' );
}

function rwnote_render_settings_page() {
    ?>
    <div class="wrap">
        <h1><?php esc_html_e( 'Site Notice', 'rwnote-site-notice' ); ?></h1>
        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
            <input type="hidden" name="action" value="rwnote_save">
            <?php wp_nonce_field( 'rwnote_save', 'rwnote_nonce' ); ?>
            <input type="text" class="regular-text" name="rwnote_notice_text"
                value="<?php echo esc_attr( get_option( 'rwnote_notice_text', '' ) ); ?>">
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}

function rwnote_save_settings() {
    if ( ! current_user_can( 'manage_options' ) ) { // The nonce is not a permission check.
        wp_die( esc_html__( 'You cannot change this setting.', 'rwnote-site-notice' ), 403 );
    }
    check_admin_referer( 'rwnote_save', 'rwnote_nonce' ); // Dies with a 403 on a bad nonce.

    $text = isset( $_POST['rwnote_notice_text'] ) ? sanitize_text_field( wp_unslash( $_POST['rwnote_notice_text'] ) ) : '';
    update_option( 'rwnote_notice_text', $text );

    wp_safe_redirect( admin_url( 'options-general.php?page=rwnote-site-notice&updated=1' ) );
    exit;
}

Four checks, in order:

  1. Capability first. The nonces guide is explicit that nonces "should never be relied on for authentication, authorization, or access control." current_user_can() decides who may change the setting.
  2. Then the nonce. wp_nonce_field() adds a hidden token to the form, and check_admin_referer() refuses the request with a 403 if the token is missing or wrong. That's what stops another site tricking a logged-in administrator's browser into submitting the form.
  3. Sanitise on the way in. wp_unslash() removes the slashes WordPress adds to request data, and sanitize_text_field() strips tags and line breaks from a one-line setting.
  4. Escape on the way out, with esc_attr() in the form field and esc_url() on the form's address.

For a plain settings screen, WordPress's Settings API (register_setting() with settings_fields()) adds the nonce for you. We wrote it out by hand here so every step is visible. The third file, uninstall.php, checks that WP_UNINSTALL_PLUGIN is defined and then deletes the option, so removing the plugin leaves nothing behind.

How we tested it

We didn't have PHP installed locally, so we used WordPress Playground, which runs WordPress and PHP from one npx command. Its php command ran php -l on all three files under PHP 7.4, 8.3 and 8.5, with no syntax errors. Then a throwaway site with the plugin mounted:

npx -y @wp-playground/[email protected] server --php=7.4 --port=9400 \
  --mount="$PWD/rwnote-site-notice:/wordpress/wp-content/plugins/rwnote-site-notice" \
  --blueprint="$PWD/blueprint.json"

The blueprint activated the plugin, saved a notice containing a <script> tag, created two pages with the shortcode, and added an editor account. On PHP 7.4 and 8.3, against the current WordPress release:

  • The shortcode printed the label and the notice, with the script tag shown as harmless text.
  • A logged-out request to the save handler changed nothing.
  • An editor got a 403 and "You cannot change this setting."
  • An administrator with a forged nonce got a 403 and WordPress's "The link you followed has expired."
  • An administrator with the real nonce saved the setting, and sanitize_text_field() stripped an injected image tag.

Two habits matter more than the command. Test the unzipped release you'll actually upload, not your working folder. And install the live site's caching and optimisation plugins in the test site, at the same versions, because plugins that rewrite the whole page can break yours in ways a clean install never shows; our look at WordPress page builders tells the story of an image-optimisation plugin that blanked every image on a custom-rendered page.

Blocks or shortcodes?

A shortcode is the simplest way to put plugin output into content: it works in any editor and needs no build step. Its weakness is that editors see a bracketed tag rather than the result.

A block shows the real output in the editor and can offer controls in a sidebar. The block editor handbook's registration guide registers blocks with register_block_type(), which reads its settings from a block.json file, hooked on init and pointed at the compiled build folder. That compiled folder is the catch: a block brings a JavaScript build into your plugin, and that's more to own. Choose a block when editors will place the component often and need to see it; choose a shortcode, or a template, when it's set once and left.

Our defaults

  • A problem every site has, with an active maintainer → install it, and review it with the rest of the plugin list every quarter.
  • One feature from a large plugin → build the feature, and remove the plugin.
  • Business-specific logic or glue → a custom WordPress plugin, in version control, with a unique prefix and Update URI set.
  • Changing how an installed plugin behaves → a small plugin that uses its hooks. Never edit another plugin's files.
  • Anything that saves data → capability check, nonce, sanitise on input, escape on output, and a test of the failure paths, not only the happy one.
  • A plugin closed for security → replace it this week, not at the next redesign.

Related comparisons: WordPress page builder vs block editor: the lock-in bill

If your plugin list has grown past the point anyone can explain it, start with the wporg_status command above and a list of what each plugin is for. When you want a second opinion on what to keep, replace or build, that's everyday WordPress development work for us. Send us the list.

Keep reading

Work with Rough Works

Need a partner for your next site? We're a Vancouver-based digital agency building websites and AI-enhanced experiences for brands across Canada and the United States. Start a project →

Common questions

When should I build a custom WordPress plugin instead of installing one?

Build when the job is small and specific to your business, when you'd use a fraction of a large plugin, when the plugin you depend on has been closed or abandoned, or when you need glue between your own systems. Install when the problem is common, security-sensitive or changes often, and a vendor with a team maintains a good answer: forms with spam handling, SEO, commerce, security scanning. The deciding question is who will maintain the code in three years, and whether that's cheaper than the alternative.

Are custom WordPress plugins more secure than off-the-shelf ones?

Not automatically. A small custom plugin has less code, so less surface, and nobody is scanning the public directory for its weaknesses. But it gets no outside review either, so its security depends entirely on whoever wrote it. The basics are well documented: check the user's capability, verify a nonce on anything that changes data, sanitise input and escape output as late as possible. A popular plugin with an active maintainer and a security team can be the safer choice for complex jobs.

How do I create a simple WordPress plugin?

Create a folder in wp-content/plugins with a PHP file inside. The file needs a header comment, and only the Plugin Name line is required. Add a direct-access guard that exits if ABSPATH isn't defined, prefix every function and option with a unique prefix of at least four letters, and attach your code to a hook or register a shortcode that returns its output. Escape everything you print. Activate it from the Plugins screen or with WP-CLI, after testing it somewhere other than your live site.

How many plugins is too many for WordPress?

There's no magic number, because plugins vary enormously in size and quality. One large plugin can load more code on every page than ten small ones. Count what you'd have to trust instead: who maintains each plugin, when it was last updated, whether it's still open on WordPress.org, and what it loads on pages that don't use it. Delete anything you're not using, since WordPress's hardening guide says to remove plugins you don't use rather than leave them deactivated.

What happens when a WordPress plugin is closed?

It stops being available from the WordPress.org directory. The plugin developer FAQ says plugins are closed for guideline violations, security issues or at the author's request, and that zips are no longer generated, although the code repository stays readable so others can fork it. Sites that already have it keep running it, but no fixes arrive through the directory. After 60 days the closure notice shows the broad reason. Find closed plugins with WP-CLI's wporg_status field and replace them, urgently if the reason is security.

How do I stop WordPress.org updates overwriting my custom plugin?

Add an Update URI line to the plugin header. WordPress's plugin handbook says the field lets third-party plugins avoid being overwritten by an update of a similarly named plugin from the WordPress.org directory. The core developer note for WordPress 5.8 says a value that isn't a WordPress.org address means WordPress won't try to update it from the directory, and that Update URI: false also works. Use a unique folder name and prefix as well, so nothing collides with a directory plugin in the first place.

How do I test a WordPress plugin before installing it on a live site?

Run it in a throwaway WordPress first. WordPress Playground starts one from a single npx command, lets you pick the PHP version, and can mount your plugin folder and apply a blueprint that activates it and creates test content. Test the release zip rather than the source folder, install the live site's caching and optimisation plugins at the same versions, and try the failure paths too: a logged-out request, a user without permission, and a forged nonce. Then test once more on a staging copy of the real site.