activitypub-php-conventions

Standardize PHP coding conventions for the ActivityPub WordPress plugin.

576|90|Updated Jul 10, 2018
One-click install
npx skills add https://github.com/Automattic/wordpress-activitypub --skill activitypub-php-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: activitypub-php-conventions
Source: https://github.com/Automattic/wordpress-activitypub/tree/main/.claude/skills/activitypub-php-conventions
Command: npx skills add https://github.com/Automattic/wordpress-activitypub --skill activitypub-php-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Maintaining consistent, high-quality PHP code in a large WordPress plugin can be challenging, leading to technical debt and slower development. This Skill provides clear conventions to ensure uniformity, making your code easier to read, maintain, and extend.

Core Features & Use Cases

  • Coding Standards: Guidelines for file naming, namespaces, text domains, and proper usage of WordPress global functions within the plugin.
  • Architectural Patterns: Detailed explanations and examples for core ActivityPub components like Transformers (converting content), Handlers (processing activities), Collections (managing lists), and REST API Controllers.
  • Plugin Structure: Overview of the includes/ and integration/ directory organization, helping you place new files correctly.

Quick Start

Explain the ActivityPub plugin's PHP file naming conventions and provide an example for a regular class.

Frequently Asked Questions about activitypub-php-conventions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I establish consistent file naming and namespace conventions for a WordPress ActivityPub plugin?

PHP file naming conventions in ActivityPub plugins follow a pattern tied to their purpose: regular classes use PascalCase filenames matching the class name, while handler and transformer classes include their role in the filename (e.g., ActivityHandler.php). Namespaces mirror directory structure under the plugin's root namespace, and all files declare their namespace at the top to enable proper autoloading and text domain usage within namespaced code.

What are Transformers, Handlers, and Collections in ActivityPub PHP architecture?

Transformers convert WordPress content into ActivityPub format; Handlers process incoming ActivityPub activities and route them to appropriate actions; Collections manage lists of ActivityPub objects. Each follows a documented pattern: Transformers inherit from a base class and implement conversion methods, Handlers contain activity routing logic, and Collections provide iteration and filtering over ActivityPub object groups.

How should I organize files in the includes and integration directories of an ActivityPub WordPress plugin?

The includes directory holds core ActivityPub classes organized by function—Transformers, Handlers, Collections, and REST controllers go in appropriately named subdirectories. The integration directory contains adapters that connect ActivityPub to other WordPress components. Both directories follow the same namespace and naming conventions, enabling consistent structure across the plugin.

Can I use WordPress global functions like esc_html() and get_option() directly within namespaced plugin code?

Yes, WordPress global functions work in namespaced code without modification because they are defined in the global namespace. Reference them directly by name—PHP automatically resolves them to the global scope. The plugin enforces proper escaping standards for all output, regardless of namespace depth.

What REST endpoint patterns does ActivityPub PHP follow for plugin extensions?

REST API controllers inherit from a base controller class and register routes under the plugin's REST namespace. Each endpoint maps to a controller method that handles the HTTP verb and returns ActivityPub-formatted JSON. Controllers follow a consistent pattern for parameter validation, permission checking, and response formatting.

Why do ActivityPub PHP conventions matter for plugin maintenance and team development?

Consistent conventions reduce technical debt by making code predictable: developers know where to find functionality, how new files should be named, and which patterns to follow. This uniformity speeds up code reviews, onboarding, and refactoring across a large plugin codebase.