Skip to content

Conversation

@pfefferle
Copy link
Member

Summary

Modernizes the plugin architecture by adding PHP namespaces and a PSR-4-like autoloader, matching the structure used in the webmention plugin.

Changes

  • Add Micropub namespace to all classes
  • Add PSR-4-like autoloader (class-autoloader.php)
  • Add singleton loader class (class-micropub.php)
  • Rename class files to match WordPress conventions:
    • class-micropub-base.phpclass-base.php (Micropub\Base)
    • class-micropub-endpoint.phpclass-endpoint.php (Micropub\Endpoint)
    • class-micropub-media.phpclass-media.php (Micropub\Media)
    • class-micropub-render.phpclass-render.php (Micropub\Render)
    • class-micropub-error.phpclass-error.php (Micropub\Error)
  • Update all class references to use namespaced versions
  • Remove orphaned templates/ directory (settings page was never implemented)
  • Update phpcs.xml configuration
  • Fix PHPCS violations

Breaking Changes

External code referencing the old class names will need to update to the new namespaced versions:

  • Micropub_Base\Micropub\Base
  • Micropub_Endpoint\Micropub\Endpoint
  • Micropub_Media\Micropub\Media
  • Micropub_Render\Micropub\Render
  • WP_Micropub_Error\Micropub\Error

Test plan

  • Verify plugin activates without errors
  • Test creating a post via Micropub client
  • Test media upload via Micropub
  • Verify PHPCS passes: ./vendor/bin/phpcs --standard=phpcs.xml

- Add Micropub namespace to all classes
- Add PSR-4-like autoloader (class-autoloader.php)
- Add singleton loader class (class-micropub.php)
- Rename class files to match WordPress conventions:
  - class-micropub-base.php → class-base.php
  - class-micropub-endpoint.php → class-endpoint.php
  - class-micropub-media.php → class-media.php
  - class-micropub-render.php → class-render.php
  - class-micropub-error.php → class-error.php
- Update all class references to use namespaced versions
- Remove orphaned templates directory (settings page was never implemented)
- Update phpcs.xml configuration
- Fix PHPCS violations
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Micropub WordPress plugin by introducing PHP namespaces and a PSR-4-like autoloader, matching the architecture of the webmention plugin. The changes include namespacing all classes under \Micropub, implementing an autoloader, creating a singleton loader class, and renaming class files to follow WordPress conventions.

Key Changes

  • Adds Micropub namespace to all plugin classes
  • Implements PSR-4-like autoloader for automatic class loading
  • Introduces singleton pattern with Micropub\Micropub main class
  • Renames and reorganizes class files following WordPress conventions (e.g., class-micropub-base.phpclass-base.php)
  • Updates all class references throughout codebase to use namespaced versions
  • Removes orphaned templates directory
  • Updates PHPCS configuration for broader code coverage
  • Fixes various PHPCS violations (formatting, alignment, escaping)

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
micropub.php Main plugin file with namespace declaration, autoloader integration, and plugin initialization
includes/class-autoloader.php New PSR-4 autoloader implementation for WordPress-style file naming
includes/class-micropub.php New singleton main class managing plugin initialization and hooks
includes/class-base.php Renamed from class-micropub-base.php, now \Micropub\Base with namespace
includes/class-endpoint.php Renamed from class-micropub-endpoint.php, now \Micropub\Endpoint with namespace
includes/class-media.php Renamed from class-micropub-media.php, now \Micropub\Media with namespace
includes/class-render.php Renamed from class-micropub-render.php, now \Micropub\Render with namespace
includes/class-error.php Renamed from class-micropub-error.php, now \Micropub\Error with namespace
includes/functions.php Updated global utility functions with proper namespacing and documentation
includes/compat-functions.php Updated compatibility functions with documentation
tests/*.php Updated all test files with namespaced class references
phpcs.xml Modernized PHPCS configuration with broader exclusions and updated rulesets
templates/*.php Removed orphaned template files that were never implemented
Comments suppressed due to low confidence (1)

includes/class-endpoint.php:1078

  • The function reference 'micropub_get_plugin_version' is being called, but this function no longer exists in the codebase. It was replaced with 'get_plugin_version()' in the namespace. This should be '\Micropub\get_plugin_version()' or use the Micropub class method directly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pfefferle
Copy link
Member Author

@dshanske do you directly call Micropub classes somewhere? do we need to bridge from the old classes to the new ones?

@dshanske
Copy link
Member

dshanske commented Jan 2, 2026

Not that I recall outside of the plugin....

@pfefferle pfefferle self-assigned this Jan 2, 2026
- Add rest/ directory with Endpoint_Controller and Media_Controller
- Controllers extend WP_REST_Controller and use Micropub trait
- Add separate Discovery class for endpoint discovery
- Update Micropub singleton to properly hook into rest_api_init, init, admin_notices
- Add MICROPUB_PLUGIN_VERSION constant
- Remove old Base, Endpoint, and Media classes
Copy link
Member

@dshanske dshanske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very different, but can't see any issue here.

Resolve conflicts:
- .distignore: Combined entries from both branches
- includes/class-micropub-endpoint.php: Keep deleted (replaced by namespaced version)
- includes/class-render.php: Keep namespace prefix, add PHPDoc documentation

Also added PHPDoc documentation to micropub_syndicate-to filter in the
new namespaced endpoint controller.
@pfefferle pfefferle removed the request for review from snarfed January 9, 2026 07:35
@pfefferle pfefferle merged commit a316c1b into trunk Jan 10, 2026
8 checks passed
@pfefferle pfefferle deleted the add-namespaces-and-autoloader branch January 11, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants