Merge branch 'master' into fix/includes-cli-phpcs-violations

This commit is contained in:
Rodrigo Primo 2018-03-06 10:32:56 -03:00
commit 95b14b3674
159 changed files with 7998 additions and 6885 deletions

File diff suppressed because one or more lines are too long

165
assets/css/jquery-ui.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -334,6 +334,18 @@ body {
position: relative; position: relative;
border-bottom: 4px solid #ccc; border-bottom: 4px solid #ccc;
line-height: 1.4em; line-height: 1.4em;
a {
color: #a16696;
text-decoration: none;
padding: 1.5em;
margin: -1.5em;
position: relative;
z-index: 1;
&:hover, &:focus {
color: #111;
text-decoration: underline;
}
}
} }
li::before { li::before {
content: ''; content: '';
@ -351,6 +363,7 @@ body {
li.active { li.active {
border-color: #a16696; border-color: #a16696;
color: #a16696; color: #a16696;
font-weight: bold;
&::before { &::before {
border-color: #a16696; border-color: #a16696;
} }
@ -367,6 +380,7 @@ body {
.wc-setup .wc-setup-actions { .wc-setup .wc-setup-actions {
overflow: hidden; overflow: hidden;
margin: 20px 0 0; margin: 20px 0 0;
position: relative;
.button { .button {
font-size: 1.25em; font-size: 1.25em;
padding: 0.5em 1em; padding: 0.5em 1em;
@ -400,7 +414,7 @@ body {
margin-top: 0; margin-top: 0;
} }
.wc-return-to-dashboard { .wc-setup-footer-links {
font-size: 0.85em; font-size: 0.85em;
color: #b5b5b5; color: #b5b5b5;
margin: 1.18em 0; margin: 1.18em 0;
@ -972,7 +986,7 @@ h3.jetpack-reasons {
align-items: center; align-items: center;
.button { .button {
margin: 1em; margin: 1em 1.5em;
} }
} }
@ -996,6 +1010,26 @@ h3.jetpack-reasons {
font-weight: 600; font-weight: 600;
} }
} }
.wc-wizard-additional-steps {
border-top: 1px solid #eee;
.wc-wizard-next-step-description {
margin-bottom: 0;
}
.wc-setup-actions {
margin: 0 0 1.5em 0;
.button {
font-size: 15px;
margin: 1em 0 1em 1.5em;
}
.button::last-child {
margin-right: 1.5em;
}
}
}
} }
p.next-steps-help-text { p.next-steps-help-text {

View File

@ -4,15 +4,11 @@
* *
* Returns an array of continents. * Returns an array of continents.
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.5.0
* @package WooCommerce/i18n
* @version 2.5.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
return array( return array(
'AF' => array( 'AF' => array(

View File

@ -4,15 +4,11 @@
* *
* Returns an array of countries and codes. * Returns an array of countries and codes.
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.5.0
* @package WooCommerce/i18n
* @version 2.5.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
return array( return array(
'AF' => __( 'Afghanistan', 'woocommerce' ), 'AF' => __( 'Afghanistan', 'woocommerce' ),

View File

@ -1,7 +1,12 @@
<?php <?php
if ( ! defined( 'ABSPATH' ) ) { /**
exit; * Locales information
} *
* @package WooCommerce/i18n
* @version 3.4.0
*/
defined( 'ABSPATH' ) || exit;
return array( return array(
'AU' => array( 'AU' => array(
@ -54,7 +59,7 @@ return array(
'dimension_unit' => 'cm', 'dimension_unit' => 'cm',
'tax_rates' => array( 'tax_rates' => array(
'' => array( '' => array(
array( array(
'country' => 'BE', 'country' => 'BE',
'state' => '', 'state' => '',
'rate' => '21.0000', 'rate' => '21.0000',
@ -123,7 +128,7 @@ return array(
'priority' => 2, 'priority' => 2,
), ),
), ),
'*' => array( '*' => array(
array( array(
'country' => 'CA', 'country' => 'CA',
'state' => 'ON', 'state' => 'ON',
@ -300,19 +305,19 @@ return array(
), ),
'GB' => array( 'GB' => array(
'currency_code' => 'GBP', 'currency_code' => 'GBP',
'currency_pos' => 'left', 'currency_pos' => 'left',
'thousand_sep' => ',', 'thousand_sep' => ',',
'decimal_sep' => '.', 'decimal_sep' => '.',
'num_decimals' => 2, 'num_decimals' => 2,
'weight_unit' => 'kg', 'weight_unit' => 'kg',
'dimension_unit' => 'cm', 'dimension_unit' => 'cm',
'tax_rates' => array( 'tax_rates' => array(
'' => array( '' => array(
array( array(
'country' => 'GB', 'country' => 'GB',
'state' => '', 'state' => '',
'rate' => '20.0000', 'rate' => '20.0000',
'name' => 'VAT', 'name' => 'VAT',
'shipping' => true, 'shipping' => true,
), ),
), ),
@ -468,7 +473,7 @@ return array(
'dimension_unit' => 'cm', 'dimension_unit' => 'cm',
'tax_rates' => array( 'tax_rates' => array(
'' => array( '' => array(
array( array(
'country' => 'PL', 'country' => 'PL',
'state' => '', 'state' => '',
'rate' => '23.0000', 'rate' => '23.0000',
@ -540,13 +545,13 @@ return array(
), ),
'US' => array( 'US' => array(
'currency_code' => 'USD', 'currency_code' => 'USD',
'currency_pos' => 'left', 'currency_pos' => 'left',
'thousand_sep' => ',', 'thousand_sep' => ',',
'decimal_sep' => '.', 'decimal_sep' => '.',
'num_decimals' => 2, 'num_decimals' => 2,
'weight_unit' => 'oz', 'weight_unit' => 'oz',
'dimension_unit' => 'in', 'dimension_unit' => 'in',
'tax_rates' => array( 'tax_rates' => array(
'AL' => array( 'AL' => array(
array( array(
'country' => 'US', 'country' => 'US',

View File

@ -2,16 +2,13 @@
/** /**
* Angola states * Angola states
* *
* @author Marcio Zebedeu * @package WooCommerce/i18n
* @category i18n * @version 1.0.0
* @package WooCommerce/i18n
* @version 1.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['AO'] = array( $states['AO'] = array(
'BGO' => __( 'Bengo', 'woocommerce' ), 'BGO' => __( 'Bengo', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Argentinian provinces * Argentinian provinces
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.4.0
* @package WooCommerce/i18n
* @version 2.4.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['AR'] = array( $states['AR'] = array(
'C' => __( 'Ciudad Aut&oacute;noma de Buenos Aires', 'woocommerce' ), 'C' => __( 'Ciudad Aut&oacute;noma de Buenos Aires', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Australian states * Australian states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['AU'] = array( $states['AU'] = array(
'ACT' => __( 'Australian Capital Territory', 'woocommerce' ), 'ACT' => __( 'Australian Capital Territory', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Bangladeshi states (districts) * Bangladeshi states (districts)
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['BD'] = array( $states['BD'] = array(
'BAG' => __( 'Bagerhat', 'woocommerce' ), 'BAG' => __( 'Bagerhat', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Bulgarian states * Bulgarian states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['BG'] = array( $states['BG'] = array(
'BG-01' => __( 'Blagoevgrad', 'woocommerce' ), 'BG-01' => __( 'Blagoevgrad', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Bolivian states * Bolivian states
* *
* @author Roman Random * @package WooCommerce/i18n
* @category i18n * @version 3.1.0
* @package WooCommerce/i18n
* @version 3.1.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['BO'] = array( $states['BO'] = array(
'B' => __( 'Chuquisaca', 'woocommerce' ), 'B' => __( 'Chuquisaca', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Brazillian states * Brazillian states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['BR'] = array( $states['BR'] = array(
'AC' => __( 'Acre', 'woocommerce' ), 'AC' => __( 'Acre', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Canadian states * Canadian states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['CA'] = array( $states['CA'] = array(
'AB' => __( 'Alberta', 'woocommerce' ), 'AB' => __( 'Alberta', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Cantons of Switzerland * Cantons of Switzerland
* *
* @author WooCommerce
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 3.2.0 * @version 3.2.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['CH'] = array( $states['CH'] = array(
'AG' => __( 'Aargau', 'woocommerce' ), 'AG' => __( 'Aargau', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Chinese states * Chinese states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['CN'] = array( $states['CN'] = array(
'CN1' => __( 'Yunnan / &#20113;&#21335;', 'woocommerce' ), 'CN1' => __( 'Yunnan / &#20113;&#21335;', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Spain states * Spain states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.11
* @package WooCommerce/i18n
* @version 2.0.11
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['ES'] = array( $states['ES'] = array(
'C' => __( 'A Coru&ntilde;a', 'woocommerce' ), 'C' => __( 'A Coru&ntilde;a', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Greek Regions * Greek Regions
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.3.0
* @package WooCommerce/i18n
* @version 2.3.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['GR'] = array( $states['GR'] = array(
'I' => __( 'Αττική', 'woocommerce' ), 'I' => __( 'Αττική', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Hong Kong states * Hong Kong states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['HK'] = array( $states['HK'] = array(
'HONG KONG' => __( 'Hong Kong Island', 'woocommerce' ), 'HONG KONG' => __( 'Hong Kong Island', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Hungary states * Hungary states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['HU'] = array( $states['HU'] = array(
'BK' => __( 'Bács-Kiskun', 'woocommerce' ), 'BK' => __( 'Bács-Kiskun', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Indonesia Provinces * Indonesia Provinces
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['ID'] = array( $states['ID'] = array(
'AC' => __( 'Daerah Istimewa Aceh', 'woocommerce' ), 'AC' => __( 'Daerah Istimewa Aceh', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Republic of Ireland * Republic of Ireland
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 3.0.0
* @package WooCommerce/i18n
* @version 3.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['IE'] = array( $states['IE'] = array(
'CW' => __( 'Carlow', 'woocommerce' ), 'CW' => __( 'Carlow', 'woocommerce' ),
@ -39,5 +36,5 @@ $states['IE'] = array(
'WD' => __( 'Waterford', 'woocommerce' ), 'WD' => __( 'Waterford', 'woocommerce' ),
'WH' => __( 'Westmeath', 'woocommerce' ), 'WH' => __( 'Westmeath', 'woocommerce' ),
'WX' => __( 'Wexford', 'woocommerce' ), 'WX' => __( 'Wexford', 'woocommerce' ),
'WW' => __( 'Wicklow', 'woocommerce' ) 'WW' => __( 'Wicklow', 'woocommerce' ),
); );

View File

@ -2,16 +2,13 @@
/** /**
* Indian states * Indian states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['IN'] = array( $states['IN'] = array(
'AP' => __( 'Andhra Pradesh', 'woocommerce' ), 'AP' => __( 'Andhra Pradesh', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Iran States * Iran States
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.2.3
* @package WooCommerce/i18n
* @version 2.2.3
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['IR'] = array( $states['IR'] = array(
'KHZ' => __( 'Khuzestan (خوزستان)', 'woocommerce' ), 'KHZ' => __( 'Khuzestan (خوزستان)', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Italy Provinces * Italy Provinces
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['IT'] = array( $states['IT'] = array(
'AG' => __( 'Agrigento', 'woocommerce' ), 'AG' => __( 'Agrigento', 'woocommerce' ),

View File

@ -2,19 +2,16 @@
/** /**
* Japan States * Japan States
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
* *
* English notation of prefectures conform to the notation of Japan Post. * English notation of prefectures conform to the notation of Japan Post.
* The suffix corresponds with the Japanese translation file. * The suffix corresponds with the Japanese translation file.
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['JP'] = array( $states['JP'] = array(
'JP01' => __( 'Hokkaido', 'woocommerce' ), 'JP01' => __( 'Hokkaido', 'woocommerce' ),

View File

@ -14,9 +14,7 @@
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['MD'] = array( $states['MD'] = array(
'C' => __( 'Chi&#537;in&#259;u', 'woocommerce' ), 'C' => __( 'Chi&#537;in&#259;u', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Mexico States * Mexico States
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.2.9
* @package WooCommerce/i18n
* @version 2.2.9
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['MX'] = array( $states['MX'] = array(
'DF' => __( 'Ciudad de M&eacute;xico', 'woocommerce' ), 'DF' => __( 'Ciudad de M&eacute;xico', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Malaysian states * Malaysian states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['MY'] = array( $states['MY'] = array(
'JHR' => __( 'Johor', 'woocommerce' ), 'JHR' => __( 'Johor', 'woocommerce' ),

View File

@ -2,17 +2,13 @@
/** /**
* Nigerian provinces * Nigerian provinces
* *
* @author hoshomoh * @package WooCommerce/i18n
* @category i18n * @version 3.0.0
* @package WooCommerce/i18n
* @version 3.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['NG'] = array( $states['NG'] = array(
'AB' => __( 'Abia', 'woocommerce' ), 'AB' => __( 'Abia', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Nepal states (Zones) * Nepal states (Zones)
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.2.5
* @package WooCommerce/i18n
* @version 2.2.5
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['NP'] = array( $states['NP'] = array(
'BAG' => __( 'Bagmati', 'woocommerce' ), 'BAG' => __( 'Bagmati', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* New Zealand States * New Zealand States
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.3.0
* @package WooCommerce/i18n
* @version 2.3.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['NZ'] = array( $states['NZ'] = array(
'NL' => __( 'Northland', 'woocommerce' ), 'NL' => __( 'Northland', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Peru states * Peru states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.1.0
* @package WooCommerce/i18n
* @version 2.1.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['PE'] = array( $states['PE'] = array(
'CAL' => __( 'El Callao', 'woocommerce' ), 'CAL' => __( 'El Callao', 'woocommerce' ),

View File

@ -2,15 +2,13 @@
/** /**
* Philippines Provinces * Philippines Provinces
* *
* @category i18n * @package WooCommerce/i18n
* @package WooCommerce/i18n * @version 2.4.0
* @version 2.4.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['PH'] = array( $states['PH'] = array(
'ABR' => __( 'Abra', 'woocommerce' ), 'ABR' => __( 'Abra', 'woocommerce' ),
@ -42,7 +40,7 @@ $states['PH'] = array(
'NCO' => __( 'Cotabato', 'woocommerce' ), 'NCO' => __( 'Cotabato', 'woocommerce' ),
'DAV' => __( 'Davao del Norte', 'woocommerce' ), 'DAV' => __( 'Davao del Norte', 'woocommerce' ),
'DAS' => __( 'Davao del Sur', 'woocommerce' ), 'DAS' => __( 'Davao del Sur', 'woocommerce' ),
'DAC' => __( 'Davao Occidental', 'woocommerce' ), // TODO: Needs to be updated when ISO code is assigned 'DAC' => __( 'Davao Occidental', 'woocommerce' ), // TODO: Needs to be updated when ISO code is assigned.
'DAO' => __( 'Davao Oriental', 'woocommerce' ), 'DAO' => __( 'Davao Oriental', 'woocommerce' ),
'DIN' => __( 'Dinagat Islands', 'woocommerce' ), 'DIN' => __( 'Dinagat Islands', 'woocommerce' ),
'EAS' => __( 'Eastern Samar', 'woocommerce' ), 'EAS' => __( 'Eastern Samar', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* Pakistan's states * Pakistan's states
* *
* @author WooCommerce * @package WooCommerce/i18n
* @category i18n * @version 3.0.0
* @package WooCommerce/i18n
* @version 3.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['PK'] = array( $states['PK'] = array(
'JK' => __( 'Azad Kashmir', 'woocommerce' ), 'JK' => __( 'Azad Kashmir', 'woocommerce' ),

View File

@ -11,9 +11,7 @@
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['RO'] = array( $states['RO'] = array(
'AB' => __( 'Alba', 'woocommerce' ), 'AB' => __( 'Alba', 'woocommerce' ),

View File

@ -2,93 +2,90 @@
/** /**
* Thailand states * Thailand states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 3.4.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['TH'] = array( $states['TH'] = array(
'TH-37' => __( 'Amnat Charoen (&#3629;&#3635;&#3609;&#3634;&#3592;&#3648;&#3592;&#3619;&#3636;&#3597;)', 'woocommerce' ), 'TH-37' => __( 'Amnat Charoen', 'woocommerce' ),
'TH-15' => __( 'Ang Thong (&#3629;&#3656;&#3634;&#3591;&#3607;&#3629;&#3591;)', 'woocommerce' ), 'TH-15' => __( 'Ang Thong', 'woocommerce' ),
'TH-14' => __( 'Ayutthaya (&#3614;&#3619;&#3632;&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3629;&#3618;&#3640;&#3608;&#3618;&#3634;)', 'woocommerce' ), 'TH-14' => __( 'Ayutthaya', 'woocommerce' ),
'TH-10' => __( 'Bangkok (&#3585;&#3619;&#3640;&#3591;&#3648;&#3607;&#3614;&#3617;&#3627;&#3634;&#3609;&#3588;&#3619;)', 'woocommerce' ), 'TH-10' => __( 'Bangkok', 'woocommerce' ),
'TH-38' => __( 'Bueng Kan (&#3610;&#3638;&#3591;&#3585;&#3634;&#3628;)', 'woocommerce' ), 'TH-38' => __( 'Bueng Kan', 'woocommerce' ),
'TH-31' => __( 'Buri Ram (&#3610;&#3640;&#3619;&#3637;&#3619;&#3633;&#3617;&#3618;&#3660;)', 'woocommerce' ), 'TH-31' => __( 'Buri Ram', 'woocommerce' ),
'TH-24' => __( 'Chachoengsao (&#3593;&#3632;&#3648;&#3594;&#3636;&#3591;&#3648;&#3607;&#3619;&#3634;)', 'woocommerce' ), 'TH-24' => __( 'Chachoengsao', 'woocommerce' ),
'TH-18' => __( 'Chai Nat (&#3594;&#3633;&#3618;&#3609;&#3634;&#3607;)', 'woocommerce' ), 'TH-18' => __( 'Chai Nat', 'woocommerce' ),
'TH-36' => __( 'Chaiyaphum (&#3594;&#3633;&#3618;&#3616;&#3641;&#3617;&#3636;)', 'woocommerce' ), 'TH-36' => __( 'Chaiyaphum', 'woocommerce' ),
'TH-22' => __( 'Chanthaburi (&#3592;&#3633;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-22' => __( 'Chanthaburi', 'woocommerce' ),
'TH-50' => __( 'Chiang Mai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3651;&#3627;&#3617;&#3656;)', 'woocommerce' ), 'TH-50' => __( 'Chiang Mai', 'woocommerce' ),
'TH-57' => __( 'Chiang Rai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3619;&#3634;&#3618;)', 'woocommerce' ), 'TH-57' => __( 'Chiang Rai', 'woocommerce' ),
'TH-20' => __( 'Chonburi (&#3594;&#3621;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-20' => __( 'Chonburi', 'woocommerce' ),
'TH-86' => __( 'Chumphon (&#3594;&#3640;&#3617;&#3614;&#3619;)', 'woocommerce' ), 'TH-86' => __( 'Chumphon', 'woocommerce' ),
'TH-46' => __( 'Kalasin (&#3585;&#3634;&#3628;&#3626;&#3636;&#3609;&#3608;&#3640;&#3660;)', 'woocommerce' ), 'TH-46' => __( 'Kalasin', 'woocommerce' ),
'TH-62' => __( 'Kamphaeng Phet (&#3585;&#3635;&#3649;&#3614;&#3591;&#3648;&#3614;&#3594;&#3619;)', 'woocommerce' ), 'TH-62' => __( 'Kamphaeng Phet', 'woocommerce' ),
'TH-71' => __( 'Kanchanaburi (&#3585;&#3634;&#3597;&#3592;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-71' => __( 'Kanchanaburi', 'woocommerce' ),
'TH-40' => __( 'Khon Kaen (&#3586;&#3629;&#3609;&#3649;&#3585;&#3656;&#3609;)', 'woocommerce' ), 'TH-40' => __( 'Khon Kaen', 'woocommerce' ),
'TH-81' => __( 'Krabi (&#3585;&#3619;&#3632;&#3610;&#3637;&#3656;)', 'woocommerce' ), 'TH-81' => __( 'Krabi', 'woocommerce' ),
'TH-52' => __( 'Lampang (&#3621;&#3635;&#3611;&#3634;&#3591;)', 'woocommerce' ), 'TH-52' => __( 'Lampang', 'woocommerce' ),
'TH-51' => __( 'Lamphun (&#3621;&#3635;&#3614;&#3641;&#3609;)', 'woocommerce' ), 'TH-51' => __( 'Lamphun', 'woocommerce' ),
'TH-42' => __( 'Loei (&#3648;&#3621;&#3618;)', 'woocommerce' ), 'TH-42' => __( 'Loei', 'woocommerce' ),
'TH-16' => __( 'Lopburi (&#3621;&#3614;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-16' => __( 'Lopburi', 'woocommerce' ),
'TH-58' => __( 'Mae Hong Son (&#3649;&#3617;&#3656;&#3630;&#3656;&#3629;&#3591;&#3626;&#3629;&#3609;)', 'woocommerce' ), 'TH-58' => __( 'Mae Hong Son', 'woocommerce' ),
'TH-44' => __( 'Maha Sarakham (&#3617;&#3627;&#3634;&#3626;&#3634;&#3619;&#3588;&#3634;&#3617;)', 'woocommerce' ), 'TH-44' => __( 'Maha Sarakham', 'woocommerce' ),
'TH-49' => __( 'Mukdahan (&#3617;&#3640;&#3585;&#3604;&#3634;&#3627;&#3634;&#3619;)', 'woocommerce' ), 'TH-49' => __( 'Mukdahan', 'woocommerce' ),
'TH-26' => __( 'Nakhon Nayok (&#3609;&#3588;&#3619;&#3609;&#3634;&#3618;&#3585;)', 'woocommerce' ), 'TH-26' => __( 'Nakhon Nayok', 'woocommerce' ),
'TH-73' => __( 'Nakhon Pathom (&#3609;&#3588;&#3619;&#3611;&#3600;&#3617;)', 'woocommerce' ), 'TH-73' => __( 'Nakhon Pathom', 'woocommerce' ),
'TH-48' => __( 'Nakhon Phanom (&#3609;&#3588;&#3619;&#3614;&#3609;&#3617;)', 'woocommerce' ), 'TH-48' => __( 'Nakhon Phanom', 'woocommerce' ),
'TH-30' => __( 'Nakhon Ratchasima (&#3609;&#3588;&#3619;&#3619;&#3634;&#3594;&#3626;&#3637;&#3617;&#3634;)', 'woocommerce' ), 'TH-30' => __( 'Nakhon Ratchasima', 'woocommerce' ),
'TH-60' => __( 'Nakhon Sawan (&#3609;&#3588;&#3619;&#3626;&#3623;&#3619;&#3619;&#3588;&#3660;)', 'woocommerce' ), 'TH-60' => __( 'Nakhon Sawan', 'woocommerce' ),
'TH-80' => __( 'Nakhon Si Thammarat (&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3608;&#3619;&#3619;&#3617;&#3619;&#3634;&#3594;)', 'woocommerce' ), 'TH-80' => __( 'Nakhon Si Thammarat', 'woocommerce' ),
'TH-55' => __( 'Nan (&#3609;&#3656;&#3634;&#3609;)', 'woocommerce' ), 'TH-55' => __( 'Nan', 'woocommerce' ),
'TH-96' => __( 'Narathiwat (&#3609;&#3619;&#3634;&#3608;&#3636;&#3623;&#3634;&#3626;)', 'woocommerce' ), 'TH-96' => __( 'Narathiwat', 'woocommerce' ),
'TH-39' => __( 'Nong Bua Lam Phu (&#3627;&#3609;&#3629;&#3591;&#3610;&#3633;&#3623;&#3621;&#3635;&#3616;&#3641;)', 'woocommerce' ), 'TH-39' => __( 'Nong Bua Lam Phu', 'woocommerce' ),
'TH-43' => __( 'Nong Khai (&#3627;&#3609;&#3629;&#3591;&#3588;&#3634;&#3618;)', 'woocommerce' ), 'TH-43' => __( 'Nong Khai', 'woocommerce' ),
'TH-12' => __( 'Nonthaburi (&#3609;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-12' => __( 'Nonthaburi', 'woocommerce' ),
'TH-13' => __( 'Pathum Thani (&#3611;&#3607;&#3640;&#3617;&#3608;&#3634;&#3609;&#3637;)', 'woocommerce' ), 'TH-13' => __( 'Pathum Thani', 'woocommerce' ),
'TH-94' => __( 'Pattani (&#3611;&#3633;&#3605;&#3605;&#3634;&#3609;&#3637;)', 'woocommerce' ), 'TH-94' => __( 'Pattani', 'woocommerce' ),
'TH-82' => __( 'Phang Nga (&#3614;&#3633;&#3591;&#3591;&#3634;)', 'woocommerce' ), 'TH-82' => __( 'Phang Nga', 'woocommerce' ),
'TH-93' => __( 'Phatthalung (&#3614;&#3633;&#3607;&#3621;&#3640;&#3591;)', 'woocommerce' ), 'TH-93' => __( 'Phatthalung', 'woocommerce' ),
'TH-56' => __( 'Phayao (&#3614;&#3632;&#3648;&#3618;&#3634;)', 'woocommerce' ), 'TH-56' => __( 'Phayao', 'woocommerce' ),
'TH-67' => __( 'Phetchabun (&#3648;&#3614;&#3594;&#3619;&#3610;&#3641;&#3619;&#3603;&#3660;)', 'woocommerce' ), 'TH-67' => __( 'Phetchabun', 'woocommerce' ),
'TH-76' => __( 'Phetchaburi (&#3648;&#3614;&#3594;&#3619;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-76' => __( 'Phetchaburi', 'woocommerce' ),
'TH-66' => __( 'Phichit (&#3614;&#3636;&#3592;&#3636;&#3605;&#3619;)', 'woocommerce' ), 'TH-66' => __( 'Phichit', 'woocommerce' ),
'TH-65' => __( 'Phitsanulok (&#3614;&#3636;&#3625;&#3603;&#3640;&#3650;&#3621;&#3585;)', 'woocommerce' ), 'TH-65' => __( 'Phitsanulok', 'woocommerce' ),
'TH-54' => __( 'Phrae (&#3649;&#3614;&#3619;&#3656;)', 'woocommerce' ), 'TH-54' => __( 'Phrae', 'woocommerce' ),
'TH-83' => __( 'Phuket (&#3616;&#3641;&#3648;&#3585;&#3655;&#3605;)', 'woocommerce' ), 'TH-83' => __( 'Phuket', 'woocommerce' ),
'TH-25' => __( 'Prachin Buri (&#3611;&#3619;&#3634;&#3592;&#3637;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-25' => __( 'Prachin Buri', 'woocommerce' ),
'TH-77' => __( 'Prachuap Khiri Khan (&#3611;&#3619;&#3632;&#3592;&#3623;&#3610;&#3588;&#3637;&#3619;&#3637;&#3586;&#3633;&#3609;&#3608;&#3660;)', 'woocommerce' ), 'TH-77' => __( 'Prachuap Khiri Khan', 'woocommerce' ),
'TH-85' => __( 'Ranong (&#3619;&#3632;&#3609;&#3629;&#3591;)', 'woocommerce' ), 'TH-85' => __( 'Ranong', 'woocommerce' ),
'TH-70' => __( 'Ratchaburi (&#3619;&#3634;&#3594;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-70' => __( 'Ratchaburi', 'woocommerce' ),
'TH-21' => __( 'Rayong (&#3619;&#3632;&#3618;&#3629;&#3591;)', 'woocommerce' ), 'TH-21' => __( 'Rayong', 'woocommerce' ),
'TH-45' => __( 'Roi Et (&#3619;&#3657;&#3629;&#3618;&#3648;&#3629;&#3655;&#3604;)', 'woocommerce' ), 'TH-45' => __( 'Roi Et', 'woocommerce' ),
'TH-27' => __( 'Sa Kaeo (&#3626;&#3619;&#3632;&#3649;&#3585;&#3657;&#3623;)', 'woocommerce' ), 'TH-27' => __( 'Sa Kaeo', 'woocommerce' ),
'TH-47' => __( 'Sakon Nakhon (&#3626;&#3585;&#3621;&#3609;&#3588;&#3619;)', 'woocommerce' ), 'TH-47' => __( 'Sakon Nakhon', 'woocommerce' ),
'TH-11' => __( 'Samut Prakan (&#3626;&#3617;&#3640;&#3607;&#3619;&#3611;&#3619;&#3634;&#3585;&#3634;&#3619;)', 'woocommerce' ), 'TH-11' => __( 'Samut Prakan', 'woocommerce' ),
'TH-74' => __( 'Samut Sakhon (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3634;&#3588;&#3619;)', 'woocommerce' ), 'TH-74' => __( 'Samut Sakhon', 'woocommerce' ),
'TH-75' => __( 'Samut Songkhram (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3591;&#3588;&#3619;&#3634;&#3617;)', 'woocommerce' ), 'TH-75' => __( 'Samut Songkhram', 'woocommerce' ),
'TH-19' => __( 'Saraburi (&#3626;&#3619;&#3632;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-19' => __( 'Saraburi', 'woocommerce' ),
'TH-91' => __( 'Satun (&#3626;&#3605;&#3641;&#3621;)', 'woocommerce' ), 'TH-91' => __( 'Satun', 'woocommerce' ),
'TH-17' => __( 'Sing Buri (&#3626;&#3636;&#3591;&#3627;&#3660;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-17' => __( 'Sing Buri', 'woocommerce' ),
'TH-33' => __( 'Sisaket (&#3624;&#3619;&#3637;&#3626;&#3632;&#3648;&#3585;&#3625;)', 'woocommerce' ), 'TH-33' => __( 'Sisaket', 'woocommerce' ),
'TH-90' => __( 'Songkhla (&#3626;&#3591;&#3586;&#3621;&#3634;)', 'woocommerce' ), 'TH-90' => __( 'Songkhla', 'woocommerce' ),
'TH-64' => __( 'Sukhothai (&#3626;&#3640;&#3650;&#3586;&#3607;&#3633;&#3618;)', 'woocommerce' ), 'TH-64' => __( 'Sukhothai', 'woocommerce' ),
'TH-72' => __( 'Suphan Buri (&#3626;&#3640;&#3614;&#3619;&#3619;&#3603;&#3610;&#3640;&#3619;&#3637;)', 'woocommerce' ), 'TH-72' => __( 'Suphan Buri', 'woocommerce' ),
'TH-84' => __( 'Surat Thani (&#3626;&#3640;&#3619;&#3634;&#3625;&#3598;&#3619;&#3660;&#3608;&#3634;&#3609;&#3637;)', 'woocommerce' ), 'TH-84' => __( 'Surat Thani', 'woocommerce' ),
'TH-32' => __( 'Surin (&#3626;&#3640;&#3619;&#3636;&#3609;&#3607;&#3619;&#3660;)', 'woocommerce' ), 'TH-32' => __( 'Surin', 'woocommerce' ),
'TH-63' => __( 'Tak (&#3605;&#3634;&#3585;)', 'woocommerce' ), 'TH-63' => __( 'Tak', 'woocommerce' ),
'TH-92' => __( 'Trang (&#3605;&#3619;&#3633;&#3591;)', 'woocommerce' ), 'TH-92' => __( 'Trang', 'woocommerce' ),
'TH-23' => __( 'Trat (&#3605;&#3619;&#3634;&#3604;)', 'woocommerce' ), 'TH-23' => __( 'Trat', 'woocommerce' ),
'TH-34' => __( 'Ubon Ratchathani (&#3629;&#3640;&#3610;&#3621;&#3619;&#3634;&#3594;&#3608;&#3634;&#3609;&#3637;)', 'woocommerce' ), 'TH-34' => __( 'Ubon Ratchathani', 'woocommerce' ),
'TH-41' => __( 'Udon Thani (&#3629;&#3640;&#3604;&#3619;&#3608;&#3634;&#3609;&#3637;)', 'woocommerce' ), 'TH-41' => __( 'Udon Thani', 'woocommerce' ),
'TH-61' => __( 'Uthai Thani (&#3629;&#3640;&#3607;&#3633;&#3618;&#3608;&#3634;&#3609;&#3637;)', 'woocommerce' ), 'TH-61' => __( 'Uthai Thani', 'woocommerce' ),
'TH-53' => __( 'Uttaradit (&#3629;&#3640;&#3605;&#3619;&#3604;&#3636;&#3605;&#3606;&#3660;)', 'woocommerce' ), 'TH-53' => __( 'Uttaradit', 'woocommerce' ),
'TH-95' => __( 'Yala (&#3618;&#3632;&#3621;&#3634;)', 'woocommerce' ), 'TH-95' => __( 'Yala', 'woocommerce' ),
'TH-35' => __( 'Yasothon (&#3618;&#3650;&#3626;&#3608;&#3619;)', 'woocommerce' ), 'TH-35' => __( 'Yasothon', 'woocommerce' ),
); );

View File

@ -2,16 +2,13 @@
/** /**
* Turkey States * Turkey States
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['TR'] = array( $states['TR'] = array(
'TR01' => __( 'Adana', 'woocommerce' ), 'TR01' => __( 'Adana', 'woocommerce' ),

View File

@ -2,43 +2,43 @@
/** /**
* Tanzania States * Tanzania States
* *
* @author Lev and Mohsin @ Extreme Web Technologies Ltd * Based on English names published at https://en.wikipedia.org/wiki/ISO_3166-2:TZ
* @category i18n *
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @version 2.0.0
* @notes Based on English names published at https://en.wikipedia.org/wiki/ISO_3166-2:TZ
*/ */
global $states; global $states;
$states['TZ'] = array( $states['TZ'] = array(
'TZ01' => __( 'Arusha', 'woocommerce' ), 'TZ01' => __( 'Arusha', 'woocommerce' ),
'TZ02' => __( 'Dar es Salaam', 'woocommerce' ), 'TZ02' => __( 'Dar es Salaam', 'woocommerce' ),
'TZ03' => __( 'Dodoma', 'woocommerce' ), 'TZ03' => __( 'Dodoma', 'woocommerce' ),
'TZ04' => __( 'Iringa', 'woocommerce' ), 'TZ04' => __( 'Iringa', 'woocommerce' ),
'TZ05' => __( 'Kagera', 'woocommerce' ), 'TZ05' => __( 'Kagera', 'woocommerce' ),
'TZ06' => __( 'Pemba North', 'woocommerce' ), 'TZ06' => __( 'Pemba North', 'woocommerce' ),
'TZ07' => __( 'Zanzibar North', 'woocommerce' ), 'TZ07' => __( 'Zanzibar North', 'woocommerce' ),
'TZ08' => __( 'Kigoma', 'woocommerce' ), 'TZ08' => __( 'Kigoma', 'woocommerce' ),
'TZ09' => __( 'Kilimanjaro', 'woocommerce' ), 'TZ09' => __( 'Kilimanjaro', 'woocommerce' ),
'TZ10' => __( 'Pemba South', 'woocommerce' ), 'TZ10' => __( 'Pemba South', 'woocommerce' ),
'TZ11' => __( 'Zanzibar South', 'woocommerce' ), 'TZ11' => __( 'Zanzibar South', 'woocommerce' ),
'TZ12' => __( 'Lindi', 'woocommerce' ), 'TZ12' => __( 'Lindi', 'woocommerce' ),
'TZ13' => __( 'Mara', 'woocommerce' ), 'TZ13' => __( 'Mara', 'woocommerce' ),
'TZ14' => __( 'Mbeya', 'woocommerce' ), 'TZ14' => __( 'Mbeya', 'woocommerce' ),
'TZ15' => __( 'Zanzibar West', 'woocommerce' ), 'TZ15' => __( 'Zanzibar West', 'woocommerce' ),
'TZ16' => __( 'Morogoro', 'woocommerce' ), 'TZ16' => __( 'Morogoro', 'woocommerce' ),
'TZ17' => __( 'Mtwara', 'woocommerce' ), 'TZ17' => __( 'Mtwara', 'woocommerce' ),
'TZ18' => __( 'Mwanza', 'woocommerce' ), 'TZ18' => __( 'Mwanza', 'woocommerce' ),
'TZ19' => __( 'Coast', 'woocommerce' ), 'TZ19' => __( 'Coast', 'woocommerce' ),
'TZ20' => __( 'Rukwa', 'woocommerce' ), 'TZ20' => __( 'Rukwa', 'woocommerce' ),
'TZ21' => __( 'Ruvuma', 'woocommerce' ), 'TZ21' => __( 'Ruvuma', 'woocommerce' ),
'TZ22' => __( 'Shinyanga', 'woocommerce' ), 'TZ22' => __( 'Shinyanga', 'woocommerce' ),
'TZ23' => __( 'Singida', 'woocommerce' ), 'TZ23' => __( 'Singida', 'woocommerce' ),
'TZ24' => __( 'Tabora', 'woocommerce' ), 'TZ24' => __( 'Tabora', 'woocommerce' ),
'TZ25' => __( 'Tanga', 'woocommerce' ), 'TZ25' => __( 'Tanga', 'woocommerce' ),
'TZ26' => __( 'Manyara', 'woocommerce' ), 'TZ26' => __( 'Manyara', 'woocommerce' ),
'TZ27' => __( 'Geita', 'woocommerce' ), 'TZ27' => __( 'Geita', 'woocommerce' ),
'TZ28' => __( 'Katavi', 'woocommerce' ), 'TZ28' => __( 'Katavi', 'woocommerce' ),
'TZ29' => __( 'Njombe', 'woocommerce' ), 'TZ29' => __( 'Njombe', 'woocommerce' ),
'TZ30' => __( 'Simiyu', 'woocommerce' ) 'TZ30' => __( 'Simiyu', 'woocommerce' ),
); );

View File

@ -2,16 +2,13 @@
/** /**
* United States * United States
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['US'] = array( $states['US'] = array(
'AL' => __( 'Alabama', 'woocommerce' ), 'AL' => __( 'Alabama', 'woocommerce' ),

View File

@ -2,16 +2,13 @@
/** /**
* South African states * South African states
* *
* @author WooThemes * @package WooCommerce/i18n
* @category i18n * @version 2.0.0
* @package WooCommerce/i18n
* @version 2.0.0
*/ */
global $states; global $states;
if ( ! defined( 'ABSPATH' ) ) { defined( 'ABSPATH' ) || exit;
exit;
}
$states['ZA'] = array( $states['ZA'] = array(
'EC' => __( 'Eastern Cape', 'woocommerce' ), 'EC' => __( 'Eastern Cape', 'woocommerce' ),

View File

@ -52,8 +52,8 @@ class WC_Admin_Addons {
$paramters = array( $paramters = array(
'category' => $category, 'category' => $category,
'term' => $term, 'term' => $term,
'country' => $country, 'country' => $country,
); );
return '?' . http_build_query( $paramters ); return '?' . http_build_query( $paramters );
@ -69,7 +69,7 @@ class WC_Admin_Addons {
* @return array of extensions * @return array of extensions
*/ */
public static function get_extension_data( $category, $term, $country ) { public static function get_extension_data( $category, $term, $country ) {
$parameters = self::build_parameter_string( $category, $term, $country ); $parameters = self::build_parameter_string( $category, $term, $country );
$raw_extensions = wp_remote_get( $raw_extensions = wp_remote_get(
'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters 'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters
); );
@ -166,12 +166,14 @@ class WC_Admin_Addons {
$utm_content = 'nostorefront'; $utm_content = 'nostorefront';
} }
$url = add_query_arg( array( $url = add_query_arg(
'utm_source' => 'addons', array(
'utm_medium' => 'product', 'utm_source' => 'addons',
'utm_campaign' => 'woocommerceplugin', 'utm_medium' => 'product',
'utm_content' => $utm_content, 'utm_campaign' => 'woocommerceplugin',
), $url ); 'utm_content' => $utm_content,
), $url
);
echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n"; echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n";
} }
@ -284,7 +286,7 @@ class WC_Admin_Addons {
public static function output_small_light_block( $block ) { public static function output_small_light_block( $block ) {
?> ?>
<div class="addons-small-light-block"> <div class="addons-small-light-block">
<img class="addons-img" src="<?php echo esc_url( $block->image ) ?>" /> <img class="addons-img" src="<?php echo esc_url( $block->image ); ?>" />
<div class="addons-small-light-block-content"> <div class="addons-small-light-block-content">
<h1><?php echo esc_html( $block->title ); ?></h1> <h1><?php echo esc_html( $block->title ); ?></h1>
<p><?php echo esc_html( $block->description ); ?></p> <p><?php echo esc_html( $block->description ); ?></p>
@ -355,9 +357,11 @@ class WC_Admin_Addons {
} }
$button_url = wp_nonce_url( $button_url = wp_nonce_url(
add_query_arg( array( add_query_arg(
'install-addon' => 'woocommerce-services', array(
) ), 'install-addon' => 'woocommerce-services',
)
),
'install-addon_woocommerce-services' 'install-addon_woocommerce-services'
); );
@ -377,22 +381,26 @@ class WC_Admin_Addons {
'image' => WC()->plugin_url() . '/assets/images/wcs-truck-banner-3x.png', 'image' => WC()->plugin_url() . '/assets/images/wcs-truck-banner-3x.png',
'title' => __( 'Show Canada Post shipping rates', 'woocommerce' ), 'title' => __( 'Show Canada Post shipping rates', 'woocommerce' ),
'description' => __( 'Display live rates from Canada Post at checkout to make shipping a breeze. Powered by WooCommerce Services.', 'woocommerce' ), 'description' => __( 'Display live rates from Canada Post at checkout to make shipping a breeze. Powered by WooCommerce Services.', 'woocommerce' ),
'logos' => array_merge( $defaults['logos'], array( 'logos' => array_merge(
array( $defaults['logos'], array(
'link' => WC()->plugin_url() . '/assets/images/wcs-canada-post-logo.jpg', array(
'alt' => 'Canada Post logo', 'link' => WC()->plugin_url() . '/assets/images/wcs-canada-post-logo.jpg',
), 'alt' => 'Canada Post logo',
) ), ),
)
),
); );
break; break;
case 'US': case 'US':
$local_defaults = array( $local_defaults = array(
'logos' => array_merge( $defaults['logos'], array( 'logos' => array_merge(
array( $defaults['logos'], array(
'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png', array(
'alt' => 'USPS logo', 'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
), 'alt' => 'USPS logo',
) ), ),
)
),
); );
break; break;
default: default:
@ -479,7 +487,7 @@ class WC_Admin_Addons {
public static function output_button( $url, $text, $theme, $plugin = '' ) { public static function output_button( $url, $text, $theme, $plugin = '' ) {
$theme = __( 'Free', 'woocommerce' ) === $text ? 'addons-button-outline-green' : $theme; $theme = __( 'Free', 'woocommerce' ) === $text ? 'addons-button-outline-green' : $theme;
$theme = is_plugin_active( $plugin ) ? 'addons-button-installed' : $theme; $theme = is_plugin_active( $plugin ) ? 'addons-button-installed' : $theme;
$text = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text; $text = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text;
?> ?>
<a <a
class="addons-button <?php echo esc_attr( $theme ); ?>" class="addons-button <?php echo esc_attr( $theme ); ?>"
@ -506,13 +514,13 @@ class WC_Admin_Addons {
$sections = self::get_sections(); $sections = self::get_sections();
$theme = wp_get_theme(); $theme = wp_get_theme();
$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : '_featured'; $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : '_featured';
$addons = array(); $addons = array();
if ( '_featured' !== $current_section ) { if ( '_featured' !== $current_section ) {
$category = isset( $_GET['section'] ) ? $_GET['section'] : null; $category = isset( $_GET['section'] ) ? $_GET['section'] : null;
$term = isset( $_GET['search'] ) ? $_GET['search'] : null; $term = isset( $_GET['search'] ) ? $_GET['search'] : null;
$country = WC()->countries->get_base_country(); $country = WC()->countries->get_base_country();
$addons = self::get_extension_data( $category, $term, $country ); $addons = self::get_extension_data( $category, $term, $country );
} }
/** /**
@ -523,7 +531,7 @@ class WC_Admin_Addons {
* @uses $theme * @uses $theme
* @uses $current_section * @uses $current_section
*/ */
include_once( dirname( __FILE__ ) . '/views/html-admin-page-addons.php' ); include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php';
} }
/** /**

View File

@ -21,11 +21,13 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
* Initialize the API key table list. * Initialize the API key table list.
*/ */
public function __construct() { public function __construct() {
parent::__construct( array( parent::__construct(
'singular' => 'key', array(
'plural' => 'keys', 'singular' => 'key',
'ajax' => false, 'plural' => 'keys',
) ); 'ajax' => false,
)
);
} }
/** /**
@ -85,9 +87,15 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
/* translators: %s: API key ID. */ /* translators: %s: API key ID. */
'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $key['key_id'] ), 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $key['key_id'] ),
'edit' => '<a href="' . esc_url( $url ) . '">' . __( 'View/Edit', 'woocommerce' ) . '</a>', 'edit' => '<a href="' . esc_url( $url ) . '">' . __( 'View/Edit', 'woocommerce' ) . '</a>',
'trash' => '<a class="submitdelete" aria-label="' . esc_attr__( 'Revoke API key', 'woocommerce' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'trash' => '<a class="submitdelete" aria-label="' . esc_attr__( 'Revoke API key', 'woocommerce' ) . '" href="' . esc_url(
'revoke-key' => $key['key_id'], wp_nonce_url(
), admin_url( 'admin.php?page=wc-settings&tab=api&section=keys' ) ), 'revoke' ) ) . '">' . esc_html__( 'Revoke', 'woocommerce' ) . '</a>', add_query_arg(
array(
'revoke-key' => $key['key_id'],
), admin_url( 'admin.php?page=wc-settings&tab=api&section=keys' )
), 'revoke'
)
) . '">' . esc_html__( 'Revoke', 'woocommerce' ) . '</a>',
); );
$row_actions = array(); $row_actions = array();
@ -212,10 +220,12 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
$this->items = $keys; $this->items = $keys;
// Set the pagination. // Set the pagination.
$this->set_pagination_args( array( $this->set_pagination_args(
'total_items' => $count, array(
'per_page' => $per_page, 'total_items' => $count,
'total_pages' => ceil( $count / $per_page ), 'per_page' => $per_page,
) ); 'total_pages' => ceil( $count / $per_page ),
)
);
} }
} }

View File

@ -57,10 +57,12 @@ class WC_Admin_API_Keys {
$keys_table_list = new WC_Admin_API_Keys_Table_List(); $keys_table_list = new WC_Admin_API_Keys_Table_List();
// Add screen option. // Add screen option.
add_screen_option( 'per_page', array( add_screen_option(
'default' => 10, 'per_page', array(
'option' => 'woocommerce_keys_per_page', 'default' => 10,
) ); 'option' => 'woocommerce_keys_per_page',
)
);
} }
} }
@ -117,11 +119,14 @@ class WC_Admin_API_Keys {
return $empty; return $empty;
} }
$key = $wpdb->get_row( $wpdb->prepare( " $key = $wpdb->get_row(
SELECT key_id, user_id, description, permissions, truncated_key, last_access $wpdb->prepare(
FROM {$wpdb->prefix}woocommerce_api_keys "SELECT key_id, user_id, description, permissions, truncated_key, last_access
WHERE key_id = %d FROM {$wpdb->prefix}woocommerce_api_keys
", $key_id ), ARRAY_A ); WHERE key_id = %d",
$key_id
), ARRAY_A
);
if ( is_null( $key ) ) { if ( is_null( $key ) ) {
return $empty; return $empty;

View File

@ -14,384 +14,400 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Assets', false ) ) : if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
/**
* WC_Admin_Assets Class.
*/
class WC_Admin_Assets {
/** /**
* Hook in tabs. * WC_Admin_Assets Class.
*/ */
public function __construct() { class WC_Admin_Assets {
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
}
/** /**
* Enqueue styles. * Hook in tabs.
*/ */
public function admin_styles() { public function __construct() {
global $wp_scripts; add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
// Register admin styles
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui.min.css', array(), WC_VERSION );
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION );
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' );
// Add RTL support for admin styles
wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
// Sitewide menu CSS
wp_enqueue_style( 'woocommerce_admin_menu_styles' );
// Admin styles for WC pages only
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
wp_enqueue_style( 'woocommerce_admin_styles' );
wp_enqueue_style( 'jquery-ui-style' );
wp_enqueue_style( 'wp-color-picker' );
}
if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
}
if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
} }
/** /**
* @deprecated 2.3 * Enqueue styles.
*/ */
if ( has_action( 'woocommerce_admin_css' ) ) { public function admin_styles() {
do_action( 'woocommerce_admin_css' ); global $wp_scripts;
wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
}
}
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
/** // Register admin styles
* Enqueue scripts. wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
*/ wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
public function admin_scripts() { wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui.min.css', array(), WC_VERSION );
global $wp_query, $post; wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION );
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' );
$screen = get_current_screen(); // Add RTL support for admin styles
$screen_id = $screen ? $screen->id : ''; wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) ); wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
// Register scripts // Sitewide menu CSS
wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), WC_VERSION ); wp_enqueue_style( 'woocommerce_admin_menu_styles' );
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), WC_VERSION );
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION );
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.3' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ),
'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
) );
wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' ); // Admin styles for WC pages only
wp_localize_script( 'accounting', 'accounting_params', array( if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
'mon_decimal_point' => wc_get_price_decimal_separator(), wp_enqueue_style( 'woocommerce_admin_styles' );
) ); wp_enqueue_style( 'jquery-ui-style' );
wp_enqueue_style( 'wp-color-picker' );
wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
wp_localize_script( 'wc-orders', 'wc_orders_params', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
) );
// WooCommerce admin pages.
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
wp_enqueue_script( 'iris' );
wp_enqueue_script( 'woocommerce_admin' );
wp_enqueue_script( 'wc-enhanced-select' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
$locale = localeconv();
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
$params = array(
/* translators: %s: decimal */
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
/* translators: %s: price decimal separator */
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'i18_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => wc_get_price_decimal_separator(),
'strings' => array(
'import_products' => __( 'Import', 'woocommerce' ),
'export_products' => __( 'Export', 'woocommerce' ),
),
'urls' => array(
'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
),
);
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
}
// Edit product category pages
if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
wp_enqueue_media();
}
// Products
if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), WC_VERSION );
$params = array(
'strings' => array(
'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ),
),
);
wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params );
}
// Meta boxes
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
wp_enqueue_media();
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION );
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION );
wp_enqueue_script( 'wc-admin-product-meta-boxes' );
wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
$params = array(
'post_id' => isset( $post->ID ) ? $post->ID : '',
'plugin_url' => WC()->plugin_url(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
'add_variation_nonce' => wp_create_nonce( 'add-variation' ),
'link_variation_nonce' => wp_create_nonce( 'link-variations' ),
'delete_variations_nonce' => wp_create_nonce( 'delete-variations' ),
'load_variations_nonce' => wp_create_nonce( 'load-variations' ),
'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), defined( 'WC_MAX_LINKED_VARIATIONS' ) ? WC_MAX_LINKED_VARIATIONS : 50 ) ),
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
'i18n_variation_added' => esc_js( __( "variation added", 'woocommerce' ) ),
'i18n_variations_added' => esc_js( __( "variations added", 'woocommerce' ) ),
'i18n_no_variations_added' => esc_js( __( "No variations added", 'woocommerce' ) ),
'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),
'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ),
);
wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
}
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
$default_location = wc_get_customer_default_location();
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), WC_VERSION );
wp_localize_script( 'wc-admin-order-meta-boxes', 'woocommerce_admin_meta_boxes_order', array(
'countries' => json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
) );
}
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
}
if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
$post_id = isset( $post->ID ) ? $post->ID : '';
$currency = '';
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) && ( $order = wc_get_order( $post_id ) ) ) {
$currency = $order->get_currency();
} }
$params = array( if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
'remove_item_notice' => __( "Are you sure you want to remove the selected items? If you have previously reduced this item's stock, or this order was submitted by a customer, you will need to manually restore the item's stock.", 'woocommerce' ), wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ), }
'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
'name_label' => __( 'Name', 'woocommerce' ),
'remove_label' => __( 'Remove', 'woocommerce' ),
'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
'values_label' => __( 'Value(s)', 'woocommerce' ),
'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ),
'visible_label' => __( 'Visible on the product page', 'woocommerce' ),
'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ),
'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ),
'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ),
'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ),
'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ),
'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ),
'featured_label' => __( 'Featured', 'woocommerce' ),
'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ),
'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ),
'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ),
'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
'plugin_url' => WC()->plugin_url(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'order_item_nonce' => wp_create_nonce( 'order-item' ),
'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png',
'post_id' => isset( $post->ID ) ? $post->ID : '',
'base_country' => WC()->countries->get_base_country(),
'currency_format_num_decimals' => wc_get_price_decimals(),
'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ),
'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
'rounding_precision' => wc_get_rounding_precision(),
'tax_rounding_mode' => wc_get_tax_rounding_mode(),
'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ),
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ),
'i18n_apply_coupon' => __( 'Enter a coupon code to apply to this order.', 'woocommerce' ),
'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
);
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params ); if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
}
/**
* @deprecated 2.3
*/
if ( has_action( 'woocommerce_admin_css' ) ) {
do_action( 'woocommerce_admin_css' );
wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
}
} }
// Term ordering - only when sorting by term_order
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION ); /**
wp_enqueue_script( 'woocommerce_term_ordering' ); * Enqueue scripts.
*/
public function admin_scripts() {
global $wp_query, $post;
$taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( $_GET['taxonomy'] ) : ''; $screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$woocommerce_term_order_params = array( // Register scripts
'taxonomy' => $taxonomy, wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), WC_VERSION );
); wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params ); wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
} wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), WC_VERSION );
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
// Product sorting - only when sorting by menu order on the products page wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) { wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true ); wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
wp_enqueue_script( 'woocommerce_product_ordering' ); wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
} wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
// Reports Pages wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) { wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION ); wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION );
wp_enqueue_script( 'wc-reports' ); wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
wp_enqueue_script( 'flot' ); wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
wp_enqueue_script( 'flot-resize' ); wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
wp_enqueue_script( 'flot-time' ); wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_enqueue_script( 'flot-pie' ); wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_enqueue_script( 'flot-stack' ); wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.3' );
} wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
// API settings
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), WC_VERSION, true );
wp_enqueue_script( 'wc-api-keys' );
wp_localize_script( wp_localize_script(
'wc-api-keys', 'wc-enhanced-select',
'woocommerce_admin_api_keys', 'wc_enhanced_select_params',
array( array(
'ajax_url' => admin_url( 'admin-ajax.php' ), 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
'update_api_nonce' => wp_create_nonce( 'update-api-key' ), 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ), 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ),
'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
) )
); );
}
// System status. wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), WC_VERSION );
wp_enqueue_script( 'wc-admin-system-status' );
wp_localize_script( wp_localize_script(
'wc-admin-system-status', 'accounting',
'woocommerce_admin_system_status', 'accounting_params',
array( array(
'delete_log_confirmation' => esc_js( __( 'Are you sure you want to delete this log?', 'woocommerce' ) ), 'mon_decimal_point' => wc_get_price_decimal_separator(),
) )
); );
}
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) { wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), WC_VERSION, true );
wp_enqueue_script( 'wc-users' );
wp_localize_script( wp_localize_script(
'wc-users', 'wc-orders',
'wc_users_params', 'wc_orders_params',
array( array(
'countries' => json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ), 'ajax_url' => admin_url( 'admin-ajax.php' ),
'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ), 'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
) )
); );
// WooCommerce admin pages.
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
wp_enqueue_script( 'iris' );
wp_enqueue_script( 'woocommerce_admin' );
wp_enqueue_script( 'wc-enhanced-select' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
$locale = localeconv();
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
$params = array(
/* translators: %s: decimal */
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
/* translators: %s: price decimal separator */
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'i18_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => wc_get_price_decimal_separator(),
'strings' => array(
'import_products' => __( 'Import', 'woocommerce' ),
'export_products' => __( 'Export', 'woocommerce' ),
),
'urls' => array(
'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
),
);
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
}
// Edit product category pages
if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
wp_enqueue_media();
}
// Products
if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), WC_VERSION );
$params = array(
'strings' => array(
'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ),
),
);
wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params );
}
// Meta boxes
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
wp_enqueue_media();
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION );
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION );
wp_enqueue_script( 'wc-admin-product-meta-boxes' );
wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
$params = array(
'post_id' => isset( $post->ID ) ? $post->ID : '',
'plugin_url' => WC()->plugin_url(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
'add_variation_nonce' => wp_create_nonce( 'add-variation' ),
'link_variation_nonce' => wp_create_nonce( 'link-variations' ),
'delete_variations_nonce' => wp_create_nonce( 'delete-variations' ),
'load_variations_nonce' => wp_create_nonce( 'load-variations' ),
'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), defined( 'WC_MAX_LINKED_VARIATIONS' ) ? WC_MAX_LINKED_VARIATIONS : 50 ) ),
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
'i18n_variation_added' => esc_js( __( 'variation added', 'woocommerce' ) ),
'i18n_variations_added' => esc_js( __( 'variations added', 'woocommerce' ) ),
'i18n_no_variations_added' => esc_js( __( 'No variations added', 'woocommerce' ) ),
'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),
'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ),
);
wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
}
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
$default_location = wc_get_customer_default_location();
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), WC_VERSION );
wp_localize_script(
'wc-admin-order-meta-boxes',
'woocommerce_admin_meta_boxes_order',
array(
'countries' => json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
)
);
}
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
}
if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
$post_id = isset( $post->ID ) ? $post->ID : '';
$currency = '';
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) && ( $order = wc_get_order( $post_id ) ) ) {
$currency = $order->get_currency();
}
$params = array(
'remove_item_notice' => __( "Are you sure you want to remove the selected items? If you have previously reduced this item's stock, or this order was submitted by a customer, you will need to manually restore the item's stock.", 'woocommerce' ),
'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ),
'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
'name_label' => __( 'Name', 'woocommerce' ),
'remove_label' => __( 'Remove', 'woocommerce' ),
'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
'values_label' => __( 'Value(s)', 'woocommerce' ),
'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ),
'visible_label' => __( 'Visible on the product page', 'woocommerce' ),
'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ),
'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ),
'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ),
'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ),
'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ),
'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ),
'featured_label' => __( 'Featured', 'woocommerce' ),
'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ),
'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ),
'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ),
'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
'plugin_url' => WC()->plugin_url(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'order_item_nonce' => wp_create_nonce( 'order-item' ),
'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png',
'post_id' => isset( $post->ID ) ? $post->ID : '',
'base_country' => WC()->countries->get_base_country(),
'currency_format_num_decimals' => wc_get_price_decimals(),
'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ),
'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
'rounding_precision' => wc_get_rounding_precision(),
'tax_rounding_mode' => wc_get_tax_rounding_mode(),
'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ),
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ),
'i18n_apply_coupon' => __( 'Enter a coupon code to apply to this order.', 'woocommerce' ),
'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
);
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
}
// Term ordering - only when sorting by term_order
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION );
wp_enqueue_script( 'woocommerce_term_ordering' );
$taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( $_GET['taxonomy'] ) : '';
$woocommerce_term_order_params = array(
'taxonomy' => $taxonomy,
);
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
}
// Product sorting - only when sorting by menu order on the products page
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true );
wp_enqueue_script( 'woocommerce_product_ordering' );
}
// Reports Pages
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION );
wp_enqueue_script( 'wc-reports' );
wp_enqueue_script( 'flot' );
wp_enqueue_script( 'flot-resize' );
wp_enqueue_script( 'flot-time' );
wp_enqueue_script( 'flot-pie' );
wp_enqueue_script( 'flot-stack' );
}
// API settings
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), WC_VERSION, true );
wp_enqueue_script( 'wc-api-keys' );
wp_localize_script(
'wc-api-keys',
'woocommerce_admin_api_keys',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'update_api_nonce' => wp_create_nonce( 'update-api-key' ),
'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ),
)
);
}
// System status.
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), WC_VERSION );
wp_enqueue_script( 'wc-admin-system-status' );
wp_localize_script(
'wc-admin-system-status',
'woocommerce_admin_system_status',
array(
'delete_log_confirmation' => esc_js( __( 'Are you sure you want to delete this log?', 'woocommerce' ) ),
)
);
}
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), WC_VERSION, true );
wp_enqueue_script( 'wc-users' );
wp_localize_script(
'wc-users',
'wc_users_params',
array(
'countries' => json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
)
);
}
} }
} }
}
endif; endif;

View File

@ -39,15 +39,15 @@ class WC_Admin_Attributes {
} }
switch ( $action ) { switch ( $action ) {
case 'add' : case 'add':
$result = self::process_add_attribute(); $result = self::process_add_attribute();
break; break;
case 'edit' : case 'edit':
$result = self::process_edit_attribute(); $result = self::process_edit_attribute();
break; break;
case 'delete' : case 'delete':
$result = self::process_delete_attribute(); $result = self::process_delete_attribute();
break; break;
} }
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
@ -69,11 +69,11 @@ class WC_Admin_Attributes {
*/ */
private static function get_posted_attribute() { private static function get_posted_attribute() {
$attribute = array( $attribute = array(
'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( stripslashes( $_POST['attribute_label'] ) ) : '', 'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( stripslashes( $_POST['attribute_label'] ) ) : '',
'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) ) : '', 'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) ) : '',
'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( $_POST['attribute_type'] ) : 'select', 'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( $_POST['attribute_type'] ) : 'select',
'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( $_POST['attribute_orderby'] ) : '', 'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( $_POST['attribute_orderby'] ) : '',
'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0, 'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0,
); );
if ( empty( $attribute['attribute_type'] ) ) { if ( empty( $attribute['attribute_type'] ) ) {
@ -166,11 +166,11 @@ class WC_Admin_Attributes {
$edit = absint( $_GET['edit'] ); $edit = absint( $_GET['edit'] );
$attribute_to_edit = $wpdb->get_row( "SELECT attribute_type, attribute_label, attribute_name, attribute_orderby, attribute_public FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'" ); $attribute_to_edit = $wpdb->get_row( 'SELECT attribute_type, attribute_label, attribute_name, attribute_orderby, attribute_public FROM ' . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'" );
?> ?>
<div class="wrap woocommerce"> <div class="wrap woocommerce">
<h1><?php esc_html_e( 'Edit attribute', 'woocommerce' ) ?></h1> <h1><?php esc_html_e( 'Edit attribute', 'woocommerce' ); ?></h1>
<?php <?php
if ( ! $attribute_to_edit ) { if ( ! $attribute_to_edit ) {
@ -262,7 +262,7 @@ class WC_Admin_Attributes {
<p class="description"><?php esc_html_e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p> <p class="description"><?php esc_html_e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p>
</td> </td>
</tr> </tr>
<?php do_action( 'woocommerce_after_edit_attribute_fields' ) ?> <?php do_action( 'woocommerce_after_edit_attribute_fields' ); ?>
</tbody> </tbody>
</table> </table>
<p class="submit"><button type="submit" name="save_attribute" id="submit" class="button-primary" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"><?php esc_html_e( 'Update', 'woocommerce' ); ?></button></p> <p class="submit"><button type="submit" name="save_attribute" id="submit" class="button-primary" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"><?php esc_html_e( 'Update', 'woocommerce' ); ?></button></p>
@ -303,7 +303,8 @@ class WC_Admin_Attributes {
<?php <?php
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) : if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) :
foreach ( $attribute_taxonomies as $tax ) : foreach ( $attribute_taxonomies as $tax ) :
?><tr> ?>
<tr>
<td> <td>
<strong><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&amp;post_type=product"><?php echo esc_html( $tax->attribute_label ); ?></a></strong> <strong><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&amp;post_type=product"><?php echo esc_html( $tax->attribute_label ); ?></a></strong>
@ -313,60 +314,65 @@ class WC_Admin_Attributes {
<?php if ( wc_has_custom_attribute_types() ) : ?> <?php if ( wc_has_custom_attribute_types() ) : ?>
<td><?php echo esc_html( wc_get_attribute_type_label( $tax->attribute_type ) ); ?> <?php echo $tax->attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?></td> <td><?php echo esc_html( wc_get_attribute_type_label( $tax->attribute_type ) ); ?> <?php echo $tax->attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?></td>
<?php endif; ?> <?php endif; ?>
<td><?php <td>
switch ( $tax->attribute_orderby ) { <?php
case 'name' : switch ( $tax->attribute_orderby ) {
esc_html_e( 'Name', 'woocommerce' ); case 'name':
break; esc_html_e( 'Name', 'woocommerce' );
case 'name_num' : break;
esc_html_e( 'Name (numeric)', 'woocommerce' ); case 'name_num':
break; esc_html_e( 'Name (numeric)', 'woocommerce' );
case 'id' : break;
esc_html_e( 'Term ID', 'woocommerce' ); case 'id':
break; esc_html_e( 'Term ID', 'woocommerce' );
default: break;
esc_html_e( 'Custom ordering', 'woocommerce' ); default:
break; esc_html_e( 'Custom ordering', 'woocommerce' );
} break;
?> }
?>
</td> </td>
<td class="attribute-terms"> <td class="attribute-terms">
<?php <?php
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name ); $taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
if ( taxonomy_exists( $taxonomy ) ) { if ( taxonomy_exists( $taxonomy ) ) {
if ( 'menu_order' === wc_attribute_orderby( $taxonomy ) ) { if ( 'menu_order' === wc_attribute_orderby( $taxonomy ) ) {
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=ASC' ); $terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=ASC' );
} else {
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=false' );
}
switch ( $tax->attribute_orderby ) {
case 'name_num':
usort( $terms, '_wc_get_product_terms_name_num_usort_callback' );
break;
case 'parent':
usort( $terms, '_wc_get_product_terms_parent_usort_callback' );
break;
}
$terms_string = implode( ', ', wp_list_pluck( $terms, 'name' ) );
if ( $terms_string ) {
echo esc_html( $terms_string );
} else {
echo '<span class="na">&ndash;</span>';
}
} else { } else {
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=false' ); echo '<span class="na">&ndash;</span>';
} }
?>
switch ( $tax->attribute_orderby ) { <br /><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&amp;post_type=product" class="configure-terms"><?php esc_html_e( 'Configure terms', 'woocommerce' ); ?></a>
case 'name_num' :
usort( $terms, '_wc_get_product_terms_name_num_usort_callback' );
break;
case 'parent' :
usort( $terms, '_wc_get_product_terms_parent_usort_callback' );
break;
}
$terms_string = implode( ', ', wp_list_pluck( $terms, 'name' ) );
if ( $terms_string ) {
echo esc_html( $terms_string );
} else {
echo '<span class="na">&ndash;</span>';
}
} else {
echo '<span class="na">&ndash;</span>';
}
?>
<br /><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&amp;post_type=product" class="configure-terms"><?php esc_html_e( 'Configure terms', 'woocommerce' ); ?></a>
</td> </td>
</tr> </tr>
<?php <?php
endforeach; endforeach;
else : else :
?><tr><td colspan="6"><?php esc_html_e( 'No attributes currently exist.', 'woocommerce' ) ?></td></tr><?php ?>
<tr>
<td colspan="6"><?php esc_html_e( 'No attributes currently exist.', 'woocommerce' ); ?></td>
</tr>
<?php
endif; endif;
?> ?>
</tbody> </tbody>
@ -379,7 +385,7 @@ class WC_Admin_Attributes {
<h2><?php esc_html_e( 'Add new attribute', 'woocommerce' ); ?></h2> <h2><?php esc_html_e( 'Add new attribute', 'woocommerce' ); ?></h2>
<p><?php esc_html_e( 'Attributes let you define extra product data, such as size or color. You can use these attributes in the shop sidebar using the "layered nav" widgets.', 'woocommerce' ); ?></p> <p><?php esc_html_e( 'Attributes let you define extra product data, such as size or color. You can use these attributes in the shop sidebar using the "layered nav" widgets.', 'woocommerce' ); ?></p>
<form action="edit.php?post_type=product&amp;page=product_attributes" method="post"> <form action="edit.php?post_type=product&amp;page=product_attributes" method="post">
<?php do_action( 'woocommerce_before_add_attribute_fields' ) ?> <?php do_action( 'woocommerce_before_add_attribute_fields' ); ?>
<div class="form-field"> <div class="form-field">
<label for="attribute_label"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label> <label for="attribute_label"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label>
@ -442,7 +448,7 @@ class WC_Admin_Attributes {
<p class="description"><?php esc_html_e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p> <p class="description"><?php esc_html_e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p>
</div> </div>
<?php do_action( 'woocommerce_after_add_attribute_fields' ) ?> <?php do_action( 'woocommerce_after_add_attribute_fields' ); ?>
<p class="submit"><button type="submit" name="add_new_attribute" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Add attribute', 'woocommerce' ); ?>"><?php esc_html_e( 'Add attribute', 'woocommerce' ); ?></button></p> <p class="submit"><button type="submit" name="add_new_attribute" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Add attribute', 'woocommerce' ); ?>"><?php esc_html_e( 'Add attribute', 'woocommerce' ); ?></button></p>
<?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?> <?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?>

View File

@ -14,84 +14,84 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Customize', false ) ) : if ( ! class_exists( 'WC_Admin_Customize', false ) ) :
/**
* WC_Admin_Customize Class.
*/
class WC_Admin_Customize {
/** /**
* Initialize customize actions. * WC_Admin_Customize Class.
*/ */
public function __construct() { class WC_Admin_Customize {
// Include custom items to customizer nav menu settings.
add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) );
add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 );
}
/** /**
* Register customize new nav menu item types. * Initialize customize actions.
* This will register WooCommerce account endpoints as a nav menu item type. */
* public function __construct() {
* @since 3.1.0 // Include custom items to customizer nav menu settings.
* @param array $item_types Menu item types. add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) );
* @return array add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 );
*/
public function register_customize_nav_menu_item_types( $item_types ) {
$item_types[] = array(
'title' => __( 'WooCommerce endpoints', 'woocommerce' ),
'type_label' => __( 'WooCommerce endpoint', 'woocommerce' ),
'type' => 'woocommerce_nav',
'object' => 'woocommerce_endpoint',
);
return $item_types;
}
/**
* Register account endpoints to customize nav menu items.
*
* @since 3.1.0
* @param array $items List of nav menu items.
* @param string $type Nav menu type.
* @param string $object Nav menu object.
* @param integer $page Page number.
* @return array
*/
public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) {
if ( 'woocommerce_endpoint' !== $object ) {
return $items;
} }
// Don't allow pagination since all items are loaded at once. /**
if ( 0 < $page ) { * Register customize new nav menu item types.
return $items; * This will register WooCommerce account endpoints as a nav menu item type.
} *
* @since 3.1.0
// Get items from account menu. * @param array $item_types Menu item types.
$endpoints = wc_get_account_menu_items(); * @return array
*/
// Remove dashboard item. public function register_customize_nav_menu_item_types( $item_types ) {
if ( isset( $endpoints['dashboard'] ) ) { $item_types[] = array(
unset( $endpoints['dashboard'] ); 'title' => __( 'WooCommerce endpoints', 'woocommerce' ),
} 'type_label' => __( 'WooCommerce endpoint', 'woocommerce' ),
'type' => 'woocommerce_nav',
// Include missing lost password. 'object' => 'woocommerce_endpoint',
$endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
$endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
foreach ( $endpoints as $endpoint => $title ) {
$items[] = array(
'id' => $endpoint,
'title' => $title,
'type_label' => __( 'Custom Link', 'woocommerce' ),
'url' => esc_url_raw( wc_get_account_endpoint_url( $endpoint ) ),
); );
return $item_types;
} }
return $items; /**
* Register account endpoints to customize nav menu items.
*
* @since 3.1.0
* @param array $items List of nav menu items.
* @param string $type Nav menu type.
* @param string $object Nav menu object.
* @param integer $page Page number.
* @return array
*/
public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) {
if ( 'woocommerce_endpoint' !== $object ) {
return $items;
}
// Don't allow pagination since all items are loaded at once.
if ( 0 < $page ) {
return $items;
}
// Get items from account menu.
$endpoints = wc_get_account_menu_items();
// Remove dashboard item.
if ( isset( $endpoints['dashboard'] ) ) {
unset( $endpoints['dashboard'] );
}
// Include missing lost password.
$endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
$endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
foreach ( $endpoints as $endpoint => $title ) {
$items[] = array(
'id' => $endpoint,
'title' => $title,
'type_label' => __( 'Custom Link', 'woocommerce' ),
'url' => esc_url_raw( wc_get_account_endpoint_url( $endpoint ) ),
);
}
return $items;
}
} }
}
endif; endif;

View File

@ -14,103 +14,105 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
/**
* WC_Admin_Dashboard Class.
*/
class WC_Admin_Dashboard {
/** /**
* Hook in tabs. * WC_Admin_Dashboard Class.
*/ */
public function __construct() { class WC_Admin_Dashboard {
// Only hook in admin parts if the user has admin access
if ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) { /**
// If on network admin, only load the widget that works in that context and skip the rest. * Hook in tabs.
if ( is_multisite() && is_network_admin() ) { */
add_action( 'wp_network_dashboard_setup', array( $this, 'register_network_order_widget' ) ); public function __construct() {
} else { // Only hook in admin parts if the user has admin access
add_action( 'wp_dashboard_setup', array( $this, 'init' ) ); if ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) {
// If on network admin, only load the widget that works in that context and skip the rest.
if ( is_multisite() && is_network_admin() ) {
add_action( 'wp_network_dashboard_setup', array( $this, 'register_network_order_widget' ) );
} else {
add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
}
} }
} }
}
/** /**
* Init dashboard widgets. * Init dashboard widgets.
*/ */
public function init() { public function init() {
if ( current_user_can( 'publish_shop_orders' ) && post_type_supports( 'product', 'comments' ) ) { if ( current_user_can( 'publish_shop_orders' ) && post_type_supports( 'product', 'comments' ) ) {
wp_add_dashboard_widget( 'woocommerce_dashboard_recent_reviews', __( 'WooCommerce recent reviews', 'woocommerce' ), array( $this, 'recent_reviews' ) ); wp_add_dashboard_widget( 'woocommerce_dashboard_recent_reviews', __( 'WooCommerce recent reviews', 'woocommerce' ), array( $this, 'recent_reviews' ) );
}
wp_add_dashboard_widget( 'woocommerce_dashboard_status', __( 'WooCommerce status', 'woocommerce' ), array( $this, 'status_widget' ) );
// Network Order Widget.
if ( is_multisite() ) {
$this->register_network_order_widget();
}
} }
wp_add_dashboard_widget( 'woocommerce_dashboard_status', __( 'WooCommerce status', 'woocommerce' ), array( $this, 'status_widget' ) );
// Network Order Widget. /**
if ( is_multisite() ) { * Register the network order dashboard widget.
$this->register_network_order_widget(); */
public function register_network_order_widget() {
wp_add_dashboard_widget( 'woocommerce_network_orders', __( 'WooCommerce network orders', 'woocommerce' ), array( $this, 'network_orders' ) );
} }
}
/** /**
* Register the network order dashboard widget. * Get top seller from DB.
*/ *
public function register_network_order_widget() { * @return object
wp_add_dashboard_widget( 'woocommerce_network_orders', __( 'WooCommerce network orders', 'woocommerce' ), array( $this, 'network_orders' ) ); */
} private function get_top_seller() {
global $wpdb;
/** $query = array();
* Get top seller from DB. $query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
* @return object
*/
private function get_top_seller() {
global $wpdb;
$query = array();
$query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
FROM {$wpdb->posts} as posts"; FROM {$wpdb->posts} as posts";
$query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id "; $query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id ";
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id "; $query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id ";
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id "; $query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id ";
$query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) ";
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) "; $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) ";
$query['where'] .= "AND order_item_meta.meta_key = '_qty' "; $query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' "; $query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
$query['where'] .= "AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "' "; $query['where'] .= "AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "' ";
$query['where'] .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "' "; $query['where'] .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "' ";
$query['groupby'] = "GROUP BY product_id"; $query['groupby'] = 'GROUP BY product_id';
$query['orderby'] = "ORDER BY qty DESC"; $query['orderby'] = 'ORDER BY qty DESC';
$query['limits'] = "LIMIT 1"; $query['limits'] = 'LIMIT 1';
return $wpdb->get_row( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_top_seller_query', $query ) ) ); return $wpdb->get_row( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_top_seller_query', $query ) ) );
} }
/** /**
* Get sales report data. * Get sales report data.
* @return object *
*/ * @return object
private function get_sales_report_data() { */
include_once( dirname( __FILE__ ) . '/reports/class-wc-report-sales-by-date.php' ); private function get_sales_report_data() {
include_once dirname( __FILE__ ) . '/reports/class-wc-report-sales-by-date.php';
$sales_by_date = new WC_Report_Sales_By_Date(); $sales_by_date = new WC_Report_Sales_By_Date();
$sales_by_date->start_date = strtotime( date( 'Y-m-01', current_time( 'timestamp' ) ) ); $sales_by_date->start_date = strtotime( date( 'Y-m-01', current_time( 'timestamp' ) ) );
$sales_by_date->end_date = current_time( 'timestamp' ); $sales_by_date->end_date = current_time( 'timestamp' );
$sales_by_date->chart_groupby = 'day'; $sales_by_date->chart_groupby = 'day';
$sales_by_date->group_by_query = 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date)'; $sales_by_date->group_by_query = 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date)';
return $sales_by_date->get_report_data(); return $sales_by_date->get_report_data();
} }
/** /**
* Show status widget. * Show status widget.
*/ */
public function status_widget() { public function status_widget() {
include_once( dirname( __FILE__ ) . '/reports/class-wc-admin-report.php' ); include_once dirname( __FILE__ ) . '/reports/class-wc-admin-report.php';
$reports = new WC_Admin_Report(); $reports = new WC_Admin_Report();
echo '<ul class="wc_status_list">'; echo '<ul class="wc_status_list">';
if ( current_user_can( 'view_woocommerce_reports' ) && ( $report_data = $this->get_sales_report_data() ) ) { if ( current_user_can( 'view_woocommerce_reports' ) && ( $report_data = $this->get_sales_report_data() ) ) {
?> ?>
<li class="sales-this-month"> <li class="sales-this-month">
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=orders&range=month' ); ?>"> <a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=orders&range=month' ); ?>">
<?php echo $reports->sales_sparkline( '', max( 7, date( 'd', current_time( 'timestamp' ) ) ) ); ?> <?php echo $reports->sales_sparkline( '', max( 7, date( 'd', current_time( 'timestamp' ) ) ) ); ?>
<?php <?php
@ -118,16 +120,16 @@ class WC_Admin_Dashboard {
printf( printf(
__( '%s net sales this month', 'woocommerce' ), __( '%s net sales this month', 'woocommerce' ),
'<strong>' . wc_price( $report_data->net_sales ) . '</strong>' '<strong>' . wc_price( $report_data->net_sales ) . '</strong>'
); );
?> ?>
</a> </a>
</li> </li>
<?php <?php
} }
if ( current_user_can( 'view_woocommerce_reports' ) && ( $top_seller = $this->get_top_seller() ) && $top_seller->qty ) { if ( current_user_can( 'view_woocommerce_reports' ) && ( $top_seller = $this->get_top_seller() ) && $top_seller->qty ) {
?> ?>
<li class="best-seller-this-month"> <li class="best-seller-this-month">
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=' . $top_seller->product_id ); ?>"> <a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=' . $top_seller->product_id ); ?>">
<?php echo $reports->sales_sparkline( $top_seller->product_id, max( 7, date( 'd', current_time( 'timestamp' ) ) ), 'count' ); ?> <?php echo $reports->sales_sparkline( $top_seller->product_id, max( 7, date( 'd', current_time( 'timestamp' ) ) ), 'count' ); ?>
<?php <?php
@ -137,36 +139,36 @@ class WC_Admin_Dashboard {
'<strong>' . get_the_title( $top_seller->product_id ) . '</strong>', '<strong>' . get_the_title( $top_seller->product_id ) . '</strong>',
$top_seller->qty $top_seller->qty
); );
?> ?>
</a> </a>
</li> </li>
<?php <?php
}
$this->status_widget_order_rows();
$this->status_widget_stock_rows();
do_action( 'woocommerce_after_dashboard_status_widget', $reports );
echo '</ul>';
} }
$this->status_widget_order_rows(); /**
$this->status_widget_stock_rows(); * Show order data is status widget.
*/
private function status_widget_order_rows() {
if ( ! current_user_can( 'edit_shop_orders' ) ) {
return;
}
$on_hold_count = 0;
$processing_count = 0;
do_action( 'woocommerce_after_dashboard_status_widget', $reports ); foreach ( wc_get_order_types( 'order-count' ) as $type ) {
echo '</ul>'; $counts = (array) wp_count_posts( $type );
} $on_hold_count += isset( $counts['wc-on-hold'] ) ? $counts['wc-on-hold'] : 0;
$processing_count += isset( $counts['wc-processing'] ) ? $counts['wc-processing'] : 0;
/** }
* Show order data is status widget. ?>
*/ <li class="processing-orders">
private function status_widget_order_rows() {
if ( ! current_user_can( 'edit_shop_orders' ) ) {
return;
}
$on_hold_count = 0;
$processing_count = 0;
foreach ( wc_get_order_types( 'order-count' ) as $type ) {
$counts = (array) wp_count_posts( $type );
$on_hold_count += isset( $counts['wc-on-hold'] ) ? $counts['wc-on-hold'] : 0;
$processing_count += isset( $counts['wc-processing'] ) ? $counts['wc-processing'] : 0;
}
?>
<li class="processing-orders">
<a href="<?php echo admin_url( 'edit.php?post_status=wc-processing&post_type=shop_order' ); ?>"> <a href="<?php echo admin_url( 'edit.php?post_status=wc-processing&post_type=shop_order' ); ?>">
<?php <?php
/* translators: %s: order count */ /* translators: %s: order count */
@ -175,10 +177,10 @@ class WC_Admin_Dashboard {
$processing_count $processing_count
); );
?> ?>
</a> </a>
</li> </li>
<li class="on-hold-orders"> <li class="on-hold-orders">
<a href="<?php echo admin_url( 'edit.php?post_status=wc-on-hold&post_type=shop_order' ); ?>"> <a href="<?php echo admin_url( 'edit.php?post_status=wc-on-hold&post_type=shop_order' ); ?>">
<?php <?php
/* translators: %s: order count */ /* translators: %s: order count */
printf( printf(
@ -186,54 +188,58 @@ class WC_Admin_Dashboard {
$on_hold_count $on_hold_count
); );
?> ?>
</a> </a>
</li> </li>
<?php <?php
}
/**
* Show stock data is status widget.
*/
private function status_widget_stock_rows() {
global $wpdb;
// Get products using a query - this is too advanced for get_posts :(
$stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
$nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) );
$transient_name = 'wc_low_stock_count';
if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) {
$query_from = apply_filters( 'woocommerce_report_low_in_stock_query_from', "FROM {$wpdb->posts} as posts
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
WHERE 1=1
AND posts.post_type IN ( 'product', 'product_variation' )
AND posts.post_status = 'publish'
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}'
" );
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
} }
$transient_name = 'wc_outofstock_count'; /**
* Show stock data is status widget.
*/
private function status_widget_stock_rows() {
global $wpdb;
if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) { // Get products using a query - this is too advanced for get_posts :(
$query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts $stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id $nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) );
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id $transient_name = 'wc_low_stock_count';
WHERE 1=1
AND posts.post_type IN ( 'product', 'product_variation' ) if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) {
AND posts.post_status = 'publish' $query_from = apply_filters(
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' 'woocommerce_report_low_in_stock_query_from',
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}' "FROM {$wpdb->posts} as posts
" ); INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) ); INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 ); WHERE 1=1
} AND posts.post_type IN ( 'product', 'product_variation' )
?> AND posts.post_status = 'publish'
<li class="low-in-stock"> AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}'"
);
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
}
$transient_name = 'wc_outofstock_count';
if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) {
$query_from = apply_filters(
'woocommerce_report_out_of_stock_query_from',
"FROM {$wpdb->posts} as posts
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
WHERE 1=1
AND posts.post_type IN ( 'product', 'product_variation' )
AND posts.post_status = 'publish'
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}'"
);
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 );
}
?>
<li class="low-in-stock">
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=low_in_stock' ); ?>"> <a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=low_in_stock' ); ?>">
<?php <?php
/* translators: %s: order count */ /* translators: %s: order count */
@ -242,10 +248,10 @@ class WC_Admin_Dashboard {
$lowinstock_count $lowinstock_count
); );
?> ?>
</a> </a>
</li> </li>
<li class="out-of-stock"> <li class="out-of-stock">
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=out_of_stock' ); ?>"> <a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=out_of_stock' ); ?>">
<?php <?php
/* translators: %s: order count */ /* translators: %s: order count */
printf( printf(
@ -253,78 +259,81 @@ class WC_Admin_Dashboard {
$outofstock_count $outofstock_count
); );
?> ?>
</a> </a>
</li> </li>
<?php <?php
}
/**
* Recent reviews widget.
*/
public function recent_reviews() {
global $wpdb;
$query_from = apply_filters( 'woocommerce_report_recent_reviews_query_from', "FROM {$wpdb->comments} comments
LEFT JOIN {$wpdb->posts} posts ON (comments.comment_post_ID = posts.ID)
WHERE comments.comment_approved = '1'
AND comments.comment_type = ''
AND posts.post_password = ''
AND posts.post_type = 'product'
AND comments.comment_parent = 0
ORDER BY comments.comment_date_gmt DESC
LIMIT 5
" );
$comments = $wpdb->get_results( "
SELECT posts.ID, posts.post_title, comments.comment_author, comments.comment_ID, comments.comment_content
{$query_from};
" );
if ( $comments ) {
echo '<ul>';
foreach ( $comments as $comment ) {
echo '<li>';
echo get_avatar( $comment->comment_author, '32' );
$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
/* translators: %s: rating */
echo '<div class="star-rating"><span style="width:' . ( $rating * 20 ) . '%">' . sprintf( __( '%s out of 5', 'woocommerce' ), $rating ) . '</span></div>';
/* translators: %s: review author */
echo '<h4 class="meta"><a href="' . get_permalink( $comment->ID ) . '#comment-' . absint( $comment->comment_ID ) . '">' . esc_html( apply_filters( 'woocommerce_admin_dashboard_recent_reviews', $comment->post_title, $comment ) ) . '</a> ' . sprintf( __( 'reviewed by %s', 'woocommerce' ), esc_html( $comment->comment_author ) ) . '</h4>';
echo '<blockquote>' . wp_kses_data( $comment->comment_content ) . '</blockquote></li>';
}
echo '</ul>';
} else {
echo '<p>' . __( 'There are no product reviews yet.', 'woocommerce' ) . '</p>';
} }
}
/** /**
* Network orders widget. * Recent reviews widget.
*/ */
public function network_orders() { public function recent_reviews() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; global $wpdb;
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), WC_VERSION ); $query_from = apply_filters(
'woocommerce_report_recent_reviews_query_from',
"FROM {$wpdb->comments} comments
LEFT JOIN {$wpdb->posts} posts ON (comments.comment_post_ID = posts.ID)
WHERE comments.comment_approved = '1'
AND comments.comment_type = ''
AND posts.post_password = ''
AND posts.post_type = 'product'
AND comments.comment_parent = 0
ORDER BY comments.comment_date_gmt DESC
LIMIT 5"
);
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), WC_VERSION, true ); $comments = $wpdb->get_results(
"SELECT posts.ID, posts.post_title, comments.comment_author, comments.comment_ID, comments.comment_content {$query_from};"
);
$user = wp_get_current_user(); if ( $comments ) {
$blogs = get_blogs_of_user( $user->ID ); echo '<ul>';
$blog_ids = wp_list_pluck( $blogs, 'userblog_id' ); foreach ( $comments as $comment ) {
wp_localize_script( 'wc-network-orders', 'woocommerce_network_orders', array( echo '<li>';
'nonce' => wp_create_nonce( 'wp_rest' ),
'sites' => array_values( $blog_ids ), echo get_avatar( $comment->comment_author, '32' );
'order_endpoint' => get_rest_url( null, 'wc/v2/orders/network' ),
) ); $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
?>
<div class="post-type-shop_order"> /* translators: %s: rating */
echo '<div class="star-rating"><span style="width:' . ( $rating * 20 ) . '%">' . sprintf( __( '%s out of 5', 'woocommerce' ), $rating ) . '</span></div>';
/* translators: %s: review author */
echo '<h4 class="meta"><a href="' . get_permalink( $comment->ID ) . '#comment-' . absint( $comment->comment_ID ) . '">' . esc_html( apply_filters( 'woocommerce_admin_dashboard_recent_reviews', $comment->post_title, $comment ) ) . '</a> ' . sprintf( __( 'reviewed by %s', 'woocommerce' ), esc_html( $comment->comment_author ) ) . '</h4>';
echo '<blockquote>' . wp_kses_data( $comment->comment_content ) . '</blockquote></li>';
}
echo '</ul>';
} else {
echo '<p>' . __( 'There are no product reviews yet.', 'woocommerce' ) . '</p>';
}
}
/**
* Network orders widget.
*/
public function network_orders() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), WC_VERSION );
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), WC_VERSION, true );
$user = wp_get_current_user();
$blogs = get_blogs_of_user( $user->ID );
$blog_ids = wp_list_pluck( $blogs, 'userblog_id' );
wp_localize_script(
'wc-network-orders', 'woocommerce_network_orders', array(
'nonce' => wp_create_nonce( 'wp_rest' ),
'sites' => array_values( $blog_ids ),
'order_endpoint' => get_rest_url( null, 'wc/v2/orders/network' ),
)
);
?>
<div class="post-type-shop_order">
<div id="woocommerce-network-order-table-loading" class="woocommerce-network-order-table-loading is-active"> <div id="woocommerce-network-order-table-loading" class="woocommerce-network-order-table-loading is-active">
<p> <p>
<span class="spinner is-active"></span> <?php esc_html_e( 'Loading network orders', 'woocommerce' ); ?> <span class="spinner is-active"></span> <?php esc_html_e( 'Loading network orders', 'woocommerce' ); ?>
@ -367,9 +376,9 @@ class WC_Admin_Dashboard {
</script> </script>
</div> </div>
<?php <?php
} }
} }
endif; endif;

View File

@ -88,7 +88,7 @@ class WC_Admin_Duplicate_Product {
} }
if ( isset( $_GET['post'] ) ) { if ( isset( $_GET['post'] ) ) {
$notify_url = wp_nonce_url( admin_url( "edit.php?post_type=product&action=duplicate_product&post=" . absint( $_GET['post'] ) ), 'woocommerce-duplicate-product_' . $_GET['post'] ); $notify_url = wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&post=' . absint( $_GET['post'] ) ), 'woocommerce-duplicate-product_' . $_GET['post'] );
?> ?>
<div id="duplicate-action"><a class="submitduplicate duplication" href="<?php echo esc_url( $notify_url ); ?>"><?php _e( 'Copy to a new draft', 'woocommerce' ); ?></a></div> <div id="duplicate-action"><a class="submitduplicate duplication" href="<?php echo esc_url( $notify_url ); ?>"><?php _e( 'Copy to a new draft', 'woocommerce' ); ?></a></div>
<?php <?php

View File

@ -73,17 +73,21 @@ class WC_Admin_Exporters {
public function admin_scripts() { public function admin_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_localize_script( 'wc-product-export', 'wc_product_export_params', array( wp_localize_script(
'export_nonce' => wp_create_nonce( 'wc-product-export' ), 'wc-product-export',
) ); 'wc_product_export_params',
array(
'export_nonce' => wp_create_nonce( 'wc-product-export' ),
)
);
} }
/** /**
* Export page UI. * Export page UI.
*/ */
public function product_exporter() { public function product_exporter() {
include_once( WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php' ); include_once WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php';
include_once( dirname( __FILE__ ) . '/views/html-admin-page-product-export.php' ); include_once dirname( __FILE__ ) . '/views/html-admin-page-product-export.php';
} }
/** /**
@ -91,7 +95,7 @@ class WC_Admin_Exporters {
*/ */
public function download_export_file() { public function download_export_file() {
if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'product-csv' ) && 'download_product_csv' === wp_unslash( $_GET['action'] ) ) { // WPCS: input var ok, sanitization ok. if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'product-csv' ) && 'download_product_csv' === wp_unslash( $_GET['action'] ) ) { // WPCS: input var ok, sanitization ok.
include_once( WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php' ); include_once WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php';
$exporter = new WC_Product_CSV_Exporter(); $exporter = new WC_Product_CSV_Exporter();
if ( ! empty( $_GET['filename'] ) ) { // WPCS: input var ok. if ( ! empty( $_GET['filename'] ) ) { // WPCS: input var ok.
@ -112,7 +116,7 @@ class WC_Admin_Exporters {
wp_die( -1 ); wp_die( -1 );
} }
include_once( WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php' ); include_once WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php';
$step = isset( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; // WPCS: input var ok, sanitization ok. $step = isset( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; // WPCS: input var ok, sanitization ok.
$exporter = new WC_Product_CSV_Exporter(); $exporter = new WC_Product_CSV_Exporter();
@ -140,20 +144,31 @@ class WC_Admin_Exporters {
$exporter->set_page( $step ); $exporter->set_page( $step );
$exporter->generate_file(); $exporter->generate_file();
$query_args = apply_filters( 'woocommerce_export_get_ajax_query_args', array( 'nonce' => wp_create_nonce( 'product-csv' ), 'action' => 'download_product_csv', 'filename' => $exporter->get_filename() ) ); $query_args = apply_filters(
'woocommerce_export_get_ajax_query_args',
array(
'nonce' => wp_create_nonce( 'product-csv' ),
'action' => 'download_product_csv',
'filename' => $exporter->get_filename(),
)
);
if ( 100 === $exporter->get_percent_complete() ) { if ( 100 === $exporter->get_percent_complete() ) {
wp_send_json_success( array( wp_send_json_success(
'step' => 'done', array(
'percentage' => 100, 'step' => 'done',
'url' => add_query_arg( $query_args, admin_url( 'edit.php?post_type=product&page=product_exporter' ) ), 'percentage' => 100,
) ); 'url' => add_query_arg( $query_args, admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
)
);
} else { } else {
wp_send_json_success( array( wp_send_json_success(
'step' => ++$step, array(
'percentage' => $exporter->get_percent_complete(), 'step' => ++$step,
'columns' => $exporter->get_column_names(), 'percentage' => $exporter->get_percent_complete(),
) ); 'columns' => $exporter->get_column_names(),
)
);
} }
} }
} }

View File

@ -36,55 +36,63 @@ class WC_Admin_Help {
return; return;
} }
$screen->add_help_tab( array( $screen->add_help_tab(
'id' => 'woocommerce_support_tab', array(
'title' => __( 'Help &amp; Support', 'woocommerce' ), 'id' => 'woocommerce_support_tab',
'content' => 'title' => __( 'Help &amp; Support', 'woocommerce' ),
'<h2>' . __( 'Help &amp; Support', 'woocommerce' ) . '</h2>' . 'content' =>
'<p>' . sprintf( '<h2>' . __( 'Help &amp; Support', 'woocommerce' ) . '</h2>' .
/* translators: %s: Documentation URL */ '<p>' . sprintf(
__( 'Should you need help understanding, using, or extending WooCommerce, <a href="%s">please read our documentation</a>. You will find all kinds of resources including snippets, tutorials and much more.', 'woocommerce' ), /* translators: %s: Documentation URL */
'https://docs.woocommerce.com/documentation/plugins/woocommerce/?utm_source=helptab&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin' __( 'Should you need help understanding, using, or extending WooCommerce, <a href="%s">please read our documentation</a>. You will find all kinds of resources including snippets, tutorials and much more.', 'woocommerce' ),
) . '</p>' . 'https://docs.woocommerce.com/documentation/plugins/woocommerce/?utm_source=helptab&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin'
'<p>' . sprintf( ) . '</p>' .
/* translators: %s: Forum URL */ '<p>' . sprintf(
__( 'For further assistance with WooCommerce core you can use the <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WooCommerce, please <a href="%2$s">use our helpdesk</a>.', 'woocommerce' ), /* translators: %s: Forum URL */
'https://wordpress.org/support/plugin/woocommerce', __( 'For further assistance with WooCommerce core you can use the <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WooCommerce, please <a href="%2$s">use our helpdesk</a>.', 'woocommerce' ),
'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin' 'https://wordpress.org/support/plugin/woocommerce',
) . '</p>' . 'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin'
'<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' . ) . '</p>' .
'<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'woocommerce' ) . '</a> <a href="https://wordpress.org/support/plugin/woocommerce" class="button">' . __( 'Community forum', 'woocommerce' ) . '</a> <a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin" class="button">' . __( 'WooCommerce helpdesk', 'woocommerce' ) . '</a></p>', '<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
) ); '<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'woocommerce' ) . '</a> <a href="https://wordpress.org/support/plugin/woocommerce" class="button">' . __( 'Community forum', 'woocommerce' ) . '</a> <a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin" class="button">' . __( 'WooCommerce helpdesk', 'woocommerce' ) . '</a></p>',
)
);
$screen->add_help_tab( array( $screen->add_help_tab(
'id' => 'woocommerce_bugs_tab', array(
'title' => __( 'Found a bug?', 'woocommerce' ), 'id' => 'woocommerce_bugs_tab',
'content' => 'title' => __( 'Found a bug?', 'woocommerce' ),
'<h2>' . __( 'Found a bug?', 'woocommerce' ) . '</h2>' . 'content' =>
/* translators: 1: GitHub issues URL 2: GitHub contribution guide URL 3: System status report URL */ '<h2>' . __( 'Found a bug?', 'woocommerce' ) . '</h2>' .
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' . /* translators: 1: GitHub issues URL 2: GitHub contribution guide URL 3: System status report URL */
'<p><a href="https://github.com/woocommerce/woocommerce/issues?state=open" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>', '<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/issues?state=open" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>',
) ); )
);
$screen->add_help_tab( array( $screen->add_help_tab(
'id' => 'woocommerce_education_tab', array(
'title' => __( 'Education', 'woocommerce' ), 'id' => 'woocommerce_education_tab',
'content' => 'title' => __( 'Education', 'woocommerce' ),
'<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' . 'content' =>
'<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course offered by one of our educational partners.', 'woocommerce' ) . '</p>' . '<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' .
'<p><a href="https://woocommerce.com/educational-partners/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'View education partners', 'woocommerce' ) . '</a></p>', '<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course offered by one of our educational partners.', 'woocommerce' ) . '</p>' .
) ); '<p><a href="https://woocommerce.com/educational-partners/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'View education partners', 'woocommerce' ) . '</a></p>',
)
);
$screen->add_help_tab( array( $screen->add_help_tab(
'id' => 'woocommerce_onboard_tab', array(
'title' => __( 'Setup wizard', 'woocommerce' ), 'id' => 'woocommerce_onboard_tab',
'content' => 'title' => __( 'Setup wizard', 'woocommerce' ),
'<h2>' . __( 'Setup wizard', 'woocommerce' ) . '</h2>' . 'content' =>
'<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '</p>' . '<h2>' . __( 'Setup wizard', 'woocommerce' ) . '</h2>' .
'<p><a href="' . admin_url( 'index.php?page=wc-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'woocommerce' ) . '</a></p>', '<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '</p>' .
'<p><a href="' . admin_url( 'index.php?page=wc-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'woocommerce' ) . '</a></p>',
) ); )
);
$screen->set_help_sidebar( $screen->set_help_sidebar(
'<p><strong>' . __( 'For more information:', 'woocommerce' ) . '</strong></p>' . '<p><strong>' . __( 'For more information:', 'woocommerce' ) . '</strong></p>' .

View File

@ -89,8 +89,8 @@ class WC_Admin_Importers {
exit; exit;
} }
include_once( WC_ABSPATH . 'includes/import/class-wc-product-csv-importer.php' ); include_once WC_ABSPATH . 'includes/import/class-wc-product-csv-importer.php';
include_once( WC_ABSPATH . 'includes/admin/importers/class-wc-product-csv-importer-controller.php' ); include_once WC_ABSPATH . 'includes/admin/importers/class-wc-product-csv-importer-controller.php';
$importer = new WC_Product_CSV_Importer_Controller(); $importer = new WC_Product_CSV_Importer_Controller();
$importer->dispatch(); $importer->dispatch();
@ -102,7 +102,7 @@ class WC_Admin_Importers {
public function register_importers() { public function register_importers() {
if ( defined( 'WP_LOAD_IMPORTERS' ) ) { if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
add_action( 'import_start', array( $this, 'post_importer_compatibility' ) ); add_action( 'import_start', array( $this, 'post_importer_compatibility' ) );
register_importer( 'woocommerce_product_csv', __( 'WooCommerce products (CSV)', 'woocommerce' ), __( 'Import <strong>products</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'product_importer' ) ); register_importer( 'woocommerce_product_csv', __( 'WooCommerce products (CSV)', 'woocommerce' ), __( 'Import <strong>products</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'product_importer' ) );
register_importer( 'woocommerce_tax_rate_csv', __( 'WooCommerce tax rates (CSV)', 'woocommerce' ), __( 'Import <strong>tax rates</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'tax_rates_importer' ) ); register_importer( 'woocommerce_tax_rate_csv', __( 'WooCommerce tax rates (CSV)', 'woocommerce' ), __( 'Import <strong>tax rates</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'tax_rates_importer' ) );
} }
} }
@ -123,7 +123,7 @@ class WC_Admin_Importers {
} }
// includes // includes
require( dirname( __FILE__ ) . '/importers/class-wc-tax-rate-importer.php' ); require dirname( __FILE__ ) . '/importers/class-wc-tax-rate-importer.php';
// Dispatch // Dispatch
$importer = new WC_Tax_Rate_Importer(); $importer = new WC_Tax_Rate_Importer();
@ -158,25 +158,29 @@ class WC_Admin_Importers {
// Create the taxonomy // Create the taxonomy
if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies() ) ) { if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies() ) ) {
wc_create_attribute( array( wc_create_attribute(
'name' => $attribute_name, array(
'slug' => $attribute_name, 'name' => $attribute_name,
'type' => 'select', 'slug' => $attribute_name,
'order_by' => 'menu_order', 'type' => 'select',
'has_archives' => false, 'order_by' => 'menu_order',
) ); 'has_archives' => false,
)
);
} }
// Register the taxonomy now so that the import works! // Register the taxonomy now so that the import works!
register_taxonomy( register_taxonomy(
$term['domain'], $term['domain'],
apply_filters( 'woocommerce_taxonomy_objects_' . $term['domain'], array( 'product' ) ), apply_filters( 'woocommerce_taxonomy_objects_' . $term['domain'], array( 'product' ) ),
apply_filters( 'woocommerce_taxonomy_args_' . $term['domain'], array( apply_filters(
'hierarchical' => true, 'woocommerce_taxonomy_args_' . $term['domain'], array(
'show_ui' => false, 'hierarchical' => true,
'query_var' => true, 'show_ui' => false,
'rewrite' => false, 'query_var' => true,
) ) 'rewrite' => false,
)
)
); );
} }
} }
@ -198,8 +202,8 @@ class WC_Admin_Importers {
wp_die( -1 ); wp_die( -1 );
} }
include_once( WC_ABSPATH . 'includes/admin/importers/class-wc-product-csv-importer-controller.php' ); include_once WC_ABSPATH . 'includes/admin/importers/class-wc-product-csv-importer-controller.php';
include_once( WC_ABSPATH . 'includes/import/class-wc-product-csv-importer.php' ); include_once WC_ABSPATH . 'includes/import/class-wc-product-csv-importer.php';
$file = wc_clean( $_POST['file'] ); $file = wc_clean( $_POST['file'] );
$params = array( $params = array(
@ -228,36 +232,40 @@ class WC_Admin_Importers {
if ( 100 === $percent_complete ) { if ( 100 === $percent_complete ) {
// Clear temp meta. // Clear temp meta.
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) ); $wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) );
$wpdb->query( " $wpdb->query(
DELETE {$wpdb->posts}, {$wpdb->postmeta}, {$wpdb->term_relationships} "DELETE {$wpdb->posts}, {$wpdb->postmeta}, {$wpdb->term_relationships}
FROM {$wpdb->posts} FROM {$wpdb->posts}
LEFT JOIN {$wpdb->term_relationships} ON ( {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id ) LEFT JOIN {$wpdb->term_relationships} ON ( {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id )
LEFT JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id ) LEFT JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )
LEFT JOIN {$wpdb->term_taxonomy} ON ( {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id ) LEFT JOIN {$wpdb->term_taxonomy} ON ( {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id )
LEFT JOIN {$wpdb->terms} ON ( {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id ) LEFT JOIN {$wpdb->terms} ON ( {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id )
WHERE {$wpdb->posts}.post_type IN ( 'product', 'product_variation' ) WHERE {$wpdb->posts}.post_type IN ( 'product', 'product_variation' )
AND {$wpdb->posts}.post_status = 'importing' AND {$wpdb->posts}.post_status = 'importing'"
" ); );
// Send success. // Send success.
wp_send_json_success( array( wp_send_json_success(
'position' => 'done', array(
'percentage' => 100, 'position' => 'done',
'url' => add_query_arg( array( 'nonce' => wp_create_nonce( 'product-csv' ) ), admin_url( 'edit.php?post_type=product&page=product_importer&step=done' ) ), 'percentage' => 100,
'imported' => count( $results['imported'] ), 'url' => add_query_arg( array( 'nonce' => wp_create_nonce( 'product-csv' ) ), admin_url( 'edit.php?post_type=product&page=product_importer&step=done' ) ),
'failed' => count( $results['failed'] ), 'imported' => count( $results['imported'] ),
'updated' => count( $results['updated'] ), 'failed' => count( $results['failed'] ),
'skipped' => count( $results['skipped'] ), 'updated' => count( $results['updated'] ),
) ); 'skipped' => count( $results['skipped'] ),
)
);
} else { } else {
wp_send_json_success( array( wp_send_json_success(
'position' => $importer->get_file_position(), array(
'percentage' => $percent_complete, 'position' => $importer->get_file_position(),
'imported' => count( $results['imported'] ), 'percentage' => $percent_complete,
'failed' => count( $results['failed'] ), 'imported' => count( $results['imported'] ),
'updated' => count( $results['updated'] ), 'failed' => count( $results['failed'] ),
'skipped' => count( $results['skipped'] ), 'updated' => count( $results['updated'] ),
) ); 'skipped' => count( $results['skipped'] ),
)
);
} }
} }
} }

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
if ( ! class_exists( 'WP_List_Table' ) ) { if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
} }
class WC_Admin_Log_Table_List extends WP_List_Table { class WC_Admin_Log_Table_List extends WP_List_Table {
@ -22,11 +22,13 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
* Initialize the log table list. * Initialize the log table list.
*/ */
public function __construct() { public function __construct() {
parent::__construct( array( parent::__construct(
'singular' => 'log', array(
'plural' => 'logs', 'singular' => 'log',
'ajax' => false, 'plural' => 'logs',
) ); 'ajax' => false,
)
);
} }
/** /**
@ -37,14 +39,38 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
public function level_dropdown() { public function level_dropdown() {
$levels = array( $levels = array(
array( 'value' => WC_Log_Levels::EMERGENCY, 'label' => __( 'Emergency', 'woocommerce' ) ), array(
array( 'value' => WC_Log_Levels::ALERT, 'label' => __( 'Alert', 'woocommerce' ) ), 'value' => WC_Log_Levels::EMERGENCY,
array( 'value' => WC_Log_Levels::CRITICAL, 'label' => __( 'Critical', 'woocommerce' ) ), 'label' => __( 'Emergency', 'woocommerce' ),
array( 'value' => WC_Log_Levels::ERROR, 'label' => __( 'Error', 'woocommerce' ) ), ),
array( 'value' => WC_Log_Levels::WARNING, 'label' => __( 'Warning', 'woocommerce' ) ), array(
array( 'value' => WC_Log_Levels::NOTICE, 'label' => __( 'Notice', 'woocommerce' ) ), 'value' => WC_Log_Levels::ALERT,
array( 'value' => WC_Log_Levels::INFO, 'label' => __( 'Info', 'woocommerce' ) ), 'label' => __( 'Alert', 'woocommerce' ),
array( 'value' => WC_Log_Levels::DEBUG, 'label' => __( 'Debug', 'woocommerce' ) ), ),
array(
'value' => WC_Log_Levels::CRITICAL,
'label' => __( 'Critical', 'woocommerce' ),
),
array(
'value' => WC_Log_Levels::ERROR,
'label' => __( 'Error', 'woocommerce' ),
),
array(
'value' => WC_Log_Levels::WARNING,
'label' => __( 'Warning', 'woocommerce' ),
),
array(
'value' => WC_Log_Levels::NOTICE,
'label' => __( 'Notice', 'woocommerce' ),
),
array(
'value' => WC_Log_Levels::INFO,
'label' => __( 'Info', 'woocommerce' ),
),
array(
'value' => WC_Log_Levels::DEBUG,
'label' => __( 'Debug', 'woocommerce' ),
),
); );
$selected_level = isset( $_REQUEST['level'] ) ? $_REQUEST['level'] : ''; $selected_level = isset( $_REQUEST['level'] ) ? $_REQUEST['level'] : '';
@ -52,13 +78,16 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
<label for="filter-by-level" class="screen-reader-text"><?php _e( 'Filter by level', 'woocommerce' ); ?></label> <label for="filter-by-level" class="screen-reader-text"><?php _e( 'Filter by level', 'woocommerce' ); ?></label>
<select name="level" id="filter-by-level"> <select name="level" id="filter-by-level">
<option<?php selected( $selected_level, '' ); ?> value=""><?php _e( 'All levels', 'woocommerce' ); ?></option> <option<?php selected( $selected_level, '' ); ?> value=""><?php _e( 'All levels', 'woocommerce' ); ?></option>
<?php foreach ( $levels as $l ) { <?php
printf( '<option%1$s value="%2$s">%3$s</option>', foreach ( $levels as $l ) {
printf(
'<option%1$s value="%2$s">%3$s</option>',
selected( $selected_level, $l['value'], false ), selected( $selected_level, $l['value'], false ),
esc_attr( $l['value'] ), esc_attr( $l['value'] ),
esc_html( $l['label'] ) esc_html( $l['label'] )
); );
} ?> }
?>
</select> </select>
<?php <?php
} }
@ -72,9 +101,9 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
return array( return array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'timestamp' => __( 'Timestamp', 'woocommerce' ), 'timestamp' => __( 'Timestamp', 'woocommerce' ),
'level' => __( 'Level', 'woocommerce' ), 'level' => __( 'Level', 'woocommerce' ),
'message' => __( 'Message', 'woocommerce' ), 'message' => __( 'Message', 'woocommerce' ),
'source' => __( 'Source', 'woocommerce' ), 'source' => __( 'Source', 'woocommerce' ),
); );
} }
@ -95,10 +124,12 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
* @return string * @return string
*/ */
public function column_timestamp( $log ) { public function column_timestamp( $log ) {
return esc_html( mysql2date( return esc_html(
get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), mysql2date(
$log['timestamp'] get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),
) ); $log['timestamp']
)
);
} }
/** /**
@ -111,17 +142,17 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
$level_key = WC_Log_Levels::get_severity_level( $log['level'] ); $level_key = WC_Log_Levels::get_severity_level( $log['level'] );
$levels = array( $levels = array(
'emergency' => __( 'Emergency', 'woocommerce' ), 'emergency' => __( 'Emergency', 'woocommerce' ),
'alert' => __( 'Alert', 'woocommerce' ), 'alert' => __( 'Alert', 'woocommerce' ),
'critical' => __( 'Critical', 'woocommerce' ), 'critical' => __( 'Critical', 'woocommerce' ),
'error' => __( 'Error', 'woocommerce' ), 'error' => __( 'Error', 'woocommerce' ),
'warning' => __( 'Warning', 'woocommerce' ), 'warning' => __( 'Warning', 'woocommerce' ),
'notice' => __( 'Notice', 'woocommerce' ), 'notice' => __( 'Notice', 'woocommerce' ),
'info' => __( 'Info', 'woocommerce' ), 'info' => __( 'Info', 'woocommerce' ),
'debug' => __( 'Debug', 'woocommerce' ), 'debug' => __( 'Debug', 'woocommerce' ),
); );
if ( isset( $levels[ $level_key ] ) ) { if ( isset( $levels[ $level_key ] ) ) {
$level = $levels[ $level_key ]; $level = $levels[ $level_key ];
$level_class = sanitize_html_class( 'log-level--' . $level_key ); $level_class = sanitize_html_class( 'log-level--' . $level_key );
return '<span class="log-level ' . $level_class . '">' . esc_html( $level ) . '</span>'; return '<span class="log-level ' . $level_class . '">' . esc_html( $level ) . '</span>';
} else { } else {
@ -183,8 +214,8 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
protected function get_sortable_columns() { protected function get_sortable_columns() {
return array( return array(
'timestamp' => array( 'timestamp', true ), 'timestamp' => array( 'timestamp', true ),
'level' => array( 'level', true ), 'level' => array( 'level', true ),
'source' => array( 'source', true ), 'source' => array( 'source', true ),
); );
} }
@ -196,12 +227,12 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
protected function source_dropdown() { protected function source_dropdown() {
global $wpdb; global $wpdb;
$sources = $wpdb->get_col( " $sources = $wpdb->get_col(
SELECT DISTINCT source "SELECT DISTINCT source
FROM {$wpdb->prefix}woocommerce_log FROM {$wpdb->prefix}woocommerce_log
WHERE source != '' WHERE source != ''
ORDER BY source ASC ORDER BY source ASC"
" ); );
if ( ! empty( $sources ) ) { if ( ! empty( $sources ) ) {
$selected_source = isset( $_REQUEST['source'] ) ? $_REQUEST['source'] : ''; $selected_source = isset( $_REQUEST['source'] ) ? $_REQUEST['source'] : '';
@ -209,13 +240,16 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
<label for="filter-by-source" class="screen-reader-text"><?php _e( 'Filter by source', 'woocommerce' ); ?></label> <label for="filter-by-source" class="screen-reader-text"><?php _e( 'Filter by source', 'woocommerce' ); ?></label>
<select name="source" id="filter-by-source"> <select name="source" id="filter-by-source">
<option<?php selected( $selected_source, '' ); ?> value=""><?php _e( 'All sources', 'woocommerce' ); ?></option> <option<?php selected( $selected_source, '' ); ?> value=""><?php _e( 'All sources', 'woocommerce' ); ?></option>
<?php foreach ( $sources as $s ) { <?php
printf( '<option%1$s value="%2$s">%3$s</option>', foreach ( $sources as $s ) {
printf(
'<option%1$s value="%2$s">%3$s</option>',
selected( $selected_source, $s, false ), selected( $selected_source, $s, false ),
esc_attr( $s ), esc_attr( $s ),
esc_html( $s ) esc_html( $s )
); );
} ?> }
?>
</select> </select>
<?php <?php
} }
@ -249,11 +283,13 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
$query_count = "SELECT COUNT(log_id) FROM {$wpdb->prefix}woocommerce_log {$where}"; $query_count = "SELECT COUNT(log_id) FROM {$wpdb->prefix}woocommerce_log {$where}";
$total_items = $wpdb->get_var( $query_count ); $total_items = $wpdb->get_var( $query_count );
$this->set_pagination_args( array( $this->set_pagination_args(
'total_items' => $total_items, array(
'per_page' => $per_page, 'total_items' => $total_items,
'total_pages' => ceil( $total_items / $per_page ), 'per_page' => $per_page,
) ); 'total_pages' => ceil( $total_items / $per_page ),
)
);
} }
/** /**
@ -280,7 +316,7 @@ class WC_Admin_Log_Table_List extends WP_List_Table {
protected function get_items_query_offset() { protected function get_items_query_offset() {
global $wpdb; global $wpdb;
$per_page = $this->get_items_per_page( 'woocommerce_status_log_items_per_page', 10 ); $per_page = $this->get_items_per_page( 'woocommerce_status_log_items_per_page', 10 );
$current_page = $this->get_pagenum(); $current_page = $this->get_pagenum();
if ( 1 < $current_page ) { if ( 1 < $current_page ) {
$offset = $per_page * ( $current_page - 1 ); $offset = $per_page * ( $current_page - 1 );

View File

@ -353,12 +353,14 @@ class WC_Admin_Menus {
} }
// Add an option to visit the store. // Add an option to visit the store.
$wp_admin_bar->add_node( array( $wp_admin_bar->add_node(
'parent' => 'site-name', array(
'id' => 'view-store', 'parent' => 'site-name',
'title' => __( 'Visit Store', 'woocommerce' ), 'id' => 'view-store',
'href' => wc_get_page_permalink( 'shop' ), 'title' => __( 'Visit Store', 'woocommerce' ),
) ); 'href' => wc_get_page_permalink( 'shop' ),
)
);
} }
} }

View File

@ -31,7 +31,7 @@ class WC_Admin_Meta_Boxes {
* *
* @var array * @var array
*/ */
public static $meta_box_errors = array(); public static $meta_box_errors = array();
/** /**
* Constructor. * Constructor.
@ -74,6 +74,7 @@ class WC_Admin_Meta_Boxes {
/** /**
* Add an error message. * Add an error message.
*
* @param string $text * @param string $text
*/ */
public static function add_error( $text ) { public static function add_error( $text ) {
@ -177,7 +178,7 @@ class WC_Admin_Meta_Boxes {
/** /**
* Check if we're saving, the trigger an action based on the post type. * Check if we're saving, the trigger an action based on the post type.
* *
* @param int $post_id * @param int $post_id
* @param object $post * @param object $post
*/ */
public function save_meta_boxes( $post_id, $post ) { public function save_meta_boxes( $post_id, $post ) {

View File

@ -19,12 +19,14 @@ class WC_Admin_Notices {
/** /**
* Stores notices. * Stores notices.
*
* @var array * @var array
*/ */
private static $notices = array(); private static $notices = array();
/** /**
* Array of notices - name => callback. * Array of notices - name => callback.
*
* @var array * @var array
*/ */
private static $core_notices = array( private static $core_notices = array(
@ -62,6 +64,7 @@ class WC_Admin_Notices {
/** /**
* Get notices * Get notices
*
* @return array * @return array
*/ */
public static function get_notices() { public static function get_notices() {
@ -91,6 +94,7 @@ class WC_Admin_Notices {
/** /**
* Show a notice. * Show a notice.
*
* @param string $name * @param string $name
*/ */
public static function add_notice( $name ) { public static function add_notice( $name ) {
@ -99,6 +103,7 @@ class WC_Admin_Notices {
/** /**
* Remove a notice from being displayed. * Remove a notice from being displayed.
*
* @param string $name * @param string $name
*/ */
public static function remove_notice( $name ) { public static function remove_notice( $name ) {
@ -108,7 +113,8 @@ class WC_Admin_Notices {
/** /**
* See if a notice is being shown. * See if a notice is being shown.
* @param string $name *
* @param string $name
* @return boolean * @return boolean
*/ */
public static function has_notice( $name ) { public static function has_notice( $name ) {
@ -162,6 +168,7 @@ class WC_Admin_Notices {
/** /**
* Add a custom notice. * Add a custom notice.
*
* @param string $name * @param string $name
* @param string $notice_html * @param string $notice_html
*/ */
@ -182,7 +189,7 @@ class WC_Admin_Notices {
$notice_html = get_option( 'woocommerce_admin_notice_' . $notice ); $notice_html = get_option( 'woocommerce_admin_notice_' . $notice );
if ( $notice_html ) { if ( $notice_html ) {
include( 'views/html-notice-custom.php' ); include 'views/html-notice-custom.php';
} }
} }
} }
@ -196,12 +203,12 @@ class WC_Admin_Notices {
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) { if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
$updater = new WC_Background_Updater(); $updater = new WC_Background_Updater();
if ( $updater->is_updating() || ! empty( $_GET['do_update_woocommerce'] ) ) { if ( $updater->is_updating() || ! empty( $_GET['do_update_woocommerce'] ) ) {
include( 'views/html-notice-updating.php' ); include 'views/html-notice-updating.php';
} else { } else {
include( 'views/html-notice-update.php' ); include 'views/html-notice-update.php';
} }
} else { } else {
include( 'views/html-notice-updated.php' ); include 'views/html-notice-updated.php';
} }
} }
@ -209,7 +216,7 @@ class WC_Admin_Notices {
* If we have just installed, show a message with the install pages button. * If we have just installed, show a message with the install pages button.
*/ */
public static function install_notice() { public static function install_notice() {
include( 'views/html-notice-install.php' ); include 'views/html-notice-install.php';
} }
/** /**
@ -221,7 +228,7 @@ class WC_Admin_Notices {
wc_deprecated_function( 'WC_Admin_Notices::theme_check_notice', '3.3.0' ); wc_deprecated_function( 'WC_Admin_Notices::theme_check_notice', '3.3.0' );
if ( ! current_theme_supports( 'woocommerce' ) ) { if ( ! current_theme_supports( 'woocommerce' ) ) {
include( 'views/html-notice-theme-support.php' ); include 'views/html-notice-theme-support.php';
} }
} }
@ -257,7 +264,7 @@ class WC_Admin_Notices {
} }
if ( $outdated ) { if ( $outdated ) {
include( 'views/html-notice-template-check.php' ); include 'views/html-notice-template-check.php';
} else { } else {
self::remove_notice( 'template_files' ); self::remove_notice( 'template_files' );
} }
@ -278,7 +285,7 @@ class WC_Admin_Notices {
} }
if ( $enabled ) { if ( $enabled ) {
include( 'views/html-notice-legacy-shipping.php' ); include 'views/html-notice-legacy-shipping.php';
} else { } else {
self::remove_notice( 'template_files' ); self::remove_notice( 'template_files' );
} }
@ -293,7 +300,7 @@ class WC_Admin_Notices {
$method_count = wc_get_shipping_method_count(); $method_count = wc_get_shipping_method_count();
if ( $product_count->publish > 0 && 0 === $method_count ) { if ( $product_count->publish > 0 && 0 === $method_count ) {
include( 'views/html-notice-no-shipping-methods.php' ); include 'views/html-notice-no-shipping-methods.php';
} }
if ( $method_count > 0 ) { if ( $method_count > 0 ) {
@ -313,7 +320,7 @@ class WC_Admin_Notices {
return; return;
} }
if ( empty( $_GET['action'] ) ) { if ( empty( $_GET['action'] ) ) {
include( 'views/html-notice-simplify-commerce.php' ); include 'views/html-notice-simplify-commerce.php';
} }
} }
@ -321,7 +328,7 @@ class WC_Admin_Notices {
* Notice shown when regenerating thumbnails background process is running. * Notice shown when regenerating thumbnails background process is running.
*/ */
public static function regenerating_thumbnails_notice() { public static function regenerating_thumbnails_notice() {
include( 'views/html-notice-regenerating-thumbnails.php' ); include 'views/html-notice-regenerating-thumbnails.php';
} }
} }

View File

@ -73,7 +73,7 @@ class WC_Admin_Permalink_Settings {
*/ */
public function product_category_slug_input() { public function product_category_slug_input() {
?> ?>
<input name="woocommerce_product_category_slug" type="text" class="regular-text code" value="<?php echo esc_attr( $this->permalinks['category_base'] ); ?>" placeholder="<?php echo esc_attr_x( 'product-category', 'slug', 'woocommerce' ) ?>" /> <input name="woocommerce_product_category_slug" type="text" class="regular-text code" value="<?php echo esc_attr( $this->permalinks['category_base'] ); ?>" placeholder="<?php echo esc_attr_x( 'product-category', 'slug', 'woocommerce' ); ?>" />
<?php <?php
} }
@ -82,7 +82,7 @@ class WC_Admin_Permalink_Settings {
*/ */
public function product_tag_slug_input() { public function product_tag_slug_input() {
?> ?>
<input name="woocommerce_product_tag_slug" type="text" class="regular-text code" value="<?php echo esc_attr( $this->permalinks['tag_base'] ); ?>" placeholder="<?php echo esc_attr_x( 'product-tag', 'slug', 'woocommerce' ) ?>" /> <input name="woocommerce_product_tag_slug" type="text" class="regular-text code" value="<?php echo esc_attr( $this->permalinks['tag_base'] ); ?>" placeholder="<?php echo esc_attr_x( 'product-tag', 'slug', 'woocommerce' ); ?>" />
<?php <?php
} }
@ -102,9 +102,9 @@ class WC_Admin_Permalink_Settings {
/* translators: %s: Home URL */ /* translators: %s: Home URL */
echo wp_kses_post( wpautop( sprintf( __( 'If you like, you may enter custom structures for your product URLs here. For example, using <code>shop</code> would make your product links like <code>%sshop/sample-product/</code>. This setting affects product URLs only, not things such as product categories.', 'woocommerce' ), esc_url( home_url( '/' ) ) ) ) ); echo wp_kses_post( wpautop( sprintf( __( 'If you like, you may enter custom structures for your product URLs here. For example, using <code>shop</code> would make your product links like <code>%sshop/sample-product/</code>. This setting affects product URLs only, not things such as product categories.', 'woocommerce' ), esc_url( home_url( '/' ) ) ) ) );
$shop_page_id = wc_get_page_id( 'shop' ); $shop_page_id = wc_get_page_id( 'shop' );
$base_slug = urldecode( ( $shop_page_id > 0 && get_post( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : _x( 'shop', 'default-slug', 'woocommerce' ) ); $base_slug = urldecode( ( $shop_page_id > 0 && get_post( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : _x( 'shop', 'default-slug', 'woocommerce' ) );
$product_base = _x( 'product', 'default-slug', 'woocommerce' ); $product_base = _x( 'product', 'default-slug', 'woocommerce' );
$structures = array( $structures = array(
0 => '', 0 => '',

View File

@ -33,9 +33,9 @@ class WC_Admin_Pointers {
} }
switch ( $screen->id ) { switch ( $screen->id ) {
case 'product' : case 'product':
$this->create_product_tutorial(); $this->create_product_tutorial();
break; break;
} }
} }
@ -49,8 +49,8 @@ class WC_Admin_Pointers {
// These pointers will chain - they will not be shown at once. // These pointers will chain - they will not be shown at once.
$pointers = array( $pointers = array(
'pointers' => array( 'pointers' => array(
'title' => array( 'title' => array(
'target' => "#title", 'target' => '#title',
'next' => 'content', 'next' => 'content',
'next_trigger' => array( 'next_trigger' => array(
'target' => '#title', 'target' => '#title',
@ -65,8 +65,8 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'content' => array( 'content' => array(
'target' => "#wp-content-editor-container", 'target' => '#wp-content-editor-container',
'next' => 'product-type', 'next' => 'product-type',
'next_trigger' => array(), 'next_trigger' => array(),
'options' => array( 'options' => array(
@ -78,14 +78,14 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'product-type' => array( 'product-type' => array(
'target' => "#product-type", 'target' => '#product-type',
'next' => 'virtual', 'next' => 'virtual',
'next_trigger' => array( 'next_trigger' => array(
'target' => "#product-type", 'target' => '#product-type',
'event' => 'change blur click', 'event' => 'change blur click',
), ),
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Choose product type', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Choose product type', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'Choose a type for this product. Simple is suitable for most physical goods and services (we recommend setting up a simple product for now).', 'woocommerce' ) . '</p>' . '<p>' . esc_html__( 'Choose a type for this product. Simple is suitable for most physical goods and services (we recommend setting up a simple product for now).', 'woocommerce' ) . '</p>' .
'<p>' . esc_html__( 'Variable is for more complex products such as t-shirts with multiple sizes.', 'woocommerce' ) . '</p>' . '<p>' . esc_html__( 'Variable is for more complex products such as t-shirts with multiple sizes.', 'woocommerce' ) . '</p>' .
@ -97,14 +97,14 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'virtual' => array( 'virtual' => array(
'target' => "#_virtual", 'target' => '#_virtual',
'next' => 'downloadable', 'next' => 'downloadable',
'next_trigger' => array( 'next_trigger' => array(
'target' => "#_virtual", 'target' => '#_virtual',
'event' => 'change', 'event' => 'change',
), ),
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Virtual products', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Virtual products', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'Check the "Virtual" box if this is a non-physical item, for example a service, which does not need shipping.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'Check the "Virtual" box if this is a non-physical item, for example a service, which does not need shipping.', 'woocommerce' ) . '</p>',
'position' => array( 'position' => array(
@ -113,14 +113,14 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'downloadable' => array( 'downloadable' => array(
'target' => "#_downloadable", 'target' => '#_downloadable',
'next' => 'regular_price', 'next' => 'regular_price',
'next_trigger' => array( 'next_trigger' => array(
'target' => "#_downloadable", 'target' => '#_downloadable',
'event' => 'change', 'event' => 'change',
), ),
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Downloadable products', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Downloadable products', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'If purchasing this product gives a customer access to a downloadable file, e.g. software, check this box.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'If purchasing this product gives a customer access to a downloadable file, e.g. software, check this box.', 'woocommerce' ) . '</p>',
'position' => array( 'position' => array(
@ -129,14 +129,14 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'regular_price' => array( 'regular_price' => array(
'target' => "#_regular_price", 'target' => '#_regular_price',
'next' => 'postexcerpt', 'next' => 'postexcerpt',
'next_trigger' => array( 'next_trigger' => array(
'target' => "#_regular_price", 'target' => '#_regular_price',
'event' => 'input', 'event' => 'input',
), ),
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Prices', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Prices', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'Next you need to give your product a price.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'Next you need to give your product a price.', 'woocommerce' ) . '</p>',
'position' => array( 'position' => array(
@ -145,14 +145,14 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'postexcerpt' => array( 'postexcerpt' => array(
'target' => "#postexcerpt", 'target' => '#postexcerpt',
'next' => 'postimagediv', 'next' => 'postimagediv',
'next_trigger' => array( 'next_trigger' => array(
'target' => "#postexcerpt", 'target' => '#postexcerpt',
'event' => 'input', 'event' => 'input',
), ),
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Product short description', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Product short description', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'Add a quick summary for your product here. This will appear on the product page under the product name.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'Add a quick summary for your product here. This will appear on the product page under the product name.', 'woocommerce' ) . '</p>',
'position' => array( 'position' => array(
@ -161,9 +161,9 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'postimagediv' => array( 'postimagediv' => array(
'target' => "#postimagediv", 'target' => '#postimagediv',
'next' => 'product_tag', 'next' => 'product_tag',
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Product images', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Product images', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( "Upload or assign an image to your product here. This image will be shown in your store's catalog.", 'woocommerce' ) . '</p>', '<p>' . esc_html__( "Upload or assign an image to your product here. This image will be shown in your store's catalog.", 'woocommerce' ) . '</p>',
@ -173,9 +173,9 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'product_tag' => array( 'product_tag' => array(
'target' => "#tagsdiv-product_tag", 'target' => '#tagsdiv-product_tag',
'next' => 'product_catdiv', 'next' => 'product_catdiv',
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Product tags', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Product tags', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'You can optionally "tag" your products here. Tags are a method of labeling your products to make them easier for customers to find.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'You can optionally "tag" your products here. Tags are a method of labeling your products to make them easier for customers to find.', 'woocommerce' ) . '</p>',
@ -186,8 +186,8 @@ class WC_Admin_Pointers {
), ),
), ),
'product_catdiv' => array( 'product_catdiv' => array(
'target' => "#product_catdiv", 'target' => '#product_catdiv',
'next' => 'submitdiv', 'next' => 'submitdiv',
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Product categories', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Product categories', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'Optionally assign categories to your products to make them easier to browse through and find in your store.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'Optionally assign categories to your products to make them easier to browse through and find in your store.', 'woocommerce' ) . '</p>',
@ -197,9 +197,9 @@ class WC_Admin_Pointers {
), ),
), ),
), ),
'submitdiv' => array( 'submitdiv' => array(
'target' => "#submitdiv", 'target' => '#submitdiv',
'next' => '', 'next' => '',
'options' => array( 'options' => array(
'content' => '<h3>' . esc_html__( 'Publish your product!', 'woocommerce' ) . '</h3>' . 'content' => '<h3>' . esc_html__( 'Publish your product!', 'woocommerce' ) . '</h3>' .
'<p>' . esc_html__( 'When you are finished editing your product, hit the "Publish" button to publish your product to your store.', 'woocommerce' ) . '</p>', '<p>' . esc_html__( 'When you are finished editing your product, hit the "Publish" button to publish your product to your store.', 'woocommerce' ) . '</p>',
@ -217,14 +217,15 @@ class WC_Admin_Pointers {
/** /**
* Enqueue pointers and add script to page. * Enqueue pointers and add script to page.
*
* @param array $pointers * @param array $pointers
*/ */
public function enqueue_pointers( $pointers ) { public function enqueue_pointers( $pointers ) {
$pointers = wp_json_encode( $pointers ); $pointers = wp_json_encode( $pointers );
wp_enqueue_style( 'wp-pointer' ); wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' );
wc_enqueue_js( " wc_enqueue_js(
jQuery( function( $ ) { "jQuery( function( $ ) {
var wc_pointers = {$pointers}; var wc_pointers = {$pointers};
setTimeout( init_wc_pointers, 800 ); setTimeout( init_wc_pointers, 800 );
@ -277,8 +278,8 @@ class WC_Admin_Pointers {
}); });
} }
} }
}); });"
" ); );
} }
} }

View File

@ -28,10 +28,10 @@ class WC_Admin_Post_Types {
* Constructor. * Constructor.
*/ */
public function __construct() { public function __construct() {
include_once( dirname( __FILE__ ) . '/class-wc-admin-meta-boxes.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-meta-boxes.php';
if ( ! function_exists( 'duplicate_post_plugin_activation' ) ) { if ( ! function_exists( 'duplicate_post_plugin_activation' ) ) {
include_once( 'class-wc-admin-duplicate-product.php' ); include_once 'class-wc-admin-duplicate-product.php';
} }
// Load correct list table classes for current screen. // Load correct list table classes for current screen.
@ -65,7 +65,7 @@ class WC_Admin_Post_Types {
// Bulk / quick edit. // Bulk / quick edit.
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit' ), 10, 2 ); add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit' ), 10, 2 );
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit' ), 10, 2 ); add_action( 'quick_edit_custom_box', array( $this, 'quick_edit' ), 10, 2 );
add_action( 'save_post', array( $this, 'bulk_and_quick_edit_hook' ), 10, 2 ); add_action( 'save_post', array( $this, 'bulk_and_quick_edit_hook' ), 10, 2 );
add_action( 'woocommerce_product_bulk_and_quick_edit', array( $this, 'bulk_and_quick_edit_save_post' ), 10, 2 ); add_action( 'woocommerce_product_bulk_and_quick_edit', array( $this, 'bulk_and_quick_edit_save_post' ), 10, 2 );
} }
@ -88,16 +88,16 @@ class WC_Admin_Post_Types {
} }
switch ( $screen_id ) { switch ( $screen_id ) {
case 'edit-shop_order' : case 'edit-shop_order':
include_once( 'list-tables/class-wc-admin-list-table-orders.php' ); include_once 'list-tables/class-wc-admin-list-table-orders.php';
new WC_Admin_List_Table_Orders(); new WC_Admin_List_Table_Orders();
break; break;
case 'edit-shop_coupon' : case 'edit-shop_coupon':
include_once( 'list-tables/class-wc-admin-list-table-coupons.php' ); include_once 'list-tables/class-wc-admin-list-table-coupons.php';
new WC_Admin_List_Table_Coupons(); new WC_Admin_List_Table_Coupons();
break; break;
case 'edit-product' : case 'edit-product':
include_once( 'list-tables/class-wc-admin-list-table-products.php' ); include_once 'list-tables/class-wc-admin-list-table-products.php';
new WC_Admin_List_Table_Products(); new WC_Admin_List_Table_Products();
break; break;
} }
@ -117,18 +117,18 @@ class WC_Admin_Post_Types {
global $post; global $post;
$messages['product'] = array( $messages['product'] = array(
0 => '', // Unused. Messages start at index 1. 0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( 'Product updated. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post->ID ) ) ), 1 => sprintf( __( 'Product updated. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post->ID ) ) ),
2 => __( 'Custom field updated.', 'woocommerce' ), 2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ), 3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Product updated.', 'woocommerce' ), 4 => __( 'Product updated.', 'woocommerce' ),
5 => __( 'Revision restored.', 'woocommerce' ), 5 => __( 'Revision restored.', 'woocommerce' ),
/* translators: %s: product url */ /* translators: %s: product url */
6 => sprintf( __( 'Product published. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post->ID ) ) ), 6 => sprintf( __( 'Product published. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post->ID ) ) ),
7 => __( 'Product saved.', 'woocommerce' ), 7 => __( 'Product saved.', 'woocommerce' ),
/* translators: %s: product url */ /* translators: %s: product url */
8 => sprintf( __( 'Product submitted. <a target="_blank" href="%s">Preview product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ), 8 => sprintf( __( 'Product submitted. <a target="_blank" href="%s">Preview product</a>', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
9 => sprintf( 9 => sprintf(
/* translators: 1: date 2: product url */ /* translators: 1: date 2: product url */
__( 'Product scheduled for: %1$s. <a target="_blank" href="%2$s">Preview product</a>', 'woocommerce' ), __( 'Product scheduled for: %1$s. <a target="_blank" href="%2$s">Preview product</a>', 'woocommerce' ),
'<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post->ID ) ) . '</strong>' '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post->ID ) ) . '</strong>'
@ -138,16 +138,16 @@ class WC_Admin_Post_Types {
); );
$messages['shop_order'] = array( $messages['shop_order'] = array(
0 => '', // Unused. Messages start at index 1. 0 => '', // Unused. Messages start at index 1.
1 => __( 'Order updated.', 'woocommerce' ), 1 => __( 'Order updated.', 'woocommerce' ),
2 => __( 'Custom field updated.', 'woocommerce' ), 2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ), 3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Order updated.', 'woocommerce' ), 4 => __( 'Order updated.', 'woocommerce' ),
5 => __( 'Revision restored.', 'woocommerce' ), 5 => __( 'Revision restored.', 'woocommerce' ),
6 => __( 'Order updated.', 'woocommerce' ), 6 => __( 'Order updated.', 'woocommerce' ),
7 => __( 'Order saved.', 'woocommerce' ), 7 => __( 'Order saved.', 'woocommerce' ),
8 => __( 'Order submitted.', 'woocommerce' ), 8 => __( 'Order submitted.', 'woocommerce' ),
9 => sprintf( 9 => sprintf(
/* translators: %s: date */ /* translators: %s: date */
__( 'Order scheduled for: %s.', 'woocommerce' ), __( 'Order scheduled for: %s.', 'woocommerce' ),
'<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) . '</strong>' '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) . '</strong>'
@ -157,16 +157,16 @@ class WC_Admin_Post_Types {
); );
$messages['shop_coupon'] = array( $messages['shop_coupon'] = array(
0 => '', // Unused. Messages start at index 1. 0 => '', // Unused. Messages start at index 1.
1 => __( 'Coupon updated.', 'woocommerce' ), 1 => __( 'Coupon updated.', 'woocommerce' ),
2 => __( 'Custom field updated.', 'woocommerce' ), 2 => __( 'Custom field updated.', 'woocommerce' ),
3 => __( 'Custom field deleted.', 'woocommerce' ), 3 => __( 'Custom field deleted.', 'woocommerce' ),
4 => __( 'Coupon updated.', 'woocommerce' ), 4 => __( 'Coupon updated.', 'woocommerce' ),
5 => __( 'Revision restored.', 'woocommerce' ), 5 => __( 'Revision restored.', 'woocommerce' ),
6 => __( 'Coupon updated.', 'woocommerce' ), 6 => __( 'Coupon updated.', 'woocommerce' ),
7 => __( 'Coupon saved.', 'woocommerce' ), 7 => __( 'Coupon saved.', 'woocommerce' ),
8 => __( 'Coupon submitted.', 'woocommerce' ), 8 => __( 'Coupon submitted.', 'woocommerce' ),
9 => sprintf( 9 => sprintf(
/* translators: %s: date */ /* translators: %s: date */
__( 'Coupon scheduled for: %s.', 'woocommerce' ), __( 'Coupon scheduled for: %s.', 'woocommerce' ),
'<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) . '</strong>' '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) . '</strong>'
@ -238,11 +238,13 @@ class WC_Admin_Post_Types {
return; return;
} }
$shipping_class = get_terms( 'product_shipping_class', array( $shipping_class = get_terms(
'hide_empty' => false, 'product_shipping_class', array(
) ); 'hide_empty' => false,
)
);
include( WC()->plugin_path() . '/includes/admin/views/html-bulk-edit-product.php' ); include WC()->plugin_path() . '/includes/admin/views/html-bulk-edit-product.php';
} }
/** /**
@ -256,11 +258,13 @@ class WC_Admin_Post_Types {
return; return;
} }
$shipping_class = get_terms( 'product_shipping_class', array( $shipping_class = get_terms(
'hide_empty' => false, 'product_shipping_class', array(
) ); 'hide_empty' => false,
)
);
include( WC()->plugin_path() . '/includes/admin/views/html-quick-edit-product.php' ); include WC()->plugin_path() . '/includes/admin/views/html-quick-edit-product.php';
} }
/** /**
@ -497,7 +501,7 @@ class WC_Admin_Post_Types {
} }
// Handle price - remove dates and set to lowest. // Handle price - remove dates and set to lowest.
$change_price_product_types = apply_filters( 'woocommerce_bulk_edit_save_price_product_types', array( 'simple', 'external' ) ); $change_price_product_types = apply_filters( 'woocommerce_bulk_edit_save_price_product_types', array( 'simple', 'external' ) );
$can_product_type_change_price = false; $can_product_type_change_price = false;
foreach ( $change_price_product_types as $product_type ) { foreach ( $change_price_product_types as $product_type ) {
if ( $product->is_type( $product_type ) ) { if ( $product->is_type( $product_type ) ) {
@ -521,7 +525,7 @@ class WC_Admin_Post_Types {
break; break;
case 2: case 2:
if ( $is_percentage ) { if ( $is_percentage ) {
$percent = $regular_price / 100; $percent = $regular_price / 100;
$new_price = $old_regular_price + ( round( $old_regular_price * $percent, wc_get_price_decimals() ) ); $new_price = $old_regular_price + ( round( $old_regular_price * $percent, wc_get_price_decimals() ) );
} else { } else {
$new_price = $old_regular_price + $regular_price; $new_price = $old_regular_price + $regular_price;
@ -529,7 +533,7 @@ class WC_Admin_Post_Types {
break; break;
case 3: case 3:
if ( $is_percentage ) { if ( $is_percentage ) {
$percent = $regular_price / 100; $percent = $regular_price / 100;
$new_price = max( 0, $old_regular_price - ( round( $old_regular_price * $percent, wc_get_price_decimals() ) ) ); $new_price = max( 0, $old_regular_price - ( round( $old_regular_price * $percent, wc_get_price_decimals() ) ) );
} else { } else {
$new_price = max( 0, $old_regular_price - $regular_price ); $new_price = max( 0, $old_regular_price - $regular_price );
@ -542,7 +546,7 @@ class WC_Admin_Post_Types {
if ( isset( $new_price ) && $new_price !== $old_regular_price ) { if ( isset( $new_price ) && $new_price !== $old_regular_price ) {
$price_changed = true; $price_changed = true;
$new_price = round( $new_price, wc_get_price_decimals() ); $new_price = round( $new_price, wc_get_price_decimals() );
$product->set_regular_price( $new_price ); $product->set_regular_price( $new_price );
} }
} }
@ -559,7 +563,7 @@ class WC_Admin_Post_Types {
break; break;
case 2: case 2:
if ( $is_percentage ) { if ( $is_percentage ) {
$percent = $sale_price / 100; $percent = $sale_price / 100;
$new_price = $old_sale_price + ( $old_sale_price * $percent ); $new_price = $old_sale_price + ( $old_sale_price * $percent );
} else { } else {
$new_price = $old_sale_price + $sale_price; $new_price = $old_sale_price + $sale_price;
@ -567,7 +571,7 @@ class WC_Admin_Post_Types {
break; break;
case 3: case 3:
if ( $is_percentage ) { if ( $is_percentage ) {
$percent = $sale_price / 100; $percent = $sale_price / 100;
$new_price = max( 0, $old_sale_price - ( $old_sale_price * $percent ) ); $new_price = max( 0, $old_sale_price - ( $old_sale_price * $percent ) );
} else { } else {
$new_price = max( 0, $old_sale_price - $sale_price ); $new_price = max( 0, $old_sale_price - $sale_price );
@ -575,7 +579,7 @@ class WC_Admin_Post_Types {
break; break;
case 4: case 4:
if ( $is_percentage ) { if ( $is_percentage ) {
$percent = $sale_price / 100; $percent = $sale_price / 100;
$new_price = max( 0, $product->regular_price - ( $product->regular_price * $percent ) ); $new_price = max( 0, $product->regular_price - ( $product->regular_price * $percent ) );
} else { } else {
$new_price = max( 0, $product->regular_price - $sale_price ); $new_price = max( 0, $product->regular_price - $sale_price );
@ -588,7 +592,7 @@ class WC_Admin_Post_Types {
if ( isset( $new_price ) && $new_price !== $old_sale_price ) { if ( isset( $new_price ) && $new_price !== $old_sale_price ) {
$price_changed = true; $price_changed = true;
$new_price = ! empty( $new_price ) || '0' === $new_price ? round( $new_price, wc_get_price_decimals() ) : ''; $new_price = ! empty( $new_price ) || '0' === $new_price ? round( $new_price, wc_get_price_decimals() ) : '';
$product->set_sale_price( $new_price ); $product->set_sale_price( $new_price );
} }
} }
@ -732,14 +736,17 @@ class WC_Admin_Post_Types {
$visibility_options = wc_get_product_visibility_options(); $visibility_options = wc_get_product_visibility_options();
?> ?>
<div class="misc-pub-section" id="catalog-visibility"> <div class="misc-pub-section" id="catalog-visibility">
<?php esc_html_e( 'Catalog visibility:', 'woocommerce' ); ?> <strong id="catalog-visibility-display"><?php <?php esc_html_e( 'Catalog visibility:', 'woocommerce' ); ?>
<strong id="catalog-visibility-display">
<?php
echo isset( $visibility_options[ $current_visibility ] ) ? esc_html( $visibility_options[ $current_visibility ] ) : esc_html( $current_visibility ); echo isset( $visibility_options[ $current_visibility ] ) ? esc_html( $visibility_options[ $current_visibility ] ) : esc_html( $current_visibility );
if ( 'yes' === $current_featured ) { if ( 'yes' === $current_featured ) {
echo ', ' . esc_html__( 'Featured', 'woocommerce' ); echo ', ' . esc_html__( 'Featured', 'woocommerce' );
} }
?></strong> ?>
</strong>
<a href="#catalog-visibility" class="edit-catalog-visibility hide-if-no-js"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a> <a href="#catalog-visibility" class="edit-catalog-visibility hide-if-no-js"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a>

View File

@ -14,229 +14,230 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Profile', false ) ) : if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
/**
* WC_Admin_Profile Class.
*/
class WC_Admin_Profile {
/** /**
* Hook in tabs. * WC_Admin_Profile Class.
*/ */
public function __construct() { class WC_Admin_Profile {
add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ) );
add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ) );
add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); /**
add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); * Hook in tabs.
} */
public function __construct() {
add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ) );
add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ) );
/** add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
* Get Address Fields for the edit user pages. add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
*
* @return array Fields to display which are filtered through woocommerce_customer_meta_fields before being returned
*/
public function get_customer_meta_fields() {
$show_fields = apply_filters('woocommerce_customer_meta_fields', array(
'billing' => array(
'title' => __( 'Customer billing address', 'woocommerce' ),
'fields' => array(
'billing_first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'description' => '',
),
'billing_last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'description' => '',
),
'billing_company' => array(
'label' => __( 'Company', 'woocommerce' ),
'description' => '',
),
'billing_address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'description' => '',
),
'billing_address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'description' => '',
),
'billing_city' => array(
'label' => __( 'City', 'woocommerce' ),
'description' => '',
),
'billing_postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'description' => '',
),
'billing_country' => array(
'label' => __( 'Country', 'woocommerce' ),
'description' => '',
'class' => 'js_field-country',
'type' => 'select',
'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
),
'billing_state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'description' => __( 'State / County or state code', 'woocommerce' ),
'class' => 'js_field-state',
),
'billing_phone' => array(
'label' => __( 'Phone', 'woocommerce' ),
'description' => '',
),
'billing_email' => array(
'label' => __( 'Email address', 'woocommerce' ),
'description' => '',
),
),
),
'shipping' => array(
'title' => __( 'Customer shipping address', 'woocommerce' ),
'fields' => array(
'copy_billing' => array(
'label' => __( 'Copy from billing address', 'woocommerce' ),
'description' => '',
'class' => 'js_copy-billing',
'type' => 'button',
'text' => __( 'Copy', 'woocommerce' ),
),
'shipping_first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'description' => '',
),
'shipping_last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'description' => '',
),
'shipping_company' => array(
'label' => __( 'Company', 'woocommerce' ),
'description' => '',
),
'shipping_address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'description' => '',
),
'shipping_address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'description' => '',
),
'shipping_city' => array(
'label' => __( 'City', 'woocommerce' ),
'description' => '',
),
'shipping_postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'description' => '',
),
'shipping_country' => array(
'label' => __( 'Country', 'woocommerce' ),
'description' => '',
'class' => 'js_field-country',
'type' => 'select',
'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
),
'shipping_state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'description' => __( 'State / County or state code', 'woocommerce' ),
'class' => 'js_field-state',
),
),
),
) );
return $show_fields;
}
/**
* Show Address Fields on edit user pages.
*
* @param WP_User $user
*/
public function add_customer_meta_fields( $user ) {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
} }
$show_fields = $this->get_customer_meta_fields(); /**
* Get Address Fields for the edit user pages.
*
* @return array Fields to display which are filtered through woocommerce_customer_meta_fields before being returned
*/
public function get_customer_meta_fields() {
$show_fields = apply_filters(
'woocommerce_customer_meta_fields', array(
'billing' => array(
'title' => __( 'Customer billing address', 'woocommerce' ),
'fields' => array(
'billing_first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'description' => '',
),
'billing_last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'description' => '',
),
'billing_company' => array(
'label' => __( 'Company', 'woocommerce' ),
'description' => '',
),
'billing_address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'description' => '',
),
'billing_address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'description' => '',
),
'billing_city' => array(
'label' => __( 'City', 'woocommerce' ),
'description' => '',
),
'billing_postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'description' => '',
),
'billing_country' => array(
'label' => __( 'Country', 'woocommerce' ),
'description' => '',
'class' => 'js_field-country',
'type' => 'select',
'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
),
'billing_state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'description' => __( 'State / County or state code', 'woocommerce' ),
'class' => 'js_field-state',
),
'billing_phone' => array(
'label' => __( 'Phone', 'woocommerce' ),
'description' => '',
),
'billing_email' => array(
'label' => __( 'Email address', 'woocommerce' ),
'description' => '',
),
),
),
'shipping' => array(
'title' => __( 'Customer shipping address', 'woocommerce' ),
'fields' => array(
'copy_billing' => array(
'label' => __( 'Copy from billing address', 'woocommerce' ),
'description' => '',
'class' => 'js_copy-billing',
'type' => 'button',
'text' => __( 'Copy', 'woocommerce' ),
),
'shipping_first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'description' => '',
),
'shipping_last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'description' => '',
),
'shipping_company' => array(
'label' => __( 'Company', 'woocommerce' ),
'description' => '',
),
'shipping_address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'description' => '',
),
'shipping_address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'description' => '',
),
'shipping_city' => array(
'label' => __( 'City', 'woocommerce' ),
'description' => '',
),
'shipping_postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'description' => '',
),
'shipping_country' => array(
'label' => __( 'Country', 'woocommerce' ),
'description' => '',
'class' => 'js_field-country',
'type' => 'select',
'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
),
'shipping_state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'description' => __( 'State / County or state code', 'woocommerce' ),
'class' => 'js_field-state',
),
),
),
)
);
return $show_fields;
}
foreach ( $show_fields as $fieldset_key => $fieldset ) : /**
?> * Show Address Fields on edit user pages.
<h2><?php echo $fieldset['title']; ?></h2> *
<table class="form-table" id="<?php echo esc_attr( 'fieldset-' . $fieldset_key ); ?>"> * @param WP_User $user
<?php */
foreach ( $fieldset['fields'] as $key => $field ) : public function add_customer_meta_fields( $user ) {
?> if ( ! current_user_can( 'manage_woocommerce' ) ) {
<tr> return;
<th><label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label></th> }
<td>
<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> $show_fields = $this->get_customer_meta_fields();
<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?>" style="width: 25em;">
<?php foreach ( $show_fields as $fieldset_key => $fieldset ) :
$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
foreach ( $field['options'] as $option_key => $option_value ) : ?>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_attr( $option_value ); ?></option>
<?php endforeach; ?>
</select>
<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
<?php elseif ( ! empty( $field['type'] ) && 'button' === $field['type'] ) : ?>
<button type="button" id="<?php echo esc_attr( $key ); ?>" class="button <?php echo esc_attr( $field['class'] ); ?>"><?php echo esc_html( $field['text'] ); ?></button>
<?php else : ?>
<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
<?php endif; ?>
<br/>
<span class="description"><?php echo wp_kses_post( $field['description'] ); ?></span>
</td>
</tr>
<?php
endforeach;
?> ?>
</table> <h2><?php echo $fieldset['title']; ?></h2>
<?php <table class="form-table" id="<?php echo esc_attr( 'fieldset-' . $fieldset_key ); ?>">
endforeach; <?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
} <tr>
<th>
<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
</th>
<td>
<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?>" style="width: 25em;">
<?php
$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
foreach ( $field['options'] as $option_key => $option_value ) :
?>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_attr( $option_value ); ?></option>
<?php endforeach; ?>
</select>
<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
<?php elseif ( ! empty( $field['type'] ) && 'button' === $field['type'] ) : ?>
<button type="button" id="<?php echo esc_attr( $key ); ?>" class="button <?php echo esc_attr( $field['class'] ); ?>"><?php echo esc_html( $field['text'] ); ?></button>
<?php else : ?>
<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
<?php endif; ?>
<br/>
<span class="description"><?php echo wp_kses_post( $field['description'] ); ?></span>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php
endforeach;
}
/** /**
* Save Address Fields on edit user pages. * Save Address Fields on edit user pages.
* *
* @param int $user_id User ID of the user being saved * @param int $user_id User ID of the user being saved
*/ */
public function save_customer_meta_fields( $user_id ) { public function save_customer_meta_fields( $user_id ) {
$save_fields = $this->get_customer_meta_fields(); $save_fields = $this->get_customer_meta_fields();
foreach ( $save_fields as $fieldset ) { foreach ( $save_fields as $fieldset ) {
foreach ( $fieldset['fields'] as $key => $field ) { foreach ( $fieldset['fields'] as $key => $field ) {
if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) );
} elseif ( isset( $_POST[ $key ] ) ) { } elseif ( isset( $_POST[ $key ] ) ) {
update_user_meta( $user_id, $key, wc_clean( $_POST[ $key ] ) ); update_user_meta( $user_id, $key, wc_clean( $_POST[ $key ] ) );
}
} }
} }
} }
}
/** /**
* Get user meta for a given key, with fallbacks to core user info for pre-existing fields. * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
* *
* @since 3.1.0 * @since 3.1.0
* @param int $user_id User ID of the user being edited * @param int $user_id User ID of the user being edited
* @param string $key Key for user meta field * @param string $key Key for user meta field
* @return string * @return string
*/ */
protected function get_user_meta( $user_id, $key ) { protected function get_user_meta( $user_id, $key ) {
$value = get_user_meta( $user_id, $key, true ); $value = get_user_meta( $user_id, $key, true );
$existing_fields = array( 'billing_first_name', 'billing_last_name' ); $existing_fields = array( 'billing_first_name', 'billing_last_name' );
if ( ! $value && in_array( $key, $existing_fields ) ) { if ( ! $value && in_array( $key, $existing_fields ) ) {
$value = get_user_meta( $user_id, str_replace( 'billing_', '', $key ), true ); $value = get_user_meta( $user_id, str_replace( 'billing_', '', $key ), true );
} elseif ( ! $value && ( 'billing_email' === $key ) ) { } elseif ( ! $value && ( 'billing_email' === $key ) ) {
$user = get_userdata( $user_id ); $user = get_userdata( $user_id );
$value = $user->user_email; $value = $user->user_email;
}
return $value;
} }
return $value;
} }
}
endif; endif;

View File

@ -32,8 +32,8 @@ class WC_Admin_Reports {
$current_tab = ! empty( $_GET['tab'] ) ? sanitize_title( $_GET['tab'] ) : $first_tab[0]; $current_tab = ! empty( $_GET['tab'] ) ? sanitize_title( $_GET['tab'] ) : $first_tab[0];
$current_report = isset( $_GET['report'] ) ? sanitize_title( $_GET['report'] ) : current( array_keys( $reports[ $current_tab ]['reports'] ) ); $current_report = isset( $_GET['report'] ) ? sanitize_title( $_GET['report'] ) : current( array_keys( $reports[ $current_tab ]['reports'] ) );
include_once( dirname( __FILE__ ) . '/reports/class-wc-admin-report.php' ); include_once dirname( __FILE__ ) . '/reports/class-wc-admin-report.php';
include_once( dirname( __FILE__ ) . '/views/html-admin-page-reports.php' ); include_once dirname( __FILE__ ) . '/views/html-admin-page-reports.php';
} }
/** /**
@ -43,16 +43,16 @@ class WC_Admin_Reports {
*/ */
public static function get_reports() { public static function get_reports() {
$reports = array( $reports = array(
'orders' => array( 'orders' => array(
'title' => __( 'Orders', 'woocommerce' ), 'title' => __( 'Orders', 'woocommerce' ),
'reports' => array( 'reports' => array(
'sales_by_date' => array( 'sales_by_date' => array(
'title' => __( 'Sales by date', 'woocommerce' ), 'title' => __( 'Sales by date', 'woocommerce' ),
'description' => '', 'description' => '',
'hide_title' => true, 'hide_title' => true,
'callback' => array( __CLASS__, 'get_report' ), 'callback' => array( __CLASS__, 'get_report' ),
), ),
'sales_by_product' => array( 'sales_by_product' => array(
'title' => __( 'Sales by product', 'woocommerce' ), 'title' => __( 'Sales by product', 'woocommerce' ),
'description' => '', 'description' => '',
'hide_title' => true, 'hide_title' => true,
@ -64,13 +64,13 @@ class WC_Admin_Reports {
'hide_title' => true, 'hide_title' => true,
'callback' => array( __CLASS__, 'get_report' ), 'callback' => array( __CLASS__, 'get_report' ),
), ),
'coupon_usage' => array( 'coupon_usage' => array(
'title' => __( 'Coupons by date', 'woocommerce' ), 'title' => __( 'Coupons by date', 'woocommerce' ),
'description' => '', 'description' => '',
'hide_title' => true, 'hide_title' => true,
'callback' => array( __CLASS__, 'get_report' ), 'callback' => array( __CLASS__, 'get_report' ),
), ),
'downloads' => array( 'downloads' => array(
'title' => __( 'Customer downloads', 'woocommerce' ), 'title' => __( 'Customer downloads', 'woocommerce' ),
'description' => '', 'description' => '',
'hide_title' => true, 'hide_title' => true,
@ -79,9 +79,9 @@ class WC_Admin_Reports {
), ),
), ),
'customers' => array( 'customers' => array(
'title' => __( 'Customers', 'woocommerce' ), 'title' => __( 'Customers', 'woocommerce' ),
'reports' => array( 'reports' => array(
'customers' => array( 'customers' => array(
'title' => __( 'Customers vs. guests', 'woocommerce' ), 'title' => __( 'Customers vs. guests', 'woocommerce' ),
'description' => '', 'description' => '',
'hide_title' => true, 'hide_title' => true,
@ -96,7 +96,7 @@ class WC_Admin_Reports {
), ),
), ),
'stock' => array( 'stock' => array(
'title' => __( 'Stock', 'woocommerce' ), 'title' => __( 'Stock', 'woocommerce' ),
'reports' => array( 'reports' => array(
'low_in_stock' => array( 'low_in_stock' => array(
'title' => __( 'Low in stock', 'woocommerce' ), 'title' => __( 'Low in stock', 'woocommerce' ),
@ -122,7 +122,7 @@ class WC_Admin_Reports {
if ( wc_tax_enabled() ) { if ( wc_tax_enabled() ) {
$reports['taxes'] = array( $reports['taxes'] = array(
'title' => __( 'Taxes', 'woocommerce' ), 'title' => __( 'Taxes', 'woocommerce' ),
'reports' => array( 'reports' => array(
'taxes_by_code' => array( 'taxes_by_code' => array(
'title' => __( 'Taxes by code', 'woocommerce' ), 'title' => __( 'Taxes by code', 'woocommerce' ),
@ -167,7 +167,7 @@ class WC_Admin_Reports {
$name = sanitize_title( str_replace( '_', '-', $name ) ); $name = sanitize_title( str_replace( '_', '-', $name ) );
$class = 'WC_Report_' . str_replace( '-', '_', $name ); $class = 'WC_Report_' . str_replace( '-', '_', $name );
include_once( apply_filters( 'wc_admin_reports_path', 'reports/class-wc-report-' . $name . '.php', $name, $class ) ); include_once apply_filters( 'wc_admin_reports_path', 'reports/class-wc-report-' . $name . '.php', $name, $class );
if ( ! class_exists( $class ) ) { if ( ! class_exists( $class ) ) {
return; return;

View File

@ -88,16 +88,18 @@ class WC_Admin_Setup_Wizard {
* @return boolean * @return boolean
*/ */
protected function is_default_theme() { protected function is_default_theme() {
return wc_is_active_theme( array( return wc_is_active_theme(
'twentyseventeen', array(
'twentysixteen', 'twentyseventeen',
'twentyfifteen', 'twentysixteen',
'twentyfourteen', 'twentyfifteen',
'twentythirteen', 'twentyfourteen',
'twentyeleven', 'twentythirteen',
'twentytwelve', 'twentyeleven',
'twentyten', 'twentytwelve',
) ); 'twentyten',
)
);
} }
/** /**
@ -185,28 +187,36 @@ class WC_Admin_Setup_Wizard {
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' ); wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION ); wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array( wp_localize_script(
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), 'wc-enhanced-select',
'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), 'wc_enhanced_select_params',
'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), array(
'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
'ajax_url' => admin_url( 'admin-ajax.php' ), 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ), 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ), 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ),
) ); 'ajax_url' => admin_url( 'admin-ajax.php' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
)
);
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION ); wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION );
wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util' ), WC_VERSION ); wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util' ), WC_VERSION );
wp_localize_script( 'wc-setup', 'wc_setup_params', array( wp_localize_script(
'pending_jetpack_install' => $pending_jetpack ? 'yes' : 'no', 'wc-setup',
) ); 'wc_setup_params',
array(
'pending_jetpack_install' => $pending_jetpack ? 'yes' : 'no',
)
);
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
@ -275,11 +285,9 @@ class WC_Admin_Setup_Wizard {
public function setup_wizard_footer() { public function setup_wizard_footer() {
?> ?>
<?php if ( 'store_setup' === $this->step ) : ?> <?php if ( 'store_setup' === $this->step ) : ?>
<a class="wc-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Not right now', 'woocommerce' ); ?></a> <a class="wc-setup-footer-links" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Not right now', 'woocommerce' ); ?></a>
<?php elseif ( 'next_steps' === $this->step ) : ?> <?php elseif ( 'activate' === $this->step ) : ?>
<a class="wc-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to your dashboard', 'woocommerce' ); ?></a> <a class="wc-setup-footer-links" href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a>
<?php elseif ( 'activate' === $this->step || 'extras' === $this->step ) : ?>
<a class="wc-return-to-dashboard" href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a>
<?php endif; ?> <?php endif; ?>
</body> </body>
</html> </html>
@ -290,19 +298,20 @@ class WC_Admin_Setup_Wizard {
* Output the steps. * Output the steps.
*/ */
public function setup_wizard_steps() { public function setup_wizard_steps() {
$output_steps = $this->steps;
?> ?>
<ol class="wc-setup-steps"> <ol class="wc-setup-steps">
<?php foreach ( $output_steps as $step_key => $step ) : ?> <?php foreach ( $this->steps as $step_key => $step ) :
<li class=" $is_completed = array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true );
<?php
if ( $step_key === $this->step ) { if ( $step_key === $this->step ) : ?>
echo 'active'; <li class="active"><?php echo esc_html( $step['name'] ); ?></li>
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) { <?php elseif ( $is_completed ) : ?>
echo 'done'; <li class="done">
} <a href="<?php echo esc_url( add_query_arg( 'step', $step_key, remove_query_arg( 'activate_error' ) ) ) ?>"><?php echo esc_html( $step['name'] ); ?></a>
?> </li>
"><?php echo esc_html( $step['name'] ); ?></li> <?php else : ?>
<li><?php echo esc_html( $step['name'] ); ?></li>
<?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</ol> </ol>
<?php <?php
@ -601,10 +610,13 @@ class WC_Admin_Setup_Wizard {
add_action( 'shutdown', array( $this, 'run_deferred_actions' ) ); add_action( 'shutdown', array( $this, 'run_deferred_actions' ) );
} }
array_push( $this->deferred_actions, array( array_push(
'func' => array( 'WC_Install', 'background_installer' ), $this->deferred_actions,
'args' => array( $plugin_id, $plugin_info ), array(
) ); 'func' => array( 'WC_Install', 'background_installer' ),
'args' => array( $plugin_id, $plugin_info ),
)
);
// Set the background installation flag for this plugin. // Set the background installation flag for this plugin.
update_option( 'woocommerce_setup_background_installing_' . $plugin_id, true ); update_option( 'woocommerce_setup_background_installing_' . $plugin_id, true );
@ -620,21 +632,27 @@ class WC_Admin_Setup_Wizard {
if ( empty( $this->deferred_actions ) ) { if ( empty( $this->deferred_actions ) ) {
add_action( 'shutdown', array( $this, 'run_deferred_actions' ) ); add_action( 'shutdown', array( $this, 'run_deferred_actions' ) );
} }
array_push( $this->deferred_actions, array( array_push(
'func' => array( 'WC_Install', 'theme_background_installer' ), $this->deferred_actions,
'args' => array( $theme_id ), array(
) ); 'func' => array( 'WC_Install', 'theme_background_installer' ),
'args' => array( $theme_id ),
)
);
} }
/** /**
* Helper method to install Jetpack. * Helper method to install Jetpack.
*/ */
protected function install_jetpack() { protected function install_jetpack() {
$this->install_plugin( 'jetpack', array( $this->install_plugin(
'file' => 'jetpack/jetpack.php', 'jetpack',
'name' => __( 'Jetpack', 'woocommerce' ), array(
'repo-slug' => 'jetpack', 'file' => 'jetpack/jetpack.php',
) ); 'name' => __( 'Jetpack', 'woocommerce' ),
'repo-slug' => 'jetpack',
)
);
} }
/** /**
@ -642,11 +660,14 @@ class WC_Admin_Setup_Wizard {
*/ */
protected function install_woocommerce_services() { protected function install_woocommerce_services() {
$this->install_jetpack(); $this->install_jetpack();
$this->install_plugin( 'woocommerce-services', array( $this->install_plugin(
'file' => 'woocommerce-services/woocommerce-services.php', 'woocommerce-services',
'name' => __( 'WooCommerce Services', 'woocommerce' ), array(
'repo-slug' => 'woocommerce-services', 'file' => 'woocommerce-services/woocommerce-services.php',
) ); 'name' => __( 'WooCommerce Services', 'woocommerce' ),
'repo-slug' => 'woocommerce-services',
)
);
} }
/** /**
@ -776,14 +797,20 @@ class WC_Admin_Setup_Wizard {
$currency_code = get_woocommerce_currency(); $currency_code = get_woocommerce_currency();
$wcs_carrier = $this->get_wcs_shipping_carrier( $country_code, $currency_code ); $wcs_carrier = $this->get_wcs_shipping_carrier( $country_code, $currency_code );
$existing_zones = WC_Shipping_Zones::get_zones(); $existing_zones = WC_Shipping_Zones::get_zones();
$dimension_unit = get_option( 'woocommerce_dimension_unit' );
$weight_unit = get_option( 'woocommerce_weight_unit' );
$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';
$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php'; if ( ! $weight_unit && isset( $locale_info[ $country_code ] ) ) {
if ( isset( $locale_info[ $country_code ] ) ) { $weight_unit = $locale_info[ $country_code ]['weight_unit'];
$dimension_unit = $locale_info[ $country_code ]['dimension_unit'];
$weight_unit = $locale_info[ $country_code ]['weight_unit'];
} else { } else {
$dimension_unit = 'cm'; $weight_unit = $weight_unit ? $weight_unit : 'kg';
$weight_unit = 'kg'; }
if ( ! $dimension_unit && isset( $locale_info[ $country_code ] ) ) {
$dimension_unit = $locale_info[ $country_code ]['dimension_unit'];
} else {
$dimension_unit = $dimension_unit ? $dimension_unit : 'cm';
} }
if ( ! empty( $existing_zones ) ) { if ( ! empty( $existing_zones ) ) {
@ -853,10 +880,12 @@ class WC_Admin_Setup_Wizard {
<p> <p>
<label for="weight_unit"> <label for="weight_unit">
<?php <?php
printf( wp_kses( printf(
__( '<strong>Weight unit</strong>—used to calculate shipping rates, and more.', 'woocommerce' ), wp_kses(
array( 'strong' => array() ) __( '<strong>Weight unit</strong>—used to calculate shipping rates, and more.', 'woocommerce' ),
) ); array( 'strong' => array() )
)
);
?> ?>
</label> </label>
</p> </p>
@ -871,10 +900,12 @@ class WC_Admin_Setup_Wizard {
<p> <p>
<label for="dimension_unit"> <label for="dimension_unit">
<?php <?php
printf( wp_kses( printf(
__( '<strong>Dimension unit</strong>—helps for accurate package selection.', 'woocommerce' ), wp_kses(
array( 'strong' => array() ) __( '<strong>Dimension unit</strong>—helps for accurate package selection.', 'woocommerce' ),
) ); array( 'strong' => array() )
)
);
?> ?>
</label> </label>
</p> </p>
@ -1914,6 +1945,24 @@ class WC_Admin_Setup_Wizard {
</p> </p>
</div> </div>
</li> </li>
<li class="wc-wizard-additional-steps">
<div class="wc-wizard-next-step-description">
<p class="next-step-heading"><?php esc_html_e( 'You can also:', 'woocommerce' ); ?></p>
</div>
<div class="wc-wizard-next-step-action">
<p class="wc-setup-actions step">
<a class="button button-large" href="<?php echo esc_url( admin_url() ); ?>">
<?php esc_html_e( 'Visit Dashboard', 'woocommerce' ); ?>
</a>
<a class="button button-large" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings' ) ); ?>">
<?php esc_html_e( 'Review Settings', 'woocommerce' ); ?>
</a>
<a class="button button-large" href="<?php echo esc_url( add_query_arg( array( 'autofocus' => array( 'panel' => 'woocommerce' ), 'url' => wc_get_page_permalink( 'shop' ) ), admin_url( 'customize.php' ) ) ); ?>">
<?php esc_html_e( 'View &amp; Customize', 'woocommerce' ); ?>
</a>
</p>
</div>
</li>
</ul> </ul>
<p class="next-steps-help-text"><?php echo wp_kses_post( $help_text ); ?></p> <p class="next-steps-help-text"><?php echo wp_kses_post( $help_text ); ?></p>
<?php <?php

View File

@ -19,14 +19,14 @@ class WC_Admin_Status {
* Handles output of the reports page in admin. * Handles output of the reports page in admin.
*/ */
public static function output() { public static function output() {
include_once( dirname( __FILE__ ) . '/views/html-admin-page-status.php' ); include_once dirname( __FILE__ ) . '/views/html-admin-page-status.php';
} }
/** /**
* Handles output of report. * Handles output of report.
*/ */
public static function status_report() { public static function status_report() {
include_once( dirname( __FILE__ ) . '/views/html-admin-page-status-report.php' ); include_once dirname( __FILE__ ) . '/views/html-admin-page-status-report.php';
} }
/** /**
@ -36,13 +36,16 @@ class WC_Admin_Status {
$tools = self::get_tools(); $tools = self::get_tools();
if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'debug_action' ) ) { if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'debug_action' ) ) {
$tools_controller = new WC_REST_System_Status_Tools_Controller; $tools_controller = new WC_REST_System_Status_Tools_Controller();
$action = wc_clean( $_GET['action'] ); $action = wc_clean( $_GET['action'] );
if ( array_key_exists( $action, $tools ) ) { if ( array_key_exists( $action, $tools ) ) {
$response = $tools_controller->execute_tool( $action ); $response = $tools_controller->execute_tool( $action );
} else { } else {
$response = array( 'success' => false, 'message' => __( 'Tool does not exist.', 'woocommerce' ) ); $response = array(
'success' => false,
'message' => __( 'Tool does not exist.', 'woocommerce' ),
);
} }
if ( $response['success'] ) { if ( $response['success'] ) {
@ -57,15 +60,16 @@ class WC_Admin_Status {
echo '<div class="updated inline"><p>' . __( 'Your changes have been saved.', 'woocommerce' ) . '</p></div>'; echo '<div class="updated inline"><p>' . __( 'Your changes have been saved.', 'woocommerce' ) . '</p></div>';
} }
include_once( dirname( __FILE__ ) . '/views/html-admin-page-status-tools.php' ); include_once dirname( __FILE__ ) . '/views/html-admin-page-status-tools.php';
} }
/** /**
* Get tools. * Get tools.
*
* @return array of tools * @return array of tools
*/ */
public static function get_tools() { public static function get_tools() {
$tools_controller = new WC_REST_System_Status_Tools_Controller; $tools_controller = new WC_REST_System_Status_Tools_Controller();
return $tools_controller->get_tools(); return $tools_controller->get_tools();
} }
@ -99,7 +103,7 @@ class WC_Admin_Status {
self::remove_log(); self::remove_log();
} }
include_once( 'views/html-admin-page-status-logs.php' ); include_once 'views/html-admin-page-status-logs.php';
} }
/** /**
@ -120,11 +124,12 @@ class WC_Admin_Status {
$log_table_list = new WC_Admin_Log_Table_List(); $log_table_list = new WC_Admin_Log_Table_List();
$log_table_list->prepare_items(); $log_table_list->prepare_items();
include_once( 'views/html-admin-page-status-logs-db.php' ); include_once 'views/html-admin-page-status-logs-db.php';
} }
/** /**
* Retrieve metadata from a file. Based on WP Core's get_file_data function. * Retrieve metadata from a file. Based on WP Core's get_file_data function.
*
* @since 2.1.1 * @since 2.1.1
* @param string $file Path to the file * @param string $file Path to the file
* @return string * @return string
@ -153,7 +158,7 @@ class WC_Admin_Status {
$version = _cleanup_header_comment( $match[1] ); $version = _cleanup_header_comment( $match[1] );
} }
return $version ; return $version;
} }
/** /**
@ -168,6 +173,7 @@ class WC_Admin_Status {
/** /**
* Scan the template files. * Scan the template files.
*
* @param string $template_path * @param string $template_path
* @return array * @return array
*/ */
@ -180,7 +186,7 @@ class WC_Admin_Status {
foreach ( $files as $key => $value ) { foreach ( $files as $key => $value ) {
if ( ! in_array( $value, array( ".", ".." ) ) ) { if ( ! in_array( $value, array( '.', '..' ) ) ) {
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
$sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
@ -198,6 +204,7 @@ class WC_Admin_Status {
/** /**
* Scan the log files. * Scan the log files.
*
* @return array * @return array
*/ */
public static function scan_log_files() { public static function scan_log_files() {
@ -221,41 +228,48 @@ class WC_Admin_Status {
/** /**
* Get latest version of a theme by slug. * Get latest version of a theme by slug.
*
* @param object $theme WP_Theme object. * @param object $theme WP_Theme object.
* @return string Version number if found. * @return string Version number if found.
*/ */
public static function get_latest_theme_version( $theme ) { public static function get_latest_theme_version( $theme ) {
include_once( ABSPATH . 'wp-admin/includes/theme.php' ); include_once ABSPATH . 'wp-admin/includes/theme.php';
$api = themes_api( 'theme_information', array( $api = themes_api(
'slug' => $theme->get_stylesheet(), 'theme_information',
'fields' => array( array(
'sections' => false, 'slug' => $theme->get_stylesheet(),
'tags' => false, 'fields' => array(
), 'sections' => false,
) ); 'tags' => false,
),
)
);
$update_theme_version = 0; $update_theme_version = 0;
// Check .org for updates. // Check .org for updates.
if ( is_object( $api ) && ! is_wp_error( $api ) ) { if ( is_object( $api ) && ! is_wp_error( $api ) ) {
$update_theme_version = $api->version; $update_theme_version = $api->version;
} elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) { // Check WooThemes Theme Version.
// Check WooThemes Theme Version. $theme_dir = substr( strtolower( str_replace( ' ', '', $theme->Name ) ), 0, 45 );
} elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) {
$theme_dir = substr( strtolower( str_replace( ' ','', $theme->Name ) ), 0, 45 );
if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) { if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) {
$theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' ); $theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) ); $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
if ( ! empty( $cl_lines ) ) { if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) { foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) { if ( preg_match( '/^[0-9]/', $cl_line ) ) {
$theme_date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) ); $theme_date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) );
$theme_version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) ); $theme_version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) );
$theme_update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) ); $theme_update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) );
$theme_version_data = array( 'date' => $theme_date , 'version' => $theme_version , 'update' => $theme_update , 'changelog' => $theme_changelog ); $theme_version_data = array(
set_transient( $theme_dir . '_version_data', $theme_version_data , DAY_IN_SECONDS ); 'date' => $theme_date,
'version' => $theme_version,
'update' => $theme_update,
'changelog' => $theme_changelog,
);
set_transient( $theme_dir . '_version_data', $theme_version_data, DAY_IN_SECONDS );
break; break;
} }
} }

View File

@ -59,8 +59,8 @@ class WC_Admin_Taxonomies {
/** /**
* Order term when created (put in position 0). * Order term when created (put in position 0).
* *
* @param mixed $term_id * @param mixed $term_id
* @param mixed $tt_id * @param mixed $tt_id
* @param string $taxonomy * @param string $taxonomy
*/ */
public function create_term( $term_id, $tt_id = '', $taxonomy = '' ) { public function create_term( $term_id, $tt_id = '', $taxonomy = '' ) {
@ -132,9 +132,9 @@ class WC_Admin_Taxonomies {
// Create the media frame. // Create the media frame.
file_frame = wp.media.frames.downloadable_file = wp.media({ file_frame = wp.media.frames.downloadable_file = wp.media({
title: '<?php _e( "Choose an image", "woocommerce" ); ?>', title: '<?php _e( 'Choose an image', 'woocommerce' ); ?>',
button: { button: {
text: '<?php _e( "Use image", "woocommerce" ); ?>' text: '<?php _e( 'Use image', 'woocommerce' ); ?>'
}, },
multiple: false multiple: false
}); });
@ -242,9 +242,9 @@ class WC_Admin_Taxonomies {
// Create the media frame. // Create the media frame.
file_frame = wp.media.frames.downloadable_file = wp.media({ file_frame = wp.media.frames.downloadable_file = wp.media({
title: '<?php _e( "Choose an image", "woocommerce" ); ?>', title: '<?php _e( 'Choose an image', 'woocommerce' ); ?>',
button: { button: {
text: '<?php _e( "Use image", "woocommerce" ); ?>' text: '<?php _e( 'Use image', 'woocommerce' ); ?>'
}, },
multiple: false multiple: false
}); });
@ -280,8 +280,8 @@ class WC_Admin_Taxonomies {
/** /**
* save_category_fields function. * save_category_fields function.
* *
* @param mixed $term_id Term ID being saved * @param mixed $term_id Term ID being saved
* @param mixed $tt_id * @param mixed $tt_id
* @param string $taxonomy * @param string $taxonomy
*/ */
public function save_category_fields( $term_id, $tt_id = '', $taxonomy = '' ) { public function save_category_fields( $term_id, $tt_id = '', $taxonomy = '' ) {
@ -310,7 +310,7 @@ class WC_Admin_Taxonomies {
?> ?>
<div class="form-wrap edit-term-notes"> <div class="form-wrap edit-term-notes">
<p> <p>
<strong><?php _e( 'Note:', 'woocommerce' ) ?></strong><br> <strong><?php _e( 'Note:', 'woocommerce' ); ?></strong><br>
<?php <?php
printf( printf(
/* translators: %s: default category */ /* translators: %s: default category */
@ -346,7 +346,7 @@ class WC_Admin_Taxonomies {
$new_columns['thumb'] = __( 'Image', 'woocommerce' ); $new_columns['thumb'] = __( 'Image', 'woocommerce' );
$columns = array_merge( $new_columns, $columns ); $columns = array_merge( $new_columns, $columns );
$columns['handle'] = ''; $columns['handle'] = '';
return $columns; return $columns;
@ -355,7 +355,7 @@ class WC_Admin_Taxonomies {
/** /**
* Adjust row actions. * Adjust row actions.
* *
* @param array $actions Array of actions. * @param array $actions Array of actions.
* @param object $term Term object. * @param object $term Term object.
* @return array * @return array
*/ */
@ -393,7 +393,7 @@ class WC_Admin_Taxonomies {
* *
* @param string $columns * @param string $columns
* @param string $column * @param string $column
* @param int $id * @param int $id
* *
* @return string * @return string
*/ */

View File

@ -21,11 +21,13 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
* Initialize the webhook table list. * Initialize the webhook table list.
*/ */
public function __construct() { public function __construct() {
parent::__construct( array( parent::__construct(
'singular' => 'webhook', array(
'plural' => 'webhooks', 'singular' => 'webhook',
'ajax' => false, 'plural' => 'webhooks',
) ); 'ajax' => false,
)
);
} }
/** /**
@ -79,9 +81,15 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $webhook->get_id() ), 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $webhook->get_id() ),
'edit' => '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'woocommerce' ) . '</a>', 'edit' => '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'woocommerce' ) . '</a>',
/* translators: %s: webhook name */ /* translators: %s: webhook name */
'delete' => '<a class="submitdelete" aria-label="' . esc_attr( sprintf( __( 'Delete "%s" permanently', 'woocommerce' ), $webhook->get_name() ) ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'delete' => '<a class="submitdelete" aria-label="' . esc_attr( sprintf( __( 'Delete "%s" permanently', 'woocommerce' ), $webhook->get_name() ) ) . '" href="' . esc_url(
'delete' => $webhook->get_id(), wp_nonce_url(
), admin_url( 'admin.php?page=wc-settings&tab=api&section=webhooks' ) ), 'delete-webhook' ) ) . '">' . esc_html__( 'Delete permanently', 'woocommerce' ) . '</a>', add_query_arg(
array(
'delete' => $webhook->get_id(),
), admin_url( 'admin.php?page=wc-settings&tab=api&section=webhooks' )
), 'delete-webhook'
)
) . '">' . esc_html__( 'Delete permanently', 'woocommerce' ) . '</a>',
); );
$actions = apply_filters( 'webhook_row_actions', $actions, $webhook ); $actions = apply_filters( 'webhook_row_actions', $actions, $webhook );
@ -237,9 +245,12 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
echo '<p class="search-box">'; echo '<p class="search-box">';
echo '<label class="screen-reader-text" for="' . esc_attr( $input_id ) . '">' . esc_html( $text ) . ':</label>'; echo '<label class="screen-reader-text" for="' . esc_attr( $input_id ) . '">' . esc_html( $text ) . ':</label>';
echo '<input type="search" id="' . esc_attr( $input_id ) . '" name="s" value="' . esc_attr( $search_query ) . '" />'; echo '<input type="search" id="' . esc_attr( $input_id ) . '" name="s" value="' . esc_attr( $search_query ) . '" />';
submit_button( $text, '', '', false, array( submit_button(
'id' => 'search-submit', $text, '', '', false,
) ); array(
'id' => 'search-submit',
)
);
echo '</p>'; echo '</p>';
} }
@ -276,10 +287,12 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
$total_items = count( $data_store->search_webhooks( $args ) ); $total_items = count( $data_store->search_webhooks( $args ) );
// Set the pagination. // Set the pagination.
$this->set_pagination_args( array( $this->set_pagination_args(
'total_items' => $total_items, array(
'per_page' => $per_page, 'total_items' => $total_items,
'total_pages' => ceil( $total_items / $per_page ), 'per_page' => $per_page,
) ); 'total_pages' => ceil( $total_items / $per_page ),
)
);
} }
} }

View File

@ -276,10 +276,13 @@ class WC_Admin_Webhooks {
$webhooks_table_list = new WC_Admin_Webhooks_Table_List(); $webhooks_table_list = new WC_Admin_Webhooks_Table_List();
// Add screen option. // Add screen option.
add_screen_option( 'per_page', array( add_screen_option(
'default' => 10, 'per_page',
'option' => 'woocommerce_webhooks_per_page', array(
) ); 'default' => 10,
'option' => 'woocommerce_webhooks_per_page',
)
);
} }
} }

View File

@ -44,46 +44,46 @@ class WC_Admin {
* Include any classes we need within admin. * Include any classes we need within admin.
*/ */
public function includes() { public function includes() {
include_once( dirname( __FILE__ ) . '/wc-admin-functions.php' ); include_once dirname( __FILE__ ) . '/wc-admin-functions.php';
include_once( dirname( __FILE__ ) . '/wc-meta-box-functions.php' ); include_once dirname( __FILE__ ) . '/wc-meta-box-functions.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-post-types.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-post-types.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-taxonomies.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-taxonomies.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-menus.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-menus.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-customize.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-customize.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-notices.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-notices.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-assets.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-assets.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-api-keys.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-api-keys.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-webhooks.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-webhooks.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-pointers.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-pointers.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-importers.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-importers.php';
include_once( dirname( __FILE__ ) . '/class-wc-admin-exporters.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-exporters.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':
include_once( dirname( __FILE__ ) . '/class-wc-admin-setup-wizard.php' ); include_once dirname( __FILE__ ) . '/class-wc-admin-setup-wizard.php';
break; break;
} }
} }
// 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';
include_once( dirname( __FILE__ ) . '/helper/class-wc-helper-plugin-info.php' ); include_once dirname( __FILE__ ) . '/helper/class-wc-helper-plugin-info.php';
include_once( dirname( __FILE__ ) . '/helper/class-wc-helper-compat.php' ); include_once dirname( __FILE__ ) . '/helper/class-wc-helper-compat.php';
include_once( dirname( __FILE__ ) . '/helper/class-wc-helper.php' ); include_once dirname( __FILE__ ) . '/helper/class-wc-helper.php';
} }
/** /**
@ -95,25 +95,25 @@ class WC_Admin {
} }
switch ( $screen->id ) { switch ( $screen->id ) {
case 'dashboard' : case 'dashboard':
case 'dashboard-network' : case 'dashboard-network':
include( 'class-wc-admin-dashboard.php' ); include 'class-wc-admin-dashboard.php';
break; break;
case 'options-permalink' : case 'options-permalink':
include( 'class-wc-admin-permalink-settings.php' ); include 'class-wc-admin-permalink-settings.php';
break; break;
case 'plugins' : case 'plugins':
include ( 'plugin-updates/class-wc-plugins-screen-updates.php' ); include 'plugin-updates/class-wc-plugins-screen-updates.php';
break; break;
case 'update-core' : case 'update-core':
include( 'plugin-updates/class-wc-updates-screen-updates.php' ); include 'plugin-updates/class-wc-updates-screen-updates.php';
break; break;
case 'users' : case 'users':
case 'user' : case 'user':
case 'profile' : case 'profile':
case 'user-edit' : case 'user-edit':
include( 'class-wc-admin-profile.php' ); include 'class-wc-admin-profile.php';
break; break;
} }
} }
@ -160,7 +160,7 @@ class WC_Admin {
public function prevent_admin_access() { public function prevent_admin_access() {
$prevent_access = false; $prevent_access = false;
if ( 'yes' === get_option( 'woocommerce_lock_down_admin', 'yes' ) && ! is_ajax() && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) { if ( 'yes' === get_option( 'woocommerce_lock_down_admin', 'yes' ) && ! is_ajax() && basename( $_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' );
@ -193,21 +193,21 @@ class WC_Admin {
} }
// 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;
@ -242,12 +242,12 @@ class WC_Admin {
sprintf( '<strong>%s</strong>', esc_html__( 'WooCommerce', 'woocommerce' ) ), sprintf( '<strong>%s</strong>', esc_html__( 'WooCommerce', 'woocommerce' ) ),
'<a href="https://wordpress.org/support/plugin/woocommerce/reviews?rate=5#new-post" target="_blank" class="wc-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'woocommerce' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>' '<a href="https://wordpress.org/support/plugin/woocommerce/reviews?rate=5#new-post" target="_blank" class="wc-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'woocommerce' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
); );
wc_enqueue_js( " wc_enqueue_js(
jQuery( 'a.wc-rating-link' ).click( function() { "jQuery( 'a.wc-rating-link' ).click( function() {
jQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } ); jQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } );
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
}); });"
" ); );
} else { } else {
$footer_text = __( 'Thank you for selling with WooCommerce.', 'woocommerce' ); $footer_text = __( 'Thank you for selling with WooCommerce.', 'woocommerce' );
} }
@ -264,9 +264,11 @@ class WC_Admin {
public function setup_wizard_check_jetpack() { public function setup_wizard_check_jetpack() {
$jetpack_active = class_exists( 'Jetpack' ); $jetpack_active = class_exists( 'Jetpack' );
wp_send_json_success( array( wp_send_json_success(
'is_active' => $jetpack_active ? 'yes' : 'no', array(
) ); 'is_active' => $jetpack_active ? 'yes' : 'no',
)
);
} }
} }

View File

@ -26,7 +26,7 @@ class WC_Helper_API {
* Perform an HTTP request to the Helper API. * Perform an HTTP request to the Helper API.
* *
* @param string $endpoint The endpoint to request. * @param string $endpoint The endpoint to request.
* @param array $args Additional data for the request. Set authenticated to a truthy value to enable auth. * @param array $args Additional data for the request. Set authenticated to a truthy value to enable auth.
* *
* @return array|WP_Error The response from wp_safe_remote_request() * @return array|WP_Error The response from wp_safe_remote_request()
*/ */
@ -53,7 +53,7 @@ class WC_Helper_API {
* Adds authentication headers to an HTTP request. * Adds authentication headers to an HTTP request.
* *
* @param string $url The request URI. * @param string $url The request URI.
* @param array $args By-ref, the args that will be passed to wp_remote_request(). * @param array $args By-ref, the args that will be passed to wp_remote_request().
* @return bool Were the headers added? * @return bool Were the headers added?
*/ */
private static function _authenticate( $url, &$args ) { private static function _authenticate( $url, &$args ) {
@ -86,7 +86,7 @@ class WC_Helper_API {
} }
$args['headers'] = array( $args['headers'] = array(
'Authorization' => 'Bearer ' . $auth['access_token'], 'Authorization' => 'Bearer ' . $auth['access_token'],
'X-Woo-Signature' => $signature, 'X-Woo-Signature' => $signature,
); );
@ -97,7 +97,7 @@ class WC_Helper_API {
* Wrapper for self::request(). * Wrapper for self::request().
* *
* @param string $endpoint The helper API endpoint to request. * @param string $endpoint The helper API endpoint to request.
* @param array $args Arguments passed to wp_remote_request(). * @param array $args Arguments passed to wp_remote_request().
* *
* @return array The response object from wp_safe_remote_request(). * @return array The response object from wp_safe_remote_request().
*/ */
@ -110,7 +110,7 @@ class WC_Helper_API {
* Wrapper for self::request(). * Wrapper for self::request().
* *
* @param string $endpoint The helper API endpoint to request. * @param string $endpoint The helper API endpoint to request.
* @param array $args Arguments passed to wp_remote_request(). * @param array $args Arguments passed to wp_remote_request().
* *
* @return array The response object from wp_safe_remote_request(). * @return array The response object from wp_safe_remote_request().
*/ */

View File

@ -70,12 +70,15 @@ class WC_Helper_Compat {
return; return;
} }
$request = WC_Helper_API::post( 'oauth/migrate', array( $request = WC_Helper_API::post(
'body' => array( 'oauth/migrate',
'home_url' => home_url(), array(
'master_key' => $master_key, 'body' => array(
), 'home_url' => home_url(),
) ); 'master_key' => $master_key,
),
)
);
if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) !== 200 ) { if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) !== 200 ) {
WC_Helper::log( 'Call to oauth/migrate returned a non-200 response code' ); WC_Helper::log( 'Call to oauth/migrate returned a non-200 response code' );
@ -89,13 +92,16 @@ class WC_Helper_Compat {
} }
// Obtain an access token. // Obtain an access token.
$request = WC_Helper_API::post( 'oauth/access_token', array( $request = WC_Helper_API::post(
'body' => array( 'oauth/access_token',
'request_token' => $request_token, array(
'home_url' => home_url(), 'body' => array(
'migrate' => true, 'request_token' => $request_token,
), 'home_url' => home_url(),
) ); 'migrate' => true,
),
)
);
if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) !== 200 ) { if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) !== 200 ) {
WC_Helper::log( 'Call to oauth/access_token returned a non-200 response code' ); WC_Helper::log( 'Call to oauth/access_token returned a non-200 response code' );
@ -108,13 +114,16 @@ class WC_Helper_Compat {
return; return;
} }
WC_Helper_Options::update( 'auth', array( WC_Helper_Options::update(
'access_token' => $access_token['access_token'], 'auth',
'access_token_secret' => $access_token['access_token_secret'], array(
'site_id' => $access_token['site_id'], 'access_token' => $access_token['access_token'],
'user_id' => null, // Set this later 'access_token_secret' => $access_token['access_token_secret'],
'updated' => time(), 'site_id' => $access_token['site_id'],
) ); 'user_id' => null, // Set this later
'updated' => time(),
)
);
// Obtain the connected user info. // Obtain the connected user info.
if ( ! WC_Helper::_flush_authentication_cache() ) { if ( ! WC_Helper::_flush_authentication_cache() ) {
@ -128,7 +137,7 @@ class WC_Helper_Compat {
* Attempt to deactivate the legacy helper plugin. * Attempt to deactivate the legacy helper plugin.
*/ */
public static function deactivate_plugin() { public static function deactivate_plugin() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); include_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( ! function_exists( 'deactivate_plugins' ) ) { if ( ! function_exists( 'deactivate_plugins' ) ) {
return; return;
} }
@ -175,11 +184,13 @@ class WC_Helper_Compat {
* Render the legacy helper compat view. * Render the legacy helper compat view.
*/ */
public static function render_compat_menu() { public static function render_compat_menu() {
$helper_url = add_query_arg( array( $helper_url = add_query_arg(
'page' => 'wc-addons', array(
'section' => 'helper', 'page' => 'wc-addons',
), admin_url( 'admin.php' ) ); 'section' => 'helper',
include( WC_Helper::get_view_filename( 'html-helper-compat.php' ) ); ), admin_url( 'admin.php' )
);
include WC_Helper::get_view_filename( 'html-helper-compat.php' );
} }
} }

View File

@ -23,12 +23,12 @@ class WC_Helper_Options {
* is not thread-safe, use with caution. * is not thread-safe, use with caution.
* *
* @param string $key The key to update. * @param string $key The key to update.
* @param mixed $value The new option value. * @param mixed $value The new option value.
* *
* @return bool True if the option has been updated. * @return bool True if the option has been updated.
*/ */
public static function update( $key, $value ) { public static function update( $key, $value ) {
$options = get_option( self::$option_name, array() ); $options = get_option( self::$option_name, array() );
$options[ $key ] = $value; $options[ $key ] = $value;
return update_option( self::$option_name, $options, true ); return update_option( self::$option_name, $options, true );
} }
@ -39,7 +39,7 @@ class WC_Helper_Options {
* @see self::update * @see self::update
* *
* @param string $key The key to fetch. * @param string $key The key to fetch.
* @param mixed $default The default option to return if the key does not exist. * @param mixed $default The default option to return if the key does not exist.
* *
* @return mixed An option or the default. * @return mixed An option or the default.
*/ */

View File

@ -45,7 +45,7 @@ class WC_Helper_Plugin_Info {
// Look through update data by slug. // Look through update data by slug.
$update_data = WC_Helper_Updater::get_update_data(); $update_data = WC_Helper_Updater::get_update_data();
$products = wp_list_filter( $update_data, array( 'slug' => $clean_slug ) ); $products = wp_list_filter( $update_data, array( 'slug' => $clean_slug ) );
if ( empty( $products ) ) { if ( empty( $products ) ) {
return $response; return $response;
@ -55,9 +55,13 @@ class WC_Helper_Plugin_Info {
$product_id = array_shift( $product_id ); $product_id = array_shift( $product_id );
// Fetch the product information from the Helper API. // Fetch the product information from the Helper API.
$request = WC_Helper_API::get( add_query_arg( array( $request = WC_Helper_API::get(
'product_id' => absint( $product_id ), add_query_arg(
), 'info' ), array( 'authenticated' => true ) ); array(
'product_id' => absint( $product_id ),
), 'info'
), array( 'authenticated' => true )
);
$results = json_decode( wp_remote_retrieve_body( $request ), true ); $results = json_decode( wp_remote_retrieve_body( $request ), true );
if ( ! empty( $results ) ) { if ( ! empty( $results ) ) {

View File

@ -36,16 +36,16 @@ class WC_Helper_Updater {
continue; continue;
} }
$data = $update_data[ $plugin['_product_id'] ]; $data = $update_data[ $plugin['_product_id'] ];
$filename = $plugin['_filename']; $filename = $plugin['_filename'];
$item = array( $item = array(
'id' => 'woocommerce-com-' . $plugin['_product_id'], 'id' => 'woocommerce-com-' . $plugin['_product_id'],
'slug' => 'woocommerce-com-' . $data['slug'], 'slug' => 'woocommerce-com-' . $data['slug'],
'plugin' => $filename, 'plugin' => $filename,
'new_version' => $data['version'], 'new_version' => $data['version'],
'url' => $data['url'], 'url' => $data['url'],
'package' => '', 'package' => '',
'upgrade_notice' => $data['upgrade_notice'], 'upgrade_notice' => $data['upgrade_notice'],
); );
@ -85,10 +85,10 @@ class WC_Helper_Updater {
$slug = $theme['_stylesheet']; $slug = $theme['_stylesheet'];
$item = array( $item = array(
'theme' => $slug, 'theme' => $slug,
'new_version' => $data['version'], 'new_version' => $data['version'],
'url' => $data['url'], 'url' => $data['url'],
'package' => '', 'package' => '',
); );
if ( self::_has_active_subscription( $theme['_product_id'] ) ) { if ( self::_has_active_subscription( $theme['_product_id'] ) ) {
@ -122,7 +122,7 @@ class WC_Helper_Updater {
foreach ( WC_Helper::get_subscriptions() as $subscription ) { foreach ( WC_Helper::get_subscriptions() as $subscription ) {
$payload[ $subscription['product_id'] ] = array( $payload[ $subscription['product_id'] ] = array(
'product_id' => $subscription['product_id'], 'product_id' => $subscription['product_id'],
'file_id' => '', 'file_id' => '',
); );
} }
@ -171,16 +171,18 @@ class WC_Helper_Updater {
} }
$data = array( $data = array(
'hash' => $hash, 'hash' => $hash,
'updated' => time(), 'updated' => time(),
'products' => array(), 'products' => array(),
'errors' => array(), 'errors' => array(),
); );
$request = WC_Helper_API::post( 'update-check', array( $request = WC_Helper_API::post(
'body' => json_encode( array( 'products' => $payload ) ), 'update-check', array(
'authenticated' => true, 'body' => json_encode( array( 'products' => $payload ) ),
) ); 'authenticated' => true,
)
);
if ( wp_remote_retrieve_response_code( $request ) !== 200 ) { if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
$data['errors'][] = 'http-error'; $data['errors'][] = 'http-error';
@ -250,7 +252,7 @@ class WC_Helper_Updater {
return 0; return 0;
} }
$count = 0; $count = 0;
$update_data = self::get_update_data(); $update_data = self::get_update_data();
if ( empty( $update_data ) ) { if ( empty( $update_data ) ) {

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,35 @@
<?php defined( 'ABSPATH' ) or exit(); ?> <?php defined( 'ABSPATH' ) or exit(); ?>
<div class="wrap woocommerce wc_addons_wrap wc-helper"> <div class="wrap woocommerce wc_addons_wrap wc-helper">
<?php include( WC_Helper::get_view_filename( 'html-section-nav.php' ) ); ?> <?php require WC_Helper::get_view_filename( 'html-section-nav.php' ); ?>
<h1 class="screen-reader-text"><?php _e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1> <h1 class="screen-reader-text"><?php _e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1>
<?php include( WC_Helper::get_view_filename( 'html-section-notices.php' ) ); ?> <?php require WC_Helper::get_view_filename( 'html-section-notices.php' ); ?>
<div class="subscriptions-header"> <div class="subscriptions-header">
<h2><?php _e( 'Subscriptions', 'woocommerce' ); ?></h2> <h2><?php _e( 'Subscriptions', 'woocommerce' ); ?></h2>
<?php include( WC_Helper::get_view_filename( 'html-section-account.php' ) ); ?> <?php require WC_Helper::get_view_filename( 'html-section-account.php' ); ?>
<p><?php printf( __( 'Below is a list of extensions available on your WooCommerce.com account. To receive extension updates please make sure the extension is installed, and its subscription activated and connected to your WooCommerce.com account. Extensions can be activated from the <a href="%s">Plugins</a> screen.', 'woocommerce' ), admin_url( 'plugins.php' ) ); ?></p> <p><?php printf( __( 'Below is a list of extensions available on your WooCommerce.com account. To receive extension updates please make sure the extension is installed, and its subscription activated and connected to your WooCommerce.com account. Extensions can be activated from the <a href="%s">Plugins</a> screen.', 'woocommerce' ), admin_url( 'plugins.php' ) ); ?></p>
</div> </div>
<ul class="subscription-filter"> <ul class="subscription-filter">
<label><?php _e( 'Sort by:', 'woocommerce' ); ?> <span class="chevron dashicons dashicons-arrow-up-alt2"></span></label> <label><?php _e( 'Sort by:', 'woocommerce' ); ?> <span class="chevron dashicons dashicons-arrow-up-alt2"></span></label>
<?php <?php
$filters = array_keys( WC_Helper::get_filters() ); $filters = array_keys( WC_Helper::get_filters() );
$last_filter = array_pop( $filters ); $last_filter = array_pop( $filters );
$current_filter = WC_Helper::get_current_filter(); $current_filter = WC_Helper::get_current_filter();
$counts = WC_Helper::get_filters_counts(); $counts = WC_Helper::get_filters_counts();
?> ?>
<?php foreach ( WC_Helper::get_filters() as $key => $label ) : ?> <?php
<?php foreach ( WC_Helper::get_filters() as $key => $label ) :
// Don't show empty filters. // Don't show empty filters.
if ( empty( $counts[ $key ] ) ) { if ( empty( $counts[ $key ] ) ) {
continue; continue;
} }
$url = admin_url( 'admin.php?page=wc-addons&section=helper&filter=' . $key ); $url = admin_url( 'admin.php?page=wc-addons&section=helper&filter=' . $key );
$class_html = $current_filter === $key ? 'class="current"' : ''; $class_html = $current_filter === $key ? 'class="current"' : '';
?> ?>
<li> <li>
<a <?php echo $class_html; ?> href="<?php echo esc_url( $url ); ?>"> <a <?php echo $class_html; ?> href="<?php echo esc_url( $url ); ?>">
@ -47,8 +47,9 @@
<tr class="wp-list-table__row is-ext-header"> <tr class="wp-list-table__row is-ext-header">
<td class="wp-list-table__ext-details"> <td class="wp-list-table__ext-details">
<div class="wp-list-table__ext-title"> <div class="wp-list-table__ext-title">
<a href="<?php echo esc_url( $subscription['product_url'] ); ?>" target="_blank"><?php <a href="<?php echo esc_url( $subscription['product_url'] ); ?>" target="_blank">
echo esc_html( $subscription['product_name'] ); ?></a> <?php echo esc_html( $subscription['product_name'] ); ?>
</a>
</div> </div>
<div class="wp-list-table__ext-description"> <div class="wp-list-table__ext-description">
@ -80,7 +81,7 @@
<br/> <br/>
<span class="subscription"> <span class="subscription">
<?php <?php
if ( ! $subscription['active'] && $subscription['maxed'] ) { if ( ! $subscription['active'] && $subscription['maxed'] ) {
/* translators: %1$d: sites active, %2$d max sites active */ /* translators: %1$d: sites active, %2$d max sites active */
printf( __( 'Subscription: Not available - %1$d of %2$d already in use', 'woocommerce' ), absint( $subscription['sites_active'] ), absint( $subscription['sites_max'] ) ); printf( __( 'Subscription: Not available - %1$d of %2$d already in use', 'woocommerce' ), absint( $subscription['sites_active'] ), absint( $subscription['sites_max'] ) );
@ -97,7 +98,7 @@
} elseif ( isset( $subscription['master_user_email'] ) ) { } elseif ( isset( $subscription['master_user_email'] ) ) {
printf( '</br>' . __( 'Shared by %s', 'woocommerce' ), esc_html( $subscription['master_user_email'] ) ); printf( '</br>' . __( 'Shared by %s', 'woocommerce' ), esc_html( $subscription['master_user_email'] ) );
} }
?> ?>
</span> </span>
</div> </div>
</td> </td>

View File

@ -75,7 +75,7 @@ class WC_Product_CSV_Importer_Controller {
*/ */
public static function get_importer( $file, $args = array() ) { public static function get_importer( $file, $args = array() ) {
$importer_class = apply_filters( 'woocommerce_product_csv_importer_class', 'WC_Product_CSV_Importer' ); $importer_class = apply_filters( 'woocommerce_product_csv_importer_class', 'WC_Product_CSV_Importer' );
$args = apply_filters( 'woocommerce_product_csv_importer_args', $args, $importer_class ); $args = apply_filters( 'woocommerce_product_csv_importer_args', $args, $importer_class );
return new $importer_class( $file, $args ); return new $importer_class( $file, $args );
} }
@ -84,7 +84,7 @@ class WC_Product_CSV_Importer_Controller {
*/ */
public function __construct() { public function __construct() {
$default_steps = array( $default_steps = array(
'upload' => array( 'upload' => array(
'name' => __( 'Upload CSV file', 'woocommerce' ), 'name' => __( 'Upload CSV file', 'woocommerce' ),
'view' => array( $this, 'upload_form' ), 'view' => array( $this, 'upload_form' ),
'handler' => array( $this, 'upload_form_handler' ), 'handler' => array( $this, 'upload_form_handler' ),
@ -94,12 +94,12 @@ class WC_Product_CSV_Importer_Controller {
'view' => array( $this, 'mapping_form' ), 'view' => array( $this, 'mapping_form' ),
'handler' => '', 'handler' => '',
), ),
'import' => array( 'import' => array(
'name' => __( 'Import', 'woocommerce' ), 'name' => __( 'Import', 'woocommerce' ),
'view' => array( $this, 'import' ), 'view' => array( $this, 'import' ),
'handler' => '', 'handler' => '',
), ),
'done' => array( 'done' => array(
'name' => __( 'Done!', 'woocommerce' ), 'name' => __( 'Done!', 'woocommerce' ),
'view' => array( $this, 'done' ), 'view' => array( $this, 'done' ),
'handler' => '', 'handler' => '',
@ -121,6 +121,7 @@ class WC_Product_CSV_Importer_Controller {
/** /**
* Get the URL for the next step's screen. * Get the URL for the next step's screen.
*
* @param string step slug (default: current step) * @param string step slug (default: current step)
* @return string URL for next step if a next step exists. * @return string URL for next step if a next step exists.
* Admin URL if it's the last step. * Admin URL if it's the last step.
@ -159,21 +160,21 @@ class WC_Product_CSV_Importer_Controller {
* Output header view. * Output header view.
*/ */
protected function output_header() { protected function output_header() {
include( dirname( __FILE__ ) . '/views/html-csv-import-header.php' ); include dirname( __FILE__ ) . '/views/html-csv-import-header.php';
} }
/** /**
* Output steps view. * Output steps view.
*/ */
protected function output_steps() { protected function output_steps() {
include( dirname( __FILE__ ) . '/views/html-csv-import-steps.php' ); include dirname( __FILE__ ) . '/views/html-csv-import-steps.php';
} }
/** /**
* Output footer view. * Output footer view.
*/ */
protected function output_footer() { protected function output_footer() {
include( dirname( __FILE__ ) . '/views/html-csv-import-footer.php' ); include dirname( __FILE__ ) . '/views/html-csv-import-footer.php';
} }
/** /**
@ -234,7 +235,7 @@ class WC_Product_CSV_Importer_Controller {
$size = size_format( $bytes ); $size = size_format( $bytes );
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
include( dirname( __FILE__ ) . '/views/html-product-csv-import-form.php' ); include dirname( __FILE__ ) . '/views/html-product-csv-import-form.php';
} }
/** /**
@ -263,7 +264,12 @@ class WC_Product_CSV_Importer_Controller {
* @return string|WP_Error * @return string|WP_Error
*/ */
public function handle_upload() { public function handle_upload() {
$valid_filetypes = apply_filters( 'woocommerce_csv_product_import_valid_filetypes', array( 'csv' => 'text/csv', 'txt' => 'text/plain' ) ); $valid_filetypes = apply_filters(
'woocommerce_csv_product_import_valid_filetypes', array(
'csv' => 'text/csv',
'txt' => 'text/plain',
)
);
if ( empty( $_POST['file_url'] ) ) { if ( empty( $_POST['file_url'] ) ) {
if ( ! isset( $_FILES['import'] ) ) { if ( ! isset( $_FILES['import'] ) ) {
@ -275,8 +281,11 @@ class WC_Product_CSV_Importer_Controller {
return new WP_Error( 'woocommerce_product_csv_importer_upload_file_invalid', __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) ); return new WP_Error( 'woocommerce_product_csv_importer_upload_file_invalid', __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
} }
$overrides = array( 'test_form' => false, 'mimes' => $valid_filetypes ); $overrides = array(
$upload = wp_handle_upload( $_FILES['import'], $overrides ); 'test_form' => false,
'mimes' => $valid_filetypes,
);
$upload = wp_handle_upload( $_FILES['import'], $overrides );
if ( isset( $upload['error'] ) ) { if ( isset( $upload['error'] ) ) {
return new WP_Error( 'woocommerce_product_csv_importer_upload_error', $upload['error'] ); return new WP_Error( 'woocommerce_product_csv_importer_upload_error', $upload['error'] );
@ -318,7 +327,7 @@ class WC_Product_CSV_Importer_Controller {
* Mapping step. * Mapping step.
*/ */
protected function mapping_form() { protected function mapping_form() {
$args = array( $args = array(
'lines' => 1, 'lines' => 1,
'delimiter' => $this->delimiter, 'delimiter' => $this->delimiter,
); );
@ -344,7 +353,7 @@ class WC_Product_CSV_Importer_Controller {
return; return;
} }
include_once( dirname( __FILE__ ) . '/views/html-csv-import-mapping.php' ); include_once dirname( __FILE__ ) . '/views/html-csv-import-mapping.php';
} }
/** /**
@ -367,19 +376,21 @@ class WC_Product_CSV_Importer_Controller {
exit; exit;
} }
wp_localize_script( 'wc-product-import', 'wc_product_import_params', array( wp_localize_script(
'import_nonce' => wp_create_nonce( 'wc-product-import' ), 'wc-product-import', 'wc_product_import_params', array(
'mapping' => array( 'import_nonce' => wp_create_nonce( 'wc-product-import' ),
'from' => $mapping_from, 'mapping' => array(
'to' => $mapping_to, 'from' => $mapping_from,
), 'to' => $mapping_to,
'file' => $this->file, ),
'update_existing' => $this->update_existing, 'file' => $this->file,
'delimiter' => $this->delimiter, 'update_existing' => $this->update_existing,
) ); 'delimiter' => $this->delimiter,
)
);
wp_enqueue_script( 'wc-product-import' ); wp_enqueue_script( 'wc-product-import' );
include_once( dirname( __FILE__ ) . '/views/html-csv-import-progress.php' ); include_once dirname( __FILE__ ) . '/views/html-csv-import-progress.php';
} }
/** /**
@ -392,7 +403,7 @@ class WC_Product_CSV_Importer_Controller {
$skipped = isset( $_GET['products-skipped'] ) ? absint( $_GET['products-skipped'] ) : 0; $skipped = isset( $_GET['products-skipped'] ) ? absint( $_GET['products-skipped'] ) : 0;
$errors = array_filter( (array) get_user_option( 'product_import_error_log' ) ); $errors = array_filter( (array) get_user_option( 'product_import_error_log' ) );
include_once( dirname( __FILE__ ) . '/views/html-csv-import-done.php' ); include_once dirname( __FILE__ ) . '/views/html-csv-import-done.php';
} }
/** /**
@ -419,69 +430,78 @@ class WC_Product_CSV_Importer_Controller {
* @return array * @return array
*/ */
protected function auto_map_columns( $raw_headers, $num_indexes = true ) { protected function auto_map_columns( $raw_headers, $num_indexes = true ) {
$weight_unit = get_option( 'woocommerce_weight_unit' ); $weight_unit = get_option( 'woocommerce_weight_unit' );
$dimension_unit = get_option( 'woocommerce_dimension_unit' ); $dimension_unit = get_option( 'woocommerce_dimension_unit' );
include( dirname( __FILE__ ) . '/mappings/mappings.php' ); include dirname( __FILE__ ) . '/mappings/mappings.php';
/** /**
* @hooked wc_importer_generic_mappings - 10 * @hooked wc_importer_generic_mappings - 10
* @hooked wc_importer_wordpress_mappings - 10 * @hooked wc_importer_wordpress_mappings - 10
* @hooked wc_importer_default_english_mappings - 100 * @hooked wc_importer_default_english_mappings - 100
*/ */
$default_columns = $this->normalize_columns_names( apply_filters( 'woocommerce_csv_product_import_mapping_default_columns', array( $default_columns = $this->normalize_columns_names(
__( 'ID', 'woocommerce' ) => 'id', apply_filters(
__( 'Type', 'woocommerce' ) => 'type', 'woocommerce_csv_product_import_mapping_default_columns', array(
__( 'SKU', 'woocommerce' ) => 'sku', __( 'ID', 'woocommerce' ) => 'id',
__( 'Name', 'woocommerce' ) => 'name', __( 'Type', 'woocommerce' ) => 'type',
__( 'Published', 'woocommerce' ) => 'published', __( 'SKU', 'woocommerce' ) => 'sku',
__( 'Is featured?', 'woocommerce' ) => 'featured', __( 'Name', 'woocommerce' ) => 'name',
__( 'Visibility in catalog', 'woocommerce' ) => 'catalog_visibility', __( 'Published', 'woocommerce' ) => 'published',
__( 'Short description', 'woocommerce' ) => 'short_description', __( 'Is featured?', 'woocommerce' ) => 'featured',
__( 'Description', 'woocommerce' ) => 'description', __( 'Visibility in catalog', 'woocommerce' ) => 'catalog_visibility',
__( 'Date sale price starts', 'woocommerce' ) => 'date_on_sale_from', __( 'Short description', 'woocommerce' ) => 'short_description',
__( 'Date sale price ends', 'woocommerce' ) => 'date_on_sale_to', __( 'Description', 'woocommerce' ) => 'description',
__( 'Tax status', 'woocommerce' ) => 'tax_status', __( 'Date sale price starts', 'woocommerce' ) => 'date_on_sale_from',
__( 'Tax class', 'woocommerce' ) => 'tax_class', __( 'Date sale price ends', 'woocommerce' ) => 'date_on_sale_to',
__( 'In stock?', 'woocommerce' ) => 'stock_status', __( 'Tax status', 'woocommerce' ) => 'tax_status',
__( 'Stock', 'woocommerce' ) => 'stock_quantity', __( 'Tax class', 'woocommerce' ) => 'tax_class',
__( 'Backorders allowed?', 'woocommerce' ) => 'backorders', __( 'In stock?', 'woocommerce' ) => 'stock_status',
__( 'Sold individually?', 'woocommerce' ) => 'sold_individually', __( 'Stock', 'woocommerce' ) => 'stock_quantity',
sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit ) => 'weight', __( 'Backorders allowed?', 'woocommerce' ) => 'backorders',
sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ) => 'length', __( 'Sold individually?', 'woocommerce' ) => 'sold_individually',
sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ) => 'width', sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit ) => 'weight',
sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ) => 'height', sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ) => 'length',
__( 'Allow customer reviews?', 'woocommerce' ) => 'reviews_allowed', sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ) => 'width',
__( 'Purchase note', 'woocommerce' ) => 'purchase_note', sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ) => 'height',
__( 'Sale price', 'woocommerce' ) => 'sale_price', __( 'Allow customer reviews?', 'woocommerce' ) => 'reviews_allowed',
__( 'Regular price', 'woocommerce' ) => 'regular_price', __( 'Purchase note', 'woocommerce' ) => 'purchase_note',
__( 'Categories', 'woocommerce' ) => 'category_ids', __( 'Sale price', 'woocommerce' ) => 'sale_price',
__( 'Tags', 'woocommerce' ) => 'tag_ids', __( 'Regular price', 'woocommerce' ) => 'regular_price',
__( 'Shipping class', 'woocommerce' ) => 'shipping_class_id', __( 'Categories', 'woocommerce' ) => 'category_ids',
__( 'Images', 'woocommerce' ) => 'images', __( 'Tags', 'woocommerce' ) => 'tag_ids',
__( 'Download limit', 'woocommerce' ) => 'download_limit', __( 'Shipping class', 'woocommerce' ) => 'shipping_class_id',
__( 'Download expiry days', 'woocommerce' ) => 'download_expiry', __( 'Images', 'woocommerce' ) => 'images',
__( 'Parent', 'woocommerce' ) => 'parent_id', __( 'Download limit', 'woocommerce' ) => 'download_limit',
__( 'Upsells', 'woocommerce' ) => 'upsell_ids', __( 'Download expiry days', 'woocommerce' ) => 'download_expiry',
__( 'Cross-sells', 'woocommerce' ) => 'cross_sell_ids', __( 'Parent', 'woocommerce' ) => 'parent_id',
__( 'Grouped products', 'woocommerce' ) => 'grouped_products', __( 'Upsells', 'woocommerce' ) => 'upsell_ids',
__( 'External URL', 'woocommerce' ) => 'product_url', __( 'Cross-sells', 'woocommerce' ) => 'cross_sell_ids',
__( 'Button text', 'woocommerce' ) => 'button_text', __( 'Grouped products', 'woocommerce' ) => 'grouped_products',
__( 'Position', 'woocommerce' ) => 'menu_order', __( 'External URL', 'woocommerce' ) => 'product_url',
) ) ); __( 'Button text', 'woocommerce' ) => 'button_text',
__( 'Position', 'woocommerce' ) => 'menu_order',
$special_columns = $this->get_special_columns( $this->normalize_columns_names( apply_filters( 'woocommerce_csv_product_import_mapping_special_columns', )
array(
__( 'Attribute %d name', 'woocommerce' ) => 'attributes:name',
__( 'Attribute %d value(s)', 'woocommerce' ) => 'attributes:value',
__( 'Attribute %d visible', 'woocommerce' ) => 'attributes:visible',
__( 'Attribute %d global', 'woocommerce' ) => 'attributes:taxonomy',
__( 'Attribute %d default', 'woocommerce' ) => 'attributes:default',
__( 'Download %d name', 'woocommerce' ) => 'downloads:name',
__( 'Download %d URL', 'woocommerce' ) => 'downloads:url',
__( 'Meta: %s', 'woocommerce' ) => 'meta:',
) )
) ) ); );
$special_columns = $this->get_special_columns(
$this->normalize_columns_names(
apply_filters(
'woocommerce_csv_product_import_mapping_special_columns',
array(
__( 'Attribute %d name', 'woocommerce' ) => 'attributes:name',
__( 'Attribute %d value(s)', 'woocommerce' ) => 'attributes:value',
__( 'Attribute %d visible', 'woocommerce' ) => 'attributes:visible',
__( 'Attribute %d global', 'woocommerce' ) => 'attributes:taxonomy',
__( 'Attribute %d default', 'woocommerce' ) => 'attributes:default',
__( 'Download %d name', 'woocommerce' ) => 'downloads:name',
__( 'Download %d URL', 'woocommerce' ) => 'downloads:url',
__( 'Meta: %s', 'woocommerce' ) => 'meta:',
)
)
)
);
$headers = array(); $headers = array();
foreach ( $raw_headers as $key => $field ) { foreach ( $raw_headers as $key => $field ) {
@ -599,11 +619,11 @@ class WC_Product_CSV_Importer_Controller {
'name' => __( 'Dimensions', 'woocommerce' ), 'name' => __( 'Dimensions', 'woocommerce' ),
'options' => array( 'options' => array(
/* translators: %s: dimension unit */ /* translators: %s: dimension unit */
'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ), 'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ),
/* translators: %s: dimension unit */ /* translators: %s: dimension unit */
'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ), 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ),
/* translators: %s: dimension unit */ /* translators: %s: dimension unit */
'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ), 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ),
), ),
), ),
'category_ids' => __( 'Categories', 'woocommerce' ), 'category_ids' => __( 'Categories', 'woocommerce' ),
@ -617,8 +637,8 @@ class WC_Product_CSV_Importer_Controller {
'external' => array( 'external' => array(
'name' => __( 'External product', 'woocommerce' ), 'name' => __( 'External product', 'woocommerce' ),
'options' => array( 'options' => array(
'product_url' => __( 'External URL', 'woocommerce' ), 'product_url' => __( 'External URL', 'woocommerce' ),
'button_text' => __( 'Button text', 'woocommerce' ), 'button_text' => __( 'Button text', 'woocommerce' ),
), ),
), ),
'downloads' => array( 'downloads' => array(

View File

@ -248,14 +248,16 @@ class WC_Tax_Rate_Importer extends WP_Importer {
$action = 'admin.php?import=woocommerce_tax_rate_csv&step=1'; $action = 'admin.php?import=woocommerce_tax_rate_csv&step=1';
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
$size = size_format( $bytes ); $size = size_format( $bytes );
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) : if ( ! empty( $upload_dir['error'] ) ) :
?><div class="error"><p><?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'woocommerce' ); ?></p>
<p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p></div><?php
else :
?> ?>
<div class="error">
<p><?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'woocommerce' ); ?></p>
<p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p>
</div>
<?php else : ?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr( wp_nonce_url( $action, 'import-upload' ) ); ?>"> <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr( wp_nonce_url( $action, 'import-upload' ) ); ?>">
<table class="form-table"> <table class="form-table">
<tbody> <tbody>

View File

@ -31,9 +31,9 @@ function wc_importer_default_english_mappings( $mappings ) {
return $mappings; return $mappings;
} }
$weight_unit = get_option( 'woocommerce_weight_unit' ); $weight_unit = get_option( 'woocommerce_weight_unit' );
$dimension_unit = get_option( 'woocommerce_dimension_unit' ); $dimension_unit = get_option( 'woocommerce_dimension_unit' );
$new_mappings = array( $new_mappings = array(
'ID' => 'id', 'ID' => 'id',
'Type' => 'type', 'Type' => 'type',
'SKU' => 'sku', 'SKU' => 'sku',

View File

@ -7,6 +7,6 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
include( dirname( __FILE__ ) . '/default.php' ); require dirname( __FILE__ ) . '/default.php';
include( dirname( __FILE__ ) . '/generic.php' ); require dirname( __FILE__ ) . '/generic.php';
include( dirname( __FILE__ ) . '/wordpress.php' ); require dirname( __FILE__ ) . '/wordpress.php';

View File

@ -9,46 +9,46 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="wc-progress-form-content woocommerce-importer"> <div class="wc-progress-form-content woocommerce-importer">
<section class="woocommerce-importer-done"> <section class="woocommerce-importer-done">
<?php <?php
$results = array(); $results = array();
if ( 0 < $imported ) { if ( 0 < $imported ) {
$results[] = sprintf( $results[] = sprintf(
/* translators: %d: products count */ /* translators: %d: products count */
_n( '%s product imported', '%s products imported', $imported, 'woocommerce' ), _n( '%s product imported', '%s products imported', $imported, 'woocommerce' ),
'<strong>' . number_format_i18n( $imported ) . '</strong>' '<strong>' . number_format_i18n( $imported ) . '</strong>'
); );
} }
if ( 0 < $updated ) { if ( 0 < $updated ) {
$results[] = sprintf( $results[] = sprintf(
/* translators: %d: products count */ /* translators: %d: products count */
_n( '%s product updated', '%s products updated', $updated, 'woocommerce' ), _n( '%s product updated', '%s products updated', $updated, 'woocommerce' ),
'<strong>' . number_format_i18n( $updated ) . '</strong>' '<strong>' . number_format_i18n( $updated ) . '</strong>'
); );
} }
if ( 0 < $skipped ) { if ( 0 < $skipped ) {
$results[] = sprintf( $results[] = sprintf(
/* translators: %d: products count */ /* translators: %d: products count */
_n( '%s product was skipped', '%s products were skipped', $skipped, 'woocommerce' ), _n( '%s product was skipped', '%s products were skipped', $skipped, 'woocommerce' ),
'<strong>' . number_format_i18n( $skipped ) . '</strong>' '<strong>' . number_format_i18n( $skipped ) . '</strong>'
); );
} }
if ( 0 < $failed ) { if ( 0 < $failed ) {
$results [] = sprintf( $results [] = sprintf(
/* translators: %d: products count */ /* translators: %d: products count */
_n( 'Failed to import %s product', 'Failed to import %s products', $failed, 'woocommerce' ), _n( 'Failed to import %s product', 'Failed to import %s products', $failed, 'woocommerce' ),
'<strong>' . number_format_i18n( $failed ) . '</strong>' '<strong>' . number_format_i18n( $failed ) . '</strong>'
); );
} }
if ( 0 < $failed || 0 < $skipped ) { if ( 0 < $failed || 0 < $skipped ) {
$results[] = '<a href="#" class="woocommerce-importer-done-view-errors">' . __( 'View import log', 'woocommerce' ) . '</a>'; $results[] = '<a href="#" class="woocommerce-importer-done-view-errors">' . __( 'View import log', 'woocommerce' ) . '</a>';
} }
/* translators: %d: import results */ /* translators: %d: import results */
echo wp_kses_post( __( 'Import complete!', 'woocommerce' ) . ' ' . implode( '. ', $results ) ); echo wp_kses_post( __( 'Import complete!', 'woocommerce' ) . ' ' . implode( '. ', $results ) );
?> ?>
</section> </section>
<section class="wc-importer-error-log" style="display:none"> <section class="wc-importer-error-log" style="display:none">
@ -61,20 +61,20 @@ if ( ! defined( 'ABSPATH' ) ) {
</thead> </thead>
<tbody> <tbody>
<?php <?php
if ( count( $errors ) ) { if ( count( $errors ) ) {
foreach ( $errors as $error ) { foreach ( $errors as $error ) {
if ( ! is_wp_error( $error ) ) { if ( ! is_wp_error( $error ) ) {
continue; continue;
}
$error_data = $error->get_error_data();
?>
<tr>
<th><code><?php echo esc_html( $error_data['row'] ); ?></code></th>
<td><?php echo esc_html( $error->get_error_message() ); ?></td>
</tr>
<?php
} }
$error_data = $error->get_error_data();
?>
<tr>
<th><code><?php echo esc_html( $error_data['row'] ); ?></code></th>
<td><?php echo esc_html( $error->get_error_message() ); ?></td>
</tr>
<?php
} }
}
?> ?>
</tbody> </tbody>
</table> </table>

View File

@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
?> ?>
<form class="wc-progress-form-content woocommerce-importer" method="post" action="<?php echo esc_url( $this->get_next_step_link() ) ?>"> <form class="wc-progress-form-content woocommerce-importer" method="post" action="<?php echo esc_url( $this->get_next_step_link() ); ?>">
<header> <header>
<h2><?php esc_html_e( 'Map CSV fields to products', 'woocommerce' ); ?></h2> <h2><?php esc_html_e( 'Map CSV fields to products', 'woocommerce' ); ?></h2>
<p><?php esc_html_e( 'Select fields from your CSV file to map against products fields, or to ignore during import.', 'woocommerce' ); ?></p> <p><?php esc_html_e( 'Select fields from your CSV file to map against products fields, or to ignore during import.', 'woocommerce' ); ?></p>

View File

@ -8,12 +8,15 @@ if ( ! defined( 'ABSPATH' ) ) {
?> ?>
<ol class="wc-progress-steps"> <ol class="wc-progress-steps">
<?php foreach ( $this->steps as $step_key => $step ) : ?> <?php foreach ( $this->steps as $step_key => $step ) : ?>
<li class="<?php <?php
if ( $step_key === $this->step ) { if ( $step_key === $this->step ) {
echo 'active'; $step_class = 'active';
} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) { } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
echo 'done'; $step_class = 'done';
} }
?>"><?php echo esc_html( $step['name'] ); ?></li> ?>
<li class="<?php echo esc_attr( $step_class ); ?>">
<?php echo esc_html( $step['name'] ); ?>
</li>
<?php endforeach; ?> <?php endforeach; ?>
</ol> </ol>

View File

@ -26,10 +26,12 @@ if ( ! defined( 'ABSPATH' ) ) {
<td> <td>
<?php <?php
if ( ! empty( $upload_dir['error'] ) ) { if ( ! empty( $upload_dir['error'] ) ) {
?><div class="inline error"> ?>
<div class="inline error">
<p><?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'woocommerce' ); ?></p> <p><?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'woocommerce' ); ?></p>
<p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p> <p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p>
</div><?php </div>
<?php
} else { } else {
?> ?>
<input type="file" id="upload" name="import" size="25" /> <input type="file" id="upload" name="import" size="25" />
@ -99,4 +101,4 @@ if ( ! defined( 'ABSPATH' ) ) {
<button type="submit" class="button button-primary button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button> <button type="submit" class="button button-primary button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button>
<?php wp_nonce_field( 'woocommerce-csv-importer' ); ?> <?php wp_nonce_field( 'woocommerce-csv-importer' ); ?>
</div> </div>
</form> </form>

View File

@ -66,7 +66,7 @@ abstract class WC_Admin_List_Table {
if ( $post_type === $this->list_table_type && 'bottom' === $which ) { if ( $post_type === $this->list_table_type && 'bottom' === $which ) {
$counts = (array) wp_count_posts( $post_type ); $counts = (array) wp_count_posts( $post_type );
unset( $counts['auto-draft'] ); unset( $counts['auto-draft'] );
$count = array_sum( $counts ); $count = array_sum( $counts );
if ( 0 < $count ) { if ( 0 < $count ) {
return; return;

View File

@ -17,7 +17,7 @@ if ( class_exists( 'WC_Admin_List_Table_Coupons', false ) ) {
} }
if ( ! class_exists( 'WC_Admin_List_Table', false ) ) { if ( ! class_exists( 'WC_Admin_List_Table', false ) ) {
include_once( 'abstract-class-wc-admin-list-table.php' ); include_once 'abstract-class-wc-admin-list-table.php';
} }
/** /**
@ -47,7 +47,7 @@ class WC_Admin_List_Table_Coupons extends WC_Admin_List_Table {
echo '<div class="woocommerce-BlankState">'; echo '<div class="woocommerce-BlankState">';
echo '<h2 class="woocommerce-BlankState-message">' . esc_html__( 'Coupons are a great way to offer discounts and rewards to your customers. They will appear here once created.', 'woocommerce' ) . '</h2>'; echo '<h2 class="woocommerce-BlankState-message">' . esc_html__( 'Coupons are a great way to offer discounts and rewards to your customers. They will appear here once created.', 'woocommerce' ) . '</h2>';
echo '<a class="woocommerce-BlankState-cta button-primary button" target="_blank" href="https://docs.woocommerce.com/document/coupon-management/?utm_source=blankslate&utm_medium=product&utm_content=couponsdoc&utm_campaign=woocommerceplugin">' . esc_html__( 'Learn more about coupons', 'woocommerce' ) . '</a>'; echo '<a class="woocommerce-BlankState-cta button-primary button" target="_blank" href="https://docs.woocommerce.com/document/coupon-management/?utm_source=blankslate&utm_medium=product&utm_content=couponsdoc&utm_campaign=woocommerceplugin">' . esc_html__( 'Learn more about coupons', 'woocommerce' ) . '</a>';
echo '<a class="woocommerce-BlankState-cta button-primary button" href="' . esc_url ( admin_url( 'post-new.php?post_type=shop_coupon' ) ) . '">' . esc_html__( 'Create your first coupon', 'woocommerce' ) . '</a>'; echo '<a class="woocommerce-BlankState-cta button-primary button" href="' . esc_url( admin_url( 'post-new.php?post_type=shop_coupon' ) ) . '">' . esc_html__( 'Create your first coupon', 'woocommerce' ) . '</a>';
echo '</div>'; echo '</div>';
} }

View File

@ -458,8 +458,8 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
// Search using CRUD. // Search using CRUD.
if ( ! empty( $query_vars['s'] ) ) { if ( ! empty( $query_vars['s'] ) ) {
$data_store = WC_Data_Store::load( 'product' ); $data_store = WC_Data_Store::load( 'product' );
$ids = $data_store->search_products( wc_clean( $query_vars['s'] ), '', true, true ); $ids = $data_store->search_products( wc_clean( $query_vars['s'] ), '', true, true );
$query_vars['post__in'] = array_merge( $ids, array( 0 ) ); $query_vars['post__in'] = array_merge( $ids, array( 0 ) );
// So we know we are searching products. // So we know we are searching products.
$query_vars['product_search'] = true; $query_vars['product_search'] = true;

View File

@ -28,7 +28,9 @@ class WC_Meta_Box_Coupon_Data {
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
$coupon = new WC_Coupon( $post->ID ); $coupon = new WC_Coupon( $post->ID );
?> ?>
<style type="text/css"> <style type="text/css">
#edit-slug-box, #minor-publishing-actions { display:none } #edit-slug-box, #minor-publishing-actions { display:none }
</style> </style>
@ -38,8 +40,9 @@ class WC_Meta_Box_Coupon_Data {
<ul class="coupon_data_tabs wc-tabs" style="display:none;"> <ul class="coupon_data_tabs wc-tabs" style="display:none;">
<?php <?php
$coupon_data_tabs = apply_filters( 'woocommerce_coupon_data_tabs', array( $coupon_data_tabs = apply_filters(
'general' => array( 'woocommerce_coupon_data_tabs', array(
'general' => array(
'label' => __( 'General', 'woocommerce' ), 'label' => __( 'General', 'woocommerce' ),
'target' => 'general_coupon_data', 'target' => 'general_coupon_data',
'class' => 'general_coupon_data', 'class' => 'general_coupon_data',
@ -49,110 +52,133 @@ class WC_Meta_Box_Coupon_Data {
'target' => 'usage_restriction_coupon_data', 'target' => 'usage_restriction_coupon_data',
'class' => '', 'class' => '',
), ),
'usage_limit' => array( 'usage_limit' => array(
'label' => __( 'Usage limits', 'woocommerce' ), 'label' => __( 'Usage limits', 'woocommerce' ),
'target' => 'usage_limit_coupon_data', 'target' => 'usage_limit_coupon_data',
'class' => '', 'class' => '',
), ),
) ); )
);
foreach ( $coupon_data_tabs as $key => $tab ) { foreach ( $coupon_data_tabs as $key => $tab ) :
?><li class="<?php echo $key; ?>_options <?php echo $key; ?>_tab <?php echo implode( ' ' , (array) $tab['class'] ); ?>"> ?>
<a href="#<?php echo $tab['target']; ?>"><span><?php echo esc_html( $tab['label'] ); ?></span></a> <li class="<?php echo $key; ?>_options <?php echo $key; ?>_tab <?php echo implode( ' ', (array) $tab['class'] ); ?>">
</li><?php <a href="#<?php echo $tab['target']; ?>">
} <span><?php echo esc_html( $tab['label'] ); ?></span>
?> </a>
</li>
<?php endforeach; ?>
</ul> </ul>
<div id="general_coupon_data" class="panel woocommerce_options_panel"><?php <div id="general_coupon_data" class="panel woocommerce_options_panel">
<?php
// Type // Type.
woocommerce_wp_select( array( woocommerce_wp_select(
'id' => 'discount_type', array(
'label' => __( 'Discount type', 'woocommerce' ), 'id' => 'discount_type',
'options' => wc_get_coupon_types(), 'label' => __( 'Discount type', 'woocommerce' ),
) ); 'options' => wc_get_coupon_types(),
)
);
// Amount // Amount.
woocommerce_wp_text_input( array( woocommerce_wp_text_input(
'id' => 'coupon_amount', array(
'label' => __( 'Coupon amount', 'woocommerce' ), 'id' => 'coupon_amount',
'placeholder' => wc_format_localized_price( 0 ), 'label' => __( 'Coupon amount', 'woocommerce' ),
'description' => __( 'Value of the coupon.', 'woocommerce' ), 'placeholder' => wc_format_localized_price( 0 ),
'data_type' => 'price', 'description' => __( 'Value of the coupon.', 'woocommerce' ),
'desc_tip' => true, 'data_type' => 'price',
) ); 'desc_tip' => true,
)
);
// Free Shipping // Free Shipping.
if ( wc_shipping_enabled() ) { if ( wc_shipping_enabled() ) {
woocommerce_wp_checkbox( array( woocommerce_wp_checkbox(
'id' => 'free_shipping', array(
'label' => __( 'Allow free shipping', 'woocommerce' ), 'id' => 'free_shipping',
'description' => sprintf( __( 'Check this box if the coupon grants free shipping. A <a href="%s" target="_blank">free shipping method</a> must be enabled in your shipping zone and be set to require "a valid free shipping coupon" (see the "Free Shipping Requires" setting).', 'woocommerce' ), 'https://docs.woocommerce.com/document/free-shipping/' ), 'label' => __( 'Allow free shipping', 'woocommerce' ),
) ); 'description' => sprintf( __( 'Check this box if the coupon grants free shipping. A <a href="%s" target="_blank">free shipping method</a> must be enabled in your shipping zone and be set to require "a valid free shipping coupon" (see the "Free Shipping Requires" setting).', 'woocommerce' ), 'https://docs.woocommerce.com/document/free-shipping/' ),
)
);
} }
// Expiry date // Expiry date.
$expiry_date = $coupon->get_date_expires() ? $coupon->get_date_expires()->date( 'Y-m-d' ) : ''; $expiry_date = $coupon->get_date_expires() ? $coupon->get_date_expires()->date( 'Y-m-d' ) : '';
woocommerce_wp_text_input( array( woocommerce_wp_text_input(
'id' => 'expiry_date', array(
'value' => esc_attr( $expiry_date ), 'id' => 'expiry_date',
'label' => __( 'Coupon expiry date', 'woocommerce' ), 'value' => esc_attr( $expiry_date ),
'placeholder' => 'YYYY-MM-DD', 'label' => __( 'Coupon expiry date', 'woocommerce' ),
'description' => '', 'placeholder' => 'YYYY-MM-DD',
'class' => 'date-picker', 'description' => '',
'custom_attributes' => array( 'class' => 'date-picker',
'pattern' => apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ), 'custom_attributes' => array(
), 'pattern' => apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ),
) ); ),
)
);
do_action( 'woocommerce_coupon_options', $coupon->get_id(), $coupon ); do_action( 'woocommerce_coupon_options', $coupon->get_id(), $coupon );
?></div> ?>
<div id="usage_restriction_coupon_data" class="panel woocommerce_options_panel"><?php </div>
<div id="usage_restriction_coupon_data" class="panel woocommerce_options_panel">
<?php
echo '<div class="options_group">'; echo '<div class="options_group">';
// minimum spend // minimum spend.
woocommerce_wp_text_input( array( woocommerce_wp_text_input(
'id' => 'minimum_amount', array(
'label' => __( 'Minimum spend', 'woocommerce' ), 'id' => 'minimum_amount',
'placeholder' => __( 'No minimum', 'woocommerce' ), 'label' => __( 'Minimum spend', 'woocommerce' ),
'description' => __( 'This field allows you to set the minimum spend (subtotal) allowed to use the coupon.', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ),
'data_type' => 'price', 'description' => __( 'This field allows you to set the minimum spend (subtotal) allowed to use the coupon.', 'woocommerce' ),
'desc_tip' => true, 'data_type' => 'price',
) ); 'desc_tip' => true,
)
);
// maximum spend // maximum spend.
woocommerce_wp_text_input( array( woocommerce_wp_text_input(
'id' => 'maximum_amount', array(
'label' => __( 'Maximum spend', 'woocommerce' ), 'id' => 'maximum_amount',
'placeholder' => __( 'No maximum', 'woocommerce' ), 'label' => __( 'Maximum spend', 'woocommerce' ),
'description' => __( 'This field allows you to set the maximum spend (subtotal) allowed when using the coupon.', 'woocommerce' ), 'placeholder' => __( 'No maximum', 'woocommerce' ),
'data_type' => 'price', 'description' => __( 'This field allows you to set the maximum spend (subtotal) allowed when using the coupon.', 'woocommerce' ),
'desc_tip' => true, 'data_type' => 'price',
) ); 'desc_tip' => true,
)
);
// Individual use // Individual use.
woocommerce_wp_checkbox( array( woocommerce_wp_checkbox(
'id' => 'individual_use', array(
'label' => __( 'Individual use only', 'woocommerce' ), 'id' => 'individual_use',
'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ), 'label' => __( 'Individual use only', 'woocommerce' ),
) ); 'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ),
)
);
// Exclude Sale Products // Exclude Sale Products.
woocommerce_wp_checkbox( array( woocommerce_wp_checkbox(
'id' => 'exclude_sale_items', array(
'label' => __( 'Exclude sale items', 'woocommerce' ), 'id' => 'exclude_sale_items',
'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are items in the cart that are not on sale.', 'woocommerce' ), 'label' => __( 'Exclude sale items', 'woocommerce' ),
) ); 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are items in the cart that are not on sale.', 'woocommerce' ),
)
);
echo '</div><div class="options_group">'; echo '</div><div class="options_group">';
// Product ids // Product ids.
?> ?>
<p class="form-field"><label><?php _e( 'Products', 'woocommerce' ); ?></label> <p class="form-field">
<select class="wc-product-search" multiple="multiple" style="width: 50%;" name="product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations"> <label><?php _e( 'Products', 'woocommerce' ); ?></label>
<?php <select class="wc-product-search" multiple="multiple" style="width: 50%;" name="product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations">
<?php
$product_ids = $coupon->get_product_ids(); $product_ids = $coupon->get_product_ids();
foreach ( $product_ids as $product_id ) { foreach ( $product_ids as $product_id ) {
@ -161,15 +187,16 @@ class WC_Meta_Box_Coupon_Data {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>'; echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
} }
} }
?> ?>
</select> <?php echo wc_help_tip( __( 'Products that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?></p> </select>
<?php <?php echo wc_help_tip( __( 'Products that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?>
</p>
// Exclude Product ids <?php // Exclude Product ids. ?>
?> <p class="form-field">
<p class="form-field"><label><?php _e( 'Exclude products', 'woocommerce' ); ?></label> <label><?php _e( 'Exclude products', 'woocommerce' ); ?></label>
<select class="wc-product-search" multiple="multiple" style="width: 50%;" name="exclude_product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations"> <select class="wc-product-search" multiple="multiple" style="width: 50%;" name="exclude_product_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations">
<?php <?php
$product_ids = $coupon->get_excluded_product_ids(); $product_ids = $coupon->get_excluded_product_ids();
foreach ( $product_ids as $product_id ) { foreach ( $product_ids as $product_id ) {
@ -178,17 +205,20 @@ class WC_Meta_Box_Coupon_Data {
echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>'; echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
} }
} }
?> ?>
</select> <?php echo wc_help_tip( __( 'Products that the coupon will not be applied to, or that cannot be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?></p> </select>
<?php echo wc_help_tip( __( 'Products that the coupon will not be applied to, or that cannot be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?>
</p>
<?php <?php
echo '</div><div class="options_group">'; echo '</div><div class="options_group">';
// Categories // Categories.
?> ?>
<p class="form-field"><label for="product_categories"><?php _e( 'Product categories', 'woocommerce' ); ?></label> <p class="form-field">
<select id="product_categories" name="product_categories[]" style="width: 50%;" class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php esc_attr_e( 'Any category', 'woocommerce' ); ?>"> <label for="product_categories"><?php _e( 'Product categories', 'woocommerce' ); ?></label>
<?php <select id="product_categories" name="product_categories[]" style="width: 50%;" class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php esc_attr_e( 'Any category', 'woocommerce' ); ?>">
<?php
$category_ids = $coupon->get_product_categories(); $category_ids = $coupon->get_product_categories();
$categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' ); $categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
@ -197,15 +227,15 @@ class WC_Meta_Box_Coupon_Data {
echo '<option value="' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</option>'; echo '<option value="' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</option>';
} }
} }
?> ?>
</select> <?php echo wc_help_tip( __( 'Product categories that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?></p> </select> <?php echo wc_help_tip( __( 'Product categories that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?>
<?php </p>
// Exclude Categories <?php // Exclude Categories. ?>
?> <p class="form-field">
<p class="form-field"><label for="exclude_product_categories"><?php _e( 'Exclude categories', 'woocommerce' ); ?></label> <label for="exclude_product_categories"><?php _e( 'Exclude categories', 'woocommerce' ); ?></label>
<select id="exclude_product_categories" name="exclude_product_categories[]" style="width: 50%;" class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php esc_attr_e( 'No categories', 'woocommerce' ); ?>"> <select id="exclude_product_categories" name="exclude_product_categories[]" style="width: 50%;" class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php esc_attr_e( 'No categories', 'woocommerce' ); ?>">
<?php <?php
$category_ids = $coupon->get_excluded_product_categories(); $category_ids = $coupon->get_excluded_product_categories();
$categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' ); $categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
@ -214,89 +244,93 @@ class WC_Meta_Box_Coupon_Data {
echo '<option value="' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</option>'; echo '<option value="' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</option>';
} }
} }
?> ?>
</select> <?php echo wc_help_tip( __( 'Product categories that the coupon will not be applied to, or that cannot be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?></p> </select>
<?php echo wc_help_tip( __( 'Product categories that the coupon will not be applied to, or that cannot be in the cart in order for the "Fixed cart discount" to be applied.', 'woocommerce' ) ); ?>
</p>
</div>
<div class="options_group">';
<?php <?php
// Customers.
woocommerce_wp_text_input(
array(
'id' => 'customer_email',
'label' => __( 'Email restrictions', 'woocommerce' ),
'placeholder' => __( 'No restrictions', 'woocommerce' ),
'description' => __( 'List of allowed emails to check against the customer billing email when an order is placed. Separate email addresses with commas.', 'woocommerce' ),
'value' => implode( ', ', (array) $coupon->get_email_restrictions() ),
'desc_tip' => true,
'type' => 'email',
'class' => '',
'custom_attributes' => array(
'multiple' => 'multiple',
),
)
);
?>
</div>
<?php do_action( 'woocommerce_coupon_options_usage_restriction', $coupon->get_id(), $coupon ); ?>
</div>
<div id="usage_limit_coupon_data" class="panel woocommerce_options_panel">
<div class="options_group">
<?php
// Usage limit per coupons.
woocommerce_wp_text_input(
array(
'id' => 'usage_limit',
'label' => __( 'Usage limit per coupon', 'woocommerce' ),
'placeholder' => esc_attr__( 'Unlimited usage', 'woocommerce' ),
'description' => __( 'How many times this coupon can be used before it is void.', 'woocommerce' ),
'type' => 'number',
'desc_tip' => true,
'class' => 'short',
'custom_attributes' => array(
'step' => 1,
'min' => 0,
),
'value' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : '',
)
);
echo '</div><div class="options_group">'; // Usage limit per product.
woocommerce_wp_text_input(
array(
'id' => 'limit_usage_to_x_items',
'label' => __( 'Limit usage to X items', 'woocommerce' ),
'placeholder' => esc_attr__( 'Apply to all qualifying items in cart', 'woocommerce' ),
'description' => __( 'The maximum number of individual items this coupon can apply to when using product discounts. Leave blank to apply to all qualifying items in cart.', 'woocommerce' ),
'desc_tip' => true,
'class' => 'short',
'type' => 'number',
'custom_attributes' => array(
'step' => 1,
'min' => 0,
),
'value' => $coupon->get_limit_usage_to_x_items() ? $coupon->get_limit_usage_to_x_items() : '',
)
);
// Customers // Usage limit per users.
woocommerce_wp_text_input( array( woocommerce_wp_text_input(
'id' => 'customer_email', array(
'label' => __( 'Email restrictions', 'woocommerce' ), 'id' => 'usage_limit_per_user',
'placeholder' => __( 'No restrictions', 'woocommerce' ), 'label' => __( 'Usage limit per user', 'woocommerce' ),
'description' => __( 'List of allowed emails to check against the customer billing email when an order is placed. Separate email addresses with commas.', 'woocommerce' ), 'placeholder' => esc_attr__( 'Unlimited usage', 'woocommerce' ),
'value' => implode( ', ', (array) $coupon->get_email_restrictions() ), 'description' => __( 'How many times this coupon can be used by an individual user. Uses billing email for guests, and user ID for logged in users.', 'woocommerce' ),
'desc_tip' => true, 'desc_tip' => true,
'type' => 'email', 'class' => 'short',
'class' => '', 'type' => 'number',
'custom_attributes' => array( 'custom_attributes' => array(
'multiple' => 'multiple', 'step' => 1,
), 'min' => 0,
) ); ),
'value' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : '',
echo '</div>'; )
);
do_action( 'woocommerce_coupon_options_usage_restriction', $coupon->get_id(), $coupon ); ?>
</div>
?></div> <?php do_action( 'woocommerce_coupon_options_usage_limit', $coupon->get_id(), $coupon ); ?>
<div id="usage_limit_coupon_data" class="panel woocommerce_options_panel"><?php </div>
echo '<div class="options_group">';
// Usage limit per coupons
woocommerce_wp_text_input( array(
'id' => 'usage_limit',
'label' => __( 'Usage limit per coupon', 'woocommerce' ),
'placeholder' => esc_attr__( 'Unlimited usage', 'woocommerce' ),
'description' => __( 'How many times this coupon can be used before it is void.', 'woocommerce' ),
'type' => 'number',
'desc_tip' => true,
'class' => 'short',
'custom_attributes' => array(
'step' => 1,
'min' => 0,
),
'value' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : '',
) );
// Usage limit per product
woocommerce_wp_text_input( array(
'id' => 'limit_usage_to_x_items',
'label' => __( 'Limit usage to X items', 'woocommerce' ),
'placeholder' => esc_attr__( 'Apply to all qualifying items in cart', 'woocommerce' ),
'description' => __( 'The maximum number of individual items this coupon can apply to when using product discounts. Leave blank to apply to all qualifying items in cart.', 'woocommerce' ),
'desc_tip' => true,
'class' => 'short',
'type' => 'number',
'custom_attributes' => array(
'step' => 1,
'min' => 0,
),
'value' => $coupon->get_limit_usage_to_x_items() ? $coupon->get_limit_usage_to_x_items() : '',
) );
// Usage limit per users
woocommerce_wp_text_input( array(
'id' => 'usage_limit_per_user',
'label' => __( 'Usage limit per user', 'woocommerce' ),
'placeholder' => esc_attr__( 'Unlimited usage', 'woocommerce' ),
'description' => __( 'How many times this coupon can be used by an individual user. Uses billing email for guests, and user ID for logged in users.', 'woocommerce' ),
'desc_tip' => true,
'class' => 'short',
'type' => 'number',
'custom_attributes' => array(
'step' => 1,
'min' => 0,
),
'value' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : '',
) );
echo '</div>';
do_action( 'woocommerce_coupon_options_usage_limit', $coupon->get_id(), $coupon );
?></div>
<?php do_action( 'woocommerce_coupon_data_panels', $coupon->get_id(), $coupon ); ?> <?php do_action( 'woocommerce_coupon_data_panels', $coupon->get_id(), $coupon ); ?>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
@ -306,11 +340,11 @@ class WC_Meta_Box_Coupon_Data {
/** /**
* Save meta box data. * Save meta box data.
* *
* @param int $post_id * @param int $post_id
* @param WP_Post $post * @param WP_Post $post
*/ */
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {
// Check for dupe coupons // Check for dupe coupons.
$coupon_code = wc_format_coupon_code( $post->post_title ); $coupon_code = wc_format_coupon_code( $post->post_title );
$id_from_code = wc_get_coupon_id_by_code( $coupon_code, $post_id ); $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $post_id );
@ -322,25 +356,27 @@ class WC_Meta_Box_Coupon_Data {
$exclude_product_categories = isset( $_POST['exclude_product_categories'] ) ? (array) $_POST['exclude_product_categories'] : array(); $exclude_product_categories = isset( $_POST['exclude_product_categories'] ) ? (array) $_POST['exclude_product_categories'] : array();
$coupon = new WC_Coupon( $post_id ); $coupon = new WC_Coupon( $post_id );
$coupon->set_props( array( $coupon->set_props(
'code' => $post->post_title, array(
'discount_type' => wc_clean( $_POST['discount_type'] ), 'code' => $post->post_title,
'amount' => wc_format_decimal( $_POST['coupon_amount'] ), 'discount_type' => wc_clean( $_POST['discount_type'] ),
'date_expires' => wc_clean( $_POST['expiry_date'] ), 'amount' => wc_format_decimal( $_POST['coupon_amount'] ),
'individual_use' => isset( $_POST['individual_use'] ), 'date_expires' => wc_clean( $_POST['expiry_date'] ),
'product_ids' => isset( $_POST['product_ids'] ) ? array_filter( array_map( 'intval', (array) $_POST['product_ids'] ) ) : array(), 'individual_use' => isset( $_POST['individual_use'] ),
'excluded_product_ids' => isset( $_POST['exclude_product_ids'] ) ? array_filter( array_map( 'intval', (array) $_POST['exclude_product_ids'] ) ) : array(), 'product_ids' => isset( $_POST['product_ids'] ) ? array_filter( array_map( 'intval', (array) $_POST['product_ids'] ) ) : array(),
'usage_limit' => absint( $_POST['usage_limit'] ), 'excluded_product_ids' => isset( $_POST['exclude_product_ids'] ) ? array_filter( array_map( 'intval', (array) $_POST['exclude_product_ids'] ) ) : array(),
'usage_limit_per_user' => absint( $_POST['usage_limit_per_user'] ), 'usage_limit' => absint( $_POST['usage_limit'] ),
'limit_usage_to_x_items' => absint( $_POST['limit_usage_to_x_items'] ), 'usage_limit_per_user' => absint( $_POST['usage_limit_per_user'] ),
'free_shipping' => isset( $_POST['free_shipping'] ), 'limit_usage_to_x_items' => absint( $_POST['limit_usage_to_x_items'] ),
'product_categories' => array_filter( array_map( 'intval', $product_categories ) ), 'free_shipping' => isset( $_POST['free_shipping'] ),
'excluded_product_categories' => array_filter( array_map( 'intval', $exclude_product_categories ) ), 'product_categories' => array_filter( array_map( 'intval', $product_categories ) ),
'exclude_sale_items' => isset( $_POST['exclude_sale_items'] ), 'excluded_product_categories' => array_filter( array_map( 'intval', $exclude_product_categories ) ),
'minimum_amount' => wc_format_decimal( $_POST['minimum_amount'] ), 'exclude_sale_items' => isset( $_POST['exclude_sale_items'] ),
'maximum_amount' => wc_format_decimal( $_POST['maximum_amount'] ), 'minimum_amount' => wc_format_decimal( $_POST['minimum_amount'] ),
'email_restrictions' => array_filter( array_map( 'trim', explode( ',', wc_clean( $_POST['customer_email'] ) ) ) ), 'maximum_amount' => wc_format_decimal( $_POST['maximum_amount'] ),
) ); 'email_restrictions' => array_filter( array_map( 'trim', explode( ',', wc_clean( $_POST['customer_email'] ) ) ) ),
)
);
$coupon->save(); $coupon->save();
do_action( 'woocommerce_coupon_options_save', $post_id, $coupon ); do_action( 'woocommerce_coupon_options_save', $post_id, $coupon );
} }

View File

@ -32,11 +32,13 @@ class WC_Meta_Box_Order_Actions {
$theorder = wc_get_order( $post->ID ); $theorder = wc_get_order( $post->ID );
} }
$order_actions = apply_filters( 'woocommerce_order_actions', array( $order_actions = apply_filters(
'send_order_details' => __( 'Email invoice / order details to customer', 'woocommerce' ), 'woocommerce_order_actions', array(
'send_order_details_admin' => __( 'Resend new order notification', 'woocommerce' ), 'send_order_details' => __( 'Email invoice / order details to customer', 'woocommerce' ),
'regenerate_download_permissions' => __( 'Regenerate download permissions', 'woocommerce' ), 'send_order_details_admin' => __( 'Resend new order notification', 'woocommerce' ),
) ); 'regenerate_download_permissions' => __( 'Regenerate download permissions', 'woocommerce' ),
)
);
?> ?>
<ul class="order_actions submitbox"> <ul class="order_actions submitbox">
@ -62,7 +64,9 @@ class WC_Meta_Box_Order_Actions {
} else { } else {
$delete_text = __( 'Move to trash', 'woocommerce' ); $delete_text = __( 'Move to trash', 'woocommerce' );
} }
?><a class="submitdelete deletion" href="<?php echo esc_url( get_delete_post_link( $post->ID ) ); ?>"><?php echo esc_html( $delete_text ); ?></a><?php ?>
<a class="submitdelete deletion" href="<?php echo esc_url( get_delete_post_link( $post->ID ) ); ?>"><?php echo esc_html( $delete_text ); ?></a>
<?php
} }
?> ?>
</div> </div>

View File

@ -4,9 +4,9 @@
* *
* Functions for displaying the order data meta box. * Functions for displaying the order data meta box.
* *
* @author WooThemes * @author WooThemes
* @category Admin * @category Admin
* @package WooCommerce/Admin/Meta Boxes * @package WooCommerce/Admin/Meta Boxes
* @version 2.2.0 * @version 2.2.0
*/ */
@ -38,97 +38,101 @@ class WC_Meta_Box_Order_Data {
*/ */
public static function init_address_fields() { public static function init_address_fields() {
self::$billing_fields = apply_filters( 'woocommerce_admin_billing_fields', array( self::$billing_fields = apply_filters(
'first_name' => array( 'woocommerce_admin_billing_fields', array(
'label' => __( 'First name', 'woocommerce' ), 'first_name' => array(
'show' => false, 'label' => __( 'First name', 'woocommerce' ),
), 'show' => false,
'last_name' => array( ),
'label' => __( 'Last name', 'woocommerce' ), 'last_name' => array(
'show' => false, 'label' => __( 'Last name', 'woocommerce' ),
), 'show' => false,
'company' => array( ),
'label' => __( 'Company', 'woocommerce' ), 'company' => array(
'show' => false, 'label' => __( 'Company', 'woocommerce' ),
), 'show' => false,
'address_1' => array( ),
'label' => __( 'Address line 1', 'woocommerce' ), 'address_1' => array(
'show' => false, 'label' => __( 'Address line 1', 'woocommerce' ),
), 'show' => false,
'address_2' => array( ),
'label' => __( 'Address line 2', 'woocommerce' ), 'address_2' => array(
'show' => false, 'label' => __( 'Address line 2', 'woocommerce' ),
), 'show' => false,
'city' => array( ),
'label' => __( 'City', 'woocommerce' ), 'city' => array(
'show' => false, 'label' => __( 'City', 'woocommerce' ),
), 'show' => false,
'postcode' => array( ),
'label' => __( 'Postcode / ZIP', 'woocommerce' ), 'postcode' => array(
'show' => false, 'label' => __( 'Postcode / ZIP', 'woocommerce' ),
), 'show' => false,
'country' => array( ),
'label' => __( 'Country', 'woocommerce' ), 'country' => array(
'show' => false, 'label' => __( 'Country', 'woocommerce' ),
'class' => 'js_field-country select short', 'show' => false,
'type' => 'select', 'class' => 'js_field-country select short',
'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(), 'type' => 'select',
), 'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
'state' => array( ),
'label' => __( 'State / County', 'woocommerce' ), 'state' => array(
'class' => 'js_field-state select short', 'label' => __( 'State / County', 'woocommerce' ),
'show' => false, 'class' => 'js_field-state select short',
), 'show' => false,
'email' => array( ),
'label' => __( 'Email address', 'woocommerce' ), 'email' => array(
), 'label' => __( 'Email address', 'woocommerce' ),
'phone' => array( ),
'label' => __( 'Phone', 'woocommerce' ), 'phone' => array(
), 'label' => __( 'Phone', 'woocommerce' ),
) ); ),
)
);
self::$shipping_fields = apply_filters( 'woocommerce_admin_shipping_fields', array( self::$shipping_fields = apply_filters(
'first_name' => array( 'woocommerce_admin_shipping_fields', array(
'label' => __( 'First name', 'woocommerce' ), 'first_name' => array(
'show' => false, 'label' => __( 'First name', 'woocommerce' ),
), 'show' => false,
'last_name' => array( ),
'label' => __( 'Last name', 'woocommerce' ), 'last_name' => array(
'show' => false, 'label' => __( 'Last name', 'woocommerce' ),
), 'show' => false,
'company' => array( ),
'label' => __( 'Company', 'woocommerce' ), 'company' => array(
'show' => false, 'label' => __( 'Company', 'woocommerce' ),
), 'show' => false,
'address_1' => array( ),
'label' => __( 'Address line 1', 'woocommerce' ), 'address_1' => array(
'show' => false, 'label' => __( 'Address line 1', 'woocommerce' ),
), 'show' => false,
'address_2' => array( ),
'label' => __( 'Address line 2', 'woocommerce' ), 'address_2' => array(
'show' => false, 'label' => __( 'Address line 2', 'woocommerce' ),
), 'show' => false,
'city' => array( ),
'label' => __( 'City', 'woocommerce' ), 'city' => array(
'show' => false, 'label' => __( 'City', 'woocommerce' ),
), 'show' => false,
'postcode' => array( ),
'label' => __( 'Postcode / ZIP', 'woocommerce' ), 'postcode' => array(
'show' => false, 'label' => __( 'Postcode / ZIP', 'woocommerce' ),
), 'show' => false,
'country' => array( ),
'label' => __( 'Country', 'woocommerce' ), 'country' => array(
'show' => false, 'label' => __( 'Country', 'woocommerce' ),
'type' => 'select', 'show' => false,
'class' => 'js_field-country select short', 'type' => 'select',
'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(), 'class' => 'js_field-country select short',
), 'options' => array( '' => __( 'Select a country&hellip;', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
'state' => array( ),
'label' => __( 'State / County', 'woocommerce' ), 'state' => array(
'class' => 'js_field-state select short', 'label' => __( 'State / County', 'woocommerce' ),
'show' => false, 'class' => 'js_field-state select short',
), 'show' => false,
) ); ),
)
);
} }
/** /**
@ -165,113 +169,128 @@ class WC_Meta_Box_Order_Data {
<input name="post_title" type="hidden" value="<?php echo empty( $post->post_title ) ? __( 'Order', 'woocommerce' ) : esc_attr( $post->post_title ); ?>" /> <input name="post_title" type="hidden" value="<?php echo empty( $post->post_title ) ? __( 'Order', 'woocommerce' ) : esc_attr( $post->post_title ); ?>" />
<input name="post_status" type="hidden" value="<?php echo esc_attr( $post->post_status ); ?>" /> <input name="post_status" type="hidden" value="<?php echo esc_attr( $post->post_status ); ?>" />
<div id="order_data" class="panel woocommerce-order-data"> <div id="order_data" class="panel woocommerce-order-data">
<h2 class="woocommerce-order-data__heading"><?php <h2 class="woocommerce-order-data__heading">
<?php
/* translators: 1: order type 2: order number */ /* translators: 1: order type 2: order number */
printf( printf(
esc_html__( '%1$s #%2$s details', 'woocommerce' ), esc_html__( '%1$s #%2$s details', 'woocommerce' ),
esc_html( $order_type_object->labels->singular_name ), esc_html( $order_type_object->labels->singular_name ),
esc_html( $order->get_order_number() ) esc_html( $order->get_order_number() )
);
?></h2>
<p class="woocommerce-order-data__meta order_number"><?php
$meta_list = array();
if ( $payment_method ) {
/* translators: %s: payment method */
$payment_method_string = sprintf(
__( 'Payment via %s', 'woocommerce' ),
esc_html( isset( $payment_gateways[ $payment_method ] ) ? $payment_gateways[ $payment_method ]->get_title() : $payment_method )
); );
if ( $transaction_id = $order->get_transaction_id() ) { ?>
if ( isset( $payment_gateways[ $payment_method ] ) && ( $url = $payment_gateways[ $payment_method ]->get_transaction_url( $order ) ) ) { </h2>
$payment_method_string .= ' (<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $transaction_id ) . '</a>)'; <p class="woocommerce-order-data__meta order_number">
} else { <?php
$payment_method_string .= ' (' . esc_html( $transaction_id ) . ')';
$meta_list = array();
if ( $payment_method ) {
/* translators: %s: payment method */
$payment_method_string = sprintf(
__( 'Payment via %s', 'woocommerce' ),
esc_html( isset( $payment_gateways[ $payment_method ] ) ? $payment_gateways[ $payment_method ]->get_title() : $payment_method )
);
if ( $transaction_id = $order->get_transaction_id() ) {
if ( isset( $payment_gateways[ $payment_method ] ) && ( $url = $payment_gateways[ $payment_method ]->get_transaction_url( $order ) ) ) {
$payment_method_string .= ' (<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $transaction_id ) . '</a>)';
} else {
$payment_method_string .= ' (' . esc_html( $transaction_id ) . ')';
}
} }
$meta_list[] = $payment_method_string;
} }
$meta_list[] = $payment_method_string; if ( $order->get_date_paid() ) {
} /* translators: 1: date 2: time */
$meta_list[] = sprintf(
__( 'Paid on %1$s @ %2$s', 'woocommerce' ),
wc_format_datetime( $order->get_date_paid() ),
wc_format_datetime( $order->get_date_paid(), get_option( 'time_format' ) )
);
}
if ( $order->get_date_paid() ) { if ( $ip_address = $order->get_customer_ip_address() ) {
/* translators: 1: date 2: time */ /* translators: %s: IP address */
$meta_list[] = sprintf( $meta_list[] = sprintf(
__( 'Paid on %1$s @ %2$s', 'woocommerce' ), __( 'Customer IP: %s', 'woocommerce' ),
wc_format_datetime( $order->get_date_paid() ), '<span class="woocommerce-Order-customerIP">' . esc_html( $ip_address ) . '</span>'
wc_format_datetime( $order->get_date_paid(), get_option( 'time_format' ) ) );
); }
}
if ( $ip_address = $order->get_customer_ip_address() ) { echo wp_kses_post( implode( '. ', $meta_list ) );
/* translators: %s: IP address */
$meta_list[] = sprintf(
__( 'Customer IP: %s', 'woocommerce' ),
'<span class="woocommerce-Order-customerIP">' . esc_html( $ip_address ) . '</span>'
);
}
echo wp_kses_post( implode( '. ', $meta_list ) ); ?>
</p>
?></p>
<div class="order_data_column_container"> <div class="order_data_column_container">
<div class="order_data_column"> <div class="order_data_column">
<h3><?php esc_html_e( 'General', 'woocommerce' ); ?></h3> <h3><?php esc_html_e( 'General', 'woocommerce' ); ?></h3>
<p class="form-field form-field-wide"><label for="order_date"><?php _e( 'Date created:', 'woocommerce' ) ?></label> <p class="form-field form-field-wide">
<label for="order_date"><?php _e( 'Date created:', 'woocommerce' ); ?></label>
<input type="text" class="date-picker" name="order_date" maxlength="10" value="<?php echo esc_attr( date_i18n( 'Y-m-d', strtotime( $post->post_date ) ) ); ?>" pattern="<?php echo esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ); ?>" />@ <input type="text" class="date-picker" name="order_date" maxlength="10" value="<?php echo esc_attr( date_i18n( 'Y-m-d', strtotime( $post->post_date ) ) ); ?>" pattern="<?php echo esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ); ?>" />@
&lrm; &lrm;
<input type="number" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ) ?>" name="order_date_hour" min="0" max="23" step="1" value="<?php echo esc_attr( date_i18n( 'H', strtotime( $post->post_date ) ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />: <input type="number" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ); ?>" name="order_date_hour" min="0" max="23" step="1" value="<?php echo esc_attr( date_i18n( 'H', strtotime( $post->post_date ) ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:
<input type="number" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ) ?>" name="order_date_minute" min="0" max="59" step="1" value="<?php echo esc_attr( date_i18n( 'i', strtotime( $post->post_date ) ) ); ?>" pattern="[0-5]{1}[0-9]{1}" /> <input type="number" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ); ?>" name="order_date_minute" min="0" max="59" step="1" value="<?php echo esc_attr( date_i18n( 'i', strtotime( $post->post_date ) ) ); ?>" pattern="[0-5]{1}[0-9]{1}" />
<input type="hidden" name="order_date_second" value="<?php echo esc_attr( date_i18n( 's', strtotime( $post->post_date ) ) ); ?>" /> <input type="hidden" name="order_date_second" value="<?php echo esc_attr( date_i18n( 's', strtotime( $post->post_date ) ) ); ?>" />
&lrm;
</p> </p>
<p class="form-field form-field-wide wc-order-status"><label for="order_status"><?php _e( 'Status:', 'woocommerce' ) ?> <?php <p class="form-field form-field-wide wc-order-status">
if ( $order->needs_payment() ) { <label for="order_status">
printf( '<a href="%s">%s</a>', <?php
esc_url( $order->get_checkout_payment_url() ), _e( 'Status:', 'woocommerce' );
__( 'Customer payment page &rarr;', 'woocommerce' ) if ( $order->needs_payment() ) {
); printf(
} '<a href="%s">%s</a>',
?></label> esc_url( $order->get_checkout_payment_url() ),
<select id="order_status" name="order_status" class="wc-enhanced-select"> __( 'Customer payment page &rarr;', 'woocommerce' )
<?php );
}
?>
</label>
<select id="order_status" name="order_status" class="wc-enhanced-select">
<?php
$statuses = wc_get_order_statuses(); $statuses = wc_get_order_statuses();
foreach ( $statuses as $status => $status_name ) { foreach ( $statuses as $status => $status_name ) {
echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status( 'edit' ), false ) . '>' . esc_html( $status_name ) . '</option>'; echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status( 'edit' ), false ) . '>' . esc_html( $status_name ) . '</option>';
} }
?> ?>
</select></p> </select>
</p>
<p class="form-field form-field-wide wc-customer-user"> <p class="form-field form-field-wide wc-customer-user">
<!--email_off--> <!-- Disable CloudFlare email obfuscation --> <!--email_off--> <!-- Disable CloudFlare email obfuscation -->
<label for="customer_user"><?php _e( 'Customer:', 'woocommerce' ) ?> <?php <label for="customer_user">
<?php
_e( 'Customer:', 'woocommerce' );
if ( $order->get_user_id( 'edit' ) ) { if ( $order->get_user_id( 'edit' ) ) {
$args = array( $args = array(
'post_status' => 'all', 'post_status' => 'all',
'post_type' => 'shop_order', 'post_type' => 'shop_order',
'_customer_user' => $order->get_user_id( 'edit' ), '_customer_user' => $order->get_user_id( 'edit' ),
); );
printf( '<a href="%s">%s</a>', printf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ), esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
' ' . __( 'View other orders &rarr;', 'woocommerce' ) ' ' . __( 'View other orders &rarr;', 'woocommerce' )
); );
printf( '<a href="%s">%s</a>', printf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( 'user_id', $order->get_user_id( 'edit' ), admin_url( 'user-edit.php' ) ) ), esc_url( add_query_arg( 'user_id', $order->get_user_id( 'edit' ), admin_url( 'user-edit.php' ) ) ),
' ' . __( 'Profile &rarr;', 'woocommerce' ) ' ' . __( 'Profile &rarr;', 'woocommerce' )
); );
} }
?></label> ?>
</label>
<?php <?php
$user_string = ''; $user_string = '';
$user_id = ''; $user_id = '';
if ( $order->get_user_id() ) { if ( $order->get_user_id() ) {
$user_id = absint( $order->get_user_id() ); $user_id = absint( $order->get_user_id() );
$user = get_user_by( 'id', $user_id ); $user = get_user_by( 'id', $user_id );
/* translators: 1: user display name 2: user ID 3: user email */ /* translators: 1: user display name 2: user ID 3: user email */
$user_string = sprintf( $user_string = sprintf(
esc_html__( '%1$s (#%2$s &ndash; %3$s)', 'woocommerce' ), esc_html__( '%1$s (#%2$s &ndash; %3$s)', 'woocommerce' ),
@ -296,43 +315,44 @@ class WC_Meta_Box_Order_Data {
<a href="#" class="load_customer_billing" style="display:none;"><?php esc_html_e( 'Load billing address', 'woocommerce' ); ?></a> <a href="#" class="load_customer_billing" style="display:none;"><?php esc_html_e( 'Load billing address', 'woocommerce' ); ?></a>
</span> </span>
</h3> </h3>
<?php <div class="address">
// Display values <?php
echo '<div class="address">';
if ( $order->get_formatted_billing_address() ) { // Display values.
echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>'; if ( $order->get_formatted_billing_address() ) {
echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>';
} else {
echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>';
}
foreach ( self::$billing_fields as $key => $field ) {
if ( isset( $field['show'] ) && false === $field['show'] ) {
continue;
}
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else { } else {
echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>'; $field_value = $order->get_meta( '_' . $field_name );
} }
foreach ( self::$billing_fields as $key => $field ) { if ( 'billing_phone' === $field_name ) {
if ( isset( $field['show'] ) && false === $field['show'] ) { $field_value = wc_make_phone_clickable( $field_value );
continue; } else {
} $field_value = make_clickable( esc_html( $field_value ) );
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
}
if ( 'billing_phone' === $field_name ) {
$field_value = wc_make_phone_clickable( $field_value );
} else {
$field_value = make_clickable( esc_html( $field_value ) );
}
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
} }
echo '</div>'; echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
}
?>
</div>
// Display form <div class="edit_address">
echo '<div class="edit_address">'; <?php
// Display form.
foreach ( self::$billing_fields as $key => $field ) { foreach ( self::$billing_fields as $key => $field ) {
if ( ! isset( $field['type'] ) ) { if ( ! isset( $field['type'] ) ) {
$field['type'] = 'text'; $field['type'] = 'text';
@ -341,12 +361,12 @@ class WC_Meta_Box_Order_Data {
$field['id'] = '_billing_' . $key; $field['id'] = '_billing_' . $key;
} }
switch ( $field['type'] ) { switch ( $field['type'] ) {
case 'select' : case 'select':
woocommerce_wp_select( $field ); woocommerce_wp_select( $field );
break; break;
default : default:
woocommerce_wp_text_input( $field ); woocommerce_wp_text_input( $field );
break; break;
} }
} }
?> ?>
@ -355,36 +375,39 @@ class WC_Meta_Box_Order_Data {
<select name="_payment_method" id="_payment_method" class="first"> <select name="_payment_method" id="_payment_method" class="first">
<option value=""><?php esc_html_e( 'N/A', 'woocommerce' ); ?></option> <option value=""><?php esc_html_e( 'N/A', 'woocommerce' ); ?></option>
<?php <?php
$found_method = false; $found_method = false;
foreach ( $payment_gateways as $gateway ) { foreach ( $payment_gateways as $gateway ) {
if ( 'yes' === $gateway->enabled ) { if ( 'yes' === $gateway->enabled ) {
echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>'; echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>';
if ( $payment_method == $gateway->id ) { if ( $payment_method == $gateway->id ) {
$found_method = true; $found_method = true;
}
} }
} }
}
if ( ! $found_method && ! empty( $payment_method ) ) { if ( ! $found_method && ! empty( $payment_method ) ) {
echo '<option value="' . esc_attr( $payment_method ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>'; echo '<option value="' . esc_attr( $payment_method ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>';
} else { } else {
echo '<option value="other">' . __( 'Other', 'woocommerce' ) . '</option>'; echo '<option value="other">' . __( 'Other', 'woocommerce' ) . '</option>';
} }
?> ?>
</select> </select>
</p> </p>
<?php <?php
woocommerce_wp_text_input( array( 'id' => '_transaction_id', 'label' => __( 'Transaction ID', 'woocommerce' ) ) ); woocommerce_wp_text_input(
array(
'id' => '_transaction_id',
'label' => __( 'Transaction ID', 'woocommerce' ),
)
);
?>
echo '</div>'; </div>
<?php do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?>
do_action( 'woocommerce_admin_order_data_after_billing_address', $order );
?>
</div> </div>
<div class="order_data_column"> <div class="order_data_column">
<h3> <h3>
<?php esc_html_e( 'Shipping', 'woocommerce' ); ?> <?php esc_html_e( 'Shipping', 'woocommerce' ); ?>
<a href="#" class="edit_address"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a> <a href="#" class="edit_address"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a>
@ -393,43 +416,43 @@ class WC_Meta_Box_Order_Data {
<a href="#" class="billing-same-as-shipping" style="display:none;"><?php esc_html_e( 'Copy billing address', 'woocommerce' ); ?></a> <a href="#" class="billing-same-as-shipping" style="display:none;"><?php esc_html_e( 'Copy billing address', 'woocommerce' ); ?></a>
</span> </span>
</h3> </h3>
<?php <div class="address">
// Display values <?php
echo '<div class="address">';
if ( $order->get_formatted_shipping_address() ) { // Display values.
echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>'; if ( $order->get_formatted_shipping_address() ) {
} else { echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>';
echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>'; } else {
} echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
}
if ( ! empty( self::$shipping_fields ) ) { if ( ! empty( self::$shipping_fields ) ) {
foreach ( self::$shipping_fields as $key => $field ) { foreach ( self::$shipping_fields as $key => $field ) {
if ( isset( $field['show'] ) && false === $field['show'] ) { if ( isset( $field['show'] ) && false === $field['show'] ) {
continue; continue;
}
$field_name = 'shipping_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
}
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( $field_value ) ) . '</p>';
} }
$field_name = 'shipping_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
}
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( $field_value ) ) . '</p>';
} }
}
if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) { if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) {
echo '<p><strong>' . __( 'Customer provided note:', 'woocommerce' ) . '</strong> ' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>'; echo '<p><strong>' . __( 'Customer provided note:', 'woocommerce' ) . '</strong> ' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>';
} }
?>
echo '</div>'; </div>
<div class="edit_address">
// Display form <?php
echo '<div class="edit_address">';
// Display form.
if ( ! empty( self::$shipping_fields ) ) { if ( ! empty( self::$shipping_fields ) ) {
foreach ( self::$shipping_fields as $key => $field ) { foreach ( self::$shipping_fields as $key => $field ) {
if ( ! isset( $field['type'] ) ) { if ( ! isset( $field['type'] ) ) {
@ -440,27 +463,26 @@ class WC_Meta_Box_Order_Data {
} }
switch ( $field['type'] ) { switch ( $field['type'] ) {
case 'select' : case 'select':
woocommerce_wp_select( $field ); woocommerce_wp_select( $field );
break; break;
default : default:
woocommerce_wp_text_input( $field ); woocommerce_wp_text_input( $field );
break; break;
} }
} }
} }
if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) { if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) :
?> ?>
<p class="form-field form-field-wide"><label for="excerpt"><?php _e( 'Customer provided note', 'woocommerce' ) ?>:</label> <p class="form-field form-field-wide">
<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>"><?php echo wp_kses_post( $post->post_excerpt ); ?></textarea></p> <label for="excerpt"><?php _e( 'Customer provided note', 'woocommerce' ); ?>:</label>
<?php <textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>"><?php echo wp_kses_post( $post->post_excerpt ); ?></textarea>
} </p>
<?php endif; ?>
</div>
echo '</div>'; <?php do_action( 'woocommerce_admin_order_data_after_shipping_address', $order ); ?>
do_action( 'woocommerce_admin_order_data_after_shipping_address', $order );
?>
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
@ -548,7 +570,7 @@ class WC_Meta_Box_Order_Data {
$payment_method_title = $methods[ $payment_method ]->get_title(); $payment_method_title = $methods[ $payment_method ]->get_title();
} }
$props['payment_method'] = $payment_method; $props['payment_method'] = $payment_method;
$props['payment_method_title'] = $payment_method_title; $props['payment_method_title'] = $payment_method_title;
} }

View File

@ -26,12 +26,15 @@ class WC_Meta_Box_Order_Downloads {
?> ?>
<div class="order_download_permissions wc-metaboxes-wrapper"> <div class="order_download_permissions wc-metaboxes-wrapper">
<div class="wc-metaboxes"><?php <div class="wc-metaboxes">
$data_store = WC_Data_Store::load( 'customer-download' ); <?php
$download_permissions = $data_store->get_downloads( array( $data_store = WC_Data_Store::load( 'customer-download' );
'order_id' => $post->ID, $download_permissions = $data_store->get_downloads(
'orderby' => 'product_id', array(
) ); 'order_id' => $post->ID,
'orderby' => 'product_id',
)
);
$product = null; $product = null;
$loop = 0; $loop = 0;
@ -44,27 +47,30 @@ class WC_Meta_Box_Order_Downloads {
$file_counter = 1; $file_counter = 1;
} }
// don't show permissions to files that have since been removed // don't show permissions to files that have since been removed.
if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) { if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) {
continue; continue;
} }
// Show file title instead of count if set // Show file title instead of count if set.
$file = $product->get_file( $download->get_download_id() ); $file = $product->get_file( $download->get_download_id() );
$file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter ); $file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter );
include( 'views/html-order-download-permission.php' ); include 'views/html-order-download-permission.php';
$loop++; $loop++;
$file_counter++; $file_counter++;
} }
} }
?></div> ?>
</div>
<div class="toolbar"> <div class="toolbar">
<p class="buttons"> <p class="buttons">
<select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select> <select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select>
<button type="button" class="button grant_access"><?php _e( 'Grant access', 'woocommerce' ); ?></button> <button type="button" class="button grant_access">
<?php _e( 'Grant access', 'woocommerce' ); ?>
</button>
</p> </p>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
@ -76,7 +82,7 @@ class WC_Meta_Box_Order_Downloads {
/** /**
* Save meta box data. * Save meta box data.
* *
* @param int $post_id * @param int $post_id
* @param WP_Post $post * @param WP_Post $post
*/ */
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {

View File

@ -38,7 +38,7 @@ class WC_Meta_Box_Order_Items {
$order = $theorder; $order = $theorder;
$data = get_post_meta( $post->ID ); $data = get_post_meta( $post->ID );
include( 'views/html-order-items.php' ); include 'views/html-order-items.php';
} }
/** /**

View File

@ -28,11 +28,11 @@ class WC_Meta_Box_Product_Data {
global $thepostid, $product_object; global $thepostid, $product_object;
$thepostid = $post->ID; $thepostid = $post->ID;
$product_object = $thepostid ? wc_get_product( $thepostid ) : new WC_Product; $product_object = $thepostid ? wc_get_product( $thepostid ) : new WC_Product();
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
include( 'views/html-product-data-panel.php' ); include 'views/html-product-data-panel.php';
} }
/** /**
@ -41,86 +41,92 @@ class WC_Meta_Box_Product_Data {
private static function output_tabs() { private static function output_tabs() {
global $post, $thepostid, $product_object; global $post, $thepostid, $product_object;
include( 'views/html-product-data-general.php' ); include 'views/html-product-data-general.php';
include( 'views/html-product-data-inventory.php' ); include 'views/html-product-data-inventory.php';
include( 'views/html-product-data-shipping.php' ); include 'views/html-product-data-shipping.php';
include( 'views/html-product-data-linked-products.php' ); include 'views/html-product-data-linked-products.php';
include( 'views/html-product-data-attributes.php' ); include 'views/html-product-data-attributes.php';
include( 'views/html-product-data-advanced.php' ); include 'views/html-product-data-advanced.php';
} }
/** /**
* Return array of product type options. * Return array of product type options.
*
* @return array * @return array
*/ */
private static function get_product_type_options() { private static function get_product_type_options() {
return apply_filters( 'product_type_options', array( return apply_filters(
'virtual' => array( 'product_type_options', array(
'id' => '_virtual', 'virtual' => array(
'wrapper_class' => 'show_if_simple', 'id' => '_virtual',
'label' => __( 'Virtual', 'woocommerce' ), 'wrapper_class' => 'show_if_simple',
'description' => __( 'Virtual products are intangible and are not shipped.', 'woocommerce' ), 'label' => __( 'Virtual', 'woocommerce' ),
'default' => 'no', 'description' => __( 'Virtual products are intangible and are not shipped.', 'woocommerce' ),
), 'default' => 'no',
'downloadable' => array( ),
'id' => '_downloadable', 'downloadable' => array(
'wrapper_class' => 'show_if_simple', 'id' => '_downloadable',
'label' => __( 'Downloadable', 'woocommerce' ), 'wrapper_class' => 'show_if_simple',
'description' => __( 'Downloadable products give access to a file upon purchase.', 'woocommerce' ), 'label' => __( 'Downloadable', 'woocommerce' ),
'default' => 'no', 'description' => __( 'Downloadable products give access to a file upon purchase.', 'woocommerce' ),
), 'default' => 'no',
) ); ),
)
);
} }
/** /**
* Return array of tabs to show. * Return array of tabs to show.
*
* @return array * @return array
*/ */
private static function get_product_data_tabs() { private static function get_product_data_tabs() {
$tabs = apply_filters( 'woocommerce_product_data_tabs', array( $tabs = apply_filters(
'general' => array( 'woocommerce_product_data_tabs', array(
'label' => __( 'General', 'woocommerce' ), 'general' => array(
'target' => 'general_product_data', 'label' => __( 'General', 'woocommerce' ),
'class' => array( 'hide_if_grouped' ), 'target' => 'general_product_data',
'priority' => 10, 'class' => array( 'hide_if_grouped' ),
), 'priority' => 10,
'inventory' => array( ),
'label' => __( 'Inventory', 'woocommerce' ), 'inventory' => array(
'target' => 'inventory_product_data', 'label' => __( 'Inventory', 'woocommerce' ),
'class' => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external' ), 'target' => 'inventory_product_data',
'priority' => 20, 'class' => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external' ),
), 'priority' => 20,
'shipping' => array( ),
'label' => __( 'Shipping', 'woocommerce' ), 'shipping' => array(
'target' => 'shipping_product_data', 'label' => __( 'Shipping', 'woocommerce' ),
'class' => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ), 'target' => 'shipping_product_data',
'priority' => 30, 'class' => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
), 'priority' => 30,
'linked_product' => array( ),
'label' => __( 'Linked Products', 'woocommerce' ), 'linked_product' => array(
'target' => 'linked_product_data', 'label' => __( 'Linked Products', 'woocommerce' ),
'class' => array(), 'target' => 'linked_product_data',
'priority' => 40, 'class' => array(),
), 'priority' => 40,
'attribute' => array( ),
'label' => __( 'Attributes', 'woocommerce' ), 'attribute' => array(
'target' => 'product_attributes', 'label' => __( 'Attributes', 'woocommerce' ),
'class' => array(), 'target' => 'product_attributes',
'priority' => 50, 'class' => array(),
), 'priority' => 50,
'variations' => array( ),
'label' => __( 'Variations', 'woocommerce' ), 'variations' => array(
'target' => 'variable_product_options', 'label' => __( 'Variations', 'woocommerce' ),
'class' => array( 'variations_tab', 'show_if_variable' ), 'target' => 'variable_product_options',
'priority' => 60, 'class' => array( 'variations_tab', 'show_if_variable' ),
), 'priority' => 60,
'advanced' => array( ),
'label' => __( 'Advanced', 'woocommerce' ), 'advanced' => array(
'target' => 'advanced_product_data', 'label' => __( 'Advanced', 'woocommerce' ),
'class' => array(), 'target' => 'advanced_product_data',
'priority' => 70, 'class' => array(),
), 'priority' => 70,
) ); ),
)
);
// Sort tabs based on priority. // Sort tabs based on priority.
uasort( $tabs, array( __CLASS__, 'product_data_tabs_sort' ) ); uasort( $tabs, array( __CLASS__, 'product_data_tabs_sort' ) );
@ -151,6 +157,7 @@ class WC_Meta_Box_Product_Data {
/** /**
* Filter callback for finding variation attributes. * Filter callback for finding variation attributes.
*
* @param WC_Product_Attribute $attribute * @param WC_Product_Attribute $attribute
* @return bool * @return bool
*/ */
@ -170,7 +177,7 @@ class WC_Meta_Box_Product_Data {
$variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ); $variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) );
$variations_total_pages = ceil( $variations_count / $variations_per_page ); $variations_total_pages = ceil( $variations_count / $variations_per_page );
include( 'views/html-product-data-variations.php' ); include 'views/html-product-data-variations.php';
} }
/** /**
@ -191,9 +198,9 @@ class WC_Meta_Box_Product_Data {
for ( $i = 0; $i < $file_url_size; $i ++ ) { for ( $i = 0; $i < $file_url_size; $i ++ ) {
if ( ! empty( $file_urls[ $i ] ) ) { if ( ! empty( $file_urls[ $i ] ) ) {
$downloads[] = array( $downloads[] = array(
'name' => wc_clean( $file_names[ $i ] ), 'name' => wc_clean( $file_names[ $i ] ),
'file' => wp_unslash( trim( $file_urls[ $i ] ) ), 'file' => wp_unslash( trim( $file_urls[ $i ] ) ),
'download_id' => wc_clean( $file_hashes[ $i ] ), 'download_id' => wc_clean( $file_hashes[ $i ] ),
); );
} }
} }
@ -203,6 +210,7 @@ class WC_Meta_Box_Product_Data {
/** /**
* Prepare children for save. * Prepare children for save.
*
* @return array * @return array
*/ */
private static function prepare_children() { private static function prepare_children() {
@ -272,9 +280,10 @@ class WC_Meta_Box_Product_Data {
/** /**
* Prepare attributes for a specific variation or defaults. * Prepare attributes for a specific variation or defaults.
* @param array $all_attributes *
* @param array $all_attributes
* @param string $key_prefix * @param string $key_prefix
* @param int $index * @param int $index
* @return array * @return array
*/ */
private static function prepare_set_attributes( $all_attributes, $key_prefix = 'attribute_', $index = null ) { private static function prepare_set_attributes( $all_attributes, $key_prefix = 'attribute_', $index = null ) {
@ -309,7 +318,7 @@ class WC_Meta_Box_Product_Data {
/** /**
* Save meta box data. * Save meta box data.
* *
* @param int $post_id * @param int $post_id
* @param $post * @param $post
*/ */
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {
@ -330,45 +339,47 @@ class WC_Meta_Box_Product_Data {
} }
} }
$errors = $product->set_props( array( $errors = $product->set_props(
'sku' => isset( $_POST['_sku'] ) ? wc_clean( $_POST['_sku'] ) : null, array(
'purchase_note' => wp_kses_post( stripslashes( $_POST['_purchase_note'] ) ), 'sku' => isset( $_POST['_sku'] ) ? wc_clean( $_POST['_sku'] ) : null,
'downloadable' => isset( $_POST['_downloadable'] ), 'purchase_note' => wp_kses_post( stripslashes( $_POST['_purchase_note'] ) ),
'virtual' => isset( $_POST['_virtual'] ), 'downloadable' => isset( $_POST['_downloadable'] ),
'featured' => isset( $_POST['_featured'] ), 'virtual' => isset( $_POST['_virtual'] ),
'catalog_visibility' => wc_clean( $_POST['_visibility'] ), 'featured' => isset( $_POST['_featured'] ),
'tax_status' => isset( $_POST['_tax_status'] ) ? wc_clean( $_POST['_tax_status'] ) : null, 'catalog_visibility' => wc_clean( $_POST['_visibility'] ),
'tax_class' => isset( $_POST['_tax_class'] ) ? wc_clean( $_POST['_tax_class'] ) : null, 'tax_status' => isset( $_POST['_tax_status'] ) ? wc_clean( $_POST['_tax_status'] ) : null,
'weight' => wc_clean( $_POST['_weight'] ), 'tax_class' => isset( $_POST['_tax_class'] ) ? wc_clean( $_POST['_tax_class'] ) : null,
'length' => wc_clean( $_POST['_length'] ), 'weight' => wc_clean( $_POST['_weight'] ),
'width' => wc_clean( $_POST['_width'] ), 'length' => wc_clean( $_POST['_length'] ),
'height' => wc_clean( $_POST['_height'] ), 'width' => wc_clean( $_POST['_width'] ),
'shipping_class_id' => absint( $_POST['product_shipping_class'] ), 'height' => wc_clean( $_POST['_height'] ),
'sold_individually' => ! empty( $_POST['_sold_individually'] ), 'shipping_class_id' => absint( $_POST['product_shipping_class'] ),
'upsell_ids' => isset( $_POST['upsell_ids'] ) ? array_map( 'intval', (array) $_POST['upsell_ids'] ) : array(), 'sold_individually' => ! empty( $_POST['_sold_individually'] ),
'cross_sell_ids' => isset( $_POST['crosssell_ids'] ) ? array_map( 'intval', (array) $_POST['crosssell_ids'] ) : array(), 'upsell_ids' => isset( $_POST['upsell_ids'] ) ? array_map( 'intval', (array) $_POST['upsell_ids'] ) : array(),
'regular_price' => wc_clean( $_POST['_regular_price'] ), 'cross_sell_ids' => isset( $_POST['crosssell_ids'] ) ? array_map( 'intval', (array) $_POST['crosssell_ids'] ) : array(),
'sale_price' => wc_clean( $_POST['_sale_price'] ), 'regular_price' => wc_clean( $_POST['_regular_price'] ),
'date_on_sale_from' => wc_clean( $_POST['_sale_price_dates_from'] ), 'sale_price' => wc_clean( $_POST['_sale_price'] ),
'date_on_sale_to' => wc_clean( $_POST['_sale_price_dates_to'] ), 'date_on_sale_from' => wc_clean( $_POST['_sale_price_dates_from'] ),
'manage_stock' => ! empty( $_POST['_manage_stock'] ), 'date_on_sale_to' => wc_clean( $_POST['_sale_price_dates_to'] ),
'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( $_POST['_backorders'] ) : null, 'manage_stock' => ! empty( $_POST['_manage_stock'] ),
'stock_status' => wc_clean( $_POST['_stock_status'] ), 'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( $_POST['_backorders'] ) : null,
'stock_quantity' => $stock, 'stock_status' => wc_clean( $_POST['_stock_status'] ),
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( $_POST['_download_limit'] ), 'stock_quantity' => $stock,
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( $_POST['_download_expiry'] ), 'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( $_POST['_download_limit'] ),
'downloads' => self::prepare_downloads( 'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( $_POST['_download_expiry'] ),
isset( $_POST['_wc_file_names'] ) ? $_POST['_wc_file_names'] : array(), 'downloads' => self::prepare_downloads(
isset( $_POST['_wc_file_urls'] ) ? $_POST['_wc_file_urls'] : array(), isset( $_POST['_wc_file_names'] ) ? $_POST['_wc_file_names'] : array(),
isset( $_POST['_wc_file_hashes'] ) ? $_POST['_wc_file_hashes'] : array() isset( $_POST['_wc_file_urls'] ) ? $_POST['_wc_file_urls'] : array(),
), isset( $_POST['_wc_file_hashes'] ) ? $_POST['_wc_file_hashes'] : array()
'product_url' => esc_url_raw( $_POST['_product_url'] ), ),
'button_text' => wc_clean( $_POST['_button_text'] ), 'product_url' => esc_url_raw( $_POST['_product_url'] ),
'children' => 'grouped' === $product_type ? self::prepare_children() : null, 'button_text' => wc_clean( $_POST['_button_text'] ),
'reviews_allowed' => ! empty( $_POST['comment_status'] ) && 'open' === $_POST['comment_status'], 'children' => 'grouped' === $product_type ? self::prepare_children() : null,
'attributes' => $attributes, 'reviews_allowed' => ! empty( $_POST['comment_status'] ) && 'open' === $_POST['comment_status'],
'default_attributes' => self::prepare_set_attributes( $attributes, 'default_attribute_' ), 'attributes' => $attributes,
) ); 'default_attributes' => self::prepare_set_attributes( $attributes, 'default_attribute_' ),
)
);
if ( is_wp_error( $errors ) ) { if ( is_wp_error( $errors ) ) {
WC_Admin_Meta_Boxes::add_error( $errors->get_error_message() ); WC_Admin_Meta_Boxes::add_error( $errors->get_error_message() );
@ -391,12 +402,12 @@ class WC_Meta_Box_Product_Data {
/** /**
* Save meta box data. * Save meta box data.
* *
* @param int $post_id * @param int $post_id
* @param WP_Post $post * @param WP_Post $post
*/ */
public static function save_variations( $post_id, $post ) { public static function save_variations( $post_id, $post ) {
if ( isset( $_POST['variable_post_id'] ) ) { if ( isset( $_POST['variable_post_id'] ) ) {
$parent = wc_get_product( $post_id ); $parent = wc_get_product( $post_id );
$parent->set_default_attributes( self::prepare_set_attributes( $parent->get_attributes(), 'default_attribute_' ) ); $parent->set_default_attributes( self::prepare_set_attributes( $parent->get_attributes(), 'default_attribute_' ) );
$parent->save(); $parent->save();
@ -423,37 +434,39 @@ class WC_Meta_Box_Product_Data {
} }
} }
$errors = $variation->set_props( array( $errors = $variation->set_props(
'status' => isset( $_POST['variable_enabled'][ $i ] ) ? 'publish' : 'private', array(
'menu_order' => wc_clean( $_POST['variation_menu_order'][ $i ] ), 'status' => isset( $_POST['variable_enabled'][ $i ] ) ? 'publish' : 'private',
'regular_price' => wc_clean( $_POST['variable_regular_price'][ $i ] ), 'menu_order' => wc_clean( $_POST['variation_menu_order'][ $i ] ),
'sale_price' => wc_clean( $_POST['variable_sale_price'][ $i ] ), 'regular_price' => wc_clean( $_POST['variable_regular_price'][ $i ] ),
'virtual' => isset( $_POST['variable_is_virtual'][ $i ] ), 'sale_price' => wc_clean( $_POST['variable_sale_price'][ $i ] ),
'downloadable' => isset( $_POST['variable_is_downloadable'][ $i ] ), 'virtual' => isset( $_POST['variable_is_virtual'][ $i ] ),
'date_on_sale_from' => wc_clean( $_POST['variable_sale_price_dates_from'][ $i ] ), 'downloadable' => isset( $_POST['variable_is_downloadable'][ $i ] ),
'date_on_sale_to' => wc_clean( $_POST['variable_sale_price_dates_to'][ $i ] ), 'date_on_sale_from' => wc_clean( $_POST['variable_sale_price_dates_from'][ $i ] ),
'description' => wp_kses_post( $_POST['variable_description'][ $i ] ), 'date_on_sale_to' => wc_clean( $_POST['variable_sale_price_dates_to'][ $i ] ),
'download_limit' => wc_clean( $_POST['variable_download_limit'][ $i ] ), 'description' => wp_kses_post( $_POST['variable_description'][ $i ] ),
'download_expiry' => wc_clean( $_POST['variable_download_expiry'][ $i ] ), 'download_limit' => wc_clean( $_POST['variable_download_limit'][ $i ] ),
'downloads' => self::prepare_downloads( 'download_expiry' => wc_clean( $_POST['variable_download_expiry'][ $i ] ),
isset( $_POST['_wc_variation_file_names'][ $variation_id ] ) ? $_POST['_wc_variation_file_names'][ $variation_id ] : array(), 'downloads' => self::prepare_downloads(
isset( $_POST['_wc_variation_file_urls'][ $variation_id ] ) ? $_POST['_wc_variation_file_urls'][ $variation_id ] : array(), isset( $_POST['_wc_variation_file_names'][ $variation_id ] ) ? $_POST['_wc_variation_file_names'][ $variation_id ] : array(),
isset( $_POST['_wc_variation_file_hashes'][ $variation_id ] ) ? $_POST['_wc_variation_file_hashes'][ $variation_id ] : array() isset( $_POST['_wc_variation_file_urls'][ $variation_id ] ) ? $_POST['_wc_variation_file_urls'][ $variation_id ] : array(),
), isset( $_POST['_wc_variation_file_hashes'][ $variation_id ] ) ? $_POST['_wc_variation_file_hashes'][ $variation_id ] : array()
'manage_stock' => isset( $_POST['variable_manage_stock'][ $i ] ), ),
'stock_quantity' => $stock, 'manage_stock' => isset( $_POST['variable_manage_stock'][ $i ] ),
'backorders' => isset( $_POST['variable_backorders'], $_POST['variable_backorders'][ $i ] ) ? wc_clean( $_POST['variable_backorders'][ $i ] ) : null, 'stock_quantity' => $stock,
'stock_status' => wc_clean( $_POST['variable_stock_status'][ $i ] ), 'backorders' => isset( $_POST['variable_backorders'], $_POST['variable_backorders'][ $i ] ) ? wc_clean( $_POST['variable_backorders'][ $i ] ) : null,
'image_id' => wc_clean( $_POST['upload_image_id'][ $i ] ), 'stock_status' => wc_clean( $_POST['variable_stock_status'][ $i ] ),
'attributes' => self::prepare_set_attributes( $parent->get_attributes(), 'attribute_', $i ), 'image_id' => wc_clean( $_POST['upload_image_id'][ $i ] ),
'sku' => isset( $_POST['variable_sku'][ $i ] ) ? wc_clean( $_POST['variable_sku'][ $i ] ) : '', 'attributes' => self::prepare_set_attributes( $parent->get_attributes(), 'attribute_', $i ),
'weight' => isset( $_POST['variable_weight'][ $i ] ) ? wc_clean( $_POST['variable_weight'][ $i ] ) : '', 'sku' => isset( $_POST['variable_sku'][ $i ] ) ? wc_clean( $_POST['variable_sku'][ $i ] ) : '',
'length' => isset( $_POST['variable_length'][ $i ] ) ? wc_clean( $_POST['variable_length'][ $i ] ) : '', 'weight' => isset( $_POST['variable_weight'][ $i ] ) ? wc_clean( $_POST['variable_weight'][ $i ] ) : '',
'width' => isset( $_POST['variable_width'][ $i ] ) ? wc_clean( $_POST['variable_width'][ $i ] ) : '', 'length' => isset( $_POST['variable_length'][ $i ] ) ? wc_clean( $_POST['variable_length'][ $i ] ) : '',
'height' => isset( $_POST['variable_height'][ $i ] ) ? wc_clean( $_POST['variable_height'][ $i ] ) : '', 'width' => isset( $_POST['variable_width'][ $i ] ) ? wc_clean( $_POST['variable_width'][ $i ] ) : '',
'shipping_class_id' => wc_clean( $_POST['variable_shipping_class'][ $i ] ), 'height' => isset( $_POST['variable_height'][ $i ] ) ? wc_clean( $_POST['variable_height'][ $i ] ) : '',
'tax_class' => isset( $_POST['variable_tax_class'][ $i ] ) ? wc_clean( $_POST['variable_tax_class'][ $i ] ) : null, 'shipping_class_id' => wc_clean( $_POST['variable_shipping_class'][ $i ] ),
) ); 'tax_class' => isset( $_POST['variable_tax_class'][ $i ] ) ? wc_clean( $_POST['variable_tax_class'][ $i ] ) : null,
)
);
if ( is_wp_error( $errors ) ) { if ( is_wp_error( $errors ) ) {
WC_Admin_Meta_Boxes::add_error( $errors->get_error_message() ); WC_Admin_Meta_Boxes::add_error( $errors->get_error_message() );

View File

@ -28,48 +28,48 @@ class WC_Meta_Box_Product_Images {
global $thepostid, $product_object; global $thepostid, $product_object;
$thepostid = $post->ID; $thepostid = $post->ID;
$product_object = $thepostid ? wc_get_product( $thepostid ) : new WC_Product; $product_object = $thepostid ? wc_get_product( $thepostid ) : new WC_Product();
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
?> ?>
<div id="product_images_container"> <div id="product_images_container">
<ul class="product_images"> <ul class="product_images">
<?php <?php
$product_image_gallery = $product_object->get_gallery_image_ids( 'edit' ); $product_image_gallery = $product_object->get_gallery_image_ids( 'edit' );
$attachments = array_filter( $product_image_gallery ); $attachments = array_filter( $product_image_gallery );
$update_meta = false; $update_meta = false;
$updated_gallery_ids = array(); $updated_gallery_ids = array();
if ( ! empty( $attachments ) ) { if ( ! empty( $attachments ) ) {
foreach ( $attachments as $attachment_id ) { foreach ( $attachments as $attachment_id ) {
$attachment = wp_get_attachment_image( $attachment_id, 'thumbnail' ); $attachment = wp_get_attachment_image( $attachment_id, 'thumbnail' );
// if attachment is empty skip // if attachment is empty skip.
if ( empty( $attachment ) ) { if ( empty( $attachment ) ) {
$update_meta = true; $update_meta = true;
continue; continue;
} }
echo '<li class="image" data-attachment_id="' . esc_attr( $attachment_id ) . '"> echo '<li class="image" data-attachment_id="' . esc_attr( $attachment_id ) . '">
' . $attachment . ' ' . $attachment . '
<ul class="actions"> <ul class="actions">
<li><a href="#" class="delete tips" data-tip="' . esc_attr__( 'Delete image', 'woocommerce' ) . '">' . __( 'Delete', 'woocommerce' ) . '</a></li> <li><a href="#" class="delete tips" data-tip="' . esc_attr__( 'Delete image', 'woocommerce' ) . '">' . __( 'Delete', 'woocommerce' ) . '</a></li>
</ul> </ul>
</li>'; </li>';
// rebuild ids to be saved // rebuild ids to be saved.
$updated_gallery_ids[] = $attachment_id; $updated_gallery_ids[] = $attachment_id;
}
// need to update product meta to set new gallery ids
if ( $update_meta ) {
update_post_meta( $post->ID, '_product_image_gallery', implode( ',', $updated_gallery_ids ) );
}
} }
// need to update product meta to set new gallery ids
if ( $update_meta ) {
update_post_meta( $post->ID, '_product_image_gallery', implode( ',', $updated_gallery_ids ) );
}
}
?> ?>
</ul> </ul>
<input type="hidden" id="product_image_gallery" name="product_image_gallery" value="<?php echo esc_attr( implode( ',', $updated_gallery_ids ) ) ?>" /> <input type="hidden" id="product_image_gallery" name="product_image_gallery" value="<?php echo esc_attr( implode( ',', $updated_gallery_ids ) ); ?>" />
</div> </div>
<p class="add_product_images hide-if-no-js"> <p class="add_product_images hide-if-no-js">
@ -81,7 +81,7 @@ class WC_Meta_Box_Product_Images {
/** /**
* Save meta box data. * Save meta box data.
* *
* @param int $post_id * @param int $post_id
* @param WP_Post $post * @param WP_Post $post
*/ */
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {

View File

@ -28,9 +28,11 @@ class WC_Meta_Box_Product_Reviews {
$current = get_comment_meta( $comment->comment_ID, 'rating', true ); $current = get_comment_meta( $comment->comment_ID, 'rating', true );
?> ?>
<select name="rating" id="rating"> <select name="rating" id="rating">
<?php for ( $rating = 1; $rating <= 5; $rating ++ ) { <?php
for ( $rating = 1; $rating <= 5; $rating ++ ) {
printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) ); printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) );
} ?> }
?>
</select> </select>
<?php <?php
} }
@ -39,7 +41,7 @@ class WC_Meta_Box_Product_Reviews {
* Save meta box data * Save meta box data
* *
* @param mixed $location * @param mixed $location
* @param int $comment_id * @param int $comment_id
* *
* @return mixed * @return mixed
*/ */

View File

@ -7,7 +7,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<h3 class="fixed"> <h3 class="fixed">
<button type="button" data-permission_id="<?php echo esc_attr( $download->get_id() ); ?>" rel="<?php echo esc_attr( $download->get_product_id() ) . ',' . esc_attr( $download->get_download_id() ); ?>" class="revoke_access button"><?php esc_html_e( 'Revoke access', 'woocommerce' ); ?></button> <button type="button" data-permission_id="<?php echo esc_attr( $download->get_id() ); ?>" rel="<?php echo esc_attr( $download->get_product_id() ) . ',' . esc_attr( $download->get_download_id() ); ?>" class="revoke_access button"><?php esc_html_e( 'Revoke access', 'woocommerce' ); ?></button>
<div class="handlediv" aria-label="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div> <div class="handlediv" aria-label="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<strong><?php <strong>
<?php
printf( printf(
'#%s &mdash; %s &mdash; %s: %s &mdash; ', '#%s &mdash; %s &mdash; %s: %s &mdash; ',
esc_html( $product->get_id() ), esc_html( $product->get_id() ),
@ -16,7 +17,8 @@ if ( ! defined( 'ABSPATH' ) ) {
esc_html( wc_get_filename_from_url( $product->get_file_download_path( $download->get_download_id() ) ) ) esc_html( wc_get_filename_from_url( $product->get_file_download_path( $download->get_download_id() ) ) )
); );
printf( _n( 'Downloaded %s time', 'Downloaded %s times', $download->get_download_count(), 'woocommerce' ), esc_html( $download->get_download_count() ) ) printf( _n( 'Downloaded %s time', 'Downloaded %s times', $download->get_download_count(), 'woocommerce' ), esc_html( $download->get_download_count() ) )
?></strong> ?>
</strong>
</h3> </h3>
<table cellpadding="0" cellspacing="0" class="wc-metabox-content"> <table cellpadding="0" cellspacing="0" class="wc-metabox-content">
<tbody> <tbody>
@ -33,14 +35,16 @@ if ( ! defined( 'ABSPATH' ) ) {
<td> <td>
<label><?php esc_html_e( 'Customer download link', 'woocommerce' ); ?></label> <label><?php esc_html_e( 'Customer download link', 'woocommerce' ); ?></label>
<?php <?php
$download_link = add_query_arg( array( $download_link = add_query_arg(
'download_file' => $download->get_product_id(), array(
'order' => $download->get_order_key(), 'download_file' => $download->get_product_id(),
'email' => urlencode( $download->get_user_email() ), 'order' => $download->get_order_key(),
'key' => $download->get_download_id(), 'email' => urlencode( $download->get_user_email() ),
), trailingslashit( home_url() ) ); 'key' => $download->get_download_id(),
), trailingslashit( home_url() )
);
?> ?>
<a id="copy-download-link" class="button" href="<?php echo esc_url( $download_link ) ?>" data-tip="<?php esc_attr_e( 'Copied!', 'woocommerce' ); ?>" data-tip-failed="<?php esc_attr_e( 'Copying to clipboard failed. You should be able to right-click the button and copy.', 'woocommerce' ); ?>"><?php esc_html_e( 'Copy link', 'woocommerce' ); ?></a> <a id="copy-download-link" class="button" href="<?php echo esc_url( $download_link ); ?>" data-tip="<?php esc_attr_e( 'Copied!', 'woocommerce' ); ?>" data-tip-failed="<?php esc_attr_e( 'Copying to clipboard failed. You should be able to right-click the button and copy.', 'woocommerce' ); ?>"><?php esc_html_e( 'Copy link', 'woocommerce' ); ?></a>
</td> </td>
<td> <td>
<label><?php esc_html_e( 'Customer download log', 'woocommerce' ); ?></label> <label><?php esc_html_e( 'Customer download log', 'woocommerce' ); ?></label>

View File

@ -33,11 +33,11 @@ if ( ! defined( 'ABSPATH' ) ) {
<td class="line_cost" width="1%"> <td class="line_cost" width="1%">
<div class="view"> <div class="view">
<?php <?php
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ); echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'fee' ) ) { if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'fee' ) ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
} }
?> ?>
</div> </div>
<div class="edit" style="display: none;"> <div class="edit" style="display: none;">
@ -49,32 +49,31 @@ if ( ! defined( 'ABSPATH' ) ) {
</td> </td>
<?php <?php
if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) { if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) {
foreach ( $order_taxes as $tax_item ) { foreach ( $order_taxes as $tax_item ) {
$tax_item_id = $tax_item->get_rate_id(); $tax_item_id = $tax_item->get_rate_id();
$tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
?> ?>
<td class="line_tax" width="1%"> <td class="line_tax" width="1%">
<div class="view"> <div class="view">
<?php <?php
echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '&ndash;'; echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '&ndash;';
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) { if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
} }
?> ?>
</div> </div>
<div class="edit" style="display: none;"> <div class="edit" style="display: none;">
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" /> <input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
</div> </div>
<div class="refund" style="display: none;"> <div class="refund" style="display: none;">
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> <input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div> </div>
</td> </td>
<?php
<?php
}
} }
}
?> ?>
<td class="wc-order-edit-line-item"> <td class="wc-order-edit-line-item">
<?php if ( $order->is_editable() ) : ?> <?php if ( $order->is_editable() ) : ?>

View File

@ -3,18 +3,20 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
$hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', array( $hidden_order_itemmeta = apply_filters(
'_qty', 'woocommerce_hidden_order_itemmeta', array(
'_tax_class', '_qty',
'_product_id', '_tax_class',
'_variation_id', '_product_id',
'_line_subtotal', '_variation_id',
'_line_subtotal_tax', '_line_subtotal',
'_line_total', '_line_subtotal_tax',
'_line_tax', '_line_total',
'method_id', '_line_tax',
'cost', 'method_id',
) ); 'cost',
)
);
?><div class="view"> ?><div class="view">
<?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?> <?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
<table cellspacing="0" class="display_meta"> <table cellspacing="0" class="display_meta">

View File

@ -19,28 +19,28 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
</td> </td>
<td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>"> <td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>">
<?php <?php
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</div>'; echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</div>';
if ( $product && $product->get_sku() ) { if ( $product && $product->get_sku() ) {
echo '<div class="wc-order-item-sku"><strong>' . esc_html__( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>'; echo '<div class="wc-order-item-sku"><strong>' . esc_html__( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>';
} }
if ( $item->get_variation_id() ) { if ( $item->get_variation_id() ) {
echo '<div class="wc-order-item-variation"><strong>' . esc_html__( 'Variation ID:', 'woocommerce' ) . '</strong> '; echo '<div class="wc-order-item-variation"><strong>' . esc_html__( 'Variation ID:', 'woocommerce' ) . '</strong> ';
if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) { if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) {
echo esc_html( $item->get_variation_id() ); echo esc_html( $item->get_variation_id() );
} else { } else {
/* translators: %s: variation id */ /* translators: %s: variation id */
printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), $item->get_variation_id() ); printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), $item->get_variation_id() );
}
echo '</div>';
} }
echo '</div>';
}
?> ?>
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" /> <input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" /> <input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" />
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ); ?> <?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ); ?>
<?php include( 'html-order-item-meta.php' ); ?> <?php require 'html-order-item-meta.php'; ?>
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ); ?> <?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ); ?>
</td> </td>
@ -51,9 +51,9 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
<?php <?php
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) ); echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) );
if ( $item->get_subtotal() !== $item->get_total() ) { if ( $item->get_subtotal() !== $item->get_total() ) {
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>'; echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
} }
?> ?>
</div> </div>
</td> </td>
@ -62,9 +62,9 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
<?php <?php
echo '<small class="times">&times;</small> ' . esc_html( $item->get_quantity() ); echo '<small class="times">&times;</small> ' . esc_html( $item->get_quantity() );
if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) { if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) {
echo '<small class="refunded">' . ( $refunded_qty * -1 ) . '</small>'; echo '<small class="refunded">' . ( $refunded_qty * -1 ) . '</small>';
} }
?> ?>
</div> </div>
<div class="edit" style="display: none;"> <div class="edit" style="display: none;">
@ -77,15 +77,15 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
<td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>"> <td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>">
<div class="view"> <div class="view">
<?php <?php
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ); echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
if ( $item->get_subtotal() !== $item->get_total() ) { if ( $item->get_subtotal() !== $item->get_total() ) {
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>'; echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
} }
if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) { if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
} }
?> ?>
</div> </div>
<div class="edit" style="display: none;"> <div class="edit" style="display: none;">
@ -106,53 +106,53 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
</td> </td>
<?php <?php
if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) { if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) {
foreach ( $order_taxes as $tax_item ) { foreach ( $order_taxes as $tax_item ) {
$tax_item_id = $tax_item->get_rate_id(); $tax_item_id = $tax_item->get_rate_id();
$tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
$tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : ''; $tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : '';
?> ?>
<td class="line_tax" width="1%"> <td class="line_tax" width="1%">
<div class="view"> <div class="view">
<?php <?php
if ( '' !== $tax_item_total ) { if ( '' !== $tax_item_total ) {
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ); echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) );
} else { } else {
echo '&ndash;'; echo '&ndash;';
} }
if ( $item->get_subtotal() !== $item->get_total() ) { if ( $item->get_subtotal() !== $item->get_total() ) {
if ( '' === $tax_item_total ) { if ( '' === $tax_item_total ) {
echo '<span class="wc-order-item-discount">&ndash;</span>'; echo '<span class="wc-order-item-discount">&ndash;</span>';
} else { } else {
echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . '</span>'; echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . '</span>';
} }
} }
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) { if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
} }
?> ?>
</div> </div>
<div class="edit" style="display: none;"> <div class="edit" style="display: none;">
<div class="split-input"> <div class="split-input">
<div class="input"> <div class="input">
<label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label> <label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label>
<input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax wc_input_price" data-subtotal_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> <input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax wc_input_price" data-subtotal_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div> </div>
<div class="input"> <div class="input">
<label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label> <label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label>
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" class="line_tax wc_input_price" data-total_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> <input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" class="line_tax wc_input_price" data-total_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div>
</div> </div>
</div> </div>
<div class="refund" style="display: none;"> </div>
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> <div class="refund" style="display: none;">
</div> <input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</td> </div>
<?php </td>
} <?php
} }
}
?> ?>
<td class="wc-order-edit-line-item" width="1%"> <td class="wc-order-edit-line-item" width="1%">
<div class="wc-order-edit-line-item-actions"> <div class="wc-order-edit-line-item-actions">

Some files were not shown because too many files have changed in this diff Show More