Skip to content

Add [ClassicPress] badge - #12097

Open
KesleyDavid wants to merge 7 commits into
badges:masterfrom
KesleyDavid:badge/classicpress-6814
Open

Add [ClassicPress] badge#12097
KesleyDavid wants to merge 7 commits into
badges:masterfrom
KesleyDavid:badge/classicpress-6814

Conversation

@KesleyDavid

Copy link
Copy Markdown
Contributor

Fixes #6814

Adds ClassicPress badges, following the existing WordPress badge pattern:

  • /classicpress/plugin/cp-version/:slug
  • /classicpress/theme/cp-version/:slug
  • /classicpress/plugin/required-php/:slug
  • /classicpress/theme/required-php/:slug

API used

The endpoint originally proposed in the issue (https://directory.classicpress.net/api/plugins/) no longer exists. These badges use the current, documented ClassicPress Directory API:

  • https://directory.classicpress.net/wp-json/wp/v2/plugins/?byslug={slug}
  • https://directory.classicpress.net/wp-json/wp/v2/themes/?byslug={slug}

Docs: https://docs.classicpress.net/developer-guides/classicpress-directory-api/

The response is an array (empty for unknown slugs) whose items carry a meta object with current_version, requires_cp and requires_php.

Note: the issue also requested /classicpress/plugin/tested/:slug, but the directory API does not expose a "tested up to" field, so that badge is not included.

How tested

  • npm run test:services -- --only=classicpress — 9 passing (live tests against the real directory API + nock-mocked tests for not-found / not-set cases)
  • npx eslint services/classicpress/**/*.js — clean
  • Prettier — clean
  • Smoke-rendered locally with npm run badge -- /classicpress/plugin/cp-version/switch-to-classicpressclassicpress | v1.7

Drafted with AI assistance; reviewed by me (KesleyDavid).

@KesleyDavid KesleyDavid changed the title Add ClassicPress badge Add [ClassicPress] badge Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 ✨ Thanks for your contribution to Shields, @KesleyDavid!

Generated by 🚫 dangerJS against bf0456f

@PyvesB

PyvesB commented Aug 9, 2026

Copy link
Copy Markdown
Member

Hello @KesleyDavid 👋🏻

Do you have any information on the API rate limits? Are these API endpoints intended for public use (turned out that some of the WordPress equivalents were not)?

@KesleyDavid

Copy link
Copy Markdown
Contributor Author

Hi @PyvesB — thanks for the heads-up, and for the pointer to #7356. That WordPress situation is exactly the kind of thing I wanted to double-check before this moved further.

I went through the ClassicPress side of things:

Public use: These endpoints are covered in their official developer guide (ClassicPress Directory API), including a walkthrough for consuming them with wp_remote_get. That reads as intentional public integration, unlike the WordPress.org APIs that turned out to be internal-only.

Rate limits: I couldn’t find any documented quotas, and the live responses don’t send rate-limit headers either. So there’s no hard number I can point at — just the assumption that we should be careful with how often we hit them.

With that in mind I pushed a small follow-up on this branch:

  1. Cache bumped to 1 hour (_cacheLength = 3600). requires_cp / requires_php only change when a plugin or theme ships a release, so the default 5‑minute platform-support cache felt heavier than needed.
  2. Requests only ask for meta (_fields=meta), which the directory accepts and cuts the payload down a lot versus the full post body.
  3. OpenAPI description now notes the public docs and the longer cache, so that context shows up in the badge builder as well.

Tests still pass (npm run test:services -- --only=classicpress — 9 green, including live hits).

If you’d rather we get an explicit okay from ClassicPress on third-party use before merging, I’m happy to open that conversation. Otherwise this should be in better shape on the load side.

@KesleyDavid
KesleyDavid force-pushed the badge/classicpress-6814 branch from 6ad7efe to b710f00 Compare August 10, 2026 13:29
@PyvesB

PyvesB commented Aug 11, 2026

Copy link
Copy Markdown
Member

Cache bumped to 1 hour (_cacheLength = 3600). requires_cp / requires_php only change when a plugin or theme ships a release, so the default 5‑minute platform-support cache felt heavier than needed.
OpenAPI description now notes the public docs and the longer cache, so that context shows up in the badge builder as well.

I think it's fine to keep the default cache until we hypothetically run into a problem. Can you please revert those changes back? The "Requests only ask for meta" change does seem useful, let's keep that one.

@PyvesB PyvesB added the service-badge New or updated service badge label Aug 11, 2026
Follow maintainer feedback: drop the 1h _cacheLength override and
OpenAPI description about longer caching so platform-support defaults
apply. Keep _fields=meta to reduce Directory API payload size.
@KesleyDavid

Copy link
Copy Markdown
Contributor Author

Hi @PyvesB — thanks for the guidance, really appreciate the careful review (and the call to keep things simple until there's a real load problem).

I applied your feedback:

  1. Reverted the custom 1h _cacheLength so the default platform-support cache applies again.
  2. Reverted the OpenAPI description that mentioned longer caching / public-docs notes tied to that change.
  3. Kept _fields=meta on Directory API requests (and the matching test query params).

Also merged latest master into this branch (no force-push) so review should be straightforward.

Happy to adjust further if anything else stands out.

message: 'not set for this plugin',
})

t.create('Plugin Required CP Version | Not Found')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please switch all not found tests to live ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

service-badge New or updated service badge

Development

Successfully merging this pull request may close these issues.

Badge Request : ClassicPress

2 participants