Merge pull request #22218 from woocommerce/add/fb-in-obw
Add Facebook to Recommended Step in OBW
This commit is contained in:
commit
caf3ff61e7
|
@ -0,0 +1 @@
|
|||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><defs><style>.cls-1{fill:#4267b2;}.cls-2{fill:#fff;}</style></defs><title>flogo_RGB_HEX-512</title><path class="cls-1" d="M483.74,0H28.26A28.26,28.26,0,0,0,0,28.26V483.74A28.26,28.26,0,0,0,28.26,512H273.5V314H207V236.5h66.5v-57c0-66.13,40.39-102.14,99.38-102.14,28.25,0,52.54,2.1,59.62,3v69.11l-40.68,0c-32.1,0-38.32,15.25-38.32,37.64V236.5h76.74l-10,77.5H353.5V512H483.74A28.26,28.26,0,0,0,512,483.74V28.26A28.26,28.26,0,0,0,483.74,0Z"/><path id="f" class="cls-2" d="M353.5,512V314h66.75l10-77.5H353.5V187.14c0-22.39,6.22-37.64,38.32-37.64l40.68,0V80.37c-7.08-.94-31.37-3-59.62-3-59,0-99.38,36-99.38,102.14v57H207V314h66.5V512Z"/></svg>
|
After Width: | Height: | Size: 732 B |
|
@ -133,6 +133,21 @@ class WC_Admin_Setup_Wizard {
|
|||
return current_user_can( 'install_plugins' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we show the Facebook install option?
|
||||
* True only if the user can install plugins,
|
||||
* and up until the end date of the recommendation.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function should_show_facebook() {
|
||||
$end_date_facebook_recommendation = new DateTime( '8 October 2019' );
|
||||
$current_user_date = new DateTime( current_time( 'Y-m-d' ) );
|
||||
|
||||
return current_user_can( 'install_plugins' ) &&
|
||||
$end_date_facebook_recommendation >= $current_user_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we display the 'Recommended' step?
|
||||
* True if at least one of the recommendations will be displayed.
|
||||
|
@ -142,7 +157,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_mailchimp();
|
||||
|| $this->should_show_mailchimp()
|
||||
|| $this->should_show_facebook();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1869,20 +1885,9 @@ class WC_Admin_Setup_Wizard {
|
|||
public function wc_setup_recommended() {
|
||||
?>
|
||||
<h1><?php esc_html_e( 'Recommended for All WooCommerce Stores', 'woocommerce' ); ?></h1>
|
||||
<p><?php
|
||||
// If we're displaying all of the recommended features, show the full description. Otherwise, display a placeholder.
|
||||
// We're not translating all of the different permutations to save on translations,
|
||||
// and the default is the most common.
|
||||
if (
|
||||
$this->should_show_theme()
|
||||
&& $this->should_show_automated_tax()
|
||||
&& $this->should_show_mailchimp()
|
||||
) :
|
||||
esc_html_e( 'Select from the list below to enable automated taxes and MailChimp’s best-in-class email services — and design your store with our official, free WooCommerce theme.', 'woocommerce' );
|
||||
else :
|
||||
esc_html_e( 'Enhance your store with these recommended features.', 'woocommerce' );
|
||||
endif;
|
||||
?></p>
|
||||
<p>
|
||||
<?php esc_html_e( 'Enhance your store with these recommended features.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
<form method="post">
|
||||
<ul class="recommended-step">
|
||||
<?php
|
||||
|
@ -1922,6 +1927,17 @@ class WC_Admin_Setup_Wizard {
|
|||
'plugins' => array( array( 'name' => __( 'Mailchimp for WooCommerce', 'woocommerce' ), 'slug' => 'mailchimp-for-woocommerce' ) ),
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( $this->should_show_facebook() ) :
|
||||
$this->display_recommended_item( array(
|
||||
'type' => 'facebook',
|
||||
'title' => __( 'Facebook', 'woocommerce' ),
|
||||
'description' => __( 'Enjoy all Facebook products combined in one extension: pixel tracking, catalog sync, messenger chat, shop functionality and Instagram shopping (coming soon)!', 'woocommerce' ),
|
||||
'img_url' => WC()->plugin_url() . '/assets/images/obw-facebook-icon.svg',
|
||||
'img_alt' => __( 'Facebook icon', 'woocommerce' ),
|
||||
'plugins' => array( array( 'name' => __( 'Facebook for WooCommerce', 'woocommerce' ), 'slug' => 'facebook-for-woocommerce' ) ),
|
||||
) );
|
||||
endif;
|
||||
?>
|
||||
</ul>
|
||||
<p class="wc-setup-actions step">
|
||||
|
@ -1942,6 +1958,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'];
|
||||
$setup_facebook = isset( $_POST['setup_facebook'] ) && 'yes' === $_POST['setup_facebook'];
|
||||
|
||||
update_option( 'woocommerce_calc_taxes', $setup_automated_tax ? 'yes' : 'no' );
|
||||
update_option( 'woocommerce_setup_automated_taxes', $setup_automated_tax );
|
||||
|
@ -1968,6 +1985,16 @@ class WC_Admin_Setup_Wizard {
|
|||
);
|
||||
}
|
||||
|
||||
if ( $setup_facebook ) {
|
||||
$this->install_plugin(
|
||||
'facebook-for-woocommerce',
|
||||
array(
|
||||
'name' => __( 'Facebook for WooCommerce', 'woocommerce' ),
|
||||
'repo-slug' => 'facebook-for-woocommerce',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
|
||||
exit;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue