plugin updates

This commit is contained in:
Tony Volpe
2024-02-21 16:19:46 +00:00
parent c72f206574
commit 21d4c85c00
1214 changed files with 102269 additions and 179257 deletions

View File

@@ -50,6 +50,8 @@ class WC_WCCOM_Site_Installation_Step_Activate_Product implements WC_WCCOM_Site_
* Activate plugin.
*
* @param int $product_id Product ID.
* @return void
* @throws WC_REST_WCCOM_Site_Installer_Error If plugin activation failed.
*/
private function activate_plugin( $product_id ) {
// Clear plugins cache used in `WC_Helper::get_local_woo_plugins`.
@@ -74,13 +76,13 @@ class WC_WCCOM_Site_Installation_Step_Activate_Product implements WC_WCCOM_Site_
}
if ( empty( $filename ) ) {
return new Installer_Error( Installer_Error_Codes::UNKNOWN_FILENAME );
throw new Installer_Error( Installer_Error_Codes::UNKNOWN_FILENAME );
}
$result = activate_plugin( $filename );
if ( is_wp_error( $result ) ) {
return new Installer_Error( Installer_Error_Codes::PLUGIN_ACTIVATION_ERROR, $result->get_error_message() );
throw new Installer_Error( Installer_Error_Codes::PLUGIN_ACTIVATION_ERROR, $result->get_error_message() );
}
}
@@ -88,6 +90,8 @@ class WC_WCCOM_Site_Installation_Step_Activate_Product implements WC_WCCOM_Site_
* Activate theme.
*
* @param int $product_id Product ID.
* @return void
* @throws WC_REST_WCCOM_Site_Installer_Error If theme activation failed.
*/
private function activate_theme( $product_id ) {
// Clear plugins cache used in `WC_Helper::get_local_woo_themes`.
@@ -112,7 +116,7 @@ class WC_WCCOM_Site_Installation_Step_Activate_Product implements WC_WCCOM_Site_
}
if ( empty( $theme_slug ) ) {
return new Installer_Error( Installer_Error_Codes::UNKNOWN_FILENAME );
throw new Installer_Error( Installer_Error_Codes::UNKNOWN_FILENAME );
}
switch_theme( $theme_slug );

View File

@@ -114,7 +114,7 @@ class WC_WCCOM_Site_Installation_Step_Get_Product_Info implements WC_WCCOM_Site_
$updates = WC_Helper_Updater::get_update_data();
if ( empty( $updates[ $product_id ]['package'] ) ) {
return new Installer_Error( Installer_Error_Codes::WCCOM_PRODUCT_MISSING_PACKAGE );
throw new Installer_Error( Installer_Error_Codes::WCCOM_PRODUCT_MISSING_PACKAGE );
}
return $updates[ $product_id ]['package'];

View File

@@ -33,13 +33,16 @@ class WC_WCCOM_Site_Installation_Step_Unpack_Product implements WC_WCCOM_Site_In
/**
* Run the step installation process.
*
* @return WC_WCCOM_Site_Installation_State
* @throws WC_REST_WCCOM_Site_Installer_Error If the package unpacked path is not returned.
*/
public function run() {
$upgrader = WC_WCCOM_Site_Installer::get_wp_upgrader();
$unpacked_path = $upgrader->unpack_package( $this->state->get_download_path(), true );
if ( empty( $unpacked_path ) ) {
return new Installer_Error( Installer_Error_Codes::MISSING_UNPACKED_PATH );
throw new Installer_Error( Installer_Error_Codes::MISSING_UNPACKED_PATH );
}
$this->state->set_unpacked_path( $unpacked_path );