Skip to content

Commit 8df741e

Browse files
authored
Merge pull request #486 from wp-cli/copilot/allow-php-file-install
Support installing plugins from single PHP file URLs
2 parents a8dc5aa + afa6848 commit 8df741e

File tree

3 files changed

+375
-3
lines changed

3 files changed

+375
-3
lines changed

features/plugin-install.feature

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,99 @@ Feature: Install WordPress plugins
274274
Error: No plugins installed.
275275
"""
276276

277+
Scenario: Install plugin from a single PHP file URL
278+
Given a WP install
279+
280+
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php --activate`
281+
Then STDOUT should contain:
282+
"""
283+
Installing
284+
"""
285+
And STDOUT should contain:
286+
"""
287+
Downloading plugin file from
288+
"""
289+
And STDOUT should contain:
290+
"""
291+
Plugin installed successfully.
292+
"""
293+
And STDOUT should contain:
294+
"""
295+
Activating
296+
"""
297+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
298+
299+
When I run `wp plugin list --field=name`
300+
Then STDOUT should contain:
301+
"""
302+
pwa-manifest-short-name
303+
"""
304+
305+
When I run `wp plugin list --name=pwa-manifest-short-name --field=status`
306+
Then STDOUT should be:
307+
"""
308+
active
309+
"""
310+
311+
Scenario: Install plugin from a single PHP file URL with --force flag
312+
Given a WP install
313+
314+
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php`
315+
Then STDOUT should contain:
316+
"""
317+
Plugin installed successfully.
318+
"""
319+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
320+
321+
When I try `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php`
322+
Then STDERR should contain:
323+
"""
324+
Warning: Plugin already installed.
325+
"""
326+
And STDOUT should contain:
327+
"""
328+
Success: Plugin already installed.
329+
"""
330+
331+
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php --force`
332+
Then STDOUT should contain:
333+
"""
334+
Plugin installed successfully.
335+
"""
336+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
337+
338+
Scenario: Install plugin from a GitHub Gist page URL
339+
Given a WP install
340+
341+
When I run `wp plugin install https://gist.github.com/westonruter/dec7d190060732e29a09751ab99cc549 --activate`
342+
Then STDOUT should contain:
343+
"""
344+
Gist resolved to raw file URL.
345+
"""
346+
And STDOUT should contain:
347+
"""
348+
Installing
349+
"""
350+
And STDOUT should contain:
351+
"""
352+
Downloading plugin file from
353+
"""
354+
And STDOUT should contain:
355+
"""
356+
Plugin installed successfully.
357+
"""
358+
And STDOUT should contain:
359+
"""
360+
Activating
361+
"""
362+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
363+
364+
When I run `wp plugin list --name=pwa-manifest-short-name --field=status`
365+
Then STDOUT should be:
366+
"""
367+
active
368+
"""
369+
277370
Scenario: Install plugin using WordPress.org directory URL
278371
Given a WP install
279372

src/Plugin_Command.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ protected function filter_item_list( $items, $args ) {
10231023
* ## OPTIONS
10241024
*
10251025
* <plugin|zip|url>...
1026-
* : One or more plugins to install. Accepts a plugin slug, the path to a local zip file, a URL to a remote zip file, or a URL to a WordPress.org plugin directory.
1026+
* : One or more plugins to install. Accepts a plugin slug, the path to a local zip file, a URL to a remote zip file or PHP file, or a URL to a WordPress.org plugin directory.
10271027
*
10281028
* [--version=<version>]
10291029
* : If set, get that particular version from wordpress.org, instead of the
@@ -1106,6 +1106,11 @@ protected function filter_item_list( $items, $args ) {
11061106
* Plugin updated successfully
11071107
* Success: Installed 1 of 1 plugins.
11081108
*
1109+
* # Install from a remote PHP file
1110+
* $ wp plugin install https://example.com/my-plugin.php
1111+
* Installing My Plugin (1.0.0)
1112+
* Downloading plugin file from https://example.com/my-plugin.php...
1113+
*
11091114
* # Install a plugin with all its dependencies
11101115
* $ wp plugin install my-plugin --with-dependencies
11111116
* Installing Required Plugin 1 (1.2.3)

0 commit comments

Comments
 (0)