Skip to content

Latest commit

 

History

History
139 lines (102 loc) · 5.08 KB

File metadata and controls

139 lines (102 loc) · 5.08 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

eXeLearning is a WordPress plugin for managing eXeLearning .elp files. It allows uploading, extracting, and embedding eXeLearning content in WordPress pages and posts.

Key principle: The plugin works directly with WordPress attachments (Media Library). No custom post type is needed - ELP files are uploaded as attachments and their metadata is stored in attachment post meta.

Development Commands

Static Editor Build

make build-editor          # Build static eXeLearning editor from submodule (requires Bun)
make build-editor-no-update # Build without updating submodule (for CI/CD)
make update-submodule      # Update eXeLearning submodule to correct branch
make clean-editor          # Remove static editor build and node_modules

Note: The static editor is built from the exelearning/ submodule (branch release/3.1-embedable-version-refactor). Output is placed in dist/static/.

Environment Setup

make up                    # Start wp-env Docker containers (http://localhost:8888, admin/password)
make down                  # Stop containers
make clean                 # Reset WordPress environment
make destroy               # Completely remove wp-env

Testing

make test                  # Run all PHPUnit tests
make test FILTER=MyTest    # Run tests matching pattern

Code Quality

make fix                   # Auto-fix code style with PHPCBF
make lint                  # Check code style with PHPCS

Translations

make pot                   # Generate .pot file
make po                    # Update .po files
make mo                    # Generate .mo files

Architecture

How It Works

  1. User uploads .elp file to Media Library
  2. Plugin validates the file using ElpParser
  3. File is extracted to wp-content/uploads/exelearning/{sha1_hash}/
  4. Metadata from ELP is stored in attachment post meta
  5. Content is embedded via shortcode or Gutenberg block

Core Components

  • exelearning.php: Main plugin file
  • includes/class-exelearning.php: Core class that initializes all components
  • includes/class-hooks.php: WordPress action registration
  • includes/class-filters.php: WordPress filter registration

ELP File Handling

  • includes/class-elp-upload-handler.php: Handles ELP file upload and extraction
  • includes/class-elp-file-service.php: Validates, parses, and extracts ELP files (inline ZipArchive + SimpleXML)
  • includes/class-elp-upload-block.php: Gutenberg block for embedding ELP content
  • includes/class-mime-types.php: Registers .elp MIME type for WordPress uploads

Admin

  • admin/class-admin-settings.php: Settings page
  • admin/class-admin-upload.php: Admin upload handler

Public/Frontend

  • public/class-shortcodes.php: [exelearning] shortcode handler
  • includes/integrations/class-media-library.php: Media library integration (columns, meta boxes)

Data Storage

ELP files use WordPress attachments. Metadata is stored in post meta:

Meta Key Description
_exelearning_title Title from ELP file
_exelearning_description Description from ELP file
_exelearning_license License information
_exelearning_language Content language
_exelearning_resource_type Learning resource type
_exelearning_extracted SHA1 hash pointing to extraction folder

File Storage

When an ELP file is uploaded:

  1. Original .elp file stored in Media Library
  2. Extracted to wp-content/uploads/exelearning/{sha1_hash}/
  3. Content accessible via index.html in extraction folder

Embedded Editor

The plugin includes a fully embedded eXeLearning editor built from the static PWA version.

Key Files

  • dist/static/: Static build of eXeLearning editor (generated by make build-editor)
  • admin/views/editor-bootstrap.php: Loads static editor with WordPress configuration
  • assets/js/wp-exe-bridge.js: Bridge JavaScript connecting editor with WordPress
  • includes/class-exelearning-rest-api.php: REST endpoints for saving/creating ELP files

How the Editor Works

  1. User clicks "Edit in eXeLearning" on an attachment
  2. Plugin loads dist/static/index.html and injects WordPress config
  3. Bridge JS (wp-exe-bridge.js) handles:
    • Loading ELP file from WordPress into editor
    • Saving edited content back to WordPress via REST API
    • Keyboard shortcuts (Ctrl+S to save)
  4. Editor runs 100% client-side (static PWA)

REST API Endpoints

Endpoint Method Description
/exelearning/v1/save/{id} POST Update existing ELP file
/exelearning/v1/create POST Create new ELP file
/exelearning/v1/elp-data/{id} GET Get ELP file metadata

Key Patterns

  • WordPress Coding Standards enforced via PHPCS
  • Tests run inside wp-env container
  • ELP files are ZIP archives with XML metadata
  • No custom post type - uses WordPress attachments
  • Static editor (PWA) runs client-side, no backend required