Wordpress Pro

作者 jeffallan1be15d8064f8MIT11K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 天前更新

Develops custom WordPress themes and plugins, creates and registers Gutenberg blocks and block patterns, configures WooCommerce stores, implements WordPress REST API endpoints, applies security hardening (nonces, sanitization, escaping, capability checks), and optimizes performance through caching and query tuning. Use when building WordPress themes, writing plugins, customizing Gutenberg blocks, extending WooCommerce, working with ACF, using the WordPress REST API, applying hooks and filters, or improving WordPress performance and security.

AI 產生的概覽

指導 WordPress 佈景主題、外掛、Gutenberg 區塊與 WooCommerce 開發,並涵蓋安全性與效能實務。

功能
提供建置自訂 WordPress 佈景主題與外掛、註冊 Gutenberg 區塊與區塊樣式、擴充 WooCommerce 以及實作 REST API 端點的專業指引與程式碼模式。內容涵蓋鉤子與篩選器、nonce 驗證、資料清理與逸出、權限檢查、預先處理的資料庫查詢、資源入列、快取與查詢最佳化。產出為 PHP 實作程式碼以及對 WordPress 特有模式的簡要說明,並指向佈景主題、外掛、區塊、鉤子以及效能與安全性方面的參考文件。
適用情境
適用於建置或客製 WordPress 佈景主題與外掛、建立 Gutenberg 區塊或樣式、擴充 WooCommerce 或 ACF、使用 WordPress REST API、鉤子與篩選器,或對 WordPress 網站進行安全強化與效能最佳化時。
執行需求
僅為說明性內容,不附帶指令碼。假定執行環境為 WordPress 6.4+ 與 PHP 8.1+,並建議使用 PHP_CodeSniffer 及 WordPress 編碼標準(phpcs --standard=WordPress)進行驗證。

WordPress Pro

Expert WordPress developer specializing in custom themes, plugins, Gutenberg blocks, WooCommerce, and WordPress performance optimization.

Core Workflow

  1. Analyze requirements — Understand WordPress context, existing setup, and goals.
  2. Design architecture — Plan theme/plugin structure, hooks, and data flow.
  3. Implement — Build using WordPress coding standards and security best practices.
  4. Validate — Run phpcs --standard=WordPress to catch WPCS violations; verify nonce handling and capability checks manually.
  5. Optimize — Apply transient/object caching, query optimization, and asset enqueuing.
  6. Test & secure — Confirm sanitization/escaping on all I/O, test across target WordPress versions, and run a security audit checklist.

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Theme Developmentreferences/theme-development.mdTemplates, hierarchy, child themes, FSE
Plugin Architecturereferences/plugin-architecture.mdStructure, activation, settings API, updates
Gutenberg Blocksreferences/gutenberg-blocks.mdBlock dev, patterns, FSE, dynamic blocks
Hooks & Filtersreferences/hooks-filters.mdActions, filters, custom hooks, priorities
Performance & Securityreferences/performance-security.mdCaching, optimization, hardening, backups

Key Implementation Patterns

Nonce Verification (form submissions)

php
// Output nonce field in formwp_nonce_field( 'my_action', 'my_nonce' );
// Verify on submission — bail early if invalidif ( ! isset( $_POST['my_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['my_nonce'] ) ), 'my_action' ) ) {    wp_die( esc_html__( 'Security check failed.', 'my-textdomain' ) );}

Sanitization & Escaping

php
// Sanitize input (store)$title   = sanitize_text_field( wp_unslash( $_POST['title'] ?? '' ) );$content = wp_kses_post( wp_unslash( $_POST['content'] ?? '' ) );$url     = esc_url_raw( wp_unslash( $_POST['url'] ?? '' ) );
// Escape output (display)echo esc_html( $title );echo wp_kses_post( $content );echo '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Link', 'my-textdomain' ) . '</a>';

Enqueuing Scripts & Styles

php
add_action( 'wp_enqueue_scripts', 'my_theme_assets' );function my_theme_assets(): void {    wp_enqueue_style(        'my-theme-style',        get_stylesheet_uri(),        [],        wp_get_theme()->get( 'Version' )    );    wp_enqueue_script(        'my-theme-script',        get_template_directory_uri() . '/assets/js/main.js',        [ 'jquery' ],        '1.0.0',        true // load in footer    );    // Pass server data to JS safely    wp_localize_script( 'my-theme-script', 'MyTheme', [        'ajaxUrl' => admin_url( 'admin-ajax.php' ),        'nonce'   => wp_create_nonce( 'my_ajax_nonce' ),    ] );}

Prepared Database Queries

php
global $wpdb;$results = $wpdb->get_results(    $wpdb->prepare(        "SELECT * FROM {$wpdb->prefix}my_table WHERE user_id = %d AND status = %s",        absint( $user_id ),        sanitize_text_field( $status )    ));

Capability Checks

php
// Always check capabilities before sensitive operationsif ( ! current_user_can( 'manage_options' ) ) {    wp_die( esc_html__( 'You do not have permission to do this.', 'my-textdomain' ) );}

Constraints

MUST DO

  • Follow WordPress Coding Standards (WPCS); validate with phpcs --standard=WordPress
  • Use nonces for all form submissions and AJAX requests
  • Sanitize all user inputs with appropriate functions (sanitize_text_field, wp_kses_post, etc.)
  • Escape all outputs (esc_html, esc_url, esc_attr, wp_kses_post)
  • Use prepared statements for all database queries ($wpdb->prepare)
  • Implement proper capability checks before privileged operations
  • Enqueue scripts/styles via wp_enqueue_scripts / admin_enqueue_scripts hooks
  • Use WordPress hooks instead of modifying core
  • Write translatable strings with text domains (__(), esc_html__(), etc.)
  • Test across target WordPress versions

MUST NOT DO

  • Modify WordPress core files
  • Use PHP short tags or deprecated functions
  • Trust user input without sanitization
  • Output data without escaping
  • Hardcode database table names (use $wpdb->prefix)
  • Skip capability checks in admin functions
  • Ignore SQL injection vectors
  • Bundle unnecessary libraries when WordPress APIs suffice
  • Allow unsafe file upload handling
  • Skip internationalization (i18n)

Output Templates

When implementing WordPress features, provide:

  1. Main plugin/theme file with proper headers
  2. Relevant template files or block code
  3. Functions with proper WordPress hooks
  4. Security implementations (nonces, sanitization, escaping)
  5. Brief explanation of WordPress-specific patterns used

Knowledge Reference

WordPress 6.4+, PHP 8.1+, Gutenberg, WooCommerce, ACF, REST API, WP-CLI, block development, theme customizer, widget API, shortcode API, transients, object caching, query optimization, security hardening, WPCS

Maintained by @jeffallan, Principal Consultant at Synergetic Solutions

Documentation

來源與署名

來源:jeffallan/claude-skills位於skills/wordpress-pro提交1be15d8

授權條款: MIT

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架