This commit is contained in:
Paul Sealock 2019-03-08 10:05:59 +13:00
parent 68573f6ed5
commit e9d02699c4
2 changed files with 59 additions and 51 deletions

View File

@ -190,8 +190,8 @@ class WC_Admin_Setup_Wizard {
'i18n' => array( 'i18n' => array(
'extra_plugins' => array( 'extra_plugins' => array(
'payment' => array( 'payment' => array(
'stripe_create_account' => __( 'Stripe setup is powered by Jetpack and WooCommerce Services.', 'woocommerce' ), 'stripe_create_account' => __( 'Stripe setup is powered by Jetpack and WooCommerce Services.', 'woocommerce' ),
'ppec_paypal_reroute_requests' => __( 'PayPal setup is powered by Jetpack and WooCommerce Services.', 'woocommerce' ), 'ppec_paypal_reroute_requests' => __( 'PayPal setup is powered by Jetpack and WooCommerce Services.', 'woocommerce' ),
'stripe_create_account,ppec_paypal_reroute_requests' => __( 'Stripe and PayPal setup are powered by Jetpack and WooCommerce Services.', 'woocommerce' ), 'stripe_create_account,ppec_paypal_reroute_requests' => __( 'Stripe and PayPal setup are powered by Jetpack and WooCommerce Services.', 'woocommerce' ),
), ),
), ),
@ -790,8 +790,8 @@ class WC_Admin_Setup_Wizard {
* @param string $input_prefix Input prefix. * @param string $input_prefix Input prefix.
*/ */
protected function shipping_method_selection_form( $country_code, $currency_code, $input_prefix ) { protected function shipping_method_selection_form( $country_code, $currency_code, $input_prefix ) {
$selected = 'flat_rate'; $selected = 'flat_rate';
$shipping_methods = $this->get_wizard_shipping_methods( $country_code, $currency_code ); $shipping_methods = $this->get_wizard_shipping_methods( $country_code, $currency_code );
?> ?>
<div class="wc-wizard-shipping-method-select"> <div class="wc-wizard-shipping-method-select">
<div class="wc-wizard-shipping-method-dropdown"> <div class="wc-wizard-shipping-method-dropdown">
@ -966,7 +966,7 @@ class WC_Admin_Setup_Wizard {
'class' => array(), 'class' => array(),
'data-tip' => array(), 'data-tip' => array(),
), ),
'a' => array( 'a' => array(
'href' => array(), 'href' => array(),
'target' => array(), 'target' => array(),
), ),
@ -985,28 +985,32 @@ class WC_Admin_Setup_Wizard {
<ul class="wc-setup-shipping-recommended"> <ul class="wc-setup-shipping-recommended">
<?php <?php
if ( $is_wcs_labels_supported ) : if ( $is_wcs_labels_supported ) :
$this->display_recommended_item( array( $this->display_recommended_item(
'type' => 'woocommerce_services', array(
'title' => __( 'Print shipping labels at home', 'woocommerce' ), 'type' => 'woocommerce_services',
'description' => __( 'We recommend WooCommerce Services & Jetpack. These plugins will save you time at the Post Office by enabling you to print your shipping labels at home.', 'woocommerce' ), 'title' => __( 'Print shipping labels at home', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-services-icon.png', 'description' => __( 'We recommend WooCommerce Services & Jetpack. These plugins will save you time at the Post Office by enabling you to print your shipping labels at home.', 'woocommerce' ),
'img_alt' => __( 'WooCommerce Services icon', 'woocommerce' ), 'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-services-icon.png',
'plugins' => $this->get_wcs_requisite_plugins(), 'img_alt' => __( 'WooCommerce Services icon', 'woocommerce' ),
) ); 'plugins' => $this->get_wcs_requisite_plugins(),
)
);
elseif ( $is_shipstation_supported ) : elseif ( $is_shipstation_supported ) :
$this->display_recommended_item( array( $this->display_recommended_item(
'type' => 'shipstation', array(
'title' => __( 'Print shipping labels at home', 'woocommerce' ), 'type' => 'shipstation',
'description' => __( 'We recommend using ShipStation to save time at the Post Office by printing your shipping labels at home. Try ShipStation free for 30 days.', 'woocommerce' ), 'title' => __( 'Print shipping labels at home', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-shipstation-icon.png', 'description' => __( 'We recommend using ShipStation to save time at the Post Office by printing your shipping labels at home. Try ShipStation free for 30 days.', 'woocommerce' ),
'img_alt' => __( 'ShipStation icon', 'woocommerce' ), 'img_url' => WC()->plugin_url() . '/assets/images/obw-shipstation-icon.png',
'plugins' => array( 'img_alt' => __( 'ShipStation icon', 'woocommerce' ),
array( 'plugins' => array(
'name' => __( 'ShipStation', 'woocommerce' ), array(
'slug' => 'woocommerce-shipstation-integration', 'name' => __( 'ShipStation', 'woocommerce' ),
'slug' => 'woocommerce-shipstation-integration',
),
), ),
), )
) ); );
endif; endif;
endif; endif;
?> ?>
@ -1023,7 +1027,7 @@ class WC_Admin_Setup_Wizard {
$this->get_product_dimension_selection() $this->get_product_dimension_selection()
), ),
array( array(
'span' => array( 'span' => array(
'class' => array(), 'class' => array(),
), ),
'select' => array( 'select' => array(
@ -1873,7 +1877,7 @@ class WC_Admin_Setup_Wizard {
&& $this->should_show_automated_tax() && $this->should_show_automated_tax()
&& $this->should_show_mailchimp() && $this->should_show_mailchimp()
) : ) :
esc_html_e( 'Select from the list below to enable automated taxes and MailChimps best-in-class email services — and design your store with our official, free WooCommerce theme.', 'woocommerce' ); esc_html_e( 'Select from the list below to enable automated taxes and MailChimps best-in-class email services — and design your store with our official, free WooCommerce theme.', 'woocommerce' );
else : else :
esc_html_e( 'Enhance your store with these recommended features.', 'woocommerce' ); esc_html_e( 'Enhance your store with these recommended features.', 'woocommerce' );
endif; endif;

View File

@ -3,14 +3,12 @@
* WooCommerce Admin * WooCommerce Admin
* *
* @class WC_Admin * @class WC_Admin
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin * @package WooCommerce/Admin
* @version 2.6.0 * @version 2.6.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly.
} }
/** /**
@ -66,12 +64,12 @@ class WC_Admin {
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-footer-pixel.php'; include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-footer-pixel.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-site-tracking.php'; include_once WC_ABSPATH . 'includes/tracks/class-wc-site-tracking.php';
// Help Tabs // Help Tabs.
if ( apply_filters( 'woocommerce_enable_admin_help_tab', true ) ) { if ( apply_filters( 'woocommerce_enable_admin_help_tab', true ) ) {
include_once dirname( __FILE__ ) . '/class-wc-admin-help.php'; include_once dirname( __FILE__ ) . '/class-wc-admin-help.php';
} }
// Setup/welcome // Setup/welcome.
if ( ! empty( $_GET['page'] ) ) { if ( ! empty( $_GET['page'] ) ) {
switch ( $_GET['page'] ) { switch ( $_GET['page'] ) {
case 'wc-setup': case 'wc-setup':
@ -80,12 +78,12 @@ class WC_Admin {
} }
} }
// Importers // Importers.
if ( defined( 'WP_LOAD_IMPORTERS' ) ) { if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
include_once dirname( __FILE__ ) . '/class-wc-admin-importers.php'; include_once dirname( __FILE__ ) . '/class-wc-admin-importers.php';
} }
// Helper // Helper.
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-options.php'; include_once dirname( __FILE__ ) . '/helper/class-wc-helper-options.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-api.php'; include_once dirname( __FILE__ ) . '/helper/class-wc-helper-api.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-updater.php'; include_once dirname( __FILE__ ) . '/helper/class-wc-helper-updater.php';
@ -95,7 +93,7 @@ class WC_Admin {
} }
/** /**
* Preloads some functionality of the Helper to be loaded on the `plugins_loaded` hook * Preloads some functionality of the Helper to be loaded on the `plugins_loaded` hook.
*/ */
public function preload_helper() { public function preload_helper() {
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-file-headers.php'; include_once dirname( __FILE__ ) . '/helper/class-wc-helper-file-headers.php';
@ -105,7 +103,9 @@ class WC_Admin {
* Include admin files conditionally. * Include admin files conditionally.
*/ */
public function conditional_includes() { public function conditional_includes() {
if ( ! $screen = get_current_screen() ) { $screen = get_current_screen();
if ( ! $screen ) {
return; return;
} }
@ -138,9 +138,9 @@ class WC_Admin {
* For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters. * For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters.
*/ */
public function admin_redirects() { public function admin_redirects() {
// Nonced plugin install redirects (whitelisted) // Nonced plugin install redirects (whitelisted).
if ( ! empty( $_GET['wc-install-plugin-redirect'] ) ) { if ( ! empty( $_GET['wc-install-plugin-redirect'] ) ) {
$plugin_slug = wc_clean( $_GET['wc-install-plugin-redirect'] ); $plugin_slug = wc_clean( wp_unslash( $_GET['wc-install-plugin-redirect'] ) );
if ( current_user_can( 'install_plugins' ) && in_array( $plugin_slug, array( 'woocommerce-gateway-stripe' ) ) ) { if ( current_user_can( 'install_plugins' ) && in_array( $plugin_slug, array( 'woocommerce-gateway-stripe' ) ) ) {
$nonce = wp_create_nonce( 'install-plugin_' . $plugin_slug ); $nonce = wp_create_nonce( 'install-plugin_' . $plugin_slug );
@ -153,15 +153,19 @@ class WC_Admin {
exit; exit;
} }
// Setup wizard redirect // Setup wizard redirect.
if ( get_transient( '_wc_activation_redirect' ) ) { if ( get_transient( '_wc_activation_redirect' ) ) {
delete_transient( '_wc_activation_redirect' ); delete_transient( '_wc_activation_redirect' );
if ( ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'wc-setup' ) ) ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_woocommerce' ) || apply_filters( 'woocommerce_prevent_automatic_wizard_redirect', false ) ) { if ( ( ! empty( $_GET['page'] ) &&
in_array( wp_unslash( $_GET['page'] ), array( 'wc-setup' ) ) ) ||
is_network_admin() || isset( $_GET['activate-multi'] ) ||
! current_user_can( 'manage_woocommerce' ) ||
apply_filters( 'woocommerce_prevent_automatic_wizard_redirect', false ) ) {
return; return;
} }
// If the user needs to install, send them to the setup wizard // If the user needs to install, send them to the setup wizard.
if ( WC_Admin_Notices::has_notice( 'install' ) ) { if ( WC_Admin_Notices::has_notice( 'install' ) ) {
wp_safe_redirect( admin_url( 'index.php?page=wc-setup' ) ); wp_safe_redirect( admin_url( 'index.php?page=wc-setup' ) );
exit; exit;
@ -175,7 +179,7 @@ class WC_Admin {
public function prevent_admin_access() { public function prevent_admin_access() {
$prevent_access = false; $prevent_access = false;
if ( apply_filters( 'woocommerce_disable_admin_bar', true ) && ! is_ajax() && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) { if ( apply_filters( 'woocommerce_disable_admin_bar', true ) && ! is_ajax() && basename( wp_unslash( $_SERVER['SCRIPT_FILENAME'] ) ) !== 'admin-post.php' ) {
$has_cap = false; $has_cap = false;
$access_caps = array( 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' ); $access_caps = array( 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' );
@ -203,28 +207,28 @@ class WC_Admin {
public function preview_emails() { public function preview_emails() {
if ( isset( $_GET['preview_woocommerce_mail'] ) ) { if ( isset( $_GET['preview_woocommerce_mail'] ) ) {
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'preview-mail' ) ) { if ( ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'], 'preview-mail' ) ) ) {
die( 'Security check' ); die( 'Security check' );
} }
// load the mailer class // load the mailer class.
$mailer = WC()->mailer(); $mailer = WC()->mailer();
// get the preview email subject // get the preview email subject.
$email_heading = __( 'HTML email template', 'woocommerce' ); $email_heading = __( 'HTML email template', 'woocommerce' );
// get the preview email content // get the preview email content.
ob_start(); ob_start();
include 'views/html-email-template-preview.php'; include 'views/html-email-template-preview.php';
$message = ob_get_clean(); $message = ob_get_clean();
// create a new email // create a new email.
$email = new WC_Email(); $email = new WC_Email();
// wrap the content with the email template and then add styles // wrap the content with the email template and then add styles.
$message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) ); $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
// print the preview email // print the preview email.
echo $message; echo $message;
exit; exit;
} }
@ -234,7 +238,7 @@ class WC_Admin {
* Change the admin footer text on WooCommerce admin pages. * Change the admin footer text on WooCommerce admin pages.
* *
* @since 2.3 * @since 2.3
* @param string $footer_text * @param string $footer_text text to be rendered in the footer.
* @return string * @return string
*/ */
public function admin_footer_text( $footer_text ) { public function admin_footer_text( $footer_text ) {
@ -249,7 +253,7 @@ class WC_Admin {
// Check to make sure we're on a WooCommerce admin page. // Check to make sure we're on a WooCommerce admin page.
if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages ) ) ) { if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages ) ) ) {
// Change the footer text // Change the footer text.
if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) { if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) {
$footer_text = sprintf( $footer_text = sprintf(
/* translators: 1: WooCommerce 2:: five stars */ /* translators: 1: WooCommerce 2:: five stars */