-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adds ability to manage plugins for self hosted sites that aren't connected to Jetpack #16675
Merged
Merged
Changes from 22 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
991e257
Add support for self hosted sites in the supportsPluginManagement logic
3644eab
Add a way support self hosted non Jetpack sites in the JetpackSiteRef
261609e
Fix supportsPluginManagement logic to prevent a crash
40034dc
Add a helper method to get a blog using the XMLRPC
3ebdf9c
Add helper method to exclude siteID from self hosted plugin events
f20b3c3
Add a protocol to represent a generic plugin management client interface
d964582
Add PluginServiceRemove methods to a new class that adheres to Plugin…
a567e9a
Add a self hosted plugin management client
cebc904
Use the PluginManagementClient instead of the PluginServiceRemote
cbbabaf
Update PodFile to point to WordPressKit branch
6217ae2
Remove unneeded enum value
b593845
Fix ending up in a limbo state when installing
586bf77
Update RELEASE-NOTES.txt
bbc354c
Merge branch 'develop' into task/16595-self-hosted-plugins
9f4c7ff
Update Podfile.lock
2777a5d
Update RELEASE-NOTES.txt
2289915
Merge branch 'develop' into task/16595-self-hosted-plugins
9ada0ef
Fix Podfile.lock updating the wrong pods
7882ac9
Update BlogBuilder to support more testing options
b89d3bf
Add Plugin Management Tests
a34ded9
Update JetpackRef.mock to fix broken tests
7df619d
Add nil account check to the supportsPluginManagement method
6f2852d
Add decouple the use of JetpackSiteRef from the PluginManagementClient
16e0361
Remove Plugin Management code that's been moved to WPKit
18ef501
Update WPKit commit
28bf51e
Update SelfHostedPluginManagementClient init
5931d10
Allow lookup of a plugin based on its slugs prefix
bf63b89
Use the found plugins ID for network actions
3c163b8
Add support for getting the PluginDirectoryEntry for self hosted plugins
426ad9c
Update release notes to ignore the self hosted feature notes from the…
79c9e73
Point to WPKit 4.36.0-beta.2
aedc0b5
Merge branch 'develop' into task/16595-self-hosted-plugins
2fcfc27
Update Podfile.lock to WPKit 4.36.0-beta.2
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
WordPress/Classes/Networking/Plugin Management/JetpackPluginManagementClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Foundation | ||
import WordPressKit | ||
|
||
class JetpackPluginManagementClient: PluginManagementClient { | ||
emilylaguna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private let siteID: Int | ||
private let remote: PluginServiceRemote | ||
|
||
required init?(with site: JetpackSiteRef) { | ||
leandroalonso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
guard let token = CredentialsService().getOAuthToken(site: site) else { | ||
return nil | ||
} | ||
|
||
siteID = site.siteID | ||
|
||
let api = WordPressComRestApi.defaultApi(oAuthToken: token, userAgent: WPUserAgent.wordPress()) | ||
remote = PluginServiceRemote(wordPressComRestApi: api) | ||
} | ||
|
||
func getPlugins(success: @escaping (SitePlugins) -> Void, failure: @escaping (Error) -> Void) { | ||
remote.getPlugins(siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func updatePlugin(pluginID: String, success: @escaping (PluginState) -> Void, failure: @escaping (Error) -> Void) { | ||
remote.updatePlugin(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func activatePlugin(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) { | ||
remote.activatePlugin(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func deactivatePlugin(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) { | ||
remote.deactivatePlugin(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func enableAutoupdates(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) { | ||
remote.enableAutoupdates(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
|
||
} | ||
|
||
func disableAutoupdates(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) { | ||
remote.disableAutoupdates(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func activateAndEnableAutoupdates(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) { | ||
remote.activateAndEnableAutoupdates(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func install(pluginSlug: String, success: @escaping (PluginState) -> Void, failure: @escaping (Error) -> Void) { | ||
remote.install(pluginSlug: pluginSlug, siteID: siteID, success: success, failure: failure) | ||
} | ||
|
||
func remove(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) { | ||
remote.remove(pluginID: pluginID, siteID: siteID, success: success, failure: failure) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
WordPress/Classes/Networking/Plugin Management/PluginManagementClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Foundation | ||
|
||
protocol PluginManagementClient { | ||
emilylaguna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
init?(with site: JetpackSiteRef) | ||
emilylaguna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
func getPlugins(success: @escaping (SitePlugins) -> Void, failure: @escaping (Error) -> Void) | ||
func updatePlugin(pluginID: String, success: @escaping (PluginState) -> Void, failure: @escaping (Error) -> Void) | ||
func activatePlugin(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) | ||
func deactivatePlugin(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) | ||
func enableAutoupdates(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) | ||
func disableAutoupdates(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) | ||
func activateAndEnableAutoupdates(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) | ||
func install(pluginSlug: String, success: @escaping (PluginState) -> Void, failure: @escaping (Error) -> Void) | ||
func remove(pluginID: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add
(Don't apply to Jetpack app)
before the change description?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 426ad9c