Skip to content

Add wp theme cache command#494

Open
Copilot wants to merge 7 commits intomainfrom
copilot/add-wp-theme-cache-command
Open

Add wp theme cache command#494
Copilot wants to merge 7 commits intomainfrom
copilot/add-wp-theme-cache-command

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Adds wp theme cache command with clear and flush subcommands for managing theme cache.

Implementation

New command class: Theme_Cache_Command

  • clear [<theme>...] [--all] - Clears cache for specified themes or all themes
  • flush - Flushes entire 'themes' cache group

Uses public wp_cache_delete() and wp_cache_flush_group() functions, avoiding private WP_Theme cache methods. Cache key logic mirrors existing Theme_Command::install() implementation:

$cache_hash = md5( $theme->get_theme_root() . '/' . $theme->get_stylesheet() );
foreach ( [ 'theme', 'screenshot', 'headers', 'page_templates' ] as $key ) {
    wp_cache_delete( $key . '-' . $cache_hash, 'themes' );
}

Changes

  • src/Theme_Cache_Command.php - New command class
  • extension-command.php - Register theme cache command
  • phpcs.xml.dist - Exclude Theme_Cache_ from prefix rule
  • composer.json - Add commands to extras list
  • features/theme-cache.feature - Behat test coverage

Usage

# Clear cache for specific theme
wp theme cache clear twentytwentyfour

# Clear cache for multiple themes  
wp theme cache clear twentytwentythree twentytwentyfour

# Clear all theme caches
wp theme cache clear --all

# Flush entire theme cache group
wp theme cache flush

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.wordpress.org
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)
    • Triggering command: /usr/bin/curl curl -s REDACTED sudo mman�� nload-cache&#39;/* &#39;/tmp/wp-cli-test-run--6980ade84aca03.98801656/&#39; (dns block)
  • developer.wordpress.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • downloads.wordpress.org
    • Triggering command: /usr/bin/curl curl -sSfL REDACTED (dns block)
    • Triggering command: /usr/bin/curl curl -sSfL REDACTED php vend�� -suite-cache--6980ade805c1d7.49180655 analyse /usr/local/bin/which ag=Off&#39; &#39;-d errols (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add wp theme cache command</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing

Add the following commands

wp theme cache <theme> get <key> 
wp theme cache <theme> add <key> <data>
wp theme cache <theme> delete

Describe the solution you'd like

Add command would map to the method cache_add on WP_Theme class.
Get command would map to the method cache_get on WP_Theme class.
Delete command would map to the method cache_delete on WP_Theme class.

This would help manage and clear theme related caches.

</issue_description>

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

@danielbachhuber I amenable to this. Feel free to submit a pull request, if you'd like. Here is some [guidance on our pull request best practices](https://make.wordpress.org/cli/handbook/contributions/pull-requests/). @swissspidy `WP_Theme::cache_add()` and `WP_Theme::cache_get()` are private, so we can't really use these.

The delete method is public, but maybe this could be used via wp cache delete and wp cache flush-group? The cache key property itself is also private though, so we can't really access it.</comment_new>


💡 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.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@github-actions github-actions bot added command:theme Related to 'theme' command scope:distribution Related to distribution state:unconfirmed labels Feb 2, 2026
Copilot AI changed the title [WIP] Add wp theme cache command functionality Add wp theme cache command Feb 2, 2026
Copilot AI requested a review from swissspidy February 2, 2026 14:05
@codecov

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review February 4, 2026 01:56
@swissspidy swissspidy requested a review from a team as a code owner February 4, 2026 01:56
Copilot AI review requested due to automatic review settings February 4, 2026 01:56

This comment was marked as resolved.

swissspidy and others added 2 commits February 3, 2026 21:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:theme Related to 'theme' command scope:distribution Related to distribution state:unconfirmed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add wp theme cache command

2 participants