woocommerce
WordPressおよびWooCommerceの開発ガイドラインに従い、PHPのベストプラクティス・セキュリティ基準・拡張性パターンを考慮したコードを生成・レビューします。WooCommerceプラグインやテーマ開発において、安全で保守性の高い実装をサポートします。
description の原文を見る
WordPress and WooCommerce development guidelines with PHP best practices, security standards, and extensibility patterns
SKILL.md 本文
WooCommerce 開発
WordPress と WooCommerce の開発、PHP のベストプラクティス、および e コマースソリューションの専門家です。
コア原則
- WordPress コーディング標準に従う
- WooCommerce のフックとフィルターを適切に使用する
- すべてのコードでセキュリティを優先する
- 後方互換性を維持する
- パフォーマンスとスケーラビリティの高いコードを書く
PHP ベストプラクティス
コーディング標準
- WordPress PHP コーディング標準に従う
- 関数と変数に意味のある名前を使用する
- 競合を避けるために、すべての関数とクラスにプレフィックスを付ける
- PHPDoc コメントでコードを文書化する
Namespacing
namespace MyPlugin\WooCommerce;
class ProductHandler {
public function __construct() {
add_action('woocommerce_before_add_to_cart_form', [$this, 'custom_content']);
}
public function custom_content() {
// Custom functionality
}
}
WooCommerce フック
アクションフック
// Add content after product summary
add_action('woocommerce_after_single_product_summary', 'custom_product_content', 15);
function custom_product_content() {
echo '<div class="custom-content">Additional information</div>';
}
// Modify order processing
add_action('woocommerce_order_status_completed', 'process_completed_order', 10, 1);
function process_completed_order($order_id) {
$order = wc_get_order($order_id);
// Process order
}
フィルターフック
// Modify product price display
add_filter('woocommerce_get_price_html', 'custom_price_html', 10, 2);
function custom_price_html($price, $product) {
if ($product->is_on_sale()) {
$price .= '<span class="sale-badge">Sale!</span>';
}
return $price;
}
// Add custom checkout fields
add_filter('woocommerce_checkout_fields', 'custom_checkout_fields');
function custom_checkout_fields($fields) {
$fields['billing']['billing_custom_field'] = [
'type' => 'text',
'label' => __('Custom Field', 'textdomain'),
'required' => false,
'priority' => 25,
];
return $fields;
}
セキュリティ
データ検証
// Sanitize input
$product_id = absint($_POST['product_id']);
$quantity = wc_stock_amount($_POST['quantity']);
$email = sanitize_email($_POST['email']);
// Escape output
echo esc_html($product->get_name());
echo esc_url($product->get_permalink());
echo wp_kses_post($product->get_description());
Nonce 検証
// Create nonce
wp_nonce_field('custom_action', 'custom_nonce');
// Verify nonce
if (!wp_verify_nonce($_POST['custom_nonce'], 'custom_action')) {
wp_die(__('Security check failed', 'textdomain'));
}
権限チェック
if (!current_user_can('manage_woocommerce')) {
wp_die(__('Unauthorized access', 'textdomain'));
}
カスタム商品タイプ
class WC_Product_Custom extends WC_Product {
public function get_type() {
return 'custom';
}
// Custom methods
}
add_filter('product_type_selector', function($types) {
$types['custom'] = __('Custom Product', 'textdomain');
return $types;
});
REST API 拡張
add_action('rest_api_init', function() {
register_rest_route('custom/v1', '/products/featured', [
'methods' => 'GET',
'callback' => 'get_featured_products',
'permission_callback' => '__return_true',
]);
});
function get_featured_products($request) {
$args = [
'status' => 'publish',
'featured' => true,
'limit' => 10,
];
$products = wc_get_products($args);
return rest_ensure_response($products);
}
データベース操作
global $wpdb;
// Use prepare for queries with variables
$results = $wpdb->get_results($wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}wc_orders WHERE status = %s",
'completed'
));
// Use WooCommerce data stores when possible
$product = new WC_Product();
$product->set_name('New Product');
$product->set_regular_price('29.99');
$product->save();
パフォーマンス
- キャッシング用に transients を使用する
- データベースクエリを最適化する
- 可能な限り遅延ロードを行う
- HTTP リクエストを最小化する
- オブジェクトキャッシングを使用する
キャッシング
$cached_data = get_transient('custom_product_data');
if (false === $cached_data) {
$cached_data = expensive_query();
set_transient('custom_product_data', $cached_data, HOUR_IN_SECONDS);
}
プラグイン構造
plugin-name/
├── plugin-name.php
├── includes/
│ ├── class-main.php
│ ├── class-admin.php
│ └── class-frontend.php
├── admin/
│ ├── css/
│ └── js/
├── public/
│ ├── css/
│ └── js/
├── templates/
└── languages/
テスト
- PHPUnit でユニットテストを書く
- WordPress テスト用に WP_UnitTestCase を使用する
- WooCommerce テストヘルパーでテストする
- PHPCS WordPress 標準で検証する
ライセンス: Apache-2.0(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- mindrally
- リポジトリ
- mindrally/skills
- ライセンス
- Apache-2.0
- 最終更新
- 不明
Source: https://github.com/mindrally/skills / ライセンス: Apache-2.0
関連スキル
secure-code-guardian
認証・認可の実装、ユーザー入力の保護、OWASP Top 10の脆弱性対策が必要な場合に使用します。bcrypt/argon2によるパスワードハッシング、パラメータ化ステートメントによるSQLインジェクション対策、CORS/CSPヘッダーの設定、Zodによる入力検証、JWTトークンの構築などのカスタムセキュリティ実装に対応します。認証、認可、入力検証、暗号化、OWASP Top 10対策、セッション管理、セキュリティ強化全般で活用できます。ただし、構築済みのOAuth/SSO統合や単独のセキュリティ監査が必要な場合は、より特化したスキルの検討をお勧めします。
claude-authenticity
APIエンドポイントが本物のClaudeによって支えられているか(ラッパーやプロキシ、偽装ではないか)を、claude-verifyプロジェクトを模した9つの重み付きルールベースチェックで検証できます。また、Claudeの正体を上書きしているプロバイダーから注入されたシステムプロンプトも抽出します。完全に自己完結しており、httpx以外の追加パッケージは不要です。Claude APIキーまたはエンドポイントを検証したい場合、サードパーティのClaudeサービスが本物か確認したい場合、APIプロバイダーのClaude正当性を監査したい場合、複数モデルを並行してテストしたい場合、またはプロバイダーが注入したシステムプロンプトを特定したい場合に使用できます。
anth-security-basics
Anthropic Claude APIのセキュリティベストプラクティスを適用し、キー管理、入力値の検証、プロンプトインジェクション対策を実施します。APIキーの保護、Claudeに送信する前のユーザー入力検証、コンテンツセーフティガードレールの実装が必要な場合に活用できます。「anthropic security」「claude api key security」「secure anthropic」「prompt injection defense」といったフレーズでトリガーされます。
x-ray
x-ray.mdプレ監査レポートを生成します。概要、強化された脅威モデル(プロトコルタイプのプロファイリング、Gitの重み付け攻撃面分析、時間軸リスク分析、コンポーザビリティ依存関係マッピング)、不変条件、統合、ドキュメント品質、テスト分析、開発者・Gitの履歴をカバーしています。「x-ray」「audit readiness」「readiness report」「pre-audit report」「prep this protocol」「protocol prep」「summarize this protocol」のキーワードで実行されます。
semgrep
Semgrepスタティック分析スキャンを実行し、カスタム検出ルールを作成します。Semgrepでのコードスキャン、セキュリティ脆弱性の検出、カスタムYAMLルールの作成、または特定のバグパターンの検出が必要な場合に使用します。重要:ユーザーが「バグをスキャンしたい」「コード品質を確認したい」「脆弱性を見つけたい」「スタティック分析」「セキュリティlint」「コード監査」または「コーディング標準を適用したい」と尋ねた場合も、Semgrepという名称を明記していなくても、このスキルを使用してください。Semgrepは30以上の言語に対応したパターンベースのコードスキャンに最適なツールです。
ghost-bits-cast-attack
Java「ゴーストビッツ」/キャストアタック プレイブック(Black Hat Asia 2026)。16ビット文字が8ビットバイトに暗黙的に縮小されるJavaサービスへの攻撃時に使用します。WAF/IDSを回避して、SQLインジェクション、デシリアライゼーション型RCE、ファイルアップロード(Webシェル)、パストトラバーサル、CRLF インジェクション、リクエストスマグリング、SMTPインジェクションを実行できます。Tomcat、Spring、Jetty、Undertow、Vert.x、Jackson、Fastjson、Apache Commons BCEL、Apache HttpClient、Angus Mail、JDK HttpServer、Lettuce、Jodd、XMLWriterに影響し、WAFバイパスにより多くの「パッチ済み」CVEを再度有効化します。