diff --git a/assets/images/obw-facebook-icon.svg b/assets/images/obw-facebook-icon.svg new file mode 100644 index 00000000000..3d617d09757 --- /dev/null +++ b/assets/images/obw-facebook-icon.svg @@ -0,0 +1 @@ +flogo_RGB_HEX-512 \ No newline at end of file diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index cdde2dbe559..ce7cb1d3177 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -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() { ?>

-

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; - ?>

+

+ +

@@ -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; }