Skip to content

Add wp term prune command to remove terms with 0 or 1 published posts#586

Merged
swissspidy merged 6 commits intomainfrom
copilot/prune-terms-with-low-posts
Mar 10, 2026
Merged

Add wp term prune command to remove terms with 0 or 1 published posts#586
swissspidy merged 6 commits intomainfrom
copilot/prune-terms-with-low-posts

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

  • Add prune method to Term_Command class in src/Term_Command.php
  • Update class-level docblock to include prune example
  • Add "term prune" to the commands list in composer.json
  • Create features/term-prune.feature with Behat tests
  • Run linting and code style checks - all pass
  • Run static analysis (PHPStan) - no errors
  • Address code review feedback (removed unreachable else block, renamed variable)
  • Combine the two separate foreach loops over $args into a single loop
  • Remove unused $prunable variable
  • Replace get_terms() + PHP filtering with direct $wpdb->get_col() query for performance
  • Improve false-return warning message for wp_delete_term()
Original prompt

This section details on the original issue you should resolve

<issue_title>Prune terms with one or less published posts</issue_title>
<issue_description>On large sites with thousands of tags or other terms, it would be helpful to have wp term prune to delete terms with one or less published posts.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@swissspidy swissspidy added the command:term Related to 'term' command label Mar 2, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add wp term prune to delete terms with one or less published posts Add wp term prune command to remove terms with 0 or 1 published posts Mar 2, 2026
@swissspidy swissspidy requested a review from Copilot March 2, 2026 16:21
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 2 commits March 2, 2026 17:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as ready for review March 3, 2026 09:20
@swissspidy swissspidy requested a review from a team as a code owner March 3, 2026 09:21
@swissspidy swissspidy added this to the 2.9.0 milestone Mar 10, 2026
@swissspidy

This comment was marked as resolved.

…tter performance

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Term_Command.php 87.50% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy merged commit dda73c9 into main Mar 10, 2026
68 of 69 checks passed
@swissspidy swissspidy deleted the copilot/prune-terms-with-low-posts branch March 10, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:term Related to 'term' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prune terms with one or less published posts

3 participants