Skip to content

Added custom taxonomy support and WP migration improvements#1641

Open
55sketch wants to merge 1 commit intomainfrom
wp-improvements
Open

Added custom taxonomy support and WP migration improvements#1641
55sketch wants to merge 1 commit intomainfrom
wp-improvements

Conversation

@55sketch
Copy link
Contributor

  • Added --customTaxonomies flag to wp-api and wp-xml commands to import custom taxonomy terms as Ghost tags
  • Handled custom taxonomies differently per package: wp-api uses wp:term embedded data, wp-xml uses category domain attributes
  • Batched processPosts in wp-api to avoid memory issues on large sites
  • Replaced concat with spread in wp-api fetch for better performance
  • Added Podigee podcast player embed support in wp-api processor
  • Guarded against null/undefined YouTube URLs in mg-utils
  • Added tests for custom taxonomy handling in both wp-api and wp-xml

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

Warning

Rate limit exceeded

@55sketch has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0560f145-c0e5-47ed-b3d3-08aa905c0f95

📥 Commits

Reviewing files that changed from the base of the PR and between ad91373 and 7c9936e.

📒 Files selected for processing (9)
  • packages/mg-utils/src/lib/youtube-utils.ts
  • packages/mg-utils/src/test/youtube-utils.test.ts
  • packages/mg-wp-api/lib/fetch.js
  • packages/mg-wp-api/lib/processor.js
  • packages/mg-wp-api/test/process.test.js
  • packages/mg-wp-xml/lib/process.js
  • packages/mg-wp-xml/test/process.test.js
  • packages/migrate/commands/wp-api.js
  • packages/migrate/commands/wp-xml.js

Walkthrough

Adds support for importing specified WordPress custom taxonomies as Ghost tags by extending processing to accept customTaxonomies (in WP API and WP XML processors) and wiring a new --customTaxonomies CLI option for both migration commands. Updates content processing to replace script.podigee-podcast-player with an iframe card. Changes posts processing to run in sequential batches of 100 and switches array concatenation to in-place push(...response) in fetch logic. Expands YouTube utility to accept null/undefined and return ''. Includes unit tests for custom taxonomies and YouTube behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding custom taxonomy support and various WordPress migration improvements across multiple packages.
Description check ✅ Passed The description is directly related to the changeset, covering custom taxonomy support, performance improvements, podcast player support, and YouTube URL handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wp-improvements
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can validate your CodeRabbit configuration file in your editor.

If your editor has YAML language server, you can enable auto-completion and validation by adding # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json at the top of your CodeRabbit configuration file.

- Added --customTaxonomies flag to wp-api and wp-xml commands to import
  custom taxonomy terms as Ghost tags
- Handled custom taxonomies differently per package: wp-api uses wp:term
  embedded data, wp-xml uses category domain attributes
- Batched processPosts in wp-api to avoid memory issues on large sites
- Replaced concat with spread in wp-api fetch for better performance
- Added Podigee podcast player embed support in wp-api processor
- Guarded against null/undefined YouTube URLs in mg-utils
- Added tests for custom taxonomy handling in both wp-api and wp-xml
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/mg-wp-api/lib/processor.js (1)

133-146: ⚠️ Potential issue | 🟡 Minor

Normalize the custom taxonomy allow-list.

Line 145 is independent from the category/post_tag branches above, so passing either built-in taxonomy here will emit duplicate Ghost tags. Converting the allow-list to an exact-match Set and filtering out the built-ins closes that hole.

Suggested fix
-    const allowedCustomTaxonomies = customTaxonomies || [];
+    const allowedCustomTaxonomies = new Set(
+        (Array.isArray(customTaxonomies) ? customTaxonomies : String(customTaxonomies ?? '').split(','))
+            .map((taxonomy) => taxonomy.trim())
+            .filter(Boolean)
+            .filter((taxonomy) => !['category', 'post_tag'].includes(taxonomy))
+    );
@@
-            if (allowedCustomTaxonomies.includes(term.taxonomy)) {
+            if (allowedCustomTaxonomies.has(term.taxonomy)) {
                 customTerms.push(processTerm(term));
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/mg-wp-api/lib/processor.js` around lines 133 - 146, The current loop
pushes built-in taxonomies twice because allowedCustomTaxonomies is treated as
an array and checked after the category/post_tag branches; change the handling
of allowedCustomTaxonomies to a Set for exact-match lookups and ensure you
explicitly exclude the built-ins ('category' and 'post_tag') before adding to
customTerms: convert customTaxonomies to a Set (e.g.,
allowedCustomTaxonomiesSet) and replace the includes check in the
wpTerms.forEach loop with a Set.has check and an explicit guard that
term.taxonomy !== 'category' && term.taxonomy !== 'post_tag' when deciding to
push processTerm(term) into customTerms.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/mg-wp-api/lib/processor.js`:
- Around line 703-712: The current loop in
parsed.$('script.podigee-podcast-player') interpolates configUrl into a string
(embedHTML) and passes it to replaceWith, which risks breaking markup; instead,
construct a real element tree: read configUrl from
el.getAttribute('data-configuration'), create an iframe element node and set its
src, style, frameborder, and scrolling attributes via the DOM/cheerio API (not
string concatenation), then wrap that iframe node with the surrounding HTML
comment nodes ("<!--kg-card-begin: html-->" and "<!--kg-card-end: html-->") or
their equivalent node types, serialize that node tree to HTML, and pass the
serialized output to replaceWith(el, ...). Use the same identifiers (configUrl,
el, replaceWith) so the change is isolated to this loop.

---

Outside diff comments:
In `@packages/mg-wp-api/lib/processor.js`:
- Around line 133-146: The current loop pushes built-in taxonomies twice because
allowedCustomTaxonomies is treated as an array and checked after the
category/post_tag branches; change the handling of allowedCustomTaxonomies to a
Set for exact-match lookups and ensure you explicitly exclude the built-ins
('category' and 'post_tag') before adding to customTerms: convert
customTaxonomies to a Set (e.g., allowedCustomTaxonomiesSet) and replace the
includes check in the wpTerms.forEach loop with a Set.has check and an explicit
guard that term.taxonomy !== 'category' && term.taxonomy !== 'post_tag' when
deciding to push processTerm(term) into customTerms.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ceb5e0f-ec4f-474b-a115-ef607ac65979

📥 Commits

Reviewing files that changed from the base of the PR and between ed5d340 and ad91373.

📒 Files selected for processing (9)
  • packages/mg-utils/src/lib/youtube-utils.ts
  • packages/mg-utils/src/test/youtube-utils.test.ts
  • packages/mg-wp-api/lib/fetch.js
  • packages/mg-wp-api/lib/processor.js
  • packages/mg-wp-api/test/process.test.js
  • packages/mg-wp-xml/lib/process.js
  • packages/mg-wp-xml/test/process.test.js
  • packages/migrate/commands/wp-api.js
  • packages/migrate/commands/wp-xml.js
✅ Files skipped from review due to trivial changes (5)
  • packages/migrate/commands/wp-xml.js
  • packages/mg-wp-xml/lib/process.js
  • packages/mg-wp-api/lib/fetch.js
  • packages/mg-wp-xml/test/process.test.js
  • packages/mg-wp-api/test/process.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/migrate/commands/wp-api.js
  • packages/mg-utils/src/lib/youtube-utils.ts

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant