PHP Skill
Modern PHP development with a focus on WordPress plugin development, OOP patterns, and security.
RULE: Always show generated class/function signatures before writing full implementation. Wait for GO.
🚧 Status: Stub — implementation pending
This reference skill has the structure but the snippet content is still being filled in
(you'll see <!-- TODO --> placeholders below). It activates and tells Claude the topic
exists, but won't yield deep snippets yet.
Want to help? Pick any TODO, write the snippet, open a PR. See CONTRIBUTING.md.
Each contribution moves the skill closer to "Ready" status.
Capabilities
OOP PHP Patterns
Laravel Basics
Custom Plugin Development
REST API Endpoints
Database Queries (wpdb)
Security (Sanitization, Nonces)
Patterns Reference
Secure wpdb query
global $wpdb;
$results = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}my_table WHERE user_id = %d AND status = %s",
$user_id,
$status
)
);
REST API endpoint
add_action( 'rest_api_init', function() {
register_rest_route( 'myplugin/v1', '/data/(?P<id>\d+)', [
'methods' => 'GET',
'callback' => 'myplugin_get_data',
'permission_callback' => function() {
return current_user_can( 'read' );
},
'args' => [
'id' => [ 'required' => true, 'validate_callback' => 'is_numeric' ]
],
]);
});
function myplugin_get_data( WP_REST_Request $request ): WP_REST_Response {
$id = absint( $request->get_param( 'id' ) );
$data = get_post_meta( $id, '_my_meta', true );
return new WP_REST_Response( [ 'data' => $data ], 200 );
}
Nonce verification
// In form
wp_nonce_field( 'myplugin_action', 'myplugin_nonce' );
// On save
if ( ! isset( $_POST['myplugin_nonce'] ) ||
! wp_verify_nonce( $_POST['myplugin_nonce'], 'myplugin_action' ) ) {
wp_die( 'Security check failed' );
}
1---2name: php3description: PHP development — OOP patterns, Laravel basics, WordPress plugin development, REST API endpoints, wpdb queries, security (sanitization, nonces)4---56# PHP Skill78Modern PHP development with a focus on WordPress plugin development, OOP patterns, and security.910**RULE: Always show generated class/function signatures before writing full implementation. Wait for GO.**1112> **🚧 Status: Stub — implementation pending**13>14> This reference skill has the structure but the snippet content is still being filled in15> (you'll see `<!-- TODO -->` placeholders below). It activates and tells Claude the topic16> exists, but won't yield deep snippets yet.17>18> **Want to help?** Pick any TODO, write the snippet, open a PR. See [CONTRIBUTING.md](../../CONTRIBUTING.md).19> Each contribution moves the skill closer to "Ready" status.2021---2223## Capabilities2425### OOP PHP Patterns26<!-- TODO: Singleton, Factory, Observer patterns in PHP -->27<!-- TODO: Interfaces, abstract classes, traits -->28<!-- TODO: PHP 8.x features: named args, match, fibers, readonly, enums -->29<!-- TODO: Composer autoloading, PSR-4 namespace setup -->3031### Laravel Basics32<!-- TODO: Routes, controllers, middleware, request validation -->33<!-- TODO: Eloquent ORM, migrations, factories, seeders -->34<!-- TODO: Blade templates, Livewire basics -->35<!-- TODO: Artisan commands, queues, jobs -->3637### Custom Plugin Development38<!-- TODO: Plugin bootstrap pattern (main class, loader, activator, deactivator) -->39<!-- TODO: Admin pages, settings API, options -->40<!-- TODO: Shortcodes, widgets, Gutenberg blocks in PHP -->41<!-- TODO: Plugin update checker (custom update server) -->4243### REST API Endpoints44<!-- TODO: register_rest_route, WP_REST_Controller base class -->45<!-- TODO: Authentication (nonce, application passwords, JWT) -->46<!-- TODO: Custom endpoints for WooCommerce data -->47<!-- TODO: Rate limiting, input validation, error responses -->4849### Database Queries (wpdb)50<!-- TODO: $wpdb->get_results, get_row, get_var, insert, update, delete -->51<!-- TODO: Prepared statements — never interpolate user input -->52<!-- TODO: Custom table creation in plugin activation -->53<!-- TODO: Query optimization, EXPLAIN, slow query identification -->5455### Security (Sanitization, Nonces)56<!-- TODO: sanitize_text_field, sanitize_email, esc_html, esc_attr, esc_url -->57<!-- TODO: wp_nonce_field, check_admin_referer, wp_verify_nonce -->58<!-- TODO: current_user_can() capability checks -->59<!-- TODO: SQL injection prevention, XSS prevention, CSRF protection -->6061---6263## Patterns Reference6465### Secure wpdb query66```php67global $wpdb;68$results = $wpdb->get_results(69 $wpdb->prepare(70 "SELECT * FROM {$wpdb->prefix}my_table WHERE user_id = %d AND status = %s",71 $user_id,72 $status73 )74);75```7677### REST API endpoint78```php79add_action( 'rest_api_init', function() {80 register_rest_route( 'myplugin/v1', '/data/(?P<id>\d+)', [81 'methods' => 'GET',82 'callback' => 'myplugin_get_data',83 'permission_callback' => function() {84 return current_user_can( 'read' );85 },86 'args' => [87 'id' => [ 'required' => true, 'validate_callback' => 'is_numeric' ]88 ],89 ]);90});9192function myplugin_get_data( WP_REST_Request $request ): WP_REST_Response {93 $id = absint( $request->get_param( 'id' ) );94 $data = get_post_meta( $id, '_my_meta', true );95 return new WP_REST_Response( [ 'data' => $data ], 200 );96}97```9899### Nonce verification100```php101// In form102wp_nonce_field( 'myplugin_action', 'myplugin_nonce' );103104// On save105if ( ! isset( $_POST['myplugin_nonce'] ) ||106 ! wp_verify_nonce( $_POST['myplugin_nonce'], 'myplugin_action' ) ) {107 wp_die( 'Security check failed' );108}109```110111<!-- TODO: Add full interactive workflows for each capability above -->