Suffix added to plugin name when using wp plugin install <url>

Viewed 31

When I try to install the plugin https://github.com/wp-graphql/wp-graphql-woocommerce using:

wp plugin install https://github.com/wp-graphql/wp-graphql-woocommerce/releases/download/v0.10.4/wp-graphql-woocommerce.zip

The plugin will be added with a random suffix added to the plugin-name /wp-content/plugins/wp-graphql-woocommerce-0ymkp2.

Is this by design or is something weird going on? Currently I am using curl to download the package and install it from the local file.

1 Answers

I ran into this when I was creating a custom plugin. It appears to happen because Wordpress expects a subdirectory at the root of the plugin's .zip file that matches the slug of the plugin.

That is, instead of the .zip file containing:

includes/class-acf-schema-filters.php
includes/class-core-schema-filters.php
.
.
.
vendor/firebase/php-jwt/src/Key.php
vendor/firebase/php-jwt/src/SignatureInvalidException.php   
wp-graphql-woocommerce.php

It should instead contain:

wp-graphql-woocommerce/includes/class-acf-schema-filters.php
wp-graphql-woocommerce/includes/class-core-schema-filters.php
.
.
.
wp-graphql-woocommerce/vendor/firebase/php-jwt/src/Key.php
wp-graphql-woocommerce/vendor/firebase/php-jwt/src/SignatureInvalidException.php   
wp-graphql-woocommerce/wp-graphql-woocommerce.php

As soon as I changed my plugin to have a subdirectory at the root of the .zip file, Wordpress stopped renaming my plugin directory with a random suffix whenever I updated it.

Related