|
| 1 | +# Agent Workflow |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +**Revive Old Posts (Revive Social)** — a WordPress plugin that automatically shares WordPress posts to social networks (Facebook, X/Twitter, LinkedIn, Instagram, Telegram, Mastodon, BlueSky, VK, Pinterest, TikTok, etc.) with scheduling and automation. |
| 6 | + |
| 7 | +- **Text Domain:** `tweet-old-post` |
| 8 | +- **Main Plugin File:** `tweet-old-post.php` |
| 9 | +- **Pro Companion Plugin:** `tweet-old-post-pro` (separate repo) |
| 10 | + |
| 11 | +## Build & Development Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +# Install dependencies |
| 15 | +npm ci |
| 16 | +composer install |
| 17 | + |
| 18 | +# Build assets (Vue dashboard + React sharing panel) |
| 19 | +npm run build # Production webpack build (Vue) |
| 20 | +npm run sharing # Production wp-scripts build (React) |
| 21 | + |
| 22 | +# Development with watch |
| 23 | +npm run dev # Webpack watch mode (Vue) |
| 24 | +npm run sharing-dev # wp-scripts dev mode (React) |
| 25 | + |
| 26 | +# Linting |
| 27 | +composer run lint # PHPCS (WordPress-Core standard) |
| 28 | +composer run format # Auto-fix PHP code style |
| 29 | +npm run lint # ESLint for Vue + React files |
| 30 | +npm run format # ESLint auto-fix |
| 31 | + |
| 32 | +# Testing |
| 33 | +composer run test # PHPUnit (all suites) |
| 34 | +./vendor/bin/phpunit tests/test-content.php # Single test file |
| 35 | +composer run phpstan # Static analysis (level 6) |
| 36 | + |
| 37 | +# E2E Testing (requires wp-env) |
| 38 | +npm run wp-env start # Start WordPress environment |
| 39 | +npm run test:e2e:playwright # Run Playwright E2E tests |
| 40 | +npm run test:e2e:playwright:ui # E2E with Playwright UI mode |
| 41 | + |
| 42 | +# Distribution |
| 43 | +npm run dist # Create distribution ZIP archive |
| 44 | +``` |
| 45 | + |
| 46 | +## Architecture |
| 47 | + |
| 48 | +### Entry Point & Autoloading |
| 49 | + |
| 50 | +`tweet-old-post.php` defines constants (prefixed `ROP_`), registers activation/deactivation hooks, sets up a custom autoloader (`class-rop-autoloader.php`), and calls `run_rop()` which instantiates the `Rop` core class. |
| 51 | + |
| 52 | +The autoloader scans `includes/` recursively, matching classes by the `Rop` namespace prefix. Class files follow the convention `class-{slug-case-name}.php`. |
| 53 | + |
| 54 | +### Core Class Hierarchy |
| 55 | + |
| 56 | +- **`Rop`** (`includes/class-rop.php`) — Core plugin class. Loads dependencies, sets up i18n, defines admin hooks. |
| 57 | +- **`Rop_Loader`** (`includes/class-rop-loader.php`) — Central hook registration system. Actions/filters are queued then bulk-registered. |
| 58 | +- **`Rop_Admin`** (`includes/admin/class-rop-admin.php`) — Admin UI, script/style enqueuing, menu registration. ~2,000 lines. |
| 59 | +- **`Rop_Rest_Api`** (`includes/admin/class-rop-rest-api.php`) — REST endpoints at `tweet-old-post/v8/api` and `tweet-old-post/v8/share/{id}`. Requires `manage_options` capability. ~1,700 lines. |
| 60 | + |
| 61 | +### Service Layer (Social Networks) |
| 62 | + |
| 63 | +`includes/admin/services/` — Each social network has a service class extending `Rop_Services_Abstract` (Strategy pattern): |
| 64 | +- Key methods: `get_service_credentials()`, `login()`, `publish()`, `get_account()` |
| 65 | +- Services: Twitter, Facebook, LinkedIn, Mastodon, BlueSky, Telegram, VK, Pinterest, Tumblr, GMB, Webhook |
| 66 | + |
| 67 | +### Models (Data Layer) |
| 68 | + |
| 69 | +`includes/admin/models/` — Settings, services, queue, scheduler, post format, post selector, URL shorteners. Models store data in WordPress options. |
| 70 | + |
| 71 | +### Helpers |
| 72 | + |
| 73 | +`includes/admin/helpers/` — Content manipulation, post formatting, cron scheduling, DB migrations, logging, custom API clients (Telegram, BlueSky). |
| 74 | + |
| 75 | +### URL Shorteners |
| 76 | + |
| 77 | +`includes/admin/shortners/` — Each shortener extends `Rop_Url_Shortner_Abstract` (Bitly, Firebase, Rebrandly, is.gd, ow.ly, rviv.ly). |
| 78 | + |
| 79 | +### Frontend (Two Systems) |
| 80 | + |
| 81 | +1. **Vue 2 Dashboard** (legacy) — Built via `webpack.config.js`. Entry points in `vue/src/` → output to `assets/js/build/`. Uses Vuex for state, vue-resource for HTTP. |
| 82 | +2. **React Components** (new) — Built via `webpack.sharing.config.js` using `@wordpress/scripts`. Source in `src/` → output to `assets/js/react/build/`. Used for instant/manual sharing in the block editor. |
| 83 | + |
| 84 | +### Cron System |
| 85 | + |
| 86 | +`cron-system/` — Alternative remote cron implementation (`RopCronSystem\Rop_Cron_Core`). Activated when `ROP_CRON_ALTERNATIVE` is true (controlled by `rop_use_remote_cron` option). |
| 87 | + |
| 88 | +### External Auth |
| 89 | + |
| 90 | +Social network authentication goes through `ROP_AUTH_APP_URL` (`https://app.revive.social`) with per-service paths (`/fb_auth`, `/tw_auth`, `/li_auth`, etc.). |
| 91 | + |
| 92 | +## Coding Standards |
| 93 | + |
| 94 | +- **PHP:** WordPress-Core via PHPCS (`phpcs.xml`) with many naming convention rules relaxed — camelCase variables/methods are allowed throughout the codebase |
| 95 | +- **JS (Vue):** `plugin:vue/recommended` with babel-eslint parser |
| 96 | +- **JS (React):** `@wordpress/eslint-plugin/recommended` with text domain enforced as `tweet-old-post` |
| 97 | +- **Static Analysis:** PHPStan level 6 with WordPress extension and baseline (`phpstan-baseline.neon`) |
| 98 | + |
| 99 | +## Testing Structure |
| 100 | + |
| 101 | +PHPUnit test suites are defined in `phpunit.xml` with individual files in `tests/`: |
| 102 | +- `test-plugin.php`, `test-accounts.php`, `test-content.php`, `test-logger.php`, `test-post-format.php`, `test-queue.php`, `test-scheduler.php`, `test-selector.php` |
| 103 | + |
| 104 | +E2E tests use Playwright with `@wordpress/e2e-test-utils-playwright`. Specs live in `tests/e2e/specs/`. Config at `tests/e2e/playwright.config.js`. |
| 105 | + |
| 106 | +PHPUnit bootstrap (`tests/bootstrap.php`) requires WordPress test suite via `WP_TESTS_DIR` env var. |
0 commit comments