OBW: Add MailChimp to recommended step

This commit is contained in:
Valerie 2018-04-14 23:54:55 -04:00
parent c1e55cd6a5
commit 551db8246e
5 changed files with 43 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1239,6 +1239,12 @@ p.jetpack-terms {
max-height: 1.75em;
padding: ( 3.5em - 1.75em ) / 2;
}
&.recommended-item-icon-mailchimp {
background-color: #209bbb;
height: 2em;
padding: ( 3.5em - 2em ) / 2;
}
}
.recommended-item-description-container {

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -121,6 +121,16 @@ class WC_Admin_Setup_Wizard {
return in_array( $country_code, $tax_supported_countries, true );
}
/**
* Should we show the MailChimp install option?
* True only if the user can install plugins.
*
* @return boolean
*/
protected function should_show_mailchimp() {
return current_user_can( 'install_plugins' );
}
/**
* Should we display the 'Recommended' step?
* True if at least one of the recommendations will be displayed.
@ -129,7 +139,8 @@ class WC_Admin_Setup_Wizard {
*/
protected function should_show_recommended_step() {
return $this->should_show_theme()
|| $this->should_show_automated_tax();
|| $this->should_show_automated_tax()
|| $this->should_show_mailchimp();
}
/**
@ -1637,6 +1648,16 @@ class WC_Admin_Setup_Wizard {
'img_alt' => __( 'automated taxes icon', 'woocommerce' ),
) );
endif;
if ( $this->should_show_mailchimp() ) :
$this->display_recommended_item( array(
'type' => 'mailchimp',
'title' => __( 'MailChimp', 'woocommerce' ),
'description' => __( 'Join the 16 million customers who use MailChimp. Sync list and store data to send automated emails, and targeted campaigns.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-mailchimp-icon.svg',
'img_alt' => __( 'MailChimp icon', 'woocommerce' ),
) );
endif;
?>
</ul>
<p class="wc-setup-actions step">
@ -1655,6 +1676,7 @@ class WC_Admin_Setup_Wizard {
$setup_storefront = isset( $_POST['setup_storefront_theme'] ) && 'yes' === $_POST['setup_storefront_theme'];
$setup_automated_tax = isset( $_POST['setup_automated_taxes'] ) && 'yes' === $_POST['setup_automated_taxes'];
$setup_mailchimp = isset( $_POST['setup_mailchimp'] ) && 'yes' === $_POST['setup_mailchimp'];
update_option( 'woocommerce_calc_taxes', $setup_automated_tax ? 'yes' : 'no' );
update_option( 'woocommerce_setup_automated_taxes', $setup_automated_tax );
@ -1667,6 +1689,17 @@ class WC_Admin_Setup_Wizard {
$this->install_woocommerce_services();
}
if ( $setup_mailchimp ) {
$this->install_plugin(
'mailchimp-for-woocommerce',
array(
'name' => __( 'MailChimp for WooCommerce', 'woocommerce' ),
'repo-slug' => 'mailchimp-for-woocommerce',
'file' => 'mailchimp-woocommerce.php',
)
);
}
wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit;
}