seo tweaks - branch update

This commit is contained in:
opportus 2016-08-16 12:19:29 +02:00
commit 26367d1108
219 changed files with 17446 additions and 6445 deletions

2
.gitignore vendored
View File

@ -28,3 +28,5 @@ Thumbs.db
# Logs
/logs
/vendor/

60
.stylelintrc Normal file
View File

@ -0,0 +1,60 @@
{
"rules": {
"indentation": "tab",
"color-hex-case": "lower",
"color-no-invalid-hex": true,
"function-calc-no-unspaced-operator": true,
"function-comma-space-after": "always-single-line",
"function-comma-space-before": "never",
"function-name-case": "lower",
"function-url-quotes": "always",
"function-whitespace-after": "always",
"number-leading-zero": "always",
"number-no-trailing-zeros": true,
"length-zero-no-unit": true,
"string-no-newline": true,
"string-quotes": "single",
"unit-case": "lower",
"unit-no-unknown": true,
"unit-whitelist": ["px", "%", "deg", "ms", "em", "vh", "vw", "rem", "s", "ex", "pt", "cm"],
"value-list-comma-space-after": "always-single-line",
"value-list-comma-space-before": "never",
"shorthand-property-no-redundant-values": true,
"property-case": "lower",
"declaration-block-no-duplicate-properties": [true, { "severity": "warning" } ],
"declaration-block-no-ignored-properties": [true, { "severity": "warning" } ],
"declaration-block-trailing-semicolon": "always",
"declaration-block-single-line-max-declarations": 0,
"declaration-block-semicolon-space-before": "never",
"declaration-block-semicolon-space-after": "always-single-line",
"declaration-block-semicolon-newline-before": "never-multi-line",
"declaration-block-semicolon-newline-after": "always-multi-line",
"block-closing-brace-newline-after": "always",
"block-closing-brace-newline-before": "always-multi-line",
"block-no-empty": true,
"block-opening-brace-newline-after": "always-multi-line",
"block-opening-brace-space-before": "always",
"selector-attribute-brackets-space-inside": "never",
"selector-attribute-operator-space-after": "never",
"selector-attribute-operator-space-before": "never",
"selector-combinator-space-after": "always",
"selector-combinator-space-before": "always",
"selector-pseudo-class-case": "lower",
"selector-pseudo-class-parentheses-space-inside": "always",
"selector-pseudo-element-case": "lower",
"selector-pseudo-element-colon-notation": "double",
"selector-pseudo-element-no-unknown": true,
"selector-type-case": "lower",
"selector-no-id": [true, { "severity": "warning" } ],
}
}

View File

@ -28,6 +28,17 @@ module.exports = function( grunt ) {
]
},
// Sass linting with Stylelint.
stylelint: {
options: {
stylelintrc: '.stylelintrc'
},
all: [
'<%= dirs.css %>/*.scss',
'!<%= dirs.css %>/select2.scss'
]
},
// Minify .js files.
uglify: {
options: {
@ -228,6 +239,7 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-stylelint' );
// Register tasks
grunt.registerTask( 'default', [

View File

@ -4,6 +4,6 @@
*/
@include keyframes( spin ) {
100% {
@include transform( rotate(360deg) );
@include transform( rotate( 360deg ) );
}
}

View File

@ -5,13 +5,13 @@
@mixin clearfix() {
*zoom: 1;
&:before,
&:after {
content: " ";
&::before,
&::after {
content: ' ';
display: table;
}
&:after {
&::after {
clear: both;
}
}
@ -105,7 +105,7 @@
* Deprecated
* Vendor prefix no longer required.
*/
@mixin transition($selector: all, $animation: ease-in-out, $duration: .2s) {
@mixin transition($selector: all, $animation: ease-in-out, $duration: 0.2s) {
transition: $selector $animation $duration;
}
@ -126,10 +126,11 @@
box-sizing: border-box;
}
@mixin darkorlighttextshadow($a, $opacity: .8) {
@mixin darkorlighttextshadow($a, $opacity: 0.8) {
@if lightness($a) >= 65% {
@include text_shadow(0, -1px, 0, rgba(0, 0, 0, $opacity));
} @else {
}
@else {
@include text_shadow(0, 1px, 0, rgba(255, 255, 255, $opacity));
}
}
@ -171,7 +172,7 @@
width: 1em;
}
@mixin icon( $glyph: "\e001" ) {
@mixin icon( $glyph: '\e001' ) {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
@ -190,7 +191,7 @@
content: $glyph;
}
@mixin icon_dashicons( $glyph: "\f333" ) {
@mixin icon_dashicons( $glyph: '\f333' ) {
font-family: 'Dashicons';
speak: none;
font-weight: normal;
@ -209,7 +210,7 @@
content: $glyph;
}
@mixin iconbefore( $glyph: "\e001" ) {
@mixin iconbefore( $glyph: '\e001' ) {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
@ -217,12 +218,12 @@
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
margin-right: .618em;
margin-right: 0.618em;
content: $glyph;
text-decoration: none;
}
@mixin iconbeforedashicons( $glyph: "\f333" ) {
@mixin iconbeforedashicons( $glyph: '\f333' ) {
font-family: 'Dashicons';
speak: none;
font-weight: normal;
@ -230,12 +231,12 @@
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
margin-right: .618em;
margin-right: 0.618em;
content: $glyph;
text-decoration: none;
}
@mixin iconafter( $glyph: "\e001" ) {
@mixin iconafter( $glyph: '\e001' ) {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
@ -243,29 +244,28 @@
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
margin-left: .618em;
margin-left: 0.618em;
content: $glyph;
text-decoration: none;
}
@mixin loader() {
&:before {
&::before {
height: 1em;
width: 1em;
display: block;
position: absolute;
top: 50%;
left: 50%;
margin-left: -.5em;
margin-top: -.5em;
display: block;
content: "";
margin-left: -0.5em;
margin-top: -0.5em;
content: '';
@include animation( spin 1s ease-in-out infinite );
background: url(../images/icons/loader.svg) center center;
background: url('../images/icons/loader.svg') center center;
background-size: cover;
line-height: 1;
text-align: center;
font-size: 2em;
color: rgba(#000,0.75);
color: rgba(#000, 0.75);
}
}

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#bb77ae;border-color:#A36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597;color:#fff;text-shadow:0 -1px 1px #A36597,1px 0 1px #A36597,0 1px 1px #A36597,-1px 0 1px #A36597}.woocommerce-message a.button-primary:active,.woocommerce-message a.button-primary:focus,.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:active,p.woocommerce-actions a.button-primary:focus,p.woocommerce-actions a.button-primary:hover{background:#A36597;border-color:#A36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #A36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close:before,p.woocommerce-actions a.woocommerce-message-close:before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice:before,div.woocommerce-no-shipping-methods-notice:before{content:"\e01b";font-family:WooCommerce;text-align:center;line-height:1;color:#F7F1F6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute}
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,1px 0 1px #a36597,0 1px 1px #a36597,-1px 0 1px #a36597}.woocommerce-message a.button-primary:active,.woocommerce-message a.button-primary:focus,.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:active,p.woocommerce-actions a.button-primary:focus,p.woocommerce-actions a.button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute}

View File

@ -6,7 +6,7 @@
/**
* Imports
*/
@import "bourbon";
@import 'bourbon';
/**
* Styling begins
@ -24,17 +24,17 @@ p.woocommerce-actions,
.woocommerce-message {
a.button-primary {
background: #bb77ae;
border-color: #A36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
border-color: #a36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
color: #fff;
text-shadow: 0px -1px 1px #A36597, 1px 0px 1px #A36597, 0px 1px 1px #A36597, -1px 0px 1px #A36597;
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
&:hover, &:focus, &:active {
background: #A36597;
border-color: #A36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
background: #a36597;
border-color: #a36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
}
}
@ -46,12 +46,12 @@ p.woocommerce-actions,
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
&:before {
&::before {
position: absolute;
top: 8px;
left: 0;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
-webkit-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
}
@ -87,12 +87,12 @@ div.woocommerce-no-shipping-methods-notice {
font-size: 1.1em;
}
}
&:before {
content: "\e01b";
font-family: "WooCommerce";
&::before {
content: '\e01b';
font-family: 'WooCommerce';
text-align: center;
line-height: 1;
color: #F7F1F6;
color: #f7f1f6;
display: block;
width: 1em;
font-size: 20em;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
body{background:#f1f1f1;box-shadow:none;margin:100px auto 24px;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-auth-content{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13);overflow:hidden;padding:24px 24px 0;zoom:1}.wc-auth-content h1,.wc-auth-content h2,.wc-auth-content h3,.wc-auth-content table{border:0;clear:none;color:#666;margin:0 0 24px;padding:0}.wc-auth-content p,.wc-auth-content ul{color:#666;font-size:1em;line-height:1.75em;margin:0 0 24px}.wc-auth-content p{padding:0}.wc-auth-content a{color:#A16696}.wc-auth-content a:focus,.wc-auth-content a:hover{color:#111}.wc-auth-content .wc-auth-login label{color:#999;display:block;margin-bottom:.5em}.wc-auth-content .wc-auth-login input{box-sizing:border-box;font-size:1.3em;padding:.5em;width:100%}.wc-auth-content .wc-auth-login .wc-auth-actions{padding:0}.wc-auth-content .wc-auth-login .wc-auth-actions .wc-auth-login-button{float:none;width:100%}.wc-auth-permissions{list-style:disc inside;padding:0}.wc-auth-permissions li{font-size:1em}.wc-auth-logged-in-as{background:#f5f5f5;border-bottom:2px solid #eee;line-height:70px;margin:0 0 24px;padding:0 1em 0 0}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:left;height:70px;margin:0 1em 0 0}.wc-auth-logged-in-as .wc-auth-logout{float:right}.wc-auth .wc-auth-actions{overflow:hidden;padding-left:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border:1px solid #d7d7d7;box-sizing:border-box;color:#777;float:right;font-size:1.25em;height:auto;line-height:1em;padding:1em 2em;text-align:center;width:50%}.wc-auth .wc-auth-actions .button:focus,.wc-auth .wc-auth-actions .button:hover{background:#fcfcfc}.wc-auth .wc-auth-actions .button-primary{background:#ad6ea1;border-color:#a16696;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);color:#fff;float:right;opacity:1;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-auth .wc-auth-actions .button-primary:focus,.wc-auth .wc-auth-actions .button-primary:hover{background:#B472A8;color:#fff}.wc-auth .wc-auth-actions .wc-auth-approve{float:right}.wc-auth .wc-auth-actions .wc-auth-deny{float:left;margin-left:-24px}
body{background:#f1f1f1;box-shadow:none;margin:100px auto 24px;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-auth-content{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13);overflow:hidden;padding:24px 24px 0;zoom:1}.wc-auth-content h1,.wc-auth-content h2,.wc-auth-content h3,.wc-auth-content table{border:0;clear:none;color:#666;margin:0 0 24px;padding:0}.wc-auth-content p,.wc-auth-content ul{color:#666;font-size:1em;line-height:1.75em;margin:0 0 24px}.wc-auth-content p{padding:0}.wc-auth-content a{color:#a16696}.wc-auth-content a:focus,.wc-auth-content a:hover{color:#111}.wc-auth-content .wc-auth-login label{color:#999;display:block;margin-bottom:.5em}.wc-auth-content .wc-auth-login input{box-sizing:border-box;font-size:1.3em;padding:.5em;width:100%}.wc-auth-content .wc-auth-login .wc-auth-actions{padding:0}.wc-auth-content .wc-auth-login .wc-auth-actions .wc-auth-login-button{float:none;width:100%}.wc-auth-permissions{list-style:disc inside;padding:0}.wc-auth-permissions li{font-size:1em}.wc-auth-logged-in-as{background:#f5f5f5;border-bottom:2px solid #eee;line-height:70px;margin:0 0 24px;padding:0 1em 0 0}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:left;height:70px;margin:0 1em 0 0}.wc-auth-logged-in-as .wc-auth-logout{float:right}.wc-auth .wc-auth-actions{overflow:hidden;padding-left:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border:1px solid #d7d7d7;box-sizing:border-box;color:#777;float:right;font-size:1.25em;height:auto;line-height:1em;padding:1em 2em;text-align:center;width:50%}.wc-auth .wc-auth-actions .button:focus,.wc-auth .wc-auth-actions .button:hover{background:#fcfcfc}.wc-auth .wc-auth-actions .button-primary{background:#ad6ea1;border-color:#a16696;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);color:#fff;float:right;opacity:1;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-auth .wc-auth-actions .button-primary:focus,.wc-auth .wc-auth-actions .button-primary:hover{background:#b472a8;color:#fff}.wc-auth .wc-auth-actions .wc-auth-approve{float:right}.wc-auth .wc-auth-actions .wc-auth-deny{float:left;margin-left:-24px}

View File

@ -18,7 +18,7 @@ body {
.wc-auth-content {
background: #fff;
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
overflow: hidden;
padding: 24px 24px 0;
zoom: 1;
@ -43,7 +43,7 @@ body {
}
a {
color: #A16696;
color: #a16696;
&:hover, &:focus {
color: #111;
}
@ -53,13 +53,13 @@ body {
label {
color: #999;
display: block;
margin-bottom: .5em;
margin-bottom: 0.5em;
}
input {
box-sizing: border-box;
font-size: 1.3em;
padding: .5em;
padding: 0.5em;
width: 100%;
}
@ -133,10 +133,10 @@ body {
color: #fff;
float: right;
opacity: 1;
text-shadow: 0px -1px 1px #8a4f7f, 1px 0px 1px #8a4f7f, 0px 1px 1px #8a4f7f, -1px 0px 1px #8a4f7f;
text-shadow: 0 -1px 1px #8a4f7f, 1px 0 1px #8a4f7f, 0 1px 1px #8a4f7f, -1px 0 1px #8a4f7f;
&:hover, &:focus {
background: #B472A8;
background: #b472a8;
color: #fff;
}
}

View File

@ -1 +1 @@
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;float:left;font-size:.8em;border-left:1px solid #fff;border-right:1px solid #ececec;text-align:center;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-left:0}ul.woocommerce_stats li:last-child{border-right:0}#woocommerce_dashboard_status .wc_status_list li.low-in-stock,#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}ul.woocommerce_stats strong{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:left;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;-webkit-transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:right;position:absolute;right:0;top:50%;margin-right:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover:before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;margin:0 12px 12px 0;text-indent:0;top:0;left:0;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month,#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a:before{font-family:Dashicons;content:"\f185"}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a:before{content:"\e006"}#woocommerce_dashboard_status .wc_status_list li.processing-orders a:before{content:"\e011";color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a:before{content:"\e033";color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a:before{content:"\e016";color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a:before{content:"\e013";color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:left;margin:0 10px 5px 0}#woocommerce_dashboard_recent_reviews .star-rating{float:right;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-left:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating:before{content:"\e021\e021\e021\e021\e021";color:#b3b3b3;float:left;top:0;left:0;position:absolute;letter-spacing:.1em;letter-spacing:0\9}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:left;top:0;left:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span:before{content:"\e020\e020\e020\e020\e020";top:0;position:absolute;left:0;letter-spacing:.1em;letter-spacing:0\9;color:#9c5d90}#dash-right-now li.product-count a:before{font-family:WooCommerce;content:"\e01d"}
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;text-align:center;float:left;font-size:.8em;border-left:1px solid #fff;border-right:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-left:0}ul.woocommerce_stats li:last-child{border-right:0}#woocommerce_dashboard_status .wc_status_list li.low-in-stock,#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}ul.woocommerce_stats strong{font-family:Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:left;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;-webkit-transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:right;position:absolute;right:0;top:50%;margin-right:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover::before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;margin:0 12px 12px 0;text-indent:0;top:0;left:0;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month,#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a::before{font-family:Dashicons;content:'\f185'}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders a::before{content:'\e011';color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a::before{content:'\e033';color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a::before{content:'\e016';color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a::before{content:'\e013';color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:left;margin:0 10px 5px 0}#woocommerce_dashboard_recent_reviews .star-rating{float:right;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-left:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b3b3;float:left;top:0;left:0;position:absolute;letter-spacing:.1em;letter-spacing:0\9}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:left;top:0;left:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span::before{content:'\e020\e020\e020\e020\e020';top:0;position:absolute;left:0;letter-spacing:.1em;letter-spacing:0\9;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}

View File

@ -6,10 +6,10 @@
/**
* Imports
*/
@import "bourbon";
@import "mixins";
@import "variables";
@import "fonts";
@import 'bourbon';
@import 'mixins';
@import 'variables';
@import 'fonts';
/**
* Styling begins
@ -26,7 +26,6 @@ ul.woocommerce_stats {
font-size: 0.8em;
border-left: 1px solid #fff;
border-right: 1px solid #ececec;
text-align: center;
box-sizing: border-box;
}
@ -39,7 +38,7 @@ ul.woocommerce_stats {
}
strong {
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;
font-size: 4em;
line-height: 1.2em;
font-weight: normal;
@ -71,7 +70,7 @@ ul.woocommerce_stats {
display: block;
color: #aaa;
padding: 9px 12px;
-webkit-transition: all ease .5s;
-webkit-transition: all ease 0.5s;
position: relative;
font-size: 12px;
@ -84,7 +83,7 @@ ul.woocommerce_stats {
right: 0;
top: 50%;
margin-right: 12px;
margin-top: -1.25em
margin-top: -1.25em;
}
strong {
@ -98,13 +97,13 @@ ul.woocommerce_stats {
&:hover {
color: #2ea2cc;
&:before,
&::before,
strong {
color: #2ea2cc !important;
}
}
&:before {
&::before {
@include icon();
font-size: 2em;
position: relative;
@ -125,32 +124,32 @@ ul.woocommerce_stats {
li.sales-this-month {
width: 100%;
a:before {
font-family: "Dashicons";
content: "\f185";
a::before {
font-family: 'Dashicons';
content: '\f185';
}
}
li.best-seller-this-month {
width: 100%;
a:before {
content: "\e006";
a::before {
content: '\e006';
}
}
li.processing-orders {
border-right: 1px solid #ececec;
a:before {
content: "\e011";
a::before {
content: '\e011';
color: $green;
}
}
li.on-hold-orders {
a:before {
content: "\e033";
a::before {
content: '\e033';
color: #999;
}
}
@ -158,15 +157,15 @@ ul.woocommerce_stats {
li.low-in-stock {
border-right: 1px solid #ececec;
a:before {
content: "\e016";
a::before {
content: '\e016';
color: $orange;
}
}
li.out-of-stock {
a:before {
content: "\e013";
a::before {
content: '\e013';
color: $red;
}
}
@ -181,7 +180,7 @@ ul.woocommerce_stats {
h4.meta {
line-height: 1.4;
margin: -.2em 0 0 0;
margin: -0.2em 0 0 0;
font-weight: normal;
color: #999;
}
@ -202,12 +201,12 @@ ul.woocommerce_stats {
position: relative;
height: 1.5em;
line-height: 1.5;
margin-left: .5em;
margin-left: 0.5em;
width: 5.4em;
font-family: 'WooCommerce' !important;
&:before {
content: "\e021\e021\e021\e021\e021";
&::before {
content: '\e021\e021\e021\e021\e021';
color: darken( #ccc, 10% );
float: left;
top: 0;
@ -226,8 +225,8 @@ ul.woocommerce_stats {
padding-top: 1.5em;
}
span:before {
content: "\e020\e020\e020\e020\e020";
span::before {
content: '\e020\e020\e020\e020\e020';
top: 0;
position: absolute;
left: 0;
@ -238,7 +237,7 @@ ul.woocommerce_stats {
}
}
#dash-right-now li.product-count a:before {
#dash-right-now li.product-count a::before {
font-family: 'WooCommerce';
content: "\e01d";
content: '\e01d';
}

View File

@ -1 +1 @@
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image:before{font-family:WooCommerce!important;content:"\e03d"}#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image:before,#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image:before{font-family:WooCommerce!important;content:"\e006"}#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image:before{font-family:WooCommerce!important;content:"\e023";font-size:1.3em!important}span.mce_woocommerce_shortcodes_button{background-image:none!important;display:block;text-indent:-9999px;position:relative;height:1em;width:1em}span.mce_woocommerce_shortcodes_button:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"";font-size:.9em;line-height:1.2}.wc_plugin_upgrade_notice{font-weight:400;color:#fff;background:#d54d21;padding:1em;margin:9px 0}.wc_plugin_upgrade_notice a{color:#fff;text-decoration:underline}.wc_plugin_upgrade_notice:before{content:"\f348";display:inline-block;font:400 18px/1 dashicons;speak:none;margin:0 8px 0 -2px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image::before{font-family:WooCommerce!important;content:'\e03d'}#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image::before,#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image::before{font-family:WooCommerce!important;content:'\e006'}#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image::before{font-family:WooCommerce!important;content:'\e023';font-size:1.3em!important}span.mce_woocommerce_shortcodes_button{background-image:none!important;display:block;text-indent:-9999px;position:relative;height:1em;width:1em}span.mce_woocommerce_shortcodes_button::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"";font-size:.9em;line-height:1.2}.wc_plugin_upgrade_notice{font-weight:400;color:#fff;background:#d54d21;padding:1em;margin:9px 0}.wc_plugin_upgrade_notice a{color:#fff;text-decoration:underline}.wc_plugin_upgrade_notice::before{content:'\f348';display:inline-block;font:400 18px/1 dashicons;speak:none;margin:0 8px 0 -2px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}

View File

@ -7,28 +7,28 @@
/**
* Imports
*/
@import "bourbon";
@import "mixins";
@import "variables";
@import "fonts";
@import 'bourbon';
@import 'mixins';
@import 'variables';
@import 'fonts';
/**
* Styling begins
*/
#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image:before {
#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image::before {
font-family: 'WooCommerce' !important;
content: "\e03d";
content: '\e03d';
}
#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image:before,
#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image:before {
#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image::before,
#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image::before {
font-family: 'WooCommerce' !important;
content: "\e006";
content: '\e006';
}
#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image:before {
#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image::before {
font-family: 'WooCommerce' !important;
content: "\e023";
content: '\e023';
font-size: 1.3em !important;
}
@ -36,9 +36,9 @@ span.mce_woocommerce_shortcodes_button {
background-image: none !important;
@include ir();
&:before {
@include icon( "\e01d" );
font-size: .9em;
&::before {
@include icon( '\e01d' );
font-size: 0.9em;
line-height: 1.2;
}
}
@ -55,8 +55,8 @@ span.mce_woocommerce_shortcodes_button {
text-decoration: underline;
}
&:before {
content: "\f348";
&::before {
content: '\f348';
display: inline-block;
font: 400 18px/1 dashicons;
speak: none;

File diff suppressed because one or more lines are too long

View File

@ -7,10 +7,10 @@
/**
* Imports
*/
@import "bourbon";
@import "mixins";
@import "variables";
@import "fonts";
@import 'bourbon';
@import 'mixins';
@import 'variables';
@import 'fonts';
/**
* Mixins
@ -19,7 +19,7 @@
border-radius: 100%;
height: 1em;
width: 1em;
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
background-color: #444;
color: #fff !important;
font-size: 16px !important;
@ -38,7 +38,7 @@ div.pp_woocommerce {
.pp_content_container {
background: #fff;
border-radius: 3px;
box-shadow: 0 1px 30px rgba(0,0,0,0.25);
box-shadow: 0 1px 30px rgba(0, 0, 0, 0.25);
padding: 20px 0;
@include clearfix();
}
@ -55,9 +55,9 @@ div.pp_woocommerce {
ul {
li {
a {
border: 1px solid rgba(0,0,0,0.5);
border: 1px solid rgba(0, 0, 0, 0.5);
background: #fff;
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
border-radius: 2px;
display: block;
@ -77,10 +77,10 @@ div.pp_woocommerce {
.pp_previous,
.pp_next {
&:before {
&::before {
@include button();
font-family: 'WooCommerce';
content: "\e00b";
content: '\e00b';
text-indent: 0;
display: none;
position: absolute;
@ -90,23 +90,23 @@ div.pp_woocommerce {
}
&:hover {
&:before {
&::before {
display: block;
}
}
}
.pp_previous {
&:before {
&::before {
left: 1em;
}
}
.pp_next {
&:before {
&::before {
right: 1em;
font-family: 'WooCommerce';
content: "\e008";
content: '\e008';
}
}
@ -136,13 +136,13 @@ div.pp_woocommerce {
.pp_close {
@include button();
top: -.5em;
right: -.5em;
top: -0.5em;
right: -0.5em;
font-size: 1.618em !important;
&:before {
&::before {
font-family: 'WooCommerce';
content: "\e013";
content: '\e013';
display: block;
position: absolute;
top: 0;
@ -160,9 +160,9 @@ div.pp_woocommerce {
position: relative;
margin-top: -1px;
&:before {
&::before {
font-family: 'WooCommerce';
content: "\e00b";
content: '\e00b';
display: block;
position: absolute;
top: 0;
@ -175,14 +175,14 @@ div.pp_woocommerce {
}
.pp_arrow_previous {
margin-right: .5em;
margin-right: 0.5em;
}
.pp_arrow_next {
margin-left: .5em;
margin-left: 0.5em;
&:before {
content: "\e008";
&::before {
content: '\e008';
}
}
@ -190,13 +190,13 @@ div.pp_woocommerce {
a.pp_contract {
@include button();
right: auto;
left: -.5em;
top: -.5em;
left: -0.5em;
top: -0.5em;
font-size: 1.618em !important;
&:before {
&::before {
font-family: 'WooCommerce';
content: "\e005";
content: '\e005';
display: block;
position: absolute;
top: 0;
@ -209,8 +209,8 @@ div.pp_woocommerce {
}
a.pp_contract {
&:before {
content: "\e004";
&::before {
content: '\e004';
}
}
@ -264,7 +264,7 @@ div.pp_woocommerce {
font-size: 44px;
line-height: 44px;
&:before {
&::before {
font-size: 44px;
}
}
@ -281,8 +281,8 @@ div.pp_woocommerce {
.pp_content {
width: 100% !important;
#pp_full_res{
& > img{
#pp_full_res {
& > img {
width: 100% !important;
height: auto !important;
}
@ -385,7 +385,7 @@ div.pp_pic_holder {
.pp_content_container .pp_details {
float: left;
margin: 10px 0 2px 0;
margin: 10px 0 2px;
}
.pp_description {
@ -401,7 +401,8 @@ div.pp_pic_holder {
.pp_social .facebook {
float: left;
margin-left: 5px;
width: 55px; overflow: hidden;
width: 55px;
overflow: hidden;
}
.pp_social .twitter {
@ -469,7 +470,7 @@ a.pp_arrow_next {
.pp_gallery ul a {
border: 1px #000 solid;
border: 1px rgba(0,0,0,0.5) solid;
border: 1px rgba(0, 0, 0, 0.5) solid;
display: block;
float: left;
height: 33px;
@ -537,7 +538,9 @@ a.pp_contract {
}
a.pp_close {
position: absolute; right: 0; top: 0;
position: absolute;
right: 0;
top: 0;
display: block;
text-indent: -10000px;
}

View File

@ -15,7 +15,7 @@
}
@page {
margin: .5cm;
margin: 0.5cm;
}
#adminmenuwrap,
@ -67,7 +67,7 @@ h2 .nav-tab {
.chart-legend li,
.chart-legend li {
padding: .25em .5em !important;
padding: 0.25em 0.5em !important;
box-shadow: none !important;
border-bottom: 1px solid gray !important;
}

File diff suppressed because one or more lines are too long

View File

@ -547,6 +547,11 @@ html[dir="rtl"] .select2-container-multi .select2-choices li
background-color: #e4e4e4;
}
.select2-container-multi .ui-sortable .select2-search-choice {
cursor: move;
}
html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
{
margin: 3px 5px 3px 0;

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ body {
}
}
.wc-setup-content {
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
padding: 24px 24px 0;
background: #fff;
overflow: hidden;
@ -62,7 +62,7 @@ body {
.description {
line-height: 1.5em;
display: block;
margin-top: .25em;
margin-top: 0.25em;
color: #999;
font-style: italic;
}
@ -70,7 +70,7 @@ body {
width: auto;
box-sizing: inherit;
padding: inherit;
margin: 0 .5em 0 0;
margin: 0 0.5em 0 0;
box-shadow: none;
}
}
@ -93,7 +93,7 @@ body {
}
table.tax-rates {
width: 100%;
font-size: .92em;
font-size: 0.92em;
th {
padding: 0;
text-align: center;
@ -116,8 +116,8 @@ body {
&.sort {
cursor: move;
color: #ccc;
&:before {
content: "\f333";
&::before {
content: '\f333';
font-family: 'dashicons';
}
}
@ -135,8 +135,8 @@ body {
overflow: hidden;
position: relative;
display: inline-block;
&:before {
content: "\f502";
&::before {
content: '\f502';
font-family: 'dashicons';
position: absolute;
left: 0;
@ -153,8 +153,8 @@ body {
overflow: hidden;
position: relative;
display: inline-block;
&:before {
content: "\f182";
&::before {
content: '\f182';
font-family: 'dashicons';
position: absolute;
left: 0;
@ -189,7 +189,7 @@ body {
line-height: 1.75em;
input {
vertical-align: middle;
margin: 1px 0 0 0;
margin: 1px 0 0;
height: 1.75em;
width: 1.75em;
line-height: 1.75em;
@ -231,35 +231,35 @@ body {
ul {
padding: 0 2em 0 0;
list-style: none outside;
margin: 0 0 -.75em;
margin: 0 0 -0.75em;
li a {
display: block;
padding: 0 0 .75em;
padding: 0 0 0.75em;
}
.setup-product {
a {
background-color: #bb77ae;
border-color: #A36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
text-shadow: 0px -1px 1px #A36597, 1px 0px 1px #A36597, 0px 1px 1px #A36597, -1px 0px 1px #A36597;
border-color: #a36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
font-size: 1em;
height: auto;
line-height: 1.75em;
margin: 0 0 .75em;
margin: 0 0 0.75em;
opacity: 1;
padding: 1em;
text-align: center;
&:hover, &:focus, &:active {
background: #A36597;
border-color: #A36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
background: #a36597;
border-color: #a36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
}
}
}
li a:before {
li a::before {
color: #82878c;
font: normal 20px/1 'dashicons';
speak: none;
@ -272,20 +272,20 @@ body {
text-decoration: none !important;
vertical-align: top;
}
.learn-more a:before {
content: "\f105";
.learn-more a::before {
content: '\f105';
}
.video-walkthrough a:before {
content: "\f126";
.video-walkthrough a::before {
content: '\f126';
}
.newsletter a:before {
content: "\f465";
.newsletter a::before {
content: '\f465';
}
}
}
.woocommerce-tracker, .updated {
padding: 24px 24px 0;
margin: 0 0 24px 0;
margin: 0 0 24px;
overflow: hidden;
background: #f5f5f5;
p {
@ -293,7 +293,7 @@ body {
margin: 0 0 12px;
}
p:last-child {
margin: 0 0 24px 0;
margin: 0 0 24px;
}
}
}
@ -317,8 +317,8 @@ body {
border-bottom: 4px solid #ccc;
line-height: 1.4em;
}
li:before {
content: "";
li::before {
content: '';
border: 4px solid #ccc;
border-radius: 100%;
width: 4px;
@ -333,14 +333,14 @@ body {
li.active {
border-color: #a16696;
color: #a16696;
&:before {
&::before {
border-color: #a16696;
}
}
li.done {
border-color: #a16696;
color: #a16696;
&:before {
&::before {
border-color: #a16696;
background: #a16696;
}
@ -351,28 +351,28 @@ body {
.button {
float: right;
font-size: 1.25em;
padding: .5em 1em;
padding: 0.5em 1em;
line-height: 1em;
margin-right: .5em;
margin-right: 0.5em;
margin-bottom: 2px;
height: auto;
border-radius: 4px;
}
.button-primary {
background-color: #bb77ae;
border-color: #A36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
text-shadow: 0px -1px 1px #A36597, 1px 0px 1px #A36597, 0px 1px 1px #A36597, -1px 0px 1px #A36597;
border-color: #a36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
float: right;
margin: 0;
opacity: 1;
&:hover, &:focus, &:active {
background: #A36597;
border-color: #A36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 #A36597;
background: #a36597;
border-color: #a36597;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
}
}
}
@ -424,7 +424,7 @@ ul.wc-wizard-payment-gateways {
}
&.checked {
background: #F7F1F6;
background: #f7f1f6;
.wc-wizard-gateway-settings {
display: table;
@ -435,12 +435,12 @@ ul.wc-wizard-payment-gateways {
font-style: italic;
p {
margin: 0 0 .5em;
margin: 0 0 0.5em;
}
}
.wc-wizard-gateway-enable {
margin: 0 0 .5em;
margin: 0 0 0.5em;
label {
display: block;
@ -452,7 +452,7 @@ ul.wc-wizard-payment-gateways {
vertical-align: middle;
}
}
label:before {
label::before {
content: '';
background: #fff;
border: 2px solid #eee;
@ -473,8 +473,8 @@ ul.wc-wizard-payment-gateways {
width: 0;
position: absolute;
&:checked + label:before {
content: "\f147";
&:checked + label::before {
content: '\f147';
font-family: 'dashicons';
color: #fff;
border-color: #a46497;

File diff suppressed because one or more lines are too long

View File

@ -6,9 +6,9 @@
/**
* Imports
*/
@import "bourbon";
@import "mixins";
@import "variables";
@import 'bourbon';
@import 'mixins';
@import 'variables';
/**
* Styling begins

File diff suppressed because one or more lines are too long

View File

@ -6,9 +6,9 @@
/**
* Imports
*/
@import "bourbon";
@import "mixins";
@import "variables";
@import 'bourbon';
@import 'mixins';
@import 'variables';
/**
* Style begins
@ -41,10 +41,10 @@
text-align: right !important; // Important to overwrite order status inline styling
&.order-actions {
text-align: left !important;
text-align: left !important; // This must always align left on handheld
}
&:before {
&::before {
content: attr(data-title) ': ';
font-weight: 700;
float: left;
@ -52,15 +52,15 @@
&.product-remove,
&.actions {
&:before {
&::before {
display: none;
}
}
}
&:nth-child(2n) {
&:nth-child( 2n ) {
td {
background-color: rgba(0,0,0,0.025);
background-color: rgba(0, 0, 0, 0.025);
}
}
}
@ -72,13 +72,13 @@
&.order-actions {
text-align: left;
&:before {
&::before {
display: none;
}
.button {
float: none;
margin: .125em .25em .125em 0;
margin: 0.125em 0.25em 0.125em 0;
}
}
}
@ -99,7 +99,7 @@
/**
* Products
*/
&, &[class*="columns-"] {
&, &[class*='columns-'] {
ul.products {
li.product {
width: 48%;
@ -107,9 +107,9 @@
clear: both;
margin: 0 0 2.992em;
&:nth-child(2n) {
&:nth-child( 2n ) {
float: right;
clear: none !important;
clear: none !important; // This should never clear.
}
}
}
@ -142,7 +142,7 @@
.coupon {
float: none;
@include clearfix();
padding-bottom: .5em;
padding-bottom: 0.5em;
input,
.button,

File diff suppressed because one or more lines are too long

View File

@ -7,11 +7,11 @@
/**
* Imports
*/
@import "bourbon";
@import "mixins";
@import "variables";
@import "animation";
@import "fonts";
@import 'bourbon';
@import 'mixins';
@import 'variables';
@import 'animation';
@import 'fonts';
/**
* Global styles
@ -29,7 +29,7 @@ p.demo_store {
background-color: $primary;
color: $primarytext;
z-index: 99998;
box-shadow: 0 1px 1em rgba(0,0,0,0.2);
box-shadow: 0 1px 1em rgba(0, 0, 0, 0.2);
a {
color: $primarytext;
}
@ -69,13 +69,13 @@ p.demo_store {
text-align: center;
line-height: 1;
border-radius: 100%;
color: red !important;
color: red !important; // Required for default theme compatibility
text-decoration: none;
font-weight: 700;
border: 0;
&:hover {
color: #fff !important;
color: #fff !important; // Required for default theme compatibility
background: red;
}
}
@ -83,7 +83,7 @@ p.demo_store {
small.note {
display: block;
color: $subtext;
font-size: .857em;
font-size: 0.857em;
margin-top: 10px;
}
@ -212,7 +212,7 @@ p.demo_store {
a {
display: inline-block;
padding: .5em 0;
padding: 0.5em 0;
font-weight: 700;
color: $secondarytext;
text-decoration: none;
@ -233,26 +233,26 @@ p.demo_store {
text-shadow: inherit;
}
&:before {
&::before {
box-shadow: 2px 2px 0 $contentbg;
}
&:after {
&::after {
box-shadow: -2px 2px 0 $contentbg;
}
}
&:before,
&:after {
&::before,
&::after {
border: 1px solid darken( $secondary, 10% );
position: absolute;
bottom: -1px;
width: 5px;
height: 5px;
content: " ";
content: ' ';
}
&:before {
&::before {
left: -6px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-bottom-right-radius: 4px;
@ -261,7 +261,7 @@ p.demo_store {
box-shadow: 2px 2px 0 $secondary;
}
&:after {
&::after {
right: -6px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-bottom-left-radius: 4px;
@ -271,9 +271,9 @@ p.demo_store {
}
}
&:before {
&::before {
position: absolute;
content: " ";
content: ' ';
width: 100%;
bottom: 0;
left: 0;
@ -303,7 +303,7 @@ p.demo_store {
}
table {
border-width: 0 0 1px 0;
border-width: 0 0 1px;
td {
padding-left: 0;
@ -376,7 +376,7 @@ p.demo_store {
td {
vertical-align: top;
padding-bottom: .5em;
padding-bottom: 0.5em;
border: 0;
}
}
@ -386,19 +386,19 @@ p.demo_store {
span.onsale {
min-height: 3.236em;
min-width: 3.236em;
padding: .202em;
padding: 0.202em;
font-size: 1em;
font-weight: 700;
position: absolute;
text-align: center;
line-height: 3.236;
top: -.5em;
left: -.5em;
top: -0.5em;
left: -0.5em;
margin: 0;
border-radius: 100%;
background-color: $highlight;
color: $highlightext;
font-size: .857em;
font-size: 0.857em;
-webkit-font-smoothing: antialiased;
}
@ -424,11 +424,11 @@ p.demo_store {
top: 0;
right: 0;
left: auto;
margin: -.5em -.5em 0 0;
margin: -0.5em -0.5em 0 0;
}
h3 {
padding: .5em 0;
padding: 0.5em 0;
margin: 0;
font-size: 1em;
}
@ -450,7 +450,7 @@ p.demo_store {
}
.star-rating {
font-size: .857em;
font-size: 0.857em;
}
.button {
@ -461,8 +461,8 @@ p.demo_store {
color: $highlight;
display: block;
font-weight: normal;
margin-bottom: .5em;
font-size: .857em;
margin-bottom: 0.5em;
font-size: 0.857em;
del {
color: inherit;
@ -525,7 +525,7 @@ p.demo_store {
line-height: 1;
font-size: 1em;
font-weight: normal;
padding: .5em;
padding: 0.5em;
min-width: 1em;
display: block;
}
@ -554,7 +554,7 @@ p.demo_store {
position: relative;
text-decoration: none;
overflow: visible;
padding: .618em 1em;
padding: 0.618em 1em;
font-weight: 700;
border-radius: 3px;
left: auto;
@ -572,14 +572,14 @@ p.demo_store {
opacity: 0.25;
padding-right: 2.618em;
&:after {
font-family: "WooCommerce";
content: "\e01c";
&::after {
font-family: 'WooCommerce';
content: '\e01c';
vertical-align: top;
-webkit-font-smoothing: antialiased;
font-weight: 400;
position: absolute;
top: .618em;
top: 0.618em;
right: 1em;
-webkit-animation: spin 2s linear infinite;
-moz-animation: spin 2s linear infinite;
@ -588,10 +588,10 @@ p.demo_store {
}
&.added {
&:after {
&::after {
font-family: 'WooCommerce';
content: "\e017";
margin-left: .53em;
content: '\e017';
margin-left: 0.53em;
vertical-align: bottom;
}
}
@ -630,7 +630,7 @@ p.demo_store {
color: inherit;
cursor: not-allowed;
opacity: 0.5;
padding: .618em 1em;
padding: 0.618em 1em;
&:hover {
color: inherit;
@ -645,7 +645,7 @@ p.demo_store {
}
a.added_to_cart {
padding-top: .5em;
padding-top: 0.5em;
white-space: nowrap;
display: inline-block;
}
@ -658,7 +658,7 @@ p.demo_store {
float: right;
color: $subtext;
font-size: 15px;
margin: 10px 0 0 0;
margin: 10px 0 0;
a {
text-decoration: none;
@ -757,8 +757,8 @@ p.demo_store {
}
}
.commentlist > li:before {
content: "";
.commentlist > li::before {
content: '';
}
}
}
@ -776,8 +776,8 @@ p.demo_store {
width: 5.4em;
font-family: 'star';
&:before {
content: "\73\73\73\73\73";
&::before {
content: '\73\73\73\73\73';
color: darken( $secondary, 10% );
float: left;
top: 0;
@ -794,8 +794,8 @@ p.demo_store {
padding-top: 1.5em;
}
span:before {
content: "\53\53\53\53\53";
span::before {
content: '\53\53\53\53\53';
top: 0;
position: absolute;
left: 0;
@ -808,7 +808,7 @@ p.demo_store {
display: block;
.star-rating {
margin: .5em 4px 0 0;
margin: 0.5em 4px 0 0;
float: left;
}
}
@ -816,14 +816,14 @@ p.demo_store {
.products {
.star-rating {
display: block;
margin: 0 0 .5em;
margin: 0 0 0.5em;
float: none;
}
}
.hreview-aggregate {
.star-rating {
margin: 10px 0 0 0;
margin: 10px 0 0;
}
}
@ -833,7 +833,7 @@ p.demo_store {
position: static;
margin: 0;
width: auto;
padding: 0 0 0;
padding: 0;
background: transparent none;
border: 0;
@ -863,7 +863,7 @@ p.demo_store {
display: inline-block;
text-decoration: none;
&:before {
&::before {
display: block;
position: absolute;
top: 0;
@ -871,40 +871,40 @@ p.demo_store {
width: 1em;
height: 1em;
line-height: 1;
font-family: "WooCommerce";
content: "\e021";
font-family: 'WooCommerce';
content: '\e021';
text-indent: 0;
}
&:hover {
~ a:before {
content: "\e021";
~ a::before {
content: '\e021';
}
}
}
&:hover {
a {
&:before {
content: "\e020";
&::before {
content: '\e020';
}
}
}
&.selected {
a.active {
&:before {
content: "\e020";
&::before {
content: '\e020';
}
~ a:before {
content: "\e021";
~ a::before {
content: '\e021';
}
}
a:not(.active) {
&:before {
content: "\e020";
a:not( .active ) {
&::before {
content: '\e020';
}
}
}
@ -915,7 +915,7 @@ p.demo_store {
*/
table.shop_attributes {
border: 0;
border-top: 1px dotted rgba(0,0,0,0.1);
border-top: 1px dotted rgba(0, 0, 0, 0.1);
margin-bottom: 1.618em;
width: 100%;
@ -924,7 +924,7 @@ p.demo_store {
font-weight: 700;
padding: 8px;
border-top: 0;
border-bottom: 1px dotted rgba(0,0,0,0.1);
border-bottom: 1px dotted rgba(0, 0, 0, 0.1);
margin: 0;
line-height: 1.5;
}
@ -933,7 +933,7 @@ p.demo_store {
font-style: italic;
padding: 0;
border-top: 0;
border-bottom: 1px dotted rgba(0,0,0,0.1);
border-bottom: 1px dotted rgba(0, 0, 0, 0.1);
margin: 0;
line-height: 1.5;
@ -945,13 +945,13 @@ p.demo_store {
.alt td,
.alt th {
background: rgba(0,0,0,0.025);
background: rgba(0, 0, 0, 0.025);
}
}
table.shop_table {
border: 1px solid rgba(0,0,0,0.1);
margin: 0px -1px 24px 0px;
border: 1px solid rgba(0, 0, 0, 0.1);
margin: 0 -1px 24px 0;
text-align: left;
width: 100%;
border-collapse: separate;
@ -963,7 +963,7 @@ p.demo_store {
}
td {
border-top: 1px solid rgba(0,0,0,0.1);
border-top: 1px solid rgba(0, 0, 0, 0.1);
padding: 6px 12px;
vertical-align: middle;
@ -985,7 +985,7 @@ p.demo_store {
tfoot th,
tbody th {
font-weight: 700;
border-top: 1px solid rgba(0,0,0,0.1);
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
}
@ -1006,14 +1006,14 @@ p.demo_store {
text-align: right;
.button {
margin: .125em 0 .125em .25em;
margin: 0.125em 0 0.125em 0.25em;
}
}
}
td.product-name {
dl.variation {
margin: .25em 0;
margin: 0.25em 0;
@include clearfix();
dt,
@ -1025,13 +1025,13 @@ p.demo_store {
dt {
font-weight: 700;
padding: 0 0 .25em 0;
padding: 0 0 0.25em;
margin: 0 4px 0 0;
clear: left;
}
dd {
padding: 0 0 .25em 0;
padding: 0 0 0.25em;
p:last-child {
margin-bottom: 0;
@ -1080,7 +1080,7 @@ p.demo_store {
dl {
margin: 0;
padding-left: 1em;
border-left: 2px solid rgba(0,0,0,0.1);
border-left: 2px solid rgba(0, 0, 0, 0.1);
@include clearfix();
dt,
@ -1092,13 +1092,13 @@ p.demo_store {
dt {
font-weight: 700;
padding: 0 0 .25em 0;
padding: 0 0 0.25em;
margin: 0 4px 0 0;
clear: left;
}
dd {
padding: 0 0 .25em 0;
padding: 0 0 0.25em;
p:last-child {
margin-bottom: 0;
@ -1253,7 +1253,7 @@ p.demo_store {
form.register {
border: 1px solid darken( $secondary, 10% );
padding: 20px;
margin: 2em 0 2em 0px;
margin: 2em 0;
text-align: left;
border-radius: 5px;
}
@ -1265,7 +1265,7 @@ p.demo_store {
li {
margin: 0;
padding: .25em 0 .25em 22px;
padding: 0.25em 0 0.25em 22px;
text-indent: -22px;
list-style: none outside;
input {
@ -1341,8 +1341,8 @@ p.demo_store {
li.chosen {
a {
&:before {
@include iconbefore( "\e013" );
&::before {
@include iconbefore( '\e013' );
color: $red;
}
}
@ -1367,8 +1367,8 @@ p.demo_store {
a {
text-decoration: none;
&:before {
@include iconbefore( "\e013" );
&::before {
@include iconbefore( '\e013' );
color: $red;
}
}
@ -1401,8 +1401,8 @@ p.demo_store {
.ui-slider {
position: relative;
text-align: left;
margin-left: .5em;
margin-right: .5em;
margin-left: 0.5em;
margin-right: 0.5em;
}
.ui-slider .ui-slider-handle {
@ -1414,17 +1414,17 @@ p.demo_store {
border-radius: 1em;
cursor: ew-resize;
outline: none;
top: -.3em;
top: -0.3em;
//&:last-child {
margin-left: -.5em;
margin-left: -0.5em;
//}
}
.ui-slider .ui-slider-range {
position: absolute;
z-index: 1;
font-size: .7em;
font-size: 0.7em;
display: block;
border: 0;
border-radius: 1em;
@ -1438,7 +1438,7 @@ p.demo_store {
}
.ui-slider-horizontal {
height: .5em;
height: 0.5em;
}
.ui-slider-horizontal .ui-slider-range {
@ -1483,8 +1483,8 @@ p.demo_store {
li.chosen {
a {
&:before {
@include iconbefore( "\e013" );
&::before {
@include iconbefore( '\e013' );
color: $red;
}
}
@ -1496,20 +1496,20 @@ p.demo_store {
.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
padding: 1em 2em 1em 3.5em !important;
margin: 0 0 2em !important;
padding: 1em 2em 1em 3.5em;
margin: 0 0 2em;
position: relative;
background-color: lighten($secondary,5%);
background-color: lighten($secondary, 5%);
color: $secondarytext;
border-top: 3px solid $primary;
list-style: none outside !important;
list-style: none outside;
@include clearfix();
width: auto;
word-wrap: break-word;
&:before {
font-family: "WooCommerce";
content: "\e028";
&::before {
font-family: 'WooCommerce';
content: '\e028';
display: inline-block;
position: absolute;
top: 1em;
@ -1521,17 +1521,17 @@ p.demo_store {
}
li {
list-style: none outside !important;
padding-left: 0 !important;
margin-left: 0 !important;
list-style: none outside !important; // Required for default theme compatibility
padding-left: 0 !important; // Required for default theme compatibility
margin-left: 0 !important; // Required for default theme compatibility
}
}
.woocommerce-message {
border-top-color: #8fae1b;
&:before {
content: "\e015";
&::before {
content: '\e015';
color: #8fae1b;
}
}
@ -1539,7 +1539,7 @@ p.demo_store {
.woocommerce-info {
border-top-color: #1e85be;
&:before {
&::before {
color: #1e85be;
}
}
@ -1547,8 +1547,8 @@ p.demo_store {
.woocommerce-error {
border-top-color: #b81c23;
&:before {
content: "\e016";
&::before {
content: '\e016';
color: #b81c23;
}
}
@ -1599,8 +1599,8 @@ p.demo_store {
margin-left: 0;
padding-left: 0;
&:before {
@include iconbefore( "\e00a" );
&::before {
@include iconbefore( '\e00a' );
}
.count {
@ -1676,8 +1676,8 @@ p.demo_store {
}
.shipping-calculator-button {
&:after {
@include iconafter( "\e019" );
&::after {
@include iconafter( '\e019' );
}
}
}
@ -1799,7 +1799,7 @@ p.demo_store {
img {
vertical-align: middle;
margin: -2px 0 0 .5em;
margin: -2px 0 0 0.5em;
padding: 0;
position: relative;
box-shadow: none;
@ -1820,7 +1820,7 @@ p.demo_store {
box-sizing: border-box;
width: 100%;
padding: 1em;
margin: 1em 0 1em 0;
margin: 1em 0;
font-size: 0.92em;
border-radius: 2px;
line-height: 1.5;
@ -1849,7 +1849,7 @@ p.demo_store {
margin: 0;
.woocommerce-SavedPaymentMethods-token,
.woocommerce-SavedPaymentMethods-new {
margin: 0 0 .5em 0;
margin: 0 0 0.5em;
label {
cursor: pointer;
}
@ -1872,43 +1872,43 @@ p.demo_store {
font-size: 1.5em;
padding: 8px;
background-repeat: no-repeat;
background-position: right .618em center;
background-position: right 0.618em center;
background-size: 32px 20px;
&.visa {
background-image: url(../images/icons/credit-cards/visa.svg);
background-image: url('../images/icons/credit-cards/visa.svg');
}
&.mastercard {
background-image: url(../images/icons/credit-cards/mastercard.svg);
background-image: url('../images/icons/credit-cards/mastercard.svg');
}
&.laser {
background-image: url(../images/icons/credit-cards/laser.svg);
background-image: url('../images/icons/credit-cards/laser.svg');
}
&.dinersclub {
background-image: url(../images/icons/credit-cards/diners.svg);
background-image: url('../images/icons/credit-cards/diners.svg');
}
&.maestro {
background-image: url(../images/icons/credit-cards/maestro.svg);
background-image: url('../images/icons/credit-cards/maestro.svg');
}
&.jcb {
background-image: url(../images/icons/credit-cards/jcb.svg);
background-image: url('../images/icons/credit-cards/jcb.svg');
}
&.amex {
background-image: url(../images/icons/credit-cards/amex.svg);
background-image: url('../images/icons/credit-cards/amex.svg');
}
&.discover {
background-image: url(../images/icons/credit-cards/discover.svg);
background-image: url('../images/icons/credit-cards/discover.svg');
}
}
span.help {
font-size: .857em;
font-size: 0.857em;
color: $subtext;
font-weight: normal;
}
@ -1921,15 +1921,15 @@ p.demo_store {
margin-bottom: 0;
}
&:before {
content: "";
&::before {
content: '';
display: block;
border: 1em solid darken( $secondary, 5% ); /* arrow size / color */
border-right-color: transparent;
border-left-color: transparent;
border-top-color: transparent;
position: absolute;
top: -.75em;
top: -0.75em;
left: 0;
margin: -1em 0 0 2em;
}
@ -1956,7 +1956,7 @@ p.demo_store {
.woocommerce-password-strength {
text-align: center;
font-weight: 600;
padding: 3px .5em;
padding: 3px 0.5em;
font-size: 1em;
&.strong {
@ -1981,7 +1981,7 @@ p.demo_store {
}
.woocommerce-password-hint {
margin: .5em 0 0 0;
margin: 0.5em 0 0;
display: block;
}
@ -2041,7 +2041,7 @@ p.demo_store {
/**
* Twenty Sixteen specific styles
*/
body:not(.search-results) {
body:not( .search-results ) {
.twentysixteen {
.entry-summary {
color: inherit;

View File

@ -88,6 +88,8 @@
}).append( this.$el );
this.resizeContent();
this.$el.focus();
$( document.body ).trigger( 'init_tooltips' );
$( document.body ).trigger( 'wc_backbone_modal_loaded', this._target );
},

View File

@ -1 +1 @@
!function(a,b,c){"use strict";a.fn.WCBackboneModal=function(b){return this.each(function(){new a.WCBackboneModal(a(this),b)})},a.WCBackboneModal=function(b,c){var d=a.extend({},a.WCBackboneModal.defaultOptions,c);d.template&&new a.WCBackboneModal.View({target:d.template,string:d.variable})},a.WCBackboneModal.defaultOptions={template:"",variable:{}},a.WCBackboneModal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,_string:void 0,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions"},resizeContent:function(){var b=a(".wc-backbone-modal-content").find("article"),c=.75*a(window).height();b.css({"max-height":c+"px"})},initialize:function(b){var d=this;this._target=b.target,this._string=b.string,c.bindAll(this,"render"),this.render(),a(window).resize(function(){d.resizeContent()})},render:function(){var b=wp.template(this._target);this.$el.attr("tabindex","0").append(b(this._string)),a(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),a(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(b){b.preventDefault(),a(document.body).trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),a(document).off("focusin"),a(document.body).css({overflow:"auto"}),this.remove(),a(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(b){a(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(b)},getFormData:function(){var b={};return a(document.body).trigger("wc_backbone_modal_before_update",this._target),a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b},keyboardActions:function(a){var b=a.keyCode||a.which;13!==b||a.target.tagName&&("input"===a.target.tagName.toLowerCase()||"textarea"===a.target.tagName.toLowerCase())||this.addButton(a),27===b&&this.closeButton(a)}})}(jQuery,Backbone,_);
!function(a,b,c){"use strict";a.fn.WCBackboneModal=function(b){return this.each(function(){new a.WCBackboneModal(a(this),b)})},a.WCBackboneModal=function(b,c){var d=a.extend({},a.WCBackboneModal.defaultOptions,c);d.template&&new a.WCBackboneModal.View({target:d.template,string:d.variable})},a.WCBackboneModal.defaultOptions={template:"",variable:{}},a.WCBackboneModal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,_string:void 0,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions"},resizeContent:function(){var b=a(".wc-backbone-modal-content").find("article"),c=.75*a(window).height();b.css({"max-height":c+"px"})},initialize:function(b){var d=this;this._target=b.target,this._string=b.string,c.bindAll(this,"render"),this.render(),a(window).resize(function(){d.resizeContent()})},render:function(){var b=wp.template(this._target);this.$el.attr("tabindex","0").append(b(this._string)),a(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$el.focus(),a(document.body).trigger("init_tooltips"),a(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(b){b.preventDefault(),a(document.body).trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),a(document).off("focusin"),a(document.body).css({overflow:"auto"}),this.remove(),a(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(b){a(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(b)},getFormData:function(){var b={};return a(document.body).trigger("wc_backbone_modal_before_update",this._target),a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b},keyboardActions:function(a){var b=a.keyCode||a.which;13!==b||a.target.tagName&&("input"===a.target.tagName.toLowerCase()||"textarea"===a.target.tagName.toLowerCase())||this.addButton(a),27===b&&this.closeButton(a)}})}(jQuery,Backbone,_);

View File

@ -120,7 +120,6 @@
this.listenTo( this.model, 'change:rates', this.setUnloadConfirmation );
this.listenTo( this.model, 'saved:rates', this.clearUnloadConfirmation );
$tbody.on( 'change autocompletechange', ':input', { view: this }, this.updateModelOnChange );
$tbody.on( 'sortupdate', { view: this }, this.updateModelOnSort );
$search_field.on( 'keyup search', { view: this }, this.onSearchField );
$pagination.on( 'click', 'a', { view: this }, this.onPageChange );
$pagination.on( 'change', 'input', { view: this }, this.onPageChange );
@ -182,13 +181,6 @@
$pagination.empty();
view.page = 1;
}
// Disable sorting if there is a search term filtering the items.
if ( $search_field.val() ) {
$tbody.sortable( 'disable' );
} else {
$tbody.sortable( 'enable' );
}
},
updateUrl: function() {
if ( ! window.history.replaceState ) {
@ -364,31 +356,6 @@
model.setRateAttribute( id, attribute, val );
},
updateModelOnSort: function( event ) {
var view = event.data.view,
model = view.model,
rates = _.indexBy( model.get( 'rates' ), 'tax_rate_id' ),
changes = {};
_.each( rates, function( rate ) {
var new_position = 0;
var old_position = parseInt( rate.tax_rate_order, 10 );
if ( $table.find( 'tr[data-id="' + rate.tax_rate_id + '"]').length ) {
new_position = parseInt( $table.find( 'tr[data-id="' + rate.tax_rate_id + '"]').index(), 10 ) + parseInt( ( view.page - 1 ) * view.per_page, 10 );
} else {
new_position = old_position;
}
if ( old_position !== new_position ) {
changes[ rate.tax_rate_id ] = _.extend( changes[ rate.tax_rate_id ] || {}, { tax_rate_order : new_position } );
}
} );
if ( _.size( changes ) ) {
model.logChanges( changes );
}
},
sanitizePage: function( page_num ) {
page_num = parseInt( page_num, 10 );
if ( page_num < 1 ) {

File diff suppressed because one or more lines are too long

View File

@ -146,7 +146,18 @@ jQuery( function( $ ) {
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
$( this ).select2( select2_args ).addClass( 'enhanced' );
if ( $( this ).data( 'sortable' ) ) {
$( this ).select2( 'container' ).find( 'ul.select2-choices' ).sortable({
containment: 'parent',
start: function() { $( this ).select2( 'onSortStart' ); },
update: function() { $( this ).select2( 'onSortEnd' ); }
});
}
});
// Ajax customer search boxes
$( ':input.wc-customer-search' ).filter( ':not(.enhanced)' ).each( function() {
@ -215,6 +226,15 @@ jQuery( function( $ ) {
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
$( this ).select2( select2_args ).addClass( 'enhanced' );
if ( $( this ).data( 'sortable' ) ) {
$( this ).select2( 'container' ).find( 'ul.select2-choices' ).sortable({
containment: 'parent',
start: function() { $( this ).select2( 'onSortStart' ); },
update: function() { $( this ).select2( 'onSortEnd' ); }
});
}
});
})

View File

@ -1 +1 @@
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_enhanced_select_params.i18n_matches_1:wc_enhanced_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_enhanced_select_params.i18n_no_matches},formatAjaxError:function(){return wc_enhanced_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_enhanced_select_params.i18n_load_more},formatSearching:function(){return wc_enhanced_select_params.i18n_searching}};return a}a(document.body).on("wc-enhanced-select-init",function(){a(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b,action:a(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a(this).data("exclude"),include:a(this).data("include"),limit:a(this).data("limit")}},results:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};a(this).data("multiple")===!0?(c.multiple=!0,c.initSelection=function(b,c){var d=a.parseJSON(b.attr("data-selected")),e=[];return a(b.val().split(",")).each(function(a,b){e.push({id:b,text:d[b]})}),c(e)},c.formatSelection=function(a){return'<div class="selected-option" data-id="'+a.id+'">'+a.text+"</div>"}):(c.multiple=!1,c.initSelection=function(a,b){var c={id:a.val(),text:a.attr("data-selected")};return b(c)}),c=a.extend(c,b()),a(this).select2(c).addClass("enhanced")}),a(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:a(this).data("exclude")}},results:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};a(this).data("multiple")===!0?(c.multiple=!0,c.initSelection=function(b,c){var d=a.parseJSON(b.attr("data-selected")),e=[];return a(b.val().split(",")).each(function(a,b){e.push({id:b,text:d[b]})}),c(e)},c.formatSelection=function(a){return'<div class="selected-option" data-id="'+a.id+'">'+a.text+"</div>"}):(c.multiple=!1,c.initSelection=function(a,b){var c={id:a.val(),text:a.attr("data-selected")};return b(c)}),c=a.extend(c,b()),a(this).select2(c).addClass("enhanced")})}).on("wc_backbone_modal_before_remove",function(){a(":input.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").select2("close")}).trigger("wc-enhanced-select-init")});
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_enhanced_select_params.i18n_matches_1:wc_enhanced_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_enhanced_select_params.i18n_no_matches},formatAjaxError:function(){return wc_enhanced_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_enhanced_select_params.i18n_load_more},formatSearching:function(){return wc_enhanced_select_params.i18n_searching}};return a}a(document.body).on("wc-enhanced-select-init",function(){a(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b,action:a(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a(this).data("exclude"),include:a(this).data("include"),limit:a(this).data("limit")}},results:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};a(this).data("multiple")===!0?(c.multiple=!0,c.initSelection=function(b,c){var d=a.parseJSON(b.attr("data-selected")),e=[];return a(b.val().split(",")).each(function(a,b){e.push({id:b,text:d[b]})}),c(e)},c.formatSelection=function(a){return'<div class="selected-option" data-id="'+a.id+'">'+a.text+"</div>"}):(c.multiple=!1,c.initSelection=function(a,b){var c={id:a.val(),text:a.attr("data-selected")};return b(c)}),c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")&&a(this).select2("container").find("ul.select2-choices").sortable({containment:"parent",start:function(){a(this).select2("onSortStart")},update:function(){a(this).select2("onSortEnd")}})}),a(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:a(this).data("exclude")}},results:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};a(this).data("multiple")===!0?(c.multiple=!0,c.initSelection=function(b,c){var d=a.parseJSON(b.attr("data-selected")),e=[];return a(b.val().split(",")).each(function(a,b){e.push({id:b,text:d[b]})}),c(e)},c.formatSelection=function(a){return'<div class="selected-option" data-id="'+a.id+'">'+a.text+"</div>"}):(c.multiple=!1,c.initSelection=function(a,b){var c={id:a.val(),text:a.attr("data-selected")};return b(c)}),c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")&&a(this).select2("container").find("ul.select2-choices").sortable({containment:"parent",start:function(){a(this).select2("onSortStart")},update:function(){a(this).select2("onSortEnd")}})})}).on("wc_backbone_modal_before_remove",function(){a(":input.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").select2("close")}).trigger("wc-enhanced-select-init")});

View File

@ -213,14 +213,14 @@
return parseInt( method.method_order, 10 );
} );
_.each( shipping_methods, function( shipping_method, instance_id ) {
_.each( shipping_methods, function( shipping_method ) {
var class_name = 'method_disabled';
if ( 'yes' === shipping_method.enabled ) {
class_name = 'method_enabled';
}
$method_list.append( '<li class="wc-shipping-zone-method"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' + instance_id + '" class="' + class_name + '">' + shipping_method.title + '</a></li>' );
$method_list.append( '<li class="wc-shipping-zone-method"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' + shipping_method.instance_id + '" class="' + class_name + '">' + shipping_method.title + '</a></li>' );
} );
} else {
$method_list.append( '<li class="wc-shipping-zone-method">' + data.strings.no_shipping_methods_offered + '</li>' );

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*global wc_add_to_cart_variation_params, wc_cart_fragments_params */
/*global wc_add_to_cart_variation_params */
/*!
* Variations Plugin
*/
@ -129,7 +129,7 @@
} );
$xhr = $.ajax( {
url: wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_variation' ),
url: wc_add_to_cart_variation_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_variation' ),
type: 'POST',
data: data,
success: function( variation ) {

File diff suppressed because one or more lines are too long

View File

@ -97,6 +97,14 @@ jQuery( function( $ ) {
}
});
// Refresh when page is shown after back button (safari)
$( window ).on( 'pageshow' , function( e ) {
if ( e.originalEvent.persisted ) {
$( '.widget_shopping_cart_content' ).empty();
$( document.body ).trigger( 'wc_fragment_refresh' );
}
} );
try {
var wc_fragments = $.parseJSON( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) ),
cart_hash = sessionStorage.getItem( cart_hash_key ),

View File

@ -1 +1 @@
jQuery(function(a){function b(){e&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(a){e&&(localStorage.setItem(f,a),sessionStorage.setItem(f,a))}function d(){a.ajax(h)}if("undefined"==typeof wc_cart_fragments_params)return!1;var e,f=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash";try{e="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(g){e=!1}var h={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(d){d&&d.fragments&&(a.each(d.fragments,function(b,c){a(b).replaceWith(c)}),e&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d.fragments)),c(d.cart_hash),d.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(e){var i=null,j=864e5;a(document.body).bind("wc_fragment_refresh updated_wc_div",function(){d()}),a(document.body).bind("added_to_cart",function(a,d,e){var g=sessionStorage.getItem(f);null!==g&&void 0!==g&&""!==g||b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d)),c(e)}),a(document.body).bind("wc_fragments_refreshed",function(){clearTimeout(i),i=setTimeout(d,j)}),a(window).on("storage onstorage",function(a){f===a.originalEvent.key&&localStorage.getItem(f)!==sessionStorage.getItem(f)&&d()});try{var k=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),l=sessionStorage.getItem(f),m=a.cookie("woocommerce_cart_hash"),n=sessionStorage.getItem("wc_cart_created");if(null!==l&&void 0!==l&&""!==l||(l=""),null!==m&&void 0!==m&&""!==m||(m=""),l&&(null===n||void 0===n||""===n))throw"No cart_created";if(n){var o=1*n+j,p=(new Date).getTime();if(o<p)throw"Fragment expired";i=setTimeout(d,o-p)}if(!k||!k["div.widget_shopping_cart_content"]||l!==m)throw"No fragment";a.each(k,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(g){d()}}else d();a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});
jQuery(function(a){function b(){e&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(a){e&&(localStorage.setItem(f,a),sessionStorage.setItem(f,a))}function d(){a.ajax(h)}if("undefined"==typeof wc_cart_fragments_params)return!1;var e,f=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash";try{e="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(g){e=!1}var h={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(d){d&&d.fragments&&(a.each(d.fragments,function(b,c){a(b).replaceWith(c)}),e&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d.fragments)),c(d.cart_hash),d.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(e){var i=null,j=864e5;a(document.body).bind("wc_fragment_refresh updated_wc_div",function(){d()}),a(document.body).bind("added_to_cart",function(a,d,e){var g=sessionStorage.getItem(f);null!==g&&void 0!==g&&""!==g||b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d)),c(e)}),a(document.body).bind("wc_fragments_refreshed",function(){clearTimeout(i),i=setTimeout(d,j)}),a(window).on("storage onstorage",function(a){f===a.originalEvent.key&&localStorage.getItem(f)!==sessionStorage.getItem(f)&&d()}),a(window).on("pageshow",function(b){b.originalEvent.persisted&&(a(".widget_shopping_cart_content").empty(),a(document.body).trigger("wc_fragment_refresh"))});try{var k=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),l=sessionStorage.getItem(f),m=a.cookie("woocommerce_cart_hash"),n=sessionStorage.getItem("wc_cart_created");if(null!==l&&void 0!==l&&""!==l||(l=""),null!==m&&void 0!==m&&""!==m||(m=""),l&&(null===n||void 0===n||""===n))throw"No cart_created";if(n){var o=1*n+j,p=(new Date).getTime();if(o<p)throw"Fragment expired";i=setTimeout(d,o-p)}if(!k||!k["div.widget_shopping_cart_content"]||l!==m)throw"No fragment";a.each(k,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(g){d()}}else d();a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});

View File

@ -354,8 +354,9 @@ jQuery( function( $ ) {
var $clicked = $( 'input[type=submit][clicked=true]' );
if ( 0 === $form.find( '.shop_table.cart' ).length ) {
return false;
return;
}
if ( is_blocked( $form ) ) {
return false;
}

File diff suppressed because one or more lines are too long

View File

@ -55,7 +55,7 @@ jQuery( function( $ ) {
$( 'input#createaccount' ).change( this.toggle_create_account ).change();
}
},
init_payment_methods: function() {
init_payment_methods: function( selectedPaymentMethod ) {
var $payment_methods = $( '.woocommerce-checkout' ).find( 'input[name="payment_method"]' );
// If there is one method, we can hide the radio input
@ -63,6 +63,11 @@ jQuery( function( $ ) {
$payment_methods.eq(0).hide();
}
// If there was a previously selected method, check that one.
if ( selectedPaymentMethod ) {
$( '#' + selectedPaymentMethod ).prop( 'checked', true );
}
// If there are none selected, select the first.
if ( 0 === $payment_methods.filter( ':checked' ).length ) {
$payment_methods.eq(0).prop( 'checked', true );
@ -271,6 +276,9 @@ jQuery( function( $ ) {
url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'update_order_review' ),
data: data,
success: function( data ) {
var selectedPaymentMethod = $( '.woocommerce-checkout input[name="payment_method"]:checked' ).attr( 'id' );
// Reload the page if requested
if ( 'true' === data.reload ) {
window.location.reload();
@ -321,7 +329,7 @@ jQuery( function( $ ) {
}
// Re-init methods
wc_checkout_form.init_payment_methods();
wc_checkout_form.init_payment_methods( selectedPaymentMethod );
// Fire updated_checkout e
$( document.body ).trigger( 'updated_checkout' );

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -104,7 +104,7 @@ abstract class WC_Data {
}
/**
* Get All Meta Data
* Get All Meta Data.
* @since 2.6.0
* @return array
*/
@ -237,7 +237,7 @@ abstract class WC_Data {
return;
}
if ( ! empty ( $this->_cache_group ) ) {
if ( ! empty( $this->_cache_group ) ) {
$cache_key = WC_Cache_Helper::get_cache_prefix( $this->_cache_group ) . $this->get_id();
$cached_meta = wp_cache_get( $cache_key, $this->_cache_group );
@ -253,21 +253,23 @@ abstract class WC_Data {
$raw_meta_data = $wpdb->get_results( $wpdb->prepare( "
SELECT " . $db_info['meta_id_field'] . ", meta_key, meta_value
FROM " . $db_info['table'] . "
WHERE " . $db_info['object_id_field'] . " = %d ORDER BY " . $db_info['meta_id_field'] . "
WHERE " . $db_info['object_id_field'] . "=%d AND meta_key NOT LIKE 'wp\_%%' ORDER BY " . $db_info['meta_id_field'] . "
", $this->get_id() ) );
if ( $raw_meta_data ) {
foreach ( $raw_meta_data as $meta ) {
if ( in_array( $meta->meta_key, $this->get_internal_meta_keys() ) ) {
continue;
}
$this->_meta_data[] = (object) array(
'key' => $meta->meta_key,
'value' => $meta->meta_value,
'value' => maybe_unserialize( $meta->meta_value ),
'meta_id' => $meta->{ $db_info['meta_id_field'] },
);
}
}
if ( ! empty ( $this->_cache_group ) ) {
if ( ! empty( $this->_cache_group ) ) {
wp_cache_set( $cache_key, $this->_meta_data, $this->_cache_group );
}
}
@ -283,7 +285,8 @@ abstract class WC_Data {
$all_meta_ids = array_map( 'absint', $wpdb->get_col( $wpdb->prepare( "
SELECT " . $db_info['meta_id_field'] . " FROM " . $db_info['table'] . "
WHERE " . $db_info['object_id_field'] . " = %d", $this->get_id() ) . "
AND meta_key NOT IN ('" . implode( "','", array_map( 'esc_sql', $this->get_internal_meta_keys() ) ) . "');
AND meta_key NOT IN ('" . implode( "','", array_map( 'esc_sql', $this->get_internal_meta_keys() ) ) . "')
AND meta_key NOT LIKE 'wp\_%%';
" ) );
$set_meta_ids = array();
@ -300,12 +303,11 @@ abstract class WC_Data {
// Delete no longer set meta data
$delete_meta_ids = array_diff( $all_meta_ids, $set_meta_ids );
foreach ( $delete_meta_ids as $meta_id ) {
delete_metadata_by_mid( $this->_meta_type, $meta_id );
}
if ( ! empty ( $this->_cache_group ) ) {
if ( ! empty( $this->_cache_group ) ) {
WC_Cache_Helper::incr_cache_prefix( $this->_cache_group );
}
$this->read_meta_data();

View File

@ -0,0 +1,595 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Legacy Abstract Order
*
* Legacy and deprecated functions are here to keep the WC_Abstract_Order clean.
* This class will be removed in future versions.
*
* @version 2.7.0
* @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/
abstract class WC_Abstract_Legacy_Order extends WC_Data {
/**
* Update a line item for the order.
*
* Note this does not update order totals.
*
* @param object|int $item order item ID or item object.
* @param WC_Product $product
* @param array $args data to update.
* @return int updated order item ID
*/
public function update_product( $item, $product, $args ) {
_deprecated_function( 'WC_Order::update_product', '2.7', 'Interact with WC_Order_Item_Product class' );
if ( is_numeric( $item ) ) {
$item = $this->get_item( $item );
}
if ( ! is_object( $item ) || ! $item->is_type( 'line_item' ) ) {
return false;
}
if ( ! $this->get_id() ) {
$this->save(); // Order must exist
}
// BW compatibility with old args
if ( isset( $args['totals'] ) ) {
foreach ( $args['totals'] as $key => $value ) {
if ( 'tax' === $key ) {
$args['total_tax'] = $value;
} elseif ( 'tax_data' === $key ) {
$args['taxes'] = $value;
} else {
$args[ $key ] = $value;
}
}
}
// Handly qty if set
if ( isset( $args['qty'] ) ) {
if ( $product->backorders_require_notification() && $product->is_on_backorder( $args['qty'] ) ) {
$item->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ) ), $args['qty'] - max( 0, $product->get_total_stock() ), true );
}
$args['subtotal'] = $args['subtotal'] ? $args['subtotal'] : $product->get_price_excluding_tax( $args['qty'] );
$args['total'] = $args['total'] ? $args['total'] : $product->get_price_excluding_tax( $args['qty'] );
}
$item->set_order_id( $this->get_id() );
$item->set_all( $args );
$item->save();
do_action( 'woocommerce_order_edit_product', $this->get_id(), $item->get_id(), $args, $product );
return $item->get_id();
}
/**
* Update coupon for order. Note this does not update order totals.
* @param object|int $item
* @param array $args
* @return int updated order item ID
*/
public function update_coupon( $item, $args ) {
_deprecated_function( 'WC_Order::update_coupon', '2.7', 'Interact with WC_Order_Item_Coupon class' );
if ( is_numeric( $item ) ) {
$item = $this->get_item( $item );
}
if ( ! is_object( $item ) || ! $item->is_type( 'coupon' ) ) {
return false;
}
if ( ! $this->get_id() ) {
$this->save(); // Order must exist
}
// BW compatibility for old args
if ( isset( $args['discount_amount'] ) ) {
$args['discount'] = $args['discount_amount'];
}
if ( isset( $args['discount_amount_tax'] ) ) {
$args['discount_tax'] = $args['discount_amount_tax'];
}
$item->set_order_id( $this->get_id() );
$item->set_all( $args );
$item->save();
do_action( 'woocommerce_order_update_coupon', $this->get_id(), $item->get_id(), $args );
return $item->get_id();
}
/**
* Update shipping method for order.
*
* Note this does not update the order total.
*
* @param object|int $item
* @param array $args
* @return int updated order item ID
*/
public function update_shipping( $item, $args ) {
_deprecated_function( 'WC_Order::update_shipping', '2.7', 'Interact with WC_Order_Item_Shipping class' );
if ( is_numeric( $item ) ) {
$item = $this->get_item( $item );
}
if ( ! is_object( $item ) || ! $item->is_type( 'shipping' ) ) {
return false;
}
if ( ! $this->get_id() ) {
$this->save(); // Order must exist
}
// BW compatibility for old args
if ( isset( $args['cost'] ) ) {
$args['total'] = $args['cost'];
}
$item->set_order_id( $this->get_id() );
$item->set_all( $args );
$item->save();
$this->calculate_shipping();
do_action( 'woocommerce_order_update_shipping', $this->get_id(), $item->get_id(), $args );
return $item->get_id();
}
/**
* Update fee for order.
*
* Note this does not update order totals.
*
* @param object|int $item
* @param array $args
* @return int updated order item ID
*/
public function update_fee( $item, $args ) {
_deprecated_function( 'WC_Order::update_fee', '2.7', 'Interact with WC_Order_Item_Fee class' );
if ( is_numeric( $item ) ) {
$item = $this->get_item( $item );
}
if ( ! is_object( $item ) || ! $item->is_type( 'fee' ) ) {
return false;
}
if ( ! $this->get_id() ) {
$this->save(); // Order must exist
}
$item->set_order_id( $this->get_id() );
$item->set_all( $args );
$item->save();
do_action( 'woocommerce_order_update_fee', $this->get_id(), $item->get_id(), $args );
return $item->get_id();
}
/**
* Update tax line on order.
* Note this does not update order totals.
*
* @since 2.7
* @param object|int $item
* @param array $args
* @return int updated order item ID
*/
public function update_tax( $item, $args ) {
_deprecated_function( 'WC_Order::update_tax', '2.7', 'Interact with WC_Order_Item_Tax class' );
if ( is_numeric( $item ) ) {
$item = $this->get_item( $item );
}
if ( ! is_object( $item ) || ! $item->is_type( 'tax' ) ) {
return false;
}
if ( ! $this->get_id() ) {
$this->save(); // Order must exist
}
$item->set_order_id( $this->get_id() );
$item->set_all( $args );
$item->save();
do_action( 'woocommerce_order_update_tax', $this->get_id(), $item->get_id(), $args );
return $item->get_id();
}
/**
* Get a product (either product or variation).
* @deprecated Add deprecation notices in future release. Replaced with $item->get_product()
* @param object $item
* @return WC_Product|bool
*/
public function get_product_from_item( $item ) {
if ( is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
} else {
$product = false;
}
return apply_filters( 'woocommerce_get_product_from_item', $product, $item, $this );
}
/**
* Set the customer address.
* @param array $address Address data.
* @param string $type billing or shipping.
*/
public function set_address( $address, $type = 'billing' ) {
foreach ( $address as $key => $value ) {
update_post_meta( $this->get_id(), "_{$type}_" . $key, $value );
if ( is_callable( array( $this, "set_{$type}_{$key}" ) ) ) {
$this->{"set_{$type}_{$key}"}( $value );
}
}
}
/**
* Set an order total.
* @param float $amount
* @param string $total_type
* @return bool
*/
public function legacy_set_total( $amount, $total_type = 'total' ) {
if ( ! in_array( $total_type, array( 'shipping', 'tax', 'shipping_tax', 'total', 'cart_discount', 'cart_discount_tax' ) ) ) {
return false;
}
switch ( $total_type ) {
case 'total' :
$amount = wc_format_decimal( $amount, wc_get_price_decimals() );
$this->set_total( $amount );
update_post_meta( $this->get_id(), '_order_total', $amount );
break;
case 'cart_discount' :
$amount = wc_format_decimal( $amount );
$this->set_discount_total( $amount );
update_post_meta( $this->get_id(), '_cart_discount', $amount );
break;
case 'cart_discount_tax' :
$amount = wc_format_decimal( $amount );
$this->set_discount_tax( $amount );
update_post_meta( $this->get_id(), '_cart_discount_tax', $amount );
break;
case 'shipping' :
$amount = wc_format_decimal( $amount );
$this->set_shipping_total( $amount );
update_post_meta( $this->get_id(), '_order_shipping', $amount );
break;
case 'shipping_tax' :
$amount = wc_format_decimal( $amount );
$this->set_shipping_tax( $amount );
update_post_meta( $this->get_id(), '_order_shipping_tax', $amount );
break;
case 'tax' :
$amount = wc_format_decimal( $amount );
$this->set_cart_tax( $amount );
update_post_meta( $this->get_id(), '_order_tax', $amount );
break;
}
return true;
}
/**
* Magic __isset method for backwards compatibility.
* @param string $key
* @return bool
*/
public function __isset( $key ) {
// Legacy properties which could be accessed directly in the past.
$legacy_props = array( 'completed_date', 'id', 'order_type', 'post', 'status', 'post_status', 'customer_note', 'customer_message', 'user_id', 'customer_user', 'prices_include_tax', 'tax_display_cart', 'display_totals_ex_tax', 'display_cart_ex_tax', 'order_date', 'modified_date', 'cart_discount', 'cart_discount_tax', 'order_shipping', 'order_shipping_tax', 'order_total', 'order_tax', 'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state', 'billing_postcode', 'billing_country', 'billing_phone', 'billing_email', 'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state', 'shipping_postcode', 'shipping_country', 'customer_ip_address', 'customer_user_agent', 'payment_method_title', 'payment_method', 'order_currency' );
return $this->get_id() ? ( in_array( $key, $legacy_props ) || metadata_exists( 'post', $this->get_id(), '_' . $key ) ) : false;
}
/**
* Magic __get method for backwards compatibility.
* @param string $key
* @return mixed
*/
public function __get( $key ) {
_doing_it_wrong( $key, 'Order properties should not be accessed directly.', '2.7' );
if ( 'completed_date' === $key ) {
return $this->get_date_completed();
} elseif ( 'paid_date' === $key ) {
return $this->get_date_paid();
} elseif ( 'modified_date' === $key ) {
return $this->get_date_modified();
} elseif ( 'order_date' === $key ) {
return $this->get_date_created();
} elseif ( 'id' === $key ) {
return $this->get_id();
} elseif ( 'post' === $key ) {
return get_post( $this->get_id() );
} elseif ( 'status' === $key || 'post_status' === $key ) {
return $this->get_status();
} elseif ( 'customer_message' === $key || 'customer_note' === $key ) {
return $this->get_customer_note();
} elseif ( in_array( $key, array( 'user_id', 'customer_user' ) ) ) {
return $this->get_customer_id();
} elseif ( 'tax_display_cart' === $key ) {
return get_option( 'woocommerce_tax_display_cart' );
} elseif ( 'display_totals_ex_tax' === $key ) {
return 'excl' === get_option( 'woocommerce_tax_display_cart' );
} elseif ( 'display_cart_ex_tax' === $key ) {
return 'excl' === get_option( 'woocommerce_tax_display_cart' );
} elseif ( 'cart_discount' === $key ) {
return $this->get_discount();
} elseif ( 'cart_discount_tax' === $key ) {
return $this->get_discount_tax();
} elseif ( 'order_tax' === $key ) {
return $this->get_cart_tax();
} elseif ( 'order_shipping_tax' === $key ) {
return $this->get_shipping_tax();
} elseif ( 'order_shipping' === $key ) {
return $this->get_shipping_total();
} elseif ( 'order_total' === $key ) {
return $this->get_total();
} elseif ( 'order_type' === $key ) {
return $this->get_type();
} elseif ( 'order_currency' === $key ) {
return $this->get_currency();
} elseif ( 'order_version' === $key ) {
return $this->get_version();
} elseif ( is_callable( array( $this, "get_{$key}" ) ) ) {
return $this->{"get_{$key}"}();
} else {
return get_post_meta( $this->get_id(), '_' . $key, true );
}
}
/**
* has_meta function for order items.
*
* @param string $order_item_id
* @return array of meta data.
*/
public function has_meta( $order_item_id ) {
global $wpdb;
_deprecated_function( 'has_meta', '2.7', 'WC_Order_item::get_meta_data' );
return $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value, meta_id, order_item_id
FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d
ORDER BY meta_id", absint( $order_item_id ) ), ARRAY_A );
}
/**
* Display meta data belonging to an item.
* @param array $item
*/
public function display_item_meta( $item ) {
_deprecated_function( 'display_item_meta', '2.7', 'wc_display_item_meta' );
$product = $item->get_product();
$item_meta = new WC_Order_Item_Meta( $item, $product );
$item_meta->display();
}
/**
* Display download links for an order item.
* @param array $item
*/
public function display_item_downloads( $item ) {
_deprecated_function( 'display_item_downloads', '2.7', 'wc_display_item_downloads' );
$product = $item->get_product();
if ( $product && $product->exists() && $product->is_downloadable() && $this->is_download_permitted() ) {
$download_files = $this->get_item_downloads( $item );
$i = 0;
$links = array();
foreach ( $download_files as $download_id => $file ) {
$i++;
$prefix = count( $download_files ) > 1 ? sprintf( __( 'Download %d', 'woocommerce' ), $i ) : __( 'Download', 'woocommerce' );
$links[] = '<small class="download-url">' . $prefix . ': <a href="' . esc_url( $file['download_url'] ) . '" target="_blank">' . esc_html( $file['name'] ) . '</a></small>' . "\n";
}
echo '<br/>' . implode( '<br/>', $links );
}
}
/**
* Get the Download URL.
*
* @param int $product_id
* @param int $download_id
* @return string
*/
public function get_download_url( $product_id, $download_id ) {
_deprecated_function( 'get_download_url', '2.7', 'WC_Order_Item_Product::get_item_download_url' );
return add_query_arg( array(
'download_file' => $product_id,
'order' => $this->get_order_key(),
'email' => urlencode( $this->get_billing_email() ),
'key' => $download_id,
), trailingslashit( home_url() ) );
}
/**
* Get the downloadable files for an item in this order.
*
* @param array $item
* @return array
*/
public function get_item_downloads( $item ) {
_deprecated_function( 'get_item_downloads', '2.7', 'WC_Order_Item_Product::get_item_downloads' );
return $item->get_item_downloads();
}
/**
* Gets shipping total. Alias of WC_Order::get_shipping_total().
* @deprecated 2.7.0 since this is an alias only.
* @return float
*/
public function get_total_shipping() {
return $this->get_shipping_total();
}
/**
* Get order item meta.
* @deprecated 2.7.0
* @param mixed $order_item_id
* @param string $key (default: '')
* @param bool $single (default: false)
* @return array|string
*/
public function get_item_meta( $order_item_id, $key = '', $single = false ) {
_deprecated_function( 'get_item_meta', '2.7', 'wc_get_order_item_meta' );
return get_metadata( 'order_item', $order_item_id, $key, $single );
}
/**
* Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta().
*
* @param mixed $order_item_id
* @return array of objects
*/
public function get_item_meta_array( $order_item_id ) {
_deprecated_function( 'get_item_meta_array', '2.7', 'WC_Order_Item::get_meta_data() (note the format has changed)' );
$item = $this->get_item( $order_item_id );
$meta_data = $item->get_meta_data();
$item_meta_array = array();
foreach ( $meta_data as $meta ) {
$item_meta_array[ $meta->meta_id ] = $meta;
}
return $item_meta_array;
}
/**
* Expand item meta into the $item array.
* @deprecated 2.7.0 Item meta no longer expanded due to new order item
* classes. This function now does nothing to avoid data breakage.
* @param array $item before expansion.
* @return array
*/
public function expand_item_meta( $item ) {
_deprecated_function( 'expand_item_meta', '2.7', '' );
return $item;
}
/**
* Load the order object. Called from the constructor.
* @deprecated 2.7.0 Logic moved to constructor
* @param int|object|WC_Order $order Order to init.
*/
protected function init( $order ) {
_deprecated_function( 'init', '2.7', 'Logic moved to constructor' );
if ( is_numeric( $order ) ) {
$this->read( $order );
} elseif ( $order instanceof WC_Order ) {
$this->read( absint( $order->get_id() ) );
} elseif ( isset( $order->ID ) ) {
$this->read( absint( $order->ID ) );
}
}
/**
* Gets an order from the database.
* @deprecated 2.7
* @param int $id (default: 0).
* @return bool
*/
public function get_order( $id = 0 ) {
_deprecated_function( 'get_order', '2.7', 'read' );
if ( ! $id ) {
return false;
}
if ( $result = get_post( $id ) ) {
$this->populate( $result );
return true;
}
return false;
}
/**
* Populates an order from the loaded post data.
* @deprecated 2.7
* @param mixed $result
*/
public function populate( $result ) {
_deprecated_function( 'populate', '2.7', 'read' );
$this->read( $result->ID );
}
/**
* Cancel the order and restore the cart (before payment).
* @deprecated 2.7.0 Moved to event handler.
* @param string $note (default: '') Optional note to add.
*/
public function cancel_order( $note = '' ) {
_deprecated_function( 'cancel_order', '2.7', 'update_status' );
WC()->session->set( 'order_awaiting_payment', false );
$this->update_status( 'cancelled', $note );
}
/**
* Record sales.
* @deprecated 2.7.0
*/
public function record_product_sales() {
_deprecated_function( 'record_product_sales', '2.7', 'wc_update_total_sales_counts' );
wc_update_total_sales_counts( $this->get_id() );
}
/**
* Increase applied coupon counts.
* @deprecated 2.7.0
*/
public function increase_coupon_usage_counts() {
_deprecated_function( 'increase_coupon_usage_counts', '2.7', 'wc_update_coupon_usage_counts' );
wc_update_coupon_usage_counts( $this->get_id() );
}
/**
* Decrease applied coupon counts.
* @deprecated 2.7.0
*/
public function decrease_coupon_usage_counts() {
_deprecated_function( 'decrease_coupon_usage_counts', '2.7', 'wc_update_coupon_usage_counts' );
wc_update_coupon_usage_counts( $this->get_id() );
}
/**
* Reduce stock levels for all line items in the order.
* @deprecated 2.7.0
*/
public function reduce_order_stock() {
_deprecated_function( 'reduce_order_stock', '2.7', 'wc_reduce_stock_levels' );
wc_reduce_stock_levels( $this->get_id() );
}
/**
* Send the stock notifications.
* @deprecated 2.7.0 No longer needs to be called directly.
*/
public function send_stock_notifications( $product, $new_stock, $qty_ordered ) {
_deprecated_function( 'send_stock_notifications', '2.7' );
}
/**
* Output items for display in html emails.
* @deprecated 2.7.0 Moved to template functions.
* @param array $args Items args.
* @return string
*/
public function email_order_items_table( $args = array() ) {
_deprecated_function( 'email_order_items_table', '2.7', 'wc_get_email_order_items' );
return wc_get_email_order_items( $this, $args );
}
/**
* Get currency.
* @deprecated 2.7.0
*/
public function get_order_currency() {
_deprecated_function( 'get_order_currency', '2.7', 'get_currency' );
return apply_filters( 'woocommerce_get_order_currency', $this->get_currency(), $this );
}
}

File diff suppressed because it is too large Load Diff

View File

@ -873,7 +873,7 @@ class WC_Product {
$tax_rates = WC_Tax::get_rates( $this->get_tax_class() );
$base_tax_rates = WC_Tax::get_base_tax_rates( $this->tax_class );
if ( ! empty( WC()->customer ) && WC()->customer->is_vat_exempt() ) {
if ( ! empty( WC()->customer ) && WC()->customer->get_is_vat_exempt() ) {
$base_taxes = WC_Tax::calc_tax( $price * $qty, $base_tax_rates, true );
$base_tax_amount = array_sum( $base_taxes );
@ -1429,7 +1429,7 @@ class WC_Product {
* @return bool
*/
public function enable_dimensions_display() {
return apply_filters( 'wc_product_enable_dimensions_display', true );
return apply_filters( 'wc_product_enable_dimensions_display', true ) && ( $this->has_dimensions() || $this->has_weight() );
}
/**
@ -1441,6 +1441,15 @@ class WC_Product {
return $this->get_dimensions() ? true : false;
}
/**
* Does a child have dimensions set?
* @since 2.7.0
* @return boolean
*/
public function child_has_dimensions() {
return false;
}
/**
* Returns the product length.
* @return string
@ -1483,6 +1492,15 @@ class WC_Product {
return $this->get_weight() ? true : false;
}
/**
* Does a child have a weight set?
* @since 2.7.0
* @return boolean
*/
public function child_has_weight() {
return false;
}
/**
* Returns formatted dimensions.
* @return string

View File

@ -126,7 +126,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
*/
public function batch_items_permissions_check( $request ) {
if ( ! wc_rest_check_post_permissions( $this->post_type, 'batch' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -521,6 +521,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
if ( 'include' === $query_args['orderby'] ) {
$query_args['orderby'] = 'post__in';
} elseif ( 'id' === $query_args['orderby'] ) {
$query_args['orderby'] = 'ID'; // ID must be capitalized
}
return $query_args;

View File

@ -0,0 +1,108 @@
<?php
/**
* REST API Shipping Zones Controller base
*
* Houses common functionality between Shipping Zones and Locations.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* REST API Shipping Zones base class.
*
* @package WooCommerce/API
* @extends WC_REST_Controller
*/
abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v1';
/**
* Route base.
*
* @var string
*/
protected $rest_base = 'shipping/zones';
/**
* Retrieve a Shipping Zone by it's ID.
*
* @param int $zone_id Shipping Zone ID.
* @return WC_Shipping_Zone|WP_Error
*/
protected function get_zone( $zone_id ) {
$zone = WC_Shipping_Zones::get_zone_by( 'zone_id', $zone_id );
if ( false === $zone ) {
return new WP_Error( 'woocommerce_rest_shipping_zone_invalid', __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
}
return $zone;
}
/**
* Check whether a given request has permission to read Shipping Zones.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( ! wc_shipping_enabled() ) {
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
}
if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check if a given request has access to create Shipping Zones.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function create_item_permissions_check( $request ) {
if ( ! wc_shipping_enabled() ) {
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
}
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check whether a given request has permission to edit Shipping Zones.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function update_items_permissions_check( $request ) {
if ( ! wc_shipping_enabled() ) {
return new WP_Error( 'rest_no_route', __( 'Shipping is disabled.', 'woocommerce' ), array( 'status' => 404 ) );
}
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
}

View File

@ -124,7 +124,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
}
if ( ! $permissions ) {
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -162,7 +162,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
}
if ( ! $permissions ) {
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -181,7 +181,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
}
if ( ! $permissions ) {
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you cannot delete resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -200,7 +200,7 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
}
if ( ! $permissions ) {
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;

View File

@ -145,7 +145,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* @return boolean
*/
public function is_taxable() {
return wc_tax_enabled() && 'taxable' === $this->tax_status && ! WC()->customer->is_vat_exempt();
return wc_tax_enabled() && 'taxable' === $this->tax_status && ! WC()->customer->get_is_vat_exempt();
}
/**

View File

@ -228,7 +228,7 @@ class WC_Admin_Assets {
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
$order = wc_get_order( $post_id );
$currency = $order->get_order_currency();
$currency = $order->get_currency();
}
$params = array(

View File

@ -271,6 +271,7 @@ class WC_Admin_Attributes {
<form action="edit.php?post_type=product&amp;page=product_attributes&amp;edit=<?php echo absint( $edit ); ?>" method="post">
<table class="form-table">
<tbody>
<?php do_action( 'woocommerce_before_edit_attribute_fields' ); ?>
<tr class="form-field form-required">
<th scope="row" valign="top">
<label for="attribute_label"><?php _e( 'Name', 'woocommerce' ); ?></label>
@ -309,7 +310,6 @@ class WC_Admin_Attributes {
<?php endforeach; ?>
<?php
/**
* Deprecated action in favor of product_attributes_type_selector filter.
*
@ -335,6 +335,7 @@ class WC_Admin_Attributes {
<p class="description"><?php _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>
</tr>
<?php do_action( 'woocommerce_after_edit_attribute_fields' ) ?>
</tbody>
</table>
<p class="submit"><input type="submit" name="save_attribute" id="submit" class="button-primary" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"></p>
@ -374,7 +375,6 @@ class WC_Admin_Attributes {
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) :
foreach ( $attribute_taxonomies as $tax ) :
?><tr>
<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>
@ -440,6 +440,8 @@ class WC_Admin_Attributes {
<h2><?php _e( 'Add New Attribute', 'woocommerce' ); ?></h2>
<p><?php _e( 'Attributes let you define extra product data, such as size or colour. You can use these attributes in the shop sidebar using the "layered nav" widgets. Please note: you cannot rename an attribute later on.', 'woocommerce' ); ?></p>
<form action="edit.php?post_type=product&amp;page=product_attributes" method="post">
<?php do_action( 'woocommerce_before_add_attribute_fields' ) ?>
<div class="form-field">
<label for="attribute_label"><?php _e( 'Name', 'woocommerce' ); ?></label>
<input name="attribute_label" id="attribute_label" type="text" value="" />
@ -489,6 +491,8 @@ class WC_Admin_Attributes {
<p class="description"><?php _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>
<?php do_action( 'woocommerce_after_add_attribute_fields' ) ?>
<p class="submit"><input type="submit" name="add_new_attribute" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Add Attribute', 'woocommerce' ); ?>"></p>
<?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?>
</form>

View File

@ -187,14 +187,14 @@ class WC_Admin_Help {
'</a>'
) . '</p>' .
'<p>' . sprintf(
__( 'For further assistance with WooCommerce core you can use the %scommunity forum%s. If you need help with premium add-ons sold by WooThemes, please %suse our helpdesk%s.', 'woocommerce' ),
__( 'For further assistance with WooCommerce core you can use the %scommunity forum%s. If you need help with premium add-ons sold by WooCommerce, please %suse our helpdesk%s.', 'woocommerce' ),
'<a href="https://wordpress.org/support/plugin/woocommerce">',
'</a>',
'<a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin">',
'</a>'
) . '</p>' .
'<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
'<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System Status', 'woocommerce' ) . '</a> <a href="' . 'https://wordpress.org/support/plugin/woocommerce' . '" class="button">' . __( 'Community Forum', 'woocommerce' ) . '</a> <a href="' . 'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin' . '" class="button">' . __( 'WooThemes 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(

View File

@ -190,8 +190,8 @@ class WC_Admin_Permalink_Settings {
}
// This is an invalid base structure and breaks pages.
if ( '%product_cat%' == $product_permalink ) {
$product_permalink = '/' . _x( 'product', 'slug', 'woocommerce' ) . '/' . $product_permalink;
if ( '/%product_cat%' === $product_permalink ) {
$product_permalink = '/' . _x( 'product', 'slug', 'woocommerce' ) . $product_permalink;
}
} elseif ( empty( $product_permalink ) ) {
$product_permalink = false;

View File

@ -607,7 +607,7 @@ class WC_Admin_Post_Types {
public function render_shop_order_columns( $column ) {
global $post, $woocommerce, $the_order;
if ( empty( $the_order ) || $the_order->id != $post->ID ) {
if ( empty( $the_order ) || $the_order->get_id() != $post->ID ) {
$the_order = wc_get_order( $post->ID );
}
@ -630,8 +630,8 @@ class WC_Admin_Post_Types {
break;
case 'customer_message' :
if ( $the_order->customer_message ) {
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $the_order->customer_message ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
if ( $the_order->get_customer_note() ) {
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $the_order->get_customer_note() ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
} else {
echo '<span class="na">&ndash;</span>';
}
@ -678,8 +678,8 @@ class WC_Admin_Post_Types {
echo '&ndash;';
}
if ( $the_order->billing_phone ) {
echo '<small class="meta">' . __( 'Tel:', 'woocommerce' ) . ' ' . esc_html( $the_order->billing_phone ) . '</small>';
if ( $the_order->get_billing_phone() ) {
echo '<small class="meta">' . __( 'Tel:', 'woocommerce' ) . ' ' . esc_html( $the_order->get_billing_phone() ) . '</small>';
}
break;
@ -727,14 +727,14 @@ class WC_Admin_Post_Types {
case 'order_total' :
echo $the_order->get_formatted_order_total();
if ( $the_order->payment_method_title ) {
echo '<small class="meta">' . __( 'Via', 'woocommerce' ) . ' ' . esc_html( $the_order->payment_method_title ) . '</small>';
if ( $the_order->get_payment_method_title() ) {
echo '<small class="meta">' . __( 'Via', 'woocommerce' ) . ' ' . esc_html( $the_order->get_payment_method_title() ) . '</small>';
}
break;
case 'order_title' :
if ( $the_order->user_id ) {
$user_info = get_userdata( $the_order->user_id );
if ( $the_order->get_user_id() ) {
$user_info = get_userdata( $the_order->get_user_id() );
}
if ( ! empty( $user_info ) ) {
@ -750,10 +750,10 @@ class WC_Admin_Post_Types {
$username .= '</a>';
} else {
if ( $the_order->billing_first_name || $the_order->billing_last_name ) {
$username = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $the_order->billing_first_name, $the_order->billing_last_name ) );
} else if ( $the_order->billing_company ) {
$username = trim( $the_order->billing_company );
if ( $the_order->get_billing_first_name()|| $the_order->get_billing_last_name() ) {
$username = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $the_order->get_billing_first_name(), $the_order->get_billing_last_name() ) );
} else if ( $the_order->get_billing_company() ) {
$username = trim( $the_order->get_billing_company() );
} else {
$username = __( 'Guest', 'woocommerce' );
}
@ -761,8 +761,8 @@ class WC_Admin_Post_Types {
printf( _x( '%s by %s', 'Order number by X', 'woocommerce' ), '<a href="' . admin_url( 'post.php?post=' . absint( $post->ID ) . '&action=edit' ) . '" class="row-title"><strong>#' . esc_attr( $the_order->get_order_number() ) . '</strong></a>', $username );
if ( $the_order->billing_email ) {
echo '<small class="meta email"><a href="' . esc_url( 'mailto:' . $the_order->billing_email ) . '">' . esc_html( $the_order->billing_email ) . '</a></small>';
if ( $the_order->get_billing_email() ) {
echo '<small class="meta email"><a href="' . esc_url( 'mailto:' . $the_order->get_billing_email() ) . '">' . esc_html( $the_order->get_billing_email() ) . '</a></small>';
}
echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'woocommerce' ) . '</span></button>';
@ -2203,12 +2203,12 @@ class WC_Admin_Post_Types {
foreach ( $existing_permissions as $existing_permission ) {
$order = wc_get_order( $existing_permission->order_id );
if ( ! empty( $order->id ) ) {
if ( $order->get_id() ) {
// Remove permissions
if ( ! empty( $removed_download_ids ) ) {
foreach ( $removed_download_ids as $download_id ) {
if ( apply_filters( 'woocommerce_process_product_file_download_paths_remove_access_to_old_file', true, $download_id, $product_id, $order ) ) {
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->id, $product_id, $download_id ) );
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->get_id(), $product_id, $download_id ) );
}
}
}
@ -2219,7 +2219,7 @@ class WC_Admin_Post_Types {
if ( apply_filters( 'woocommerce_process_product_file_download_paths_grant_access_to_new_file', true, $download_id, $product_id, $order ) ) {
// grant permission if it doesn't already exist
if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT 1=1 FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->id, $product_id, $download_id ) ) ) {
if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT 1=1 FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order->get_id(), $product_id, $download_id ) ) ) {
wc_downloadable_file_permission( $download_id, $product_id, $order );
}
}

View File

@ -40,96 +40,19 @@ class WC_Admin_Status {
$tools = self::get_tools();
if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'debug_action' ) ) {
$tools_controller = new WC_REST_System_Status_Tools_Controller;
$action = wc_clean( $_GET['action'] );
switch ( $_GET['action'] ) {
case 'clear_transients' :
wc_delete_product_transients();
wc_delete_shop_order_transients();
WC_Cache_Helper::get_transient_version( 'shipping', true );
echo '<div class="updated inline"><p>' . __( 'Product Transients Cleared', 'woocommerce' ) . '</p></div>';
break;
case 'clear_expired_transients' :
/*
* Deletes all expired transients. The multi-table delete syntax is used.
* to delete the transient record from table a, and the corresponding.
* transient_timeout record from table b.
*
* Based on code inside core's upgrade_network() function.
*/
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
WHERE a.option_name LIKE %s
AND a.option_name NOT LIKE %s
AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
AND b.option_value < %d";
$rows = $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', time() ) );
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
WHERE a.option_name LIKE %s
AND a.option_name NOT LIKE %s
AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
AND b.option_value < %d";
$rows2 = $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', time() ) );
echo '<div class="updated inline"><p>' . sprintf( __( '%d Transients Rows Cleared', 'woocommerce' ), $rows + $rows2 ) . '</p></div>';
break;
case 'reset_roles' :
// Remove then re-add caps and roles
WC_Install::remove_roles();
WC_Install::create_roles();
echo '<div class="updated inline"><p>' . __( 'Roles successfully reset', 'woocommerce' ) . '</p></div>';
break;
case 'recount_terms' :
$product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
_wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), true, false );
$product_tags = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
_wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), true, false );
echo '<div class="updated inline"><p>' . __( 'Terms successfully recounted', 'woocommerce' ) . '</p></div>';
break;
case 'clear_sessions' :
$wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" );
wp_cache_flush();
echo '<div class="updated inline"><p>' . __( 'Sessions successfully cleared', 'woocommerce' ) . '</p></div>';
break;
case 'install_pages' :
WC_Install::create_pages();
echo '<div class="updated inline"><p>' . __( 'All missing WooCommerce pages was installed successfully.', 'woocommerce' ) . '</p></div>';
break;
case 'delete_taxes' :
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;" );
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;" );
WC_Cache_Helper::incr_cache_prefix( 'taxes' );
echo '<div class="updated inline"><p>' . __( 'Tax rates successfully deleted', 'woocommerce' ) . '</p></div>';
break;
case 'reset_tracking' :
delete_option( 'woocommerce_allow_tracking' );
WC_Admin_Notices::add_notice( 'tracking' );
echo '<div class="updated inline"><p>' . __( 'Usage tracking settings successfully reset.', 'woocommerce' ) . '</p></div>';
break;
default :
$action = esc_attr( $_GET['action'] );
if ( isset( $tools[ $action ]['callback'] ) ) {
$callback = $tools[ $action ]['callback'];
$return = call_user_func( $callback );
if ( $return === false ) {
$callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback;
echo '<div class="error inline"><p>' . sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string ) . '</p></div>';
if ( array_key_exists( $action, $tools ) ) {
$response = $tools_controller->execute_tool( $action );
} else {
$response = array( 'success' => false, 'message' => __( 'Tool does not exist.', 'woocommerce' ) );
}
}
break;
if ( $response['success'] ) {
echo '<div class="updated inline"><p>' . esc_html( $response['message'] ) . '</p></div>';
} else {
echo '<div class="error inline"><p>' . esc_html( $response['message'] ) . '</p></div>';
}
}
@ -146,50 +69,8 @@ class WC_Admin_Status {
* @return array of tools
*/
public static function get_tools() {
$tools = array(
'clear_transients' => array(
'name' => __( 'WC Transients', 'woocommerce' ),
'button' => __( 'Clear transients', 'woocommerce' ),
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ),
),
'clear_expired_transients' => array(
'name' => __( 'Expired Transients', 'woocommerce' ),
'button' => __( 'Clear expired transients', 'woocommerce' ),
'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ),
),
'recount_terms' => array(
'name' => __( 'Term counts', 'woocommerce' ),
'button' => __( 'Recount terms', 'woocommerce' ),
'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ),
),
'reset_roles' => array(
'name' => __( 'Capabilities', 'woocommerce' ),
'button' => __( 'Reset capabilities', 'woocommerce' ),
'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ),
),
'clear_sessions' => array(
'name' => __( 'Customer Sessions', 'woocommerce' ),
'button' => __( 'Clear all sessions', 'woocommerce' ),
'desc' => __( '<strong class="red">Warning:</strong> This tool will delete all customer session data from the database, including any current live carts.', 'woocommerce' ),
),
'install_pages' => array(
'name' => __( 'Install WooCommerce Pages', 'woocommerce' ),
'button' => __( 'Install pages', 'woocommerce' ),
'desc' => __( '<strong class="red">Note:</strong> This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce' ),
),
'delete_taxes' => array(
'name' => __( 'Delete all WooCommerce tax rates', 'woocommerce' ),
'button' => __( 'Delete ALL tax rates', 'woocommerce' ),
'desc' => __( '<strong class="red">Note:</strong> This option will delete ALL of your tax rates, use with caution.', 'woocommerce' ),
),
'reset_tracking' => array(
'name' => __( 'Reset Usage Tracking Settings', 'woocommerce' ),
'button' => __( 'Reset usage tracking settings', 'woocommerce' ),
'desc' => __( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', 'woocommerce' ),
)
);
return apply_filters( 'woocommerce_debug_tools', $tools );
$tools_controller = new WC_REST_System_Status_Tools_Controller;
return $tools_controller->get_tools();
}
/**
@ -205,7 +86,13 @@ class WC_Admin_Status {
$viewed_log = current( $logs );
}
include_once( dirname( __FILE__ ) . '/views/html-admin-page-status-logs.php' );
$handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : '';
if ( ! empty( $_REQUEST[ 'handle' ] ) ) {
self::remove_log();
}
include_once( 'views/html-admin-page-status-logs.php' );
}
/**
@ -240,6 +127,16 @@ class WC_Admin_Status {
return $version ;
}
/**
* Return the log file handle.
*
* @param string $filename
* @return string
*/
public static function get_log_file_handle( $filename ) {
return substr( $filename, 0, strlen( $filename ) > 37 ? strlen( $filename ) - 37 : strlen( $filename ) - 4 );
}
/**
* Scan the template files.
* @param string $template_path
@ -342,4 +239,21 @@ class WC_Admin_Status {
return $update_theme_version;
}
/**
* Remove/delete the chosen file.
*/
public static function remove_log() {
if ( empty( $_REQUEST[ '_wpnonce' ] ) || ! wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'remove_log' ) ) {
wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
}
if ( ! empty( $_REQUEST[ 'handle' ] ) ) {
$logger = wc_get_logger();
$logger->remove( $_REQUEST[ 'handle' ] );
}
wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );
exit();
}
}

View File

@ -125,7 +125,7 @@ class WC_Meta_Box_Order_Actions {
if ( ! empty( $mails ) ) {
foreach ( $mails as $mail ) {
if ( $mail->id == $email_to_send ) {
$mail->trigger( $order->id );
$mail->trigger( $order->get_id() );
$order->add_order_note( sprintf( __( '%s email notification manually sent.', 'woocommerce' ), $mail->title ), false, true );
}
}

View File

@ -153,7 +153,7 @@ class WC_Meta_Box_Order_Data {
$payment_gateways = array();
}
$payment_method = ! empty( $order->payment_method ) ? $order->payment_method : '';
$payment_method = $order->get_payment_method() ? $order->get_payment_method() : '';
$order_type_object = get_post_type_object( $post->post_type );
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
@ -180,8 +180,8 @@ class WC_Meta_Box_Order_Data {
}
}
if ( $order->paid_date ) {
printf( ' ' . _x( 'on %s @ %s', 'on date at time', 'woocommerce' ), date_i18n( get_option( 'date_format' ), strtotime( $order->paid_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $order->paid_date ) ) );
if ( $order->get_date_paid() ) {
printf( ' ' . _x( 'on %s @ %s', 'on date at time', 'woocommerce' ), date_i18n( get_option( 'date_format' ), $order->get_date_paid() ), date_i18n( get_option( 'time_format' ), $order->get_date_paid() ) );
}
echo '. ';
@ -219,10 +219,10 @@ class WC_Meta_Box_Order_Data {
<p class="form-field form-field-wide wc-customer-user">
<label for="customer_user"><?php _e( 'Customer:', 'woocommerce' ) ?> <?php
if ( ! empty( $order->customer_user ) ) {
if ( $order->get_user_id() ) {
$args = array( 'post_status' => 'all',
'post_type' => 'shop_order',
'_customer_user' => absint( $order->customer_user )
'_customer_user' => absint( $order->get_user_id() )
);
printf( '<a href="%s">%s &rarr;</a>',
esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
@ -233,8 +233,8 @@ class WC_Meta_Box_Order_Data {
<?php
$user_string = '';
$user_id = '';
if ( ! empty( $order->customer_user ) ) {
$user_id = absint( $order->customer_user );
if ( $order->get_user_id() ) {
$user_id = absint( $order->get_user_id() );
$user = get_user_by( 'id', $user_id );
$user_string = esc_html( $user->display_name ) . ' (#' . absint( $user->ID ) . ' &ndash; ' . esc_html( $user->user_email ) . ')';
}
@ -266,8 +266,8 @@ class WC_Meta_Box_Order_Data {
$field_name = 'billing_' . $key;
if ( $order->$field_name ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( $order->$field_name ) ) . '</p>';
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( call_user_func( array( $order, 'get_' . $field_name ) ) ) ) . '</p>';
}
}
@ -352,8 +352,8 @@ class WC_Meta_Box_Order_Data {
$field_name = 'shipping_' . $key;
if ( ! empty( $order->$field_name ) ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( $order->$field_name ) ) . '</p>';
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( call_user_func( array( $order, 'get_' . $field_name ) ) ) ) . '</p>';
}
}
}

View File

@ -1,13 +1,9 @@
<div class="view">
<?php
global $wpdb;
if ( $metadata = $order->has_meta( $item_id ) ) {
echo '<table cellspacing="0" class="display_meta">';
foreach ( $metadata as $meta ) {
<?php if ( $meta_data = $item->get_formatted_meta_data() ) : ?>
<table cellspacing="0" class="display_meta">
<?php foreach ( $meta_data as $meta_id => $meta ) :
// Skip hidden core fields
if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
if ( in_array( $meta->key, apply_filters( 'woocommerce_hidden_order_itemmeta', array(
'_qty',
'_tax_class',
'_product_id',
@ -21,36 +17,22 @@
) ) ) ) {
continue;
}
// Skip serialised meta
if ( is_serialized( $meta['meta_value'] ) ) {
continue;
}
// Get attribute data
if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
$term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
$meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
$meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
} else {
$meta['meta_key'] = wc_attribute_label( $meta['meta_key'], $_product );
}
echo '<tr><th>' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':</th><td>' . wp_kses_post( wpautop( make_clickable( rawurldecode( $meta['meta_value'] ) ) ) ) . '</td></tr>';
}
echo '</table>';
}
?>
<tr>
<th><?php echo wp_kses_post( $meta->display_key ); ?>:</th>
<td><?php echo wp_kses_post( $meta->display_value ); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
<div class="edit" style="display: none;">
<table class="meta" cellspacing="0">
<tbody class="meta_items">
<?php
if ( $metadata = $order->has_meta( $item_id )) {
foreach ( $metadata as $meta ) {
<?php if ( $meta_data = $item->get_formatted_meta_data() ) : ?>
<?php foreach ( $meta_data as $meta_id => $meta ) :
// Skip hidden core fields
if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
if ( in_array( $meta->key, apply_filters( 'woocommerce_hidden_order_itemmeta', array(
'_qty',
'_tax_class',
'_product_id',
@ -64,26 +46,16 @@
) ) ) ) {
continue;
}
// Skip serialised meta
if ( is_serialized( $meta['meta_value'] ) ) {
continue;
}
$meta['meta_key'] = rawurldecode( $meta['meta_key'] );
$meta['meta_value'] = esc_textarea( rawurldecode( $meta['meta_value'] ) ); // using a <textarea />
$meta['meta_id'] = absint( $meta['meta_id'] );
echo '<tr data-meta_id="' . esc_attr( $meta['meta_id'] ) . '">
?>
<tr data-meta_id="<?php echo esc_attr( $meta_id ); ?>">
<td>
<input type="text" name="meta_key[' . $meta['meta_id'] . ']" value="' . esc_attr( $meta['meta_key'] ) . '" />
<textarea name="meta_value[' . $meta['meta_id'] . ']">' . $meta['meta_value'] . '</textarea>
<input type="text" name="meta_key[<?php echo esc_attr( $meta_id ); ?>]" value="<?php echo esc_attr( $meta->key ); ?>" />
<textarea name="meta_value[<?php echo esc_attr( $meta_id ); ?>]"><?php echo esc_textarea( rawurldecode( $meta->value ) ); ?></textarea>
</td>
<td width="1%"><button class="remove_order_item_meta button">&times;</button></td>
</tr>';
}
}
?>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
<tfoot>
<tr>

View File

@ -9,6 +9,7 @@
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$_product = $order->get_product_from_item( $item );
$product_link = $_product ? admin_url( 'post.php?post=' . absint( $_product->id ) . '&action=edit' ) : '';
$thumbnail = $_product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $_product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : '';
$tax_data = empty( $legacy_order ) && wc_tax_enabled() ? maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' ) : false;
@ -53,10 +54,10 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
<div class="view">
<?php
if ( isset( $item['line_total'] ) ) {
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_order_currency() ) );
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) );
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] != $item['line_total'] ) {
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_order_currency() ) ) . '</span>';
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
}
}
?>
@ -84,15 +85,15 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
<div class="view">
<?php
if ( isset( $item['line_total'] ) ) {
echo wc_price( $item['line_total'], array( 'currency' => $order->get_order_currency() ) );
echo wc_price( $item['line_total'], array( 'currency' => $order->get_currency() ) );
}
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] !== $item['line_total'] ) {
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item['line_subtotal'] - $item['line_total'], '' ), array( 'currency' => $order->get_order_currency() ) ) . '</span>';
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item['line_subtotal'] - $item['line_total'], '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
}
if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>
@ -124,17 +125,17 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
<div class="view">
<?php
if ( '' != $tax_item_total ) {
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_order_currency() ) );
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) );
} else {
echo '&ndash;';
}
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] !== $item['line_total'] ) {
echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_order_currency() ) ) . '</span>';
echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . '</span>';
}
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>

View File

@ -75,16 +75,13 @@ if ( wc_tax_enabled() ) {
<tbody id="order_line_items">
<?php
foreach ( $line_items as $item_id => $item ) {
$_product = $order->get_product_from_item( $item );
$item_meta = $order->get_item_meta( $item_id );
do_action( 'woocommerce_before_order_item_' . $item['type'] . '_html', $item_id, $item, $order );
do_action( 'woocommerce_before_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
include( 'html-order-item.php' );
do_action( 'woocommerce_order_item_' . $item['type'] . '_html', $item_id, $item, $order );
do_action( 'woocommerce_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
}
do_action( 'woocommerce_admin_order_items_after_line_items', $order->id );
do_action( 'woocommerce_admin_order_items_after_line_items', $order->get_id() );
?>
</tbody>
<tbody id="order_shipping_line_items">
@ -93,7 +90,7 @@ if ( wc_tax_enabled() ) {
foreach ( $line_items_shipping as $item_id => $item ) {
include( 'html-order-shipping.php' );
}
do_action( 'woocommerce_admin_order_items_after_shipping', $order->id );
do_action( 'woocommerce_admin_order_items_after_shipping', $order->get_id() );
?>
</tbody>
<tbody id="order_fee_line_items">
@ -101,7 +98,7 @@ if ( wc_tax_enabled() ) {
foreach ( $line_items_fee as $item_id => $item ) {
include( 'html-order-fee.php' );
}
do_action( 'woocommerce_admin_order_items_after_fees', $order->id );
do_action( 'woocommerce_admin_order_items_after_fees', $order->get_id() );
?>
</tbody>
<tbody id="order_refunds">
@ -110,7 +107,7 @@ if ( wc_tax_enabled() ) {
foreach ( $refunds as $refund ) {
include( 'html-order-refund.php' );
}
do_action( 'woocommerce_admin_order_items_after_refunds', $order->id );
do_action( 'woocommerce_admin_order_items_after_refunds', $order->get_id() );
}
?>
</tbody>
@ -129,13 +126,12 @@ if ( wc_tax_enabled() ) {
?>
<div class="wc-used-coupons">
<ul class="wc_coupon_list"><?php
echo '<li><strong>' . __( 'Coupon(s) Used', 'woocommerce' ) . '</strong></li>';
echo '<li><strong>' . __( 'Coupon(s)', 'woocommerce' ) . '</strong></li>';
foreach ( $coupons as $item_id => $item ) {
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item['name'] ) );
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) );
$link = $post_id ? add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) : add_query_arg( array( 's' => $item->get_code(), 'post_status' => 'all', 'post_type' => 'shop_coupon' ), admin_url( 'edit.php' ) );
$link = $post_id ? add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) : add_query_arg( array( 's' => $item['name'], 'post_status' => 'all', 'post_type' => 'shop_coupon' ), admin_url( 'edit.php' ) );
echo '<li class="code"><a href="' . esc_url( $link ) . '" class="tips" data-tip="' . esc_attr( wc_price( $item['discount_amount'], array( 'currency' => $order->get_order_currency() ) ) ) . '"><span>' . esc_html( $item['name'] ). '</span></a></li>';
echo '<li class="code"><a href="' . esc_url( $link ) . '" class="tips" data-tip="' . esc_attr( wc_price( $item->get_discount(), array( 'currency' => $order->get_currency() ) ) ) . '"><span>' . esc_html( $item->get_code() ). '</span></a></li>';
}
?></ul>
</div>
@ -147,25 +143,25 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php echo wc_help_tip( __( 'This is the total discount. Discounts are defined per line item.', 'woocommerce' ) ); ?> <?php _e( 'Discount', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_order_currency() ) ); ?>
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); ?>
</td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->id ); ?>
<?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->get_id() ); ?>
<tr>
<td class="label"><?php echo wc_help_tip( __( 'This is the shipping and handling total costs for the order.', 'woocommerce' ) ); ?> <?php _e( 'Shipping', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total"><?php
if ( ( $refunded = $order->get_total_shipping_refunded() ) > 0 ) {
echo '<del>' . strip_tags( wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_total_shipping() - $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</ins>';
echo '<del>' . strip_tags( wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_total_shipping() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>';
} else {
echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) );
echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_currency() ) );
}
?></td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_shipping', $order->id ); ?>
<?php do_action( 'woocommerce_admin_order_totals_after_shipping', $order->get_id() ); ?>
<?php if ( wc_tax_enabled() ) : ?>
<?php foreach ( $order->get_tax_totals() as $code => $tax ) : ?>
@ -174,7 +170,7 @@ if ( wc_tax_enabled() ) {
<td width="1%"></td>
<td class="total"><?php
if ( ( $refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id ) ) > 0 ) {
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_order_currency() ) ) . '</ins>';
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>';
} else {
echo $tax->formatted_amount;
}
@ -183,7 +179,7 @@ if ( wc_tax_enabled() ) {
<?php endforeach; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_admin_order_totals_after_tax', $order->id ); ?>
<?php do_action( 'woocommerce_admin_order_totals_after_tax', $order->get_id() ); ?>
<tr>
<td class="label"><?php _e( 'Order Total', 'woocommerce' ); ?>:</td>
@ -203,15 +199,15 @@ if ( wc_tax_enabled() ) {
</td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_total', $order->id ); ?>
<?php do_action( 'woocommerce_admin_order_totals_after_total', $order->get_id() ); ?>
<tr>
<td class="label refunded-total"><?php _e( 'Refunded', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_refunded', $order->id ); ?>
<?php do_action( 'woocommerce_admin_order_totals_after_refunded', $order->get_id() ); ?>
</table>
<div class="clear"></div>
@ -259,11 +255,11 @@ if ( wc_tax_enabled() ) {
</tr>
<tr>
<td class="label"><?php _e( 'Amount already refunded', 'woocommerce' ); ?>:</td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
</tr>
<tr>
<td class="label"><?php _e( 'Total available to refund', 'woocommerce' ); ?>:</td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
</tr>
<tr>
<td class="label"><label for="refund_amount"><?php _e( 'Refund amount', 'woocommerce' ); ?>:</label></td>
@ -283,7 +279,7 @@ if ( wc_tax_enabled() ) {
<div class="clear"></div>
<div class="refund-actions">
<?php
$refund_amount = '<span class="wc-order-refund-amount">' . wc_price( 0, array( 'currency' => $order->get_order_currency() ) ) . '</span>';
$refund_amount = '<span class="wc-order-refund-amount">' . wc_price( 0, array( 'currency' => $order->get_currency() ) ) . '</span>';
$gateway_supports_refunds = false !== $payment_gateway && $payment_gateway->supports( 'refunds' );
$gateway_name = false !== $payment_gateway ? ( ! empty( $payment_gateway->method_title ) ? $payment_gateway->method_title : $payment_gateway->get_title() ) : __( 'Payment Gateway', 'woocommerce' );
?>

View File

@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
$method_id = isset( $item['method_id'] ) ? $item['method_id'] : '';
$current_method = ( 0 === strpos( $method_id, $method->id ) ) ? $method_id : $method->id;
echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $method_id == $current_method, true, false ) . '>' . esc_html( $method->get_title() ) . '</option>';
echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $method_id == $current_method, true, false ) . '>' . esc_html( $method->get_method_title() ) . '</option>';
if ( $method_id == $current_method ) {
$found_method = true;
@ -60,10 +60,10 @@ if ( ! defined( 'ABSPATH' ) ) {
<td class="line_cost" width="1%">
<div class="view">
<?php
echo ( isset( $item['cost'] ) ) ? wc_price( wc_round_tax_total( $item['cost'] ), array( 'currency' => $order->get_order_currency() ) ) : '';
echo ( isset( $item['cost'] ) ) ? wc_price( wc_round_tax_total( $item['cost'] ), array( 'currency' => $order->get_currency() ) ) : '';
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' ) ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>
@ -87,10 +87,10 @@ if ( ! defined( 'ABSPATH' ) ) {
<td class="line_tax" width="1%">
<div class="view">
<?php
echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_order_currency() ) ) : '&ndash;';
echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '&ndash;';
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' ) ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>

View File

@ -242,14 +242,14 @@ class WC_Admin_Report {
$key = is_array( $value['meta_key'] ) ? $value['meta_key'][0] . '_array' : $value['meta_key'];
if ( strtolower( $value['operator'] ) == 'in' ) {
if ( strtolower( $value['operator'] ) == 'in' || strtolower( $value['operator'] ) == 'not in' ) {
if ( is_array( $value['meta_value'] ) ) {
$value['meta_value'] = implode( "','", $value['meta_value'] );
}
if ( ! empty( $value['meta_value'] ) ) {
$where_value = "IN ('{$value['meta_value']}')";
$where_value = "{$value['operator']} ('{$value['meta_value']}')";
}
} else {
$where_value = "{$value['operator']} '{$value['meta_value']}'";
@ -289,14 +289,14 @@ class WC_Admin_Report {
foreach ( $where as $value ) {
if ( strtolower( $value['operator'] ) == 'in' ) {
if ( strtolower( $value['operator'] ) == 'in' || strtolower( $value['operator'] ) == 'not in' ) {
if ( is_array( $value['value'] ) ) {
$value['value'] = implode( "','", $value['value'] );
}
if ( ! empty( $value['value'] ) ) {
$where_value = "IN ('{$value['value']}')";
$where_value = "{$value['operator']} ('{$value['value']}')";
}
} else {
$where_value = "{$value['operator']} '{$value['value']}'";

View File

@ -133,7 +133,7 @@ class WC_Report_Customer_List extends WP_List_Table {
if ( ! empty( $orders ) ) {
$order = $orders[0];
return '<a href="' . admin_url( 'post.php?post=' . $order->id . '&action=edit' ) . '">' . _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number() . '</a> &ndash; ' . date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) );
return '<a href="' . admin_url( 'post.php?post=' . $order->get_id() . '&action=edit' ) . '">' . _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number() . '</a> &ndash; ' . date_i18n( get_option( 'date_format' ), $order->get_date_created() );
} else {
return '-';
}

View File

@ -12,10 +12,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<h3><?php printf( __( '"%s" Tax Rates', 'woocommerce' ), $current_class ? esc_html( $current_class ) : __( 'Standard', 'woocommerce' ) ); ?></h3>
<table class="wc_tax_rates wc_input_table sortable widefat">
<table class="wc_tax_rates wc_input_table widefat">
<thead>
<tr>
<th class="sort">&nbsp;</th>
<th width="8%"><a href="https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes" target="_blank"><?php _e( 'Country&nbsp;Code', 'woocommerce' ); ?></a>&nbsp;<?php echo wc_help_tip( __( 'A 2 digit country code, e.g. US. Leave blank to apply to all.', 'woocommerce' ) ); ?></th>
<th width="8%"><?php _e( 'State&nbsp;Code', 'woocommerce' ); ?>&nbsp;<?php echo wc_help_tip( __( 'A 2 digit state code, e.g. AL. Leave blank to apply to all.', 'woocommerce' ) ); ?></th>
<th><?php _e( 'ZIP/Postcode', 'woocommerce' ); ?>&nbsp;<?php echo wc_help_tip( __( 'Postcode for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all areas. Wildcards (*) and ranges for numeric postcodes (e.g. 12345...12350) can also be used.', 'woocommerce' ) ); ?></th>
@ -29,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</thead>
<tfoot>
<tr>
<th colspan="10">
<th colspan="9">
<a href="#" class="button plus insert"><?php _e( 'Insert row', 'woocommerce' ); ?></a>
<a href="#" class="button minus remove_tax_rates"><?php _e( 'Remove selected row(s)', 'woocommerce' ); ?></a>
<a href="#" download="tax_rates.csv" class="button export"><?php _e( 'Export CSV', 'woocommerce' ); ?></a>
@ -39,15 +38,13 @@ if ( ! defined( 'ABSPATH' ) ) {
</tfoot>
<tbody id="rates">
<tr>
<th colspan="10" style="text-align: center;"><?php esc_html_e( 'Loading&hellip;', 'woocommerce' ); ?></th>
<th colspan="9" style="text-align: center;"><?php esc_html_e( 'Loading&hellip;', 'woocommerce' ); ?></th>
</tr>
</tbody>
</table>
<script type="text/html" id="tmpl-wc-tax-table-row">
<tr class="tips" data-tip="<?php echo esc_attr( sprintf( __( 'Tax rate ID: %s', 'woocommerce' ), '{{ data.tax_rate_id }}' ) ); ?>" data-id="{{ data.tax_rate_id }}">
<td class="sort"></td>
<td class="country">
<input type="text" value="{{ data.tax_rate_country }}" placeholder="*" name="tax_rate_country[{{ data.tax_rate_id }}]" class="wc_input_country_iso" data-attribute="tax_rate_country" style="text-transform:uppercase" />
</td>
@ -88,7 +85,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<script type="text/html" id="tmpl-wc-tax-table-row-empty">
<tr>
<th colspan="10" style="text-align:center"><?php esc_html_e( 'No Matching Tax Rates Found.', 'woocommerce' ); ?></th>
<th colspan="9" style="text-align:center"><?php esc_html_e( 'No Matching Tax Rates Found.', 'woocommerce' ); ?></th>
</tr>
</script>

View File

@ -11,7 +11,12 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( $logs ) : ?>
<div id="log-viewer-select">
<div class="alignleft">
<h2><?php printf( __( 'Log file: %s (%s)', 'woocommerce' ), esc_html( $viewed_log ), date_i18n( get_option( 'date_format') . ' ' . get_option( 'time_format'), filemtime( WC_LOG_DIR . $viewed_log ) ) ); ?></h2>
<h2>
<?php echo esc_html( $viewed_log ); ?>
<?php if ( ! empty( $handle ) ) : ?>
<a class="page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'handle' => $handle ), admin_url( 'admin.php?page=wc-status&tab=logs' ) ), 'remove_log' ) ); ?>" class="button"><?php esc_html_e( 'Delete Log', 'woocommerce');?></a>
<?php endif; ?>
</h2>
</div>
<div class="alignright">
<form action="<?php echo admin_url( 'admin.php?page=wc-status&tab=logs' ); ?>" method="post">
@ -26,7 +31,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="clear"></div>
</div>
<div id="log-viewer">
<textarea cols="70" rows="25"><?php echo esc_textarea( file_get_contents( WC_LOG_DIR . $viewed_log ) ); ?></textarea>
<textarea cols="70" rows="40"><?php echo esc_textarea( file_get_contents( WC_LOG_DIR . $viewed_log ) ); ?></textarea>
</div>
<?php else : ?>
<div class="updated woocommerce-message inline"><p><?php _e( 'There are currently no logs to view.', 'woocommerce' ); ?></p></div>

View File

@ -6,8 +6,15 @@
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $wpdb;
global $wpdb;
$system_status = new WC_REST_System_Status_Controller;
$environment = $system_status->get_environment_info();
$database = $system_status->get_database_info();
$active_plugins = $system_status->get_active_plugins();
$theme = $system_status->get_theme_info();
$settings = $system_status->get_settings();
$pages = $system_status->get_pages();
?>
<div class="updated woocommerce-message inline">
<p><?php _e( 'Please copy and paste this information in your ticket when contacting support:', 'woocommerce' ); ?> </p>
@ -29,54 +36,47 @@ global $wpdb;
<tr>
<td data-export-label="Home URL"><?php _e( 'Home URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The URL of your site\'s homepage.', 'woocommerce' ) ); ?></td>
<td><?php form_option( 'home' ); ?></td>
<td><?php echo esc_html( $environment['home_url'] ) ?></td>
</tr>
<tr>
<td data-export-label="Site URL"><?php _e( 'Site URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The root URL of your site.', 'woocommerce' ) ); ?></td>
<td><?php form_option( 'siteurl' ); ?></td>
<td><?php echo esc_html( $environment['site_url'] ) ?></td>
</tr>
<tr>
<td data-export-label="WC Version"><?php _e( 'WC Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce installed on your site.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( WC()->version ); ?></td>
<td><?php echo esc_html( $environment['version'] ) ?></td>
</tr>
<tr>
<td data-export-label="Log Directory Writable"><?php _e( 'Log Directory Writable', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Several WooCommerce extensions can write logs which makes debugging problems easier. The directory must be writable for this to happen.', 'woocommerce' ) ); ?></td>
<td><?php
if ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . WC_LOG_DIR . '</code></mark> ';
if ( $environment['log_directory_writable'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $environment['log_directory'] ) . '</code></mark> ';
} else {
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'To allow logging, make <code>%s</code> writable or define a custom <code>WC_LOG_DIR</code>.', 'woocommerce' ) . '</mark>', WC_LOG_DIR );
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'To allow logging, make <code>%s</code> writable or define a custom <code>WC_LOG_DIR</code>.', 'woocommerce' ) . '</mark>', $environment['log_directory'] );
}
?></td>
</tr>
<tr>
<td data-export-label="WP Version"><?php _e( 'WP Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WordPress installed on your site.', 'woocommerce' ) ); ?></td>
<td><?php bloginfo('version'); ?></td>
<td><?php echo esc_html( $environment['wp_version'] ) ?></td>
</tr>
<tr>
<td data-export-label="WP Multisite"><?php _e( 'WP Multisite', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Whether or not you have WordPress Multisite enabled.', 'woocommerce' ) ); ?></td>
<td><?php if ( is_multisite() ) echo '<span class="dashicons dashicons-yes"></span>'; else echo '&ndash;'; ?></td>
<td><?php if ( $environment['wp_multisite'] ) echo '<span class="dashicons dashicons-yes"></span>'; else echo '&ndash;'; ?></td>
</tr>
<tr>
<td data-export-label="WP Memory Limit"><?php _e( 'WP Memory Limit', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The maximum amount of memory (RAM) that your site can use at one time.', 'woocommerce' ) ); ?></td>
<td><?php
$memory = wc_let_to_num( WP_MEMORY_LIMIT );
if ( function_exists( 'memory_get_usage' ) ) {
$system_memory = wc_let_to_num( @ini_get( 'memory_limit' ) );
$memory = max( $memory, $system_memory );
}
if ( $memory < 67108864 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend setting memory to at least 64MB. See: %s', 'woocommerce' ), size_format( $memory ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'woocommerce' ) . '</a>' ) . '</mark>';
if ( $environment['wp_memory_limit'] < 67108864 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend setting memory to at least 64MB. See: %s', 'woocommerce' ), size_format( $environment['wp_memory_limit'] ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . size_format( $memory ) . '</mark>';
echo '<mark class="yes">' . size_format( $environment['wp_memory_limit'] ) . '</mark>';
}
?></td>
</tr>
@ -84,7 +84,7 @@ global $wpdb;
<td data-export-label="WP Debug Mode"><?php _e( 'WP Debug Mode', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not WordPress is in Debug Mode.', 'woocommerce' ) ); ?></td>
<td>
<?php if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) : ?>
<?php if ( $environment['wp_debug_mode'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php else : ?>
<mark class="no">&ndash;</mark>
@ -95,17 +95,17 @@ global $wpdb;
<td data-export-label="WP Cron"><?php _e( 'WP Cron', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not WP Cron Jobs are enabled.', 'woocommerce' ) ); ?></td>
<td>
<?php if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) : ?>
<mark class="no">&ndash;</mark>
<?php else : ?>
<?php if ( $environment['wp_cron'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php else : ?>
<mark class="no">&ndash;</mark>
<?php endif; ?>
</td>
</tr>
<tr>
<td data-export-label="Language"><?php _e( 'Language', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The current language used by WordPress. Default = English', 'woocommerce' ) ); ?></td>
<td><?php echo get_locale(); ?></td>
<td><?php echo esc_html( $environment['language'] ) ?></td>
</tr>
</tbody>
</table>
@ -119,23 +119,16 @@ global $wpdb;
<tr>
<td data-export-label="Server Info"><?php _e( 'Server Info', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Information about the web server that is currently hosting your site.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
<td><?php echo esc_html( $environment['server_info'] ); ?></td>
</tr>
<tr>
<td data-export-label="PHP Version"><?php _e( 'PHP Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of PHP installed on your hosting server.', 'woocommerce' ) ); ?></td>
<td><?php
// Check if phpversion function exists.
if ( function_exists( 'phpversion' ) ) {
$php_version = phpversion();
if ( version_compare( $php_version, '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum PHP version of 5.6. See: %s', 'woocommerce' ), esc_html( $php_version ), '<a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . __( 'How to update your PHP version', 'woocommerce' ) . '</a>' ) . '</mark>';
if ( version_compare( $environment['php_version'], '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum PHP version of 5.6. See: %s', 'woocommerce' ), esc_html( $environment['php_version'] ), '<a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . __( 'How to update your PHP version', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $php_version ) . '</mark>';
}
} else {
_e( "Couldn't determine PHP version because phpversion() doesn't exist.", 'woocommerce' );
echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>';
}
?></td>
</tr>
@ -143,55 +136,44 @@ global $wpdb;
<tr>
<td data-export-label="PHP Post Max Size"><?php _e( 'PHP Post Max Size', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The largest filesize that can be contained in one post.', 'woocommerce' ) ); ?></td>
<td><?php echo size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) ); ?></td>
<td><?php echo esc_html( size_format( $environment['php_post_max_size'] ) ) ?></td>
</tr>
<tr>
<td data-export-label="PHP Time Limit"><?php _e( 'PHP Time Limit', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The amount of time (in seconds) that your site will spend on a single operation before timing out (to avoid server lockups)', 'woocommerce' ) ); ?></td>
<td><?php echo ini_get( 'max_execution_time' ); ?></td>
<td><?php echo esc_html( $environment['php_max_execution_time'] ) ?></td>
</tr>
<tr>
<td data-export-label="PHP Max Input Vars"><?php _e( 'PHP Max Input Vars', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The maximum number of variables your server can use for a single function to avoid overloads.', 'woocommerce' ) ); ?></td>
<td><?php echo ini_get( 'max_input_vars' ); ?></td>
<td><?php echo esc_html( $environment['php_max_input_vars'] ) ?></td>
</tr>
<tr>
<td data-export-label="cURL Version"><?php _e( 'cURL Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of cURL installed on your server.', 'woocommerce' ) ); ?></td>
<td><?php
if ( function_exists( 'curl_version' ) ) {
$curl_version = curl_version();
echo $curl_version['version'] . ', ' . $curl_version['ssl_version'];
} else {
_e( 'N/A', 'woocommerce' );
}
?></td>
<td><?php echo esc_html( $environment['curl_version'] ) ?></td>
</tr>
<tr>
<td data-export-label="SUHOSIN Installed"><?php _e( 'SUHOSIN Installed', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Suhosin is an advanced protection system for PHP installations. It was designed to protect your servers on the one hand against a number of well known problems in PHP applications and on the other hand against potential unknown vulnerabilities within these applications or the PHP core itself. If enabled on your server, Suhosin may need to be configured to increase its data submission limits.', 'woocommerce' ) ); ?></td>
<td><?php echo extension_loaded( 'suhosin' ) ? '<span class="dashicons dashicons-yes"></span>' : '&ndash;'; ?></td>
<td><?php echo $environment['suhosin_installed'] ? '<span class="dashicons dashicons-yes"></span>' : '&ndash;'; ?></td>
</tr>
<?php endif;
if ( $wpdb->use_mysqli ) {
$ver = mysqli_get_server_info( $wpdb->dbh );
} else {
$ver = mysql_get_server_info();
}
if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : ?>
<tr>
<td data-export-label="MySQL Version"><?php _e( 'MySQL Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of MySQL installed on your hosting server.', 'woocommerce' ) ); ?></td>
<td>
<?php
$mysql_version = $wpdb->db_version();
if ( version_compare( $mysql_version, '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum MySQL version of 5.6. See: %s', 'woocommerce' ), esc_html( $mysql_version ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress Requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum MySQL version of 5.6. See: %s', 'woocommerce' ), esc_html( $environment['mysql_version'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress Requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $mysql_version ) . '</mark>';
echo '<mark class="yes">' . esc_html( $environment['mysql_version'] ) . '</mark>';
}
?>
</td>
@ -200,138 +182,96 @@ global $wpdb;
<tr>
<td data-export-label="Max Upload Size"><?php _e( 'Max Upload Size', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The largest filesize that can be uploaded to your WordPress installation.', 'woocommerce' ) ); ?></td>
<td><?php echo size_format( wp_max_upload_size() ); ?></td>
<td><?php echo size_format( $environment['max_upload_size'] ) ?></td>
</tr>
<tr>
<td data-export-label="Default Timezone is UTC"><?php _e( 'Default Timezone is UTC', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The default timezone for your server.', 'woocommerce' ) ); ?></td>
<td><?php
$default_timezone = date_default_timezone_get();
if ( 'UTC' !== $default_timezone ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'woocommerce' ), $default_timezone ) . '</mark>';
if ( 'UTC' !== $environment['default_timezone'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'woocommerce' ), $environment['default_timezone'] ) . '</mark>';
} else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} ?>
</td>
</tr>
<?php
$posting = array();
// fsockopen/cURL.
$posting['fsockopen_curl']['name'] = 'fsockopen/cURL';
$posting['fsockopen_curl']['help'] = wc_help_tip( __( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'woocommerce' ) );
if ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ) {
$posting['fsockopen_curl']['success'] = true;
} else {
$posting['fsockopen_curl']['success'] = false;
$posting['fsockopen_curl']['note'] = __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce' );
}
// SOAP.
$posting['soap_client']['name'] = 'SoapClient';
$posting['soap_client']['help'] = wc_help_tip( __( 'Some webservices like shipping use SOAP to get information from remote servers, for example, live shipping quotes from FedEx require SOAP to be installed.', 'woocommerce' ) );
if ( class_exists( 'SoapClient' ) ) {
$posting['soap_client']['success'] = true;
} else {
$posting['soap_client']['success'] = false;
$posting['soap_client']['note'] = sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' );
}
// DOMDocument.
$posting['dom_document']['name'] = 'DOMDocument';
$posting['dom_document']['help'] = wc_help_tip( __( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'woocommerce' ) );
if ( class_exists( 'DOMDocument' ) ) {
$posting['dom_document']['success'] = true;
} else {
$posting['dom_document']['success'] = false;
$posting['dom_document']['note'] = sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' );
}
// GZIP.
$posting['gzip']['name'] = 'GZip';
$posting['gzip']['help'] = wc_help_tip( __( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'woocommerce' ) );
if ( is_callable( 'gzopen' ) ) {
$posting['gzip']['success'] = true;
} else {
$posting['gzip']['success'] = false;
$posting['gzip']['note'] = sprintf( __( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'woocommerce' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' );
}
// Multibyte String.
$posting['mbstring']['name'] = 'Multibyte String';
$posting['mbstring']['help'] = wc_help_tip( __( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'woocommerce' ) );
if ( extension_loaded( 'mbstring' ) ) {
$posting['mbstring']['success'] = true;
} else {
$posting['mbstring']['success'] = false;
$posting['mbstring']['note'] = sprintf( __( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'woocommerce' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' );
}
// WP Remote Post Check.
$posting['wp_remote_post']['name'] = __( 'Remote Post', 'woocommerce');
$posting['wp_remote_post']['help'] = wc_help_tip( __( 'PayPal uses this method of communicating when sending back transaction information.', 'woocommerce' ) );
$response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array(
'timeout' => 60,
'user-agent' => 'WooCommerce/' . WC()->version,
'httpversion' => '1.1',
'body' => array(
'cmd' => '_notify-validate'
)
) );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$posting['wp_remote_post']['success'] = true;
} else {
$posting['wp_remote_post']['note'] = __( 'wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider.', 'woocommerce' );
if ( is_wp_error( $response ) ) {
$posting['wp_remote_post']['note'] .= ' ' . sprintf( __( 'Error: %s', 'woocommerce' ), wc_clean( $response->get_error_message() ) );
} else {
$posting['wp_remote_post']['note'] .= ' ' . sprintf( __( 'Status code: %s', 'woocommerce' ), wc_clean( $response['response']['code'] ) );
}
$posting['wp_remote_post']['success'] = false;
}
// WP Remote Get Check.
$posting['wp_remote_get']['name'] = __( 'Remote Get', 'woocommerce');
$posting['wp_remote_get']['help'] = wc_help_tip( __( 'WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce' ) );
$response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$posting['wp_remote_get']['success'] = true;
} else {
$posting['wp_remote_get']['note'] = __( 'wp_remote_get() failed. The WooCommerce plugin updater won\'t work with your server. Contact your hosting provider.', 'woocommerce' );
if ( is_wp_error( $response ) ) {
$posting['wp_remote_get']['note'] .= ' ' . sprintf( __( 'Error: %s', 'woocommerce' ), wc_clean( $response->get_error_message() ) );
} else {
$posting['wp_remote_get']['note'] .= ' ' . sprintf( __( 'Status code: %s', 'woocommerce' ), wc_clean( $response['response']['code'] ) );
}
$posting['wp_remote_get']['success'] = false;
}
$posting = apply_filters( 'woocommerce_debug_posting', $posting );
foreach ( $posting as $post ) {
$mark = ! empty( $post['success'] ) ? 'yes' : 'error';
?>
<tr>
<td data-export-label="<?php echo esc_html( $post['name'] ); ?>"><?php echo esc_html( $post['name'] ); ?>:</td>
<td class="help"><?php echo isset( $post['help'] ) ? $post['help'] : ''; ?></td>
<td>
<mark class="<?php echo $mark; ?>">
<?php echo ! empty( $post['success'] ) ? '<span class="dashicons dashicons-yes"></span>' : '<span class="dashicons dashicons-no-alt"></span>'; ?> <?php echo ! empty( $post['note'] ) ? wp_kses_data( $post['note'] ) : ''; ?>
</mark>
<td data-export-label="fsockopen/cURL"><?php _e( 'fsockopen/cURL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['fsockopen_or_curl_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce' ) . '</mark>';
} ?>
</td>
</tr>
<tr>
<td data-export-label="SoapClient"><?php _e( 'SoapClient', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Some webservices like shipping use SOAP to get information from remote servers, for example, live shipping quotes from FedEx require SOAP to be installed.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['soapclient_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>';
} ?>
</td>
</tr>
<tr>
<td data-export-label="DOMDocument"><?php _e( 'DOMDocument', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['domdocument_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>';
} ?>
</td>
</tr>
<tr>
<td data-export-label="GZip"><?php _e( 'GZip', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['gzip_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'woocommerce' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>';
} ?>
</td>
</tr>
<tr>
<td data-export-label="Multibyte String"><?php _e( 'Multibyte String', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['mbstring_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'woocommerce' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>';
} ?>
</td>
</tr>
<tr>
<td data-export-label="Remote Post"><?php _e( 'Remote Post', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'PayPal uses this method of communicating when sending back transaction information.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['remote_post_successful'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'wp_remote_post() failed. Contact your hosting provider.', 'woocommerce' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>';
} ?>
</td>
</tr>
<tr>
<td data-export-label="Remote Get"><?php _e( 'Remote Get', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce' ) ); ?></td>
<td><?php
if ( $environment['remote_get_successful'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'wp_remote_get() failed. Contact your hosting provider.', 'woocommerce' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>';
} ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
@ -344,137 +284,83 @@ global $wpdb;
<tr>
<td data-export-label="WC Database Version"><?php _e( 'WC Database Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce Version.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( get_option( 'woocommerce_db_version' ) ); ?></td>
<td><?php echo esc_html( $database['wc_database_version'] ); ?></td>
</tr>
<tr>
<td data-export-label="WC Database Prefix"><?php _e( 'Database Prefix', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php
if ( strlen( $wpdb->prefix ) > 20 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend using a prefix with less than 20 characters. See: %s', 'woocommerce' ), esc_html( $wpdb->prefix ), '<a href="https://docs.woocommerce.com/document/completed-order-email-doesnt-contain-download-links/#section-2" target="_blank">' . __( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>';
if ( strlen( $database['database_prefix'] ) > 20 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend using a prefix with less than 20 characters. See: %s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '<a href="https://docs.woocommerce.com/document/completed-order-email-doesnt-contain-download-links/#section-2" target="_blank">' . __( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $wpdb->prefix ) . '</mark>';
echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<?php
$tables = array(
'woocommerce_sessions',
'woocommerce_api_keys',
'woocommerce_attribute_taxonomies',
'woocommerce_downloadable_product_permissions',
'woocommerce_order_items',
'woocommerce_order_itemmeta',
'woocommerce_tax_rates',
'woocommerce_tax_rate_locations',
'woocommerce_shipping_zones',
'woocommerce_shipping_zone_locations',
'woocommerce_shipping_zone_methods',
'woocommerce_payment_tokens',
'woocommerce_payment_tokenmeta',
);
if ( get_option( 'db_version' ) < 34370 ) {
$tables[] = 'woocommerce_termmeta';
}
foreach ( $tables as $table ) {
foreach ( $database['database_tables'] as $table => $table_exists ) {
?>
<tr>
<td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td>
<td><?php echo $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s;", $wpdb->prefix . $table ) ) !== $wpdb->prefix . $table ? '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>' : '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; ?></td>
<td><?php echo ! $table_exists ? '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>' : '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; ?></td>
</tr>
<?php
}
if ( in_array( get_option( 'woocommerce_default_customer_address' ), array( 'geolocation_ajax', 'geolocation' ) ) ) {
if ( $settings['geolocation_enabled'] ) {
?>
<tr>
<td data-export-label="MaxMind GeoIP Database"><?php _e( 'MaxMind GeoIP Database', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The GeoIP database from MaxMind is used to geolocate customers.', 'woocommerce' ) ); ?></td>
<td><?php
if ( file_exists( WC_Geolocation::get_local_database_path() ) ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( WC_Geolocation::get_local_database_path() ) . '</code></mark> ';
if ( file_exists( $database['maxmind_geoip_database'] ) ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $database['maxmind_geoip_database'] ) . '</code></mark> ';
} else {
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to \"Downloads\" and download the \"Binary / gzip\" file next to \"GeoLite Country\"', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . WC_Geolocation::get_local_database_path() . '</code>' ) . '</mark>', WC_LOG_DIR );
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . $database['maxmind_geoip_database'] . '</code>' ) . '</mark>', WC_LOG_DIR );
}
?></td>
</tr>
<?php
}
?>
</tr>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Active Plugins (<?php echo count( (array) get_option( 'active_plugins' ) ); ?>)"><h2><?php _e( 'Active Plugins', 'woocommerce' ); ?> (<?php echo count( (array) get_option( 'active_plugins' ) ); ?>)</h2></th>
<th colspan="3" data-export-label="Active Plugins (<?php echo count( $active_plugins ) ?>)"><h2><?php _e( 'Active Plugins', 'woocommerce' ); ?> (<?php echo count( $active_plugins ) ?>)</h2></th>
</tr>
</thead>
<tbody>
<?php
$active_plugins = (array) get_option( 'active_plugins', array() );
if ( is_multisite() ) {
$network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
$active_plugins = array_merge( $active_plugins, $network_activated_plugins );
}
foreach ( $active_plugins as $plugin ) {
$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
$dirname = dirname( $plugin );
$version_string = '';
$network_string = '';
if ( ! empty( $plugin_data['Name'] ) ) {
if ( ! empty( $plugin['name'] ) ) {
$dirname = dirname( $plugin['plugin'] );
// Link the plugin name to the plugin url if available.
$plugin_name = esc_html( $plugin_data['Name'] );
if ( ! empty( $plugin_data['PluginURI'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin_data['PluginURI'] ) . '" title="' . esc_attr__( 'Visit plugin homepage' , 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
$plugin_name = esc_html( $plugin['name'] );
if ( ! empty( $plugin['url'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" title="' . esc_attr__( 'Visit plugin homepage' , 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
}
if ( strstr( $dirname, 'woocommerce-' ) && strstr( $plugin_data['PluginURI'], 'woothemes.com' ) ) {
if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
$changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) );
if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) {
$date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
$version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
$update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog );
set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
break;
}
}
}
$version_string = '';
$network_string = '';
if ( strstr( $plugin['url'], 'woothemes.com' ) ) {
if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
$version_string = ' &ndash; <strong style="color:red;">' . esc_html( sprintf( _x( '%s is available', 'Version info', 'woocommerce' ), $plugin['version_latest'] ) ) . '</strong>';
}
if ( ! empty( $version_data['version'] ) && version_compare( $version_data['version'], $plugin_data['Version'], '>' ) ) {
$version_string = ' &ndash; <strong style="color:red;">' . esc_html( sprintf( _x( '%s is available', 'Version info', 'woocommerce' ), $version_data['version'] ) ) . '</strong>';
}
if ( $plugin_data['Network'] != false ) {
if ( $plugin['network_activated'] != false ) {
$network_string = ' &ndash; <strong style="color:black;">' . __( 'Network enabled', 'woocommerce' ) . '</strong>';
}
}
?>
<tr>
<td><?php echo $plugin_name; ?></td>
<td class="help">&nbsp;</td>
<td><?php echo sprintf( _x( 'by %s', 'by author', 'woocommerce' ), $plugin_data['Author'] ) . ' &ndash; ' . esc_html( $plugin_data['Version'] ) . $version_string . $network_string; ?></td>
<td><?php echo sprintf( _x( 'by %s', 'by author', 'woocommerce' ), $plugin['author_name'] ) . ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $network_string; ?></td>
</tr>
<?php
}
@ -489,49 +375,51 @@ global $wpdb;
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="API Enabled"><?php _e( 'API Enabled', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Does your site have REST API enabled?', 'woocommerce' ) ); ?></td>
<td><?php echo $settings['api_enabled'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">&ndash;</mark>'; ?></td>
</tr>
<tr>
<td data-export-label="Force SSL"><?php _e( 'Force SSL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Does your site force a SSL Certificate for transactions?', 'woocommerce' ) ); ?></td>
<td><?php echo 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">&ndash;</mark>'; ?></td>
<td><?php echo $settings['force_ssl'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">&ndash;</mark>'; ?></td>
</tr>
<tr>
<td data-export-label="Currency"><?php _e( 'Currency', 'woocommerce' ) ?></td>
<td class="help"><?php echo wc_help_tip( __( 'What currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ) ); ?></td>
<td><?php echo get_woocommerce_currency(); ?> (<?php echo get_woocommerce_currency_symbol() ?>)</td>
<td><?php echo esc_html( $settings['currency'] ) ?> (<?php echo esc_html( $settings['currency_symbol'] ) ?>)</td>
</tr>
<tr>
<td data-export-label="Currency Position"><?php _e( 'Currency Position', 'woocommerce' ) ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The position of the currency symbol.', 'woocommerce' ) ); ?></td>
<td><?php echo get_option( 'woocommerce_currency_pos' ); ?></td>
<td><?php echo esc_html( $settings['currency_position'] ) ?></td>
</tr>
<tr>
<td data-export-label="Thousand Separator"><?php _e( 'Thousand Separator', 'woocommerce' ) ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The thousand separator of displayed prices.', 'woocommerce' ) ); ?></td>
<td><?php echo wc_get_price_thousand_separator(); ?></td>
<td><?php echo esc_html( $settings['thousand_separator'] ) ?></td>
</tr>
<tr>
<td data-export-label="Decimal Separator"><?php _e( 'Decimal Separator', 'woocommerce' ) ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The decimal separator of displayed prices.', 'woocommerce' ) ); ?></td>
<td><?php echo wc_get_price_decimal_separator(); ?></td>
<td><?php echo esc_html( $settings['decimal_separator'] ) ?></td>
</tr>
<tr>
<td data-export-label="Number of Decimals"><?php _e( 'Number of Decimals', 'woocommerce' ) ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The number of decimal points shown in displayed prices.', 'woocommerce' ) ); ?></td>
<td><?php echo wc_get_price_decimals(); ?></td>
<td><?php echo esc_html( $settings['number_of_decimals'] ) ?></td>
</tr>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="API"><h2><?php _e( 'API', 'woocommerce' ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="API Enabled"><?php _e( 'API Enabled', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Does your site have REST API enabled?', 'woocommerce' ) ); ?></td>
<td><?php echo 'yes' === get_option( 'woocommerce_api_enabled' ) ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">&ndash;</mark>'; ?></td>
<td data-export-label="Taxonomies: Product Types"><?php _e( 'Taxonomies: Product Types', 'woocommerce' ); ?></th>
<td class="help"><?php echo wc_help_tip( __( 'A list of taxonomy terms that can be used in regard to order/product statuses.', 'woocommerce' ) ); ?></td>
<td><?php
$display_terms = array();
foreach ( $settings['taxonomies'] as $slug => $name ) {
$display_terms[] = strtolower( $name ) . ' (' . $slug . ')';
}
echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td>
</tr>
</tbody>
</table>
@ -543,177 +431,109 @@ global $wpdb;
</thead>
<tbody>
<?php
$check_pages = array(
_x( 'Shop Base', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_shop_page_id',
'shortcode' => '',
'help' => __( 'The URL of your WooCommerce shop\'s homepage (along with the Page ID).', 'woocommerce' ),
),
_x( 'Cart', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_cart_page_id',
'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']',
'help' => __( 'The URL of your WooCommerce shop\'s cart (along with the page ID).', 'woocommerce' ),
),
_x( 'Checkout', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_checkout_page_id',
'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']',
'help' => __( 'The URL of your WooCommerce shop\'s checkout (along with the page ID).', 'woocommerce' ),
),
_x( 'My Account', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_myaccount_page_id',
'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']',
'help' => __( 'The URL of your WooCommerce shop\'s “My Account” Page (along with the page ID).', 'woocommerce' ),
)
);
$alt = 1;
foreach ( $check_pages as $page_name => $values ) {
foreach ( $pages as $page ) {
$error = false;
$page_id = get_option( $values['option'] );
if ( $page_id ) {
$page_name = '<a href="' . get_edit_post_link( $page_id ) . '" title="' . sprintf( _x( 'Edit %s page', 'WC Pages links in the System Status', 'woocommerce' ), esc_html( $page_name ) ) . '">' . esc_html( $page_name ) . '</a>';
if ( $page['page_id'] ) {
$page_name = '<a href="' . get_edit_post_link( $page['page_id'] ) . '" title="' . sprintf( _x( 'Edit %s page', 'WC Pages links in the System Status', 'woocommerce' ), esc_html( $page['page_name'] ) ) . '">' . esc_html( $page['page_name'] ) . '</a>';
} else {
$page_name = esc_html( $page_name );
$page_name = esc_html( $page['page_name'] );
}
echo '<tr><td data-export-label="' . esc_attr( $page_name ) . '">' . $page_name . ':</td>';
echo '<td class="help">' . wc_help_tip( $values['help'] ) . '</td><td>';
echo '<td class="help">' . wc_help_tip( sprintf( __( 'The URL of your WooCommerce shop\'s %s (along with the Page ID).', 'woocommerce' ), $page_name ) ) . '</td><td>';
// Page ID check.
if ( ! $page_id ) {
if ( ! $page['page_set'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page not set', 'woocommerce' ) . '</mark>';
$error = true;
} else if ( ! get_post( $page_id ) ) {
} else if ( ! $page['page_exists'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page ID is set, but the page does not exist', 'woocommerce' ) . '</mark>';
$error = true;
} else if ( get_post_status( $page_id ) !== 'publish' ) {
} else if ( ! $page['page_visible'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page visibility should be %spublic%s', 'woocommerce' ), '<a href="https://codex.wordpress.org/Content_Visibility" target="_blank">', '</a>' ) . '</mark>';
$error = true;
} else {
// Shortcode check
if ( $values['shortcode'] ) {
$page = get_post( $page_id );
if ( empty( $page ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page does not exist', 'woocommerce' ) ) . '</mark>';
if ( $page['shortcode_required'] ) {
if ( ! $page['shortcode_present'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page does not contain the shortcode.', 'woocommerce' ), $page['shortcode'] ) . '</mark>';
$error = true;
} else if ( ! strstr( $page->post_content, $values['shortcode'] ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page does not contain the shortcode: %s', 'woocommerce' ), $values['shortcode'] ) . '</mark>';
$error = true;
}
}
}
}
if ( ! $error ) echo '<mark class="yes">#' . absint( $page_id ) . ' - ' . str_replace( home_url(), '', get_permalink( $page_id ) ) . '</mark>';
if ( ! $error ) echo '<mark class="yes">#' . absint( $page['page_id'] ) . ' - ' . str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) . '</mark>';
echo '</td></tr>';
}
?>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Taxonomies"><h2><?php _e( 'Taxonomies', 'woocommerce' ); ?><?php echo wc_help_tip( __( 'A list of taxonomy terms that can be used in regard to order/product statuses.', 'woocommerce' ) ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="Product Types"><?php _e( 'Product Types', 'woocommerce' ); ?>:</td>
<td class="help">&nbsp;</td>
<td><?php
$display_terms = array();
$terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
$display_terms[] = strtolower( $term->name ) . ' (' . $term->slug . ')';
}
echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td>
</tr>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Theme"><h2><?php _e( 'Theme', 'woocommerce' ); ?></h2></th>
</tr>
</thead>
<?php
include_once( ABSPATH . 'wp-admin/includes/theme-install.php' );
$active_theme = wp_get_theme();
$theme_version = $active_theme->Version;
$update_theme_version = WC_Admin_Status::get_latest_theme_version( $active_theme );
?>
<tbody>
<tr>
<td data-export-label="Name"><?php _e( 'Name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the current active theme.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $active_theme->Name ); ?></td>
<td><?php echo esc_html( $theme['name'] ) ?></td>
</tr>
<tr>
<td data-export-label="Version"><?php _e( 'Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the current active theme.', 'woocommerce' ) ); ?></td>
<td><?php
echo esc_html( $theme_version );
if ( version_compare( $theme_version, $update_theme_version, '<' ) ) {
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $update_theme_version ) ) . '</strong>';
echo esc_html( $theme['version'] );
if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) {
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . '</strong>';
}
?></td>
</tr>
<tr>
<td data-export-label="Author URL"><?php _e( 'Author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The theme developers URL.', 'woocommerce' ) ); ?></td>
<td><?php echo $active_theme->{'Author URI'}; ?></td>
<td><?php echo esc_html( $theme['author_url'] ) ?></td>
</tr>
<tr>
<td data-export-label="Child Theme"><?php _e( 'Child Theme', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not the current theme is a child theme.', 'woocommerce' ) ); ?></td>
<td><?php
echo is_child_theme() ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> &ndash; ' . sprintf( __( 'If you\'re modifying WooCommerce on a parent theme you didn\'t build personally, then we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'woocommerce' ), 'https://codex.wordpress.org/Child_Themes' );
echo $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> &ndash; ' . sprintf( __( 'If you\'re modifying WooCommerce on a parent theme you didn\'t build personally, then we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'woocommerce' ), 'https://codex.wordpress.org/Child_Themes' );
?></td>
</tr>
<?php
if( is_child_theme() ) :
$parent_theme = wp_get_theme( $active_theme->Template );
$update_theme_version = WC_Admin_Status::get_latest_theme_version( $parent_theme );
if( $theme['is_child_theme'] ) :
?>
<tr>
<td data-export-label="Parent Theme Name"><?php _e( 'Parent Theme Name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the parent theme.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $parent_theme->Name ); ?></td>
<td><?php echo esc_html( $theme['parent_name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Version"><?php _e( 'Parent Theme Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the parent theme.', 'woocommerce' ) ); ?></td>
<td><?php
echo esc_html( $parent_theme->Version );
if ( version_compare( $parent_theme->Version, $update_theme_version, '<' ) ) {
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $update_theme_version ) ) . '</strong>';
echo esc_html( $theme['parent_version'] );
if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) {
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>';
}
?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Author URL"><?php _e( 'Parent Theme Author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The parent theme developers URL.', 'woocommerce' ) ); ?></td>
<td><?php echo $parent_theme->{'Author URI'}; ?></td>
<td><?php echo esc_html( $theme['parent_author_url'] ) ?></td>
</tr>
<?php endif ?>
<tr>
<td data-export-label="WooCommerce Support"><?php _e( 'WooCommerce Support', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not the current active theme declares WooCommerce support.', 'woocommerce' ) ); ?></td>
<td><?php
if ( ! current_theme_supports( 'woocommerce' ) && ! in_array( $active_theme->template, wc_get_core_supported_themes() ) ) {
if ( ! $theme['has_woocommerce_support'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Not Declared', 'woocommerce' ) . '</mark>';
} else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
@ -729,62 +549,36 @@ global $wpdb;
</tr>
</thead>
<tbody>
<?php if ( file_exists( get_stylesheet_directory() . '/woocommerce.php' ) || file_exists( get_template_directory() . '/woocommerce.php' ) ) : ?>
<?php if ( $theme['has_woocommerce_file'] ) : ?>
<tr>
<td data-export-label="Overrides"><?php _e( 'Archive Template', 'woocommerce' ); ?>:</td>
<td data-export-label="Archive Template"><?php _e( 'Archive Template', 'woocommerce' ); ?>:</td>
<td class="help">&nbsp;</td>
<td><?php _e( 'Your theme has a woocommerce.php file, you will not be able to override the woocommerce/archive-product.php custom template since woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.', 'woocommerce' ); ?></td>
</tr>
<?php endif ?>
<?php
$template_paths = apply_filters( 'woocommerce_template_overrides_scan_paths', array( 'WooCommerce' => WC()->plugin_path() . '/templates/' ) );
$scanned_files = array();
$found_files = array();
$outdated_templates = false;
foreach ( $template_paths as $plugin_name => $template_path ) {
$scanned_files = WC_Admin_Status::scan_template_files( $template_path );
foreach ( $scanned_files as $file ) {
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/' . $file;
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
$theme_file = get_template_directory() . '/' . $file;
} elseif( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
$theme_file = get_template_directory() . '/woocommerce/' . $file;
} else {
$theme_file = false;
}
if ( ! empty( $theme_file ) ) {
$core_version = WC_Admin_Status::get_file_version( $template_path . $file );
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
if ( ! $outdated_templates ) {
$outdated_templates = true;
}
$found_files[ $plugin_name ][] = sprintf( __( '<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'woocommerce' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
} else {
$found_files[ $plugin_name ][] = sprintf( '<code>%s</code>', str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ) );
}
}
}
}
if ( ! empty( $found_files ) ) {
foreach ( $found_files as $plugin_name => $found_plugin_files ) {
?>
if ( ! empty( $theme['overrides'] ) ) { ?>
<tr>
<td data-export-label="Overrides"><?php _e( 'Overrides', 'woocommerce' ); ?> (<?php echo $plugin_name; ?>):</td>
<td data-export-label="Overrides"><?php _e( 'Overrides', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php echo implode( ', <br/>', $found_plugin_files ); ?></td>
<td>
<?php
for ( $i = 0; $i < count( $theme['overrides'] ); $i++ ) {
$override = $theme['overrides'][ $i ];
if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) {
printf( __( '<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'woocommerce' ), $override['file'], $override['version'] ? $override['version'] : '-', $override['core_version'] );
} else {
echo esc_html( $override['file'] );
}
if ( $i !== ( count( $theme['overrides'] ) - 1 ) ) {
echo ', ';
}
echo '<br />';
}
?>
</td>
</tr>
<?php
}
} else {
?>
<tr>
@ -795,12 +589,12 @@ global $wpdb;
<?php
}
if ( true === $outdated_templates ) {
if ( true === $theme['has_outdated_templates'] ) {
?>
<tr>
<td>&nbsp;</td>
<td data-export-label="Outdated Templates"><?php _e( 'Outdated Templates', 'woocommerce' ); ?>:</td>
<td class="help">&nbsp;</td>
<td><a href="https://docs.woocommerce.com/document/fix-outdated-templates-woocommerce/" target="_blank"><?php _e( 'Learn how to update outdated templates', 'woocommerce' ) ?></a></td>
<td><mark class="error"><span class="dashicons dashicons-warning"></span></mark><a href="https://docs.woocommerce.com/document/fix-outdated-templates-woocommerce/" target="_blank"><?php _e( 'Learn how to update', 'woocommerce' ) ?></a></td>
</tr>
<?php
}

View File

@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div id="message" class="updated woocommerce-message woocommerce-tracker">
<p><?php printf( __( 'Want to help make WooCommerce even more awesome? Allow WooThemes to collect non-sensitive diagnostic data and usage information, and get %s discount on your next WooThemes purchase. %sFind out more%s.', 'woocommerce' ), '20%', '<a href="https://woocommerce.com/usage-tracking/" target="_blank">', '</a>' ); ?></p>
<p><?php printf( __( 'Want to help make WooCommerce even more awesome? Allow WooCommerce to collect non-sensitive diagnostic data and usage information, and get %s discount on your next WooThemes purchase. %sFind out more%s.', 'woocommerce' ), '20%', '<a href="https://woocommerce.com/usage-tracking/" target="_blank">', '</a>' ); ?></p>
<p class="submit">
<a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc_tracker_optin', 'true' ), 'wc_tracker_optin', 'wc_tracker_nonce' ) ); ?>"><?php _e( 'Allow', 'woocommerce' ); ?></a>
<a class="skip button-secondary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'tracking' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php _e( 'No, do not bother me again', 'woocommerce' ); ?></a>

View File

@ -43,8 +43,9 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
<input type="hidden" name="range" value="custom" />
<input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['start_date'] ) ) echo esc_attr( $_GET['start_date'] ); ?>" name="start_date" class="range_datepicker from" />
<input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['end_date'] ) ) echo esc_attr( $_GET['end_date'] ); ?>" name="end_date" class="range_datepicker to" />
<input type="text" size="11" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['start_date'] ) ) echo esc_attr( $_GET['start_date'] ); ?>" name="start_date" class="range_datepicker from" />
<span>&ndash;</span>
<input type="text" size="11" placeholder="yyyy-mm-dd" value="<?php if ( ! empty( $_GET['end_date'] ) ) echo esc_attr( $_GET['end_date'] ); ?>" name="end_date" class="range_datepicker to" />
<input type="submit" class="button" value="<?php esc_attr_e( 'Go', 'woocommerce' ); ?>" />
</div>
</form>

View File

@ -62,9 +62,7 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
$option_value = get_option( $option );
if ( $option_value > 0 ) {
$page_object = get_post( $option_value );
if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
// Valid page is already in place
return $page_object->ID;

View File

@ -246,8 +246,8 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller {
// Content.
$data->post_content = '';
// Excerpt.
if ( ! empty( $schema['properties']['excerpt'] ) && isset( $request['description'] ) ) {
// Coupon description (excerpt).
if ( ! empty( $schema['properties']['description'] ) && isset( $request['description'] ) ) {
$data->post_excerpt = wp_filter_post_kses( $request['description'] );
}

View File

@ -191,7 +191,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
*/
public function batch_items_permissions_check( $request ) {
if ( ! wc_rest_check_user_permissions( 'batch' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -484,12 +484,12 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
'last_name' => $customer->last_name,
'username' => $customer->user_login,
'last_order' => array(
'id' => is_object( $last_order ) ? $last_order->id : null,
'id' => is_object( $last_order ) ? $last_order->get_id() : null,
'date' => is_object( $last_order ) ? wc_rest_prepare_date_response( $last_order->post->post_date_gmt ) : null
),
'orders_count' => wc_get_customer_order_count( $customer->ID ),
'total_spent' => wc_format_decimal( wc_get_customer_total_spent( $customer->ID ), 2 ),
'avatar_url' => wc_get_customer_avatar_url( $customer->customer_email ),
'avatar_url' => wc_get_customer_avatar_url( $customer->user_email ),
'billing' => array(
'first_name' => $customer->billing_first_name,
'last_name' => $customer->billing_last_name,

View File

@ -161,7 +161,7 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
$order = get_post( (int) $request['order_id'] );
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
return new WP_Error( 'woocommerce_rest_{$this->post_type}_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$args = array(
@ -228,7 +228,7 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
$response = $this->prepare_item_for_response( $note, $request );
$response = rest_ensure_response( $response );
$response->set_status( 201 );
$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, str_replace( '(?P<order_id>[\d]+)', $order->id, $this->rest_base ), $note_id ) ) );
$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, str_replace( '(?P<order_id>[\d]+)', $order->get_id(), $this->rest_base ), $note_id ) ) );
return $response;
}

View File

@ -114,7 +114,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
$refund = wc_get_order( $post );
if ( ! $refund || intval( $refund->post->post_parent ) !== intval( $order->id ) ) {
if ( ! $refund || intval( $refund->post->post_parent ) !== intval( $order->get_id() ) ) {
return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 404 );
}
@ -299,8 +299,8 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
$order = wc_get_order( $order_data );
if ( isset( $payment_gateways[ $order->payment_method ] ) && $payment_gateways[ $order->payment_method ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->payment_method ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
if ( is_wp_error( $result ) ) {
return $result;

View File

@ -125,19 +125,19 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
$dp = $request['dp'];
$data = array(
'id' => $order->id,
'parent_id' => $post->post_parent,
'id' => $order->get_id(),
'parent_id' => $order->get_parent_id(),
'status' => $order->get_status(),
'order_key' => $order->order_key,
'order_key' => $order->get_order_key(),
'number' => $order->get_order_number(),
'currency' => $order->get_order_currency(),
'version' => $order->order_version,
'prices_include_tax' => $order->prices_include_tax,
'date_created' => wc_rest_prepare_date_response( $post->post_date_gmt ),
'date_modified' => wc_rest_prepare_date_response( $post->post_modified_gmt ),
'currency' => $order->get_currency(),
'version' => $order->get_version(),
'prices_include_tax' => $order->get_prices_include_tax(),
'date_created' => wc_rest_prepare_date_response( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
'date_modified' => wc_rest_prepare_date_response( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
'customer_id' => $order->get_user_id(),
'discount_total' => wc_format_decimal( $order->get_total_discount(), $dp ),
'discount_tax' => wc_format_decimal( $order->cart_discount_tax, $dp ),
'discount_tax' => wc_format_decimal( $order->get_discount_tax(), $dp ),
'shipping_total' => wc_format_decimal( $order->get_total_shipping(), $dp ),
'shipping_tax' => wc_format_decimal( $order->get_shipping_tax(), $dp ),
'cart_tax' => wc_format_decimal( $order->get_cart_tax(), $dp ),
@ -145,16 +145,16 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'total_tax' => wc_format_decimal( $order->get_total_tax(), $dp ),
'billing' => array(),
'shipping' => array(),
'payment_method' => $order->payment_method,
'payment_method_title' => $order->payment_method_title,
'payment_method' => $order->get_payment_method(),
'payment_method_title' => $order->get_payment_method_title(),
'transaction_id' => $order->get_transaction_id(),
'customer_ip_address' => $order->customer_ip_address,
'customer_user_agent' => $order->customer_user_agent,
'created_via' => $order->created_via,
'customer_note' => $order->customer_note,
'date_completed' => wc_rest_prepare_date_response( $order->completed_date ),
'date_paid' => $order->paid_date,
'cart_hash' => $order->cart_hash,
'customer_ip_address' => $order->get_customer_ip_address(),
'customer_user_agent' => $order->get_customer_user_agent(),
'created_via' => $order->get_created_via(),
'customer_note' => $order->get_customer_note(),
'date_completed' => wc_rest_prepare_date_response( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
'date_paid' => $order->get_date_paid(),
'cart_hash' => $order->get_cart_hash(),
'line_items' => array(),
'tax_lines' => array(),
'shipping_lines' => array(),
@ -364,7 +364,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
protected function prepare_links( $order ) {
$links = array(
'self' => array(
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $order->id ) ),
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id() ) ),
),
'collection' => array(
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
@ -377,9 +377,9 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
);
}
if ( 0 !== (int) $order->post->post_parent ) {
if ( 0 !== (int) $order->get_parent_id() ) {
$links['up'] = array(
'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order->post->post_parent ) ),
'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order->get_parent_id() ) ),
);
}
@ -517,7 +517,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
}
// Set currency.
update_post_meta( $order->id, '_order_currency', $request['currency'] );
update_post_meta( $order->get_id(), '_order_currency', $request['currency'] );
// Set lines.
$lines = array(
@ -541,10 +541,10 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
// Set payment method.
if ( ! empty( $request['payment_method'] ) ) {
update_post_meta( $order->id, '_payment_method', $request['payment_method'] );
update_post_meta( $order->get_id(), '_payment_method', $request['payment_method'] );
}
if ( ! empty( $request['payment_method_title'] ) ) {
update_post_meta( $order->id, '_payment_method_title', $request['payment_method_title'] );
update_post_meta( $order->get_id(), '_payment_method_title', $request['payment_method_title'] );
}
if ( true === $request['set_paid'] ) {
$order->payment_complete( $request['transaction_id'] );
@ -552,12 +552,12 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
// Set meta data.
if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
$this->update_meta_data( $order->id, $request['meta_data'] );
$this->update_meta_data( $order->get_id(), $request['meta_data'] );
}
wc_transaction_query( 'commit' );
return $order->id;
return $order->get_id();
} catch ( WC_REST_Exception $e ) {
wc_transaction_query( 'rollback' );
@ -934,7 +934,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
$result = $wpdb->get_row(
$wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d",
absint( $item['id'] ),
absint( $order->id )
absint( $order->get_id() )
) );
if ( is_null( $result ) ) {
@ -975,7 +975,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
try {
$update_totals = false;
$order = wc_get_order( $post );
$order_args = array( 'order_id' => $order->id );
$order_args = array( 'order_id' => $order->get_id() );
// Customer note.
if ( isset( $request['customer_note'] ) ) {
@ -989,7 +989,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_customer_user', $request['customer_id'] );
update_post_meta( $order->get_id(), '_customer_user', $request['customer_id'] );
}
// Update addresses.
@ -1032,10 +1032,10 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
// Set payment method.
if ( ! empty( $request['payment_method'] ) ) {
update_post_meta( $order->id, '_payment_method', $request['payment_method'] );
update_post_meta( $order->get_id(), '_payment_method', $request['payment_method'] );
}
if ( ! empty( $request['payment_method_title'] ) ) {
update_post_meta( $order->id, '_payment_method_title', $request['payment_method'] );
update_post_meta( $order->get_id(), '_payment_method_title', $request['payment_method'] );
}
if ( $order->needs_payment() && isset( $request['set_paid'] ) && true === $request['set_paid'] ) {
$order->payment_complete( ! empty( $request['transaction_id'] ) ? $request['transaction_id'] : '' );
@ -1043,7 +1043,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
// Set order currency.
if ( isset( $request['currency'] ) ) {
update_post_meta( $order->id, '_order_currency', $request['currency'] );
update_post_meta( $order->get_id(), '_order_currency', $request['currency'] );
}
// If items have changed, recalculate order totals.
@ -1053,7 +1053,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
// Update meta data.
if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
$this->update_meta_data( $order->id, $request['meta_data'] );
$this->update_meta_data( $order->get_id(), $request['meta_data'] );
}
// Update the order post to set customer note/modified date.
@ -1064,7 +1064,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
$order->update_status( $request['status'], isset( $request['status_note'] ) ? $request['status_note'] : '' );
}
return $order->id;
return $order->get_id();
} catch ( WC_REST_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}

View File

@ -183,7 +183,7 @@ class WC_REST_Product_Attributes_Controller extends WC_REST_Controller {
}
if ( ! wc_rest_check_manager_permissions( 'attributes', 'delete' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you cannot delete resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -197,7 +197,7 @@ class WC_REST_Product_Attributes_Controller extends WC_REST_Controller {
*/
public function batch_items_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'attributes', 'batch' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -360,7 +360,7 @@ class WC_REST_Product_Attributes_Controller extends WC_REST_Controller {
// Checks for errors.
if ( false === $update ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Could not edit the attribute', 'woocommerce' ), array( 'status' => 400 ) );
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Could not edit the attribute.', 'woocommerce' ), array( 'status' => 400 ) );
}
$attribute = $this->get_attribute( $id );

View File

@ -1,8 +1,8 @@
<?php
/**
* REST API Product Reviews controller
* REST API Product Reviews Controller.
*
* Handles requests to the /products/<product_id>/reviews endpoint.
* Handles requests to /products/<product_id>/reviews.
*
* @author WooThemes
* @category API
@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
* REST API Products controller class.
* REST API Product Reviews Controller Class.
*
* @package WooCommerce/API
* @extends WC_REST_Controller
@ -47,6 +47,22 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => $this->get_collection_params(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'create_item' ),
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
'review' => array(
'required' => true,
),
'name' => array(
'required' => true,
),
'email' => array(
'required' => true,
),
) ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
@ -59,8 +75,35 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_item' ),
'permission_callback' => array( $this, 'update_item_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'delete_item' ),
'permission_callback' => array( $this, 'delete_item_permissions_check' ),
'args' => array(
'force' => array(
'default' => false,
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
),
),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'batch_items' ),
'permission_callback' => array( $this, 'batch_items_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
'schema' => array( $this, 'get_public_batch_schema' ),
) );
}
/**
@ -78,7 +121,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
}
/**
* Check if a given request has access to read a webhook develivery.
* Check if a given request has access to read a product review.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
@ -93,6 +136,61 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
return true;
}
/**
* Check if a given request has access to create a new product review.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function create_item_permissions_check( $request ) {
$post = get_post( (int) $request['product_id'] );
if ( $post && ! wc_rest_check_post_permissions( 'product', 'create', $post->ID ) ) {
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check if a given request has access to update a product review.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function update_item_permissions_check( $request ) {
$post = get_post( (int) $request['product_id'] );
if ( $post && ! wc_rest_check_post_permissions( 'product', 'edit', $post->ID ) ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check if a given request has access to delete a product review.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function delete_item_permissions_check( $request ) {
$post = get_post( (int) $request['product_id'] );
if ( $post && ! wc_rest_check_post_permissions( 'product', 'delete', $post->ID ) ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check if a given request has access to batch manage product reviews.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function batch_items_permissions_check( $request ) {
if ( ! wc_rest_check_post_permissions( 'product', 'batch' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Get all reviews from a product.
*
@ -100,13 +198,13 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
* @return array
*/
public function get_items( $request ) {
$product = get_post( (int) $request['product_id'] );
$product_id = (int) $request['product_id'];
if ( empty( $product->post_type ) || 'product' !== $product->post_type ) {
if ( 'product' !== get_post_type( $product_id ) ) {
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$reviews = get_approved_comments( $product->ID );
$reviews = get_approved_comments( $product_id );
$data = array();
foreach ( $reviews as $review_data ) {
$review = $this->prepare_item_for_response( $review_data, $request );
@ -125,15 +223,15 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
*/
public function get_item( $request ) {
$id = (int) $request['id'];
$product = get_post( (int) $request['product_id'] );
$product_id = (int) $request['product_id'];
if ( empty( $product->post_type ) || 'product' !== $product->post_type ) {
if ( 'product' !== get_post_type( $product_id ) ) {
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$review = get_comment( $id );
if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== intval( $product->ID ) ) {
if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) {
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
@ -143,6 +241,197 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
return $response;
}
/**
* Create a product review.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function create_item( $request ) {
$product_id = (int) $request['product_id'];
if ( 'product' !== get_post_type( $product_id ) ) {
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$prepared_review = $this->prepare_item_for_database( $request );
/**
* Filter a product review (comment) before it is inserted via the REST API.
*
* Allows modification of the comment right before it is inserted via `wp_insert_comment`.
*
* @param array $prepared_review The prepared comment data for `wp_insert_comment`.
* @param WP_REST_Request $request Request used to insert the comment.
*/
$prepared_review = apply_filters( 'rest_pre_insert_product_review', $prepared_review, $request );
$product_review_id = wp_insert_comment( $prepared_review );
if ( ! $product_review_id ) {
return new WP_Error( 'rest_product_review_failed_create', __( 'Creating product review failed.' ), array( 'status' => 500 ) );
}
update_comment_meta( $product_review_id, 'rating', ( ! empty( $request['rating'] ) ? $request['rating'] : '0' ) );
$product_review = get_comment( $product_review_id );
$this->update_additional_fields_for_object( $product_review, $request );
/**
* Fires after a single item is created or updated via the REST API.
*
* @param WP_Comment $product_review Inserted object.
* @param WP_REST_Request $request Request object.
* @param boolean $creating True when creating item, false when updating.
*/
do_action( "woocommerce_rest_insert_product_review", $product_review, $request, true );
$request->set_param( 'context', 'edit' );
$response = $this->prepare_item_for_response( $product_review, $request );
$response = rest_ensure_response( $response );
$response->set_status( 201 );
$base = str_replace( '(?P<product_id>[\d]+)', $product_id, $this->rest_base );
$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $product_review_id ) ) );
return $response;
}
/**
* Update a single product review.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function update_item( $request ) {
$product_review_id = (int) $request['id'];
$product_id = (int) $request['product_id'];
if ( 'product' !== get_post_type( $product_id ) ) {
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$review = get_comment( $product_review_id );
if ( empty( $product_review_id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) {
return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$prepared_review = $this->prepare_item_for_database( $request );
$updated = wp_update_comment( $prepared_review );
if ( 0 === $updated ) {
return new WP_Error( 'rest_product_review_failed_edit', __( 'Updating product review failed.' ), array( 'status' => 500 ) );
}
if ( ! empty( $request['rating'] ) ) {
update_comment_meta( $product_review_id, 'rating', $request['rating'] );
}
$product_review = get_comment( $product_review_id );
$this->update_additional_fields_for_object( $product_review, $request );
/**
* Fires after a single item is created or updated via the REST API.
*
* @param WP_Comment $comment Inserted object.
* @param WP_REST_Request $request Request object.
* @param boolean $creating True when creating item, false when updating.
*/
do_action( "woocommerce_rest_insert_product_review", $product_review, $request, true );
$request->set_param( 'context', 'edit' );
$response = $this->prepare_item_for_response( $product_review, $request );
return rest_ensure_response( $response );
}
/**
* Delete a product review.
*
* @param WP_REST_Request $request Full details about the request
* @return WP_Error|boolean
*/
public function delete_item( $request ) {
$product_review_id = is_array( $request['id'] ) ? $request['id']['id'] : $request['id'];
$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
$product_review = get_comment( $product_review_id );
if ( empty( $product_review_id ) || empty( $product_review->comment_ID ) || empty( $product_review->comment_post_ID ) ) {
return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid product review ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
/**
* Filter whether a product review is trashable.
*
* Return false to disable trash support for the product review.
*
* @param boolean $supports_trash Whether the object supports trashing.
* @param WP_Post $product_review The object being considered for trashing support.
*/
$supports_trash = apply_filters( 'rest_product_review_trashable', ( EMPTY_TRASH_DAYS > 0 ), $product_review );
$request->set_param( 'context', 'edit' );
$response = $this->prepare_item_for_response( $product_review, $request );
if ( $force ) {
$result = wp_delete_comment( $product_review_id, true );
} else {
if ( ! $supports_trash ) {
return new WP_Error( 'rest_trash_not_supported', __( 'The product review does not support trashing.' ), array( 'status' => 501 ) );
}
if ( 'trash' === $product_review->comment_approved ) {
return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
}
$result = wp_trash_comment( $product_review->comment_ID );
}
if ( ! $result ) {
return new WP_Error( 'rest_cannot_delete', __( 'The product review cannot be deleted.' ), array( 'status' => 500 ) );
}
/**
* Fires after a product review is deleted via the REST API.
*
* @param object $product_review The deleted item.
* @param WP_REST_Response $response The response data.
* @param WP_REST_Request $request The request sent to the API.
*/
do_action( 'rest_delete_product_review', $product_review, $response, $request );
return $response;
}
/**
* Bulk create, update and delete items.
*
* @since 2.7.0
* @param WP_REST_Request $request Full details about the request.
* @return array Of WP_Error or WP_REST_Response.
*/
public function batch_items( $request ) {
$items = array_filter( $request->get_params() );
$params = $request->get_url_params();
$product_id = $params['product_id'];
$body_params = array();
foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) {
if ( ! empty( $items[ $batch_type ] ) ) {
$injected_items = array();
foreach ( $items[ $batch_type ] as $item ) {
$injected_items[] = array_merge( array( 'product_id' => $product_id ), $item );
}
$body_params[ $batch_type ] = $injected_items;
}
}
$request = new WP_REST_Request( $request->get_method() );
$request->set_body_params( $body_params );
return parent::batch_items( $request );
}
/**
* Prepare a single product review output for response.
*
@ -180,6 +469,38 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
return apply_filters( 'woocommerce_rest_prepare_product_review', $response, $review, $request );
}
/**
* Prepare a single product review to be inserted into the database.
*
* @param WP_REST_Request $request Request object.
* @return array|WP_Error $prepared_review
*/
protected function prepare_item_for_database( $request ) {
$prepared_review = array( 'comment_approved' => 1, 'comment_type' => 'review' );
if ( isset( $request['id'] ) ) {
$prepared_review['comment_ID'] = (int) $request['id'];
}
if ( isset( $request['review'] ) ) {
$prepared_review['comment_content'] = $request['review'];
}
if ( isset( $request['product_id'] ) ) {
$prepared_review['comment_post_ID'] = (int) $request['product_id'];
}
if ( isset( $request['name'] ) ) {
$prepared_review['comment_author'] = $request['name'];
}
if ( isset( $request['email'] ) ) {
$prepared_review['comment_author_email'] = $request['email'];
}
return apply_filters( 'rest_preprocess_product_review', $prepared_review, $request );
}
/**
* Prepare links for the request.
*
@ -219,37 +540,38 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
'id' => array(
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view' ),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'review' => array(
'description' => __( 'The content of the review.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'date_created' => array(
'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'rating' => array(
'description' => __( 'Review rating (0 to 5).', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view' ),
'readonly' => true,
'context' => array( 'view', 'edit' ),
),
'name' => array(
'description' => __( 'Reviewer name.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
'context' => array( 'view', 'edit' ),
),
'email' => array(
'description' => __( 'Reviewer email.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
'context' => array( 'view', 'edit' ),
),
'verified' => array(
'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view' ),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
),

View File

@ -297,7 +297,7 @@ class WC_REST_Settings_Options_Controller extends WC_REST_Controller {
*/
public function update_items_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;

View File

@ -0,0 +1,179 @@
<?php
/**
* REST API Shipping Zone Locations controller
*
* Handles requests to the /shipping/zones/<id>/locations endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* REST API Shipping Zone Locations class.
*
* @package WooCommerce/API
* @extends WC_REST_Shipping_Zones_Controller_Base
*/
class WC_REST_Shipping_Zone_Locations_Controller extends WC_REST_Shipping_Zones_Controller_Base {
/**
* Register the routes for Shipping Zone Locations.
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d-]+)/locations', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_items' ),
'permission_callback' => array( $this, 'update_items_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
}
/**
* Get all Shipping Zone Locations.
*
* @param WP_REST_Request $request
* @return WP_REST_Response|WP_Error
*/
public function get_items( $request ) {
$zone = $this->get_zone( $request['id'] );
if ( is_wp_error( $zone ) ) {
return $zone;
}
$locations = $zone->get_zone_locations();
$data = array();
foreach ( $locations as $location_obj ) {
$location = $this->prepare_item_for_response( $location_obj, $request );
$location = $this->prepare_response_for_collection( $location );
$data[] = $location;
}
return rest_ensure_response( $data );
}
/**
* Update all Shipping Zone Locations.
*
* @param WP_REST_Request $request
* @return WP_REST_Response|WP_Error
*/
public function update_items( $request ) {
$zone = $this->get_zone( $request['id'] );
if ( is_wp_error( $zone ) ) {
return $zone;
}
$raw_locations = $request->get_json_params();
$locations = array();
foreach ( (array) $raw_locations as $raw_location ) {
if ( empty( $raw_location['code'] ) || empty( $raw_location['type'] ) ) {
continue;
}
$locations[] = $raw_location;
}
$zone->set_locations( $locations );
$zone->save();
return $this->get_items( $request );
}
/**
* Prepare the Shipping Zone Location for the REST response.
*
* @param array $item Shipping Zone Location.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response
*/
public function prepare_item_for_response( $item, $request ) {
$context = empty( $request['context'] ) ? 'view' : $request['context'];
$data = $this->add_additional_fields_to_object( $item, $request );
$data = $this->filter_response_by_context( $data, $context );
// Wrap the data in a response object.
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $request['id'] ) );
return $response;
}
/**
* Prepare links for the request.
*
* @param int $zone_id Given Shipping Zone ID.
* @return array Links for the given Shipping Zone Location.
*/
protected function prepare_links( $zone_id ) {
$base = '/' . $this->namespace . '/' . $this->rest_base . '/' . $zone_id;
$links = array(
'collection' => array(
'href' => rest_url( $base . '/locations' ),
),
'describes' => array(
'href' => rest_url( $base ),
),
);
return $links;
}
/**
* Get the Shipping Zone Locations schema, conforming to JSON Schema
*
* @return array
*/
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'shipping_zone_location',
'type' => 'object',
'properties' => array(
'code' => array(
'description' => __( 'Shipping zone location code.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'required' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'type' => array(
'description' => __( 'Shipping zone location type.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'required' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
'enum' => array(
'postcode',
'state',
'country',
'continent',
),
),
),
);
return $this->add_additional_fields_schema( $schema );
}
}

View File

@ -0,0 +1,217 @@
<?php
/**
* REST API Shipping Zone Methods controller
*
* Handles requests to the /shipping/zones/<id>/methods endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* REST API Shipping Zone Methods class.
*
* @package WooCommerce/API
* @extends WC_REST_Shipping_Zones_Controller_Base
*/
class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zones_Controller_Base {
/**
* Register the routes for Shipping Zone Methods.
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d-]+)/methods', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d-]+)/methods/(?P<instance_id>[\d-]+)', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_item' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
}
/**
* Get a single Shipping Zone Method.
*
* @param WP_REST_Request $request
* @return WP_REST_Response|WP_Error
*/
public function get_item( $request ) {
$zone = $this->get_zone( $request['zone_id'] );
if ( is_wp_error( $zone ) ) {
return $zone;
}
$instance_id = (int) $request['instance_id'];
$methods = $zone->get_shipping_methods();
$method = false;
foreach ( $methods as $method_obj ) {
if ( $instance_id === $method_obj->instance_id ) {
$method = $method_obj;
break;
}
}
if ( false === $method ) {
return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) );
}
$data = $this->prepare_item_for_response( $method, $request );
return rest_ensure_response( $data );
}
/**
* Get all Shipping Zone Methods.
*
* @param WP_REST_Request $request
* @return WP_REST_Response|WP_Error
*/
public function get_items( $request ) {
$zone = $this->get_zone( $request['zone_id'] );
if ( is_wp_error( $zone ) ) {
return $zone;
}
$methods = $zone->get_shipping_methods();
$data = array();
foreach ( $methods as $method_obj ) {
$method = $this->prepare_item_for_response( $method_obj, $request );
$data[] = $method;
}
return rest_ensure_response( $data );
}
/**
* Prepare the Shipping Zone Method for the REST response.
*
* @param array $item Shipping Zone Method.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response
*/
public function prepare_item_for_response( $item, $request ) {
$method = array(
'instance_id' => $item->instance_id,
'title' => $item->instance_settings['title'],
'order' => $item->method_order,
'enabled' => ( 'yes' === $item->enabled ),
'method_id' => $item->id,
'method_title' => $item->method_title,
'method_description' => $item->method_description,
);
$context = empty( $request['context'] ) ? 'view' : $request['context'];
$data = $this->add_additional_fields_to_object( $method, $request );
$data = $this->filter_response_by_context( $data, $context );
// Wrap the data in a response object.
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $request['zone_id'], $item->instance_id ) );
$response = $this->prepare_response_for_collection( $response );
return $response;
}
/**
* Prepare links for the request.
*
* @param int $zone_id Given Shipping Zone ID.
* @param int $instance_id Given Shipping Zone Method Instance ID.
* @return array Links for the given Shipping Zone Method.
*/
protected function prepare_links( $zone_id, $instance_id ) {
$base = '/' . $this->namespace . '/' . $this->rest_base . '/' . $zone_id;
$links = array(
'self' => array(
'href' => rest_url( $base . '/methods/' . $instance_id ),
),
'collection' => array(
'href' => rest_url( $base . '/methods' ),
),
'describes' => array(
'href' => rest_url( $base ),
),
);
return $links;
}
/**
* Get the Shipping Zone Methods schema, conforming to JSON Schema
*
* @return array
*/
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'shipping_zone_method',
'type' => 'object',
'properties' => array(
'instance_id' => array(
'description' => __( 'Shipping method instance ID.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view' ),
),
'title' => array(
'description' => __( 'Shipping method customer facing title.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
),
'order' => array(
'description' => __( 'Shipping method sort order.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'required' => false,
'arg_options' => array(
'sanitize_callback' => 'absint',
),
),
'enabled' => array(
'description' => __( 'Shipping method enabled status.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
'required' => false,
),
'method_id' => array(
'description' => __( 'Shipping method ID.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
),
'method_title' => array(
'description' => __( 'Shipping method title.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
),
'method_description' => array(
'description' => __( 'Shipping method description.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
),
),
);
return $this->add_additional_fields_schema( $schema );
}
}

View File

@ -0,0 +1,253 @@
<?php
/**
* REST API Shipping Zones controller
*
* Handles requests to the /shipping/zones endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* REST API Shipping Zones class.
*
* @package WooCommerce/API
* @extends WC_REST_Shipping_Zones_Controller_Base
*/
class WC_REST_Shipping_Zones_Controller extends WC_REST_Shipping_Zones_Controller_Base {
/**
* Register the routes for Shipping Zones.
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'create_item' ),
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d-]+)', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_item' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_item' ),
'permission_callback' => array( $this, 'update_items_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
}
/**
* Get a single Shipping Zone.
*
* @param WP_REST_Request $request
* @return WP_REST_Response
*/
public function get_item( $request ) {
$zone = $this->get_zone( $request->get_param( 'id' ) );
if ( is_wp_error( $zone ) ) {
return $zone;
}
$data = $zone->get_data();
$data = $this->prepare_item_for_response( $data, $request );
$data = $this->prepare_response_for_collection( $data );
return rest_ensure_response( $data );
}
/**
* Get all Shipping Zones.
*
* @param WP_REST_Request $request
* @return WP_REST_Response
*/
public function get_items( $request ) {
$rest_of_the_world = WC_Shipping_Zones::get_zone_by( 'zone_id', 0 );
$zones = WC_Shipping_Zones::get_zones();
array_unshift( $zones, $rest_of_the_world->get_data() );
$data = array();
foreach ( $zones as $zone_obj ) {
$zone = $this->prepare_item_for_response( $zone_obj, $request );
$zone = $this->prepare_response_for_collection( $zone );
$data[] = $zone;
}
return rest_ensure_response( $data );
}
/**
* Create a single Shipping Zone.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Request|WP_Error
*/
public function create_item( $request ) {
$zone = new WC_Shipping_Zone( null );
if ( ! is_null( $request->get_param( 'name' ) ) ) {
$zone->set_zone_name( $request->get_param( 'name' ) );
}
if ( ! is_null( $request->get_param( 'order' ) ) ) {
$zone->set_zone_order( $request->get_param( 'order' ) );
}
$zone->create();
if ( $zone->get_id() !== 0 ) {
$request->set_param( 'id', $zone->get_id() );
$response = $this->get_item( $request );
$response->set_status( 201 );
$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $zone->get_id() ) ) );
return $response;
} else {
return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( "Resource cannot be created. Check to make sure 'order' and 'name' are present.", 'woocommerce' ), array( 'status' => 500 ) );
}
}
/**
* Update a single Shipping Zone.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Request|WP_Error
*/
public function update_item( $request ) {
$zone = $this->get_zone( $request->get_param( 'id' ) );
if ( is_wp_error( $zone ) ) {
return $zone;
}
$zone_changed = false;
if ( ! is_null( $request->get_param( 'name' ) ) ) {
$zone->set_zone_name( $request->get_param( 'name' ) );
$zone_changed = true;
}
if ( ! is_null( $request->get_param( 'order' ) ) ) {
$zone->set_zone_order( $request->get_param( 'order' ) );
$zone_changed = true;
}
if ( $zone_changed ) {
$zone->save();
}
return $this->get_item( $request );
}
/**
* Prepare the Shipping Zone for the REST response.
*
* @param array $item Shipping Zone.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response
*/
public function prepare_item_for_response( $item, $request ) {
$data = array(
'id' => (int) $item['zone_id'],
'name' => $item['zone_name'],
'order' => (int) $item['zone_order'],
);
$context = empty( $request['context'] ) ? 'view' : $request['context'];
$data = $this->add_additional_fields_to_object( $data, $request );
$data = $this->filter_response_by_context( $data, $context );
// Wrap the data in a response object.
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $data['id'] ) );
return $response;
}
/**
* Prepare links for the request.
*
* @param int $zone_id Given Shipping Zone ID.
* @return array Links for the given Shipping Zone.
*/
protected function prepare_links( $zone_id ) {
$base = '/' . $this->namespace . '/' . $this->rest_base;
$links = array(
'self' => array(
'href' => rest_url( trailingslashit( $base ) . $zone_id ),
),
'collection' => array(
'href' => rest_url( $base ),
),
'describedby' => array(
'href' => rest_url( trailingslashit( $base ) . $zone_id . '/locations' ),
),
);
return $links;
}
/**
* Get the Shipping Zones schema, conforming to JSON Schema
*
* @return array
*/
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'shipping_zone',
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'name' => array(
'description' => __( 'Shipping zone name.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'required' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'order' => array(
'description' => __( 'Shipping zone order.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'required' => false,
'arg_options' => array(
'sanitize_callback' => 'absint',
),
),
),
);
return $this->add_additional_fields_schema( $schema );
}
}

View File

@ -0,0 +1,821 @@
<?php
/**
* REST API WC System Status controller
*
* Handles requests to the /system_status endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @package WooCommerce/API
* @extends WC_REST_Controller
*/
class WC_REST_System_Status_Controller extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v1';
/**
* Route base.
*
* @var string
*/
protected $rest_base = 'system_status';
/**
* Register the route for /system_status
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => $this->get_collection_params(),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
}
/**
* Check whether a given request has permission to view system status.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Get a system status info, by section.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
$schema = $this->get_item_schema();
$mappings = $this->get_item_mappings();
$response = array();
foreach ( $mappings as $section => $values ) {
settype( $values, $schema['properties'][ $section ]['type'] );
foreach ( $values as $key => $value ) {
if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) {
settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] );
}
}
$response[ $section ] = $values;
}
return rest_ensure_response( $response );
}
/**
* Get the system status schema, conforming to JSON Schema.
*
* @return array
*/
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'system_status',
'type' => 'object',
'properties' => array(
'environment' => array(
'description' => __( 'Environment', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'properties' => array(
'home_url' => array(
'description' => __( 'Home URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'site_url' => array(
'description' => __( 'Site URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'wc_version' => array(
'description' => __( 'WooCommerce Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'log_directory' => array(
'description' => __( 'Log Directory', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'log_directory_writable' => array(
'description' => __( 'Is Log Directory Writable?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_version' => array(
'description' => __( 'WordPress Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'wp_multisite' => array(
'description' => __( 'Is WordPress Multisite?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_memory_limit' => array(
'description' => __( 'WordPress Memory Limit', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'wp_debug_mode' => array(
'description' => __( 'Is WordPress Debug Mode Active?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'wp_cron' => array(
'description' => __( 'Are WordPress Cron Jobs Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'language' => array(
'description' => __( 'WordPress Language', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'server_info' => array(
'description' => __( 'Server Info', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'php_version' => array(
'description' => __( 'PHP Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'php_post_max_size' => array(
'description' => __( 'PHP Post Max Size', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'php_max_execution_time' => array(
'description' => __( 'PHP Max Execution Time', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'php_max_input_vars' => array(
'description' => __( 'PHP Max Input Vars', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'curl_version' => array(
'description' => __( 'cURL Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'suhosin_installed' => array(
'description' => __( 'Is SUHOSIN Installed?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'max_upload_size' => array(
'description' => __( 'Max Upload Size', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'mysql_version' => array(
'description' => __( 'MySQL Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'default_timezone' => array(
'description' => __( 'Default Timezone', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'fsockopen_or_curl_enabled' => array(
'description' => __( 'Is fsockopen/cURL Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'soapclient_enabled' => array(
'description' => __( 'Is SoapClient Class Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'domdocument_enabled' => array(
'description' => __( 'Is DomDocument Class Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'gzip_enabled' => array(
'description' => __( 'Is GZip Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'mbstring_enabled' => array(
'description' => __( 'Is mbstring Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'remote_post_successful' => array(
'description' => __( 'Remote POST Successful?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'remote_post_response' => array(
'description' => __( 'Remote POST Response', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'remote_get_successful' => array(
'description' => __( 'Remote GET Successful?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'remote_get_response' => array(
'description' => __( 'Remote GET Response', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
),
),
'database' => array(
'description' => __( 'Database', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'properties' => array(
'wc_database_version' => array(
'description' => __( 'WC Database Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'database_prefix' => array(
'description' => __( 'Database Prefix', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'maxmind_geoip_database' => array(
'description' => __( 'MaxMind GeoIP Database', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'database_tables' => array(
'description' => __( 'Database Tables', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
),
)
),
'active_plugins' => array(
'description' => __( 'Active Plugins', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
),
'theme' => array(
'description' => __( 'Theme', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'properties' => array(
'name' => array(
'description' => __( 'Theme Name', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'version' => array(
'description' => __( 'Theme Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'version_latest' => array(
'description' => __( 'Latest Version Of Theme', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'author_url' => array(
'description' => __( 'Theme Author URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'is_child_theme' => array(
'description' => __( 'Is this theme a child theme?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'has_woocommerce_support' => array(
'description' => __( 'Does the theme declare WooCommerce support?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'has_woocommerce_file' => array(
'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'has_outdated_templates' => array(
'description' => __( 'Does this theme have outdated templates?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'overrides' => array(
'description' => __( 'Template Overrides', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
),
'parent_name' => array(
'description' => __( 'Parent Theme Name', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'parent_version' => array(
'description' => __( 'Parent Theme Version', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'parent_author_url' => array(
'description' => __( 'Parent Theme Author URL', 'woocommerce' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
)
),
'settings' => array(
'description' => __( 'Settings', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'properties' => array(
'api_enabled' => array(
'description' => __( 'REST API Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'force_ssl' => array(
'description' => __( 'SSL Forced?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'currency' => array(
'description' => __( 'Currency', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'currency_symbol' => array(
'description' => __( 'Currency Symbol', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'currency_position' => array(
'description' => __( 'Currency Position', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'thousand_separator' => array(
'description' => __( 'Thousand Separator', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'decimal_separator' => array(
'description' => __( 'Decimal Separator', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'number_of_decimals' => array(
'description' => __( 'Number of Decimals', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'geolocation_enabled' => array(
'description' => __( 'Geolocation Enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'taxonomies' => array(
'description' => __( 'Taxonomy Terms for Product/Order Statuses', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
),
)
),
'pages' => array(
'description' => __( 'WooCommerce Pages', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
),
)
);
return $this->add_additional_fields_schema( $schema );
}
/**
* Return an array of sections and the data associated with each.
*
* @return array
*/
public function get_item_mappings() {
return array(
'environment' => $this->get_environment_info(),
'database' => $this->get_database_info(),
'active_plugins' => $this->get_active_plugins(),
'theme' => $this->get_theme_info(),
'settings' => $this->get_settings(),
'pages' => $this->get_pages(),
);
}
/**
* Get array of environment information. Includes thing like software
* versions, and various server settings.
*
* @return array
*/
public function get_environment_info() {
global $wpdb;
// Figure out cURL version, if installed.
$curl_version = '';
if ( function_exists( 'curl_version' ) ) {
$curl_version = curl_version();
$curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
}
// WP memory limit
$wp_memory_limit = wc_let_to_num( WP_MEMORY_LIMIT );
if ( function_exists( 'memory_get_usage' ) ) {
$wp_memory_limit = max( $wp_memory_limit, wc_let_to_num( @ini_get( 'memory_limit' ) ) );
}
// Test POST requests
$post_response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array(
'timeout' => 60,
'user-agent' => 'WooCommerce/' . WC()->version,
'httpversion' => '1.1',
'body' => array(
'cmd' => '_notify-validate'
)
) );
$post_response_successful = false;
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) {
$post_response_successful = true;
}
// Test GET requests
$get_response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) );
$get_response_successful = false;
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) {
$get_response_successful = true;
}
// Return all environment info. Described by JSON Schema.
return array(
'home_url' => get_option( 'home' ),
'site_url' => get_option( 'siteurl' ),
'version' => WC()->version,
'log_directory' => WC_LOG_DIR,
'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ),
'wp_version' => get_bloginfo('version'),
'wp_multisite' => is_multisite(),
'wp_memory_limit' => $wp_memory_limit,
'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
'language' => get_locale(),
'server_info' => $_SERVER['SERVER_SOFTWARE'],
'php_version' => phpversion(),
'php_post_max_size' => wc_let_to_num( ini_get( 'post_max_size' ) ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_max_input_vars' => ini_get( 'max_input_vars' ),
'curl_version' => $curl_version,
'suhosin_installed' => extension_loaded( 'suhosin' ),
'max_upload_size' => wp_max_upload_size(),
'mysql_version' => ( ! empty( $wpdb->is_mysql ) ? $wpdb->db_version() : '' ),
'default_timezone' => date_default_timezone_get(),
'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ),
'soapclient_enabled' => class_exists( 'SoapClient' ),
'domdocument_enabled' => class_exists( 'DOMDocument' ),
'gzip_enabled' => is_callable( 'gzopen' ),
'mbstring_enabled' => extension_loaded( 'mbstring' ),
'remote_post_successful' => $post_response_successful,
'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ),
'remote_get_successful' => $get_response_successful,
'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ),
);
}
/**
* Get array of database information. Version, prefix, and table existence.
*
* @return array
*/
public function get_database_info() {
global $wpdb;
// WC Core tables to check existence of
$tables = array(
'woocommerce_sessions',
'woocommerce_api_keys',
'woocommerce_attribute_taxonomies',
'woocommerce_downloadable_product_permissions',
'woocommerce_order_items',
'woocommerce_order_itemmeta',
'woocommerce_tax_rates',
'woocommerce_tax_rate_locations',
'woocommerce_shipping_zones',
'woocommerce_shipping_zone_locations',
'woocommerce_shipping_zone_methods',
'woocommerce_payment_tokens',
'woocommerce_payment_tokenmeta',
);
if ( get_option( 'db_version' ) < 34370 ) {
$tables[] = 'woocommerce_termmeta';
}
$table_exists = array();
foreach ( $tables as $table ) {
$table_exists[ $table ] = ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s;", $wpdb->prefix . $table ) ) === $wpdb->prefix . $table );
}
// Return all database info. Described by JSON Schema.
return array(
'wc_database_version' => get_option( 'woocommerce_db_version' ),
'database_prefix' => $wpdb->prefix,
'maxmind_geoip_database' => WC_Geolocation::get_local_database_path(),
'database_tables' => $table_exists,
);
}
/**
* Get a list of plugins active on the site.
*
* @return array
*/
public function get_active_plugins() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// Get both site plugins and network plugins
$active_plugins = (array) get_option( 'active_plugins', array() );
if ( is_multisite() ) {
$network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
$active_plugins = array_merge( $active_plugins, $network_activated_plugins );
}
$active_plugins_data = array();
foreach ( $active_plugins as $plugin ) {
$data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
$dirname = dirname( $plugin );
$theme_version_latest = '';
if ( strstr( $data['PluginURI'], 'woothemes.com' ) ) {
if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
$changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) );
if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) {
$date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
$version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
$update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog );
set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
break;
}
}
}
}
$theme_version_latest = $version_data['version'];
} else {
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
$slug = explode( '/', $plugin );
$slug = explode( '.', end( $slug ) );
$slug = $slug[0];
$api = plugins_api( 'plugin_information', array(
'slug' => $slug,
'fields' => array(
'sections' => false,
'tags' => false,
)
) );
if ( is_object( $api ) && ! is_wp_error( $api ) ) {
$theme_version_latest = $api->version;
}
}
// convert plugin data to json response format.
$active_plugins_data[] = array(
'plugin' => $plugin,
'name' => $data['Name'],
'version' => $data['Version'],
'version_latest' => $theme_version_latest,
'url' => $data['PluginURI'],
'author_name' => $data['AuthorName'],
'author_url' => esc_url_raw( $data['AuthorURI'] ),
'network_activated' => $data['Network'],
);
}
return $active_plugins_data;
}
/**
* Get info on the current active theme, info on parent theme (if presnet)
* and a list of template overrides.
*
* @return array
*/
public function get_theme_info() {
$active_theme = wp_get_theme();
// Get parent theme info if this theme is a child theme, otherwise
// pass empty info in the response.
if ( is_child_theme() ) {
$parent_theme = wp_get_theme( $active_theme->Template );
$parent_theme_info = array(
'parent_name' => $parent_theme->Name,
'parent_version' => $parent_theme->Version,
'parent_version_latest' => WC_Admin_Status::get_latest_theme_version( $parent_theme ),
'parent_author_url' => $parent_theme->{'Author URI'},
);
} else {
$parent_theme_info = array( 'parent_name' => '', 'parent_version' => '', 'parent_version_latest' => '', 'parent_author_url' => '' );
}
/**
* Scan the theme directory for all WC templates to see if our theme
* overrides any of them.
*/
$override_files = array();
$outdated_templates = false;
$scan_files = WC_Admin_Status::scan_template_files( WC()->plugin_path() . '/templates/' );
foreach ( $scan_files as $file ) {
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/' . $file;
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
$theme_file = get_template_directory() . '/' . $file;
} elseif ( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
$theme_file = get_template_directory() . '/woocommerce/' . $file;
} else {
$theme_file = false;
}
if ( ! empty( $theme_file ) ) {
$core_version = WC_Admin_Status::get_file_version( WC()->plugin_path() . '/templates/' . $file );
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
if ( ! $outdated_templates ) {
$outdated_templates = true;
}
}
$override_files[] = array(
'file' => str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ),
'version' => $theme_version,
'core_version' => $core_version,
);
}
}
$active_theme_info = array(
'name' => $active_theme->Name,
'version' => $active_theme->Version,
'version_latest' => WC_Admin_Status::get_latest_theme_version( $active_theme ),
'author_url' => esc_url_raw( $active_theme->{'Author URI'} ),
'is_child_theme' => is_child_theme(),
'has_woocommerce_support' => ( current_theme_supports( 'woocommerce' ) || in_array( $active_theme->template, wc_get_core_supported_themes() ) ),
'has_woocommerce_file' => ( file_exists( get_stylesheet_directory() . '/woocommerce.php' ) || file_exists( get_template_directory() . '/woocommerce.php' ) ),
'has_outdated_templates' => $outdated_templates,
'overrides' => $override_files,
);
return array_merge( $active_theme_info, $parent_theme_info );
}
/**
* Get some setting values for the site that are useful for debugging
* purposes. For full settings access, use the settings api.
*
* @return array
*/
public function get_settings() {
// Get a list of terms used for product/order taxonomies
$term_response = array();
$terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
$term_response[ $term->slug ] = strtolower( $term->name );
}
// Return array of useful settings for debugging.
return array(
'api_enabled' => 'yes' === get_option( 'woocommerce_api_enabled' ),
'force_ssl' => 'yes' === get_option( 'woocommerce_force_ssl_checkout' ),
'currency' => get_woocommerce_currency(),
'currency_symbol' => get_woocommerce_currency_symbol(),
'currency_position' => get_option( 'woocommerce_currency_pos' ),
'thousand_separator' => wc_get_price_thousand_separator(),
'decimal_separator' => wc_get_price_decimal_separator(),
'number_of_decimals' => wc_get_price_decimals(),
'geolocation_enabled' => in_array( get_option( 'woocommerce_default_customer_address' ), array( 'geolocation_ajax', 'geolocation' ) ),
'taxonomies' => $term_response,
);
}
/**
* Returns a mini-report on WC pages and if they are configured correctly:
* Present, visible, and including the correct shortcode.
*
* @return array
*/
public function get_pages() {
// WC pages to check against
$check_pages = array(
_x( 'Shop Base', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_shop_page_id',
'shortcode' => '',
),
_x( 'Cart', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_cart_page_id',
'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']',
),
_x( 'Checkout', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_checkout_page_id',
'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']',
),
_x( 'My Account', 'Page setting', 'woocommerce' ) => array(
'option' => 'woocommerce_myaccount_page_id',
'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']',
),
);
$pages_output = array();
foreach ( $check_pages as $page_name => $values ) {
$errors = array();
$page_id = get_option( $values['option'] );
$page_set = $page_exists = $page_visible = false;
$shortcode_present = $shortcode_required = false;
// Page checks
if ( $page_id ) {
$page_set = true;
}
if ( get_post( $page_id ) ) {
$page_exists = true;
}
if ( 'publish' === get_post_status( $page_id ) ) {
$page_visible = true;
}
// Shortcode checks
if ( $values['shortcode'] && get_post( $page_id ) ) {
$shortcode_required = true;
$page = get_post( $page_id );
if ( strstr( $page->post_content, $values['shortcode'] ) ) {
$shortcode_present = true;
}
}
// Wrap up our findings into an output array
$pages_output[] = array(
'page_name' => $page_name,
'page_id' => $page_id,
'page_set' => $page_set,
'page_exists' => $page_exists,
'page_visible' => $page_visible,
'shortcode' => $values['shortcode'],
'shortcode_required' => $shortcode_required,
'shortcode_present' => $shortcode_present,
);
}
return $pages_output;
}
/**
* Get any query params needed.
*
* @return array
*/
public function get_collection_params() {
return array(
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
);
}
}

View File

@ -0,0 +1,434 @@
<?php
/**
* REST API WC System Status Tools Controller
*
* Handles requests to the /system_status/tools/* endpoints.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @package WooCommerce/API
* @extends WC_REST_Controller
*/
class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v1';
/**
* Route base.
*
* @var string
*/
protected $rest_base = 'system_status/tools';
/**
* Register the routes for /system_status/tools/*.
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => $this->get_collection_params(),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\w-]+)', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_item' ),
'permission_callback' => array( $this, 'get_item_permissions_check' ),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_item' ),
'permission_callback' => array( $this, 'update_item_permissions_check' ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
}
/**
* Check whether a given request has permission to view system status tools.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check whether a given request has permission to view a specific system status tool.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_item_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check whether a given request has permission to execute a specific system status tool.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function update_item_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'system_status', 'edit' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* A list of avaiable tools for use in the system status section.
* 'button' becomes 'action' in the API.
*
* @return array
*/
public function get_tools() {
$tools = array(
'clear_transients' => array(
'name' => __( 'WC Transients', 'woocommerce' ),
'button' => __( 'Clear transients', 'woocommerce' ),
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ),
),
'clear_expired_transients' => array(
'name' => __( 'Expired Transients', 'woocommerce' ),
'button' => __( 'Clear expired transients', 'woocommerce' ),
'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ),
),
'recount_terms' => array(
'name' => __( 'Term counts', 'woocommerce' ),
'button' => __( 'Recount terms', 'woocommerce' ),
'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ),
),
'reset_roles' => array(
'name' => __( 'Capabilities', 'woocommerce' ),
'button' => __( 'Reset capabilities', 'woocommerce' ),
'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ),
),
'clear_sessions' => array(
'name' => __( 'Customer Sessions', 'woocommerce' ),
'button' => __( 'Clear all sessions', 'woocommerce' ),
'desc' => __( '<strong class="red">Warning:</strong> This tool will delete all customer session data from the database, including any current live carts.', 'woocommerce' ),
),
'install_pages' => array(
'name' => __( 'Install WooCommerce Pages', 'woocommerce' ),
'button' => __( 'Install pages', 'woocommerce' ),
'desc' => __( '<strong class="red">Note:</strong> This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce' ),
),
'delete_taxes' => array(
'name' => __( 'Delete all WooCommerce tax rates', 'woocommerce' ),
'button' => __( 'Delete ALL tax rates', 'woocommerce' ),
'desc' => __( '<strong class="red">Note:</strong> This option will delete ALL of your tax rates, use with caution.', 'woocommerce' ),
),
'reset_tracking' => array(
'name' => __( 'Reset Usage Tracking Settings', 'woocommerce' ),
'button' => __( 'Reset usage tracking settings', 'woocommerce' ),
'desc' => __( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', 'woocommerce' ),
)
);
return apply_filters( 'woocommerce_debug_tools', $tools );
}
/**
* Get a list of system status tools.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
$tools = array();
foreach ( $this->get_tools() as $id => $tool ) {
$tools[] = $this->prepare_response_for_collection( $this->prepare_item_for_response ( array(
'id' => $id,
'name' => $tool['name'],
'action' => $tool['button'],
'description' => $tool['desc'],
), $request ) );
}
$response = rest_ensure_response( $tools );
return $response;
}
/**
* Return a single tool.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public function get_item( $request ) {
$tools = $this->get_tools();
if ( empty( $tools[ $request['id'] ] ) ) {
return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$tool = $tools[ $request['id'] ];
return rest_ensure_response( $this->prepare_item_for_response ( array(
'id' => $request['id'],
'name' => $tool['name'],
'action' => $tool['button'],
'description' => $tool['desc'],
), $request ) );
}
/**
* Update (execute) a tool.
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public function update_item( $request ) {
$tools = $this->get_tools();
if ( empty( $tools[ $request['id'] ] ) ) {
return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$tool = $tools[ $request['id'] ];
$tool = array(
'id' => $request['id'],
'name' => $tool['name'],
'action' => $tool['button'],
'description' => $tool['desc'],
);
$execute_return = $this->execute_tool( $request['id'] );
$tool = array_merge( $tool, $execute_return );
$request->set_param( 'context', 'edit' );
$response = $this->prepare_item_for_response( $tool, $request );
return rest_ensure_response( $response );
}
/**
* Prepare a tool item for serialization.
*
* @param array $item Object.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response( $item, $request ) {
$context = empty( $request['context'] ) ? 'view' : $request['context'];
$data = $this->add_additional_fields_to_object( $item, $request );
$data = $this->filter_response_by_context( $data, $context );
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $item['id'] ) );
return $response;
}
/**
* Get the system status tools schema, conforming to JSON Schema.
*
* @return array
*/
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'system_status_tool',
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'A unique identifier for the tool.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_title',
),
),
'name' => array(
'description' => __( 'Tool name.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'action' => array(
'description' => __( 'What running the tool will do.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'description' => array(
'description' => __( 'Tool description.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'success' => array(
'description' => __( 'Did the tool run successfully?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'edit' ),
),
'message' => array(
'description' => __( 'Tool return message.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
),
);
return $this->add_additional_fields_schema( $schema );
}
/**
* Prepare links for the request.
*
* @param string $id
* @return array
*/
protected function prepare_links( $id ) {
$base = '/' . $this->namespace . '/' . $this->rest_base;
$links = array(
'item' => array(
'href' => rest_url( trailingslashit( $base ) . $id ),
'embeddable' => true,
),
);
return $links;
}
/**
* Get any query params needed.
*
* @return array
*/
public function get_collection_params() {
return array(
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
);
}
/**
* Actually executes a a tool.
*
* @param string $tool
* @return array
*/
public function execute_tool( $tool ) {
global $wpdb;
$ran = true;
switch ( $tool ) {
case 'clear_transients' :
wc_delete_product_transients();
wc_delete_shop_order_transients();
WC_Cache_Helper::get_transient_version( 'shipping', true );
$message = __( 'Product Transients Cleared', 'woocommerce' );
break;
case 'clear_expired_transients' :
/*
* Deletes all expired transients. The multi-table delete syntax is used.
* to delete the transient record from table a, and the corresponding.
* transient_timeout record from table b.
*
* Based on code inside core's upgrade_network() function.
*/
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
WHERE a.option_name LIKE %s
AND a.option_name NOT LIKE %s
AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
AND b.option_value < %d";
$rows = $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', time() ) );
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
WHERE a.option_name LIKE %s
AND a.option_name NOT LIKE %s
AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
AND b.option_value < %d";
$rows2 = $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', time() ) );
$message = sprintf( __( '%d Transients Rows Cleared', 'woocommerce' ), $rows + $rows2 );
break;
case 'reset_roles' :
// Remove then re-add caps and roles
WC_Install::remove_roles();
WC_Install::create_roles();
$message = __( 'Roles successfully reset', 'woocommerce' );
break;
case 'recount_terms' :
$product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
_wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), true, false );
$product_tags = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
_wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), true, false );
$message = __( 'Terms successfully recounted', 'woocommerce' );
break;
case 'clear_sessions' :
$wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" );
wp_cache_flush();
$message = __( 'Sessions successfully cleared', 'woocommerce' );
break;
case 'install_pages' :
WC_Install::create_pages();
return __( 'All missing WooCommerce pages was installed successfully.', 'woocommerce' );
break;
case 'delete_taxes' :
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;" );
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;" );
WC_Cache_Helper::incr_cache_prefix( 'taxes' );
$message = __( 'Tax rates successfully deleted', 'woocommerce' );
break;
case 'reset_tracking' :
delete_option( 'woocommerce_allow_tracking' );
WC_Admin_Notices::add_notice( 'tracking' );
$message = __( 'Usage tracking settings successfully reset.', 'woocommerce' );
break;
default :
$tools = $this->get_tools();
if ( isset( $tools[ $tool ]['callback'] ) ) {
$callback = $tools[ $tool ]['callback'];
$return = call_user_func( $callback );
if ( $return === false ) {
$callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback;
$ran = false;
$message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string );
} else {
$message = __( 'Tool ran.', 'woocommerce' );
}
} else {
$ran = false;
$message = __( 'There was an error calling this tool. There is no callback present.', 'woocommerce' );
}
break;
}
return array( 'success' => $ran, 'message' => $message );
}
}

View File

@ -174,7 +174,7 @@ class WC_REST_Taxes_Controller extends WC_REST_Controller {
*/
public function batch_items_permissions_check( $request ) {
if ( ! wc_rest_check_manager_permissions( 'settings', 'batch' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;

View File

@ -110,29 +110,29 @@ class WC_API_Coupons extends WC_API_Resource {
$coupon = new WC_Coupon( $code );
$coupon_post = get_post( $coupon->id );
$coupon_post = get_post( $coupon->get_id() );
$coupon_data = array(
'id' => $coupon->id,
'code' => $coupon->code,
'type' => $coupon->type,
'id' => $coupon->get_id(),
'code' => $coupon->get_code(),
'type' => $coupon->get_discount_type(),
'created_at' => $this->server->format_datetime( $coupon_post->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $coupon_post->post_modified_gmt ),
'amount' => wc_format_decimal( $coupon->amount, 2 ),
'individual_use' => ( 'yes' === $coupon->individual_use ),
'product_ids' => array_map( 'absint', (array) $coupon->product_ids ),
'exclude_product_ids' => array_map( 'absint', (array) $coupon->exclude_product_ids ),
'usage_limit' => ( ! empty( $coupon->usage_limit ) ) ? $coupon->usage_limit : null,
'usage_limit_per_user' => ( ! empty( $coupon->usage_limit_per_user ) ) ? $coupon->usage_limit_per_user : null,
'limit_usage_to_x_items' => (int) $coupon->limit_usage_to_x_items,
'usage_count' => (int) $coupon->usage_count,
'expiry_date' => $this->server->format_datetime( $coupon->expiry_date ),
'enable_free_shipping' => $coupon->enable_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->product_categories ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->exclude_product_categories ),
'exclude_sale_items' => $coupon->exclude_sale_items(),
'minimum_amount' => wc_format_decimal( $coupon->minimum_amount, 2 ),
'customer_emails' => $coupon->customer_email,
'amount' => wc_format_decimal( $coupon->get_amount(), 2 ),
'individual_use' => $coupon->get_individual_use(),
'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ),
'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ),
'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null,
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
'usage_count' => (int) $coupon->get_usage_count(),
'expiry_date' => $this->server->format_datetime( $coupon->get_expiry_date() ),
'enable_free_shipping' => $coupon->get_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ),
'exclude_sale_items' => $coupon->get_exclude_sale_items(),
'minimum_amount' => wc_format_decimal( $coupon->get_minimum_amount(), 2 ),
'customer_emails' => $coupon->get_email_restrictions(),
);
return array( 'coupon' => apply_filters( 'woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server ) );

View File

@ -146,7 +146,7 @@ class WC_API_Customers extends WC_API_Resource {
'first_name' => $customer->first_name,
'last_name' => $customer->last_name,
'username' => $customer->user_login,
'last_order_id' => is_object( $last_order ) ? $last_order->id : null,
'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null,
'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->post_date_gmt ) : null,
'orders_count' => (int) $customer->_order_count,
'total_spent' => wc_format_decimal( $customer->_money_spent, 2 ),
@ -359,43 +359,43 @@ class WC_API_Customers extends WC_API_Resource {
*/
public function add_customer_data( $order_data, $order ) {
if ( 0 == $order->customer_user ) {
if ( 0 == $order->get_user_id() ) {
// add customer data from order
$order_data['customer'] = array(
'id' => 0,
'email' => $order->billing_email,
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'email' => $order->get_billing_email(),
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'billing_address' => array(
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address_1' => $order->billing_address_1,
'address_2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'postcode' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
'phone' => $order->billing_phone,
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
'address_1' => $order->get_billing_address_1(),
'address_2' => $order->get_billing_address_2(),
'city' => $order->get_billing_city(),
'state' => $order->get_billing_state(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'email' => $order->get_billing_email(),
'phone' => $order->get_billing_phone(),
),
'shipping_address' => array(
'first_name' => $order->shipping_first_name,
'last_name' => $order->shipping_last_name,
'company' => $order->shipping_company,
'address_1' => $order->shipping_address_1,
'address_2' => $order->shipping_address_2,
'city' => $order->shipping_city,
'state' => $order->shipping_state,
'postcode' => $order->shipping_postcode,
'country' => $order->shipping_country,
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'company' => $order->get_shipping_company(),
'address_1' => $order->get_shipping_address_1(),
'address_2' => $order->get_shipping_address_2(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
);
} else {
$order_data['customer'] = current( $this->get_customer( $order->customer_user ) );
$order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) );
}
return $order_data;

View File

@ -114,7 +114,7 @@ class WC_API_Orders extends WC_API_Resource {
$order_post = get_post( $id );
$order_data = array(
'id' => $order->id,
'id' => $order->get_id(),
'order_number' => $order->get_order_number(),
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
@ -133,38 +133,38 @@ class WC_API_Orders extends WC_API_Resource {
'order_discount' => wc_format_decimal( $order->get_order_discount(), 2 ),
'shipping_methods' => $order->get_shipping_method(),
'payment_details' => array(
'method_id' => $order->payment_method,
'method_title' => $order->payment_method_title,
'paid' => isset( $order->paid_date ),
'method_id' => $order->get_payment_method(),
'method_title' => $order->get_payment_method_title(),
'paid' => 0 < $order->get_date_paid(),
),
'billing_address' => array(
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address_1' => $order->billing_address_1,
'address_2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'postcode' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
'phone' => $order->billing_phone,
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
'address_1' => $order->get_billing_address_1(),
'address_2' => $order->get_billing_address_2(),
'city' => $order->get_billing_city(),
'state' => $order->get_billing_state(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'email' => $order->get_billing_email(),
'phone' => $order->get_billing_phone(),
),
'shipping_address' => array(
'first_name' => $order->shipping_first_name,
'last_name' => $order->shipping_last_name,
'company' => $order->shipping_company,
'address_1' => $order->shipping_address_1,
'address_2' => $order->shipping_address_2,
'city' => $order->shipping_city,
'state' => $order->shipping_state,
'postcode' => $order->shipping_postcode,
'country' => $order->shipping_country,
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'company' => $order->get_shipping_company(),
'address_1' => $order->get_shipping_address_1(),
'address_2' => $order->get_shipping_address_2(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
'note' => $order->customer_note,
'customer_ip' => $order->customer_ip_address,
'customer_user_agent' => $order->customer_user_agent,
'customer_id' => $order->customer_user,
'note' => $order->get_customer_note(),
'customer_ip' => $order->get_customer_ip_address(),
'customer_user_agent' => $order->get_customer_user_agent(),
'customer_id' => $order->get_user_id(),
'view_order_url' => $order->get_view_order_url(),
'line_items' => array(),
'shipping_lines' => array(),

View File

@ -121,29 +121,29 @@ class WC_API_Coupons extends WC_API_Resource {
}
$coupon = new WC_Coupon( $code );
$coupon_post = get_post( $coupon->id );
$coupon_post = get_post( $coupon->get_id() );
$coupon_data = array(
'id' => $coupon->id,
'code' => $coupon->code,
'type' => $coupon->type,
'id' => $coupon->get_id(),
'code' => $coupon->get_code(),
'type' => $coupon->get_discount_type(),
'created_at' => $this->server->format_datetime( $coupon_post->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $coupon_post->post_modified_gmt ),
'amount' => wc_format_decimal( $coupon->coupon_amount, 2 ),
'individual_use' => ( 'yes' === $coupon->individual_use ),
'product_ids' => array_map( 'absint', (array) $coupon->product_ids ),
'exclude_product_ids' => array_map( 'absint', (array) $coupon->exclude_product_ids ),
'usage_limit' => ( ! empty( $coupon->usage_limit ) ) ? $coupon->usage_limit : null,
'usage_limit_per_user' => ( ! empty( $coupon->usage_limit_per_user ) ) ? $coupon->usage_limit_per_user : null,
'limit_usage_to_x_items' => (int) $coupon->limit_usage_to_x_items,
'usage_count' => (int) $coupon->usage_count,
'expiry_date' => ( ! empty( $coupon->expiry_date ) ) ? $this->server->format_datetime( $coupon->expiry_date ) : null,
'enable_free_shipping' => $coupon->enable_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->product_categories ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->exclude_product_categories ),
'exclude_sale_items' => $coupon->exclude_sale_items(),
'minimum_amount' => wc_format_decimal( $coupon->minimum_amount, 2 ),
'maximum_amount' => wc_format_decimal( $coupon->maximum_amount, 2 ),
'customer_emails' => $coupon->customer_email,
'amount' => wc_format_decimal( $coupon->get_amount(), 2 ),
'individual_use' => $coupon->get_individual_use(),
'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ),
'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ),
'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null,
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
'usage_count' => (int) $coupon->get_usage_count(),
'expiry_date' => $coupon->get_expiry_date() ? $this->server->format_datetime( $coupon->get_expiry_date() ) : null,
'enable_free_shipping' => $coupon->get_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ),
'exclude_sale_items' => $coupon->get_exclude_sale_items(),
'minimum_amount' => wc_format_decimal( $coupon->get_minimum_amount(), 2 ),
'maximum_amount' => wc_format_decimal( $coupon->get_maximum_amount(), 2 ),
'customer_emails' => $coupon->get_email_restrictions(),
'description' => $coupon_post->post_excerpt,
);

View File

@ -169,7 +169,7 @@ class WC_API_Customers extends WC_API_Resource {
'last_name' => $customer->last_name,
'username' => $customer->user_login,
'role' => $roles[0],
'last_order_id' => is_object( $last_order ) ? $last_order->id : null,
'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null,
'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->post_date_gmt ) : null,
'orders_count' => wc_get_customer_order_count( $customer->ID ),
'total_spent' => wc_format_decimal( wc_get_customer_total_spent( $customer->ID ), 2 ),
@ -622,43 +622,43 @@ class WC_API_Customers extends WC_API_Resource {
*/
public function add_customer_data( $order_data, $order ) {
if ( 0 == $order->customer_user ) {
if ( 0 == $order->get_user_id() ) {
// add customer data from order
$order_data['customer'] = array(
'id' => 0,
'email' => $order->billing_email,
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'email' => $order->get_billing_email(),
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'billing_address' => array(
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address_1' => $order->billing_address_1,
'address_2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'postcode' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
'phone' => $order->billing_phone,
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
'address_1' => $order->get_billing_address_1(),
'address_2' => $order->get_billing_address_2(),
'city' => $order->get_billing_city(),
'state' => $order->get_billing_state(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'email' => $order->get_billing_email(),
'phone' => $order->get_billing_phone(),
),
'shipping_address' => array(
'first_name' => $order->shipping_first_name,
'last_name' => $order->shipping_last_name,
'company' => $order->shipping_company,
'address_1' => $order->shipping_address_1,
'address_2' => $order->shipping_address_2,
'city' => $order->shipping_city,
'state' => $order->shipping_state,
'postcode' => $order->shipping_postcode,
'country' => $order->shipping_country,
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'company' => $order->get_shipping_company(),
'address_1' => $order->get_shipping_address_1(),
'address_2' => $order->get_shipping_address_2(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
);
} else {
$order_data['customer'] = current( $this->get_customer( $order->customer_user ) );
$order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) );
}
return $order_data;

View File

@ -154,13 +154,13 @@ class WC_API_Orders extends WC_API_Resource {
$order_post = get_post( $id );
$order_data = array(
'id' => $order->id,
'id' => $order->get_id(),
'order_number' => $order->get_order_number(),
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
'status' => $order->get_status(),
'currency' => $order->get_order_currency(),
'currency' => $order->get_currency(),
'total' => wc_format_decimal( $order->get_total(), $dp ),
'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ),
'total_line_items_quantity' => $order->get_item_count(),
@ -171,37 +171,37 @@ class WC_API_Orders extends WC_API_Resource {
'total_discount' => wc_format_decimal( $order->get_total_discount(), $dp ),
'shipping_methods' => $order->get_shipping_method(),
'payment_details' => array(
'method_id' => $order->payment_method,
'method_title' => $order->payment_method_title,
'paid' => isset( $order->paid_date ),
'method_id' => $order->get_payment_method(),
'method_title' => $order->get_payment_method_title(),
'paid' => 0 < $order->get_date_paid(),
),
'billing_address' => array(
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address_1' => $order->billing_address_1,
'address_2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'postcode' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
'phone' => $order->billing_phone,
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
'address_1' => $order->get_billing_address_1(),
'address_2' => $order->get_billing_address_2(),
'city' => $order->get_billing_city(),
'state' => $order->get_billing_state(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'email' => $order->get_billing_email(),
'phone' => $order->get_billing_phone(),
),
'shipping_address' => array(
'first_name' => $order->shipping_first_name,
'last_name' => $order->shipping_last_name,
'company' => $order->shipping_company,
'address_1' => $order->shipping_address_1,
'address_2' => $order->shipping_address_2,
'city' => $order->shipping_city,
'state' => $order->shipping_state,
'postcode' => $order->shipping_postcode,
'country' => $order->shipping_country,
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'company' => $order->get_shipping_company(),
'address_1' => $order->get_shipping_address_1(),
'address_2' => $order->get_shipping_address_2(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
'note' => $order->customer_note,
'customer_ip' => $order->customer_ip_address,
'customer_user_agent' => $order->customer_user_agent,
'note' => $order->get_customer_note(),
'customer_ip' => $order->get_customer_ip_address(),
'customer_user_agent' => $order->get_customer_user_agent(),
'customer_id' => $order->get_user_id(),
'view_order_url' => $order->get_view_order_url(),
'line_items' => array(),
@ -451,8 +451,8 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_invalid_payment_details', __( 'Payment method ID and title are required', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_payment_method', $data['payment_details']['method_id'] );
update_post_meta( $order->id, '_payment_method_title', $data['payment_details']['method_title'] );
update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] );
update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] );
// mark as paid if set
if ( isset( $data['payment_details']['paid'] ) && true === $data['payment_details']['paid'] ) {
@ -467,24 +467,24 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid', 'woocommerce'), 400 );
}
update_post_meta( $order->id, '_order_currency', $data['currency'] );
update_post_meta( $order->get_id(), '_order_currency', $data['currency'] );
}
// set order meta
if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) {
$this->set_order_meta( $order->id, $data['order_meta'] );
$this->set_order_meta( $order->get_id(), $data['order_meta'] );
}
// HTTP 201 Created
$this->server->send_status( 201 );
wc_delete_shop_order_transients( $order->id );
wc_delete_shop_order_transients( $order->get_id() );
do_action( 'woocommerce_api_create_order', $order->id, $data, $this );
do_action( 'woocommerce_api_create_order', $order->get_id(), $data, $this );
wc_transaction_query( 'commit' );
return $this->get_order( $order->id );
return $this->get_order( $order->get_id() );
} catch ( WC_API_Exception $e ) {
@ -538,7 +538,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_order_id', __( 'Order ID is invalid', 'woocommerce' ), 400 );
}
$order_args = array( 'order_id' => $order->id );
$order_args = array( 'order_id' => $order->get_id() );
// Customer note.
if ( isset( $data['note'] ) ) {
@ -552,7 +552,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Customer ID is invalid', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_customer_user', $data['customer_id'] );
update_post_meta( $order->get_id(), '_customer_user', $data['customer_id'] );
}
// Billing/shipping address.
@ -597,12 +597,12 @@ class WC_API_Orders extends WC_API_Resource {
// Method ID.
if ( isset( $data['payment_details']['method_id'] ) ) {
update_post_meta( $order->id, '_payment_method', $data['payment_details']['method_id'] );
update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] );
}
// Method title.
if ( isset( $data['payment_details']['method_title'] ) ) {
update_post_meta( $order->id, '_payment_method_title', $data['payment_details']['method_title'] );
update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] );
}
// Mark as paid if set.
@ -617,7 +617,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_order_currency', $data['currency'] );
update_post_meta( $order->get_id(), '_order_currency', $data['currency'] );
}
// If items have changed, recalculate order totals.
@ -627,7 +627,7 @@ class WC_API_Orders extends WC_API_Resource {
// Update order meta.
if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) {
$this->set_order_meta( $order->id, $data['order_meta'] );
$this->set_order_meta( $order->get_id(), $data['order_meta'] );
}
// Update the order post to set customer note/modified date.
@ -638,9 +638,9 @@ class WC_API_Orders extends WC_API_Resource {
$order->update_status( $data['status'], isset( $data['status_note'] ) ? $data['status_note'] : '', true );
}
wc_delete_shop_order_transients( $order->id );
wc_delete_shop_order_transients( $order->get_id() );
do_action( 'woocommerce_api_edit_order', $order->id, $data, $this );
do_action( 'woocommerce_api_edit_order', $order->get_id(), $data, $this );
return $this->get_order( $id );
@ -835,7 +835,7 @@ class WC_API_Orders extends WC_API_Resource {
$result = $wpdb->get_row(
$wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d",
absint( $item['id'] ),
absint( $order->id )
absint( $order->get_id() )
) );
if ( is_null( $result ) ) {
@ -1321,7 +1321,7 @@ class WC_API_Orders extends WC_API_Resource {
do_action( 'woocommerce_api_create_order_note', $note_id, $order_id, $this );
return $this->get_order_note( $order->id, $note_id );
return $this->get_order_note( $order->get_id(), $note_id );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
@ -1368,11 +1368,11 @@ class WC_API_Orders extends WC_API_Resource {
}
// Ensure note ID is associated with given order
if ( $note->comment_post_ID != $order->id ) {
if ( $note->comment_post_ID != $order->get_id() ) {
throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 );
}
$data = apply_filters( 'woocommerce_api_edit_order_note_data', $data, $note->comment_ID, $order->id, $this );
$data = apply_filters( 'woocommerce_api_edit_order_note_data', $data, $note->comment_ID, $order->get_id(), $this );
// Note content
if ( isset( $data['note'] ) ) {
@ -1391,9 +1391,9 @@ class WC_API_Orders extends WC_API_Resource {
update_comment_meta( $note->comment_ID, 'is_customer_note', true === $data['customer_note'] ? 1 : 0 );
}
do_action( 'woocommerce_api_edit_order_note', $note->comment_ID, $order->id, $this );
do_action( 'woocommerce_api_edit_order_note', $note->comment_ID, $order->get_id(), $this );
return $this->get_order_note( $order->id, $note->comment_ID );
return $this->get_order_note( $order->get_id(), $note->comment_ID );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
@ -1614,8 +1614,8 @@ class WC_API_Orders extends WC_API_Resource {
$order = wc_get_order( $order_id );
if ( isset( $payment_gateways[ $order->payment_method ] ) && $payment_gateways[ $order->payment_method ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->payment_method ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
if ( is_wp_error( $result ) ) {
return $result;

View File

@ -121,29 +121,29 @@ class WC_API_Coupons extends WC_API_Resource {
}
$coupon = new WC_Coupon( $code );
$coupon_post = get_post( $coupon->id );
$coupon_post = get_post( $coupon->get_id() );
$coupon_data = array(
'id' => $coupon->id,
'code' => $coupon->code,
'type' => $coupon->type,
'id' => $coupon->get_id(),
'code' => $coupon->get_code(),
'type' => $coupon->get_discount_type(),
'created_at' => $this->server->format_datetime( $coupon_post->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $coupon_post->post_modified_gmt ),
'amount' => wc_format_decimal( $coupon->coupon_amount, 2 ),
'individual_use' => ( 'yes' === $coupon->individual_use ),
'product_ids' => array_map( 'absint', (array) $coupon->product_ids ),
'exclude_product_ids' => array_map( 'absint', (array) $coupon->exclude_product_ids ),
'usage_limit' => ( ! empty( $coupon->usage_limit ) ) ? $coupon->usage_limit : null,
'usage_limit_per_user' => ( ! empty( $coupon->usage_limit_per_user ) ) ? $coupon->usage_limit_per_user : null,
'limit_usage_to_x_items' => (int) $coupon->limit_usage_to_x_items,
'usage_count' => (int) $coupon->usage_count,
'expiry_date' => ( ! empty( $coupon->expiry_date ) ) ? $this->server->format_datetime( $coupon->expiry_date ) : null,
'enable_free_shipping' => $coupon->enable_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->product_categories ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->exclude_product_categories ),
'exclude_sale_items' => $coupon->exclude_sale_items(),
'minimum_amount' => wc_format_decimal( $coupon->minimum_amount, 2 ),
'maximum_amount' => wc_format_decimal( $coupon->maximum_amount, 2 ),
'customer_emails' => $coupon->customer_email,
'amount' => wc_format_decimal( $coupon->get_amount(), 2 ),
'individual_use' => $coupon->get_individual_use(),
'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ),
'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ),
'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null,
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
'usage_count' => (int) $coupon->get_usage_count(),
'expiry_date' => $coupon->get_expiry_date() ? $this->server->format_datetime( $coupon->get_expiry_date() ) : null,
'enable_free_shipping' => $coupon->get_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ),
'exclude_sale_items' => $coupon->get_exclude_sale_items(),
'minimum_amount' => wc_format_decimal( $coupon->get_minimum_amount(), 2 ),
'maximum_amount' => wc_format_decimal( $coupon->get_maximum_amount(), 2 ),
'customer_emails' => $coupon->get_email_restrictions(),
'description' => $coupon_post->post_excerpt,
);

View File

@ -170,7 +170,7 @@ class WC_API_Customers extends WC_API_Resource {
'last_name' => $customer->last_name,
'username' => $customer->user_login,
'role' => $roles[0],
'last_order_id' => is_object( $last_order ) ? $last_order->id : null,
'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null,
'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->post_date_gmt ) : null,
'orders_count' => wc_get_customer_order_count( $customer->ID ),
'total_spent' => wc_format_decimal( wc_get_customer_total_spent( $customer->ID ), 2 ),
@ -611,43 +611,43 @@ class WC_API_Customers extends WC_API_Resource {
*/
public function add_customer_data( $order_data, $order ) {
if ( 0 == $order->customer_user ) {
if ( 0 == $order->get_user_id() ) {
// add customer data from order
$order_data['customer'] = array(
'id' => 0,
'email' => $order->billing_email,
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'email' => $order->get_billing_email(),
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'billing_address' => array(
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address_1' => $order->billing_address_1,
'address_2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'postcode' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
'phone' => $order->billing_phone,
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
'address_1' => $order->get_billing_address_1(),
'address_2' => $order->get_billing_address_2(),
'city' => $order->get_billing_city(),
'state' => $order->get_billing_state(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'email' => $order->get_billing_email(),
'phone' => $order->get_billing_phone(),
),
'shipping_address' => array(
'first_name' => $order->shipping_first_name,
'last_name' => $order->shipping_last_name,
'company' => $order->shipping_company,
'address_1' => $order->shipping_address_1,
'address_2' => $order->shipping_address_2,
'city' => $order->shipping_city,
'state' => $order->shipping_state,
'postcode' => $order->shipping_postcode,
'country' => $order->shipping_country,
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'company' => $order->get_shipping_company(),
'address_1' => $order->get_shipping_address_1(),
'address_2' => $order->get_shipping_address_2(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
);
} else {
$order_data['customer'] = current( $this->get_customer( $order->customer_user ) );
$order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) );
}
return $order_data;

View File

@ -159,14 +159,14 @@ class WC_API_Orders extends WC_API_Resource {
}
$order_data = array(
'id' => $order->id,
'id' => $order->get_id(),
'order_number' => $order->get_order_number(),
'order_key' => $order->order_key,
'order_key' => $order->get_order_key(),
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
'status' => $order->get_status(),
'currency' => $order->get_order_currency(),
'currency' => $order->get_currency(),
'total' => wc_format_decimal( $order->get_total(), $dp ),
'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ),
'total_line_items_quantity' => $order->get_item_count(),
@ -177,37 +177,37 @@ class WC_API_Orders extends WC_API_Resource {
'total_discount' => wc_format_decimal( $order->get_total_discount(), $dp ),
'shipping_methods' => $order->get_shipping_method(),
'payment_details' => array(
'method_id' => $order->payment_method,
'method_title' => $order->payment_method_title,
'paid' => isset( $order->paid_date ),
'method_id' => $order->get_payment_method(),
'method_title' => $order->get_payment_method_title(),
'paid' => 0 < $order->get_date_paid(),
),
'billing_address' => array(
'first_name' => $order->billing_first_name,
'last_name' => $order->billing_last_name,
'company' => $order->billing_company,
'address_1' => $order->billing_address_1,
'address_2' => $order->billing_address_2,
'city' => $order->billing_city,
'state' => $order->billing_state,
'postcode' => $order->billing_postcode,
'country' => $order->billing_country,
'email' => $order->billing_email,
'phone' => $order->billing_phone,
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'company' => $order->get_billing_company(),
'address_1' => $order->get_billing_address_1(),
'address_2' => $order->get_billing_address_2(),
'city' => $order->get_billing_city(),
'state' => $order->get_billing_state(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'email' => $order->get_billing_email(),
'phone' => $order->get_billing_phone(),
),
'shipping_address' => array(
'first_name' => $order->shipping_first_name,
'last_name' => $order->shipping_last_name,
'company' => $order->shipping_company,
'address_1' => $order->shipping_address_1,
'address_2' => $order->shipping_address_2,
'city' => $order->shipping_city,
'state' => $order->shipping_state,
'postcode' => $order->shipping_postcode,
'country' => $order->shipping_country,
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'company' => $order->get_shipping_company(),
'address_1' => $order->get_shipping_address_1(),
'address_2' => $order->get_shipping_address_2(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
'note' => $order->customer_note,
'customer_ip' => $order->customer_ip_address,
'customer_user_agent' => $order->customer_user_agent,
'note' => $order->get_customer_note(),
'customer_ip' => $order->get_customer_ip_address(),
'customer_user_agent' => $order->get_customer_user_agent(),
'customer_id' => $order->get_user_id(),
'view_order_url' => $order->get_view_order_url(),
'line_items' => array(),
@ -474,7 +474,7 @@ class WC_API_Orders extends WC_API_Resource {
// set is vat exempt
if ( isset( $data['is_vat_exempt'] ) ) {
update_post_meta( $order->id, '_is_vat_exempt', $data['is_vat_exempt'] ? 'yes' : 'no' );
update_post_meta( $order->get_id(), '_is_vat_exempt', $data['is_vat_exempt'] ? 'yes' : 'no' );
}
// calculate totals and set them
@ -488,8 +488,8 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_invalid_payment_details', __( 'Payment method ID and title are required', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_payment_method', $data['payment_details']['method_id'] );
update_post_meta( $order->id, '_payment_method_title', $data['payment_details']['method_title'] );
update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] );
update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] );
// mark as paid if set
if ( isset( $data['payment_details']['paid'] ) && true === $data['payment_details']['paid'] ) {
@ -504,24 +504,24 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid', 'woocommerce'), 400 );
}
update_post_meta( $order->id, '_order_currency', $data['currency'] );
update_post_meta( $order->get_id(), '_order_currency', $data['currency'] );
}
// set order meta
if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) {
$this->set_order_meta( $order->id, $data['order_meta'] );
$this->set_order_meta( $order->get_id(), $data['order_meta'] );
}
// HTTP 201 Created
$this->server->send_status( 201 );
wc_delete_shop_order_transients( $order->id );
wc_delete_shop_order_transients( $order->get_id() );
do_action( 'woocommerce_api_create_order', $order->id, $data, $this );
do_action( 'woocommerce_api_create_order', $order->get_id(), $data, $this );
wc_transaction_query( 'commit' );
return $this->get_order( $order->id );
return $this->get_order( $order->get_id() );
} catch ( WC_API_Exception $e ) {
@ -575,7 +575,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_order_id', __( 'Order ID is invalid', 'woocommerce' ), 400 );
}
$order_args = array( 'order_id' => $order->id );
$order_args = array( 'order_id' => $order->get_id() );
// Customer note.
if ( isset( $data['note'] ) ) {
@ -589,7 +589,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Customer ID is invalid', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_customer_user', $data['customer_id'] );
update_post_meta( $order->get_id(), '_customer_user', $data['customer_id'] );
}
// Billing/shipping address.
@ -633,12 +633,12 @@ class WC_API_Orders extends WC_API_Resource {
// Method ID.
if ( isset( $data['payment_details']['method_id'] ) ) {
update_post_meta( $order->id, '_payment_method', $data['payment_details']['method_id'] );
update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] );
}
// Method title.
if ( isset( $data['payment_details']['method_title'] ) ) {
update_post_meta( $order->id, '_payment_method_title', $data['payment_details']['method_title'] );
update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] );
}
// Mark as paid if set.
@ -653,7 +653,7 @@ class WC_API_Orders extends WC_API_Resource {
throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid', 'woocommerce' ), 400 );
}
update_post_meta( $order->id, '_order_currency', $data['currency'] );
update_post_meta( $order->get_id(), '_order_currency', $data['currency'] );
}
// If items have changed, recalculate order totals.
@ -663,7 +663,7 @@ class WC_API_Orders extends WC_API_Resource {
// Update order meta.
if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) {
$this->set_order_meta( $order->id, $data['order_meta'] );
$this->set_order_meta( $order->get_id(), $data['order_meta'] );
}
// Update the order post to set customer note/modified date.
@ -674,9 +674,9 @@ class WC_API_Orders extends WC_API_Resource {
$order->update_status( $data['status'], isset( $data['status_note'] ) ? $data['status_note'] : '', true );
}
wc_delete_shop_order_transients( $order->id );
wc_delete_shop_order_transients( $order->get_id() );
do_action( 'woocommerce_api_edit_order', $order->id, $data, $this );
do_action( 'woocommerce_api_edit_order', $order->get_id(), $data, $this );
return $this->get_order( $id );
} catch ( WC_API_Exception $e ) {
@ -877,7 +877,7 @@ class WC_API_Orders extends WC_API_Resource {
$result = $wpdb->get_row(
$wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d",
absint( $item['id'] ),
absint( $order->id )
absint( $order->get_id() )
) );
if ( is_null( $result ) ) {
@ -1366,7 +1366,7 @@ class WC_API_Orders extends WC_API_Resource {
do_action( 'woocommerce_api_create_order_note', $note_id, $order_id, $this );
return $this->get_order_note( $order->id, $note_id );
return $this->get_order_note( $order->get_id(), $note_id );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
@ -1413,11 +1413,11 @@ class WC_API_Orders extends WC_API_Resource {
}
// Ensure note ID is associated with given order
if ( $note->comment_post_ID != $order->id ) {
if ( $note->comment_post_ID != $order->get_id() ) {
throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 );
}
$data = apply_filters( 'woocommerce_api_edit_order_note_data', $data, $note->comment_ID, $order->id, $this );
$data = apply_filters( 'woocommerce_api_edit_order_note_data', $data, $note->comment_ID, $order->get_id(), $this );
// Note content
if ( isset( $data['note'] ) ) {
@ -1436,9 +1436,9 @@ class WC_API_Orders extends WC_API_Resource {
update_comment_meta( $note->comment_ID, 'is_customer_note', true === $data['customer_note'] ? 1 : 0 );
}
do_action( 'woocommerce_api_edit_order_note', $note->comment_ID, $order->id, $this );
do_action( 'woocommerce_api_edit_order_note', $note->comment_ID, $order->get_id(), $this );
return $this->get_order_note( $order->id, $note->comment_ID );
return $this->get_order_note( $order->get_id(), $note->comment_ID );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
@ -1659,8 +1659,8 @@ class WC_API_Orders extends WC_API_Resource {
$order = wc_get_order( $order_id );
if ( isset( $payment_gateways[ $order->payment_method ] ) && $payment_gateways[ $order->payment_method ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->payment_method ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund->get_refund_amount(), $refund->get_refund_reason() );
if ( is_wp_error( $result ) ) {
return $result;

View File

@ -310,34 +310,34 @@ class WC_AJAX {
WC()->session->set( 'chosen_payment_method', empty( $_POST['payment_method'] ) ? '' : $_POST['payment_method'] );
if ( isset( $_POST['country'] ) ) {
WC()->customer->set_country( $_POST['country'] );
WC()->customer->set_billing_country( $_POST['country'] );
}
if ( isset( $_POST['state'] ) ) {
WC()->customer->set_state( $_POST['state'] );
WC()->customer->set_billing_state( $_POST['state'] );
}
if ( isset( $_POST['postcode'] ) ) {
WC()->customer->set_postcode( $_POST['postcode'] );
WC()->customer->set_billing_postcode( $_POST['postcode'] );
}
if ( isset( $_POST['city'] ) ) {
WC()->customer->set_city( $_POST['city'] );
WC()->customer->set_billing_city( $_POST['city'] );
}
if ( isset( $_POST['address'] ) ) {
WC()->customer->set_address( $_POST['address'] );
WC()->customer->set_billing_address( $_POST['address'] );
}
if ( isset( $_POST['address_2'] ) ) {
WC()->customer->set_address_2( $_POST['address_2'] );
WC()->customer->set_billing_address_2( $_POST['address_2'] );
}
if ( wc_ship_to_billing_address_only() ) {
if ( ! empty( $_POST['country'] ) ) {
WC()->customer->set_shipping_country( $_POST['country'] );
WC()->customer->calculated_shipping( true );
WC()->customer->set_calculated_shipping( true );
}
if ( isset( $_POST['state'] ) ) {
@ -363,7 +363,7 @@ class WC_AJAX {
if ( ! empty( $_POST['s_country'] ) ) {
WC()->customer->set_shipping_country( $_POST['s_country'] );
WC()->customer->calculated_shipping( true );
WC()->customer->set_calculated_shipping( true );
}
if ( isset( $_POST['s_state'] ) ) {
@ -387,6 +387,7 @@ class WC_AJAX {
}
}
WC()->customer->save();
WC()->cart->calculate_totals();
// Get order review fragment
@ -1061,7 +1062,7 @@ class WC_AJAX {
$product = wc_get_product( $product_id );
$files = $product->get_files();
if ( ! $order->billing_email ) {
if ( ! $order->get_billing_email() ) {
die();
}
@ -1147,64 +1148,16 @@ class WC_AJAX {
die();
}
$_product = wc_get_product( $post->ID );
$product = wc_get_product( $post->ID );
$order = wc_get_order( $order_id );
$order_taxes = $order->get_taxes();
$class = 'new_row';
// Set values
$item = array();
$item['product_id'] = $_product->id;
$item['variation_id'] = isset( $_product->variation_id ) ? $_product->variation_id : '';
$item['variation_data'] = $item['variation_id'] ? $_product->get_variation_attributes() : '';
$item['name'] = $_product->get_title();
$item['tax_class'] = $_product->get_tax_class();
$item['qty'] = 1;
$item['line_subtotal'] = wc_format_decimal( $_product->get_price_excluding_tax() );
$item['line_subtotal_tax'] = '';
$item['line_total'] = wc_format_decimal( $_product->get_price_excluding_tax() );
$item['line_tax'] = '';
$item['type'] = 'line_item';
// Add line item
$item_id = wc_add_order_item( $order_id, array(
'order_item_name' => $item['name'],
'order_item_type' => 'line_item'
) );
// Add line item meta
if ( $item_id ) {
wc_add_order_item_meta( $item_id, '_qty', $item['qty'] );
wc_add_order_item_meta( $item_id, '_tax_class', $item['tax_class'] );
wc_add_order_item_meta( $item_id, '_product_id', $item['product_id'] );
wc_add_order_item_meta( $item_id, '_variation_id', $item['variation_id'] );
wc_add_order_item_meta( $item_id, '_line_subtotal', $item['line_subtotal'] );
wc_add_order_item_meta( $item_id, '_line_subtotal_tax', $item['line_subtotal_tax'] );
wc_add_order_item_meta( $item_id, '_line_total', $item['line_total'] );
wc_add_order_item_meta( $item_id, '_line_tax', $item['line_tax'] );
// Since 2.2
wc_add_order_item_meta( $item_id, '_line_tax_data', array( 'total' => array(), 'subtotal' => array() ) );
// Store variation data in meta
if ( $item['variation_data'] && is_array( $item['variation_data'] ) ) {
foreach ( $item['variation_data'] as $key => $value ) {
wc_add_order_item_meta( $item_id, str_replace( 'attribute_', '', $key ), $value );
}
}
$item_id = $order->add_product( $product );
$item = apply_filters( 'woocommerce_ajax_order_item', $order->get_item( $item_id ), $item_id );
do_action( 'woocommerce_ajax_add_order_item_meta', $item_id, $item );
}
$item['item_meta'] = $order->get_item_meta( $item_id );
$item['item_meta_array'] = $order->get_item_meta_array( $item_id );
$item = $order->expand_item_meta( $item );
$item = apply_filters( 'woocommerce_ajax_order_item', $item, $item_id );
include( 'admin/meta-boxes/views/html-order-item.php' );
// Quit out
die();
}
@ -1255,11 +1208,11 @@ class WC_AJAX {
$order = wc_get_order( $order_id );
$order_taxes = $order->get_taxes();
$shipping_methods = WC()->shipping() ? WC()->shipping->load_shipping_methods() : array();
$item = array();
// Add new shipping
$shipping = new WC_Shipping_Rate();
$item_id = $order->add_shipping( $shipping );
$item = $order->get_item( $item_id );
include( 'admin/meta-boxes/views/html-order-shipping.php' );
@ -1366,8 +1319,14 @@ class WC_AJAX {
if ( $_product->exists() && $_product->managing_stock() && isset( $order_item_qty[ $item_id ] ) && $order_item_qty[ $item_id ] > 0 ) {
$stock_change = apply_filters( 'woocommerce_reduce_order_stock_quantity', $order_item_qty[ $item_id ], $item_id );
$new_stock = $_product->reduce_stock( $stock_change );
$item_name = $_product->get_sku() ? $_product->get_sku() : $order_item['product_id'];
$item_name = $_product->get_sku() ? $_product->get_sku() : $_product->id;
if ( ! empty( $_product->variation_id ) ) {
$note = sprintf( __( 'Item %s variation #%s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $_product->variation_id, $new_stock + $stock_change, $new_stock );
} else {
$note = sprintf( __( 'Item %s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $new_stock + $stock_change, $new_stock );
}
$return[] = $note;
$order->add_order_note( $note );
$order->send_stock_notifications( $_product, $new_stock, $order_item_qty[ $item_id ] );
@ -1407,8 +1366,14 @@ class WC_AJAX {
$old_stock = $_product->get_stock_quantity();
$stock_change = apply_filters( 'woocommerce_restore_order_stock_quantity', $order_item_qty[ $item_id ], $item_id );
$new_quantity = $_product->increase_stock( $stock_change );
$item_name = $_product->get_sku() ? $_product->get_sku(): $order_item['product_id'];
$item_name = $_product->get_sku() ? $_product->get_sku() : $_product->id;
if ( ! empty( $_product->variation_id ) ) {
$note = sprintf( __( 'Item %s variation #%s stock increased from %s to %s.', 'woocommerce' ), $item_name, $_product->variation_id, $old_stock, $new_quantity );
} else {
$note = sprintf( __( 'Item %s stock increased from %s to %s.', 'woocommerce' ), $item_name, $old_stock, $new_quantity );
}
$return[] = $note;
$order->add_order_note( $note );
}
@ -2221,8 +2186,8 @@ class WC_AJAX {
if ( WC()->payment_gateways() ) {
$payment_gateways = WC()->payment_gateways->payment_gateways();
}
if ( isset( $payment_gateways[ $order->payment_method ] ) && $payment_gateways[ $order->payment_method ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->payment_method ]->process_refund( $order_id, $refund_amount, $refund_reason );
if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) {
$result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund_amount, $refund_reason );
do_action( 'woocommerce_refund_processed', $refund, $result );

View File

@ -110,10 +110,8 @@ class WC_API extends WC_Legacy_API {
* @since 2.6.0
*/
private function rest_api_init() {
global $wp_version;
// REST API was included starting WordPress 4.4.
if ( version_compare( $wp_version, 4.4, '<' ) ) {
if ( ! class_exists( 'WP_REST_Server' ) ) {
return;
}
@ -143,9 +141,11 @@ class WC_API extends WC_Legacy_API {
// Abstract controllers.
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-posts-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php' );
// REST API controllers.
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php' );
@ -165,10 +165,17 @@ class WC_API extends WC_Legacy_API {
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-reports-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-settings-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-settings-options-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zones-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-locations-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-methods-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-tax-classes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-taxes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhook-deliveries.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhooks-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-tools-controller.php' );
do_action( 'woocommerce_api_includes' );
}
/**
@ -179,7 +186,7 @@ class WC_API extends WC_Legacy_API {
// Register settings to the REST API.
$this->register_wp_admin_settings();
$controllers = array(
$controllers = apply_filters( 'woocommerce_api_controllers', array(
'WC_REST_Coupons_Controller',
'WC_REST_Customer_Downloads_Controller',
'WC_REST_Customers_Controller',
@ -198,11 +205,16 @@ class WC_API extends WC_Legacy_API {
'WC_REST_Reports_Controller',
'WC_REST_Settings_Controller',
'WC_REST_Settings_Options_Controller',
'WC_REST_Shipping_Zones_Controller',
'WC_REST_Shipping_Zone_Locations_Controller',
'WC_REST_Shipping_Zone_Methods_Controller',
'WC_REST_Tax_Classes_Controller',
'WC_REST_Taxes_Controller',
'WC_REST_Webhook_Deliveries_Controller',
'WC_REST_Webhooks_Controller',
);
'WC_REST_System_Status_Controller',
'WC_REST_System_Status_Tools_Controller',
) );
foreach ( $controllers as $controller ) {
$this->$controller = new $controller();

View File

@ -36,7 +36,7 @@ class WC_Background_Updater extends WP_Background_Process {
*/
public function dispatch() {
$dispatched = parent::dispatch();
$logger = new WC_Logger();
$logger = wc_get_logger();
if ( is_wp_error( $dispatched ) ) {
$logger->add( 'wc_db_updates', sprintf( 'Unable to dispatch WooCommerce updater: %s', $dispatched->get_error_message() ) );
@ -97,7 +97,7 @@ class WC_Background_Updater extends WP_Background_Process {
define( 'WC_UPDATING', true );
}
$logger = new WC_Logger();
$logger = wc_get_logger();
include_once( dirname( __FILE__ ) . '/wc-update-functions.php' );
@ -119,7 +119,7 @@ class WC_Background_Updater extends WP_Background_Process {
* performed, or, call parent::complete().
*/
protected function complete() {
$logger = new WC_Logger();
$logger = wc_get_logger();
$logger->add( 'wc_db_updates', 'Data update complete' );
WC_Install::update_db_version();
parent::complete();

View File

@ -74,7 +74,7 @@ class WC_Breadcrumb {
'is_tax'
);
if ( ( ! is_front_page() && ! ( is_post_type_archive() && get_option( 'page_on_front' ) == wc_get_page_id( 'shop' ) ) ) || is_paged() ) {
if ( ( ! is_front_page() && ! ( is_post_type_archive() && intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) ) || is_paged() ) {
foreach ( $conditionals as $conditional ) {
if ( call_user_func( $conditional ) ) {
call_user_func( array( $this, 'add_crumbs_' . substr( $conditional, 3 ) ) );

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