Use WC_Install class to install/activate WooCommerce services from the Extensions page.
This commit is contained in:
parent
d8e508842d
commit
c212725053
|
@ -324,9 +324,11 @@ class WC_Admin_Addons {
|
|||
return;
|
||||
}
|
||||
|
||||
$button_url = $url = wp_nonce_url(
|
||||
self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce-services' ),
|
||||
'install-plugin_woocommerce-services'
|
||||
$button_url = wp_nonce_url(
|
||||
add_query_arg( array(
|
||||
'install-addon' => 'woocommerce-services',
|
||||
) ),
|
||||
'install-addon_woocommerce-services'
|
||||
);
|
||||
|
||||
$defaults = array(
|
||||
|
@ -425,10 +427,32 @@ class WC_Admin_Addons {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_GET['install-addon'] ) && 'woocommerce-services' === $_GET['install-addon'] ) {
|
||||
self::install_woocommerce_services_addon();
|
||||
}
|
||||
|
||||
$sections = self::get_sections();
|
||||
$theme = wp_get_theme();
|
||||
$section_keys = array_keys( $sections );
|
||||
$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
|
||||
include_once( dirname( __FILE__ ) . '/views/html-admin-page-addons.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Install WooCommerce Services from Extensions screens.
|
||||
*/
|
||||
public static function install_woocommerce_services_addon() {
|
||||
check_admin_referer( 'install-addon_woocommerce-services' );
|
||||
|
||||
$services_plugin_id = 'woocommerce-services';
|
||||
$services_plugin = array(
|
||||
'name' => __( 'WooCommerce Services', 'woocommerce' ),
|
||||
'repo-slug' => 'woocommerce-services',
|
||||
);
|
||||
|
||||
WC_Install::background_installer( $services_plugin_id, $services_plugin );
|
||||
|
||||
wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue