Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installing Plugins/Themes into an arbitrary folder #1803

Merged
merged 8 commits into from
Oct 9, 2024

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Sep 25, 2024

Motivation for the change, related issues

See #1802

This allows for installing a user-generated ZIP file into a specific theme/plugin path.

Implementation details

InstallAssetOptions has a new param, targetSlug (to match it's existing targetPath) which if set the ultimate install path is targetPath/targetSlug. If the param is not set, it defaults to guessing from the ZIP filename and ZIP contents as current.

InstallPluginOptions and InstallThemeOptions both gain the same parameter, and pass it through if set.

InstallThemeOptions was previously not actually in use, this fixes that, bringing it inline with InstallPluginOptions.

Tests are a bit of a weird mess, as the testing structure doesn't cleanup between iteration runs, and the helper methods are different between each section. zipFiles helper from the plugin tests should probably be a common helper instead.

The tests should show the current "issue" with 6b3b5a5 failing, and the latest changeset resolving that error.

Testing Instructions (or ideally a Blueprint)

{
  "landingPage": "/wp-admin/admin.php?page=example",
  "steps": [
    {
      "step": "login",
      "username": "admin",
      "password": "password"
    },
    {
      "step": "installPlugin",
      "pluginZipFile": {
        "resource": "wordpress.org/plugins",
        "slug": "hello-dolly"
      },
      "options": {
        "targetSlug": "hello-example-plugin"
      }
    },
    {
      "step": "writeFile",
      "path": "/wordpress/wp-content/mu-plugins/example.php",
      "data": "<?php add_action('admin_menu', function(){ add_menu_page('Example','Example',0,'example',function(){ echo '<pre>'; print_r( glob( WP_PLUGIN_DIR . '/*' ) ); echo '</pre>'; }); } );"
    }
  ]
}

This should display a admin page with the following output:

Array
(
    [0] => /wordpress/wp-content/plugins/hello-example-plugin
    [1] => /wordpress/wp-content/plugins/hello.php
    [2] => /wordpress/wp-content/plugins/index.php
)

@dd32 dd32 changed the title Add/install asset arbritrary path Allow installing Plugins/Themes into an arbitrary folder Sep 25, 2024
@dd32 dd32 force-pushed the add/installAsset-arbritrary-path branch from f402cb8 to 6b3b5a5 Compare September 25, 2024 03:50
@dd32 dd32 marked this pull request as ready for review September 25, 2024 04:08
@bgrgicak bgrgicak requested a review from a team September 27, 2024 10:26
@adamziel adamziel force-pushed the trunk branch 2 times, most recently from 680cd19 to 2e376d2 Compare October 4, 2024 09:24
@bgrgicak
Copy link
Collaborator

bgrgicak commented Oct 8, 2024

@dd32 would the new directory resources work for your use case?

@adamziel
Copy link
Collaborator

adamziel commented Oct 8, 2024

I don't think the directory resources solve for the same use-case. This is about giving the plugin directory an arbitrary name – that would be a useful feature. I struggled with that myself. @dd32 This is a useful change, thank you! It needs a rebase and I'd change targetSlug to something suggesting a directory name although I don't have any specific ideas right now.

@dd32
Copy link
Member Author

dd32 commented Oct 9, 2024

Directory resource does look like a nice change! But yeah not overly useful for this case.

It needs a rebase

On it!

I'd change targetSlug to something suggesting a directory name although I don't have any specific ideas right now.

Yeah, I wasn't overly loving it, There's an existing targetPath which I was modeling off so perhaps targetDirectoryName or targetDirectoryBasename ?

@adamziel
Copy link
Collaborator

adamziel commented Oct 9, 2024

TargetFolderName sounds nice, thank you!

@adamziel adamziel merged commit 41bb913 into trunk Oct 9, 2024
9 checks passed
@adamziel adamziel deleted the add/installAsset-arbritrary-path branch October 9, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants