Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cursor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN printf '%s\n' \
'export WP_TESTS_DB_USER=root' \
'export WP_TESTS_DB_PASSWORD=root' \
'export WP_TESTS_DB_HOST=127.0.0.1' \
> /etc/profile.d/fqj-wp-tests-db.sh
> /etc/profile.d/rfsd-wp-tests-db.sh

RUN echo 'ubuntu ALL=(ALL) NOPASSWD: /usr/sbin/service mariadb *' > /etc/sudoers.d/mariadb \
&& chmod 440 /etc/sudoers.d/mariadb
Expand Down
4 changes: 2 additions & 2 deletions .cursor/cloud-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

if [[ ! -f /etc/profile.d/fqj-wp-tests-db.sh ]]; then
sudo tee /etc/profile.d/fqj-wp-tests-db.sh >/dev/null <<'EOF'
if [[ ! -f /etc/profile.d/rfsd-wp-tests-db.sh ]]; then
sudo tee /etc/profile.d/rfsd-wp-tests-db.sh >/dev/null <<'EOF'
export WP_TESTS_DB_NAME=wordpress_test
export WP_TESTS_DB_USER=root
export WP_TESTS_DB_PASSWORD=root
Expand Down
2 changes: 1 addition & 1 deletion .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "FAQ JSON-LD WordPress Plugin",
"name": "Renderbit FAQ Structured Data WordPress Plugin",
"build": {
"dockerfile": "Dockerfile",
"context": "."
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Bug Report
description: Report a bug or issue with the FAQ JSON-LD Manager plugin
description: Report a bug or issue with the Renderbit FAQ Structured Data plugin
title: "[Bug]: "
labels: ["bug"]
body:
Expand All @@ -12,7 +12,7 @@ body:
id: version
attributes:
label: Plugin Version
description: What version of FAQ JSON-LD Manager are you using?
description: What version of Renderbit FAQ Structured Data are you using?
placeholder: e.g., 3.0.0
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Feature Request
description: Suggest a new feature or improvement for the FAQ JSON-LD Manager plugin
description: Suggest a new feature or improvement for the Renderbit FAQ Structured Data plugin
title: "[Feature]: "
labels: ["enhancement"]
body:
Expand Down
22 changes: 11 additions & 11 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Copilot Instructions for FAQ JSON-LD WordPress Plugin
# Copilot Instructions for Renderbit FAQ Structured Data WordPress Plugin

## Overview

This plugin manages FAQ items as a custom post type (CPT) and injects FAQ JSON-LD into WordPress posts/pages. It uses a custom mapping table for fast lookups, per-post transient caching, a background invalidation queue (via WP-Cron), a settings UI, and WP-CLI tools for advanced management.

## Architecture & Key Components

- **Custom Post Type:** `faq_item` is registered for FAQ entries.
- **Mapping Table:** MySQL table (`fqj_mappings`) links FAQ items to posts, post types, terms, URLs, or global context. See `includes/indexer.php`.
- **Custom Post Type:** `rfsd_faq` is registered for FAQ entries.
- **Mapping Table:** MySQL table (`rfsd_mappings`) links FAQ items to posts, post types, terms, URLs, or global context. See `includes/indexer.php`.
- **JSON-LD Output:** Injected on the frontend using `includes/frontend.php`, with per-post transient caching for performance.
- **Cache Invalidation:** Uses a background queue (`includes/queue.php`) processed by WP-Cron or WP-CLI. Queue state and logs are visible in the Health admin page.
- **Admin UI:** Custom meta boxes and settings in `includes/admin.php` and `includes/settings.php`. Select2 (bundled in `assets/vendor/select2`) is used for post selectors (see `assets/js/fqj-admin.js`).
- **Admin UI:** Custom meta boxes and settings in `includes/admin.php` and `includes/settings.php`. Select2 (bundled in `assets/vendor/select2`) is used for post selectors (see `assets/js/rfsd-admin.js`).
- **Health & Diagnostics:** Admin page (`includes/health.php`) shows queue status, logs, and provides manual actions.
- **WP-CLI Integration:** `includes/class-fqjcli.php` provides commands for purging transients, processing the invalidation queue and showing its length.
- **WP-CLI Integration:** `includes/class-rfsd-cli.php` provides commands for purging transients, processing the invalidation queue and showing its length.

## Developer Workflows

- **Activate/Upgrade:** On plugin activation, the mapping table is created/updated automatically.
- **Settings:** Accessible under the FAQ Items menu. Options include cache TTL, batch size, and output type.
- **Cache Management:**
- Manual: Use Health admin page or WP-CLI (`wp fqj purge-transients`, `wp fqj process-queue [--limit=N]`, `wp fqj queue-info`).
- Manual: Use Health admin page or WP-CLI (`wp rfsd purge-transients`, `wp rfsd process-queue [--limit=N]`, `wp rfsd queue-info`).
- Automatic: Invalidation queue is processed every 5 minutes by WP-Cron.
- **Debugging:**
- Check the Health admin page for queue/logs.
Expand All @@ -28,8 +28,8 @@ This plugin manages FAQ items as a custom post type (CPT) and injects FAQ JSON-L
## Project-Specific Patterns

- **Mapping Structure:** All associations (post, post_type, term, url, global) are stored in a single table for fast lookups.
- **Transient Keys:** Format is `fqj_faq_json_{generation}_{post_id}`; always build it with `fqj_cache_key( $post_id )`. The mapping table name comes from `fqj_table_name()`.
- **Admin JS:** Uses Select2 for post selectors, AJAX for search (`fqj_search_posts` action).
- **Transient Keys:** Format is `rfsd_faq_json_{generation}_{post_id}`; always build it with `rfsd_cache_key( $post_id )`. The mapping table name comes from `rfsd_table_name()`.
- **Admin JS:** Uses Select2 for post selectors, AJAX for search (`rfsd_search_posts` action).
- **Settings/Health Pages:** Registered as submenus under the FAQ Items CPT.

## Integration Points
Expand All @@ -40,15 +40,15 @@ This plugin manages FAQ items as a custom post type (CPT) and injects FAQ JSON-L

## Key Files

- `faq-jsonld.php`: Main plugin loader and CPT registration.
- `renderbit-faq-structured-data.php`: Main plugin loader and CPT registration.
- `includes/indexer.php`: Mapping table logic.
- `includes/queue.php`: Invalidation queue logic.
- `includes/frontend.php`: JSON-LD output and caching.
- `includes/admin.php`: Admin UI/meta boxes.
- `includes/settings.php`: Settings page.
- `includes/health.php`: Health/diagnostics UI.
- `includes/class-fqjcli.php`: WP-CLI commands.
- `assets/js/fqj-admin.js`, `assets/js/fqj-health.js`: Admin JS (Select2, AJAX).
- `includes/class-rfsd-cli.php`: WP-CLI commands.
- `assets/js/rfsd-admin.js`, `assets/js/rfsd-health.js`: Admin JS (Select2, AJAX).

## Example: Adding a New Mapping Type

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-wporg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
run: |
tag="${GITHUB_REF#refs/tags/}"
tag="${tag#v}"
header="$(sed -n 's/^ \* Version: *//p' faq-jsonld.php)"
constant="$(sed -n "s/^define( 'FQJ_VERSION', '\(.*\)' );$/\1/p" faq-jsonld.php)"
header="$(sed -n 's/^ \* Version: *//p' renderbit-faq-structured-data.php)"
constant="$(sed -n "s/^define( 'RFSD_VERSION', '\(.*\)' );$/\1/p" renderbit-faq-structured-data.php)"
stable="$(sed -n 's/^Stable tag: *//p' readme.txt)"
echo "tag=$tag header=$header FQJ_VERSION=$constant stable=$stable"
echo "tag=$tag header=$header RFSD_VERSION=$constant stable=$stable"
[ "$tag" = "$header" ] && [ "$tag" = "$constant" ] && [ "$tag" = "$stable" ]

- name: Deploy to WordPress.org SVN
uses: 10up/action-wordpress-plugin-deploy@54bd289b8525fd23a5c365ec369185f2966529c2 # 2.3.0
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: faq-jsonld
SLUG: renderbit-faq-structured-data
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ jobs:
name: Release ${{ env.TAG_NAME }}
draft: true
generate_release_notes: true
files: faq-jsonld.zip
files: renderbit-faq-structured-data.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
tools: none

- name: Lint plugin files
run: find faq-jsonld.php uninstall.php includes -name '*.php' -print0 | xargs -0 -n1 php -l
run: find renderbit-faq-structured-data.php uninstall.php includes -name '*.php' -print0 | xargs -0 -n1 php -l

phpcs:
name: Coding standards
Expand All @@ -59,12 +59,12 @@ jobs:

# Check what ships (the git archive, as in the release zip and WordPress.org SVN), not the dev files.
- name: Export plugin files
run: mkdir -p build/faq-jsonld && git archive HEAD | tar -x -C build/faq-jsonld
run: mkdir -p build/renderbit-faq-structured-data && git archive HEAD | tar -x -C build/renderbit-faq-structured-data

- uses: WordPress/plugin-check-action@10857da14b6c2246d15402b3e69f777edcf8c12e # v1.1.9
with:
build-dir: build/faq-jsonld
slug: faq-jsonld
build-dir: build/renderbit-faq-structured-data
slug: renderbit-faq-structured-data
strict: true

phpunit:
Expand Down
14 changes: 7 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# AGENTS.md

WordPress plugin `faq-jsonld`: FAQs as a `faq_item` CPT, schema.org `FAQPage` JSON-LD printed on singular posts/pages. Procedural PHP, every function prefixed `fqj_`, no build step, no runtime Composer deps.
WordPress plugin `renderbit-faq-structured-data`: FAQs as a `rfsd_faq` CPT (`RFSD_POST_TYPE`; FAQs from the old `faq-jsonld` plugin are imported on activation), schema.org `FAQPage` JSON-LD printed on singular posts/pages. Procedural PHP, every function prefixed `rfsd_`, no build step, no runtime Composer deps.

**PHP ceiling is 7.2 for shipped code** — `composer.json` pins platform 7.4, so syntax up to 7.4 passes locally while CI's `php -l` matrix (7.2–8.4) fails. Write 7.2-compatible syntax in `faq-jsonld.php`, `uninstall.php`, `includes/`.
**PHP ceiling is 7.2 for shipped code** — `composer.json` pins platform 7.4, so syntax up to 7.4 passes locally while CI's `php -l` matrix (7.2–8.4) fails. Write 7.2-compatible syntax in `renderbit-faq-structured-data.php`, `uninstall.php`, `includes/`.

Full architecture, data flow (save → index → render → invalidate), and versioning rules live in `CLAUDE.md` — read its Architecture section before touching `includes/indexer.php`, `includes/queue.php`, `includes/frontend.php`, or cache keys. Keep `CLAUDE.md` in sync if you change behavior it describes.

Expand All @@ -11,13 +11,13 @@ Full architecture, data flow (save → index → render → invalidate), and ver
```bash
composer install && npm install # setup; .env.testing must exist (copy .env.testing.example)

composer lint # phpcs, WordPress Coding Standards, text domain faq-jsonld
composer lint # phpcs, WordPress Coding Standards, text domain renderbit-faq-structured-data
composer test # PHPUnit, single-site
composer test:multisite # same suite as a multisite network
vendor/bin/phpunit --filter test_name # one test
vendor/bin/phpunit tests/php/test-queue.php # one file
npm test # Jest (jsdom) for assets/js
npx jest tests/js/fqj-admin.test.js -t "name" # one JS test
npx jest tests/js/rfsd-admin.test.js -t "name" # one JS test
```

CI (`.github/workflows/tests.yml`) runs all of the above plus `WordPress/plugin-check` on every PR. Verify with `composer lint && composer test && npm test` before claiming done.
Expand All @@ -29,6 +29,6 @@ CI (`.github/workflows/tests.yml`) runs all of the above plus `WordPress/plugin-
- Test groups: network-only tests are tagged `@group ms-required`, single-site-only `@group ms-excluded`; each phpunit config excludes the other group, so a test in neither group runs twice and one in both runs never.
- `composer build-zip` runs `git archive HEAD` — **uncommitted changes are not in the zip**. `composer check-zip` verifies contents against `.gitattributes` `export-ignore`, which also decides what ships to WordPress.org SVN. Add new dev-only files there.
- Raw `$wpdb` queries use `%i` for table identifiers and carry targeted `phpcs:ignore`/`phpcs:disable … phpcs:enable` comments naming the specific sniffs — keep this pattern so `composer lint` stays clean.
- Two independent version constants: bump `FQJ_DB_VERSION` only when `CREATE TABLE` SQL in `fqj_create_table()` changes (dbDelta rules: no `IF NOT EXISTS`, two spaces after `PRIMARY KEY`, `KEY` not `INDEX`, no inline comments); bump `FQJ_DATA_VERSION` only to force a one-time reindex + cache purge.
- Transient keys are always built with `fqj_cache_key( $post_id )` (embeds `fqj_cache_gen`) — never hand-build `fqj_faq_json_*` keys, or purge-all breaks with a persistent object cache.
- Releasing: `composer bump-patch|minor|major` keeps four version strings in sync (`composer.json`, plugin header, `FQJ_VERSION`, `readme.txt` Stable tag); add the `readme.txt` changelog entry by hand. Pushing a `vX.Y.Z` tag to `main` creates a draft release; publishing it deploys to WordPress.org SVN.
- Two independent version constants: bump `RFSD_DB_VERSION` only when `CREATE TABLE` SQL in `rfsd_create_table()` changes (dbDelta rules: no `IF NOT EXISTS`, two spaces after `PRIMARY KEY`, `KEY` not `INDEX`, no inline comments); bump `RFSD_DATA_VERSION` only to force a one-time reindex + cache purge.
- Transient keys are always built with `rfsd_cache_key( $post_id )` (embeds `rfsd_cache_gen`) — never hand-build `rfsd_faq_json_*` keys, or purge-all breaks with a persistent object cache.
- Releasing: `composer bump-patch|minor|major` keeps four version strings in sync (`composer.json`, plugin header, `RFSD_VERSION`, `readme.txt` Stable tag); add the `readme.txt` changelog entry by hand. Pushing a `vX.Y.Z` tag to `main` creates a draft release; publishing it deploys to WordPress.org SVN.
Loading
Loading