How shipwebdotjp/lineconnect works
The LINE Connect project is a WordPress plugin designed to integrate LINE official accounts with your WordPress installation. It provides features like linking WordPress and LINE users, sending post notifications, supporting rich menu tap events, and handling automated messaging based on received messages. The overall architecture splits concerns between backend functionality (core plugin logic, WordPress hooks, and interactions with LINE APIs) and frontend/client-side components (JavaScript assets, styles, and interactive elements).
Main Components
• Plugin Core & Backend:
• WordPress Plugin Hooks: Central integration point with WordPress (activation, deactivation, dashboard settings).
• Core PHP Modules: Located in directories like “include” and “src” (e.g., ActionExecute, ActionFlow, Scenario, and Utilities) which handle actions, admin management, webhook processing, and business logic such as linking users or processing rich menus.
• External API & Event Handling: Components that manage communication with LINE’s messaging/webhook APIs (for rich menu events, notifications and triggers).
• Client-side & Frontend Modules:
• Frontend Directories: Separate “frontend” folders (e.g., “frontend/action-execute”, “line-dm”, “line-bulkmessage”, “line-richmenu”) contain build outputs (JavaScript bundles, CSS assets) for interactive web pages or administrative interfaces.
• JavaScript Components: Built using frameworks like Tailwind, webpack, and react-jsonschema-form (indicating dynamic UI forms and event handling for managing LINE interactions).
• Documentation and Localization:
• Documentation: “docs” and “document” directories include detailed usage, technical guides, and schema definitions.
• i18n / Languages: Localization files (like .po, .json) to support multi-language capabilities for the plugin.
• Testing & CI:
• Tests: A comprehensive “tests” directory which covers backend PHP functionality (unit tests for scenarios, audience, messaging, etc.).
• CI/CD: GitHub workflows in “.github/workflows” for deployment and generating installable zip packages.
Relationships and Interactions
• The Plugin Core interfaces with WordPress via hooks and menu actions and interacts with the frontend assets (e.g., JavaScript components for action execution, rich menu management).
• Incoming events, such as LINE webhooks, are routed to specific PHP modules (e.g., in “include” and “src”) to process messages, update logs, and trigger appropriate notifications.
• Client-side components (bundled in the “frontend” and “line-*” directories) provide the UI for administrators or end users to manage various LINE Connect features. These assets consume backend APIs implemented by the plugin.
• External dependencies (e.g., LINE’s official API endpoints and third-party libraries through Composer for PHP and NPM for front-end code) form part of the communication pipeline.
Architectural Patterns and Design Principles
• Separation of Concerns: Clear separation between the WordPress integration (plugin core), business logic (PHP modules), and user interface (frontend assets and dynamic JS forms).
• Modularization: Each functionality (action execution, action flow, scenario processing, rich menu handling) has its own dedicated module (as seen in the directory names), making it easier to extend or maintain.
• Event-Driven Interactions: Use of webhooks and event logs suggests an event-driven design where events trigger specific code paths.
• Use of Standard Build Tools: Frontend assets are built using webpack, Tailwind CSS, and work with localization & schema-based form generators (react-jsonschema-form).