Skip to content

REST API: JPO: Enable WooCommerce installation#8482

Merged
ockham merged 8 commits intomasterfrom
add/install-and-activate-plugin-function
Jan 10, 2018
Merged

REST API: JPO: Enable WooCommerce installation#8482
ockham merged 8 commits intomasterfrom
add/install-and-activate-plugin-function

Conversation

@ockham
Copy link
Copy Markdown
Contributor

@ockham ockham commented Jan 8, 2018

Add install_and_activate_plugins() to the Plugins Helper class, and use that to install WooCommerce from the JP Onboarding endpoint.

Counterpart to Automattic/wp-calypso#21237 -- find testing instructions there.

@ockham ockham self-assigned this Jan 8, 2018
@ockham ockham requested a review from a team as a code owner January 8, 2018 10:58
@ockham ockham changed the title Add/install and activate plugin function REST API: JPO: Enable WooCommerce installation Jan 8, 2018
@ockham ockham requested review from AnnaMag and tyxla January 8, 2018 10:59
@ockham ockham force-pushed the add/install-and-activate-plugin-function branch 3 times, most recently from bfb7994 to 4939b5d Compare January 8, 2018 11:28
Copy link
Copy Markdown
Member

@tyxla tyxla Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that activate_plugin returns null on successful activation, so you'll want to update the logic here to return true on success (probably by checking if it's NOT a WP_Error). You might be able to benefit from the other review comments from this review (I mentioned that there): #8450 (review).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, my bad. Oh those dreaded return values.

ockham added a commit that referenced this pull request Jan 8, 2018
Move:
* the `Jetpack_Automatic_Install_Skin` helper class to `_inc/lib/class.jetpack-automatic-install-skin.php`
* some static helper methods from `Jetpack_JSON_API_Plugins_Install_Endpoint` to `Jetpack_Plugins` in `_inc/lib/plugins.php`.

(Preparatory work for #8482. De-duplicate all the things!)
@ockham ockham force-pushed the add/install-and-activate-plugin-function branch from 4939b5d to cc93681 Compare January 8, 2018 14:43
@ockham ockham added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jan 8, 2018
@ockham ockham requested review from eliorivero and oskosk January 8, 2018 15:17
@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 8, 2018

Ready for review!

Copy link
Copy Markdown
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant work ❤️ 😍

Code looks great and tests as expected. LGTM 👍

Left a couple of comments only, nothing blocking.

// Check if get_plugins() function exists. This is required on the front end of the
// site, since it is in a file that is normally only loaded in the admin.
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation appears to be use a space instead of a tab here.

}

public static function get_plugin_id_by_slug( $slug ) {
// Check if get_plugins() function exists. This is required on the front end of the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're also not in the front end of the site, are we?

Copy link
Copy Markdown
Contributor Author

@ockham ockham Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I was copy-pasting this from elsewhere. Since #8464 worked without it, I guess I can just drop it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer keeping it just in case, because those admin files are often not specifically loaded. We can consider removing it only if we're sure that in all cases this method is called, the file is specifically required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, has to remain for our use case:

[08-Jan-2018 15:54:56 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function get_plugins() in ~/public_html/wp-content/plugins/jetpack/_inc/lib/plugins.php:104

@oskosk oskosk added this to the 5.8 milestone Jan 8, 2018
@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 9, 2018

Soliciting review from JP Crew members @oskosk and @eliorivero 🙏

Copy link
Copy Markdown
Contributor

@oskosk oskosk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐑 !!!

@oskosk oskosk added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jan 10, 2018
@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented Jan 10, 2018

Woohoo, thanks for reviewing @tyxla and @oskosk!

@ockham ockham merged commit 2c31883 into master Jan 10, 2018
@ockham ockham deleted the add/install-and-activate-plugin-function branch January 10, 2018 13:57
@tyxla tyxla removed the [Status] Ready to Merge Go ahead, you can push that green button! label Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants