Merge pull request #22965 from woocommerce/fix/phpcs-errors
Tracks: Fix CodeSniffer errors
This commit is contained in:
commit
dd9c584af5
|
@ -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' ),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -536,22 +536,16 @@ class WC_Admin_Setup_Wizard {
|
||||||
public function wc_setup_store_setup_save() {
|
public function wc_setup_store_setup_save() {
|
||||||
check_admin_referer( 'wc-setup' );
|
check_admin_referer( 'wc-setup' );
|
||||||
|
|
||||||
// phpcs:disable WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.VIP.ValidatedSanitizedInput.InputNotValidated, WordPress.VIP.ValidatedSanitizedInput.MissingUnslash
|
$address = isset( $_POST['store_address'] ) ? wc_clean( wp_unslash( $_POST['store_address'] ) ) : '';
|
||||||
$address = sanitize_text_field( $_POST['store_address'] );
|
$address_2 = isset( $_POST['store_address_2'] ) ? wc_clean( wp_unslash( $_POST['store_address_2'] ) ) : '';
|
||||||
$address_2 = sanitize_text_field( $_POST['store_address_2'] );
|
$city = isset( $_POST['store_city'] ) ? wc_clean( wp_unslash( $_POST['store_city'] ) ) : '';
|
||||||
$city = sanitize_text_field( $_POST['store_city'] );
|
$country = isset( $_POST['store_country'] ) ? wc_clean( wp_unslash( $_POST['store_country'] ) ) : '';
|
||||||
$country = sanitize_text_field( $_POST['store_country'] );
|
$state = isset( $_POST['store_state'] ) ? wc_clean( wp_unslash( $_POST['store_state'] ) ) : '*';
|
||||||
$state = isset( $_POST['store_state'] ) ? sanitize_text_field( $_POST['store_state'] ) : false;
|
$postcode = isset( $_POST['store_postcode'] ) ? wc_clean( wp_unslash( $_POST['store_postcode'] ) ) : '';
|
||||||
$postcode = sanitize_text_field( $_POST['store_postcode'] );
|
$currency_code = isset( $_POST['currency_code'] ) ? wc_clean( wp_unslash( $_POST['currency_code'] ) ) : '';
|
||||||
$currency_code = sanitize_text_field( $_POST['currency_code'] );
|
$product_type = isset( $_POST['product_type'] ) ? wc_clean( wp_unslash( $_POST['product_type'] ) ) : '';
|
||||||
$product_type = sanitize_text_field( $_POST['product_type'] );
|
$sell_in_person = isset( $_POST['sell_in_person'] ) && ( 'yes' === wc_clean( wp_unslash( $_POST['sell_in_person'] ) ) );
|
||||||
$sell_in_person = isset( $_POST['sell_in_person'] ) && ( 'yes' === sanitize_text_field( $_POST['sell_in_person'] ) );
|
$tracking = isset( $_POST['wc_tracker_checkbox'] ) && ( 'yes' === wc_clean( wp_unslash( $_POST['wc_tracker_checkbox'] ) ) );
|
||||||
$tracking = isset( $_POST['wc_tracker_checkbox'] ) && ( 'yes' === sanitize_text_field( $_POST['wc_tracker_checkbox'] ) );
|
|
||||||
// phpcs:enable
|
|
||||||
|
|
||||||
if ( ! $state ) {
|
|
||||||
$state = '*';
|
|
||||||
}
|
|
||||||
|
|
||||||
update_option( 'woocommerce_store_address', $address );
|
update_option( 'woocommerce_store_address', $address );
|
||||||
update_option( 'woocommerce_store_address_2', $address_2 );
|
update_option( 'woocommerce_store_address_2', $address_2 );
|
||||||
|
@ -790,8 +784,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 +960,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 +979,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 +1021,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 +1871,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 MailChimp’s 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 MailChimp’s 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;
|
||||||
|
|
|
@ -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() && isset( $_SERVER['SCRIPT_FILENAME'] ) && basename( sanitize_text_field( 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,29 +207,31 @@ 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 ( ! ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( 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.
|
||||||
|
// phpcs:ignore WordPress.Security.EscapeOutput
|
||||||
echo $message;
|
echo $message;
|
||||||
|
// phpcs:enable
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +240,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 +255,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 */
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* WooCommerce Admin
|
||||||
|
*
|
||||||
|
* @class WC_Helper
|
||||||
|
* @package WooCommerce/Admin
|
||||||
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +18,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
class WC_Helper {
|
class WC_Helper {
|
||||||
/**
|
/**
|
||||||
* A log object returned by wc_get_logger().
|
* A log object returned by wc_get_logger().
|
||||||
|
*
|
||||||
|
* @var $log
|
||||||
*/
|
*/
|
||||||
public static $log;
|
public static $log;
|
||||||
|
|
||||||
|
@ -33,11 +42,11 @@ class WC_Helper {
|
||||||
add_action( 'woocommerce_helper_output', array( __CLASS__, 'render_helper_output' ) );
|
add_action( 'woocommerce_helper_output', array( __CLASS__, 'render_helper_output' ) );
|
||||||
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
|
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
|
||||||
|
|
||||||
// Attempt to toggle subscription state upon plugin activation/deactivation
|
// Attempt to toggle subscription state upon plugin activation/deactivation.
|
||||||
add_action( 'activated_plugin', array( __CLASS__, 'activated_plugin' ) );
|
add_action( 'activated_plugin', array( __CLASS__, 'activated_plugin' ) );
|
||||||
add_action( 'deactivated_plugin', array( __CLASS__, 'deactivated_plugin' ) );
|
add_action( 'deactivated_plugin', array( __CLASS__, 'deactivated_plugin' ) );
|
||||||
|
|
||||||
// Add some nags about extension updates
|
// Add some nags about extension updates.
|
||||||
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
|
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
|
||||||
|
|
||||||
do_action( 'woocommerce_helper_loaded' );
|
do_action( 'woocommerce_helper_loaded' );
|
||||||
|
@ -61,7 +70,8 @@ class WC_Helper {
|
||||||
'section' => 'helper',
|
'section' => 'helper',
|
||||||
'wc-helper-connect' => 1,
|
'wc-helper-connect' => 1,
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'connect' ),
|
'wc-helper-nonce' => wp_create_nonce( 'connect' ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
include self::get_view_filename( 'html-oauth-start.php' );
|
include self::get_view_filename( 'html-oauth-start.php' );
|
||||||
|
@ -73,7 +83,8 @@ class WC_Helper {
|
||||||
'section' => 'helper',
|
'section' => 'helper',
|
||||||
'wc-helper-disconnect' => 1,
|
'wc-helper-disconnect' => 1,
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'disconnect' ),
|
'wc-helper-nonce' => wp_create_nonce( 'disconnect' ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
$current_filter = self::get_current_filter();
|
$current_filter = self::get_current_filter();
|
||||||
|
@ -84,7 +95,8 @@ class WC_Helper {
|
||||||
'filter' => $current_filter,
|
'filter' => $current_filter,
|
||||||
'wc-helper-refresh' => 1,
|
'wc-helper-refresh' => 1,
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'refresh' ),
|
'wc-helper-nonce' => wp_create_nonce( 'refresh' ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
// Installed plugins and themes, with or without an active subscription.
|
// Installed plugins and themes, with or without an active subscription.
|
||||||
|
@ -108,7 +120,8 @@ class WC_Helper {
|
||||||
'wc-helper-product-key' => $subscription['product_key'],
|
'wc-helper-product-key' => $subscription['product_key'],
|
||||||
'wc-helper-product-id' => $subscription['product_id'],
|
'wc-helper-product-id' => $subscription['product_id'],
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'activate:' . $subscription['product_key'] ),
|
'wc-helper-nonce' => wp_create_nonce( 'activate:' . $subscription['product_key'] ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
$subscription['deactivate_url'] = add_query_arg(
|
$subscription['deactivate_url'] = add_query_arg(
|
||||||
|
@ -120,7 +133,8 @@ class WC_Helper {
|
||||||
'wc-helper-product-key' => $subscription['product_key'],
|
'wc-helper-product-key' => $subscription['product_key'],
|
||||||
'wc-helper-product-id' => $subscription['product_id'],
|
'wc-helper-product-id' => $subscription['product_id'],
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'deactivate:' . $subscription['product_key'] ),
|
'wc-helper-nonce' => wp_create_nonce( 'deactivate:' . $subscription['product_key'] ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
$subscription['local'] = array(
|
$subscription['local'] = array(
|
||||||
|
@ -284,6 +298,7 @@ class WC_Helper {
|
||||||
|
|
||||||
if ( $data['_has_update'] ) {
|
if ( $data['_has_update'] ) {
|
||||||
$action = array(
|
$action = array(
|
||||||
|
/* translators: %s: version number */
|
||||||
'message' => sprintf( __( 'Version %s is <strong>available</strong>. To enable this update you need to <strong>purchase</strong> a new subscription.', 'woocommerce' ), esc_html( $updates[ $data['_product_id'] ]['version'] ) ),
|
'message' => sprintf( __( 'Version %s is <strong>available</strong>. To enable this update you need to <strong>purchase</strong> a new subscription.', 'woocommerce' ), esc_html( $updates[ $data['_product_id'] ]['version'] ) ),
|
||||||
'button_label' => __( 'Purchase', 'woocommerce' ),
|
'button_label' => __( 'Purchase', 'woocommerce' ),
|
||||||
'button_url' => $data['_product_url'],
|
'button_url' => $data['_product_url'],
|
||||||
|
@ -314,11 +329,11 @@ class WC_Helper {
|
||||||
WC_Helper_Options::update( 'auth', $auth );
|
WC_Helper_Options::update( 'auth', $auth );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort alphabetically
|
// Sort alphabetically.
|
||||||
uasort( $subscriptions, array( __CLASS__, '_sort_by_product_name' ) );
|
uasort( $subscriptions, array( __CLASS__, '_sort_by_product_name' ) );
|
||||||
uasort( $no_subscriptions, array( __CLASS__, '_sort_by_name' ) );
|
uasort( $no_subscriptions, array( __CLASS__, '_sort_by_name' ) );
|
||||||
|
|
||||||
// Filters
|
// Filters.
|
||||||
self::get_filters_counts( $subscriptions ); // Warm it up.
|
self::get_filters_counts( $subscriptions ); // Warm it up.
|
||||||
self::_filter( $subscriptions, self::get_current_filter() );
|
self::_filter( $subscriptions, self::get_current_filter() );
|
||||||
|
|
||||||
|
@ -352,7 +367,7 @@ class WC_Helper {
|
||||||
*
|
*
|
||||||
* @param array $subscriptions The array of all available subscriptions.
|
* @param array $subscriptions The array of all available subscriptions.
|
||||||
*
|
*
|
||||||
* @return array Filter counts (filter => count)
|
* @return array Filter counts (filter => count).
|
||||||
*/
|
*/
|
||||||
public static function get_filters_counts( $subscriptions = null ) {
|
public static function get_filters_counts( $subscriptions = null ) {
|
||||||
static $filters;
|
static $filters;
|
||||||
|
@ -384,8 +399,8 @@ class WC_Helper {
|
||||||
$current_filter = 'all';
|
$current_filter = 'all';
|
||||||
$valid_filters = array_keys( self::get_filters() );
|
$valid_filters = array_keys( self::get_filters() );
|
||||||
|
|
||||||
if ( ! empty( $_GET['filter'] ) && in_array( $_GET['filter'], $valid_filters ) ) {
|
if ( ! empty( $_GET['filter'] ) && in_array( wp_unslash( $_GET['filter'] ), $valid_filters ) ) {
|
||||||
$current_filter = $_GET['filter'];
|
$current_filter = wp_unslash( $_GET['filter'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $current_filter;
|
return $current_filter;
|
||||||
|
@ -458,7 +473,7 @@ class WC_Helper {
|
||||||
* @return array Array pairs of message/type strings with notices.
|
* @return array Array pairs of message/type strings with notices.
|
||||||
*/
|
*/
|
||||||
private static function _get_return_notices() {
|
private static function _get_return_notices() {
|
||||||
$return_status = isset( $_GET['wc-helper-status'] ) ? $_GET['wc-helper-status'] : null;
|
$return_status = isset( $_GET['wc-helper-status'] ) ? wp_unslash( $_GET['wc-helper-status'] ) : null;
|
||||||
$notices = array();
|
$notices = array();
|
||||||
|
|
||||||
switch ( $return_status ) {
|
switch ( $return_status ) {
|
||||||
|
@ -505,13 +520,15 @@ class WC_Helper {
|
||||||
'wc-helper-deactivate-plugin' => 1,
|
'wc-helper-deactivate-plugin' => 1,
|
||||||
'wc-helper-product-id' => $subscription['product_id'],
|
'wc-helper-product-id' => $subscription['product_id'],
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'deactivate-plugin:' . $subscription['product_id'] ),
|
'wc-helper-nonce' => wp_create_nonce( 'deactivate-plugin:' . $subscription['product_id'] ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
/* translators: %1$s: product name, %2$s: deactivate url */
|
/* translators: %1$s: product name, %2$s: deactivate url */
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
__( 'Subscription for %1$s deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactivate the plugin as well.', 'woocommerce' ),
|
__( 'Subscription for %1$s deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactivate the plugin as well.', 'woocommerce' ),
|
||||||
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', esc_url( $deactivate_plugin_url )
|
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>',
|
||||||
|
esc_url( $deactivate_plugin_url )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +569,8 @@ class WC_Helper {
|
||||||
/* translators: %1$s: product name, %2$s: plugins screen url */
|
/* translators: %1$s: product name, %2$s: plugins screen url */
|
||||||
'message' => sprintf(
|
'message' => sprintf(
|
||||||
__( 'An error has occurred when deactivating the extension %1$s. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', 'woocommerce' ),
|
__( 'An error has occurred when deactivating the extension %1$s. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', 'woocommerce' ),
|
||||||
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', admin_url( 'plugins.php' )
|
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>',
|
||||||
|
admin_url( 'plugins.php' )
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
@ -640,11 +658,13 @@ class WC_Helper {
|
||||||
'section' => 'helper',
|
'section' => 'helper',
|
||||||
'wc-helper-return' => 1,
|
'wc-helper-return' => 1,
|
||||||
'wc-helper-nonce' => wp_create_nonce( 'connect' ),
|
'wc-helper-nonce' => wp_create_nonce( 'connect' ),
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
$request = WC_Helper_API::post(
|
$request = WC_Helper_API::post(
|
||||||
'oauth/request_token', array(
|
'oauth/request_token',
|
||||||
|
array(
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'home_url' => home_url(),
|
'home_url' => home_url(),
|
||||||
'redirect_uri' => $redirect_uri,
|
'redirect_uri' => $redirect_uri,
|
||||||
|
@ -675,7 +695,8 @@ class WC_Helper {
|
||||||
'home_url' => rawurlencode( home_url() ),
|
'home_url' => rawurlencode( home_url() ),
|
||||||
'redirect_uri' => rawurlencode( $redirect_uri ),
|
'redirect_uri' => rawurlencode( $redirect_uri ),
|
||||||
'secret' => rawurlencode( $secret ),
|
'secret' => rawurlencode( $secret ),
|
||||||
), WC_Helper_API::url( 'oauth/authorize' )
|
),
|
||||||
|
WC_Helper_API::url( 'oauth/authorize' )
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_redirect( esc_url_raw( $connect_url ) );
|
wp_redirect( esc_url_raw( $connect_url ) );
|
||||||
|
@ -709,7 +730,8 @@ class WC_Helper {
|
||||||
|
|
||||||
// Obtain an access token.
|
// Obtain an access token.
|
||||||
$request = WC_Helper_API::post(
|
$request = WC_Helper_API::post(
|
||||||
'oauth/access_token', array(
|
'oauth/access_token',
|
||||||
|
array(
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'request_token' => $_GET['request_token'],
|
'request_token' => $_GET['request_token'],
|
||||||
'home_url' => home_url(),
|
'home_url' => home_url(),
|
||||||
|
@ -731,7 +753,8 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
WC_Helper_Options::update(
|
WC_Helper_Options::update(
|
||||||
'auth', array(
|
'auth',
|
||||||
|
array(
|
||||||
'access_token' => $access_token['access_token'],
|
'access_token' => $access_token['access_token'],
|
||||||
'access_token_secret' => $access_token['access_token_secret'],
|
'access_token_secret' => $access_token['access_token_secret'],
|
||||||
'site_id' => $access_token['site_id'],
|
'site_id' => $access_token['site_id'],
|
||||||
|
@ -767,7 +790,8 @@ class WC_Helper {
|
||||||
'page' => 'wc-addons',
|
'page' => 'wc-addons',
|
||||||
'section' => 'helper',
|
'section' => 'helper',
|
||||||
'wc-helper-status' => 'helper-connected',
|
'wc-helper-status' => 'helper-connected',
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
die();
|
die();
|
||||||
|
@ -792,11 +816,13 @@ class WC_Helper {
|
||||||
'page' => 'wc-addons',
|
'page' => 'wc-addons',
|
||||||
'section' => 'helper',
|
'section' => 'helper',
|
||||||
'wc-helper-status' => 'helper-disconnected',
|
'wc-helper-status' => 'helper-disconnected',
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
WC_Helper_API::post(
|
WC_Helper_API::post(
|
||||||
'oauth/invalidate_token', array(
|
'oauth/invalidate_token',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -834,7 +860,8 @@ class WC_Helper {
|
||||||
'section' => 'helper',
|
'section' => 'helper',
|
||||||
'filter' => self::get_current_filter(),
|
'filter' => self::get_current_filter(),
|
||||||
'wc-helper-status' => 'helper-refreshed',
|
'wc-helper-status' => 'helper-refreshed',
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
self::_flush_authentication_cache();
|
self::_flush_authentication_cache();
|
||||||
|
@ -858,7 +885,8 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = WC_Helper_API::post(
|
$request = WC_Helper_API::post(
|
||||||
'activate', array(
|
'activate',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
'body' => json_encode(
|
'body' => json_encode(
|
||||||
array(
|
array(
|
||||||
|
@ -890,7 +918,8 @@ class WC_Helper {
|
||||||
'filter' => self::get_current_filter(),
|
'filter' => self::get_current_filter(),
|
||||||
'wc-helper-status' => $activated ? 'activate-success' : 'activate-error',
|
'wc-helper-status' => $activated ? 'activate-success' : 'activate-error',
|
||||||
'wc-helper-product-id' => $product_id,
|
'wc-helper-product-id' => $product_id,
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_safe_redirect( $redirect_uri );
|
wp_safe_redirect( $redirect_uri );
|
||||||
|
@ -910,7 +939,8 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = WC_Helper_API::post(
|
$request = WC_Helper_API::post(
|
||||||
'deactivate', array(
|
'deactivate',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
'body' => json_encode(
|
'body' => json_encode(
|
||||||
array(
|
array(
|
||||||
|
@ -934,7 +964,8 @@ class WC_Helper {
|
||||||
'filter' => self::get_current_filter(),
|
'filter' => self::get_current_filter(),
|
||||||
'wc-helper-status' => $deactivated ? 'deactivate-success' : 'deactivate-error',
|
'wc-helper-status' => $deactivated ? 'deactivate-success' : 'deactivate-error',
|
||||||
'wc-helper-product-id' => $product_id,
|
'wc-helper-product-id' => $product_id,
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_safe_redirect( $redirect_uri );
|
wp_safe_redirect( $redirect_uri );
|
||||||
|
@ -961,7 +992,8 @@ class WC_Helper {
|
||||||
array_merge(
|
array_merge(
|
||||||
self::get_local_woo_plugins(),
|
self::get_local_woo_plugins(),
|
||||||
self::get_local_woo_themes()
|
self::get_local_woo_themes()
|
||||||
), array( '_product_id' => $product_id )
|
),
|
||||||
|
array( '_product_id' => $product_id )
|
||||||
);
|
);
|
||||||
|
|
||||||
// Attempt to deactivate this plugin or theme.
|
// Attempt to deactivate this plugin or theme.
|
||||||
|
@ -981,7 +1013,8 @@ class WC_Helper {
|
||||||
'filter' => self::get_current_filter(),
|
'filter' => self::get_current_filter(),
|
||||||
'wc-helper-status' => $deactivated ? 'deactivate-plugin-success' : 'deactivate-plugin-error',
|
'wc-helper-status' => $deactivated ? 'deactivate-plugin-success' : 'deactivate-plugin-error',
|
||||||
'wc-helper-product-id' => $product_id,
|
'wc-helper-product-id' => $product_id,
|
||||||
), admin_url( 'admin.php' )
|
),
|
||||||
|
admin_url( 'admin.php' )
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_safe_redirect( $redirect_uri );
|
wp_safe_redirect( $redirect_uri );
|
||||||
|
@ -1000,7 +1033,8 @@ class WC_Helper {
|
||||||
array_merge(
|
array_merge(
|
||||||
self::get_local_woo_plugins(),
|
self::get_local_woo_plugins(),
|
||||||
self::get_local_woo_themes()
|
self::get_local_woo_themes()
|
||||||
), array( '_product_id' => $product_id )
|
),
|
||||||
|
array( '_product_id' => $product_id )
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( $local ) ) {
|
if ( ! empty( $local ) ) {
|
||||||
|
@ -1138,7 +1172,8 @@ class WC_Helper {
|
||||||
|
|
||||||
// Obtain the connected user info.
|
// Obtain the connected user info.
|
||||||
$request = WC_Helper_API::get(
|
$request = WC_Helper_API::get(
|
||||||
'subscriptions', array(
|
'subscriptions',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -1212,7 +1247,8 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = WC_Helper_API::post(
|
$request = WC_Helper_API::post(
|
||||||
'activate', array(
|
'activate',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
'body' => json_encode(
|
'body' => json_encode(
|
||||||
array(
|
array(
|
||||||
|
@ -1278,7 +1314,8 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = WC_Helper_API::post(
|
$request = WC_Helper_API::post(
|
||||||
'deactivate', array(
|
'deactivate',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
'body' => json_encode(
|
'body' => json_encode(
|
||||||
array(
|
array(
|
||||||
|
@ -1407,7 +1444,8 @@ class WC_Helper {
|
||||||
/* translators: %1$s: helper url, %2$d: number of extensions */
|
/* translators: %1$s: helper url, %2$d: number of extensions */
|
||||||
return sprintf(
|
return sprintf(
|
||||||
_n( 'Note: You currently have <a href="%1$s">%2$d paid extension</a> which should be updated first before updating WooCommerce.', 'Note: You currently have <a href="%1$s">%2$d paid extensions</a> which should be updated first before updating WooCommerce.', $available, 'woocommerce' ),
|
_n( 'Note: You currently have <a href="%1$s">%2$d paid extension</a> which should be updated first before updating WooCommerce.', 'Note: You currently have <a href="%1$s">%2$d paid extensions</a> which should be updated first before updating WooCommerce.', $available, 'woocommerce' ),
|
||||||
admin_url( 'admin.php?page=wc-addons§ion=helper' ), $available
|
admin_url( 'admin.php?page=wc-addons§ion=helper' ),
|
||||||
|
$available
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1448,7 +1486,8 @@ class WC_Helper {
|
||||||
*/
|
*/
|
||||||
public static function _flush_authentication_cache() {
|
public static function _flush_authentication_cache() {
|
||||||
$request = WC_Helper_API::get(
|
$request = WC_Helper_API::get(
|
||||||
'oauth/me', array(
|
'oauth/me',
|
||||||
|
array(
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -1463,7 +1502,8 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
WC_Helper_Options::update(
|
WC_Helper_Options::update(
|
||||||
'auth_user_data', array(
|
'auth_user_data',
|
||||||
|
array(
|
||||||
'name' => $user_data['name'],
|
'name' => $user_data['name'],
|
||||||
'email' => $user_data['email'],
|
'email' => $user_data['email'],
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
$erasure_text = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'tools.php?page=remove_personal_data' ) ), $erasure_text );
|
$erasure_text = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'tools.php?page=remove_personal_data' ) ), $erasure_text );
|
||||||
}
|
}
|
||||||
|
|
||||||
$tracking_info_text = sprintf( '<a href="%s" target="_blank">%s</a>','https://woocommerce.com/usage-tracking', esc_html__( 'Read more about what we collect', 'woocommerce' ) );
|
$tracking_info_text = sprintf( '<a href="%s" target="_blank">%s</a>', 'https://woocommerce.com/usage-tracking', esc_html__( 'Read more about what we collect', 'woocommerce' ) );
|
||||||
|
|
||||||
$settings = apply_filters(
|
$settings = apply_filters(
|
||||||
'woocommerce_' . $this->id . '_settings',
|
'woocommerce_' . $this->id . '_settings',
|
||||||
|
@ -243,6 +243,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Enable tracking', 'woocommerce' ),
|
'title' => __( 'Enable tracking', 'woocommerce' ),
|
||||||
'desc' => __( 'Allow usage of WooCommerce to be tracked', 'woocommerce' ),
|
'desc' => __( 'Allow usage of WooCommerce to be tracked', 'woocommerce' ),
|
||||||
|
/* Translators: %s URL to tracking info screen. */
|
||||||
'desc_tip' => sprintf( esc_html__( 'If you would rather opt-out, and do not check this box, we will not know this store exists and we will not collect any usage data. %s.', 'woocommerce' ), $tracking_info_text ),
|
'desc_tip' => sprintf( esc_html__( 'If you would rather opt-out, and do not check this box, we will not know this store exists and we will not collect any usage data. %s.', 'woocommerce' ), $tracking_info_text ),
|
||||||
'id' => 'woocommerce_allow_tracking',
|
'id' => 'woocommerce_allow_tracking',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
|
|
@ -60,16 +60,19 @@ class WC_Tracker {
|
||||||
update_option( 'woocommerce_tracker_last_send', time() );
|
update_option( 'woocommerce_tracker_last_send', time() );
|
||||||
|
|
||||||
$params = self::get_tracking_data();
|
$params = self::get_tracking_data();
|
||||||
wp_safe_remote_post( self::$api_url, array(
|
wp_safe_remote_post(
|
||||||
'method' => 'POST',
|
self::$api_url,
|
||||||
'timeout' => 45,
|
array(
|
||||||
'redirection' => 5,
|
'method' => 'POST',
|
||||||
'httpversion' => '1.0',
|
'timeout' => 45,
|
||||||
'blocking' => false,
|
'redirection' => 5,
|
||||||
'headers' => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url_raw( home_url( '/' ) ) ) . ';' ),
|
'httpversion' => '1.0',
|
||||||
'body' => wp_json_encode( $params ),
|
'blocking' => false,
|
||||||
'cookies' => array(),
|
'headers' => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url_raw( home_url( '/' ) ) ) . ';' ),
|
||||||
) );
|
'body' => wp_json_encode( $params ),
|
||||||
|
'cookies' => array(),
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,23 +90,23 @@ class WC_Tracker {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function get_tracking_data() {
|
private static function get_tracking_data() {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
// General site info.
|
// General site info.
|
||||||
$data['url'] = home_url();
|
$data['url'] = home_url();
|
||||||
$data['email'] = apply_filters( 'woocommerce_tracker_admin_email', get_option( 'admin_email' ) );
|
$data['email'] = apply_filters( 'woocommerce_tracker_admin_email', get_option( 'admin_email' ) );
|
||||||
$data['theme'] = self::get_theme_info();
|
$data['theme'] = self::get_theme_info();
|
||||||
|
|
||||||
// WordPress Info.
|
// WordPress Info.
|
||||||
$data['wp'] = self::get_wordpress_info();
|
$data['wp'] = self::get_wordpress_info();
|
||||||
|
|
||||||
// Server Info.
|
// Server Info.
|
||||||
$data['server'] = self::get_server_info();
|
$data['server'] = self::get_server_info();
|
||||||
|
|
||||||
// Plugin info.
|
// Plugin info.
|
||||||
$all_plugins = self::get_all_plugins();
|
$all_plugins = self::get_all_plugins();
|
||||||
$data['active_plugins'] = $all_plugins['active_plugins'];
|
$data['active_plugins'] = $all_plugins['active_plugins'];
|
||||||
$data['inactive_plugins'] = $all_plugins['inactive_plugins'];
|
$data['inactive_plugins'] = $all_plugins['inactive_plugins'];
|
||||||
|
|
||||||
// Jetpack & WooCommerce Connect.
|
// Jetpack & WooCommerce Connect.
|
||||||
$data['jetpack_version'] = defined( 'JETPACK__VERSION' ) ? JETPACK__VERSION : 'none';
|
$data['jetpack_version'] = defined( 'JETPACK__VERSION' ) ? JETPACK__VERSION : 'none';
|
||||||
|
@ -114,26 +117,26 @@ class WC_Tracker {
|
||||||
$data['helper_connected'] = self::get_helper_connected();
|
$data['helper_connected'] = self::get_helper_connected();
|
||||||
|
|
||||||
// Store count info.
|
// Store count info.
|
||||||
$data['users'] = self::get_user_counts();
|
$data['users'] = self::get_user_counts();
|
||||||
$data['products'] = self::get_product_counts();
|
$data['products'] = self::get_product_counts();
|
||||||
$data['orders'] = self::get_orders();
|
$data['orders'] = self::get_orders();
|
||||||
$data['reviews'] = self::get_review_counts();
|
$data['reviews'] = self::get_review_counts();
|
||||||
$data['categories'] = self::get_category_counts();
|
$data['categories'] = self::get_category_counts();
|
||||||
|
|
||||||
// Payment gateway info.
|
// Payment gateway info.
|
||||||
$data['gateways'] = self::get_active_payment_gateways();
|
$data['gateways'] = self::get_active_payment_gateways();
|
||||||
|
|
||||||
// Shipping method info.
|
// Shipping method info.
|
||||||
$data['shipping_methods'] = self::get_active_shipping_methods();
|
$data['shipping_methods'] = self::get_active_shipping_methods();
|
||||||
|
|
||||||
// Get all WooCommerce options info.
|
// Get all WooCommerce options info.
|
||||||
$data['settings'] = self::get_all_woocommerce_options_values();
|
$data['settings'] = self::get_all_woocommerce_options_values();
|
||||||
|
|
||||||
// Template overrides.
|
// Template overrides.
|
||||||
$data['template_overrides'] = self::get_all_template_overrides();
|
$data['template_overrides'] = self::get_all_template_overrides();
|
||||||
|
|
||||||
// Template overrides.
|
// Template overrides.
|
||||||
$data['admin_user_agents'] = self::get_admin_user_agents();
|
$data['admin_user_agents'] = self::get_admin_user_agents();
|
||||||
|
|
||||||
return apply_filters( 'woocommerce_tracker_data', $data );
|
return apply_filters( 'woocommerce_tracker_data', $data );
|
||||||
}
|
}
|
||||||
|
@ -197,20 +200,20 @@ class WC_Tracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( function_exists( 'ini_get' ) ) {
|
if ( function_exists( 'ini_get' ) ) {
|
||||||
$server_data['php_post_max_size'] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
|
$server_data['php_post_max_size'] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
|
||||||
$server_data['php_time_limt'] = ini_get( 'max_execution_time' );
|
$server_data['php_time_limt'] = ini_get( 'max_execution_time' );
|
||||||
$server_data['php_max_input_vars'] = ini_get( 'max_input_vars' );
|
$server_data['php_max_input_vars'] = ini_get( 'max_input_vars' );
|
||||||
$server_data['php_suhosin'] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
|
$server_data['php_suhosin'] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
|
||||||
}
|
}
|
||||||
|
|
||||||
$database_version = wc_get_server_database_version();
|
$database_version = wc_get_server_database_version();
|
||||||
$server_data['mysql_version'] = $database_version['number'];
|
$server_data['mysql_version'] = $database_version['number'];
|
||||||
|
|
||||||
$server_data['php_max_upload_size'] = size_format( wp_max_upload_size() );
|
$server_data['php_max_upload_size'] = size_format( wp_max_upload_size() );
|
||||||
$server_data['php_default_timezone'] = date_default_timezone_get();
|
$server_data['php_default_timezone'] = date_default_timezone_get();
|
||||||
$server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
|
$server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
|
||||||
$server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
|
$server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
|
||||||
$server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
|
$server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
|
||||||
|
|
||||||
return $server_data;
|
return $server_data;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +235,7 @@ class WC_Tracker {
|
||||||
|
|
||||||
foreach ( $plugins as $k => $v ) {
|
foreach ( $plugins as $k => $v ) {
|
||||||
// Take care of formatting the data how we want it.
|
// Take care of formatting the data how we want it.
|
||||||
$formatted = array();
|
$formatted = array();
|
||||||
$formatted['name'] = strip_tags( $v['Name'] );
|
$formatted['name'] = strip_tags( $v['Name'] );
|
||||||
if ( isset( $v['Version'] ) ) {
|
if ( isset( $v['Version'] ) ) {
|
||||||
$formatted['version'] = strip_tags( $v['Version'] );
|
$formatted['version'] = strip_tags( $v['Version'] );
|
||||||
|
@ -347,12 +350,15 @@ class WC_Tracker {
|
||||||
private static function get_review_counts() {
|
private static function get_review_counts() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$review_count = array();
|
$review_count = array();
|
||||||
$counts = $wpdb->get_results( "
|
$counts = $wpdb->get_results(
|
||||||
|
"
|
||||||
SELECT comment_approved, COUNT(*) AS num_reviews
|
SELECT comment_approved, COUNT(*) AS num_reviews
|
||||||
FROM {$wpdb->comments}
|
FROM {$wpdb->comments}
|
||||||
WHERE comment_type = 'review'
|
WHERE comment_type = 'review'
|
||||||
GROUP BY comment_approved
|
GROUP BY comment_approved
|
||||||
", ARRAY_A );
|
",
|
||||||
|
ARRAY_A
|
||||||
|
);
|
||||||
if ( $counts ) {
|
if ( $counts ) {
|
||||||
foreach ( $counts as $count ) {
|
foreach ( $counts as $count ) {
|
||||||
if ( 1 === $count['comment_approved'] ) {
|
if ( 1 === $count['comment_approved'] ) {
|
||||||
|
@ -451,7 +457,7 @@ class WC_Tracker {
|
||||||
$template_paths = apply_filters( 'woocommerce_template_overrides_scan_paths', array( 'WooCommerce' => WC()->plugin_path() . '/templates/' ) );
|
$template_paths = apply_filters( 'woocommerce_template_overrides_scan_paths', array( 'WooCommerce' => WC()->plugin_path() . '/templates/' ) );
|
||||||
$scanned_files = array();
|
$scanned_files = array();
|
||||||
|
|
||||||
require_once( WC()->plugin_path() . '/includes/admin/class-wc-admin-status.php' );
|
require_once WC()->plugin_path() . '/includes/admin/class-wc-admin-status.php';
|
||||||
|
|
||||||
foreach ( $template_paths as $plugin_name => $template_path ) {
|
foreach ( $template_paths as $plugin_name => $template_path ) {
|
||||||
$scanned_files[ $plugin_name ] = WC_Admin_Status::scan_template_files( $template_path );
|
$scanned_files[ $plugin_name ] = WC_Admin_Status::scan_template_files( $template_path );
|
||||||
|
@ -496,7 +502,8 @@ class WC_Tracker {
|
||||||
public static function get_order_totals() {
|
public static function get_order_totals() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$gross_total = $wpdb->get_var( "
|
$gross_total = $wpdb->get_var(
|
||||||
|
"
|
||||||
SELECT
|
SELECT
|
||||||
SUM( order_meta.meta_value ) AS 'gross_total'
|
SUM( order_meta.meta_value ) AS 'gross_total'
|
||||||
FROM {$wpdb->prefix}posts AS orders
|
FROM {$wpdb->prefix}posts AS orders
|
||||||
|
@ -504,7 +511,8 @@ class WC_Tracker {
|
||||||
WHERE order_meta.meta_key = '_order_total'
|
WHERE order_meta.meta_key = '_order_total'
|
||||||
AND orders.post_status = 'wc-completed'
|
AND orders.post_status = 'wc-completed'
|
||||||
GROUP BY order_meta.meta_key
|
GROUP BY order_meta.meta_key
|
||||||
" );
|
"
|
||||||
|
);
|
||||||
|
|
||||||
if ( is_null( $gross_total ) ) {
|
if ( is_null( $gross_total ) ) {
|
||||||
$gross_total = 0;
|
$gross_total = 0;
|
||||||
|
@ -523,13 +531,16 @@ class WC_Tracker {
|
||||||
private static function get_order_dates() {
|
private static function get_order_dates() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$min_max = $wpdb->get_row( "
|
$min_max = $wpdb->get_row(
|
||||||
|
"
|
||||||
SELECT
|
SELECT
|
||||||
MIN( post_date_gmt ) as 'first', MAX( post_date_gmt ) as 'last'
|
MIN( post_date_gmt ) as 'first', MAX( post_date_gmt ) as 'last'
|
||||||
FROM {$wpdb->prefix}posts
|
FROM {$wpdb->prefix}posts
|
||||||
WHERE post_type = 'shop_order'
|
WHERE post_type = 'shop_order'
|
||||||
AND post_status = 'wc-completed'
|
AND post_status = 'wc-completed'
|
||||||
", ARRAY_A );
|
",
|
||||||
|
ARRAY_A
|
||||||
|
);
|
||||||
|
|
||||||
if ( is_null( $min_max ) ) {
|
if ( is_null( $min_max ) ) {
|
||||||
$min_max = array(
|
$min_max = array(
|
||||||
|
|
Loading…
Reference in New Issue