• Resolved WEBKINDER

    (@webkinder)


    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

    (@timwhitlock)

    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 via the UI does support it. I suggest you use that instead.

    Thread Starter WEBKINDER

    (@webkinder)

    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

    • This reply was modified 2 years, 2 months ago by WEBKINDER.
    • This reply was modified 2 years, 2 months ago by WEBKINDER.
    Plugin Author Tim W

    (@timwhitlock)

    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

    (@webkinder)

    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 2 years, 2 months ago by WEBKINDER.
    • This reply was modified 2 years, 2 months ago by WEBKINDER.
    Plugin Author Tim W

    (@timwhitlock)

    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

    (@webkinder)

    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 2 years, 2 months ago by WEBKINDER.
    Plugin Author Tim W

    (@timwhitlock)

    Now supported on the Development branch

    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.