How automattic/wp-job-manager works
Project Type and Purpose
• This is a WordPress plugin (“WP Job Manager”) that extends WordPress with a lightweight, shortcode-based job-board.
• It registers a custom post type (job_listing), renders frontend job listings via templates and shortcodes, provides admin screens, REST/API endpoints, AJAX handlers, and integrates with third-party plugins (SEO, multilingual, WP Import, etc.).
File Structure
Top-level directories and their roles:
• assets/ → CSS, JS, images, fonts, and third-party JS/CSS libraries
• includes/ → PHP source organized by feature (abstracts, admin, API, forms, emails, helpers, promoted-jobs, UI, widgets)
• templates/ → PHP template overrides for frontend display and email HTML/plain templates
• docs/ → API docs
• tests/ → PHPUnit and JS test suites
• scripts/ → release scripts, build-plugin, CI helpers
• composer.json, package.json, webpack.config.js → dependency, build, and lint configurations
README Insights
• Confirms: shortcode-based, lightweight, plugin for any WP theme
• Points to external docs for API and add-ons
a. Main Components
• WordPress Core
• WP Job Manager Plugin
– Frontend Rendering (shortcodes, templates, asset enqueues)
– Data Layer (custom post type registration, DB reads/writes via WPDB)
– AJAX & REST API Module (class-wp-job-manager-ajax.php, class-wp-job-manager-rest-api.php)
– Email Module (classes under includes/emails + templates/emails)
– Promoted Jobs Add-on Module
– Helpers & Utilities (nonce, caching, geocoding, stats tracking)
• Database (MySQL via WPDB)
• Third-Party Integrations (SEO, WPML, Jetpack, etc. via includes/3rd-party)
• Build & CI Tools (Composer, npm/Webpack, GitHub Actions, Psalm, PHPUnit)
b. Relationships and Interactions
• WordPress Core ↔ Plugin: plugin hooks into init, wp_enqueue_scripts, admin_menu, REST API hooks
• Admin UI ↔ Database: create/update plugin options, CPT settings, taxonomy metadata
• Shortcodes & Templates ↔ Database: query job_listing posts, render HTML
• AJAX & REST API ↔ Frontend JS: job submission, filtering, stats; data serialized to/from JSON
• Email Module ↔ WP_Mail: triggers on post status changes, uses templates to build content
• Promoted Jobs Module ↔ Plugin Core: extends job_listing, schedules status changes, notifications
• Helpers ↔ All Modules: nonce verification, caching, stats collection, geocoding calls
• Build Tools ↔ Source: transpile/bundle JS, compile SCSS to CSS, run static analysis/tests
c. Architectural Patterns & Principles
• Modular plugin structure: split by feature area under includes/
• Hook-based extensibility via WP actions/filters
• Separation of concerns: Admin vs Frontend vs API vs Data
• Template-override model: fallback templates in plugin, overridable in theme
• PSR-4 autoloading (via composer) for PHP classes
d. Key Technologies/Frameworks
• PHP 7+; WordPress Plugin API (actions, filters, shortcodes, REST API)
• JavaScript (ES6) with Webpack, jQuery, third-party libs (chosen, fileupload, select2)
• SCSS for CSS, built via webpack or npm scripts
• PHPUnit for PHP tests, Jest or similar for JS tests
• GitHub Actions for CI, Psalm for static analysis