重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
php-wordpress by pluginagentmarketplace/custom-plugin-php
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-php --skill php-wordpress掌握 WordPress 主题和插件开发的原子技能
用于构建 WordPress 主题、插件和古腾堡块的综合技能。涵盖 WordPress 6.x,专注于现代开发实践和安全性。
interface SkillParams {
topic:
| "themes" // 经典主题、区块主题、全站编辑
| "plugins" // 架构、钩子、设置
| "gutenberg" // 区块、模式、InnerBlocks
| "rest-api" // 自定义端点、身份验证
| "security" // 随机数、数据清理、转义
| "woocommerce"; // 商店扩展
level: "beginner" | "intermediate" | "advanced";
wp_version?: "6.4" | "6.5" | "6.6" | "6.7";
theme_type?: "classic" | "block" | "hybrid";
}
validation:
topic:
required: true
allowed: [themes, plugins, gutenberg, rest-api, security, woocommerce]
level:
required: true
wp_version:
default: "6.6"
beginner:
- 主题结构和文件
- 模板层次结构
- 加载样式/脚本
intermediate:
- 自定义文章类型
- 主题定制器
- 区块主题基础
advanced:
- 全站编辑
- 深入理解 theme.json
- 性能优化
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
beginner:
- 插件结构
- 动作和过滤器
- 短代码
intermediate:
- 设置 API
- 自定义数据库表
- AJAX 处理
advanced:
- 插件架构模式
- WP-CLI 命令
- 多站点支持
beginner:
- 区块基础和 block.json
- 编辑和保存函数
- 区块属性
intermediate:
- InnerBlocks
- 区块变体
- 服务端渲染
advanced:
- 交互性 API
- 区块绑定
- 自定义区块分类
errors:
HOOK_ERROR:
code: "WP_001"
recovery: "检查钩子名称和触发时机"
SECURITY_ERROR:
code: "WP_002"
recovery: "添加适当的转义/清理"
retry:
max_attempts: 3
backoff:
type: exponential
initial_delay_ms: 100
<?php
/**
* Plugin Name: My Custom Plugin
* Description: A custom WordPress plugin
* Version: 1.0.0
* Requires PHP: 8.0
* Author: Developer
*/
declare(strict_types=1);
defined('ABSPATH') || exit;
final class MyCustomPlugin
{
public function __construct()
{
add_action('init', [$this, 'registerPostType']);
add_action('rest_api_init', [$this, 'registerRoutes']);
}
public function registerPostType(): void
{
register_post_type('portfolio', [
'labels' => ['name' => __('Portfolio')],
'public' => true,
'show_in_rest' => true,
'supports' => ['title', 'editor', 'thumbnail'],
]);
}
public function registerRoutes(): void
{
register_rest_route('myplugin/v1', '/items', [
'methods' => 'GET',
'callback' => [$this, 'getItems'],
'permission_callback' => '__return_true',
]);
}
public function getItems(\WP_REST_Request $request): \WP_REST_Response
{
$items = get_posts(['post_type' => 'portfolio']);
return new \WP_REST_Response($items, 200);
}
}
new MyCustomPlugin();
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "myplugin/testimonial",
"title": "Testimonial",
"category": "widgets",
"icon": "format-quote",
"description": "Display a testimonial",
"supports": {
"html": false,
"align": ["wide", "full"]
},
"attributes": {
"content": { "type": "string" },
"author": { "type": "string" }
},
"textdomain": "myplugin",
"editorScript": "file:./index.js",
"style": "file:./style-index.css"
}
<?php
// 输入清理
$title = sanitize_text_field($_POST['title'] ?? '');
$content = wp_kses_post($_POST['content'] ?? '');
$id = absint($_POST['id'] ?? 0);
// 输出转义
echo esc_html($title);
echo esc_attr($attribute);
echo esc_url($url);
echo wp_kses_post($content);
// 随机数验证
if (!wp_verify_nonce($_POST['_wpnonce'], 'my_action')) {
wp_die('Security check failed');
}
// 权限检查
if (!current_user_can('edit_posts')) {
wp_die('Unauthorized');
}
// 数据库查询
global $wpdb;
$results = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}custom_table WHERE id = %d",
$id
)
);
| 问题 | 解决方案 |
|---|---|
| 钩子未触发 | 检查钩子名称拼写和触发时机 |
| 区块未显示 | 验证 block.json,运行 npm build |
| REST API 403 | 检查 permission_callback |
| 白屏 | 启用 WP_DEBUG,检查 error.log |
// wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', true);
| 指标 | 目标 |
|---|---|
| 安全合规性 | 100% |
| 钩子正确性 | 100% |
| WPCS 合规性 | 100% |
Skill("php-wordpress", {topic: "gutenberg", level: "intermediate"})
每周安装
46
仓库
GitHub 星标
2
首次出现
2026年1月25日
安全审计
安装于
codex40
github-copilot40
gemini-cli38
opencode38
amp34
kimi-cli34
Atomic skill for mastering WordPress theme and plugin development
Comprehensive skill for building WordPress themes, plugins, and Gutenberg blocks. Covers WordPress 6.x with focus on modern development practices and security.
interface SkillParams {
topic:
| "themes" // Classic, block, FSE
| "plugins" // Architecture, hooks, settings
| "gutenberg" // Blocks, patterns, InnerBlocks
| "rest-api" // Custom endpoints, authentication
| "security" // Nonces, sanitization, escaping
| "woocommerce"; // Store extensions
level: "beginner" | "intermediate" | "advanced";
wp_version?: "6.4" | "6.5" | "6.6" | "6.7";
theme_type?: "classic" | "block" | "hybrid";
}
validation:
topic:
required: true
allowed: [themes, plugins, gutenberg, rest-api, security, woocommerce]
level:
required: true
wp_version:
default: "6.6"
beginner:
- Theme structure and files
- Template hierarchy
- Enqueuing styles/scripts
intermediate:
- Custom post types
- Theme customizer
- Block theme basics
advanced:
- Full Site Editing
- theme.json deep dive
- Performance optimization
beginner:
- Plugin structure
- Actions and filters
- Shortcodes
intermediate:
- Settings API
- Custom database tables
- AJAX handling
advanced:
- Plugin architecture patterns
- WP-CLI commands
- Multisite support
beginner:
- Block basics and block.json
- Edit and save functions
- Block attributes
intermediate:
- InnerBlocks
- Block variations
- Server-side rendering
advanced:
- Interactivity API
- Block Bindings
- Custom block categories
errors:
HOOK_ERROR:
code: "WP_001"
recovery: "Check hook name and timing"
SECURITY_ERROR:
code: "WP_002"
recovery: "Add proper escaping/sanitization"
retry:
max_attempts: 3
backoff:
type: exponential
initial_delay_ms: 100
<?php
/**
* Plugin Name: My Custom Plugin
* Description: A custom WordPress plugin
* Version: 1.0.0
* Requires PHP: 8.0
* Author: Developer
*/
declare(strict_types=1);
defined('ABSPATH') || exit;
final class MyCustomPlugin
{
public function __construct()
{
add_action('init', [$this, 'registerPostType']);
add_action('rest_api_init', [$this, 'registerRoutes']);
}
public function registerPostType(): void
{
register_post_type('portfolio', [
'labels' => ['name' => __('Portfolio')],
'public' => true,
'show_in_rest' => true,
'supports' => ['title', 'editor', 'thumbnail'],
]);
}
public function registerRoutes(): void
{
register_rest_route('myplugin/v1', '/items', [
'methods' => 'GET',
'callback' => [$this, 'getItems'],
'permission_callback' => '__return_true',
]);
}
public function getItems(\WP_REST_Request $request): \WP_REST_Response
{
$items = get_posts(['post_type' => 'portfolio']);
return new \WP_REST_Response($items, 200);
}
}
new MyCustomPlugin();
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "myplugin/testimonial",
"title": "Testimonial",
"category": "widgets",
"icon": "format-quote",
"description": "Display a testimonial",
"supports": {
"html": false,
"align": ["wide", "full"]
},
"attributes": {
"content": { "type": "string" },
"author": { "type": "string" }
},
"textdomain": "myplugin",
"editorScript": "file:./index.js",
"style": "file:./style-index.css"
}
<?php
// Input sanitization
$title = sanitize_text_field($_POST['title'] ?? '');
$content = wp_kses_post($_POST['content'] ?? '');
$id = absint($_POST['id'] ?? 0);
// Output escaping
echo esc_html($title);
echo esc_attr($attribute);
echo esc_url($url);
echo wp_kses_post($content);
// Nonce verification
if (!wp_verify_nonce($_POST['_wpnonce'], 'my_action')) {
wp_die('Security check failed');
}
// Capability check
if (!current_user_can('edit_posts')) {
wp_die('Unauthorized');
}
// Database queries
global $wpdb;
$results = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}custom_table WHERE id = %d",
$id
)
);
| Problem | Solution |
|---|---|
| Hook not firing | Check hook name spelling and timing |
| Block not appearing | Verify block.json, run npm build |
| REST API 403 | Check permission_callback |
| White screen | Enable WP_DEBUG, check error.log |
// wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', true);
| Metric | Target |
|---|---|
| Security compliance | 100% |
| Hook correctness | 100% |
| WPCS compliance | 100% |
Skill("php-wordpress", {topic: "gutenberg", level: "intermediate"})
Weekly Installs
46
Repository
GitHub Stars
2
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex40
github-copilot40
gemini-cli38
opencode38
amp34
kimi-cli34
PHP 8.x 最佳实践指南:51条规则掌握现代PHP开发、PSR标准与SOLID原则
1,200 周安装