Merge branch 'master' into fix/19152

This commit is contained in:
Mike Jolley 2018-03-12 17:23:21 +00:00
commit 2f73afcb70
381 changed files with 18077 additions and 14565 deletions

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

7
assets/css/jquery-ui.min.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

View File

@ -917,6 +917,18 @@ button.pswp__button--zoom:hover {
} }
} }
.woocommerce-no-js {
form.woocommerce-form-login,
form.woocommerce-form-coupon {
display: block !important;
}
.woocommerce-form-login-toggle,
.woocommerce-form-coupon-toggle,
.showcoupon {
display: none !important;
}
}
.woocommerce-terms-and-conditions { .woocommerce-terms-and-conditions {
border: 1px solid rgba(0,0,0,.2); border: 1px solid rgba(0,0,0,.2);
box-shadow: inset 0 1px 2px rgba(0,0,0,.1); box-shadow: inset 0 1px 2px rgba(0,0,0,.1);

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 {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1621,6 +1621,18 @@ p.demo_store,
} }
} }
.woocommerce-no-js {
form.woocommerce-form-login,
form.woocommerce-form-coupon {
display: block !important;
}
.woocommerce-form-login-toggle,
.woocommerce-form-coupon-toggle,
.showcoupon {
display: none !important;
}
}
/** /**
* Photoswipe * Photoswipe
* 1. These styles are required to overwrite default theme button styles (Twenty Twelve adds gradients via background-image). * 1. These styles are required to overwrite default theme button styles (Twenty Twelve adds gradients via background-image).
@ -2112,6 +2124,13 @@ button.pswp__button--zoom:hover {
background: rgba(0,0,0,.05); background: rgba(0,0,0,.05);
} }
.woocommerce-invalid {
#terms {
outline: 2px solid red;
outline-offset: 2px;
}
}
/** /**
* Password strength meter * Password strength meter
*/ */

View File

@ -13,6 +13,7 @@
this.variationData = $form.data( 'product_variations' ); this.variationData = $form.data( 'product_variations' );
this.useAjax = false === this.variationData; this.useAjax = false === this.variationData;
this.xhr = false; this.xhr = false;
this.loading = true;
// Initial state. // Initial state.
this.$singleVariationWrap.show(); this.$singleVariationWrap.show();
@ -41,6 +42,7 @@
setTimeout( function() { setTimeout( function() {
$form.trigger( 'check_variations' ); $form.trigger( 'check_variations' );
$form.trigger( 'wc_variation_form' ); $form.trigger( 'wc_variation_form' );
$form.loading = loading;
}, 100 ); }, 100 );
}; };
@ -145,9 +147,13 @@
form.$form.trigger( 'found_variation', [ variation ] ); form.$form.trigger( 'found_variation', [ variation ] );
} else { } else {
form.$form.trigger( 'reset_data' ); form.$form.trigger( 'reset_data' );
attributes.chosenCount = 0;
if ( ! form.loading ) {
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' ); form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 ); form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
} }
}
}, },
complete: function() { complete: function() {
form.$form.unblock(); form.$form.unblock();
@ -163,10 +169,14 @@
form.$form.trigger( 'found_variation', [ variation ] ); form.$form.trigger( 'found_variation', [ variation ] );
} else { } else {
form.$form.trigger( 'reset_data' ); form.$form.trigger( 'reset_data' );
attributes.chosenCount = 0;
if ( ! form.loading ) {
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' ); form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 ); form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
} }
} }
}
} else { } else {
form.$form.trigger( 'update_variation_values' ); form.$form.trigger( 'update_variation_values' );
form.$form.trigger( 'reset_data' ); form.$form.trigger( 'reset_data' );

22
composer.lock generated
View File

@ -3225,16 +3225,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v2.8.34", "version": "v2.8.35",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "162ca7d0ea597599967aa63b23418e747da0896b" "reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/162ca7d0ea597599967aa63b23418e747da0896b", "url": "https://api.github.com/repos/symfony/console/zipball/a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
"reference": "162ca7d0ea597599967aa63b23418e747da0896b", "reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3282,7 +3282,7 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2018-01-29T08:54:45+00:00" "time": "2018-02-26T15:33:21+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
@ -3457,7 +3457,7 @@
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v2.8.34", "version": "v2.8.35",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
@ -3546,16 +3546,16 @@
}, },
{ {
"name": "tracy/tracy", "name": "tracy/tracy",
"version": "v2.4.11", "version": "v2.4.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/tracy.git", "url": "https://github.com/nette/tracy.git",
"reference": "bcb93a9d4347be8779c83b200b64ea6f52d6f9ed" "reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/tracy/zipball/bcb93a9d4347be8779c83b200b64ea6f52d6f9ed", "url": "https://api.github.com/repos/nette/tracy/zipball/4182ce7b92f67002509b7fa2fc34bd84deea0b24",
"reference": "bcb93a9d4347be8779c83b200b64ea6f52d6f9ed", "reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3607,7 +3607,7 @@
"nette", "nette",
"profiler" "profiler"
], ],
"time": "2018-02-01T18:11:38+00:00" "time": "2018-02-28T00:49:47+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",

View File

