Build a simple WordPress plugin

Generate a secure, well-structured WordPress plugin with hooks, sanitization, nonces and admin settings. Designed for ChatGPT and Claude. It includes 3 customizable variables and you can copy it for free in one click.

Intermediate · Code · Pending editorial review

Designed for:

Prompt

Act as an expert WordPress developer who follows the WordPress Coding Standards.

Build a plugin called “{{name}}” that does the following: {{function}}.
Minimum PHP version: {{php}}.

Requirements:
1. Plugin file structure and standard header.
2. Correct use of hooks (actions and filters), explaining why each one is used.
3. An admin settings page using the Settings API.
4. Security: capability checks, nonces, input sanitization and output escaping (esc_html, esc_attr, wp_kses).
5. Translatable strings with a text domain.
6. Uninstall code that cleans up the options it created.

Show each file in a separate block with its path. At the end, explain how to test it in a local environment.

How to use it

Always test the plugin in a local or staging environment before installing it on a live site, and take a backup.

Usage example

Function: show a configurable notice at the top of the site during a date range.

Sample output

top-notice/top-notice.php (excerpt)

<?php
/**
 * Plugin Name:  Top Notice
 * Description:  Shows a configurable notice bar with text and a link.
 * Version:      1.0.0
 * Requires PHP: 8.1
 * Text Domain:  top-notice
 */

defined( 'ABSPATH' ) || exit;

add_action( 'admin_init', 'top_notice_register_settings' );
function top_notice_register_settings(): void {
	register_setting( 'top_notice', 'top_notice_options', array(
		'sanitize_callback' => 'top_notice_sanitize',
	) );
}

function top_notice_sanitize( $input ): array {
	$input = is_array( $input ) ? $input : array();
	return array(
		'text' => sanitize_text_field( $input['text'] ?? '' ),
		'url'  => esc_url_raw( $input['url'] ?? '' ),
	);
}

add_action( 'wp_body_open', 'top_notice_render' );
function top_notice_render(): void {
	$opts = get_option( 'top_notice_options', array() );
	if ( empty( $opts['text'] ) ) {
		return;
	}
	printf(
		'<div class="top-notice" role="region" aria-label="%s">%s <a href="%s">%s</a></div>',
		esc_attr__( 'Notice', 'top-notice' ),
		esc_html( $opts['text'] ),
		esc_url( $opts['url'] ?? '' ),
		esc_html__( 'Learn more', 'top-notice' )
	);
}

admin_init registers the option through the Settings API, which already handles the form nonce; wp_body_open prints the bar right after <body> opens. Input is sanitized on save and escaped on output, and every string goes through the text domain…

Key facts

Category
Programming & development · WordPress
Output type
Code
Level
Intermediate
Designed for
ChatGPT and Claude
Verified in
Pending editorial verification
Variables
Plugin name, What it should do and Minimum PHP version
Language
English
Price
Free, no sign-up
Updated
Nov 7, 2026

Frequently asked questions

Can I install the generated plugin on my live site?

Test it first on a local or staging site with WP_DEBUG enabled, keep a backup and review the security checks before activating it in production.

Is it suitable for complex plugins?

It works best for focused plugins such as a shortcode, a settings page or a custom post type. For bigger projects, use it to scaffold the structure and build features one at a time.

What is this prompt for?

Generate a secure, well-structured WordPress plugin with hooks, sanitization, nonces and admin settings.

Which AI tools does it work with?

It is designed for ChatGPT and Claude. We have not verified it in these tools yet, so results may vary between them.

How do I customize the prompt?

Click “Customize” and fill in the variables (Plugin name, What it should do and Minimum PHP version). The text updates instantly and you can then copy it in one click. Values are stored only in your browser.

Do I need experience to use it?

It is intermediate: it helps to know the topic so you can provide good context and review the result critically.

Is this prompt free?

Yes. Every HomeCasa Prompts prompt is free, with no sign-up or subscription. You can also use them in professional projects.

Can I trust the AI output?

Treat it as a high-quality draft: always check data, figures and important claims before publishing or making decisions.

Related prompts