/wordpress-skills:wp-plugin-developmentfrom wordpress-skills
Reviews WordPress plugin architecture, lifecycle hooks, Settings API, custom post types, and WordPress.org submission compliance. Use for plugin code audits and pre-submission checks.
Ships in wordpress-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Systematic plugin architecture review for WordPress plugins targeting WordPress 6.x+. Core principle: WordPress plugins extend functionality through a standardized API ecosystem—lifecycle hooks (activation/deactivation/uninstall), Settings API, hooks system (actions/filters), custom post types/taxonomies, and internationalization. Review validates plugin architecture, naming conventions, WordPress.org compliance standards, and cross-references wp-security-review for security-specific patterns (nonces, capabilities, sanitization). Report findings grouped by file with line numbers, severity labels (CRITICAL/WARNING/INFO), and BAD/GOOD code pairs showing proper implementations.
Use when:
Don't use for:
Follow this six-step workflow for systematic plugin reviews:
Identify plugin type and context
Check plugin header completeness and metadata
Plugin Name field presentScan for CRITICAL patterns (breaks functionality or causes WordPress.org rejection)
defined( 'ABSPATH' ) || exit; check in PHP filesflush_rewrite_rules() called on init hook (expensive operation on every page load)$wpdb->query() instead of dbDelta()permission_callback (WordPress 5.5+ requirement)Check WARNING patterns (non-standard but functional)
__() or _e() calls without text domain parameter/wp-content/plugins/)sanitize_callback in register_setting()show_in_rest for Gutenberg compatibilityis_admin() check)Note INFO improvements (best practices and optimizations)
Requires at least, Requires PHP)show_in_rest for Block Editor supportDomain Path in headerApply context-aware severity and report
/wp-sec-review for comprehensive security analysis."my-plugin.php)Plugin headers (PLG-02):
Plugin Name field → WordPress won't recognize pluginText Domain → Breaks internationalizationRequires at least or Requires PHP → Can't enforce version requirementsABSPATH check (PLG-03):
defined( 'ABSPATH' ) || exit; at top → Direct file access possiblePrefixing (PLG-04):
function [a-z_]+\( without plugin prefix (4-5 char minimum)Activation/deactivation hooks (PLG-04):
register_activation_hook() but plugin has setup needs → No way to initializeregister_deactivation_hook() but plugin has temp data → No cleanup on deactivationregister_activation_hook( __FILE__, 'callback' )uninstall.php)WP_UNINSTALL_PLUGIN constant check (PLG-05):
uninstall.php without WP_UNINSTALL_PLUGIN check → Can be executed directlyif ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { exit; }Cleanup completeness (PLG-05):
delete_option()) → Leaves plugin data in databasedelete_transient()) → Database bloatDROP TABLE) → Orphaned tablesdelete_metadata( 'user', ... )) → User data remainsregister_post_type() usage (PLG-06):
show_in_rest => true → Not accessible in Block Editorflush_rewrite_rules() called on init → Performance issue (expensive DB write on every page load)register_post_type( 'key', array( ... ) ) hooked to initRewrite flush timing (PLG-06):
flush_rewrite_rules() on init hook → DB write on every page loadregister_taxonomy() usage (PLG-07):
show_in_rest => true → Not accessible in Block Editorregister_taxonomy( 'name', 'post_type', array( ... ) ) hooked to initregister_setting() usage (PLG-08):
add_settings_field() without corresponding register_setting() → Field won't saveregister_setting() without sanitize_callback → Unsanitized data storedregister_setting() without type parameter → Type inference unreliableregister_setting( 'option_group', 'option_name', array( ... ) ) on admin_initSettings API workflow (PLG-09):
add_settings_section() page slug doesn't match do_settings_sections() call → Section won't renderadd_settings_field() section ID doesn't match add_settings_section() ID → Field won't rendersettings_fields() call → No nonce protection, options won't savedo_settings_sections() call → Fields won't renderregister_setting() → add_settings_section() → add_settings_field() → form HTML with settings_fields() and do_settings_sections()add_action/add_filter patterns (PLG-10):
accepted_args not specified when callback needs multiple parameters → Parameters truncatedadd_action( 'hook_name', 'callback', $priority, $accepted_args )Filter return requirement (PLG-10):
add_filter( 'hook', 'callback' ) where callback has no return statementHook removal (PLG-10):
remove_action() or remove_filter() params don't match registration → Won't remove hookadd_action()/add_filter() calladd_action( 'init', 'callback', 15 ) requires remove_action( 'init', 'callback', 15 )Custom hooks for extensibility (PLG-10):
do_action() or apply_filters() for extensibilitydo_action( 'myplugin_after_save', $data ) or apply_filters( 'myplugin_modify_output', $output )Text domain matching (PLG-11):
Text Domain: my-plugin must match plugin folder/file name exactlyi18n function usage (PLG-11):
__() or _e() without text domain parameter → Falls back to core translations (incorrect)__( 'Text', 'text-domain' ) never __( 'Text' )sprintf( __( 'Text %s', 'domain' ), $var ) not __( "Text $var", 'domain' )Pluralization (PLG-11):
_n() → Breaks languages with complex plural rules_n( 'singular', 'plural', $count, 'domain' ) for count-dependent stringsContext-aware translation (PLG-11):
_x() for disambiguation when same English word has different translations_x( 'Post', 'noun', 'domain' ) vs _x( 'Post', 'verb', 'domain' )Escaped translation variants (PLG-11):
esc_html__() or esc_attr__() for combined translation + escapingecho esc_html__( 'Text', 'domain' ) instead of echo esc_html( __( 'Text', 'domain' ) )Translation loading (PLG-11):
load_plugin_textdomain() optional for WordPress 4.6+ (auto-loads from translate.wordpress.org)init if called: add_action( 'init', 'load_textdomain_callback' )register_rest_route() usage:
permission_callback → WordPress 5.5+ error, endpoint blockedpermission_callback => '__return_true' on write operations → Unauthenticated access allowedregister_rest_route( 'namespace/v1', '/route', array( ... ) ) on rest_api_init hook__return_true is CORRECT for public read-only endpointsNamespace and versioning:
myplugin/v1 not just mypluginParameter validation:
sanitize_callback in args → Unsanitized inputvalidate_callback in args → Invalid input acceptedHook registration:
admin-ajax.php for high-frequency calls → Consider REST API for better performanceadd_action( 'wp_ajax_action_name', 'callback' ) for authenticatedadd_action( 'wp_ajax_nopriv_action_name', 'callback' ) for publicSecurity checks:
check_ajax_referer()) and capability checksadd_menu_page/add_submenu_page:
current_user_can() → Capability param insufficient aloneadd_menu_page( $title, $menu_title, 'manage_options', $slug, $callback )Table creation:
$wpdb->query( "CREATE TABLE..." ) instead of dbDelta() → No upgrade path, charset issuesrequire_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql );$wpdb->prefix for table names (not hardcoded wp_)$wpdb->get_charset_collate() for charset/collationdbDelta SQL formatting requirements:
wp_schedule_event() usage:
wp_schedule_event() without checking wp_next_scheduled() → Duplicate schedulesif ( ! wp_next_scheduled( 'hook' ) ) before wp_schedule_event()wp_clear_scheduled_hook( 'hook' ) in deactivation hookset_transient() usage:
set_transient( 'mypl_key', $value, HOUR_IN_SECONDS )Use these rg commands for quick plugin scanning. Organized by severity.
# Main plugin file should contain "Plugin Name" header
# If this returns nothing, the plugin likely lacks a valid main header.
rg -n "Plugin Name:" . -g '*.php'
# PHP files missing ABSPATH check (direct file access possible)
rg -L --iglob '*.php' "defined\s*\(\s*['\"]ABSPATH['\"]\s*\)|defined\s*\(\s*'ABSPATH'\s*\)" .
# Unprefixed function declarations in global scope (namespace collision risk)
rg -n "^function\s+[a-z_][a-z0-9_]*\s*\(" . -g '*.php'
# Text domain mismatch (compare header vs i18n calls)
# First: inspect the main plugin file header for the expected text domain
rg -n "Text Domain:" . -g '*.php'
# Then: compare that slug with translation calls across the plugin
rg -n "__\(|_e\(|_n\(|_x\(" . -g '*.php'
# flush_rewrite_rules outside activation/deactivation (expensive operation on every page load)
rg -n "flush_rewrite_rules" . -g '*.php'
# Filter callbacks missing return statement (manual follow-up required)
rg -n "add_filter\s*\(" . -g '*.php'
# register_rest_route without permission_callback (manual per-route review)
rg -n "register_rest_route\s*\(" . -g '*.php'
# Missing register_activation_hook (no setup mechanism)
rg -n "register_activation_hook\s*\(" . -g '*.php'
# Missing uninstall cleanup (no uninstall.php and no register_uninstall_hook)
test -f uninstall.php || rg -n "register_uninstall_hook\s*\(" . -g '*.php'
# i18n functions without obvious text domain parameter (manual confirmation required)
rg -n "__\(|_e\(" . -g '*.php'
# Hardcoded /wp-content/plugins/ paths (breaks on custom WordPress installations)
rg -n "/wp-content/plugins/" . -g '*.php'
# Direct CREATE TABLE with $wpdb->query (should use dbDelta)
rg -n "wpdb->query\s*\(.*CREATE TABLE" . -g '*.php'
# Post type key length check (max 20 characters)
rg -n "register_post_type\s*\(" . -g '*.php'
# Missing show_in_rest in register_post_type (manual per-registration review)
rg -n "register_post_type\s*\(" . -g '*.php'
# Missing "Requires at least" or "Requires PHP" in plugin header
rg -n "Requires at least:|Requires PHP:" . -g '*.php'
# Functions not using PHP namespaces (could modernize)
rg -n "^function\s+myprefix_" . -g '*.php'
# Admin code loading on frontend (manual context check)
rg -n "add_action\s*\(\s*['\"]admin_" . -g '*.php'
# Missing Domain Path in plugin header
rg -n "Domain Path:" . -g '*.php'
WordPress plugins operate in different distribution contexts. Adjust review severity based on context.
Strictest standards apply. Plugin Check (PCP) tool enforces these requirements:
Plugin Check (PCP) compliance:
defined( 'ABSPATH' ) || exit;)/wp-content/ paths (use WP_CONTENT_DIR or helper functions)How to verify: Run Plugin Check tool before submission:
# Via WP-CLI
wp plugin install plugin-check --activate
wp plugin check my-plugin.php
# Or via WordPress Admin
# Navigate to: Plugins > Add New > Search "Plugin Check"
# Then: Tools > Plugin Check > Select your plugin
WordPress.org context severity escalation:
More flexibility. No WordPress.org submission requirements.
Relaxed requirements:
Still important:
Different loading behavior. Must-use plugins load automatically before regular plugins.
Key differences:
wp-content/mu-plugins/ directoryReview adjustments for mu-plugins:
register_activation_hook() → Expected for mu-pluginsregister_deactivation_hook() → Expected for mu-pluginsPattern to detect mu-plugin context:
// Check if plugin is loaded as must-use
if ( strpos( __FILE__, WPMU_PLUGIN_DIR ) !== false ) {
// Running as must-use plugin - skip activation hooks
}
Special files with specific names. Drop-ins replace WordPress core functionality.
Common drop-ins:
object-cache.php → Object caching backend (Redis, Memcached)db.php → Custom database classadvanced-cache.php → Page caching systemdb-error.php → Custom database error pagemaintenance.php → Custom maintenance mode pageReview adjustments for drop-ins:
Pattern to detect drop-in:
// Drop-ins are in wp-content/ root, not plugins/
// Check filename against known drop-in names
$drop_ins = array( 'object-cache.php', 'db.php', 'advanced-cache.php', 'db-error.php', 'maintenance.php' );
Common plugin patterns organized by concern. All examples use WordPress PHP Coding Standards (spaces inside parentheses, array() not [], Yoda conditions).
Complete header block with all recommended fields:
❌ BAD: Minimal header
<?php
/**
* Plugin Name: My Plugin
*/
✅ GOOD: Complete header with all recommended fields
<?php
/**
* Plugin Name: My Awesome Plugin
* Plugin URI: https://example.com/my-awesome-plugin
* Description: Does amazing things with WordPress
* Version: 1.0.0
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: John Doe
* Author URI: https://example.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: my-awesome-plugin
* Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
Avoid global namespace pollution:
❌ BAD: No prefix (namespace collision risk)
<?php
function save_settings() {
update_option( 'plugin_settings', $_POST['data'] );
}
class Plugin_Settings {
// ...
}
add_action( 'admin_init', 'save_settings' );
✅ GOOD: Prefixed functions and classes
<?php
function mypl_save_settings() {
update_option( 'mypl_settings', $_POST['data'] );
}
class MyPL_Settings {
// ...
}
add_action( 'admin_init', 'mypl_save_settings' );
✅ BETTER: Use PHP namespaces
<?php
namespace MyPlugin\Admin;
function save_settings() {
update_option( 'mypl_settings', $_POST['data'] ); // Still prefix option names
}
class Settings {
// ...
}
add_action( 'admin_init', __NAMESPACE__ . '\save_settings' );
Proper plugin lifecycle management:
❌ BAD: No lifecycle hooks
<?php
// Plugin registers CPT on init but never flushes rewrites
add_action( 'init', 'mypl_register_cpt' );
function mypl_register_cpt() {
register_post_type( 'mypl_book', array( /* args */ ) );
}
✅ GOOD: Complete lifecycle with activation/deactivation/uninstall
<?php
// Main plugin file: my-plugin.php
// Activation hook
register_activation_hook( __FILE__, 'mypl_activate' );
function mypl_activate() {
// Set default options
add_option( 'mypl_version', '1.0.0' );
// Register CPT before flushing
mypl_register_cpt();
// Flush rewrite rules ONLY on activation
flush_rewrite_rules();
}
// Deactivation hook
register_deactivation_hook( __FILE__, 'mypl_deactivate' );
function mypl_deactivate() {
// Clear transients
delete_transient( 'mypl_cache' );
// Flush rewrite rules
flush_rewrite_rules();
}
// Init hook for normal operation
add_action( 'init', 'mypl_register_cpt' );
function mypl_register_cpt() {
register_post_type( 'mypl_book', array( /* args */ ) );
}
// Uninstall file: uninstall.php
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Delete all plugin data
delete_option( 'mypl_version' );
delete_option( 'mypl_settings' );
// Drop custom table
global $wpdb;
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}mypl_data" );
Proper CPT/taxonomy registration with rewrite rule management:
❌ BAD: Flushes rewrites on every page load
<?php
add_action( 'init', 'mypl_register_cpt' );
function mypl_register_cpt() {
register_post_type( 'book', array( // Missing prefix, no show_in_rest
'public' => true,
) );
flush_rewrite_rules(); // CRITICAL: Runs on EVERY page load
}
✅ GOOD: Prefixed, Gutenberg-ready, flushes only on activation
<?php
add_action( 'init', 'mypl_register_cpt_and_taxonomy' );
function mypl_register_cpt_and_taxonomy() {
// Register custom post type (max 20 chars, prefixed)
register_post_type(
'mypl_book',
array(
'labels' => array(
'name' => __( 'Books', 'my-plugin' ),
'singular_name' => __( 'Book', 'my-plugin' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'books' ),
'supports' => array( 'title', 'editor', 'thumbnail' ),
'show_in_rest' => true, // Gutenberg support
)
);
// Register custom taxonomy (max 32 chars, prefixed)
register_taxonomy(
'mypl_genre',
'mypl_book',
array(
'labels' => array(
'name' => __( 'Genres', 'my-plugin' ),
'singular_name' => __( 'Genre', 'my-plugin' ),
),
'hierarchical' => true,
'public' => true,
'show_in_rest' => true, // Gutenberg support
)
);
}
// Flush rewrites ONLY on activation
register_activation_hook( __FILE__, 'mypl_activate' );
function mypl_activate() {
mypl_register_cpt_and_taxonomy(); // Register first
flush_rewrite_rules(); // Then flush (only once)
}
register_deactivation_hook( __FILE__, 'mypl_deactivate' );
function mypl_deactivate() {
flush_rewrite_rules(); // Clean up rewrite rules
}
Complete Settings API workflow:
❌ BAD: add_settings_field without register_setting (won't save)
<?php
add_action( 'admin_init', 'mypl_settings_init' );
function mypl_settings_init() {
add_settings_section( 'mypl_section', 'Settings', null, 'mypl-settings' );
add_settings_field(
'mypl_api_key',
'API Key',
'mypl_api_key_callback',
'mypl-settings',
'mypl_section'
);
// Missing register_setting() - field won't save!
}
✅ GOOD: Complete Settings API workflow
<?php
add_action( 'admin_init', 'mypl_register_settings' );
function mypl_register_settings() {
// 1. Register setting (declares option name and sanitization)
register_setting(
'mypl_options_group', // Option group
'mypl_settings', // Option name
array(
'type' => 'array',
'sanitize_callback' => 'mypl_sanitize_settings',
'default' => array(
'api_key' => '',
'enabled' => false,
),
)
);
// 2. Add settings section
add_settings_section(
'mypl_main_section',
__( 'Main Settings', 'my-plugin' ),
'mypl_section_callback',
'mypl-settings'
);
// 3. Add settings fields
add_settings_field(
'mypl_api_key',
__( 'API Key', 'my-plugin' ),
'mypl_api_key_callback',
'mypl-settings',
'mypl_main_section'
);
add_settings_field(
'mypl_enabled',
__( 'Enable Feature', 'my-plugin' ),
'mypl_enabled_callback',
'mypl-settings',
'mypl_main_section'
);
}
function mypl_section_callback() {
echo '<p>' . esc_html__( 'Configure your plugin settings below.', 'my-plugin' ) . '</p>';
}
function mypl_api_key_callback() {
$options = get_option( 'mypl_settings' );
$value = isset( $options['api_key'] ) ? $options['api_key'] : '';
?>
<input type="text"
name="mypl_settings[api_key]"
value="<?php echo esc_attr( $value ); ?>"
class="regular-text">
<?php
}
function mypl_enabled_callback() {
$options = get_option( 'mypl_settings' );
$checked = isset( $options['enabled'] ) && $options['enabled'];
?>
<input type="checkbox"
name="mypl_settings[enabled]"
value="1"
<?php checked( $checked, true ); ?>>
<?php
}
function mypl_sanitize_settings( $input ) {
$sanitized = array();
if ( isset( $input['api_key'] ) ) {
$sanitized['api_key'] = sanitize_text_field( $input['api_key'] );
}
$sanitized['enabled'] = isset( $input['enabled'] ) && $input['enabled'] ? true : false;
return $sanitized;
}
// Settings page HTML
function mypl_settings_page() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
?>
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<form method="post" action="options.php">
<?php
// Output nonce, action, option_page fields
settings_fields( 'mypl_options_group' );
// Output sections and fields
do_settings_sections( 'mypl-settings' );
submit_button();
?>
</form>
</div>
<?php
}
Actions and filters with priority management:
❌ BAD: Filter without return statement (fatal error)
<?php
add_filter( 'the_content', 'mypl_modify_content' );
function mypl_modify_content( $content ) {
if ( is_single() ) {
$content .= '<p>Footer text</p>';
}
// Missing return! Fatal error.
}
✅ GOOD: Complete hooks usage with priority and return
<?php
// Action with priority (runs before core at priority 10)
add_action( 'init', 'mypl_register_cpt', 9 );
function mypl_register_cpt() {
register_post_type( 'mypl_book', array( /* args */ ) );
}
// Filter with return (CRITICAL)
add_filter( 'the_content', 'mypl_modify_content', 10, 1 );
function mypl_modify_content( $content ) {
if ( is_single() ) {
$content .= '<p>Footer text</p>';
}
return $content; // ALWAYS return in filters
}
// Multiple parameters with accepted_args
add_filter( 'wp_mail', 'mypl_modify_email', 10, 1 );
function mypl_modify_email( $args ) {
$args['from'] = 'Custom <[email protected]>';
return $args;
}
// Removing hooks (MUST match exact registration params)
add_action( 'wp_footer', 'mypl_footer_code', 15 );
// To remove: priority must match
remove_action( 'wp_footer', 'mypl_footer_code', 15 );
// Create custom hooks for extensibility
function mypl_process_data( $data ) {
// Allow other plugins to modify data
$data = apply_filters( 'mypl_before_process', $data );
// Process data
$result = process( $data );
// Allow other plugins to hook after processing
do_action( 'mypl_after_process', $result );
return $result;
}
Text domain matching and placeholder usage:
❌ BAD: Variable embedded in translatable string
<?php
$count = 5;
echo __( "You have $count messages", 'my-plugin' ); // Breaks translation extraction
// Missing text domain
echo __( 'Save Settings' );
// Text domain mismatch
// Plugin folder: my-awesome-plugin
echo __( 'Save', 'my_plugin' ); // Underscore instead of dash
✅ GOOD: Placeholders with sprintf, correct text domain
<?php
// Basic translation with text domain
echo __( 'Settings saved successfully', 'my-awesome-plugin' );
// Translation with echo
_e( 'Click here to continue', 'my-awesome-plugin' );
// Placeholders with sprintf (NOT embedded variables)
$count = 5;
echo sprintf(
__( 'You have %d messages', 'my-awesome-plugin' ),
$count
);
// Pluralization with _n()
echo sprintf(
_n(
'One post found',
'%d posts found',
$count,
'my-awesome-plugin'
),
number_format_i18n( $count )
);
// Context-aware translation with _x()
echo _x( 'Post', 'noun - blog post', 'my-awesome-plugin' );
echo _x( 'Post', 'verb - submit', 'my-awesome-plugin' );
// Escaped output + translation
echo '<h1>' . esc_html__( 'Welcome', 'my-awesome-plugin' ) . '</h1>';
echo '<input placeholder="' . esc_attr__( 'Enter your name', 'my-awesome-plugin' ) . '">';
// Load text domain on init (optional in WP 4.6+)
add_action( 'init', 'mypl_load_textdomain' );
function mypl_load_textdomain() {
load_plugin_textdomain(
'my-awesome-plugin',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages'
);
}
❌ BAD: Missing permission_callback (WordPress 5.5+ error)
<?php
add_action( 'rest_api_init', 'mypl_register_routes' );
function mypl_register_routes() {
register_rest_route( 'mypl/v1', '/posts', array(
'methods' => 'GET',
'callback' => 'mypl_get_posts',
// Missing: 'permission_callback' (WordPress 5.5+ blocks this)
) );
}
✅ GOOD: Complete REST endpoint with permission_callback and validation
<?php
add_action( 'rest_api_init', 'mypl_register_routes' );
function mypl_register_routes() {
// Public read-only endpoint
register_rest_route(
'mypl/v1', // Namespace with version
'/posts',
array(
'methods' => 'GET',
'callback' => 'mypl_get_posts',
'permission_callback' => '__return_true', // Explicitly public (OK for read-only)
'args' => array(
'per_page' => array(
'default' => 10,
'sanitize_callback' => 'absint',
'validate_callback' => function( $param ) {
return is_numeric( $param ) && $param > 0 && $param <= 100;
},
),
),
)
);
// Protected write endpoint
register_rest_route(
'mypl/v1',
'/posts/(?P<id>\d+)',
array(
'methods' => 'DELETE',
'callback' => 'mypl_delete_post',
'permission_callback' => function() {
return current_user_can( 'delete_posts' );
},
'args' => array(
'id' => array(
'validate_callback' => function( $param ) {
return is_numeric( $param );
},
),
),
)
);
}
function mypl_get_posts( $request ) {
$per_page = $request->get_param( 'per_page' );
$posts = get_posts( array( 'posts_per_page' => $per_page ) );
return rest_ensure_response( $posts );
}
function mypl_delete_post( $request ) {
$post_id = $request->get_param( 'id' );
$result = wp_delete_post( $post_id, true );
if ( ! $result ) {
return new WP_Error(
'delete_failed',
__( 'Failed to delete post', 'my-plugin' ),
array( 'status' => 500 )
);
}
return rest_ensure_response( array( 'deleted' => true, 'id' => $post_id ) );
}
Note: For security depth on REST endpoints (nonce validation, capability checks, input sanitization), see wp-security-review skill.
✅ GOOD: AJAX handler registration
<?php
// Authenticated users
add_action( 'wp_ajax_mypl_save_data', 'mypl_save_data_callback' );
// Public (non-authenticated)
add_action( 'wp_ajax_nopriv_mypl_save_data', 'mypl_save_data_callback' );
function mypl_save_data_callback() {
// Security checks (see wp-security-review for depth)
check_ajax_referer( 'mypl_nonce', 'nonce' );
if ( ! current_user_can( 'edit_posts' ) ) {
wp_send_json_error( 'Insufficient permissions' );
}
$data = sanitize_text_field( $_POST['data'] );
// Process data
update_option( 'mypl_data', $data );
wp_send_json_success( 'Data saved' );
}
Separate admin from public code:
❌ BAD: Admin code loading on every page
<?php
add_action( 'wp_enqueue_scripts', 'mypl_enqueue_admin_assets' );
function mypl_enqueue_admin_assets() {
// Admin assets loading on public pages (unnecessary)
wp_enqueue_script( 'mypl-admin', plugin_dir_url( __FILE__ ) . 'admin.js' );
}
✅ GOOD: Conditional admin loading
<?php
// Only load admin code in admin context
if ( is_admin() ) {
require_once plugin_dir_path( __FILE__ ) . 'admin/class-admin.php';
}
// Admin-specific assets
add_action( 'admin_enqueue_scripts', 'mypl_enqueue_admin_assets' );
function mypl_enqueue_admin_assets() {
wp_enqueue_script(
'mypl-admin',
plugin_dir_url( __FILE__ ) . 'admin/admin.js',
array( 'jquery' ),
'1.0.0',
true
);
}
// Public-facing assets
add_action( 'wp_enqueue_scripts', 'mypl_enqueue_public_assets' );
function mypl_enqueue_public_assets() {
wp_enqueue_script(
'mypl-public',
plugin_dir_url( __FILE__ ) . 'public/public.js',
array( 'jquery' ),
'1.0.0',
true
);
}
Prevent fatal errors from conflicts:
✅ GOOD: Existence checks for functions and classes
<?php
// Function existence check
if ( ! function_exists( 'mypl_init' ) ) {
function mypl_init() {
// Plugin initialization
}
}
// Class existence check
if ( ! class_exists( 'MyPL_Plugin' ) ) {
class MyPL_Plugin {
// Plugin class
}
}
| Severity | Definition | Examples |
|---|---|---|
| CRITICAL | Will cause WordPress.org rejection OR breaks plugin functionality OR causes fatal errors | Missing Plugin Name header, unprefixed global functions causing namespace collision, text domain mismatch, missing ABSPATH check, direct DB table creation without dbDelta, filter callback without return statement, post type key > 20 chars, taxonomy name > 32 chars, flush_rewrite_rules() on init hook, REST route without permission_callback (WP 5.5+) |
| WARNING | Non-standard patterns causing maintainability or compatibility issues, but plugin still functions | Missing internationalization (i18n), __() without text domain, hardcoded /wp-content/ paths, missing sanitize_callback in register_setting(), missing show_in_rest for Gutenberg support, wp_schedule_event() without checking for existing schedule, transients without expiration |
| INFO | Best practice improvements and modernization opportunities | Could use PHP namespaces instead of prefixing, missing version requirements in header (Requires at least, Requires PHP), admin code loading on frontend, missing Domain Path in header, could use _x() for context-aware translation |
Report findings grouped by FILE, with line numbers and severity labels. Use BAD/GOOD code pairs for each finding.
# WordPress Plugin Review: my-awesome-plugin
## FILE: my-awesome-plugin.php
### Line 15: CRITICAL - Missing ABSPATH check
Direct file access possible. Add ABSPATH check at top of all PHP files.
❌ BAD:
<?php
/**
* Plugin Name: My Plugin
*/
function mypl_init() { ... }
✅ GOOD:
<?php
/**
* Plugin Name: My Plugin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function mypl_init() { ... }
### Line 45: WARNING - Missing text domain in i18n call
Translation won't work. Always include text domain parameter.
❌ BAD:
echo __( 'Save Settings' );
✅ GOOD:
echo __( 'Save Settings', 'my-awesome-plugin' );
## FILE: includes/class-cpt.php
### Line 23: CRITICAL - flush_rewrite_rules on init hook
Expensive DB write on every page load. Move to activation hook.
❌ BAD:
add_action( 'init', 'mypl_register_cpt' );
function mypl_register_cpt() {
register_post_type( 'book', array( /* ... */ ) );
flush_rewrite_rules(); // Runs on EVERY request
}
✅ GOOD:
add_action( 'init', 'mypl_register_cpt' );
function mypl_register_cpt() {
register_post_type( 'mypl_book', array( /* ... */ ) );
}
register_activation_hook( __FILE__, 'mypl_activate' );
function mypl_activate() {
mypl_register_cpt();
flush_rewrite_rules(); // Only on activation
}
## SUMMARY
**Total issues: 15**
- CRITICAL: 4 (must fix for WordPress.org submission)
- WARNING: 8 (non-standard patterns)
- INFO: 3 (best practice improvements)
**WordPress.org readiness:** NOT READY - 4 critical issues block submission
**Security note:** This review focused on plugin architecture and WordPress.org compliance. Security issues detected (missing nonce in AJAX handler, unsanitized input in form). Run `/wp-sec-review` for comprehensive security analysis.
Patterns that look like issues but are NOT problems:
| Pattern | Why It's NOT a Problem | Context |
|---|---|---|
| mu-plugin without activation hooks | Must-use plugins load automatically, don't activate/deactivate | Normal for mu-plugins in wp-content/mu-plugins/ |
| Drop-in plugin without standard header | Drop-ins use special filenames, not plugin headers | Valid for object-cache.php, db.php, advanced-cache.php, etc. |
| Private plugin without readme.txt | readme.txt only required for WordPress.org submissions | Private/enterprise plugins use internal docs |
__return_true in REST permission_callback for GET | Public read-only endpoints don't need authentication | Correct pattern for public REST API reads |
| Settings API sanitize_callback changing type | Can convert checkbox string to boolean, text to array, etc. | Valid transformation, not a bug |
| No text domain for core WordPress strings | Core strings already translated | Valid when passing strings to wp_die(), __() with core strings |
| Short prefix (3 chars) with namespace | PHP namespace provides collision protection | Acceptable when using namespace MyPlugin\Feature; |
| No activation hook when plugin has no setup | Not all plugins need database tables, options, or rewrite flushes | Valid for simple plugins (shortcodes, filters only) |
flush_rewrite_rules() in admin settings save | Acceptable when user explicitly changes permalink structure | Valid in settings pages when slug/rewrite changes |
Direct $wpdb->query() for DROP TABLE | dbDelta() is for CREATE/ALTER, not DROP | Correct pattern in uninstall.php |
| Missing i18n on internal debug strings | Developer-facing strings don't need translation | Valid for error_log(), internal comments |
register_taxonomy() without show_in_rest | Not all taxonomies need Gutenberg UI | Valid for backend-only taxonomies |
Quick checklist for Plugin Check standards before WordPress.org submission:
defined( 'ABSPATH' ) || exit;)/wp-content/ or /wp-content/plugins/ pathseval(), base64_decode(), or obfuscated codeRequires at least, Requires PHP)Verification command:
wp plugin install plugin-check --activate
wp plugin check my-plugin.php
For advanced plugin development patterns, load these companion reference documents:
| Task | Reference to Load |
|---|---|
| Plugin file structure, singleton patterns, autoloading, dependency injection, main plugin class architecture | references/architecture-patterns.md |
| Action/filter lifecycle, priority system, hook removal, custom hooks, pluggable functions, hook naming conventions | references/hooks-guide.md |
| Class-based plugin architecture, PHP namespaces, PSR-4 autoloading, trait usage, abstract classes, service containers | references/oop-patterns.md |
| Settings API workflow, Options API best practices, REST API schema validation, Transients API, custom database tables with dbDelta | references/api-patterns.md |
Note: Reference docs provide deep-dive content. This SKILL.md is self-sufficient for standard plugin reviews.
Security crossover: When encountering security-relevant patterns (form handlers without nonces, AJAX without capability checks, REST endpoints without permission validation), this skill provides brief reminders but defers to wp-security-review for comprehensive security analysis. The three-step security pattern (nonce + capability + sanitize) applies to all state-changing operations. Use /wp-sec-review command for detailed security audit.
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (jorgerosal/wordpress-skills) — no native marketplace selected
npx claudepluginhub p/jorgerosal-wordpress-skills18 skills in this plugin
/wp-accessibility-reviewWordPress accessibility review for themes, blocks, plugins, and admin interfaces. Use when reviewing keyboard navigation, focus behavior, semantic HTML, ARIA usage, form labeling, screen-reader support, contrast-related implementation issues, or when user mentions "accessibility review", "a11y", "keyboard navigation", "focus management", "screen reader", "ARIA", "semantic HTML", "accessible form", or "accessible block". Detects implementation-level accessibility issues in frontend output, block markup, admin screens, and interactive UI behavior./wp-acf-and-content-modelingWordPress ACF and content modeling review. Use when reviewing Advanced Custom Fields usage, field group architecture, CPT and taxonomy design, options pages, repeaters, flexible content, block-bound field groups, meta storage patterns, or when user mentions "ACF", "field groups", "flexible content", "repeater", "custom post type design", "taxonomy design", "content model", "relationship fields", "ACF JSON", "options page", or "meta query performance". Detects schema drift, weak content modeling, brittle field naming, and performance issues in meta-heavy WordPress builds./wp-admin-ui-developmentWordPress admin UI review and development guidance. Use when reviewing admin pages, settings screens, menu pages, notices, list tables, metabox-like interfaces, screen options, capability checks, admin scripts or styles, or when user mentions "admin UI", "settings page", "wp-admin", "admin screen", "options page", "list table", "admin menu", "admin notice", "screen options", or "dashboard page". Detects capability issues, Settings API misuse, admin-only performance problems, and UX mistakes in WordPress admin interfaces./wp-block-developmentWordPress block editor code review and Gutenberg block development patterns for WordPress 6.x+. Use when reviewing block code, auditing block.json schema, checking editor components, validating render callbacks, analyzing block attributes, verifying InnerBlocks usage, detecting block validation errors, reviewing Interactivity API directives, or when user mentions "block review", "Gutenberg", "block development", "block editor", "block.json", "useBlockProps", "InnerBlocks", "Interactivity API", "data-wp-bind", "render_callback", "dynamic block", "static block", "block deprecation", "block attributes", "block supports", "@wordpress/scripts", "wp-scripts", "block validation error", "save function", "RichText", "InspectorControls", "BlockControls". Detects issues in block.json schema, React/JSX editor patterns, server-side rendering, attribute handling, and frontend interactions./wp-ci-cd-and-release-engineeringWordPress CI/CD and release engineering review guidance. Use when reviewing GitHub Actions, deployment pipelines, Composer/npm build steps, plugin/theme packaging, release automation, secrets handling, SVN deploy flows for WordPress.org, staged rollouts, rollback plans, or when user mentions CI, CD, release pipeline, GitHub Actions, deployment workflow, build artifact, plugin zip, or release engineering. Helps review build reproducibility, packaging correctness, secret boundaries, deployment safety, rollback readiness, and WordPress-specific release pitfalls./wp-headless-and-wpgraphqlHeadless WordPress and WPGraphQL review guidance. Use when reviewing decoupled WordPress architectures, WPGraphQL schema design, `register_graphql_field`, `register_graphql_connection`, `graphql_register_types`, Next.js/Gatsby/Remix frontends, preview mode, auth flows, persisted queries, or build/revalidation pipelines. Helps review schema boundaries, resolver performance, preview/auth correctness, cache invalidation, and content modeling decisions for headless WordPress stacks.Other plugins' skills for the same job