Title: [WP-CLI] Specific theme or plugin extraction
Last modified: September 20, 2022

---

# [WP-CLI] Specific theme or plugin extraction

 *  Resolved [WEBKINDER](https://wordpress.org/support/users/webkinder/)
 * (@webkinder)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/)
 * Hi,
    is there a way to only extract the available source string from one specific
   theme or plugin? There is a option to set a filter for the `wp loco extract` 
   command, but it only allows all themes/plugins or a text domain (we have the 
   issue that there might be the same text-domain for multiple plugins or themes,
   but we only have to extract the strings in one theme).
 * Kind regards,
    WEBKINDER

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16027359)
 * It’s not possible to specify a plugin or theme other than by its text domain,
   which is expected to be unique by convention.
 * Your use case isn’t supported by the cli utility, but the [equivalent sync function](https://localise.biz/wordpress/plugin/manual/sync#xgettext)
   via the UI does support it. I suggest you use that instead.
 *  Thread Starter [WEBKINDER](https://wordpress.org/support/users/webkinder/)
 * (@webkinder)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16043642)
 * Would it be possible to add this functionality to the CLI extract, fetch and 
   sync command?
    We have already successfully tested a possible integration, I 
   think it would be great to be able to have the same use case covered by the cli
   utility instead only only supporting it through the UI.
 * Possible changes:
    [https://gist.github.com/raphaelportmann/191ea568edbf6bb46bc98f9485fcc25b](https://gist.github.com/raphaelportmann/191ea568edbf6bb46bc98f9485fcc25b)
    -  This reply was modified 3 years, 8 months ago by [WEBKINDER](https://wordpress.org/support/users/webkinder/).
    -  This reply was modified 3 years, 8 months ago by [WEBKINDER](https://wordpress.org/support/users/webkinder/).
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16046678)
 * So you are proposing to use `theme/foo` to avoid matching every bundle whose 
   text domains is “foo”. Likewise `plugin/foo/bar.php`. Is that correct?
 *  Thread Starter [WEBKINDER](https://wordpress.org/support/users/webkinder/)
 * (@webkinder)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16047445)
 * Thats correct. It uses the theme/plugin handle (has to be unique) instead of 
   a text-domain (should be unique but isn’t in our case). The way I propose to 
   implement it there’s not really a problem with colliding handles and text-domains.
   So it shouldn’t break existing scripts using the CLI command with text-domains.
   
   Or do you see a better way?
    -  This reply was modified 3 years, 8 months ago by [WEBKINDER](https://wordpress.org/support/users/webkinder/).
    -  This reply was modified 3 years, 8 months ago by [WEBKINDER](https://wordpress.org/support/users/webkinder/).
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16047791)
 * It’s a little esoteric, but should be ok.
 * The one thing I’d change is to use a syntax like theme:name to avoid it looking
   like a path, which it isn’t.
 * I wonder if the disambiguation is necessary for plugins as they should end with*.
   php (I think) e.g. loco-translate/loco.php is the handle for this plugin.
 *  Thread Starter [WEBKINDER](https://wordpress.org/support/users/webkinder/)
 * (@webkinder)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16048070)
 * For sure, the “theme:handle” and “plugin:handle” format would definitely help
   to understand the syntax used to select a single theme or plugin.
    Imo it’s also
   better to use the same syntax for themes and plugins, so it’s easier to understand
   and constistent when using the command.
    -  This reply was modified 3 years, 8 months ago by [WEBKINDER](https://wordpress.org/support/users/webkinder/).
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16054800)
 * Now supported on the [Development branch](https://localise.biz/wordpress/plugin/developers)
 * The syntax is `themes:{slug}` or `plugins:{handle}` to keep naming consistent
   with (themes|plugins|core) and act like an optional argument to the type. As 
   a result the Core is filterable also, e.g. `core:admin-network`

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[WP-CLI] Specific theme or plugin extraction’ is closed to new replies.

 * ![](https://ps.w.org/loco-translate/assets/icon-256x256.png?rev=1000676)
 * [Loco Translate](https://wordpress.org/plugins/loco-translate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/loco-translate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/loco-translate/)
 * [Active Topics](https://wordpress.org/support/plugin/loco-translate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/loco-translate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/loco-translate/reviews/)

## Tags

 * [cli](https://wordpress.org/support/topic-tag/cli/)
 * [extract](https://wordpress.org/support/topic-tag/extract/)

 * 7 replies
 * 2 participants
 * Last reply from: [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/wp-cli-specific-theme-or-plugin-extraction/#post-16054800)
 * Status: resolved