@ -4,15 +4,11 @@
* *
* Returns an array of continents. * Returns an array of continents.
* *
* @author WooThemes
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.5.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.5.0 * @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(

View File

@ -2,16 +2,13 @@
/** /**
* Angola states * Angola states
* *
* @author Marcio Zebedeu
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 1.0.0 * @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
* @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['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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 3.1.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.11 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.3.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 3.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.2.3 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.2.9 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 3.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.2.5 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.3.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.1.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 3.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @version 3.4.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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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,12 +2,12 @@
/** /**
* 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(
@ -40,5 +40,5 @@ $states['TZ'] = array(
'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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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
* @category i18n
* @package WooCommerce/i18n * @package WooCommerce/i18n
* @version 2.0.0 * @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

@ -1,4 +1,15 @@
<?php <?php
/**
* Abstract Data.
*
* Handles generic data interaction which is implemented by
* the different data store classes.
*
* @class WC_Data
* @version 3.0.0
* @package WooCommerce/Classes
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -10,8 +21,6 @@ if ( ! defined( 'ABSPATH' ) ) {
* *
* @version 2.6.0 * @version 2.6.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
abstract class WC_Data { abstract class WC_Data {
@ -172,7 +181,7 @@ abstract class WC_Data {
* Delete an object, set the ID to 0, and return result. * Delete an object, set the ID to 0, and return result.
* *
* @since 2.6.0 * @since 2.6.0
* @param bool $force_delete * @param bool $force_delete Should the date be deleted permanently.
* @return bool result * @return bool result
*/ */
public function delete( $force_delete = false ) { public function delete( $force_delete = false ) {
@ -295,8 +304,8 @@ abstract class WC_Data {
* Get Meta Data by Key. * Get Meta Data by Key.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $key * @param string $key Meta Key.
* @param bool $single return first found meta with key, or all with $key * @param bool $single return first found meta with key, or all with $key.
* @param string $context What the value is for. Valid values are view and edit. * @param string $context What the value is for. Valid values are view and edit.
* @return mixed * @return mixed
*/ */
@ -315,7 +324,7 @@ abstract class WC_Data {
$value = $single ? '' : array(); $value = $single ? '' : array();
if ( ! empty( $array_keys ) ) { if ( ! empty( $array_keys ) ) {
// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()) // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
if ( $single ) { if ( $single ) {
$value = $meta_data[ current( $array_keys ) ]->value; $value = $meta_data[ current( $array_keys ) ]->value;
} else { } else {
@ -334,7 +343,7 @@ abstract class WC_Data {
* See if meta data exists, since get_meta always returns a '' or array(). * See if meta data exists, since get_meta always returns a '' or array().
* *
* @since 3.0.0 * @since 3.0.0
* @param string $key * @param string $key Meta Key.
* @return boolean * @return boolean
*/ */
public function meta_exists( $key = '' ) { public function meta_exists( $key = '' ) {
@ -347,7 +356,7 @@ abstract class WC_Data {
* Set all meta data from array. * Set all meta data from array.
* *
* @since 2.6.0 * @since 2.6.0
* @param array $data Key/Value pairs * @param array $data Key/Value pairs.
*/ */
public function set_meta_data( $data ) { public function set_meta_data( $data ) {
if ( ! empty( $data ) && is_array( $data ) ) { if ( ! empty( $data ) && is_array( $data ) ) {
@ -369,9 +378,9 @@ abstract class WC_Data {
* Add meta data. * Add meta data.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $key Meta key * @param string $key Meta key.
* @param string $value Meta value * @param string $value Meta value.
* @param bool $unique Should this be a unique key? * @param bool $unique Should this be a unique key?.
*/ */
public function add_meta_data( $key, $value, $unique = false ) { public function add_meta_data( $key, $value, $unique = false ) {
if ( $this->is_internal_meta_key( $key ) ) { if ( $this->is_internal_meta_key( $key ) ) {
@ -394,11 +403,11 @@ abstract class WC_Data {
/** /**
* Update meta data by key or ID, if provided. * Update meta data by key or ID, if provided.
* @since 2.6.0
* *
* @param string $key * @since 2.6.0
* @param string $value * @param string $key Meta key.
* @param int $meta_id * @param string $value Meta value.
* @param int $meta_id Meta ID.
*/ */
public function update_meta_data( $key, $value, $meta_id = 0 ) { public function update_meta_data( $key, $value, $meta_id = 0 ) {
if ( $this->is_internal_meta_key( $key ) ) { if ( $this->is_internal_meta_key( $key ) ) {
@ -426,7 +435,7 @@ abstract class WC_Data {
* Delete meta data. * Delete meta data.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $key Meta key * @param string $key Meta key.
*/ */
public function delete_meta_data( $key ) { public function delete_meta_data( $key ) {
$this->maybe_read_meta_data(); $this->maybe_read_meta_data();
@ -443,7 +452,7 @@ abstract class WC_Data {
* Delete meta data. * Delete meta data.
* *
* @since 2.6.0 * @since 2.6.0
* @param int $mid Meta ID * @param int $mid Meta ID.
*/ */
public function delete_meta_data_by_mid( $mid ) { public function delete_meta_data_by_mid( $mid ) {
$this->maybe_read_meta_data(); $this->maybe_read_meta_data();
@ -549,7 +558,7 @@ abstract class WC_Data {
* Set ID. * Set ID.
* *
* @since 3.0.0 * @since 3.0.0
* @param int $id * @param int $id ID.
*/ */
public function set_id( $id ) { public function set_id( $id ) {
$this->id = absint( $id ); $this->id = absint( $id );
@ -570,7 +579,7 @@ abstract class WC_Data {
* Set object read property. * Set object read property.
* *
* @since 3.0.0 * @since 3.0.0
* @param boolean $read * @param boolean $read Should read?.
*/ */
public function set_object_read( $read = true ) { public function set_object_read( $read = true ) {
$this->object_read = (bool) $read; $this->object_read = (bool) $read;
@ -593,7 +602,7 @@ abstract class WC_Data {
* @since 3.0.0 * @since 3.0.0
* *
* @param array $props Key value pairs to set. Key is the prop and should map to a setter function name. * @param array $props Key value pairs to set. Key is the prop and should map to a setter function name.
* @param string $context * @param string $context In what context to run this.
* *
* @return bool|WP_Error * @return bool|WP_Error
*/ */
@ -618,7 +627,7 @@ abstract class WC_Data {
} }
} }
return sizeof( $errors->get_error_codes() ) ? $errors : true; return count( $errors->get_error_codes() ) ? $errors : true;
} }
/** /**
@ -659,7 +668,7 @@ abstract class WC_Data {
* @since 3.0.0 * @since 3.0.0
*/ */
public function apply_changes() { public function apply_changes() {
$this->data = array_replace_recursive( $this->data, $this->changes ); $this->data = array_replace_recursive( $this->data, $this->changes ); // @codingStandardsIgnoreLine
$this->changes = array(); $this->changes = array();
} }
@ -736,13 +745,13 @@ abstract class WC_Data {
} }
$this->set_prop( $prop, $datetime ); $this->set_prop( $prop, $datetime );
} catch ( Exception $e ) {} } catch ( Exception $e ) {} // @codingStandardsIgnoreLine.
} }
/** /**
* When invalid data is found, throw an exception unless reading from the DB. * When invalid data is found, throw an exception unless reading from the DB.
* *
* @throws WC_Data_Exception * @throws WC_Data_Exception Data Exception.
* @since 3.0.0 * @since 3.0.0
* @param string $code Error code. * @param string $code Error code.
* @param string $message Error message. * @param string $message Error message.

View File

@ -1,4 +1,14 @@
<?php <?php
/**
* Abstract Integration class
*
* Extension of the Settings API which in turn gets extended
* by individual integrations to offer additional functionality.
*
* @class WC_Settings_API
* @version 2.6.0
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@ -13,31 +23,33 @@ if ( ! defined( 'ABSPATH' ) ) {
* @extends WC_Settings_API * @extends WC_Settings_API
* @version 2.6.0 * @version 2.6.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
abstract class WC_Integration extends WC_Settings_API { abstract class WC_Integration extends WC_Settings_API {
/** /**
* yes or no based on whether the integration is enabled. * Yes or no based on whether the integration is enabled.
*
* @var string * @var string
*/ */
public $enabled = 'yes'; public $enabled = 'yes';
/** /**
* Integration title. * Integration title.
*
* @var string * @var string
*/ */
public $method_title = ''; public $method_title = '';
/** /**
* Integration description. * Integration description.
*
* @var string * @var string
*/ */
public $method_description = ''; public $method_description = '';
/** /**
* Return the title for admin screens. * Return the title for admin screens.
*
* @return string * @return string
*/ */
public function get_method_title() { public function get_method_title() {
@ -46,6 +58,7 @@ abstract class WC_Integration extends WC_Settings_API {
/** /**
* Return the description for admin screens. * Return the description for admin screens.
*
* @return string * @return string
*/ */
public function get_method_description() { public function get_method_description() {

View File

@ -1,6 +1,13 @@
<?php <?php
/**
* Log handling functionality.
*
* @class WC_Log_Handler
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly.
} }
/** /**
@ -8,8 +15,6 @@ if ( ! defined( 'ABSPATH' ) ) {
* *
* @version 1.0.0 * @version 1.0.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
abstract class WC_Log_Handler implements WC_Log_Handler_Interface { abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
@ -27,7 +32,7 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
* Builds a log entry text from level, timestamp and message. * Builds a log entry text from level, timestamp and message.
* *
* @param int $timestamp Log timestamp. * @param int $timestamp Log timestamp.
* @param string $level emergency|alert|critical|error|warning|notice|info|debug * @param string $level emergency|alert|critical|error|warning|notice|info|debug.
* @param string $message Log message. * @param string $message Log message.
* @param array $context Additional information for log handlers. * @param array $context Additional information for log handlers.
* *

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Query abstraction layer functionality.
*
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -10,19 +16,19 @@ if ( ! defined( 'ABSPATH' ) ) {
* *
* @version 3.1.0 * @version 3.1.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author Automattic
*/ */
abstract class WC_Object_Query { abstract class WC_Object_Query {
/** /**
* Stores query data. * Stores query data.
*
* @var array * @var array
*/ */
protected $query_vars = array(); protected $query_vars = array();
/** /**
* Create a new query. * Create a new query.
*
* @param array $args Criteria to query on in a format similar to WP_Query. * @param array $args Criteria to query on in a format similar to WP_Query.
*/ */
public function __construct( $args = array() ) { public function __construct( $args = array() ) {
@ -31,6 +37,7 @@ abstract class WC_Object_Query {
/** /**
* Get the current query vars. * Get the current query vars.
*
* @return array * @return array
*/ */
public function get_query_vars() { public function get_query_vars() {
@ -39,6 +46,7 @@ abstract class WC_Object_Query {
/** /**
* Get the value of a query variable. * Get the value of a query variable.
*
* @param string $query_var Query variable to get value for. * @param string $query_var Query variable to get value for.
* @param mixed $default Default value if query variable is not set. * @param mixed $default Default value if query variable is not set.
* @return mixed Query variable value if set, otherwise default. * @return mixed Query variable value if set, otherwise default.
@ -52,6 +60,7 @@ abstract class WC_Object_Query {
/** /**
* Set a query variable. * Set a query variable.
*
* @param string $query_var Query variable to set. * @param string $query_var Query variable to set.
* @param mixed $value Value to set for query variable. * @param mixed $value Value to set for query variable.
*/ */
@ -61,6 +70,7 @@ abstract class WC_Object_Query {
/** /**
* Get the default allowed query vars. * Get the default allowed query vars.
*
* @return array * @return array
*/ */
protected function get_default_query_vars() { protected function get_default_query_vars() {

View File

@ -1,4 +1,4 @@
<?php // @codingStandardsIgnoreLine <?php
/** /**
* Abstract Order * Abstract Order
* *
@ -1649,7 +1649,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$subtotal = wc_price( $subtotal, array( 'currency' => $this->get_currency() ) ); $subtotal = wc_price( $subtotal, array( 'currency' => $this->get_currency() ) );
if ( 'excl' === $tax_display && $this->get_prices_include_tax() ) { if ( 'excl' === $tax_display && $this->get_prices_include_tax() && wc_tax_enabled() ) {
$subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>'; $subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
} }
} else { } else {

View File

@ -1,4 +1,13 @@
<?php <?php
/**
* Abstract payment gateway
*
* Hanldes generic payment gateway functionality which is extended by idividual payment gateways.
*
* @class WC_Payment_Gateway
* @version 2.1.0
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@ -13,91 +22,103 @@ if ( ! defined( 'ABSPATH' ) ) {
* @extends WC_Settings_API * @extends WC_Settings_API
* @version 2.1.0 * @version 2.1.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
abstract class WC_Payment_Gateway extends WC_Settings_API { abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Set if the place order button should be renamed on selection. * Set if the place order button should be renamed on selection.
*
* @var string * @var string
*/ */
public $order_button_text; public $order_button_text;
/** /**
* yes or no based on whether the method is enabled. * Yes or no based on whether the method is enabled.
*
* @var string * @var string
*/ */
public $enabled = 'yes'; public $enabled = 'yes';
/** /**
* Payment method title for the frontend. * Payment method title for the frontend.
*
* @var string * @var string
*/ */
public $title; public $title;
/** /**
* Payment method description for the frontend. * Payment method description for the frontend.
*
* @var string * @var string
*/ */
public $description; public $description;
/** /**
* Chosen payment method id. * Chosen payment method id.
*
* @var bool * @var bool
*/ */
public $chosen; public $chosen;
/** /**
* Gateway title. * Gateway title.
*
* @var string * @var string
*/ */
public $method_title = ''; public $method_title = '';
/** /**
* Gateway description. * Gateway description.
*
* @var string * @var string
*/ */
public $method_description = ''; public $method_description = '';
/** /**
* True if the gateway shows fields on the checkout. * True if the gateway shows fields on the checkout.
*
* @var bool * @var bool
*/ */
public $has_fields; public $has_fields;
/** /**
* Countries this gateway is allowed for. * Countries this gateway is allowed for.
*
* @var array * @var array
*/ */
public $countries; public $countries;
/** /**
* Available for all counties or specific. * Available for all counties or specific.
*
* @var string * @var string
*/ */
public $availability; public $availability;
/** /**
* Icon for the gateway. * Icon for the gateway.
*
* @var string * @var string
*/ */
public $icon; public $icon;
/** /**
* Supported features such as 'default_credit_card_form', 'refunds'. * Supported features such as 'default_credit_card_form', 'refunds'.
*
* @var array * @var array
*/ */
public $supports = array( 'products' ); public $supports = array( 'products' );
/** /**
* Maximum transaction amount, zero does not define a maximum. * Maximum transaction amount, zero does not define a maximum.
*
* @var int * @var int
*/ */
public $max_amount = 0; public $max_amount = 0;
/** /**
* Optional URL to view a transaction. * Optional URL to view a transaction.
*
* @var string * @var string
*/ */
public $view_transaction_url = ''; public $view_transaction_url = '';
@ -105,23 +126,26 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Optional label to show for "new payment method" in the payment * Optional label to show for "new payment method" in the payment
* method/token selection radio selection. * method/token selection radio selection.
*
* @var string * @var string
*/ */
public $new_method_label = ''; public $new_method_label = '';
/** /**
* Contains a users saved tokens for this gateway. * Contains a users saved tokens for this gateway.
*
* @var array * @var array
*/ */
protected $tokens = array(); protected $tokens = array();
/** /**
* Returns a users saved tokens for this gateway. * Returns a users saved tokens for this gateway.
*
* @since 2.6.0 * @since 2.6.0
* @return array * @return array
*/ */
public function get_tokens() { public function get_tokens() {
if ( sizeof( $this->tokens ) > 0 ) { if ( count( $this->tokens ) > 0 ) {
return $this->tokens; return $this->tokens;
} }
@ -134,6 +158,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Return the title for admin screens. * Return the title for admin screens.
*
* @return string * @return string
*/ */
public function get_method_title() { public function get_method_title() {
@ -142,6 +167,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Return the description for admin screens. * Return the description for admin screens.
*
* @return string * @return string
*/ */
public function get_method_description() { public function get_method_description() {
@ -168,7 +194,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Get the return url (thank you page). * Get the return url (thank you page).
* *
* @param WC_Order $order * @param WC_Order $order Order object.
* @return string * @return string
*/ */
public function get_return_url( $order = null ) { public function get_return_url( $order = null ) {
@ -300,7 +326,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* 'redirect' => $this->get_return_url( $order ) * 'redirect' => $this->get_return_url( $order )
* ); * );
* *
* @param int $order_id * @param int $order_id Order ID.
* @return array * @return array
*/ */
public function process_payment( $order_id ) { public function process_payment( $order_id ) {
@ -313,9 +339,9 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* If the gateway declares 'refunds' support, this will allow it to refund. * If the gateway declares 'refunds' support, this will allow it to refund.
* a passed in amount. * a passed in amount.
* *
* @param int $order_id * @param int $order_id Order ID.
* @param float $amount * @param float $amount Refund amount.
* @param string $reason * @param string $reason Refund reason.
* @return boolean True or false based on success, or a WP_Error object. * @return boolean True or false based on success, or a WP_Error object.
*/ */
public function process_refund( $order_id, $amount = null, $reason = '' ) { public function process_refund( $order_id, $amount = null, $reason = '' ) {
@ -329,15 +355,18 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* *
* @return bool * @return bool
*/ */
public function validate_fields() { return true; } public function validate_fields() {
return true;
}
/** /**
* If There are no payment fields show the description if set. * If There are no payment fields show the description if set.
* Override this in your gateway if you have some. * Override this in your gateway if you have some.
*/ */
public function payment_fields() { public function payment_fields() {
if ( $description = $this->get_description() ) { $description = $this->get_description();
echo wpautop( wptexturize( $description ) ); if ( $description ) {
echo wpautop( wptexturize( $description ) ); // @codingStandardsIgnoreLine.
} }
if ( $this->supports( 'default_credit_card_form' ) ) { if ( $this->supports( 'default_credit_card_form' ) ) {
@ -361,12 +390,13 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Core credit card form which gateways can used if needed. Deprecated - inherit WC_Payment_Gateway_CC instead. * Core credit card form which gateways can used if needed. Deprecated - inherit WC_Payment_Gateway_CC instead.
* @param array $args *
* @param array $fields * @param array $args Arguments.
* @param array $fields Fields.
*/ */
public function credit_card_form( $args = array(), $fields = array() ) { public function credit_card_form( $args = array(), $fields = array() ) {
wc_deprecated_function( 'credit_card_form', '2.6', 'WC_Payment_Gateway_CC->form' ); wc_deprecated_function( 'credit_card_form', '2.6', 'WC_Payment_Gateway_CC->form' );
$cc_form = new WC_Payment_Gateway_CC; $cc_form = new WC_Payment_Gateway_CC();
$cc_form->id = $this->id; $cc_form->id = $this->id;
$cc_form->supports = $this->supports; $cc_form->supports = $this->supports;
$cc_form->form(); $cc_form->form();
@ -374,6 +404,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Enqueues our tokenization script to handle some of the new form options. * Enqueues our tokenization script to handle some of the new form options.
*
* @since 2.6.0 * @since 2.6.0
*/ */
public function tokenization_script() { public function tokenization_script() {
@ -387,6 +418,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Grab and display our saved payment methods. * Grab and display our saved payment methods.
*
* @since 2.6.0 * @since 2.6.0
*/ */
public function saved_payment_methods() { public function saved_payment_methods() {
@ -399,13 +431,14 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
$html .= $this->get_new_payment_method_option_html(); $html .= $this->get_new_payment_method_option_html();
$html .= '</ul>'; $html .= '</ul>';
echo apply_filters( 'wc_payment_gateway_form_saved_payment_methods_html', $html, $this ); echo apply_filters( 'wc_payment_gateway_form_saved_payment_methods_html', $html, $this ); // @codingStandardsIgnoreLine
} }
/** /**
* Gets saved payment method HTML from a token. * Gets saved payment method HTML from a token.
*
* @since 2.6.0 * @since 2.6.0
* @param WC_Payment_Token $token Payment Token * @param WC_Payment_Token $token Payment Token.
* @return string Generated payment method HTML * @return string Generated payment method HTML
*/ */
public function get_saved_payment_method_option_html( $token ) { public function get_saved_payment_method_option_html( $token ) {
@ -426,6 +459,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
* Only displayed when a gateway supports tokenization. * Only displayed when a gateway supports tokenization.
*
* @since 2.6.0 * @since 2.6.0
*/ */
public function get_new_payment_method_option_html() { public function get_new_payment_method_option_html() {
@ -444,6 +478,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
/** /**
* Outputs a checkbox for saving a new payment method to the database. * Outputs a checkbox for saving a new payment method to the database.
*
* @since 2.6.0 * @since 2.6.0
*/ */
public function save_payment_method_checkbox() { public function save_payment_method_checkbox() {

View File

@ -1,9 +1,18 @@
<?php <?php
/**
* Abstract payment tokens
*
* Generic payment tokens functionality which can be extended by idividual types of payment tokens.
*
* @class WC_Payment_Token
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php' ); require_once WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php';
/** /**
* WooCommerce Payment Token. * WooCommerce Payment Token.
@ -15,13 +24,12 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* @version 3.0.0 * @version 3.0.0
* @since 2.6.0 * @since 2.6.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
abstract class WC_Payment_Token extends WC_Legacy_Payment_Token { abstract class WC_Payment_Token extends WC_Legacy_Payment_Token {
/** /**
* Token Data (stored in the payment_tokens table). * Token Data (stored in the payment_tokens table).
*
* @var array * @var array
*/ */
protected $data = array( protected $data = array(
@ -35,6 +43,8 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
/** /**
* Token Type (CC, eCheck, or a custom type added by an extension). * Token Type (CC, eCheck, or a custom type added by an extension).
* Set by child classes. * Set by child classes.
*
* @var string
*/ */
protected $type = ''; protected $type = '';
@ -48,7 +58,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* user_id - int Optional - ID for the user this token is associated with. 0 if this token is not associated with a user * user_id - int Optional - ID for the user this token is associated with. 0 if this token is not associated with a user
* *
* @since 2.6.0 * @since 2.6.0
* @param mixed $token * @param mixed $token Token.
*/ */
public function __construct( $token = '' ) { public function __construct( $token = '' ) {
parent::__construct( $token ); parent::__construct( $token );
@ -71,16 +81,16 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
} }
/* /*
|-------------------------------------------------------------------------- *--------------------------------------------------------------------------
| Getters * Getters
|-------------------------------------------------------------------------- *--------------------------------------------------------------------------
*/ */
/** /**
* Returns the raw payment token. * Returns the raw payment token.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $context * @param string $context Context in which to call this.
* @return string Raw token * @return string Raw token
*/ */
public function get_token( $context = 'view' ) { public function get_token( $context = 'view' ) {
@ -92,7 +102,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Overwritten by child classes. * Overwritten by child classes.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $deprecated Deprecated since WooCommerce 3.0 * @param string $deprecated Deprecated since WooCommerce 3.0.
* @return string Payment Token Type (CC, eCheck) * @return string Payment Token Type (CC, eCheck)
*/ */
public function get_type( $deprecated = '' ) { public function get_type( $deprecated = '' ) {
@ -104,7 +114,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Get's overwritten by child classes. * Get's overwritten by child classes.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $deprecated Deprecated since WooCommerce 3.0 * @param string $deprecated Deprecated since WooCommerce 3.0.
* @return string * @return string
*/ */
public function get_display_name( $deprecated = '' ) { public function get_display_name( $deprecated = '' ) {
@ -115,7 +125,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Returns the user ID associated with the token or false if this token is not associated. * Returns the user ID associated with the token or false if this token is not associated.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $context * @param string $context In what context to execute this.
* @return int User ID if this token is associated with a user or 0 if no user is associated * @return int User ID if this token is associated with a user or 0 if no user is associated
*/ */
public function get_user_id( $context = 'view' ) { public function get_user_id( $context = 'view' ) {
@ -126,7 +136,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Returns the ID of the gateway associated with this payment token. * Returns the ID of the gateway associated with this payment token.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $context * @param string $context In what context to execute this.
* @return string Gateway ID * @return string Gateway ID
*/ */
public function get_gateway_id( $context = 'view' ) { public function get_gateway_id( $context = 'view' ) {
@ -137,7 +147,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Returns the ID of the gateway associated with this payment token. * Returns the ID of the gateway associated with this payment token.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $context * @param string $context In what context to execute this.
* @return string Gateway ID * @return string Gateway ID
*/ */
public function get_is_default( $context = 'view' ) { public function get_is_default( $context = 'view' ) {
@ -154,7 +164,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Set the raw payment token. * Set the raw payment token.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $token * @param string $token Payment token.
*/ */
public function set_token( $token ) { public function set_token( $token ) {
$this->set_prop( 'token', $token ); $this->set_prop( 'token', $token );
@ -164,7 +174,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Set the user ID for the user associated with this order. * Set the user ID for the user associated with this order.
* *
* @since 2.6.0 * @since 2.6.0
* @param int $user_id * @param int $user_id User ID.
*/ */
public function set_user_id( $user_id ) { public function set_user_id( $user_id ) {
$this->set_prop( 'user_id', absint( $user_id ) ); $this->set_prop( 'user_id', absint( $user_id ) );
@ -174,7 +184,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
* Set the gateway ID. * Set the gateway ID.
* *
* @since 2.6.0 * @since 2.6.0
* @param string $gateway_id * @param string $gateway_id Gateway ID.
*/ */
public function set_gateway_id( $gateway_id ) { public function set_gateway_id( $gateway_id ) {
$this->set_prop( 'gateway_id', $gateway_id ); $this->set_prop( 'gateway_id', $gateway_id );
@ -182,8 +192,9 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
/** /**
* Marks the payment as default or non-default. * Marks the payment as default or non-default.
*
* @since 2.6.0 * @since 2.6.0
* @param boolean $is_default True or false * @param boolean $is_default True or false.
*/ */
public function set_default( $is_default ) { public function set_default( $is_default ) {
$this->set_prop( 'is_default', (bool) $is_default ); $this->set_prop( 'is_default', (bool) $is_default );
@ -207,6 +218,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
/** /**
* Validate basic token info (token and type are required). * Validate basic token info (token and type are required).
*
* @since 2.6.0 * @since 2.6.0
* @return boolean True if the passed data is valid * @return boolean True if the passed data is valid
*/ */

View File

@ -2,7 +2,7 @@
/** /**
* WooCommerce product base class. * WooCommerce product base class.
* *
* @package WooCommerce/Classes * @package WooCommerce/Abstracts
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Legacy product contains all deprecated methods for this class and can be * Legacy product contains all deprecated methods for this class and can be
* removed in the future. * removed in the future.
*/ */
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php' ); require_once WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php';
/** /**
* Abstract Product Class * Abstract Product Class
@ -22,8 +22,6 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php' );
* *
* @version 3.0.0 * @version 3.0.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
class WC_Product extends WC_Abstract_Legacy_Product { class WC_Product extends WC_Abstract_Legacy_Product {
@ -1192,6 +1190,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
// Validate the file extension. // Validate the file extension.
if ( ! $download_object->is_allowed_filetype() ) { if ( ! $download_object->is_allowed_filetype() ) {
if ( $this->get_object_read() ) { if ( $this->get_object_read() ) {
/* translators: %1$s: Downloadable file */
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $download_object->get_file() ) . '</code>', '<code>' . implode( ', ', array_keys( $download_object->get_allowed_mime_types() ) ) . '</code>' ); $errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $download_object->get_file() ) . '</code>', '<code>' . implode( ', ', array_keys( $download_object->get_allowed_mime_types() ) ) . '</code>' );
} }
continue; continue;
@ -1200,6 +1199,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
// Validate the file exists. // Validate the file exists.
if ( ! $download_object->file_exists() ) { if ( ! $download_object->file_exists() ) {
if ( $this->get_object_read() ) { if ( $this->get_object_read() ) {
/* translators: %s: Downloadable file */
$errors[] = sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '<code>' . $download_object->get_file() . '</code>' ); $errors[] = sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '<code>' . $download_object->get_file() . '</code>' );
} }
continue; continue;
@ -1801,7 +1801,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
public function get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) { public function get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) {
if ( has_post_thumbnail( $this->get_id() ) ) { if ( has_post_thumbnail( $this->get_id() ) ) {
$image = get_the_post_thumbnail( $this->get_id(), $size, $attr ); $image = get_the_post_thumbnail( $this->get_id(), $size, $attr );
} elseif ( ( $parent_id = wp_get_post_parent_id( $this->get_id() ) ) && has_post_thumbnail( $parent_id ) ) { } elseif ( ( $parent_id = wp_get_post_parent_id( $this->get_id() ) ) && has_post_thumbnail( $parent_id ) ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
$image = get_the_post_thumbnail( $parent_id, $size, $attr ); $image = get_the_post_thumbnail( $parent_id, $size, $attr );
} elseif ( $placeholder ) { } elseif ( $placeholder ) {
$image = wc_placeholder_img( $size ); $image = wc_placeholder_img( $size );
@ -1818,7 +1818,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @return string * @return string
*/ */
public function get_shipping_class() { public function get_shipping_class() {
if ( $class_id = $this->get_shipping_class_id() ) { if ( $class_id = $this->get_shipping_class_id() ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
$term = get_term_by( 'id', $class_id, 'product_shipping_class' ); $term = get_term_by( 'id', $class_id, 'product_shipping_class' );
if ( $term && ! is_wp_error( $term ) ) { if ( $term && ! is_wp_error( $term ) ) {
@ -1910,13 +1910,13 @@ class WC_Product extends WC_Abstract_Legacy_Product {
public function get_price_suffix( $price = '', $qty = 1 ) { public function get_price_suffix( $price = '', $qty = 1 ) {
$html = ''; $html = '';
if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) && wc_tax_enabled() && 'taxable' === $this->get_tax_status() ) { if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) && wc_tax_enabled() && 'taxable' === $this->get_tax_status() ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
if ( '' === $price ) { if ( '' === $price ) {
$price = $this->get_price(); $price = $this->get_price();
} }
$replacements = array( $replacements = array(
'{price_including_tax}' => wc_price( wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), '{price_including_tax}' => wc_price( wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), // @phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
'{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), '{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), // @phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
); );
$html = str_replace( array_keys( $replacements ), array_values( $replacements ), ' <small class="woocommerce-price-suffix">' . wp_kses_post( $suffix ) . '</small>' ); $html = str_replace( array_keys( $replacements ), array_values( $replacements ), ' <small class="woocommerce-price-suffix">' . wp_kses_post( $suffix ) . '</small>' );
} }

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* REST Controller
*
* @class WC_REST_Controller
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@ -7,8 +13,6 @@ if ( ! defined( 'ABSPATH' ) ) {
/** /**
* Abstract Rest Controller Class * Abstract Rest Controller Class
* *
* @author WooThemes
* @category API
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @extends WP_REST_Controller * @extends WP_REST_Controller
* @version 2.6.0 * @version 2.6.0
@ -109,7 +113,11 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* @return array Of WP_Error or WP_REST_Response. * @return array Of WP_Error or WP_REST_Response.
*/ */
public function batch_items( $request ) { public function batch_items( $request ) {
/** @var WP_REST_Server $wp_rest_server */ /**
* REST Server
*
* @var WP_REST_Server $wp_rest_server
*/
global $wp_rest_server; global $wp_rest_server;
// Get the request params. // Get the request params.
@ -143,7 +151,11 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
if ( is_wp_error( $_response ) ) { if ( is_wp_error( $_response ) ) {
$response['create'][] = array( $response['create'][] = array(
'id' => 0, 'id' => 0,
'error' => array( 'code' => $_response->get_error_code(), 'message' => $_response->get_error_message(), 'data' => $_response->get_error_data() ), 'error' => array(
'code' => $_response->get_error_code(),
'message' => $_response->get_error_message(),
'data' => $_response->get_error_data(),
),
); );
} else { } else {
$response['create'][] = $wp_rest_server->response_to_data( $_response, '' ); $response['create'][] = $wp_rest_server->response_to_data( $_response, '' );
@ -160,7 +172,11 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
if ( is_wp_error( $_response ) ) { if ( is_wp_error( $_response ) ) {
$response['update'][] = array( $response['update'][] = array(
'id' => $item['id'], 'id' => $item['id'],
'error' => array( 'code' => $_response->get_error_code(), 'message' => $_response->get_error_message(), 'data' => $_response->get_error_data() ), 'error' => array(
'code' => $_response->get_error_code(),
'message' => $_response->get_error_message(),
'data' => $_response->get_error_data(),
),
); );
} else { } else {
$response['update'][] = $wp_rest_server->response_to_data( $_response, '' ); $response['update'][] = $wp_rest_server->response_to_data( $_response, '' );
@ -177,13 +193,20 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
} }
$_item = new WP_REST_Request( 'DELETE' ); $_item = new WP_REST_Request( 'DELETE' );
$_item->set_query_params( array( 'id' => $id, 'force' => true ) ); $_item->set_query_params( array(
'id' => $id,
'force' => true,
) );
$_response = $this->delete_item( $_item ); $_response = $this->delete_item( $_item );
if ( is_wp_error( $_response ) ) { if ( is_wp_error( $_response ) ) {
$response['delete'][] = array( $response['delete'][] = array(
'id' => $id, 'id' => $id,
'error' => array( 'code' => $_response->get_error_code(), 'message' => $_response->get_error_message(), 'data' => $_response->get_error_data() ), 'error' => array(
'code' => $_response->get_error_code(),
'message' => $_response->get_error_message(),
'data' => $_response->get_error_data(),
),
); );
} else { } else {
$response['delete'][] = $wp_rest_server->response_to_data( $_response, '' ); $response['delete'][] = $wp_rest_server->response_to_data( $_response, '' );
@ -198,8 +221,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate a text value for a text based setting. * Validate a text value for a text based setting.
* *
* @since 3.0.0 * @since 3.0.0
* @param string $value * @param string $value Value.
* @param array $setting * @param array $setting Setting.
* @return string * @return string
*/ */
public function validate_setting_text_field( $value, $setting ) { public function validate_setting_text_field( $value, $setting ) {
@ -211,8 +234,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate select based settings. * Validate select based settings.
* *
* @since 3.0.0 * @since 3.0.0
* @param string $value * @param string $value Value.
* @param array $setting * @param array $setting Setting.
* @return string|WP_Error * @return string|WP_Error
*/ */
public function validate_setting_select_field( $value, $setting ) { public function validate_setting_select_field( $value, $setting ) {
@ -227,8 +250,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate multiselect based settings. * Validate multiselect based settings.
* *
* @since 3.0.0 * @since 3.0.0
* @param array $values * @param array $values Values.
* @param array $setting * @param array $setting Setting.
* @return array|WP_Error * @return array|WP_Error
*/ */
public function validate_setting_multiselect_field( $values, $setting ) { public function validate_setting_multiselect_field( $values, $setting ) {
@ -254,8 +277,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate image_width based settings. * Validate image_width based settings.
* *
* @since 3.0.0 * @since 3.0.0
* @param array $values * @param array $values Values.
* @param array $setting * @param array $setting Setting.
* @return string|WP_Error * @return string|WP_Error
*/ */
public function validate_setting_image_width_field( $values, $setting ) { public function validate_setting_image_width_field( $values, $setting ) {
@ -280,8 +303,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate radio based settings. * Validate radio based settings.
* *
* @since 3.0.0 * @since 3.0.0
* @param string $value * @param string $value Value.
* @param array $setting * @param array $setting Setting.
* @return string|WP_Error * @return string|WP_Error
*/ */
public function validate_setting_radio_field( $value, $setting ) { public function validate_setting_radio_field( $value, $setting ) {
@ -292,8 +315,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate checkbox based settings. * Validate checkbox based settings.
* *
* @since 3.0.0 * @since 3.0.0
* @param string $value * @param string $value Value.
* @param array $setting * @param array $setting Setting.
* @return string|WP_Error * @return string|WP_Error
*/ */
public function validate_setting_checkbox_field( $value, $setting ) { public function validate_setting_checkbox_field( $value, $setting ) {
@ -311,8 +334,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
* Validate textarea based settings. * Validate textarea based settings.
* *
* @since 3.0.0 * @since 3.0.0
* @param string $value * @param string $value Value.
* @param array $setting * @param array $setting Setting.
* @return string * @return string
*/ */
public function validate_setting_textarea_field( $value, $setting ) { public function validate_setting_textarea_field( $value, $setting ) {
@ -320,7 +343,12 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
return wp_kses( trim( stripslashes( $value ) ), return wp_kses( trim( stripslashes( $value ) ),
array_merge( array_merge(
array( array(
'iframe' => array( 'src' => true, 'style' => true, 'id' => true, 'class' => true ), 'iframe' => array(
'src' => true,
'style' => true,
'id' => true,
'class' => true,
),
), ),
wp_kses_allowed_html( 'post' ) wp_kses_allowed_html( 'post' )
) )

View File

@ -2,8 +2,7 @@
/** /**
* Abstract Rest CRUD Controller Class * Abstract Rest CRUD Controller Class
* *
* @author Automattic * @class WC_REST_CRUD_Controller
* @category API
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @version 3.0.0 * @version 3.0.0
*/ */
@ -40,6 +39,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
* @return object WC_Data object or WP_Error object. * @return object WC_Data object or WP_Error object.
*/ */
protected function get_object( $id ) { protected function get_object( $id ) {
// translators: %s: Class method name.
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) ); return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
} }
@ -94,7 +94,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
/** /**
* Get object permalink. * Get object permalink.
* *
* @param object $object * @param object $object Object.
* @return string * @return string
*/ */
protected function get_permalink( $object ) { protected function get_permalink( $object ) {
@ -110,6 +110,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
*/ */
protected function prepare_object_for_response( $object, $request ) { protected function prepare_object_for_response( $object, $request ) {
// translators: %s: Class method name.
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) ); return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
} }
@ -122,6 +123,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
* @return WP_Error|WC_Data The prepared item, or WP_Error object on failure. * @return WP_Error|WC_Data The prepared item, or WP_Error object on failure.
*/ */
protected function prepare_object_for_database( $request, $creating = false ) { protected function prepare_object_for_database( $request, $creating = false ) {
// translators: %s: Class method name.
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) ); return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
} }

View File

@ -1,14 +1,18 @@
<?php <?php
/**
* Abstract Rest Posts Controller Class
*
* @class WC_REST_Posts_Controller
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
/** /**
* Abstract Rest Posts Controller Class * WC_REST_Posts_Controller
* *
* @author WooThemes
* @category API
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @version 2.6.0 * @version 2.6.0
*/ */
@ -223,8 +227,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
/** /**
* Add post meta fields. * Add post meta fields.
* *
* @param WP_Post $post * @param WP_Post $post Post Object.
* @param WP_REST_Request $request * @param WP_REST_Request $request WP_REST_Request Object.
* @return bool|WP_Error * @return bool|WP_Error
*/ */
protected function add_post_meta_fields( $post, $request ) { protected function add_post_meta_fields( $post, $request ) {
@ -234,7 +238,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
/** /**
* Delete post. * Delete post.
* *
* @param WP_Post $post * @param WP_Post $post Post object.
*/ */
protected function delete_post( $post ) { protected function delete_post( $post ) {
wp_delete_post( $post->ID, true ); wp_delete_post( $post->ID, true );
@ -364,7 +368,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
$total_posts = $posts_query->found_posts; $total_posts = $posts_query->found_posts;
if ( $total_posts < 1 ) { if ( $total_posts < 1 ) {
// Out-of-bounds, run the query again without LIMIT for total count // Out-of-bounds, run the query again without LIMIT for total count.
unset( $query_args['paged'] ); unset( $query_args['paged'] );
$count_query = new WP_Query(); $count_query = new WP_Query();
$count_query->query( $query_args ); $count_query->query( $query_args );
@ -499,8 +503,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
* Determine the allowed query_vars for a get_items() response and * Determine the allowed query_vars for a get_items() response and
* prepare for WP_Query. * prepare for WP_Query.
* *
* @param array $prepared_args * @param array $prepared_args Prepared arguments.
* @param WP_REST_Request $request * @param WP_REST_Request $request Request object.
* @return array $query_args * @return array $query_args
*/ */
protected function prepare_items_query( $prepared_args = array(), $request = null ) { protected function prepare_items_query( $prepared_args = array(), $request = null ) {
@ -515,7 +519,6 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
* The dynamic portion of the hook name, $var, refers to the query_var key. * The dynamic portion of the hook name, $var, refers to the query_var key.
* *
* @param mixed $prepared_args[ $var ] The query_var value. * @param mixed $prepared_args[ $var ] The query_var value.
*
*/ */
$query_args[ $var ] = apply_filters( "woocommerce_rest_query_var-{$var}", $prepared_args[ $var ] ); $query_args[ $var ] = apply_filters( "woocommerce_rest_query_var-{$var}", $prepared_args[ $var ] );
} }
@ -526,7 +529,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
if ( 'include' === $query_args['orderby'] ) { if ( 'include' === $query_args['orderby'] ) {
$query_args['orderby'] = 'post__in'; $query_args['orderby'] = 'post__in';
} elseif ( 'id' === $query_args['orderby'] ) { } elseif ( 'id' === $query_args['orderby'] ) {
$query_args['orderby'] = 'ID'; // ID must be capitalized $query_args['orderby'] = 'ID'; // ID must be capitalized.
} }
return $query_args; return $query_args;
@ -708,8 +711,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
/** /**
* Update post meta fields. * Update post meta fields.
* *
* @param WP_Post $post * @param WP_Post $post Post object.
* @param WP_REST_Request $request * @param WP_REST_Request $request Request object.
* @return bool|WP_Error * @return bool|WP_Error
*/ */
protected function update_post_meta_fields( $post, $request ) { protected function update_post_meta_fields( $post, $request ) {

View File

@ -4,9 +4,7 @@
* *
* Houses common functionality between Shipping Zones and Locations. * Houses common functionality between Shipping Zones and Locations.
* *
* @author WooThemes * @package WooCommerce/Abstracts
* @category API
* @package WooCommerce/API
* @since 3.0.0 * @since 3.0.0
*/ */

View File

@ -1,12 +1,10 @@
<?php // @codingStandardsIgnoreLine. <?php
/** /**
* Handle data for the current customers session * Handle data for the current customers session
* *
* @class WC_Session * @class WC_Session
* @version 2.0.0 * @version 2.0.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author Automattic
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {

View File

@ -1,4 +1,4 @@
<?php // @codingStandardsIgnoreLine. <?php
/** /**
* Abstract Settings API Class * Abstract Settings API Class
* *

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Abstract shipping method
*
* @class WC_Shipping_Method
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@ -12,8 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) {
* @class WC_Shipping_Method * @class WC_Shipping_Method
* @version 3.0.0 * @version 3.0.0
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/ */
abstract class WC_Shipping_Method extends WC_Settings_API { abstract class WC_Shipping_Method extends WC_Settings_API {
@ -23,78 +27,91 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* - instance-settings Instance settings screens. * - instance-settings Instance settings screens.
* - settings Non-instance settings screens. Enabled by default for BW compatibility with methods before instances existed. * - settings Non-instance settings screens. Enabled by default for BW compatibility with methods before instances existed.
* - instance-settings-modal Allows the instance settings to be loaded within a modal in the zones UI. * - instance-settings-modal Allows the instance settings to be loaded within a modal in the zones UI.
*
* @var array * @var array
*/ */
public $supports = array( 'settings' ); public $supports = array( 'settings' );
/** /**
* Unique ID for the shipping method - must be set. * Unique ID for the shipping method - must be set.
*
* @var string * @var string
*/ */
public $id = ''; public $id = '';
/** /**
* Method title. * Method title.
*
* @var string * @var string
*/ */
public $method_title = ''; public $method_title = '';
/** /**
* Method description. * Method description.
*
* @var string * @var string
*/ */
public $method_description = ''; public $method_description = '';
/** /**
* yes or no based on whether the method is enabled. * Yes or no based on whether the method is enabled.
*
* @var string * @var string
*/ */
public $enabled = 'yes'; public $enabled = 'yes';
/** /**
* Shipping method title for the frontend. * Shipping method title for the frontend.
*
* @var string * @var string
*/ */
public $title; public $title;
/** /**
* This is an array of rates - methods must populate this array to register shipping costs. * This is an array of rates - methods must populate this array to register shipping costs.
*
* @var array * @var array
*/ */
public $rates = array(); public $rates = array();
/** /**
* If 'taxable' tax will be charged for this method (if applicable). * If 'taxable' tax will be charged for this method (if applicable).
*
* @var string * @var string
*/ */
public $tax_status = 'taxable'; public $tax_status = 'taxable';
/** /**
* Fee for the method (if applicable). * Fee for the method (if applicable).
*
* @var string * @var string
*/ */
public $fee = null; public $fee = null;
/** /**
* Minimum fee for the method (if applicable). * Minimum fee for the method (if applicable).
*
* @var string * @var string
*/ */
public $minimum_fee = null; public $minimum_fee = null;
/** /**
* Instance ID if used. * Instance ID if used.
*
* @var int * @var int
*/ */
public $instance_id = 0; public $instance_id = 0;
/** /**
* Instance form fields. * Instance form fields.
*
* @var array * @var array
*/ */
public $instance_form_fields = array(); public $instance_form_fields = array();
/** /**
* Instance settings. * Instance settings.
*
* @var array * @var array
*/ */
public $instance_settings = array(); public $instance_settings = array();
@ -102,6 +119,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Availability - legacy. Used for method Availability. * Availability - legacy. Used for method Availability.
* No longer useful for instance based shipping methods. * No longer useful for instance based shipping methods.
*
* @deprecated 2.6.0 * @deprecated 2.6.0
* @var string * @var string
*/ */
@ -110,6 +128,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Availability countries - legacy. Used for method Availability. * Availability countries - legacy. Used for method Availability.
* No longer useful for instance based shipping methods. * No longer useful for instance based shipping methods.
*
* @deprecated 2.6.0 * @deprecated 2.6.0
* @var array * @var array
*/ */
@ -117,7 +136,8 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Constructor. * Constructor.
* @param int $instance_id *
* @param int $instance_id Instance ID.
*/ */
public function __construct( $instance_id = 0 ) { public function __construct( $instance_id = 0 ) {
$this->instance_id = absint( $instance_id ); $this->instance_id = absint( $instance_id );
@ -128,7 +148,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* *
* Methods should override this to declare support (or lack of support) for a feature. * Methods should override this to declare support (or lack of support) for a feature.
* *
* @param $feature string The name of a feature to test support for. * @param string $feature The name of a feature to test support for.
* @return bool True if the shipping method supports the feature, false otherwise. * @return bool True if the shipping method supports the feature, false otherwise.
*/ */
public function supports( $feature ) { public function supports( $feature ) {
@ -138,12 +158,13 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Called to calculate shipping rates for this method. Rates can be added using the add_rate() method. * Called to calculate shipping rates for this method. Rates can be added using the add_rate() method.
* *
* @param array $package * @param array $package Package array.
*/ */
public function calculate_shipping( $package = array() ) {} public function calculate_shipping( $package = array() ) {}
/** /**
* Whether or not we need to calculate tax on top of the shipping rate. * Whether or not we need to calculate tax on top of the shipping rate.
*
* @return boolean * @return boolean
*/ */
public function is_taxable() { public function is_taxable() {
@ -152,6 +173,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Whether or not this method is enabled in settings. * Whether or not this method is enabled in settings.
*
* @since 2.6.0 * @since 2.6.0
* @return boolean * @return boolean
*/ */
@ -161,6 +183,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Return the shipping method instance ID. * Return the shipping method instance ID.
*
* @since 2.6.0 * @since 2.6.0
* @return int * @return int
*/ */
@ -170,6 +193,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Return the shipping method title. * Return the shipping method title.
*
* @since 2.6.0 * @since 2.6.0
* @return string * @return string
*/ */
@ -179,6 +203,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Return the shipping method description. * Return the shipping method description.
*
* @since 2.6.0 * @since 2.6.0
* @return string * @return string
*/ */
@ -197,8 +222,9 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Return calculated rates for a package. * Return calculated rates for a package.
*
* @since 2.6.0 * @since 2.6.0
* @param object $package * @param object $package Package array.
* @return array * @return array
*/ */
public function get_rates_for_package( $package ) { public function get_rates_for_package( $package ) {
@ -212,8 +238,9 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Returns a rate ID based on this methods ID and instance, with an optional * Returns a rate ID based on this methods ID and instance, with an optional
* suffix if distinguishing between multiple rates. * suffix if distinguishing between multiple rates.
*
* @since 2.6.0 * @since 2.6.0
* @param string $suffix * @param string $suffix Suffix.
* @return string * @return string
*/ */
public function get_rate_id( $suffix = '' ) { public function get_rate_id( $suffix = '' ) {
@ -232,25 +259,26 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Add a shipping rate. If taxes are not set they will be calculated based on cost. * Add a shipping rate. If taxes are not set they will be calculated based on cost.
* @param array $args (default: array()) *
* @param array $args Arguments (default: array()).
*/ */
public function add_rate( $args = array() ) { public function add_rate( $args = array() ) {
$args = wp_parse_args( $args, array( $args = wp_parse_args( $args, array(
'id' => $this->get_rate_id(), // ID for the rate. If not passed, this id:instance default will be used. 'id' => $this->get_rate_id(), // ID for the rate. If not passed, this id:instance default will be used.
'label' => '', // Label for the rate 'label' => '', // Label for the rate.
'cost' => '0', // Amount or array of costs (per item shipping) 'cost' => '0', // Amount or array of costs (per item shipping).
'taxes' => '', // Pass taxes, or leave empty to have it calculated for you, or 'false' to disable calculations 'taxes' => '', // Pass taxes, or leave empty to have it calculated for you, or 'false' to disable calculations.
'calc_tax' => 'per_order', // Calc tax per_order or per_item. Per item needs an array of costs 'calc_tax' => 'per_order', // Calc tax per_order or per_item. Per item needs an array of costs.
'meta_data' => array(), // Array of misc meta data to store along with this rate - key value pairs. 'meta_data' => array(), // Array of misc meta data to store along with this rate - key value pairs.
'package' => false, // Package array this rate was generated for @since 2.6.0 'package' => false, // Package array this rate was generated for @since 2.6.0.
) ); ) );
// ID and label are required // ID and label are required.
if ( ! $args['id'] || ! $args['label'] ) { if ( ! $args['id'] || ! $args['label'] ) {
return; return;
} }
// Total up the cost // Total up the cost.
$total_cost = is_array( $args['cost'] ) ? array_sum( $args['cost'] ) : $args['cost']; $total_cost = is_array( $args['cost'] ) ? array_sum( $args['cost'] ) : $args['cost'];
$taxes = $args['taxes']; $taxes = $args['taxes'];
@ -262,7 +290,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
// Round the total cost after taxes have been calculated. // Round the total cost after taxes have been calculated.
$total_cost = wc_format_decimal( $total_cost, wc_get_price_decimals() ); $total_cost = wc_format_decimal( $total_cost, wc_get_price_decimals() );
// Create rate object // Create rate object.
$rate = new WC_Shipping_Rate(); $rate = new WC_Shipping_Rate();
$rate->set_id( $args['id'] ); $rate->set_id( $args['id'] );
$rate->set_method_id( $this->id ); $rate->set_method_id( $this->id );
@ -277,7 +305,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
} }
} }
// Store package data // Store package data.
if ( $args['package'] ) { if ( $args['package'] ) {
$items_in_package = array(); $items_in_package = array();
foreach ( $args['package']['contents'] as $item ) { foreach ( $args['package']['contents'] as $item ) {
@ -292,15 +320,16 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Calc taxes per item being shipping in costs array. * Calc taxes per item being shipping in costs array.
*
* @since 2.6.0 * @since 2.6.0
* @access protected * @access protected
* @param array $costs * @param array $costs Costs.
* @return array of taxes * @return array of taxes
*/ */
protected function get_taxes_per_item( $costs ) { protected function get_taxes_per_item( $costs ) {
$taxes = array(); $taxes = array();
// If we have an array of costs we can look up each items tax class and add tax accordingly // If we have an array of costs we can look up each items tax class and add tax accordingly.
if ( is_array( $costs ) ) { if ( is_array( $costs ) ) {
$cart = WC()->cart->get_cart(); $cart = WC()->cart->get_cart();
@ -312,17 +341,17 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
$item_taxes = WC_Tax::calc_shipping_tax( $amount, WC_Tax::get_shipping_tax_rates( $cart[ $cost_key ]['data']->get_tax_class() ) ); $item_taxes = WC_Tax::calc_shipping_tax( $amount, WC_Tax::get_shipping_tax_rates( $cart[ $cost_key ]['data']->get_tax_class() ) );
// Sum the item taxes // Sum the item taxes.
foreach ( array_keys( $taxes + $item_taxes ) as $key ) { foreach ( array_keys( $taxes + $item_taxes ) as $key ) {
$taxes[ $key ] = ( isset( $item_taxes[ $key ] ) ? $item_taxes[ $key ] : 0 ) + ( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 ); $taxes[ $key ] = ( isset( $item_taxes[ $key ] ) ? $item_taxes[ $key ] : 0 ) + ( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 );
} }
} }
// Add any cost for the order - order costs are in the key 'order' // Add any cost for the order - order costs are in the key 'order'.
if ( isset( $costs['order'] ) ) { if ( isset( $costs['order'] ) ) {
$item_taxes = WC_Tax::calc_shipping_tax( $costs['order'], WC_Tax::get_shipping_tax_rates() ); $item_taxes = WC_Tax::calc_shipping_tax( $costs['order'], WC_Tax::get_shipping_tax_rates() );
// Sum the item taxes // Sum the item taxes.
foreach ( array_keys( $taxes + $item_taxes ) as $key ) { foreach ( array_keys( $taxes + $item_taxes ) as $key ) {
$taxes[ $key ] = ( isset( $item_taxes[ $key ] ) ? $item_taxes[ $key ] : 0 ) + ( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 ); $taxes[ $key ] = ( isset( $item_taxes[ $key ] ) ? $item_taxes[ $key ] : 0 ) + ( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 );
} }
@ -334,25 +363,26 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Is this method available? * Is this method available?
* @param array $package *
* @param array $package Package.
* @return bool * @return bool
*/ */
public function is_available( $package ) { public function is_available( $package ) {
$available = $this->is_enabled(); $available = $this->is_enabled();
// Country availability (legacy, for non-zone based methods) // Country availability (legacy, for non-zone based methods).
if ( ! $this->instance_id && $available ) { if ( ! $this->instance_id && $available ) {
$countries = is_array( $this->countries ) ? $this->countries : array(); $countries = is_array( $this->countries ) ? $this->countries : array();
switch ( $this->availability ) { switch ( $this->availability ) {
case 'specific' : case 'specific':
case 'including' : case 'including':
$available = in_array( $package['destination']['country'], array_intersect( $countries, array_keys( WC()->countries->get_shipping_countries() ) ) ); $available = in_array( $package['destination']['country'], array_intersect( $countries, array_keys( WC()->countries->get_shipping_countries() ) ) );
break; break;
case 'excluding' : case 'excluding':
$available = in_array( $package['destination']['country'], array_diff( array_keys( WC()->countries->get_shipping_countries() ), $countries ) ); $available = in_array( $package['destination']['country'], array_diff( array_keys( WC()->countries->get_shipping_countries() ), $countries ) );
break; break;
default : default:
$available = in_array( $package['destination']['country'], array_keys( WC()->countries->get_shipping_countries() ) ); $available = in_array( $package['destination']['country'], array_keys( WC()->countries->get_shipping_countries() ) );
break; break;
} }
@ -363,8 +393,9 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Get fee to add to shipping cost. * Get fee to add to shipping cost.
* @param string|float $fee *
* @param float $total * @param string|float $fee Fee.
* @param float $total Total.
* @return float * @return float
*/ */
public function get_fee( $fee, $total ) { public function get_fee( $fee, $total ) {
@ -379,6 +410,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Does this method have a settings page? * Does this method have a settings page?
*
* @return bool * @return bool
*/ */
public function has_settings() { public function has_settings() {
@ -387,6 +419,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Return admin options as a html string. * Return admin options as a html string.
*
* @return string * @return string
*/ */
public function get_admin_options_html() { public function get_admin_options_html() {
@ -407,33 +440,33 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
echo '<h2>' . esc_html( $this->get_method_title() ) . '</h2>'; echo '<h2>' . esc_html( $this->get_method_title() ) . '</h2>';
} }
echo wp_kses_post( wpautop( $this->get_method_description() ) ); echo wp_kses_post( wpautop( $this->get_method_description() ) );
echo $this->get_admin_options_html(); echo $this->get_admin_options_html(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
} }
/** /**
* get_option function. * Get_option function.
* *
* Gets and option from the settings API, using defaults if necessary to prevent undefined notices. * Gets and option from the settings API, using defaults if necessary to prevent undefined notices.
* *
* @param string $key * @param string $key Key.
* @param mixed $empty_value * @param mixed $empty_value Empty value.
* @return mixed The value specified for the option or a default value for the option. * @return mixed The value specified for the option or a default value for the option.
*/ */
public function get_option( $key, $empty_value = null ) { public function get_option( $key, $empty_value = null ) {
// Instance options take priority over global options // Instance options take priority over global options.
if ( $this->instance_id && array_key_exists( $key, $this->get_instance_form_fields() ) ) { if ( $this->instance_id && array_key_exists( $key, $this->get_instance_form_fields() ) ) {
return $this->get_instance_option( $key, $empty_value ); return $this->get_instance_option( $key, $empty_value );
} }
// Return global option // Return global option.
return parent::get_option( $key, $empty_value ); return parent::get_option( $key, $empty_value );
} }
/** /**
* Gets an option from the settings API, using defaults if necessary to prevent undefined notices. * Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
* *
* @param string $key * @param string $key Key.
* @param mixed $empty_value * @param mixed $empty_value Empty value.
* @return mixed The value specified for the option or a default value for the option. * @return mixed The value specified for the option or a default value for the option.
*/ */
public function get_instance_option( $key, $empty_value = null ) { public function get_instance_option( $key, $empty_value = null ) {
@ -457,6 +490,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Get settings fields for instances of this shipping method (within zones). * Get settings fields for instances of this shipping method (within zones).
* Should be overridden by shipping methods to add options. * Should be overridden by shipping methods to add options.
*
* @since 2.6.0 * @since 2.6.0
* @return array * @return array
*/ */
@ -466,6 +500,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Return the name of the option in the WP DB. * Return the name of the option in the WP DB.
*
* @since 2.6.0 * @since 2.6.0
* @return string * @return string
*/ */
@ -475,6 +510,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Initialise Settings for instances. * Initialise Settings for instances.
*
* @since 2.6.0 * @since 2.6.0
*/ */
public function init_instance_settings() { public function init_instance_settings() {
@ -490,6 +526,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
/** /**
* Processes and saves options. * Processes and saves options.
* If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out. * If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
*
* @since 2.6.0 * @since 2.6.0
* @return bool was anything saved? * @return bool was anything saved?
*/ */

View File

@ -1,13 +1,18 @@
<?php <?php
/**
* Abstract widget class
*
* @class WC_Widget
* @package WooCommerce/Abstracts
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
/** /**
* Abstract Widget Class * WC_Widget
* *
* @author WooThemes
* @category Widgets
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
* @version 2.5.0 * @version 2.5.0
* @extends WP_Widget * @extends WP_Widget
@ -69,7 +74,7 @@ abstract class WC_Widget extends WP_Widget {
/** /**
* Get cached widget. * Get cached widget.
* *
* @param array $args * @param array $args Arguments.
* @return bool true if the widget is cached otherwise false * @return bool true if the widget is cached otherwise false
*/ */
public function get_cached_widget( $args ) { public function get_cached_widget( $args ) {
@ -80,7 +85,7 @@ abstract class WC_Widget extends WP_Widget {
} }
if ( isset( $cache[ $args['widget_id'] ] ) ) { if ( isset( $cache[ $args['widget_id'] ] ) ) {
echo $cache[ $args['widget_id'] ]; echo $cache[ $args['widget_id'] ]; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
return true; return true;
} }
@ -90,8 +95,8 @@ abstract class WC_Widget extends WP_Widget {
/** /**
* Cache the widget. * Cache the widget.
* *
* @param array $args * @param array $args Arguments.
* @param string $content * @param string $content Content.
* @return string the content that was cached * @return string the content that was cached
*/ */
public function cache_widget( $args, $content ) { public function cache_widget( $args, $content ) {
@ -118,32 +123,32 @@ abstract class WC_Widget extends WP_Widget {
/** /**
* Output the html at the start of a widget. * Output the html at the start of a widget.
* *
* @param array $args * @param array $args Arguments.
* @param array $instance * @param array $instance Instance.
*/ */
public function widget_start( $args, $instance ) { public function widget_start( $args, $instance ) {
echo $args['before_widget']; echo $args['before_widget']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
if ( $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ) ) { if ( $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ) ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found, WordPress.CodeAnalysis.AssignmentInCondition.Found
echo $args['before_title'] . $title . $args['after_title']; echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
} }
} }
/** /**
* Output the html at the end of a widget. * Output the html at the end of a widget.
* *
* @param array $args * @param array $args Arguments.
*/ */
public function widget_end( $args ) { public function widget_end( $args ) {
echo $args['after_widget']; echo $args['after_widget']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
} }
/** /**
* Updates a particular instance of a widget. * Updates a particular instance of a widget.
* *
* @see WP_Widget->update * @see WP_Widget->update
* @param array $new_instance * @param array $new_instance New instance.
* @param array $old_instance * @param array $old_instance Old instance.
* @return array * @return array
*/ */
public function update( $new_instance, $old_instance ) { public function update( $new_instance, $old_instance ) {
@ -162,7 +167,7 @@ abstract class WC_Widget extends WP_Widget {
// Format the value based on settings type. // Format the value based on settings type.
switch ( $setting['type'] ) { switch ( $setting['type'] ) {
case 'number' : case 'number':
$instance[ $key ] = absint( $new_instance[ $key ] ); $instance[ $key ] = absint( $new_instance[ $key ] );
if ( isset( $setting['min'] ) && '' !== $setting['min'] ) { if ( isset( $setting['min'] ) && '' !== $setting['min'] ) {
@ -173,10 +178,10 @@ abstract class WC_Widget extends WP_Widget {
$instance[ $key ] = min( $instance[ $key ], $setting['max'] ); $instance[ $key ] = min( $instance[ $key ], $setting['max'] );
} }
break; break;
case 'textarea' : case 'textarea':
$instance[ $key ] = wp_kses( trim( wp_unslash( $new_instance[ $key ] ) ), wp_kses_allowed_html( 'post' ) ); $instance[ $key ] = wp_kses( trim( wp_unslash( $new_instance[ $key ] ) ), wp_kses_allowed_html( 'post' ) );
break; break;
case 'checkbox' : case 'checkbox':
$instance[ $key ] = empty( $new_instance[ $key ] ) ? 0 : 1; $instance[ $key ] = empty( $new_instance[ $key ] ) ? 0 : 1;
break; break;
default: default:
@ -200,7 +205,7 @@ abstract class WC_Widget extends WP_Widget {
* *
* @see WP_Widget->form * @see WP_Widget->form
* *
* @param array $instance * @param array $instance Instance.
*/ */
public function form( $instance ) { public function form( $instance ) {
@ -215,29 +220,29 @@ abstract class WC_Widget extends WP_Widget {
switch ( $setting['type'] ) { switch ( $setting['type'] ) {
case 'text' : case 'text':
?> ?>
<p> <p>
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label> <label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; ?></label><?php // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="text" value="<?php echo esc_attr( $value ); ?>" /> <input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="text" value="<?php echo esc_attr( $value ); ?>" />
</p> </p>
<?php <?php
break; break;
case 'number' : case 'number':
?> ?>
<p> <p>
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label> <label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>" /> <input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>" />
</p> </p>
<?php <?php
break; break;
case 'select' : case 'select':
?> ?>
<p> <p>
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label> <label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
<select class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>"> <select class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>">
<?php foreach ( $setting['options'] as $option_key => $option_value ) : ?> <?php foreach ( $setting['options'] as $option_key => $option_value ) : ?>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( $option_value ); ?></option> <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( $option_value ); ?></option>
<?php endforeach; ?> <?php endforeach; ?>
@ -246,11 +251,11 @@ abstract class WC_Widget extends WP_Widget {
<?php <?php
break; break;
case 'textarea' : case 'textarea':
?> ?>
<p> <p>
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label> <label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
<textarea class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" cols="20" rows="3"><?php echo esc_textarea( $value ); ?></textarea> <textarea class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" cols="20" rows="3"><?php echo esc_textarea( $value ); ?></textarea>
<?php if ( isset( $setting['desc'] ) ) : ?> <?php if ( isset( $setting['desc'] ) ) : ?>
<small><?php echo esc_html( $setting['desc'] ); ?></small> <small><?php echo esc_html( $setting['desc'] ); ?></small>
<?php endif; ?> <?php endif; ?>
@ -258,17 +263,17 @@ abstract class WC_Widget extends WP_Widget {
<?php <?php
break; break;
case 'checkbox' : case 'checkbox':
?> ?>
<p> <p>
<input class="checkbox <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="checkbox" value="1" <?php checked( $value, 1 ); ?> /> <input class="checkbox <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="checkbox" value="1" <?php checked( $value, 1 ); ?> />
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label> <label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
</p> </p>
<?php <?php
break; break;
// Default: run an action // Default: run an action.
default : default:
do_action( 'woocommerce_widget_field_' . $setting['type'], $key, $value, $setting, $instance ); do_action( 'woocommerce_widget_field_' . $setting['type'], $key, $value, $setting, $instance );
break; break;
} }
@ -328,13 +333,13 @@ abstract class WC_Widget extends WP_Widget {
} }
// All current filters. // All current filters.
if ( $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes() ) { if ( $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes() ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found, WordPress.CodeAnalysis.AssignmentInCondition.Found
foreach ( $_chosen_attributes as $name => $data ) { foreach ( $_chosen_attributes as $name => $data ) {
$filter_name = sanitize_title( str_replace( 'pa_', '', $name ) ); $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
if ( ! empty( $data['terms'] ) ) { if ( ! empty( $data['terms'] ) ) {
$link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link ); $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
} }
if ( 'or' == $data['query_type'] ) { if ( 'or' === $data['query_type'] ) {
$link = add_query_arg( 'query_type_' . $filter_name, 'or', $link ); $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
} }
} }

View File

@ -166,12 +166,14 @@ class WC_Admin_Addons {
$utm_content = 'nostorefront'; $utm_content = 'nostorefront';
} }
$url = add_query_arg( array( $url = add_query_arg(
array(
'utm_source' => 'addons', 'utm_source' => 'addons',
'utm_medium' => 'product', 'utm_medium' => 'product',
'utm_campaign' => 'woocommerceplugin', 'utm_campaign' => 'woocommerceplugin',
'utm_content' => $utm_content, 'utm_content' => $utm_content,
), $url ); ), $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(
array(
'install-addon' => 'woocommerce-services', '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(
$defaults['logos'], array(
array( array(
'link' => WC()->plugin_url() . '/assets/images/wcs-canada-post-logo.jpg', 'link' => WC()->plugin_url() . '/assets/images/wcs-canada-post-logo.jpg',
'alt' => 'Canada Post logo', '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(
$defaults['logos'], array(
array( array(
'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png', 'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
'alt' => 'USPS logo', 'alt' => 'USPS logo',
), ),
) ), )
),
); );
break; break;
default: default:
@ -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(
array(
'singular' => 'key', 'singular' => 'key',
'plural' => 'keys', 'plural' => 'keys',
'ajax' => false, '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(
wp_nonce_url(
add_query_arg(
array(
'revoke-key' => $key['key_id'], 'revoke-key' => $key['key_id'],
), admin_url( 'admin.php?page=wc-settings&tab=api&section=keys' ) ), 'revoke' ) ) . '">' . esc_html__( 'Revoke', 'woocommerce' ) . '</a>', ), 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(
array(
'total_items' => $count, 'total_items' => $count,
'per_page' => $per_page, 'per_page' => $per_page,
'total_pages' => ceil( $count / $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(
'per_page', array(
'default' => 10, 'default' => 10,
'option' => 'woocommerce_keys_per_page', '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(
"SELECT key_id, user_id, description, permissions, truncated_key, last_access
FROM {$wpdb->prefix}woocommerce_api_keys FROM {$wpdb->prefix}woocommerce_api_keys
WHERE key_id = %d WHERE key_id = %d",
", $key_id ), ARRAY_A ); $key_id
), ARRAY_A
);
if ( is_null( $key ) ) { if ( is_null( $key ) ) {
return $empty; return $empty;

View File

@ -14,10 +14,10 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Assets', false ) ) : if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
/** /**
* WC_Admin_Assets Class. * WC_Admin_Assets Class.
*/ */
class WC_Admin_Assets { class WC_Admin_Assets {
/** /**
* Hook in tabs. * Hook in tabs.
@ -35,12 +35,11 @@ class WC_Admin_Assets {
$screen = get_current_screen(); $screen = get_current_screen();
$screen_id = $screen ? $screen->id : ''; $screen_id = $screen ? $screen->id : '';
$jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.11.4';
// Register admin styles // 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_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( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
wp_register_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_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_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' ); wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' );
@ -113,7 +112,10 @@ class WC_Admin_Assets {
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' ); 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( '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_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(
'wc-enhanced-select',
'wc_enhanced_select_params',
array(
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
'i18n_ajax_error' => _x( 'Loading failed', '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_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
@ -128,18 +130,27 @@ class WC_Admin_Assets {
'search_products_nonce' => wp_create_nonce( 'search-products' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ), 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
'search_categories_nonce' => wp_create_nonce( 'search-categories' ), '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' ); wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
wp_localize_script( 'accounting', 'accounting_params', array( wp_localize_script(
'accounting',
'accounting_params',
array(
'mon_decimal_point' => wc_get_price_decimal_separator(), 'mon_decimal_point' => wc_get_price_decimal_separator(),
) ); )
);
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-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( wp_localize_script(
'wc-orders',
'wc_orders_params',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_url' => admin_url( 'admin-ajax.php' ),
'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ), 'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
) ); )
);
// WooCommerce admin pages. // WooCommerce admin pages.
if ( in_array( $screen_id, wc_get_screen_ids() ) ) { if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
@ -221,9 +232,9 @@ class WC_Admin_Assets {
'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ), 'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ), 'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ), 'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
'i18n_variation_added' => esc_js( __( "variation added", 'woocommerce' ) ), 'i18n_variation_added' => esc_js( __( 'variation added', 'woocommerce' ) ),
'i18n_variations_added' => esc_js( __( "variations added", 'woocommerce' ) ), 'i18n_variations_added' => esc_js( __( 'variations added', 'woocommerce' ) ),
'i18n_no_variations_added' => esc_js( __( "No 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_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_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_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
@ -239,14 +250,18 @@ class WC_Admin_Assets {
$default_location = wc_get_customer_default_location(); $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_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( 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() ) ), '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' ), 'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '', 'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '', 'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ), 'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ), 'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
) ); )
);
} }
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) { 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 ); 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 );
@ -392,7 +407,7 @@ class WC_Admin_Assets {
); );
} }
} }
} }
endif; endif;

View File

@ -39,13 +39,13 @@ 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;
} }
@ -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,15 +314,16 @@ 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>
<?php
switch ( $tax->attribute_orderby ) { switch ( $tax->attribute_orderby ) {
case 'name' : case 'name':
esc_html_e( 'Name', 'woocommerce' ); esc_html_e( 'Name', 'woocommerce' );
break; break;
case 'name_num' : case 'name_num':
esc_html_e( 'Name (numeric)', 'woocommerce' ); esc_html_e( 'Name (numeric)', 'woocommerce' );
break; break;
case 'id' : case 'id':
esc_html_e( 'Term ID', 'woocommerce' ); esc_html_e( 'Term ID', 'woocommerce' );
break; break;
default: default:
@ -342,10 +344,10 @@ class WC_Admin_Attributes {
} }
switch ( $tax->attribute_orderby ) { switch ( $tax->attribute_orderby ) {
case 'name_num' : case 'name_num':
usort( $terms, '_wc_get_product_terms_name_num_usort_callback' ); usort( $terms, '_wc_get_product_terms_name_num_usort_callback' );
break; break;
case 'parent' : case 'parent':
usort( $terms, '_wc_get_product_terms_parent_usort_callback' ); usort( $terms, '_wc_get_product_terms_parent_usort_callback' );
break; break;
} }
@ -366,7 +368,11 @@ class WC_Admin_Attributes {
<?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,10 +14,10 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Customize', false ) ) : if ( ! class_exists( 'WC_Admin_Customize', false ) ) :
/** /**
* WC_Admin_Customize Class. * WC_Admin_Customize Class.
*/ */
class WC_Admin_Customize { class WC_Admin_Customize {
/** /**
* Initialize customize actions. * Initialize customize actions.
@ -91,7 +91,7 @@ class WC_Admin_Customize {
return $items; return $items;
} }
} }
endif; endif;

View File

@ -14,10 +14,10 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
/** /**
* WC_Admin_Dashboard Class. * WC_Admin_Dashboard Class.
*/ */
class WC_Admin_Dashboard { class WC_Admin_Dashboard {
/** /**
* Hook in tabs. * Hook in tabs.
@ -58,6 +58,7 @@ class WC_Admin_Dashboard {
/** /**
* Get top seller from DB. * Get top seller from DB.
*
* @return object * @return object
*/ */
private function get_top_seller() { private function get_top_seller() {
@ -75,19 +76,20 @@ class WC_Admin_Dashboard {
$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() { private function get_sales_report_data() {
include_once( dirname( __FILE__ ) . '/reports/class-wc-report-sales-by-date.php' ); 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' ) ) );
@ -102,7 +104,7 @@ class WC_Admin_Dashboard {
* 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();
@ -203,7 +205,9 @@ class WC_Admin_Dashboard {
$transient_name = 'wc_low_stock_count'; $transient_name = 'wc_low_stock_count';
if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) { if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) {
$query_from = apply_filters( 'woocommerce_report_low_in_stock_query_from', "FROM {$wpdb->posts} as posts $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 postmeta ON posts.ID = postmeta.post_id
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
WHERE 1=1 WHERE 1=1
@ -211,8 +215,8 @@ class WC_Admin_Dashboard {
AND posts.post_status = 'publish' AND posts.post_status = 'publish'
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' 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) <= '{$stock}'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}' 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};" ) ); $lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 ); set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
} }
@ -220,15 +224,17 @@ class WC_Admin_Dashboard {
$transient_name = 'wc_outofstock_count'; $transient_name = 'wc_outofstock_count';
if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) { if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) {
$query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts $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 postmeta ON posts.ID = postmeta.post_id
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
WHERE 1=1 WHERE 1=1
AND posts.post_type IN ( 'product', 'product_variation' ) AND posts.post_type IN ( 'product', 'product_variation' )
AND posts.post_status = 'publish' AND posts.post_status = 'publish'
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}' 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};" ) ); $outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 ); set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 );
} }
@ -264,7 +270,9 @@ class WC_Admin_Dashboard {
public function recent_reviews() { public function recent_reviews() {
global $wpdb; global $wpdb;
$query_from = apply_filters( 'woocommerce_report_recent_reviews_query_from', "FROM {$wpdb->comments} comments $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) LEFT JOIN {$wpdb->posts} posts ON (comments.comment_post_ID = posts.ID)
WHERE comments.comment_approved = '1' WHERE comments.comment_approved = '1'
AND comments.comment_type = '' AND comments.comment_type = ''
@ -272,13 +280,12 @@ class WC_Admin_Dashboard {
AND posts.post_type = 'product' AND posts.post_type = 'product'
AND comments.comment_parent = 0 AND comments.comment_parent = 0
ORDER BY comments.comment_date_gmt DESC ORDER BY comments.comment_date_gmt DESC
LIMIT 5 LIMIT 5"
" ); );
$comments = $wpdb->get_results( " $comments = $wpdb->get_results(
SELECT posts.ID, posts.post_title, comments.comment_author, comments.comment_ID, comments.comment_content "SELECT posts.ID, posts.post_title, comments.comment_author, comments.comment_ID, comments.comment_content {$query_from};"
{$query_from}; );
" );
if ( $comments ) { if ( $comments ) {
echo '<ul>'; echo '<ul>';
@ -318,11 +325,13 @@ class WC_Admin_Dashboard {
$blogs = get_blogs_of_user( $user->ID ); $blogs = get_blogs_of_user( $user->ID );
$blog_ids = wp_list_pluck( $blogs, 'userblog_id' ); $blog_ids = wp_list_pluck( $blogs, 'userblog_id' );
wp_localize_script( 'wc-network-orders', 'woocommerce_network_orders', array( wp_localize_script(
'wc-network-orders', 'woocommerce_network_orders', array(
'nonce' => wp_create_nonce( 'wp_rest' ), 'nonce' => wp_create_nonce( 'wp_rest' ),
'sites' => array_values( $blog_ids ), 'sites' => array_values( $blog_ids ),
'order_endpoint' => get_rest_url( null, 'wc/v2/orders/network' ), 'order_endpoint' => get_rest_url( null, 'wc/v2/orders/network' ),
) ); )
);
?> ?>
<div class="post-type-shop_order"> <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">
@ -369,7 +378,7 @@ class WC_Admin_Dashboard {
<?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(
'wc-product-export',
'wc_product_export_params',
array(
'export_nonce' => wp_create_nonce( 'wc-product-export' ), '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(
array(
'step' => 'done', 'step' => 'done',
'percentage' => 100, 'percentage' => 100,
'url' => add_query_arg( $query_args, admin_url( 'edit.php?post_type=product&page=product_exporter' ) ), '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(
array(
'step' => ++$step, 'step' => ++$step,
'percentage' => $exporter->get_percent_complete(), 'percentage' => $exporter->get_percent_complete(),
'columns' => $exporter->get_column_names(), 'columns' => $exporter->get_column_names(),
) ); )
);
} }
} }
} }

View File

@ -36,7 +36,8 @@ class WC_Admin_Help {
return; return;
} }
$screen->add_help_tab( array( $screen->add_help_tab(
array(
'id' => 'woocommerce_support_tab', 'id' => 'woocommerce_support_tab',
'title' => __( 'Help &amp; Support', 'woocommerce' ), 'title' => __( 'Help &amp; Support', 'woocommerce' ),
'content' => 'content' =>
@ -54,9 +55,11 @@ class WC_Admin_Help {
) . '</p>' . ) . '</p>' .
'<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</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>', '<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(
array(
'id' => 'woocommerce_bugs_tab', 'id' => 'woocommerce_bugs_tab',
'title' => __( 'Found a bug?', 'woocommerce' ), 'title' => __( 'Found a bug?', 'woocommerce' ),
'content' => 'content' =>
@ -65,18 +68,22 @@ class WC_Admin_Help {
'<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>' . 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>', '<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(
array(
'id' => 'woocommerce_education_tab', 'id' => 'woocommerce_education_tab',
'title' => __( 'Education', 'woocommerce' ), 'title' => __( 'Education', 'woocommerce' ),
'content' => 'content' =>
'<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' . '<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' .
'<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>' . __( '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>', '<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(
array(
'id' => 'woocommerce_onboard_tab', 'id' => 'woocommerce_onboard_tab',
'title' => __( 'Setup wizard', 'woocommerce' ), 'title' => __( 'Setup wizard', 'woocommerce' ),
'content' => 'content' =>
@ -84,7 +91,8 @@ class WC_Admin_Help {
'<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '</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>', '<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();
@ -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(
array(
'name' => $attribute_name, 'name' => $attribute_name,
'slug' => $attribute_name, 'slug' => $attribute_name,
'type' => 'select', 'type' => 'select',
'order_by' => 'menu_order', 'order_by' => 'menu_order',
'has_archives' => false, '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(
'woocommerce_taxonomy_args_' . $term['domain'], array(
'hierarchical' => true, 'hierarchical' => true,
'show_ui' => false, 'show_ui' => false,
'query_var' => true, 'query_var' => true,
'rewrite' => false, '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,19 +232,20 @@ 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(
array(
'position' => 'done', 'position' => 'done',
'percentage' => 100, 'percentage' => 100,
'url' => add_query_arg( array( 'nonce' => wp_create_nonce( 'product-csv' ) ), admin_url( 'edit.php?post_type=product&page=product_importer&step=done' ) ), 'url' => add_query_arg( array( 'nonce' => wp_create_nonce( 'product-csv' ) ), admin_url( 'edit.php?post_type=product&page=product_importer&step=done' ) ),
@ -248,16 +253,19 @@ class WC_Admin_Importers {
'failed' => count( $results['failed'] ), 'failed' => count( $results['failed'] ),
'updated' => count( $results['updated'] ), 'updated' => count( $results['updated'] ),
'skipped' => count( $results['skipped'] ), 'skipped' => count( $results['skipped'] ),
) ); )
);
} else { } else {
wp_send_json_success( array( wp_send_json_success(
array(
'position' => $importer->get_file_position(), 'position' => $importer->get_file_position(),
'percentage' => $percent_complete, 'percentage' => $percent_complete,
'imported' => count( $results['imported'] ), 'imported' => count( $results['imported'] ),
'failed' => count( $results['failed'] ), 'failed' => count( $results['failed'] ),
'updated' => count( $results['updated'] ), 'updated' => count( $results['updated'] ),
'skipped' => count( $results['skipped'] ), '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(
array(
'singular' => 'log', 'singular' => 'log',
'plural' => 'logs', 'plural' => 'logs',
'ajax' => false, '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
} }
@ -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(
mysql2date(
get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),
$log['timestamp'] $log['timestamp']
) ); )
);
} }
/** /**
@ -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(
array(
'total_items' => $total_items, 'total_items' => $total_items,
'per_page' => $per_page, 'per_page' => $per_page,
'total_pages' => ceil( $total_items / $per_page ), 'total_pages' => ceil( $total_items / $per_page ),
) ); )
);
} }
/** /**

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(
array(
'parent' => 'site-name', 'parent' => 'site-name',
'id' => 'view-store', 'id' => 'view-store',
'title' => __( 'Visit Store', 'woocommerce' ), 'title' => __( 'Visit Store', 'woocommerce' ),
'href' => wc_get_page_permalink( 'shop' ), 'href' => wc_get_page_permalink( 'shop' ),
) ); )
);
} }
} }

View File

@ -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 ) {

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,6 +113,7 @@ 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
*/ */
@ -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
} }

View File

@ -33,7 +33,7 @@ class WC_Admin_Pointers {
} }
switch ( $screen->id ) { switch ( $screen->id ) {
case 'product' : case 'product':
$this->create_product_tutorial(); $this->create_product_tutorial();
break; break;
} }
@ -50,7 +50,7 @@ class WC_Admin_Pointers {
$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',
@ -66,7 +66,7 @@ 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(
@ -79,10 +79,10 @@ 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(
@ -98,10 +98,10 @@ 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(
@ -114,10 +114,10 @@ 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(
@ -130,10 +130,10 @@ 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(
@ -146,10 +146,10 @@ 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(
@ -162,7 +162,7 @@ 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>' .
@ -174,7 +174,7 @@ 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>' .
@ -186,7 +186,7 @@ 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>' .
@ -198,7 +198,7 @@ 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>' .
@ -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.
@ -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;
} }
@ -238,11 +238,13 @@ class WC_Admin_Post_Types {
return; return;
} }
$shipping_class = get_terms( 'product_shipping_class', array( $shipping_class = get_terms(
'product_shipping_class', array(
'hide_empty' => false, '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(
'product_shipping_class', array(
'hide_empty' => false, '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';
} }
/** /**
@ -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,10 +14,10 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Admin_Profile', false ) ) : if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
/** /**
* WC_Admin_Profile Class. * WC_Admin_Profile Class.
*/ */
class WC_Admin_Profile { class WC_Admin_Profile {
/** /**
* Hook in tabs. * Hook in tabs.
@ -36,7 +36,8 @@ class WC_Admin_Profile {
* @return array Fields to display which are filtered through woocommerce_customer_meta_fields before being returned * @return array Fields to display which are filtered through woocommerce_customer_meta_fields before being returned
*/ */
public function get_customer_meta_fields() { public function get_customer_meta_fields() {
$show_fields = apply_filters('woocommerce_customer_meta_fields', array( $show_fields = apply_filters(
'woocommerce_customer_meta_fields', array(
'billing' => array( 'billing' => array(
'title' => __( 'Customer billing address', 'woocommerce' ), 'title' => __( 'Customer billing address', 'woocommerce' ),
'fields' => array( 'fields' => array(
@ -142,7 +143,8 @@ class WC_Admin_Profile {
), ),
), ),
), ),
) ); )
);
return $show_fields; return $show_fields;
} }
@ -162,17 +164,18 @@ class WC_Admin_Profile {
?> ?>
<h2><?php echo $fieldset['title']; ?></h2> <h2><?php echo $fieldset['title']; ?></h2>
<table class="form-table" id="<?php echo esc_attr( 'fieldset-' . $fieldset_key ); ?>"> <table class="form-table" id="<?php echo esc_attr( 'fieldset-' . $fieldset_key ); ?>">
<?php <?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
foreach ( $fieldset['fields'] as $key => $field ) :
?>
<tr> <tr>
<th><label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label></th> <th>
<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
</th>
<td> <td>
<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> <?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;"> <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?>" style="width: 25em;">
<?php <?php
$selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); $selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
foreach ( $field['options'] as $option_key => $option_value ) : ?> 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> <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_attr( $option_value ); ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
@ -187,9 +190,7 @@ class WC_Admin_Profile {
<span class="description"><?php echo wp_kses_post( $field['description'] ); ?></span> <span class="description"><?php echo wp_kses_post( $field['description'] ); ?></span>
</td> </td>
</tr> </tr>
<?php <?php endforeach; ?>
endforeach;
?>
</table> </table>
<?php <?php
endforeach; endforeach;
@ -236,7 +237,7 @@ class WC_Admin_Profile {
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';
} }
/** /**
@ -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,7 +88,8 @@ 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(
array(
'twentyseventeen', 'twentyseventeen',
'twentysixteen', 'twentysixteen',
'twentyfifteen', 'twentyfifteen',
@ -97,7 +98,8 @@ class WC_Admin_Setup_Wizard {
'twentyeleven', 'twentyeleven',
'twentytwelve', 'twentytwelve',
'twentyten', 'twentyten',
) ); )
);
} }
/** /**
@ -185,7 +187,10 @@ 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(
'wc-enhanced-select',
'wc_enhanced_select_params',
array(
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
'i18n_ajax_error' => _x( 'Loading failed', '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_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
@ -199,14 +204,19 @@ class WC_Admin_Setup_Wizard {
'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_url' => admin_url( 'admin-ajax.php' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ),
'search_customers_nonce' => wp_create_nonce( 'search-customers' ), '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(
'wc-setup',
'wc_setup_params',
array(
'pending_jetpack_install' => $pending_jetpack ? 'yes' : 'no', '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(
$this->deferred_actions,
array(
'func' => array( 'WC_Install', 'background_installer' ), 'func' => array( 'WC_Install', 'background_installer' ),
'args' => array( $plugin_id, $plugin_info ), '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(
$this->deferred_actions,
array(
'func' => array( 'WC_Install', 'theme_background_installer' ), 'func' => array( 'WC_Install', 'theme_background_installer' ),
'args' => array( $theme_id ), '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(
'jetpack',
array(
'file' => 'jetpack/jetpack.php', 'file' => 'jetpack/jetpack.php',
'name' => __( 'Jetpack', 'woocommerce' ), 'name' => __( 'Jetpack', 'woocommerce' ),
'repo-slug' => 'jetpack', '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(
'woocommerce-services',
array(
'file' => 'woocommerce-services/woocommerce-services.php', 'file' => 'woocommerce-services/woocommerce-services.php',
'name' => __( 'WooCommerce Services', 'woocommerce' ), 'name' => __( 'WooCommerce Services', 'woocommerce' ),
'repo-slug' => 'woocommerce-services', '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 ( isset( $locale_info[ $country_code ] ) ) {
$dimension_unit = $locale_info[ $country_code ]['dimension_unit']; if ( ! $weight_unit && isset( $locale_info[ $country_code ] ) ) {
$weight_unit = $locale_info[ $country_code ]['weight_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(
wp_kses(
__( '<strong>Weight unit</strong>—used to calculate shipping rates, and more.', 'woocommerce' ), __( '<strong>Weight unit</strong>—used to calculate shipping rates, and more.', 'woocommerce' ),
array( 'strong' => array() ) 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(
wp_kses(
__( '<strong>Dimension unit</strong>—helps for accurate package selection.', 'woocommerce' ), __( '<strong>Dimension unit</strong>—helps for accurate package selection.', 'woocommerce' ),
array( 'strong' => array() ) 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,29 +228,31 @@ 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(
'theme_information',
array(
'slug' => $theme->get_stylesheet(), 'slug' => $theme->get_stylesheet(),
'fields' => array( 'fields' => array(
'sections' => false, 'sections' => false,
'tags' => 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' );
@ -251,11 +260,16 @@ class WC_Admin_Status {
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

@ -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
}); });
@ -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 */

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(
array(
'singular' => 'webhook', 'singular' => 'webhook',
'plural' => 'webhooks', 'plural' => 'webhooks',
'ajax' => false, '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(
wp_nonce_url(
add_query_arg(
array(
'delete' => $webhook->get_id(), 'delete' => $webhook->get_id(),
), admin_url( 'admin.php?page=wc-settings&tab=api&section=webhooks' ) ), 'delete-webhook' ) ) . '">' . esc_html__( 'Delete permanently', 'woocommerce' ) . '</a>', ), 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(
$text, '', '', false,
array(
'id' => 'search-submit', '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(
array(
'total_items' => $total_items, 'total_items' => $total_items,
'per_page' => $per_page, 'per_page' => $per_page,
'total_pages' => ceil( $total_items / $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(
'per_page',
array(
'default' => 10, 'default' => 10,
'option' => 'woocommerce_webhooks_per_page', '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,24 +95,24 @@ 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' );
@ -200,7 +200,7 @@ class WC_Admin {
// 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
@ -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(
array(
'is_active' => $jetpack_active ? 'yes' : 'no', 'is_active' => $jetpack_active ? 'yes' : 'no',
) ); )
);
} }
} }

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(
'oauth/migrate',
array(
'body' => array( 'body' => array(
'home_url' => home_url(), 'home_url' => home_url(),
'master_key' => $master_key, '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(
'oauth/access_token',
array(
'body' => array( 'body' => array(
'request_token' => $request_token, 'request_token' => $request_token,
'home_url' => home_url(), 'home_url' => home_url(),
'migrate' => true, '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(
'auth',
array(
'access_token' => $access_token['access_token'], 'access_token' => $access_token['access_token'],
'access_token_secret' => $access_token['access_token_secret'], 'access_token_secret' => $access_token['access_token_secret'],
'site_id' => $access_token['site_id'], 'site_id' => $access_token['site_id'],
'user_id' => null, // Set this later 'user_id' => null, // Set this later
'updated' => time(), '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(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
include( WC_Helper::get_view_filename( 'html-helper-compat.php' ) ); );
include WC_Helper::get_view_filename( 'html-helper-compat.php' );
} }
} }

View File

@ -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(
add_query_arg(
array(
'product_id' => absint( $product_id ), 'product_id' => absint( $product_id ),
), 'info' ), array( 'authenticated' => true ) ); ), '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

@ -177,10 +177,12 @@ class WC_Helper_Updater {
'errors' => array(), 'errors' => array(),
); );
$request = WC_Helper_API::post( 'update-check', array( $request = WC_Helper_API::post(
'update-check', array(
'body' => json_encode( array( 'products' => $payload ) ), 'body' => json_encode( array( 'products' => $payload ) ),
'authenticated' => true, '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';

View File

@ -57,31 +57,37 @@ class WC_Helper {
// No active connection. // No active connection.
if ( empty( $auth['access_token'] ) ) { if ( empty( $auth['access_token'] ) ) {
$connect_url = add_query_arg( array( $connect_url = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'wc-helper-connect' => 1, 'wc-helper-connect' => 1,
'wc-helper-nonce' => wp_create_nonce( 'connect' ), 'wc-helper-nonce' => wp_create_nonce( 'connect' ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
include( self::get_view_filename( 'html-oauth-start.php' ) ); include self::get_view_filename( 'html-oauth-start.php' );
return; return;
} }
$disconnect_url = add_query_arg( array( $disconnect_url = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'wc-helper-disconnect' => 1, 'wc-helper-disconnect' => 1,
'wc-helper-nonce' => wp_create_nonce( 'disconnect' ), 'wc-helper-nonce' => wp_create_nonce( 'disconnect' ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
$current_filter = self::get_current_filter(); $current_filter = self::get_current_filter();
$refresh_url = add_query_arg( array( $refresh_url = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => $current_filter, 'filter' => $current_filter,
'wc-helper-refresh' => 1, 'wc-helper-refresh' => 1,
'wc-helper-nonce' => wp_create_nonce( 'refresh' ), 'wc-helper-nonce' => wp_create_nonce( 'refresh' ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
// Installed plugins and themes, with or without an active subscription. // Installed plugins and themes, with or without an active subscription.
$woo_plugins = self::get_local_woo_plugins(); $woo_plugins = self::get_local_woo_plugins();
@ -95,7 +101,8 @@ class WC_Helper {
foreach ( $subscriptions as &$subscription ) { foreach ( $subscriptions as &$subscription ) {
$subscription['active'] = in_array( $site_id, $subscription['connections'] ); $subscription['active'] = in_array( $site_id, $subscription['connections'] );
$subscription['activate_url'] = add_query_arg( array( $subscription['activate_url'] = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => $current_filter, 'filter' => $current_filter,
@ -103,9 +110,11 @@ class WC_Helper {
'wc-helper-product-key' => $subscription['product_key'], 'wc-helper-product-key' => $subscription['product_key'],
'wc-helper-product-id' => $subscription['product_id'], 'wc-helper-product-id' => $subscription['product_id'],
'wc-helper-nonce' => wp_create_nonce( 'activate:' . $subscription['product_key'] ), 'wc-helper-nonce' => wp_create_nonce( 'activate:' . $subscription['product_key'] ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
$subscription['deactivate_url'] = add_query_arg( array( $subscription['deactivate_url'] = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => $current_filter, 'filter' => $current_filter,
@ -113,7 +122,8 @@ class WC_Helper {
'wc-helper-product-key' => $subscription['product_key'], 'wc-helper-product-key' => $subscription['product_key'],
'wc-helper-product-id' => $subscription['product_id'], 'wc-helper-product-id' => $subscription['product_id'],
'wc-helper-nonce' => wp_create_nonce( 'deactivate:' . $subscription['product_key'] ), 'wc-helper-nonce' => wp_create_nonce( 'deactivate:' . $subscription['product_key'] ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
$subscription['local'] = array( $subscription['local'] = array(
'installed' => false, 'installed' => false,
@ -315,7 +325,7 @@ class WC_Helper {
self::_filter( $subscriptions, self::get_current_filter() ); self::_filter( $subscriptions, self::get_current_filter() );
// We have an active connection. // We have an active connection.
include( self::get_view_filename( 'html-main.php' ) ); include self::get_view_filename( 'html-main.php' );
return; return;
} }
@ -459,8 +469,10 @@ class WC_Helper {
$notices[] = array( $notices[] = array(
'type' => 'updated', 'type' => 'updated',
/* translators: %s: product name */ /* translators: %s: product name */
'message' => sprintf( __( '%s activated successfully. You will now receive updates for this product.', 'woocommerce' ), 'message' => sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), __( '%s activated successfully. You will now receive updates for this product.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>'
),
); );
break; break;
@ -469,8 +481,10 @@ class WC_Helper {
$notices[] = array( $notices[] = array(
'type' => 'error', 'type' => 'error',
/* translators: %s: product name */ /* translators: %s: product name */
'message' => sprintf( __( 'An error has occurred when activating %s. Please try again later.', 'woocommerce' ), 'message' => sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), __( 'An error has occurred when activating %s. Please try again later.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>'
),
); );
break; break;
@ -479,22 +493,28 @@ class WC_Helper {
$local = self::_get_local_from_product_id( absint( $_GET['wc-helper-product-id'] ) ); $local = self::_get_local_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
/* translators: %s: product name */ /* translators: %s: product name */
$message = sprintf( __( 'Subscription for %s deactivated successfully. You will no longer receive updates for this product.', 'woocommerce' ), $message = sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ); __( 'Subscription for %s deactivated successfully. You will no longer receive updates for this product.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>'
);
if ( $local && is_plugin_active( $local['_filename'] ) && current_user_can( 'activate_plugins' ) ) { if ( $local && is_plugin_active( $local['_filename'] ) && current_user_can( 'activate_plugins' ) ) {
$deactivate_plugin_url = add_query_arg( array( $deactivate_plugin_url = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => self::get_current_filter(), 'filter' => self::get_current_filter(),
'wc-helper-deactivate-plugin' => 1, 'wc-helper-deactivate-plugin' => 1,
'wc-helper-product-id' => $subscription['product_id'], 'wc-helper-product-id' => $subscription['product_id'],
'wc-helper-nonce' => wp_create_nonce( 'deactivate-plugin:' . $subscription['product_id'] ), 'wc-helper-nonce' => wp_create_nonce( 'deactivate-plugin:' . $subscription['product_id'] ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
/* translators: %1$s: product name, %2$s: deactivate url */ /* translators: %1$s: product name, %2$s: deactivate url */
$message = sprintf( __( 'Subscription for %1$s deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactivate the plugin as well.', 'woocommerce' ), $message = sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', esc_url( $deactivate_plugin_url ) ); __( 'Subscription for %1$s deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactivate the plugin as well.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', esc_url( $deactivate_plugin_url )
);
} }
$notices[] = array( $notices[] = array(
@ -508,8 +528,10 @@ class WC_Helper {
$notices[] = array( $notices[] = array(
'type' => 'error', 'type' => 'error',
/* translators: %s: product name */ /* translators: %s: product name */
'message' => sprintf( __( 'An error has occurred when deactivating the subscription for %s. Please try again later.', 'woocommerce' ), 'message' => sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), __( 'An error has occurred when deactivating the subscription for %s. Please try again later.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>'
),
); );
break; break;
@ -518,8 +540,10 @@ class WC_Helper {
$notices[] = array( $notices[] = array(
'type' => 'updated', 'type' => 'updated',
/* translators: %s: product name */ /* translators: %s: product name */
'message' => sprintf( __( 'The extension %s has been deactivated successfully.', 'woocommerce' ), 'message' => sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ), __( 'The extension %s has been deactivated successfully.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>'
),
); );
break; break;
@ -528,8 +552,10 @@ class WC_Helper {
$notices[] = array( $notices[] = array(
'type' => 'error', 'type' => 'error',
/* translators: %1$s: product name, %2$s: plugins screen url */ /* translators: %1$s: product name, %2$s: plugins screen url */
'message' => sprintf( __( 'An error has occurred when deactivating the extension %1$s. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', 'woocommerce' ), 'message' => sprintf(
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', admin_url( 'plugins.php' ) ), __( 'An error has occurred when deactivating the extension %1$s. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', admin_url( 'plugins.php' )
),
); );
break; break;
@ -610,19 +636,23 @@ class WC_Helper {
wp_die( 'Could not verify nonce' ); wp_die( 'Could not verify nonce' );
} }
$redirect_uri = add_query_arg( array( $redirect_uri = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'wc-helper-return' => 1, 'wc-helper-return' => 1,
'wc-helper-nonce' => wp_create_nonce( 'connect' ), 'wc-helper-nonce' => wp_create_nonce( 'connect' ),
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
$request = WC_Helper_API::post( 'oauth/request_token', array( $request = WC_Helper_API::post(
'oauth/request_token', array(
'body' => array( 'body' => array(
'home_url' => home_url(), 'home_url' => home_url(),
'redirect_uri' => $redirect_uri, 'redirect_uri' => $redirect_uri,
), ),
) ); )
);
$code = wp_remote_retrieve_response_code( $request ); $code = wp_remote_retrieve_response_code( $request );
@ -637,11 +667,13 @@ class WC_Helper {
wp_die( 'Something went wrong' ); wp_die( 'Something went wrong' );
} }
$connect_url = add_query_arg( array( $connect_url = add_query_arg(
array(
'home_url' => rawurlencode( home_url() ), 'home_url' => rawurlencode( home_url() ),
'redirect_uri' => rawurlencode( $redirect_uri ), 'redirect_uri' => rawurlencode( $redirect_uri ),
'secret' => rawurlencode( $secret ), 'secret' => rawurlencode( $secret ),
), WC_Helper_API::url( 'oauth/authorize' ) ); ), WC_Helper_API::url( 'oauth/authorize' )
);
wp_redirect( esc_url_raw( $connect_url ) ); wp_redirect( esc_url_raw( $connect_url ) );
die(); die();
@ -669,12 +701,14 @@ class WC_Helper {
} }
// Obtain an access token. // Obtain an access token.
$request = WC_Helper_API::post( 'oauth/access_token', array( $request = WC_Helper_API::post(
'oauth/access_token', array(
'body' => array( 'body' => array(
'request_token' => $_GET['request_token'], 'request_token' => $_GET['request_token'],
'home_url' => home_url(), 'home_url' => home_url(),
), ),
) ); )
);
$code = wp_remote_retrieve_response_code( $request ); $code = wp_remote_retrieve_response_code( $request );
@ -689,13 +723,15 @@ class WC_Helper {
wp_die( 'Something went wrong' ); wp_die( 'Something went wrong' );
} }
WC_Helper_Options::update( 'auth', array( WC_Helper_Options::update(
'auth', array(
'access_token' => $access_token['access_token'], 'access_token' => $access_token['access_token'],
'access_token_secret' => $access_token['access_token_secret'], 'access_token_secret' => $access_token['access_token_secret'],
'site_id' => $access_token['site_id'], 'site_id' => $access_token['site_id'],
'user_id' => get_current_user_id(), 'user_id' => get_current_user_id(),
'updated' => time(), 'updated' => time(),
) ); )
);
// Obtain the connected user info. // Obtain the connected user info.
if ( ! self::_flush_authentication_cache() ) { if ( ! self::_flush_authentication_cache() ) {
@ -712,11 +748,15 @@ class WC_Helper {
WC_Tracker::send_tracking_data( true ); WC_Tracker::send_tracking_data( true );
} }
wp_safe_redirect( add_query_arg( array( wp_safe_redirect(
add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'wc-helper-status' => 'helper-connected', 'wc-helper-status' => 'helper-connected',
), admin_url( 'admin.php' ) ) ); ), admin_url( 'admin.php' )
)
);
die(); die();
} }
@ -729,15 +769,19 @@ class WC_Helper {
wp_die( 'Could not verify nonce' ); wp_die( 'Could not verify nonce' );
} }
$redirect_uri = add_query_arg( array( $redirect_uri = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'wc-helper-status' => 'helper-disconnected', 'wc-helper-status' => 'helper-disconnected',
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
WC_Helper_API::post( 'oauth/invalidate_token', array( WC_Helper_API::post(
'oauth/invalidate_token', array(
'authenticated' => true, 'authenticated' => true,
) ); )
);
WC_Helper_Options::update( 'auth', array() ); WC_Helper_Options::update( 'auth', array() );
WC_Helper_Options::update( 'auth_user_data', array() ); WC_Helper_Options::update( 'auth_user_data', array() );
@ -761,12 +805,14 @@ class WC_Helper {
wp_die( 'Could not verify nonce' ); wp_die( 'Could not verify nonce' );
} }
$redirect_uri = add_query_arg( array( $redirect_uri = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => self::get_current_filter(), 'filter' => self::get_current_filter(),
'wc-helper-status' => 'helper-refreshed', 'wc-helper-status' => 'helper-refreshed',
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
self::_flush_authentication_cache(); self::_flush_authentication_cache();
self::_flush_subscriptions_cache(); self::_flush_subscriptions_cache();
@ -788,12 +834,16 @@ class WC_Helper {
wp_die( 'Could not verify nonce' ); wp_die( 'Could not verify nonce' );
} }
$request = WC_Helper_API::post( 'activate', array( $request = WC_Helper_API::post(
'activate', array(
'authenticated' => true, 'authenticated' => true,
'body' => json_encode( array( 'body' => json_encode(
array(
'product_key' => $product_key, 'product_key' => $product_key,
) ), )
) ); ),
)
);
$activated = wp_remote_retrieve_response_code( $request ) === 200; $activated = wp_remote_retrieve_response_code( $request ) === 200;
$body = json_decode( wp_remote_retrieve_body( $request ), true ); $body = json_decode( wp_remote_retrieve_body( $request ), true );
@ -808,13 +858,15 @@ class WC_Helper {
} }
self::_flush_subscriptions_cache(); self::_flush_subscriptions_cache();
$redirect_uri = add_query_arg( array( $redirect_uri = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => self::get_current_filter(), 'filter' => self::get_current_filter(),
'wc-helper-status' => $activated ? 'activate-success' : 'activate-error', 'wc-helper-status' => $activated ? 'activate-success' : 'activate-error',
'wc-helper-product-id' => $product_id, 'wc-helper-product-id' => $product_id,
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
wp_safe_redirect( $redirect_uri ); wp_safe_redirect( $redirect_uri );
die(); die();
@ -832,12 +884,16 @@ class WC_Helper {
wp_die( 'Could not verify nonce' ); wp_die( 'Could not verify nonce' );
} }
$request = WC_Helper_API::post( 'deactivate', array( $request = WC_Helper_API::post(
'deactivate', array(
'authenticated' => true, 'authenticated' => true,
'body' => json_encode( array( 'body' => json_encode(
array(
'product_key' => $product_key, 'product_key' => $product_key,
) ), )
) ); ),
)
);
$code = wp_remote_retrieve_response_code( $request ); $code = wp_remote_retrieve_response_code( $request );
$deactivated = 200 === $code; $deactivated = 200 === $code;
@ -846,13 +902,15 @@ class WC_Helper {
} }
self::_flush_subscriptions_cache(); self::_flush_subscriptions_cache();
$redirect_uri = add_query_arg( array( $redirect_uri = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => self::get_current_filter(), 'filter' => self::get_current_filter(),
'wc-helper-status' => $deactivated ? 'deactivate-success' : 'deactivate-error', 'wc-helper-status' => $deactivated ? 'deactivate-success' : 'deactivate-error',
'wc-helper-product-id' => $product_id, 'wc-helper-product-id' => $product_id,
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
wp_safe_redirect( $redirect_uri ); wp_safe_redirect( $redirect_uri );
die(); die();
@ -874,8 +932,12 @@ class WC_Helper {
wp_die( 'You are not allowed to manage plugins on this site.' ); wp_die( 'You are not allowed to manage plugins on this site.' );
} }
$local = wp_list_filter( array_merge( self::get_local_woo_plugins(), $local = wp_list_filter(
self::get_local_woo_themes() ), array( '_product_id' => $product_id ) ); array_merge(
self::get_local_woo_plugins(),
self::get_local_woo_themes()
), array( '_product_id' => $product_id )
);
// Attempt to deactivate this plugin or theme. // Attempt to deactivate this plugin or theme.
if ( ! empty( $local ) ) { if ( ! empty( $local ) ) {
@ -887,13 +949,15 @@ class WC_Helper {
$deactivated = ! is_plugin_active( $local['_filename'] ); $deactivated = ! is_plugin_active( $local['_filename'] );
} }
$redirect_uri = add_query_arg( array( $redirect_uri = add_query_arg(
array(
'page' => 'wc-addons', 'page' => 'wc-addons',
'section' => 'helper', 'section' => 'helper',
'filter' => self::get_current_filter(), 'filter' => self::get_current_filter(),
'wc-helper-status' => $deactivated ? 'deactivate-plugin-success' : 'deactivate-plugin-error', 'wc-helper-status' => $deactivated ? 'deactivate-plugin-success' : 'deactivate-plugin-error',
'wc-helper-product-id' => $product_id, 'wc-helper-product-id' => $product_id,
), admin_url( 'admin.php' ) ); ), admin_url( 'admin.php' )
);
wp_safe_redirect( $redirect_uri ); wp_safe_redirect( $redirect_uri );
die(); die();
@ -907,8 +971,12 @@ class WC_Helper {
* @return array|bool The array containing the local plugin/theme data or false. * @return array|bool The array containing the local plugin/theme data or false.
*/ */
private static function _get_local_from_product_id( $product_id ) { private static function _get_local_from_product_id( $product_id ) {
$local = wp_list_filter( array_merge( self::get_local_woo_plugins(), $local = wp_list_filter(
self::get_local_woo_themes() ), array( '_product_id' => $product_id ) ); array_merge(
self::get_local_woo_plugins(),
self::get_local_woo_themes()
), array( '_product_id' => $product_id )
);
if ( ! empty( $local ) ) { if ( ! empty( $local ) ) {
return array_shift( $local ); return array_shift( $local );
@ -952,7 +1020,7 @@ class WC_Helper {
*/ */
public static function get_local_woo_plugins() { public static function get_local_woo_plugins() {
if ( ! function_exists( 'get_plugins' ) ) { if ( ! function_exists( 'get_plugins' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); require_once ABSPATH . 'wp-admin/includes/plugin.php';
} }
$plugins = get_plugins(); $plugins = get_plugins();
@ -1008,7 +1076,7 @@ class WC_Helper {
$txt = $theme->get_stylesheet_directory() . '/theme_info.txt'; $txt = $theme->get_stylesheet_directory() . '/theme_info.txt';
if ( is_readable( $txt ) ) { if ( is_readable( $txt ) ) {
$txt = file_get_contents( $txt ); $txt = file_get_contents( $txt );
$txt = preg_split( "#\s#", $txt ); $txt = preg_split( '#\s#', $txt );
if ( count( $txt ) >= 2 ) { if ( count( $txt ) >= 2 ) {
$header = sprintf( '%d:%s', $txt[0], $txt[1] ); $header = sprintf( '%d:%s', $txt[0], $txt[1] );
} }
@ -1054,9 +1122,11 @@ class WC_Helper {
} }
// Obtain the connected user info. // Obtain the connected user info.
$request = WC_Helper_API::get( 'subscriptions', array( $request = WC_Helper_API::get(
'subscriptions', array(
'authenticated' => true, 'authenticated' => true,
) ); )
);
if ( wp_remote_retrieve_response_code( $request ) !== 200 ) { if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
set_transient( $cache_key, array(), 15 * MINUTE_IN_SECONDS ); set_transient( $cache_key, array(), 15 * MINUTE_IN_SECONDS );
@ -1126,12 +1196,16 @@ class WC_Helper {
return; return;
} }
$request = WC_Helper_API::post( 'activate', array( $request = WC_Helper_API::post(
'activate', array(
'authenticated' => true, 'authenticated' => true,
'body' => json_encode( array( 'body' => json_encode(
array(
'product_key' => $subscription['product_key'], 'product_key' => $subscription['product_key'],
) ), )
) ); ),
)
);
$activated = wp_remote_retrieve_response_code( $request ) === 200; $activated = wp_remote_retrieve_response_code( $request ) === 200;
$body = json_decode( wp_remote_retrieve_body( $request ), true ); $body = json_decode( wp_remote_retrieve_body( $request ), true );
@ -1187,12 +1261,16 @@ class WC_Helper {
continue; continue;
} }
$request = WC_Helper_API::post( 'deactivate', array( $request = WC_Helper_API::post(
'deactivate', array(
'authenticated' => true, 'authenticated' => true,
'body' => json_encode( array( 'body' => json_encode(
array(
'product_key' => $subscription['product_key'], 'product_key' => $subscription['product_key'],
) ), )
) ); ),
)
);
if ( wp_remote_retrieve_response_code( $request ) === 200 ) { if ( wp_remote_retrieve_response_code( $request ) === 200 ) {
$deactivated++; $deactivated++;
@ -1306,8 +1384,10 @@ class WC_Helper {
} }
/* translators: %1$s: helper url, %2$d: number of extensions */ /* translators: %1$s: helper url, %2$d: number of extensions */
return sprintf( _n( 'Note: You currently have <a href="%1$s">%2$d paid extension</a> which should be updated first before updating WooCommerce.', 'Note: You currently have <a href="%1$s">%2$d paid extensions</a> which should be updated first before updating WooCommerce.', $available, 'woocommerce' ), return sprintf(
admin_url( 'admin.php?page=wc-addons&section=helper' ), $available ); _n( 'Note: You currently have <a href="%1$s">%2$d paid extension</a> which should be updated first before updating WooCommerce.', 'Note: You currently have <a href="%1$s">%2$d paid extensions</a> which should be updated first before updating WooCommerce.', $available, 'woocommerce' ),
admin_url( 'admin.php?page=wc-addons&section=helper' ), $available
);
} }
/** /**
@ -1346,9 +1426,11 @@ class WC_Helper {
* @access private * @access private
*/ */
public static function _flush_authentication_cache() { public static function _flush_authentication_cache() {
$request = WC_Helper_API::get( 'oauth/me', array( $request = WC_Helper_API::get(
'oauth/me', array(
'authenticated' => true, 'authenticated' => true,
) ); )
);
if ( wp_remote_retrieve_response_code( $request ) !== 200 ) { if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
return false; return false;
@ -1359,10 +1441,12 @@ class WC_Helper {
return false; return false;
} }
WC_Helper_Options::update( 'auth_user_data', array( WC_Helper_Options::update(
'auth_user_data', array(
'name' => $user_data['name'], 'name' => $user_data['name'],
'email' => $user_data['email'], 'email' => $user_data['email'],
) ); )
);
return true; return true;
} }

View File

@ -1,14 +1,14 @@
<?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>
@ -21,8 +21,8 @@
$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;
@ -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">

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Class WC_Product_CSV_Importer_Controller file.
*
* @package WooCommerce\Admin\Importers
*/
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -10,8 +16,6 @@ if ( ! class_exists( 'WP_Importer' ) ) {
/** /**
* Product importer controller - handles file upload and forms in admin. * Product importer controller - handles file upload and forms in admin.
* *
* @author Automattic
* @category Admin
* @package WooCommerce/Admin/Importers * @package WooCommerce/Admin/Importers
* @version 3.1.0 * @version 3.1.0
*/ */
@ -52,6 +56,13 @@ class WC_Product_CSV_Importer_Controller {
*/ */
protected $delimiter = ','; protected $delimiter = ',';
/**
* Whether to use previous mapping selections.
*
* @var bool
*/
protected $map_preferences = false;
/** /**
* Whether to skip existing products. * Whether to skip existing products.
* *
@ -101,15 +112,23 @@ class WC_Product_CSV_Importer_Controller {
$this->steps = apply_filters( 'woocommerce_product_csv_importer_steps', $default_steps ); $this->steps = apply_filters( 'woocommerce_product_csv_importer_steps', $default_steps );
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
$this->step = isset( $_REQUEST['step'] ) ? sanitize_key( $_REQUEST['step'] ) : current( array_keys( $this->steps ) ); $this->step = isset( $_REQUEST['step'] ) ? sanitize_key( $_REQUEST['step'] ) : current( array_keys( $this->steps ) );
$this->file = isset( $_REQUEST['file'] ) ? wc_clean( $_REQUEST['file'] ) : ''; $this->file = isset( $_REQUEST['file'] ) ? wc_clean( wp_unslash( $_REQUEST['file'] ) ) : '';
$this->update_existing = isset( $_REQUEST['update_existing'] ) ? (bool) $_REQUEST['update_existing'] : false; $this->update_existing = isset( $_REQUEST['update_existing'] ) ? (bool) $_REQUEST['update_existing'] : false;
$this->delimiter = ! empty( $_REQUEST['delimiter'] ) ? wc_clean( $_REQUEST['delimiter'] ) : ','; $this->delimiter = ! empty( $_REQUEST['delimiter'] ) ? wc_clean( wp_unslash( $_REQUEST['delimiter'] ) ) : ',';
$this->map_preferences = isset( $_REQUEST['map_preferences'] ) ? (bool) $_REQUEST['map_preferences'] : false;
// phpcs:enable
if ( $this->map_preferences ) {
add_filter( 'woocommerce_csv_product_import_mapped_columns', array( $this, 'auto_map_user_preferences' ), 9999 );
}
} }
/** /**
* 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.
* Empty string on failure. * Empty string on failure.
@ -125,7 +144,7 @@ class WC_Product_CSV_Importer_Controller {
return admin_url(); return admin_url();
} }
$step_index = array_search( $step, $keys ); $step_index = array_search( $step, $keys, true );
if ( false === $step_index ) { if ( false === $step_index ) {
return ''; return '';
@ -136,6 +155,7 @@ class WC_Product_CSV_Importer_Controller {
'file' => str_replace( DIRECTORY_SEPARATOR, '/', $this->file ), 'file' => str_replace( DIRECTORY_SEPARATOR, '/', $this->file ),
'delimiter' => $this->delimiter, 'delimiter' => $this->delimiter,
'update_existing' => $this->update_existing, 'update_existing' => $this->update_existing,
'map_preferences' => $this->map_preferences,
'_wpnonce' => wp_create_nonce( 'woocommerce-csv-importer' ), // wp_nonce_url() escapes & to &amp; breaking redirects. '_wpnonce' => wp_create_nonce( 'woocommerce-csv-importer' ), // wp_nonce_url() escapes & to &amp; breaking redirects.
); );
@ -146,21 +166,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';
} }
/** /**
@ -203,6 +223,7 @@ class WC_Product_CSV_Importer_Controller {
* Dispatch current step and show correct view. * Dispatch current step and show correct view.
*/ */
public function dispatch() { public function dispatch() {
// phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
if ( ! empty( $_POST['save_step'] ) && ! empty( $this->steps[ $this->step ]['handler'] ) ) { if ( ! empty( $_POST['save_step'] ) && ! empty( $this->steps[ $this->step ]['handler'] ) ) {
call_user_func( $this->steps[ $this->step ]['handler'], $this ); call_user_func( $this->steps[ $this->step ]['handler'], $this );
} }
@ -221,7 +242,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';
} }
/** /**
@ -250,20 +271,31 @@ 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'] ) ) { // phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification -- Nonce already verified in WC_Product_CSV_Importer_Controller::upload_form_handler()
$file_url = isset( $_POST['file_url'] ) ? esc_url_raw( wp_unslash( $_POST['file_url'] ) ) : '';
if ( empty( $file_url ) ) {
if ( ! isset( $_FILES['import'] ) ) { if ( ! isset( $_FILES['import'] ) ) {
return new WP_Error( 'woocommerce_product_csv_importer_upload_file_empty', __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'woocommerce' ) ); return new WP_Error( 'woocommerce_product_csv_importer_upload_file_empty', __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'woocommerce' ) );
} }
$filetype = wp_check_filetype( $_FILES['import']['name'], $valid_filetypes ); $filetype = wp_check_filetype( wc_clean( wp_unslash( $_FILES['import']['name'] ) ), $valid_filetypes );
if ( ! in_array( $filetype['type'], $valid_filetypes ) ) { if ( ! in_array( $filetype['type'], $valid_filetypes, true ) ) {
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( wp_unslash( $_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'] );
@ -289,14 +321,15 @@ class WC_Product_CSV_Importer_Controller {
wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
return $upload['file']; return $upload['file'];
} elseif ( file_exists( ABSPATH . $_POST['file_url'] ) ) { } elseif ( file_exists( ABSPATH . $file_url ) ) {
$filetype = wp_check_filetype( ABSPATH . $_POST['file_url'], $valid_filetypes ); $filetype = wp_check_filetype( ABSPATH . $file_url, $valid_filetypes );
if ( ! in_array( $filetype['type'], $valid_filetypes ) ) { if ( ! in_array( $filetype['type'], $valid_filetypes, true ) ) {
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' ) );
} }
return ABSPATH . $_POST['file_url']; return ABSPATH . $file_url;
} }
// phpcs:enable
return new WP_Error( 'woocommerce_product_csv_importer_upload_invalid_file', __( 'Please upload or provide the link to a valid CSV file.', 'woocommerce' ) ); return new WP_Error( 'woocommerce_product_csv_importer_upload_invalid_file', __( 'Please upload or provide the link to a valid CSV file.', 'woocommerce' ) );
} }
@ -331,7 +364,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';
} }
/** /**
@ -343,15 +376,21 @@ class WC_Product_CSV_Importer_Controller {
return; return;
} }
if ( ! empty( $_POST['map_to'] ) ) { // phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification -- Nonce already verified in WC_Admin_Importers::do_ajax_product_import()
$mapping_from = wp_unslash( $_POST['map_from'] ); if ( ! empty( $_POST['map_from'] ) && ! empty( $_POST['map_to'] ) ) {
$mapping_to = wp_unslash( $_POST['map_to'] ); $mapping_from = wc_clean( wp_unslash( $_POST['map_from'] ) );
$mapping_to = wc_clean( wp_unslash( $_POST['map_to'] ) );
// Save mapping preferences for future imports.
update_user_option( get_current_user_id(), 'woocommerce_product_import_mapping', $mapping_to );
} else { } else {
wp_redirect( esc_url_raw( $this->get_next_step_link( 'upload' ) ) ); wp_redirect( esc_url_raw( $this->get_next_step_link( 'upload' ) ) );
exit; exit;
} }
// phpcs:enable
wp_localize_script( 'wc-product-import', 'wc_product_import_params', array( wp_localize_script(
'wc-product-import', 'wc_product_import_params', array(
'import_nonce' => wp_create_nonce( 'wc-product-import' ), 'import_nonce' => wp_create_nonce( 'wc-product-import' ),
'mapping' => array( 'mapping' => array(
'from' => $mapping_from, 'from' => $mapping_from,
@ -360,23 +399,26 @@ class WC_Product_CSV_Importer_Controller {
'file' => $this->file, 'file' => $this->file,
'update_existing' => $this->update_existing, 'update_existing' => $this->update_existing,
'delimiter' => $this->delimiter, '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';
} }
/** /**
* Done step. * Done step.
*/ */
protected function done() { protected function done() {
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
$imported = isset( $_GET['products-imported'] ) ? absint( $_GET['products-imported'] ) : 0; $imported = isset( $_GET['products-imported'] ) ? absint( $_GET['products-imported'] ) : 0;
$updated = isset( $_GET['products-updated'] ) ? absint( $_GET['products-updated'] ) : 0; $updated = isset( $_GET['products-updated'] ) ? absint( $_GET['products-updated'] ) : 0;
$failed = isset( $_GET['products-failed'] ) ? absint( $_GET['products-failed'] ) : 0; $failed = isset( $_GET['products-failed'] ) ? absint( $_GET['products-failed'] ) : 0;
$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' ) );
// phpcs:enable
include_once( dirname( __FILE__ ) . '/views/html-csv-import-done.php' ); include_once dirname( __FILE__ ) . '/views/html-csv-import-done.php';
} }
/** /**
@ -406,14 +448,16 @@ class WC_Product_CSV_Importer_Controller {
$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(
apply_filters(
'woocommerce_csv_product_import_mapping_default_columns', array(
__( 'ID', 'woocommerce' ) => 'id', __( 'ID', 'woocommerce' ) => 'id',
__( 'Type', 'woocommerce' ) => 'type', __( 'Type', 'woocommerce' ) => 'type',
__( 'SKU', 'woocommerce' ) => 'sku', __( 'SKU', 'woocommerce' ) => 'sku',
@ -431,9 +475,13 @@ class WC_Product_CSV_Importer_Controller {
__( 'Stock', 'woocommerce' ) => 'stock_quantity', __( 'Stock', 'woocommerce' ) => 'stock_quantity',
__( 'Backorders allowed?', 'woocommerce' ) => 'backorders', __( 'Backorders allowed?', 'woocommerce' ) => 'backorders',
__( 'Sold individually?', 'woocommerce' ) => 'sold_individually', __( 'Sold individually?', 'woocommerce' ) => 'sold_individually',
/* translators: %s: Weight unit */
sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit ) => 'weight', sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit ) => 'weight',
/* translators: %s: Length unit */
sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ) => 'length', sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ) => 'length',
/* translators: %s: Width unit */
sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ) => 'width', sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ) => 'width',
/* translators: %s: Height unit */
sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ) => 'height', sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ) => 'height',
__( 'Allow customer reviews?', 'woocommerce' ) => 'reviews_allowed', __( 'Allow customer reviews?', 'woocommerce' ) => 'reviews_allowed',
__( 'Purchase note', 'woocommerce' ) => 'purchase_note', __( 'Purchase note', 'woocommerce' ) => 'purchase_note',
@ -452,20 +500,35 @@ class WC_Product_CSV_Importer_Controller {
__( 'External URL', 'woocommerce' ) => 'product_url', __( 'External URL', 'woocommerce' ) => 'product_url',
__( 'Button text', 'woocommerce' ) => 'button_text', __( 'Button text', 'woocommerce' ) => 'button_text',
__( 'Position', 'woocommerce' ) => 'menu_order', __( 'Position', 'woocommerce' ) => 'menu_order',
) ) ); )
)
);
$special_columns = $this->get_special_columns( $this->normalize_columns_names( apply_filters( 'woocommerce_csv_product_import_mapping_special_columns', $special_columns = $this->get_special_columns(
$this->normalize_columns_names(
apply_filters(
'woocommerce_csv_product_import_mapping_special_columns',
array( array(
/* translators: %d: Attribute number */
__( 'Attribute %d name', 'woocommerce' ) => 'attributes:name', __( 'Attribute %d name', 'woocommerce' ) => 'attributes:name',
/* translators: %d: Attribute number */
__( 'Attribute %d value(s)', 'woocommerce' ) => 'attributes:value', __( 'Attribute %d value(s)', 'woocommerce' ) => 'attributes:value',
/* translators: %d: Attribute number */
__( 'Attribute %d visible', 'woocommerce' ) => 'attributes:visible', __( 'Attribute %d visible', 'woocommerce' ) => 'attributes:visible',
/* translators: %d: Attribute number */
__( 'Attribute %d global', 'woocommerce' ) => 'attributes:taxonomy', __( 'Attribute %d global', 'woocommerce' ) => 'attributes:taxonomy',
/* translators: %d: Attribute number */
__( 'Attribute %d default', 'woocommerce' ) => 'attributes:default', __( 'Attribute %d default', 'woocommerce' ) => 'attributes:default',
/* translators: %d: Download number */
__( 'Download %d name', 'woocommerce' ) => 'downloads:name', __( 'Download %d name', 'woocommerce' ) => 'downloads:name',
/* translators: %d: Download number */
__( 'Download %d URL', 'woocommerce' ) => 'downloads:url', __( 'Download %d URL', 'woocommerce' ) => 'downloads:url',
/* translators: %d: Meta number */
__( 'Meta: %s', 'woocommerce' ) => 'meta:', __( 'Meta: %s', 'woocommerce' ) => 'meta:',
) )
) ) ); )
)
);
$headers = array(); $headers = array();
foreach ( $raw_headers as $key => $field ) { foreach ( $raw_headers as $key => $field ) {
@ -488,6 +551,22 @@ class WC_Product_CSV_Importer_Controller {
return apply_filters( 'woocommerce_csv_product_import_mapped_columns', $headers, $raw_headers ); return apply_filters( 'woocommerce_csv_product_import_mapped_columns', $headers, $raw_headers );
} }
/**
* Map columns using the user's lastest import mappings.
*
* @param array $headers Header columns.
* @return array
*/
public function auto_map_user_preferences( $headers ) {
$mapping_preferences = get_user_option( 'woocommerce_product_import_mapping' );
if ( ! empty( $mapping_preferences ) && is_array( $mapping_preferences ) ) {
return $mapping_preferences;
}
return $headers;
}
/** /**
* Sanitize special column name regex. * Sanitize special column name regex.
* *
@ -519,7 +598,7 @@ class WC_Product_CSV_Importer_Controller {
/** /**
* Get mapping options. * Get mapping options.
* *
* @param string $item Item name * @param string $item Item name.
* @return array * @return array
*/ */
protected function get_mapping_options( $item = '' ) { protected function get_mapping_options( $item = '' ) {

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