Merge branch 'master' into update/19302

This commit is contained in:
Mike Jolley 2018-04-03 14:57:24 +01:00
commit 7b45e90357
207 changed files with 7005 additions and 4627 deletions

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#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 .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#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;left:0;padding:10px 21px 10px 15px;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;right:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right: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;left:12px;position:absolute}
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .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 .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .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;left:0;padding:10px 21px 10px 15px;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;right:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right: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;left:12px;position:absolute}

View File

@ -1 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#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 .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#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 .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .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}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .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 .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .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 .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .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}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -807,6 +807,7 @@ table.wc_status_table--tools {
pre {
font-family: monospace;
white-space: pre-wrap;
word-wrap: break-word;
}
}
@ -2603,8 +2604,7 @@ table.wp-list-table {
}
span.wc-image,
span.wc-featured,
span.wc-type {
span.wc-featured {
@include ir();
margin: 0 auto;
@ -2627,11 +2627,6 @@ table.wp-list-table {
cursor: pointer;
}
span.wc-type::before {
font-family: 'WooCommerce';
content: '\e006';
}
span.product-type {
@include ir();
font-size: 1.6em;

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 0 0 1em}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:right;height:70px;margin:0 0 0 1em}.wc-auth-logged-in-as .wc-auth-logout{float:left}.wc-auth .wc-auth-actions{overflow:hidden;padding-right:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border-bottom-width:2px;border:1px solid #d7d7d7;box-sizing:border-box;color:#777;float:left;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;box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);color:#fff;float:left;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:left}.wc-auth .wc-auth-actions .wc-auth-deny{float:right;margin-right:-24px}
body{background:#f1f1f1;-webkit-box-shadow:none;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;-webkit-box-shadow:0 1px 3px rgba(0,0,0,.13);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{-webkit-box-sizing:border-box;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 0 0 1em}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:right;height:70px;margin:0 0 0 1em}.wc-auth-logged-in-as .wc-auth-logout{float:left}.wc-auth .wc-auth-actions{overflow:hidden;padding-right:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border-bottom-width:2px;border:1px solid #d7d7d7;-webkit-box-sizing:border-box;box-sizing:border-box;color:#777;float:left;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:left;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:left}.wc-auth .wc-auth-actions .wc-auth-deny{float:right;margin-right:-24px}

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-bottom-width:2px;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;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;-webkit-box-shadow:none;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;-webkit-box-shadow:0 1px 3px rgba(0,0,0,.13);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{-webkit-box-sizing:border-box;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-bottom-width:2px;border:1px solid #d7d7d7;-webkit-box-sizing:border-box;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

@ -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;text-align:center;float:right;font-size:.8em;border-right:1px solid #fff;border-left:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-right:0}ul.woocommerce_stats li:last-child{border-left:0}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:right;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;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:left;position:absolute;left:0;top:50%;margin-left: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;line-height:1;margin:0;text-indent:0;position:absolute;top:0;right:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:right;margin-left:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#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{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-left:1px solid #ececec}#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{border-left:1px solid #ececec}#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 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:right;margin:0 0 5px 10px}#woocommerce_dashboard_recent_reviews .star-rating{float:left;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-right:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b2b2;float:right;top:0;right:0;position:absolute;letter-spacing:.1em}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:right;top:0;right: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;right:0;letter-spacing:.1em;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:right;font-size:.8em;border-right:1px solid #fff;border-left:1px solid #ececec;-webkit-box-sizing:border-box;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-right:0}ul.woocommerce_stats li:last-child{border-left:0}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:right;padding:0;-webkit-box-sizing:border-box;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;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:left;position:absolute;left:0;top:50%;margin-left: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;line-height:1;margin:0;text-indent:0;position:absolute;top:0;right:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:right;margin-left:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#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{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-left:1px solid #ececec}#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{border-left:1px solid #ececec}#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 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:right;margin:0 0 5px 10px}#woocommerce_dashboard_recent_reviews .star-rating{float:left;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-right:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b2b2;float:right;top:0;right:0;position:absolute;letter-spacing:.1em}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:right;top:0;right: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;right:0;letter-spacing:.1em;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;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}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}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;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;line-height:1;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left;margin-right:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#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{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}#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{border-right:1px solid #ececec}#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 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:#b3b2b2;float:left;top:0;left:0;position:absolute;letter-spacing:.1em}#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;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;-webkit-box-sizing:border-box;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-left:0}ul.woocommerce_stats li:last-child{border-right:0}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;-webkit-box-sizing:border-box;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;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;line-height:1;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:left;margin-right:12px;margin-bottom:12px}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#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{width:100%}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-right:1px solid #ececec}#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{border-right:1px solid #ececec}#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 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:#b3b2b2;float:left;top:0;left:0;position:absolute;letter-spacing:.1em}#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;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
*{background:0 0!important;color:#000!important;text-shadow:none!important;-webkit-filter:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-right:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-right:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-right:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}
*{background:0 0!important;color:#000!important;text-shadow:none!important;-webkit-filter:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-right:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-right:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-right:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;-webkit-box-shadow:none!important;box-shadow:none!important;border-bottom:1px solid gray!important}

View File

@ -1 +1 @@
*{background:0 0!important;color:#000!important;text-shadow:none!important;-webkit-filter:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-left:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-left:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-left:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}
*{background:0 0!important;color:#000!important;text-shadow:none!important;-webkit-filter:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important;transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-left:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-left:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-left:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;-webkit-box-shadow:none!important;box-shadow:none!important;border-bottom:1px solid gray!important}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
* Twenty Seventeen integration styles
*/
@import 'mixins';
@import 'animation';
/**
* Fonts

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,16 @@ body {
max-width: 30%;
}
}
.wc-setup {
text-align: center;
.select2-container {
text-align: left;
}
.hidden {
display: none;
}
}
.wc-setup-content {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
padding: 2em;
@ -20,6 +30,7 @@ body {
background: #fff;
overflow: hidden;
zoom: 1;
text-align: left;
h1, h2, h3, table {
margin: 0 0 20px;
@ -297,7 +308,6 @@ body {
}
}
.woocommerce-newsletter,
.woocommerce-tracker,
.updated {
padding: 24px 24px 0;
margin: 0 0 24px;
@ -312,9 +322,74 @@ body {
margin: 0 0 24px;
}
}
.woocommerce-tracker + .woocommerce-newsletter {
margin-top: -24px;
border-top: 2px dashed #ddd;
.woocommerce-tracker {
margin: 24px 0;
border: 1px solid #eee;
padding: 20px;
border-radius: 4px;
overflow: hidden;
p {
font-size: 14px;
line-height: 1.5em;
}
.checkbox {
line-height: 24px;
font-weight: 500;
font-size: 1em;
margin-top: 0;
margin-bottom: 20px;
input[type="checkbox"] {
opacity: 0;
position: absolute;
left: -9999px;
}
label {
position: relative;
display: inline-block;
padding-left: 28px;
&:before,
&:after {
position: absolute;
content: "";
display: inline-block;
}
&:before {
height: 16px;
width: 16px;
left: 0px;
top: 3px;
border: 1px solid #aaa;
background-color: #fff;
border-radius: 3px;
}
&:after {
height: 5px;
width: 9px;
border-left: 2px solid;
border-bottom: 2px solid;
transform: rotate(-45deg);
left: 4px;
top: 7px;
color: #fff;
}
}
input[type="checkbox"] + label::after {
content: none;
}
input[type="checkbox"]:checked + label::after {
content: "";
}
input[type="checkbox"]:focus + label::before {
outline: rgb(59, 153, 252) auto 5px;
}
input[type="checkbox"]:checked + label::before {
background: #935687;
border-color: #935687;
outline: none;
}
}
}
}
.wc-setup-steps {
@ -417,8 +492,8 @@ body {
.wc-setup-footer-links {
font-size: 0.85em;
color: #b5b5b5;
margin: 1.18em 0;
display: block;
margin: 1.18em auto;
display: inline-block;
text-align: center;
}
@ -828,11 +903,21 @@ h3.jetpack-reasons {
font-size: 14px;
}
.jetpack-logo {
.jetpack-logo, .wcs-notice {
display: block;
margin: 1.75em auto 2em auto;
max-height: 175px;
}
.activate-splash {
.jetpack-logo {
width: 170px;
margin-bottom: 0;
}
.wcs-notice {
margin-top: 1em;
padding-left: 57px;
}
}
.step {
text-align: center;
@ -888,8 +973,6 @@ h3.jetpack-reasons {
}
.store-address-container {
margin-top: 4px;
.city-and-postcode {
display: flex;
@ -902,9 +985,11 @@ h3.jetpack-reasons {
}
}
}
}
.store-currency-container {
margin-top: 10px;
input[type="text"],
select,
.select2-container {
margin-bottom: 10px;
}
}
.product-type-container {
margin-top: 14px;
@ -1072,15 +1157,6 @@ p.jetpack-terms {
}
}
.allow-tracking {
color: #9f9f9f;
margin-top: 1em;
text-align: center;
font-size: 0.9em;
padding-top: 2em;
border-top: 1px solid #ccc;
}
.wc-wizard-service-setting-stripe_create_account, .wc-wizard-service-setting-ppec_paypal_reroute_requests {
display: flex;
align-items: flex-start;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -112,9 +112,6 @@ jQuery( function ( $ ) {
if ( ! $country_input.val() ) {
$country_input.val( woocommerce_admin_meta_boxes_order.default_country ).change();
}
if ( ! $state_input.val() ) {
$state_input.val( woocommerce_admin_meta_boxes_order.default_state ).change();
}

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,6 @@
/*global wc_setup_params */
/*global wc_setup_currencies */
/*global wc_base_state */
jQuery( function( $ ) {
function blockWizardUI() {
$('.wc-setup-content').block({
@ -21,6 +22,35 @@ jQuery( function( $ ) {
return true;
} );
$( '#store_country' ).on( 'change', function() {
// Prevent if we don't have the metabox data
if ( wc_setup_params.states === null ){
return;
}
var $this = $( this ),
country = $this.val(),
$state_select = $( '#store_state' );
if ( ! $.isEmptyObject( wc_setup_params.states[ country ] ) ) {
var states = wc_setup_params.states[ country ];
$state_select.empty();
$.each( states, function( index ) {
$state_select.append( $( '<option value="' + index + '">' + states[ index ] + '</option>' ) );
} );
$( '.store-state-container' ).show();
$state_select.selectWoo().val( wc_base_state ).change().prop( 'required', true );
} else {
$( '.store-state-container' ).hide();
$state_select.empty().val( '' ).change().prop( 'required', false );
}
} );
$( '#store_country' ).change();
$( '.wc-wizard-services' ).on( 'change', '.wc-wizard-service-enable input', function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( '.wc-wizard-service-toggle' ).removeClass( 'disabled' );
@ -142,8 +172,8 @@ jQuery( function( $ ) {
}
} ).find( 'input#stripe_create_account, input#ppec_paypal_reroute_requests' ).change();
$( 'select#store_country_state' ).on( 'change', function() {
var countryCode = this.value.split( ':' )[ 0 ];
$( 'select#store_country' ).on( 'change', function() {
var countryCode = $( this ).val();
$( 'select#currency_code' ).val( wc_setup_currencies[ countryCode ] ).change();
} );
} );

View File

@ -42,7 +42,7 @@
setTimeout( function() {
$form.trigger( 'check_variations' );
$form.trigger( 'wc_variation_form' );
$form.loading = loading;
$form.loading = false;
}, 100 );
};

File diff suppressed because one or more lines are too long

View File

@ -240,17 +240,20 @@ jQuery( function( $ ) {
if ( $slides.length > 0 ) {
$slides.each( function( i, el ) {
var img = $( el ).find( 'img' ),
large_image_src = img.attr( 'data-large_image' ),
large_image_w = img.attr( 'data-large_image_width' ),
large_image_h = img.attr( 'data-large_image_height' ),
item = {
src : large_image_src,
w : large_image_w,
h : large_image_h,
title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' )
};
items.push( item );
var img = $( el ).find( 'img' );
if ( img.length ) {
var large_image_src = img.attr( 'data-large_image' ),
large_image_w = img.attr( 'data-large_image_width' ),
large_image_h = img.attr( 'data-large_image_height' ),
item = {
src : large_image_src,
w : large_image_w,
h : large_image_h,
title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' )
};
items.push( item );
}
} );
}

View File

@ -5465,12 +5465,11 @@ S2.define('select2/core',[
$(document).on('keydown', function (evt) {
var key = evt.which;
if (self.isOpen()) {
if (key === KEYS.ESC || key === KEYS.TAB ||
(key === KEYS.UP && evt.altKey)) {
if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) {
self.close();
evt.preventDefault();
} else if (key === KEYS.ENTER) {
} else if (key === KEYS.ENTER || key === KEYS.TAB) {
self.trigger('results:select', {});
evt.preventDefault();

File diff suppressed because one or more lines are too long

View File

@ -5465,12 +5465,11 @@ S2.define('select2/core',[
$(document).on('keydown', function (evt) {
var key = evt.which;
if (self.isOpen()) {
if (key === KEYS.ESC || key === KEYS.TAB ||
(key === KEYS.UP && evt.altKey)) {
if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) {
self.close();
evt.preventDefault();
} else if (key === KEYS.ENTER) {
} else if (key === KEYS.ENTER || key === KEYS.TAB) {
self.trigger('results:select', {});
evt.preventDefault();

File diff suppressed because one or more lines are too long

View File

@ -1876,7 +1876,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return bool
*/
public function has_status( $status ) {
return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status ? true : false, $this, $status );
return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status, $this, $status );
}
/**

View File

@ -273,7 +273,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* @return bool
*/
public function has_fields() {
return $this->has_fields ? true : false;
return (bool) $this->has_fields;
}
/**
@ -385,7 +385,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* @since 1.5.7
*/
public function supports( $feature ) {
return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this );
return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
}
/**

View File

@ -1360,7 +1360,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @since 2.5.0
*/
public function supports( $feature ) {
return apply_filters( 'woocommerce_product_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this );
return apply_filters( 'woocommerce_product_supports', in_array( $feature, $this->supports ), $feature, $this );
}
/**
@ -1577,7 +1577,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
return true;
}
return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0 ? true : false;
return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0;
}
/**

View File

@ -43,7 +43,7 @@ abstract class WC_Background_Process extends WP_Background_Process {
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE {$column} LIKE %s", $key ) ); // @codingStandardsIgnoreLine.
return ( $count > 0 ) ? false : true;
return ! ( $count > 0 );
}
/**
@ -72,7 +72,7 @@ abstract class WC_Background_Process extends WP_Background_Process {
$batch = new stdClass();
$batch->key = $query->$column;
$batch->data = maybe_unserialize( $query->$value_column );
$batch->data = array_filter( (array) maybe_unserialize( $query->$value_column ) );
return $batch;
}

View File

@ -110,7 +110,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.3' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.4' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
wp_localize_script(
'wc-enhanced-select',

View File

@ -2,15 +2,10 @@
/**
* Init WooCommerce data importers.
*
* @author Automattic
* @category Admin
* @package WooCommerce/Admin
* @version 3.1.0
* @package WooCommerce/Admin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WC_Admin_Importers Class.
@ -111,7 +106,6 @@ class WC_Admin_Importers {
* The tax rate importer which extends WP_Importer.
*/
public function tax_rates_importer() {
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/import.php';
if ( ! class_exists( 'WP_Importer' ) ) {
@ -122,10 +116,8 @@ class WC_Admin_Importers {
}
}
// includes
require dirname( __FILE__ ) . '/importers/class-wc-tax-rate-importer.php';
// Dispatch
$importer = new WC_Tax_Rate_Importer();
$importer->dispatch();
}
@ -139,11 +131,11 @@ class WC_Admin_Importers {
public function post_importer_compatibility() {
global $wpdb;
if ( empty( $_POST['import_id'] ) || ! class_exists( 'WXR_Parser' ) ) {
if ( empty( $_POST['import_id'] ) || ! class_exists( 'WXR_Parser' ) ) { // PHPCS: input var ok, CSRF ok.
return;
}
$id = absint( $_POST['import_id'] );
$id = absint( $_POST['import_id'] ); // PHPCS: input var ok.
$file = get_attached_file( $id );
$parser = new WXR_Parser();
$import_data = $parser->parse( $file );
@ -156,8 +148,8 @@ class WC_Admin_Importers {
if ( ! taxonomy_exists( $term['domain'] ) ) {
$attribute_name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $term['domain'] ) );
// Create the taxonomy
if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies() ) ) {
// Create the taxonomy.
if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies(), true ) ) {
wc_create_attribute(
array(
'name' => $attribute_name,
@ -198,19 +190,19 @@ class WC_Admin_Importers {
check_ajax_referer( 'wc-product-import', 'security' );
if ( ! current_user_can( 'edit_products' ) || ! isset( $_POST['file'] ) ) {
if ( ! current_user_can( 'edit_products' ) || ! isset( $_POST['file'] ) ) { // PHPCS: input var ok.
wp_die( -1 );
}
include_once WC_ABSPATH . 'includes/admin/importers/class-wc-product-csv-importer-controller.php';
include_once WC_ABSPATH . 'includes/import/class-wc-product-csv-importer.php';
$file = wc_clean( $_POST['file'] );
$file = wc_clean( wp_unslash( $_POST['file'] ) ); // PHPCS: input var ok.
$params = array(
'delimiter' => ! empty( $_POST['delimiter'] ) ? wc_clean( $_POST['delimiter'] ) : ',',
'start_pos' => isset( $_POST['position'] ) ? absint( $_POST['position'] ) : 0,
'mapping' => isset( $_POST['mapping'] ) ? (array) $_POST['mapping'] : array(),
'update_existing' => isset( $_POST['update_existing'] ) ? (bool) $_POST['update_existing'] : false,
'delimiter' => ! empty( $_POST['delimiter'] ) ? wc_clean( wp_unslash( $_POST['delimiter'] ) ) : ',', // PHPCS: input var ok.
'start_pos' => isset( $_POST['position'] ) ? absint( $_POST['position'] ) : 0, // PHPCS: input var ok.
'mapping' => isset( $_POST['mapping'] ) ? (array) wc_clean( wp_unslash( $_POST['mapping'] ) ) : array(), // PHPCS: input var ok.
'update_existing' => isset( $_POST['update_existing'] ) ? (bool) $_POST['update_existing'] : false, // PHPCS: input var ok.
'lines' => apply_filters( 'woocommerce_product_import_batch_size', 30 ),
'parse' => true,
);
@ -231,7 +223,7 @@ class WC_Admin_Importers {
if ( 100 === $percent_complete ) {
// Clear temp meta.
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) );
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) ); // @codingStandardsIgnoreLine.
$wpdb->query(
"DELETE {$wpdb->posts}, {$wpdb->postmeta}, {$wpdb->term_relationships}
FROM {$wpdb->posts}
@ -243,6 +235,14 @@ class WC_Admin_Importers {
AND {$wpdb->posts}.post_status = 'importing'"
);
// Clear orphan variations.
$wpdb->query(
"DELETE products
FROM {$wpdb->posts} products
LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent
WHERE wp.ID IS NULL AND products.post_type = 'product_variation';"
);
// Send success.
wp_send_json_success(
array(

View File

@ -171,12 +171,6 @@ class WC_Admin_Setup_Wizard {
unset( $default_steps['shipping'] );
}
// Hide the activate step if Jetpack is already active, but not
// if we're returning from connecting Jetpack on WordPress.com.
if ( class_exists( 'Jetpack' ) && Jetpack::is_active() && ! isset( $_GET['from'] ) && ! isset( $_GET['activate_error'] ) ) { // WPCS: CSRF ok, input var ok.
unset( $default_steps['activate'] );
}
// Whether or not there is a pending background install of Jetpack.
$pending_jetpack = ! class_exists( 'Jetpack' ) && get_option( 'woocommerce_setup_background_installing_jetpack' );
@ -215,6 +209,7 @@ class WC_Admin_Setup_Wizard {
'wc_setup_params',
array(
'pending_jetpack_install' => $pending_jetpack ? 'yes' : 'no',
'states' => WC()->countries->get_states(),
)
);
@ -298,21 +293,38 @@ class WC_Admin_Setup_Wizard {
* Output the steps.
*/
public function setup_wizard_steps() {
$output_steps = $this->steps;
$selected_features = array_filter( $this->wc_setup_activate_get_feature_list() );
// Hide the activate step if Jetpack is already active, unless WooCommerce Services
// features are selected, or unless the Activate step was already taken.
if ( class_exists( 'Jetpack' ) && Jetpack::is_active() && empty( $selected_features ) && 'yes' !== get_transient( 'wc_setup_activated' ) ) {
unset( $output_steps['activate'] );
}
?>
<ol class="wc-setup-steps">
<?php foreach ( $this->steps as $step_key => $step ) :
<?php
foreach ( $output_steps as $step_key => $step ) {
$is_completed = array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true );
if ( $step_key === $this->step ) : ?>
if ( $step_key === $this->step ) {
?>
<li class="active"><?php echo esc_html( $step['name'] ); ?></li>
<?php elseif ( $is_completed ) : ?>
<?php
} elseif ( $is_completed ) {
?>
<li class="done">
<a href="<?php echo esc_url( add_query_arg( 'step', $step_key, remove_query_arg( 'activate_error' ) ) ) ?>"><?php echo esc_html( $step['name'] ); ?></a>
<a href="<?php echo esc_url( add_query_arg( 'step', $step_key, remove_query_arg( 'activate_error' ) ) ); ?>"><?php echo esc_html( $step['name'] ); ?></a>
</li>
<?php else : ?>
<?php
} else {
?>
<li><?php echo esc_html( $step['name'] ); ?></li>
<?php endif; ?>
<?php endforeach; ?>
<?php
}
}
?>
</ol>
<?php
}
@ -347,8 +359,6 @@ class WC_Admin_Setup_Wizard {
$user_location = WC_Geolocation::geolocate_ip();
$country = $user_location['country'];
$state = $user_location['state'];
} elseif ( empty( $state ) ) {
$state = '*';
}
$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';
@ -357,75 +367,44 @@ class WC_Admin_Setup_Wizard {
<form method="post" class="address-step">
<?php wp_nonce_field( 'wc-setup' ); ?>
<p class="store-setup"><?php esc_html_e( 'The following wizard will help you configure your store and get you started quickly.', 'woocommerce' ); ?></p>
<label for="store_country_state" class="location-prompt">
<?php esc_html_e( 'Where is your store based?', 'woocommerce' ); ?>
</label>
<select
id="store_country_state"
name="store_country_state"
required
data-placeholder="<?php esc_attr_e( 'Choose a country&hellip;', 'woocommerce' ); ?>"
aria-label="<?php esc_attr_e( 'Country', 'woocommerce' ); ?>"
class="location-input wc-enhanced-select dropdown"
>
<?php WC()->countries->country_dropdown_options( $country, $state ); ?>
</select>
<div class="store-address-container">
<label class="location-prompt" for="store_address">
<?php esc_html_e( 'Address', 'woocommerce' ); ?>
</label>
<input
type="text"
id="store_address"
class="location-input"
name="store_address"
required
value="<?php echo esc_attr( $address ); ?>"
/>
<label class="location-prompt" for="store_address_2">
<?php esc_html_e( 'Address line 2', 'woocommerce' ); ?>
</label>
<input
type="text"
id="store_address_2"
class="location-input"
name="store_address_2"
value="<?php echo esc_attr( $address_2 ); ?>"
/>
<div class="city-and-postcode">
<div>
<label class="location-prompt" for="store_city">
<?php esc_html_e( 'City', 'woocommerce' ); ?>
<label for="store_country" class="location-prompt"><?php esc_html_e( 'Where is your store based?', 'woocommerce' ); ?></label>
<select id="store_country" name="store_country" required data-placeholder="<?php esc_attr_e( 'Choose a country&hellip;', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'woocommerce' ); ?>" class="location-input wc-enhanced-select dropdown">
<?php foreach ( WC()->countries->get_countries() as $code => $label ) : ?>
<option <?php selected( $code, $country ); ?> value="<?php echo esc_attr( $code ); ?>"><?php echo esc_html( $label ); ?></option>
<?php endforeach; ?>
</select>
<label class="location-prompt" for="store_address"><?php esc_html_e( 'Address', 'woocommerce' ); ?></label>
<input type="text" id="store_address" class="location-input" name="store_address" required value="<?php echo esc_attr( $address ); ?>" />
<label class="location-prompt" for="store_address_2"><?php esc_html_e( 'Address line 2', 'woocommerce' ); ?></label>
<input type="text" id="store_address_2" class="location-input" name="store_address_2" value="<?php echo esc_attr( $address_2 ); ?>" />
<div class="store-state-container hidden">
<label for="store_state" class="location-prompt">
<?php esc_html_e( 'State', 'woocommerce' ); ?>
</label>
<input
type="text"
id="store_city"
class="location-input"
name="store_city"
required
value="<?php echo esc_attr( $city ); ?>"
/>
<select id="store_state" name="store_state" data-placeholder="<?php esc_attr_e( 'Choose a state&hellip;', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'State', 'woocommerce' ); ?>" class="location-input wc-enhanced-select dropdown"></select>
</div>
<div>
<label class="location-prompt" for="store_postcode">
<?php esc_html_e( 'Postcode / ZIP', 'woocommerce' ); ?>
</label>
<input
type="text"
id="store_postcode"
class="location-input"
name="store_postcode"
required
value="<?php echo esc_attr( $postcode ); ?>"
/>
<div class="city-and-postcode">
<div>
<label class="location-prompt" for="store_city"><?php esc_html_e( 'City', 'woocommerce' ); ?></label>
<input type="text" id="store_city" class="location-input" name="store_city" required value="<?php echo esc_attr( $city ); ?>" />
</div>
<div>
<label class="location-prompt" for="store_postcode"><?php esc_html_e( 'Postcode / ZIP', 'woocommerce' ); ?></label>
<input type="text" id="store_postcode" class="location-input" name="store_postcode" required value="<?php echo esc_attr( $postcode ); ?>" />
</div>
</div>
</div>
</div>
<div class="store-currency-container">
<label class="location-prompt" for="currency_code">
<?php esc_html_e( 'What currency do you use?', 'woocommerce' ); ?>
<?php esc_html_e( 'What currency do you accept payments in?', 'woocommerce' ); ?>
</label>
<select
id="currency_code"
@ -438,27 +417,30 @@ class WC_Admin_Setup_Wizard {
<?php foreach ( get_woocommerce_currencies() as $code => $name ) : ?>
<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $currency, $code ); ?>>
<?php
$symbol = get_woocommerce_currency_symbol( $code );
if ( $symbol === $code ) {
/* translators: 1: currency name 2: currency code */
echo esc_html( sprintf( __( '%1$s (%2$s)', 'woocommerce' ), $name, get_woocommerce_currency_symbol( $code ) ) );
echo esc_html( sprintf( __( '%1$s (%2$s)', 'woocommerce' ), $name, $code ) );
} else {
/* translators: 1: currency name 2: currency symbol, 3: currency code */
echo esc_html( sprintf( __( '%1$s (%2$s / %3$s)', 'woocommerce' ), $name, get_woocommerce_currency_symbol( $code ), $code ) );
}
?>
</option>
<?php endforeach; ?>
</select>
<script type="text/javascript">
var wc_setup_currencies = <?php echo wp_json_encode( $currency_by_country ); ?>;
var wc_base_state = "<?php echo esc_js( $state ); ?>";
</script>
</div>
<div class="product-type-container">
<label class="location-prompt" for="product_type">
<?php esc_html_e( 'What type of product do you plan to sell?', 'woocommerce' ); ?>
<?php esc_html_e( 'What type of products do you plan to sell?', 'woocommerce' ); ?>
</label>
<select
id="product_type"
name="product_type"
required
class="location-input wc-enhanced-select dropdown"
>
<select id="product_type" name="product_type" required class="location-input wc-enhanced-select dropdown">
<option value="both" <?php selected( $product_type, 'both' ); ?>><?php esc_html_e( 'I plan to sell both physical and digital products', 'woocommerce' ); ?></option>
<option value="physical" <?php selected( $product_type, 'physical' ); ?>><?php esc_html_e( 'I plan to sell physical products', 'woocommerce' ); ?></option>
<option value="virtual" <?php selected( $product_type, 'virtual' ); ?>><?php esc_html_e( 'I plan to sell digital products', 'woocommerce' ); ?></option>
@ -476,12 +458,24 @@ class WC_Admin_Setup_Wizard {
<?php esc_html_e( 'I will also be selling products or services in person.', 'woocommerce' ); ?>
</label>
<?php if ( 'unknown' === get_option( 'woocommerce_allow_tracking', 'unknown' ) ) : ?>
<div class="allow-tracking">
<input type="checkbox" id="wc_tracker_optin" name="wc_tracker_optin" value="yes" checked />
<label for="wc_tracker_optin"><?php esc_html_e( 'Allow WooCommerce to collect non-sensitive diagnostic data and usage information.', 'woocommerce' ); ?></label>
<?php
if ( 'unknown' === get_option( 'woocommerce_allow_tracking', 'unknown' ) ) {
?>
<div class="woocommerce-tracker">
<p class="checkbox">
<input type="checkbox" id="wc_tracker_checkbox" name="wc_tracker_checkbox" value="yes" checked />
<label for="wc_tracker_checkbox"><?php esc_html_e( 'Help WooCommerce improve with usage tracking.', 'woocommerce' ); ?></label>
</p>
<p>
<?php
esc_html_e( 'Gathering usage data allows us to make WooCommerce better &mdash; your store will be considered as we evaluate new features, judge the quality of an update, or determine if an improvement makes sense. If you would rather opt-out, and do not check this box, we will not know this store exists and we will not collect any usage data.', 'woocommerce' );
echo ' <a target="_blank" href="https://woocommerce.com/usage-tracking/">' . esc_html__( 'Read more about what we collect.', 'woocommerce' ) . '</a>';
?>
</p>
</div>
<?php endif; ?>
<?php
}
?>
<p class="wc-setup-actions step">
<button type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( "Let's go!", 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( "Let's go!", 'woocommerce' ); ?></button>
</p>
@ -498,24 +492,29 @@ class WC_Admin_Setup_Wizard {
$address = sanitize_text_field( $_POST['store_address'] );
$address_2 = sanitize_text_field( $_POST['store_address_2'] );
$city = sanitize_text_field( $_POST['store_city'] );
$country_state = sanitize_text_field( $_POST['store_country_state'] );
$country = sanitize_text_field( $_POST['store_country'] );
$state = sanitize_text_field( $_POST['store_state'] );
$postcode = sanitize_text_field( $_POST['store_postcode'] );
$currency_code = sanitize_text_field( $_POST['currency_code'] );
$product_type = sanitize_text_field( $_POST['product_type'] );
$sell_in_person = isset( $_POST['sell_in_person'] ) && ( 'yes' === sanitize_text_field( $_POST['sell_in_person'] ) );
$tracking = isset( $_POST['wc_tracker_optin'] ) && ( 'yes' === sanitize_text_field( $_POST['wc_tracker_optin'] ) );
$tracking = isset( $_POST['wc_tracker_checkbox'] ) && ( 'yes' === sanitize_text_field( $_POST['wc_tracker_checkbox'] ) );
// @codingStandardsIgnoreEnd
if ( ! $state ) {
$state = '*';
}
update_option( 'woocommerce_store_address', $address );
update_option( 'woocommerce_store_address_2', $address_2 );
update_option( 'woocommerce_store_city', $city );
update_option( 'woocommerce_default_country', $country_state );
update_option( 'woocommerce_default_country', $country . ':' . $state );
update_option( 'woocommerce_store_postcode', $postcode );
update_option( 'woocommerce_currency', $currency_code );
update_option( 'woocommerce_product_type', $product_type );
update_option( 'woocommerce_sell_in_person', $sell_in_person );
$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';
$country = WC()->countries->get_base_country();
// Set currency formatting options based on chosen location and currency.
if (
@ -1675,8 +1674,9 @@ class WC_Admin_Setup_Wizard {
}
}
protected function wc_setup_activate_get_description() {
$description = false;
protected function wc_setup_activate_get_feature_list() {
$features = array();
$stripe_settings = get_option( 'woocommerce_stripe_settings', false );
$stripe_enabled = is_array( $stripe_settings )
&& isset( $stripe_settings['create_account'] ) && 'yes' === $stripe_settings['create_account']
@ -1685,32 +1685,35 @@ class WC_Admin_Setup_Wizard {
$ppec_enabled = is_array( $ppec_settings )
&& isset( $ppec_settings['reroute_requests'] ) && 'yes' === $ppec_settings['reroute_requests']
&& isset( $ppec_settings['enabled'] ) && 'yes' === $ppec_settings['enabled'];
$payment_enabled = $stripe_enabled || $ppec_enabled;
$taxes_enabled = (bool) get_option( 'woocommerce_setup_automated_taxes', false );
$features['payment'] = $stripe_enabled || $ppec_enabled;
$features['taxes'] = (bool) get_option( 'woocommerce_setup_automated_taxes', false );
$domestic_rates = (bool) get_option( 'woocommerce_setup_domestic_live_rates_zone', false );
$intl_rates = (bool) get_option( 'woocommerce_setup_intl_live_rates_zone', false );
$rates_enabled = $domestic_rates || $intl_rates;
$features['rates'] = $domestic_rates || $intl_rates;
/* translators: %s: list of features, potentially comma separated */
$description_base = __( 'Your store is almost ready! To activate services like %s, just connect with Jetpack.', 'woocommerce' );
return $features;
}
if ( $payment_enabled && $taxes_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'payment setup, automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $payment_enabled && $taxes_enabled ) {
$description = sprintf( $description_base, __( 'payment setup and automated taxes', 'woocommerce' ) );
} else if ( $payment_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'payment setup, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $payment_enabled ) {
$description = sprintf( $description_base, __( 'payment setup', 'woocommerce' ) );
} else if ( $taxes_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $taxes_enabled ) {
$description = sprintf( $description_base, __( 'automated taxes', 'woocommerce' ) );
} else if ( $rates_enabled ) {
$description = sprintf( $description_base, __( 'live rates and discounted shipping labels', 'woocommerce' ) );
protected function wc_setup_activate_get_feature_list_str() {
$features = $this->wc_setup_activate_get_feature_list();
if ( $features['payment'] && $features['taxes'] && $features['rates'] ) {
return __( 'payment setup, automated taxes, live rates and discounted shipping labels', 'woocommerce' );
} else if ( $features['payment'] && $features['taxes'] ) {
return __( 'payment setup and automated taxes', 'woocommerce' );
} else if ( $features['payment'] && $features['rates'] ) {
return __( 'payment setup, live rates and discounted shipping labels', 'woocommerce' );
} else if ( $features['payment'] ) {
return __( 'payment setup', 'woocommerce' );
} else if ( $features['taxes'] && $features['rates'] ) {
return __( 'automated taxes, live rates and discounted shipping labels', 'woocommerce' );
} else if ( $features['taxes'] ) {
return __( 'automated taxes', 'woocommerce' );
} else if ( $features['rates'] ) {
return __( 'live rates and discounted shipping labels', 'woocommerce' );
}
return $description;
return false;
}
/**
@ -1719,6 +1722,8 @@ class WC_Admin_Setup_Wizard {
public function wc_setup_activate() {
$this->wc_setup_activate_actions();
$jetpack_connected = class_exists( 'Jetpack' ) && Jetpack::is_active();
$has_jetpack_error = false;
if ( isset( $_GET['activate_error'] ) ) {
$has_jetpack_error = true;
@ -1728,19 +1733,57 @@ class WC_Admin_Setup_Wizard {
$error_message = $this->get_activate_error_message( sanitize_text_field( wp_unslash( $_GET['activate_error'] ) ) );
$description = $error_message;
} else {
$description = $this->wc_setup_activate_get_description();
$title = $description ?
__( 'Connect your store to Jetpack', 'woocommerce' ) :
__( 'Connect your store to Jetpack to enable extra features', 'woocommerce' );
$feature_list = $this->wc_setup_activate_get_feature_list_str();
$description = false;
if ( $feature_list ) {
if ( ! $jetpack_connected ) {
/* translators: %s: list of features, potentially comma separated */
$description_base = __( 'Your store is almost ready! To activate services like %s, just connect with Jetpack.', 'woocommerce' );
} else {
$description_base = __( 'Thanks for using Jetpack! Your store is almost ready: to activate services like %s, just connect your store.', 'woocommerce' );
}
$description = sprintf( $description_base, $feature_list );
}
if ( ! $jetpack_connected ) {
$title = $feature_list ?
__( 'Connect your store to Jetpack', 'woocommerce' ) :
__( 'Connect your store to Jetpack to enable extra features', 'woocommerce' );
$button_text = __( 'Continue with Jetpack', 'woocommerce' );
} elseif ( $feature_list ) {
$title = __( 'Connect your store to activate WooCommerce Services', 'woocommerce' );
$button_text = __( 'Continue with WooCommerce Services', 'woocommerce' );
} else {
wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit;
}
}
?>
<h1><?php echo esc_html( $title ); ?></h1>
<p><?php echo esc_html( $description ); ?></p>
<img
class="jetpack-logo"
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_vertical_logo.png' ); ?>"
alt="Jetpack logo"
/>
<?php if ( $jetpack_connected ) : ?>
<div class="activate-splash">
<img
class="jetpack-logo"
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_horizontal_logo.png' ); ?>"
alt="Jetpack logo"
/>
<img
class="wcs-notice"
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/wcs-notice.png' ); ?>"
/>
</div>
<?php else : ?>
<img
class="jetpack-logo"
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_vertical_logo.png' ); ?>"
alt="Jetpack logo"
/>
<?php endif; ?>
<?php if ( $has_jetpack_error ) : ?>
<p class="wc-setup-actions step">
<a
@ -1762,53 +1805,55 @@ class WC_Admin_Setup_Wizard {
</p>
<form method="post" class="activate-jetpack">
<p class="wc-setup-actions step">
<button type="submit" class="button-primary button button-large" value="<?php esc_attr_e( 'Connect with Jetpack', 'woocommerce' ); ?>"><?php esc_html_e( 'Continue with Jetpack', 'woocommerce' ); ?></button>
<button type="submit" class="button-primary button button-large" value="<?php echo esc_attr( $button_text ); ?>"><?php echo esc_html( $button_text ); ?></button>
</p>
<input type="hidden" name="save_step" value="activate" />
<?php wp_nonce_field( 'wc-setup' ); ?>
</form>
<h3 class="jetpack-reasons">
<?php
echo esc_html( $description ?
__( "Bonus reasons you'll love Jetpack", 'woocommerce' ) :
__( "Reasons you'll love Jetpack", 'woocommerce' )
);
?>
</h3>
<ul class="wc-wizard-features">
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Better security', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( 'Protect your store from unauthorized access.', 'woocommerce' ); ?>
</p>
</li>
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Store stats', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( 'Get insights on how your store is doing, including total sales, top products, and more.', 'woocommerce' ); ?>
</p>
</li>
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Store monitoring', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( 'Get an alert if your store is down for even a few minutes.', 'woocommerce' ); ?>
</p>
</li>
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Product promotion', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( "Share new items on social media the moment they're live in your store.", 'woocommerce' ); ?>
</p>
</li>
</ul>
<?php if ( ! $jetpack_connected ) : ?>
<h3 class="jetpack-reasons">
<?php
echo esc_html( $description ?
__( "Bonus reasons you'll love Jetpack", 'woocommerce' ) :
__( "Reasons you'll love Jetpack", 'woocommerce' )
);
?>
</h3>
<ul class="wc-wizard-features">
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Better security', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( 'Protect your store from unauthorized access.', 'woocommerce' ); ?>
</p>
</li>
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Store stats', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( 'Get insights on how your store is doing, including total sales, top products, and more.', 'woocommerce' ); ?>
</p>
</li>
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Store monitoring', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( 'Get an alert if your store is down for even a few minutes.', 'woocommerce' ); ?>
</p>
</li>
<li class="wc-wizard-feature-item">
<p class="wc-wizard-feature-name">
<strong><?php esc_html_e( 'Product promotion', 'woocommerce' ); ?></strong>
</p>
<p class="wc-wizard-feature-description">
<?php esc_html_e( "Share new items on social media the moment they're live in your store.", 'woocommerce' ); ?>
</p>
</li>
</ul>
<?php endif; ?>
<?php endif; ?>
<?php
}
@ -1835,9 +1880,16 @@ class WC_Admin_Setup_Wizard {
public function wc_setup_activate_save() {
check_admin_referer( 'wc-setup' );
set_transient( 'wc_setup_activated', 'yes', MINUTE_IN_SECONDS * 10 );
// Leave a note for WooCommerce Services that Jetpack has been opted into.
update_option( 'woocommerce_setup_jetpack_opted_in', true );
if ( class_exists( 'Jetpack' ) && Jetpack::is_active() ) {
wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit;
}
WC_Install::background_installer( 'jetpack', array(
'file' => 'jetpack/jetpack.php',
'name' => __( 'Jetpack', 'woocommerce' ),

View File

@ -118,7 +118,6 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
$show_columns['product_cat'] = __( 'Categories', 'woocommerce' );
$show_columns['product_tag'] = __( 'Tags', 'woocommerce' );
$show_columns['featured'] = '<span class="wc-featured parent-tips" data-tip="' . esc_attr__( 'Featured', 'woocommerce' ) . '">' . __( 'Featured', 'woocommerce' ) . '</span>';
$show_columns['product_type'] = '<span class="wc-type parent-tips" data-tip="' . esc_attr__( 'Type', 'woocommerce' ) . '">' . __( 'Type', 'woocommerce' ) . '</span>';
$show_columns['date'] = __( 'Date', 'woocommerce' );
return array_merge( $show_columns, $columns );
@ -199,31 +198,6 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
echo $this->object->get_sku() ? esc_html( $this->object->get_sku() ) : '<span class="na">&ndash;</span>';
}
/**
* Render columm: product_type.
*/
protected function render_product_type_column() {
if ( $this->object->is_type( 'grouped' ) ) {
echo '<span class="product-type tips grouped" data-tip="' . esc_attr__( 'Grouped', 'woocommerce' ) . '"></span>';
} elseif ( $this->object->is_type( 'external' ) ) {
echo '<span class="product-type tips external" data-tip="' . esc_attr__( 'External/Affiliate', 'woocommerce' ) . '"></span>';
} elseif ( $this->object->is_type( 'simple' ) ) {
if ( $this->object->is_virtual() ) {
echo '<span class="product-type tips virtual" data-tip="' . esc_attr__( 'Virtual', 'woocommerce' ) . '"></span>';
} elseif ( $this->object->is_downloadable() ) {
echo '<span class="product-type tips downloadable" data-tip="' . esc_attr__( 'Downloadable', 'woocommerce' ) . '"></span>';
} else {
echo '<span class="product-type tips simple" data-tip="' . esc_attr__( 'Simple', 'woocommerce' ) . '"></span>';
}
} elseif ( $this->object->is_type( 'variable' ) ) {
echo '<span class="product-type tips variable" data-tip="' . esc_attr__( 'Variable', 'woocommerce' ) . '"></span>';
} else {
// Assuming that we have other types in future.
echo '<span class="product-type tips ' . esc_attr( sanitize_html_class( $this->object->get_type() ) ) . '" data-tip="' . esc_attr( ucfirst( $this->object->get_type() ) ) . '"></span>';
}
}
/**
* Render columm: price.
*/
@ -454,10 +428,9 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
// Search using CRUD.
if ( ! empty( $query_vars['s'] ) ) {
$data_store = WC_Data_Store::load( 'product' );
$ids = $data_store->search_products( wc_clean( $query_vars['s'] ), '', true, true );
$query_vars['post__in'] = array_merge( $ids, array( 0 ) );
// So we know we are searching products.
$data_store = WC_Data_Store::load( 'product' );
$ids = $data_store->search_products( wc_clean( wp_unslash( $query_vars['s'] ) ), '', true, true );
$query_vars['post__in'] = array_merge( $ids, array( 0 ) );
$query_vars['product_search'] = true;
unset( $query_vars['s'] );
}

View File

@ -360,6 +360,15 @@ class WC_Meta_Box_Order_Data {
if ( ! isset( $field['id'] ) ) {
$field['id'] = '_billing_' . $key;
}
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
}
switch ( $field['type'] ) {
case 'select':
woocommerce_wp_select( $field );
@ -462,6 +471,14 @@ class WC_Meta_Box_Order_Data {
$field['id'] = '_shipping_' . $key;
}
$field_name = 'shipping_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
}
switch ( $field['type'] ) {
case 'select':
woocommerce_wp_select( $field );

View File

@ -63,7 +63,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
echo '<small class="times">&times;</small> ' . esc_html( $item->get_quantity() );
if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) {
echo '<small class="refunded">' . ( $refunded_qty * -1 ) . '</small>';
echo '<small class="refunded">-' . ( $refunded_qty * -1 ) . '</small>';
}
?>
</div>
@ -84,7 +84,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
}
if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>
@ -130,7 +130,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
}
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>

View File

@ -48,6 +48,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="clear"></div>
</div>
<?php do_action( 'woocommerce_variable_product_before_variations' ); ?>
<div class="toolbar toolbar-top">
<select id="field_to_edit" class="variation_actions">
<option data-global="true" value="add_variation"><?php esc_html_e( 'Add variation', 'woocommerce' ); ?></option>

View File

@ -332,8 +332,13 @@ class WC_Admin_Report {
}
if ( $debug || $nocache || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
// Enable big selects for reports
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
static $big_selects = false;
// Enable big selects for reports, just once for this session
if ( ! $big_selects ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$big_selects = true;
}
$cached_results[ $query_hash ] = apply_filters( 'woocommerce_reports_get_order_report_data', $wpdb->$query_type( $query ), $data );
set_transient( strtolower( get_class( $this ) ), $cached_results, DAY_IN_SECONDS );
}

View File

@ -1,394 +1,393 @@
<?php
<?php // @codingStandardsIgnoreLine.
/**
* WooCommerce Shipping Settings
* WooCommerce Checkout Settings
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
defined( 'ABSPATH' ) || exit;
if ( class_exists( 'WC_Settings_Payment_Gateways', false ) ) {
return new WC_Settings_Payment_Gateways();
}
if ( ! class_exists( 'WC_Settings_Payment_Gateways', false ) ) :
/**
* WC_Settings_Payment_Gateways.
*/
class WC_Settings_Payment_Gateways extends WC_Settings_Page {
/**
* WC_Settings_Payment_Gateways.
* Constructor.
*/
class WC_Settings_Payment_Gateways extends WC_Settings_Page {
public function __construct() {
$this->id = 'checkout';
$this->label = _x( 'Checkout', 'Settings tab label', 'woocommerce' );
/**
* Constructor.
*/
public function __construct() {
$this->id = 'checkout';
$this->label = _x( 'Checkout', 'Settings tab label', 'woocommerce' );
add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) );
parent::__construct();
}
add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) );
parent::__construct();
}
/**
* Get sections.
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __( 'Checkout options', 'woocommerce' ),
);
/**
* Get sections.
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __( 'Checkout options', 'woocommerce' ),
);
if ( ! defined( 'WC_INSTALLING' ) ) {
$payment_gateways = WC()->payment_gateways->payment_gateways();
foreach ( $payment_gateways as $gateway ) {
$title = empty( $gateway->method_title ) ? ucfirst( $gateway->id ) : $gateway->method_title;
$sections[ strtolower( $gateway->id ) ] = esc_html( $title );
}
}
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
}
/**
* Get settings array.
*
* @param string $current_section
*
* @return array
*/
public function get_settings( $current_section = '' ) {
$settings = array();
if ( '' === $current_section ) {
$settings = apply_filters(
'woocommerce_payment_gateways_settings', array(
array(
'title' => __( 'Checkout process', 'woocommerce' ),
'type' => 'title',
'id' => 'checkout_process_options',
),
array(
'title' => __( 'Coupons', 'woocommerce' ),
'desc' => __( 'Enable the use of coupons', 'woocommerce' ),
'id' => 'woocommerce_enable_coupons',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
),
array(
'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
'id' => 'woocommerce_calc_discounts_sequentially',
'default' => 'no',
'type' => 'checkbox',
'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ),
'checkboxgroup' => 'end',
'autoload' => false,
),
array(
'title' => __( 'Checkout process', 'woocommerce' ),
'desc' => __( 'Enable guest checkout', 'woocommerce' ),
'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'woocommerce' ),
'id' => 'woocommerce_enable_guest_checkout',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'autoload' => false,
),
array(
'desc' => __( 'Force secure checkout', 'woocommerce' ),
'id' => 'woocommerce_force_ssl_checkout',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
'show_if_checked' => 'option',
'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (<a href="%s" target="_blank">an SSL Certificate is required</a>).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ),
),
'unforce_ssl_checkout' => array(
'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ),
'id' => 'woocommerce_unforce_ssl_checkout',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'show_if_checked' => 'yes',
),
array(
'type' => 'sectionend',
'id' => 'checkout_process_options',
),
array(
'title' => __( 'Checkout pages', 'woocommerce' ),
'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ),
'type' => 'title',
'id' => 'checkout_page_options',
),
array(
'title' => __( 'Cart page', 'woocommerce' ),
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ),
'id' => 'woocommerce_cart_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'css' => 'min-width:300px;',
'desc_tip' => true,
),
array(
'title' => __( 'Checkout page', 'woocommerce' ),
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ),
'id' => 'woocommerce_checkout_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'css' => 'min-width:300px;',
'desc_tip' => true,
),
array(
'title' => __( 'Terms and conditions', 'woocommerce' ),
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ),
'id' => 'woocommerce_terms_page_id',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'css' => 'min-width:300px;',
'type' => 'single_select_page',
'args' => array( 'exclude' => wc_get_page_id( 'checkout' ) ),
'desc_tip' => true,
'autoload' => false,
),
array(
'type' => 'sectionend',
'id' => 'checkout_page_options',
),
array(
'title' => __( 'Checkout endpoints', 'woocommerce' ),
'type' => 'title',
'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ),
'id' => 'account_endpoint_options',
),
array(
'title' => __( 'Pay', 'woocommerce' ),
'desc' => __( 'Endpoint for the "Checkout &rarr; Pay" page.', 'woocommerce' ),
'id' => 'woocommerce_checkout_pay_endpoint',
'type' => 'text',
'default' => 'order-pay',
'desc_tip' => true,
),
array(
'title' => __( 'Order received', 'woocommerce' ),
'desc' => __( 'Endpoint for the "Checkout &rarr; Order received" page.', 'woocommerce' ),
'id' => 'woocommerce_checkout_order_received_endpoint',
'type' => 'text',
'default' => 'order-received',
'desc_tip' => true,
),
array(
'title' => __( 'Add payment method', 'woocommerce' ),
'desc' => __( 'Endpoint for the "Checkout &rarr; Add payment method" page.', 'woocommerce' ),
'id' => 'woocommerce_myaccount_add_payment_method_endpoint',
'type' => 'text',
'default' => 'add-payment-method',
'desc_tip' => true,
),
array(
'title' => __( 'Delete payment method', 'woocommerce' ),
'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ),
'id' => 'woocommerce_myaccount_delete_payment_method_endpoint',
'type' => 'text',
'default' => 'delete-payment-method',
'desc_tip' => true,
),
array(
'title' => __( 'Set default payment method', 'woocommerce' ),
'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ),
'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint',
'type' => 'text',
'default' => 'set-default-payment-method',
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'checkout_endpoint_options',
),
array(
'title' => __( 'Payment gateways', 'woocommerce' ),
'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ),
'type' => 'title',
'id' => 'payment_gateways_options',
),
array(
'type' => 'payment_gateways',
),
array(
'type' => 'sectionend',
'id' => 'payment_gateways_options',
),
)
);
if ( wc_site_is_https() ) {
unset( $settings['unforce_ssl_checkout'] );
}
}
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
}
/**
* Output the settings.
*/
public function output() {
global $current_section;
// Load shipping methods so we can show any global options they may have.
if ( ! defined( 'WC_INSTALLING' ) ) {
$payment_gateways = WC()->payment_gateways->payment_gateways();
if ( $current_section ) {
foreach ( $payment_gateways as $gateway ) {
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ) ) ) {
$gateway->admin_options();
break;
}
}
} else {
$settings = $this->get_settings();
WC_Admin_Settings::output_fields( $settings );
foreach ( $payment_gateways as $gateway ) {
$title = empty( $gateway->method_title ) ? ucfirst( $gateway->id ) : $gateway->method_title;
$sections[ strtolower( $gateway->id ) ] = esc_html( $title );
}
}
/**
* Output payment gateway settings.
*/
public function payment_gateways_setting() {
?>
<tr valign="top">
<th scope="row" class="titledesc"><?php _e( 'Gateway display order', 'woocommerce' ); ?></th>
<td class="forminp">
<table class="wc_gateways widefat" cellspacing="0">
<thead>
<tr>
<?php
$columns = apply_filters(
'woocommerce_payment_gateways_setting_columns', array(
'sort' => '',
'name' => __( 'Gateway', 'woocommerce' ),
'id' => __( 'Gateway ID', 'woocommerce' ),
'status' => __( 'Enabled', 'woocommerce' ),
)
);
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
}
foreach ( $columns as $key => $column ) {
echo '<th class="' . esc_attr( $key ) . '">' . esc_html( $column ) . '</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ( WC()->payment_gateways->payment_gateways() as $gateway ) {
/**
* Get settings array.
*
* @param string $current_section Section being shown.
* @return array
*/
public function get_settings( $current_section = '' ) {
$settings = array();
echo '<tr>';
if ( '' === $current_section ) {
$settings = apply_filters(
'woocommerce_payment_gateways_settings', array(
foreach ( $columns as $key => $column ) {
array(
'title' => __( 'Checkout process', 'woocommerce' ),
'type' => 'title',
'id' => 'checkout_process_options',
),
switch ( $key ) {
array(
'title' => __( 'Coupons', 'woocommerce' ),
'desc' => __( 'Enable the use of coupons', 'woocommerce' ),
'id' => 'woocommerce_enable_coupons',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
),
case 'sort':
echo '<td width="1%" class="sort">
<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />
</td>';
break;
array(
'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
'id' => 'woocommerce_calc_discounts_sequentially',
'default' => 'no',
'type' => 'checkbox',
'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ),
'checkboxgroup' => 'end',
'autoload' => false,
),
case 'name':
$method_title = $gateway->get_title() ? $gateway->get_title() : __( '(no title)', 'woocommerce' );
echo '<td class="name">
<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) . '">' . esc_html( $method_title ) . '</a>
</td>';
break;
array(
'title' => __( 'Checkout process', 'woocommerce' ),
'desc' => __( 'Enable guest checkout', 'woocommerce' ),
'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'woocommerce' ),
'id' => 'woocommerce_enable_guest_checkout',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'autoload' => false,
),
case 'id':
echo '<td class="id">' . esc_html( $gateway->id ) . '</td>';
break;
array(
'desc' => __( 'Force secure checkout', 'woocommerce' ),
'id' => 'woocommerce_force_ssl_checkout',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
'show_if_checked' => 'option',
/* Translators: %s Docs URL. */
'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (<a href="%s" target="_blank">an SSL Certificate is required</a>).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ),
),
case 'status':
echo '<td class="status">';
echo ( 'yes' === $gateway->enabled ) ? '<span class="status-enabled tips" data-tip="' . esc_attr__( 'Yes', 'woocommerce' ) . '">' . esc_html__( 'Yes', 'woocommerce' ) . '</span>' : '-';
echo '</td>';
break;
'unforce_ssl_checkout' => array(
'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ),
'id' => 'woocommerce_unforce_ssl_checkout',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'show_if_checked' => 'yes',
),
default:
do_action( 'woocommerce_payment_gateways_setting_column_' . $key, $gateway );
break;
}
}
array(
'type' => 'sectionend',
'id' => 'checkout_process_options',
),
echo '</tr>';
}
?>
</tbody>
</table>
</td>
</tr>
<?php
array(
'title' => __( 'Checkout pages', 'woocommerce' ),
'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ),
'type' => 'title',
'id' => 'checkout_page_options',
),
array(
'title' => __( 'Cart page', 'woocommerce' ),
/* Translators: %s Page contents. */
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ),
'id' => 'woocommerce_cart_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'css' => 'min-width:300px;',
'desc_tip' => true,
),
array(
'title' => __( 'Checkout page', 'woocommerce' ),
/* Translators: %s Page contents. */
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ),
'id' => 'woocommerce_checkout_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'css' => 'min-width:300px;',
'desc_tip' => true,
),
array(
'title' => __( 'Terms and conditions', 'woocommerce' ),
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ),
'id' => 'woocommerce_terms_page_id',
'default' => '',
'class' => 'wc-enhanced-select-nostd',
'css' => 'min-width:300px;',
'type' => 'single_select_page',
'args' => array( 'exclude' => wc_get_page_id( 'checkout' ) ),
'desc_tip' => true,
'autoload' => false,
),
array(
'type' => 'sectionend',
'id' => 'checkout_page_options',
),
array(
'title' => __( 'Checkout endpoints', 'woocommerce' ),
'type' => 'title',
'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ),
'id' => 'account_endpoint_options',
),
array(
'title' => __( 'Pay', 'woocommerce' ),
'desc' => __( 'Endpoint for the "Checkout &rarr; Pay" page.', 'woocommerce' ),
'id' => 'woocommerce_checkout_pay_endpoint',
'type' => 'text',
'default' => 'order-pay',
'desc_tip' => true,
),
array(
'title' => __( 'Order received', 'woocommerce' ),
'desc' => __( 'Endpoint for the "Checkout &rarr; Order received" page.', 'woocommerce' ),
'id' => 'woocommerce_checkout_order_received_endpoint',
'type' => 'text',
'default' => 'order-received',
'desc_tip' => true,
),
array(
'title' => __( 'Add payment method', 'woocommerce' ),
'desc' => __( 'Endpoint for the "Checkout &rarr; Add payment method" page.', 'woocommerce' ),
'id' => 'woocommerce_myaccount_add_payment_method_endpoint',
'type' => 'text',
'default' => 'add-payment-method',
'desc_tip' => true,
),
array(
'title' => __( 'Delete payment method', 'woocommerce' ),
'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ),
'id' => 'woocommerce_myaccount_delete_payment_method_endpoint',
'type' => 'text',
'default' => 'delete-payment-method',
'desc_tip' => true,
),
array(
'title' => __( 'Set default payment method', 'woocommerce' ),
'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ),
'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint',
'type' => 'text',
'default' => 'set-default-payment-method',
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'checkout_endpoint_options',
),
array(
'title' => __( 'Payment gateways', 'woocommerce' ),
'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ),
'type' => 'title',
'id' => 'payment_gateways_options',
),
array(
'type' => 'payment_gateways',
),
array(
'type' => 'sectionend',
'id' => 'payment_gateways_options',
),
)
);
if ( wc_site_is_https() ) {
unset( $settings['unforce_ssl_checkout'] );
}
}
/**
* Save settings.
*/
public function save() {
global $current_section;
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
}
$wc_payment_gateways = WC_Payment_Gateways::instance();
/**
* Output the settings.
*/
public function output() {
global $current_section;
if ( ! $current_section ) {
// Prevent the T&Cs and checkout page from being set to the same page.
if ( isset( $_POST['woocommerce_terms_page_id'], $_POST['woocommerce_checkout_page_id'] ) && $_POST['woocommerce_terms_page_id'] === $_POST['woocommerce_checkout_page_id'] ) {
$_POST['woocommerce_terms_page_id'] = '';
}
// Load gateways so we can show any global options they may have.
$payment_gateways = WC()->payment_gateways->payment_gateways();
WC_Admin_Settings::save_fields( $this->get_settings() );
$wc_payment_gateways->process_admin_options();
} else {
foreach ( $wc_payment_gateways->payment_gateways() as $gateway ) {
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ) ) ) {
do_action( 'woocommerce_update_options_payment_gateways_' . $gateway->id );
$wc_payment_gateways->init();
}
if ( $current_section ) {
foreach ( $payment_gateways as $gateway ) {
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ), true ) ) {
$gateway->admin_options();
break;
}
}
} else {
$settings = $this->get_settings();
if ( $current_section ) {
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
}
WC_Admin_Settings::output_fields( $settings );
}
}
endif;
/**
* Output payment gateway settings.
*/
public function payment_gateways_setting() {
?>
<tr valign="top">
<th scope="row" class="titledesc"><?php esc_html_e( 'Gateway display order', 'woocommerce' ); ?></th>
<td class="forminp">
<table class="wc_gateways widefat" cellspacing="0">
<thead>
<tr>
<?php
$columns = apply_filters(
'woocommerce_payment_gateways_setting_columns', array(
'sort' => '',
'name' => __( 'Gateway', 'woocommerce' ),
'id' => __( 'Gateway ID', 'woocommerce' ),
'status' => __( 'Enabled', 'woocommerce' ),
)
);
foreach ( $columns as $key => $column ) {
echo '<th class="' . esc_attr( $key ) . '">' . esc_html( $column ) . '</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ( WC()->payment_gateways->payment_gateways() as $gateway ) {
echo '<tr>';
foreach ( $columns as $key => $column ) {
switch ( $key ) {
case 'sort':
echo '<td width="1%" class="sort">
<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />
</td>';
break;
case 'name':
$method_title = $gateway->get_title() ? $gateway->get_title() : __( '(no title)', 'woocommerce' );
echo '<td class="name">
<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html( $method_title ) . '</a>
</td>';
break;
case 'id':
echo '<td class="id">' . esc_html( $gateway->id ) . '</td>';
break;
case 'status':
echo '<td class="status">';
echo ( 'yes' === $gateway->enabled ) ? '<span class="status-enabled tips" data-tip="' . esc_attr__( 'Yes', 'woocommerce' ) . '">' . esc_html__( 'Yes', 'woocommerce' ) . '</span>' : '-';
echo '</td>';
break;
default:
do_action( 'woocommerce_payment_gateways_setting_column_' . $key, $gateway );
break;
}
}
echo '</tr>';
}
?>
</tbody>
</table>
</td>
</tr>
<?php
}
/**
* Save settings.
*/
public function save() {
global $current_section;
$wc_payment_gateways = WC_Payment_Gateways::instance();
if ( ! $current_section ) {
// Prevent the T&Cs and checkout page from being set to the same page.
if ( isset( $_POST['woocommerce_terms_page_id'], $_POST['woocommerce_checkout_page_id'] ) && $_POST['woocommerce_terms_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { // WPCS: input var ok, CSRF ok.
$_POST['woocommerce_terms_page_id'] = '';
}
WC_Admin_Settings::save_fields( $this->get_settings() );
$wc_payment_gateways->process_admin_options();
$wc_payment_gateways->init();
} else {
foreach ( $wc_payment_gateways->payment_gateways() as $gateway ) {
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ), true ) ) {
do_action( 'woocommerce_update_options_payment_gateways_' . $gateway->id );
$wc_payment_gateways->init();
}
}
}
if ( $current_section ) {
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
}
}
}
return new WC_Settings_Payment_Gateways();

View File

@ -2,357 +2,359 @@
/**
* WooCommerce General Settings
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
defined( 'ABSPATH' ) || exit;
if ( class_exists( 'WC_Settings_General', false ) ) {
return new WC_Settings_General();
}
if ( ! class_exists( 'WC_Settings_General', false ) ) :
/**
* WC_Admin_Settings_General.
*/
class WC_Settings_General extends WC_Settings_Page {
/**
* WC_Admin_Settings_General.
* Constructor.
*/
class WC_Settings_General extends WC_Settings_Page {
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'woocommerce' );
/**
* Constructor.
*/
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'woocommerce' );
parent::__construct();
}
/**
* Get settings array.
*
* @return array
*/
public function get_settings() {
$currency_code_options = get_woocommerce_currencies();
foreach ( $currency_code_options as $code => $name ) {
$currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')';
}
$settings = apply_filters(
'woocommerce_general_settings', array(
array(
'title' => __( 'Store Address', 'woocommerce' ),
'type' => 'title',
'desc' => __( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ),
'id' => 'store_address',
),
array(
'title' => __( 'Address line 1', 'woocommerce' ),
'desc' => __( 'The street address for your business location.', 'woocommerce' ),
'id' => 'woocommerce_store_address',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Address line 2', 'woocommerce' ),
'desc' => __( 'An additional, optional address line for your business location.', 'woocommerce' ),
'id' => 'woocommerce_store_address_2',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'City', 'woocommerce' ),
'desc' => __( 'The city in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_store_city',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Country / State', 'woocommerce' ),
'desc' => __( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_default_country',
'default' => 'GB',
'type' => 'single_select_country',
'desc_tip' => true,
),
array(
'title' => __( 'Postcode / ZIP', 'woocommerce' ),
'desc' => __( 'The postal code, if any, in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_store_postcode',
'css' => 'min-width:50px;',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'store_address',
),
array(
'title' => __( 'General options', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'general_options',
),
array(
'title' => __( 'Selling location(s)', 'woocommerce' ),
'desc' => __( 'This option lets you limit which countries you are willing to sell to.', 'woocommerce' ),
'id' => 'woocommerce_allowed_countries',
'default' => 'all',
'type' => 'select',
'class' => 'wc-enhanced-select',
'css' => 'min-width: 350px;',
'desc_tip' => true,
'options' => array(
'all' => __( 'Sell to all countries', 'woocommerce' ),
'all_except' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
'specific' => __( 'Sell to specific countries', 'woocommerce' ),
),
),
array(
'title' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_all_except_countries',
'css' => 'min-width: 350px;',
'default' => '',
'type' => 'multi_select_countries',
),
array(
'title' => __( 'Sell to specific countries', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_specific_allowed_countries',
'css' => 'min-width: 350px;',
'default' => '',
'type' => 'multi_select_countries',
),
array(
'title' => __( 'Shipping location(s)', 'woocommerce' ),
'desc' => __( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.', 'woocommerce' ),
'id' => 'woocommerce_ship_to_countries',
'default' => '',
'type' => 'select',
'class' => 'wc-enhanced-select',
'desc_tip' => true,
'options' => array(
'' => __( 'Ship to all countries you sell to', 'woocommerce' ),
'all' => __( 'Ship to all countries', 'woocommerce' ),
'specific' => __( 'Ship to specific countries only', 'woocommerce' ),
'disabled' => __( 'Disable shipping &amp; shipping calculations', 'woocommerce' ),
),
),
array(
'title' => __( 'Ship to specific countries', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_specific_ship_to_countries',
'css' => '',
'default' => '',
'type' => 'multi_select_countries',
),
array(
'title' => __( 'Default customer location', 'woocommerce' ),
'id' => 'woocommerce_default_customer_address',
'desc_tip' => __( 'This option determines a customers default location. The MaxMind GeoLite Database will be periodically downloaded to your wp-content directory if using geolocation.', 'woocommerce' ),
'default' => 'geolocation',
'type' => 'select',
'class' => 'wc-enhanced-select',
'options' => array(
'' => __( 'No location by default', 'woocommerce' ),
'base' => __( 'Shop base address', 'woocommerce' ),
'geolocation' => __( 'Geolocate', 'woocommerce' ),
'geolocation_ajax' => __( 'Geolocate (with page caching support)', 'woocommerce' ),
),
),
array(
'title' => __( 'Enable taxes', 'woocommerce' ),
'desc' => __( 'Enable taxes and tax calculations', 'woocommerce' ),
'id' => 'woocommerce_calc_taxes',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'general_options',
),
array(
'title' => __( 'Currency options', 'woocommerce' ),
'type' => 'title',
'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ),
'id' => 'pricing_options',
),
array(
'title' => __( 'Currency', 'woocommerce' ),
'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
'id' => 'woocommerce_currency',
'default' => 'GBP',
'type' => 'select',
'class' => 'wc-enhanced-select',
'desc_tip' => true,
'options' => $currency_code_options,
),
array(
'title' => __( 'Currency position', 'woocommerce' ),
'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ),
'id' => 'woocommerce_currency_pos',
'class' => 'wc-enhanced-select',
'default' => 'left',
'type' => 'select',
'options' => array(
'left' => __( 'Left', 'woocommerce' ),
'right' => __( 'Right', 'woocommerce' ),
'left_space' => __( 'Left with space', 'woocommerce' ),
'right_space' => __( 'Right with space', 'woocommerce' ),
),
'desc_tip' => true,
),
array(
'title' => __( 'Thousand separator', 'woocommerce' ),
'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ),
'id' => 'woocommerce_price_thousand_sep',
'css' => 'width:50px;',
'default' => ',',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Decimal separator', 'woocommerce' ),
'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ),
'id' => 'woocommerce_price_decimal_sep',
'css' => 'width:50px;',
'default' => '.',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Number of decimals', 'woocommerce' ),
'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ),
'id' => 'woocommerce_price_num_decimals',
'css' => 'width:50px;',
'default' => '2',
'desc_tip' => true,
'type' => 'number',
'custom_attributes' => array(
'min' => 0,
'step' => 1,
),
),
array(
'type' => 'sectionend',
'id' => 'pricing_options',
),
)
);
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
}
/**
* Output a color picker input box.
*
* @param mixed $name
* @param string $id
* @param mixed $value
* @param string $desc (default: '')
*/
public function color_picker( $name, $id, $value, $desc = '' ) {
echo '<div class="color_box">' . wc_help_tip( $desc ) . '
<input name="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
</div>';
}
/**
* Show a notice showing where the store notice setting has moved.
*
* @since 3.3.1
* @todo remove in next major release.
*/
private function store_notice_setting_moved_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_store_notice_setting_moved_notice', true ) ) {
return;
}
?>
<div id="message" class="updated woocommerce-message inline">
<a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'store_notice_setting_moved' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
<p>
<?php
/* translators: %s: URL to customizer. */
echo wp_kses(
sprintf(
__( 'Looking for the store notice setting? It can now be found <a href="%s">in the Customizer</a>.', 'woocommerce' ), esc_url(
add_query_arg(
array(
'autofocus' => array(
'panel' => 'woocommerce',
),
'url' => wc_get_page_permalink( 'shop' ),
), admin_url( 'customize.php' )
)
)
), array(
'a' => array(
'href' => array(),
'title' => array(),
),
)
);
?>
</p>
</div>
<?php
}
/**
* Output the settings.
*/
public function output() {
$settings = $this->get_settings();
$this->store_notice_setting_moved_notice();
WC_Admin_Settings::output_fields( $settings );
}
/**
* Save settings.
*/
public function save() {
$settings = $this->get_settings();
WC_Admin_Settings::save_fields( $settings );
}
parent::__construct();
}
endif;
/**
* Get settings array.
*
* @return array
*/
public function get_settings() {
$currency_code_options = get_woocommerce_currencies();
foreach ( $currency_code_options as $code => $name ) {
$currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')';
}
$woocommerce_default_customer_address_options = array(
'' => __( 'No location by default', 'woocommerce' ),
'base' => __( 'Shop base address', 'woocommerce' ),
'geolocation' => __( 'Geolocate', 'woocommerce' ),
'geolocation_ajax' => __( 'Geolocate (with page caching support)', 'woocommerce' ),
);
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
unset( $woocommerce_default_customer_address_options['geolocation'], $woocommerce_default_customer_address_options['geolocation_ajax'] );
}
$settings = apply_filters(
'woocommerce_general_settings', array(
array(
'title' => __( 'Store Address', 'woocommerce' ),
'type' => 'title',
'desc' => __( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ),
'id' => 'store_address',
),
array(
'title' => __( 'Address line 1', 'woocommerce' ),
'desc' => __( 'The street address for your business location.', 'woocommerce' ),
'id' => 'woocommerce_store_address',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Address line 2', 'woocommerce' ),
'desc' => __( 'An additional, optional address line for your business location.', 'woocommerce' ),
'id' => 'woocommerce_store_address_2',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'City', 'woocommerce' ),
'desc' => __( 'The city in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_store_city',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Country / State', 'woocommerce' ),
'desc' => __( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_default_country',
'default' => 'GB',
'type' => 'single_select_country',
'desc_tip' => true,
),
array(
'title' => __( 'Postcode / ZIP', 'woocommerce' ),
'desc' => __( 'The postal code, if any, in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_store_postcode',
'css' => 'min-width:50px;',
'default' => '',
'type' => 'text',
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'store_address',
),
array(
'title' => __( 'General options', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'general_options',
),
array(
'title' => __( 'Selling location(s)', 'woocommerce' ),
'desc' => __( 'This option lets you limit which countries you are willing to sell to.', 'woocommerce' ),
'id' => 'woocommerce_allowed_countries',
'default' => 'all',
'type' => 'select',
'class' => 'wc-enhanced-select',
'css' => 'min-width: 350px;',
'desc_tip' => true,
'options' => array(
'all' => __( 'Sell to all countries', 'woocommerce' ),
'all_except' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
'specific' => __( 'Sell to specific countries', 'woocommerce' ),
),
),
array(
'title' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_all_except_countries',
'css' => 'min-width: 350px;',
'default' => '',
'type' => 'multi_select_countries',
),
array(
'title' => __( 'Sell to specific countries', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_specific_allowed_countries',
'css' => 'min-width: 350px;',
'default' => '',
'type' => 'multi_select_countries',
),
array(
'title' => __( 'Shipping location(s)', 'woocommerce' ),
'desc' => __( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.', 'woocommerce' ),
'id' => 'woocommerce_ship_to_countries',
'default' => '',
'type' => 'select',
'class' => 'wc-enhanced-select',
'desc_tip' => true,
'options' => array(
'' => __( 'Ship to all countries you sell to', 'woocommerce' ),
'all' => __( 'Ship to all countries', 'woocommerce' ),
'specific' => __( 'Ship to specific countries only', 'woocommerce' ),
'disabled' => __( 'Disable shipping &amp; shipping calculations', 'woocommerce' ),
),
),
array(
'title' => __( 'Ship to specific countries', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_specific_ship_to_countries',
'css' => '',
'default' => '',
'type' => 'multi_select_countries',
),
array(
'title' => __( 'Default customer location', 'woocommerce' ),
'id' => 'woocommerce_default_customer_address',
'desc_tip' => __( 'This option determines a customers default location. The MaxMind GeoLite Database will be periodically downloaded to your wp-content directory if using geolocation.', 'woocommerce' ),
'default' => 'geolocation',
'type' => 'select',
'class' => 'wc-enhanced-select',
'options' => $woocommerce_default_customer_address_options,
),
array(
'title' => __( 'Enable taxes', 'woocommerce' ),
'desc' => __( 'Enable taxes and tax calculations', 'woocommerce' ),
'id' => 'woocommerce_calc_taxes',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'general_options',
),
array(
'title' => __( 'Currency options', 'woocommerce' ),
'type' => 'title',
'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ),
'id' => 'pricing_options',
),
array(
'title' => __( 'Currency', 'woocommerce' ),
'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
'id' => 'woocommerce_currency',
'default' => 'GBP',
'type' => 'select',
'class' => 'wc-enhanced-select',
'desc_tip' => true,
'options' => $currency_code_options,
),
array(
'title' => __( 'Currency position', 'woocommerce' ),
'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ),
'id' => 'woocommerce_currency_pos',
'class' => 'wc-enhanced-select',
'default' => 'left',
'type' => 'select',
'options' => array(
'left' => __( 'Left', 'woocommerce' ),
'right' => __( 'Right', 'woocommerce' ),
'left_space' => __( 'Left with space', 'woocommerce' ),
'right_space' => __( 'Right with space', 'woocommerce' ),
),
'desc_tip' => true,
),
array(
'title' => __( 'Thousand separator', 'woocommerce' ),
'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ),
'id' => 'woocommerce_price_thousand_sep',
'css' => 'width:50px;',
'default' => ',',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Decimal separator', 'woocommerce' ),
'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ),
'id' => 'woocommerce_price_decimal_sep',
'css' => 'width:50px;',
'default' => '.',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'Number of decimals', 'woocommerce' ),
'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ),
'id' => 'woocommerce_price_num_decimals',
'css' => 'width:50px;',
'default' => '2',
'desc_tip' => true,
'type' => 'number',
'custom_attributes' => array(
'min' => 0,
'step' => 1,
),
),
array(
'type' => 'sectionend',
'id' => 'pricing_options',
),
)
);
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
}
/**
* Output a color picker input box.
*
* @param mixed $name Name of input.
* @param string $id ID of input.
* @param mixed $value Value of input.
* @param string $desc (default: '') Description for input.
*/
public function color_picker( $name, $id, $value, $desc = '' ) {
echo '<div class="color_box">' . wc_help_tip( $desc ) . '
<input name="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
</div>';
}
/**
* Show a notice showing where the store notice setting has moved.
*
* @since 3.3.1
* @todo remove in next major release.
*/
private function store_notice_setting_moved_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_store_notice_setting_moved_notice', true ) ) {
return;
}
?>
<div id="message" class="updated woocommerce-message inline">
<a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'store_notice_setting_moved' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
<p>
<?php
echo wp_kses(
sprintf(
/* translators: %s: URL to customizer. */
__( 'Looking for the store notice setting? It can now be found <a href="%s">in the Customizer</a>.', 'woocommerce' ), esc_url(
add_query_arg(
array(
'autofocus' => array(
'panel' => 'woocommerce',
),
'url' => wc_get_page_permalink( 'shop' ),
), admin_url( 'customize.php' )
)
)
), array(
'a' => array(
'href' => array(),
'title' => array(),
),
)
);
?>
</p>
</div>
<?php
}
/**
* Output the settings.
*/
public function output() {
$settings = $this->get_settings();
$this->store_notice_setting_moved_notice();
WC_Admin_Settings::output_fields( $settings );
}
/**
* Save settings.
*/
public function save() {
$settings = $this->get_settings();
WC_Admin_Settings::save_fields( $settings );
}
}
return new WC_Settings_General();

View File

@ -1,11 +1,11 @@
<?php
/**
* Admin View: Page - Status Report.
*
* @package WooCommerce
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
global $wpdb;
@ -56,58 +56,83 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tbody>
<tr>
<td data-export-label="Home URL"><?php esc_html_e( 'Home URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The homepage URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The homepage URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['home_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="Site URL"><?php esc_html_e( 'Site URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The root URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The root URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['site_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="WC Version"><?php esc_html_e( 'WC version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce installed on your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td data-export-label="WC Version"><?php esc_html_e( 'WooCommerce version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WooCommerce installed on your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['version'] ); ?></td>
</tr>
<tr>
<td data-export-label="Log Directory Writable"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Several WooCommerce extensions can write logs which makes debugging problems easier. The directory must be writable for this to happen.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
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 {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'To allow logging, make %1$s writable or define a custom %2$s.', 'woocommerce' ), '<code>' . $environment['log_directory'] . '</code>', '<code>WC_LOG_DIR</code>' ) . '</mark>';
/* Translators: %1$s: Log directory, %2$s: Log directory constant */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'To allow logging, make %1$s writable or define a custom %2$s.', 'woocommerce' ), '<code>' . esc_html( $environment['log_directory'] ) . '</code>', '<code>WC_LOG_DIR</code>' ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="WP Version"><?php esc_html_e( 'WP version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WordPress installed on your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['wp_version'] ); ?></td>
<td data-export-label="WP Version"><?php esc_html_e( 'WordPress version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WordPress installed on your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
$latest_version = get_transient( 'woocommerce_system_status_wp_version_check' );
if ( false === $latest_version ) {
$version_check = wp_remote_get( 'https://api.wordpress.org/core/version-check/1.7/' );
$api_response = json_decode( wp_remote_retrieve_body( $version_check ), true );
if ( $api_response && isset( $api_response['offers'], $api_response['offers'][0], $api_response['offers'][0]['version'] ) ) {
$latest_version = $api_response['offers'][0]['version'];
} else {
$latest_version = $environment['wp_version'];
}
set_transient( 'woocommerce_system_status_wp_version_check', $latest_version, DAY_IN_SECONDS );
}
if ( version_compare( $environment['wp_version'], $latest_version, '<' ) ) {
/* Translators: %1$s: Current version, %2$s: New version */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - There is a newer version of WordPress available (%2$s)', 'woocommerce' ), esc_html( $environment['wp_version'] ), esc_html( $latest_version ) ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $environment['wp_version'] ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="WP Multisite"><?php esc_html_e( 'WP multisite', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Whether or not you have WordPress Multisite enabled.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td data-export-label="WP Multisite"><?php esc_html_e( 'WordPress multisite', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Whether or not you have WordPress Multisite enabled.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '&ndash;'; ?></td>
</tr>
<tr>
<td data-export-label="WP Memory Limit"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td data-export-label="WP Memory Limit"><?php esc_html_e( 'WordPress memory limit', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The maximum amount of memory (RAM) that your site can use at one time.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( $environment['wp_memory_limit'] < 67108864 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$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>';
/* Translators: %1$s: Memory limit, %2$s: Docs link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'woocommerce' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . size_format( $environment['wp_memory_limit'] ) . '</mark>';
echo '<mark class="yes">' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="WP Debug Mode"><?php esc_html_e( 'WP debug mode', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not WordPress is in Debug Mode.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td data-export-label="WP Debug Mode"><?php esc_html_e( 'WordPress debug mode', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not WordPress is in Debug Mode.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php if ( $environment['wp_debug_mode'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
@ -117,8 +142,8 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</td>
</tr>
<tr>
<td data-export-label="WP Cron"><?php esc_html_e( 'WP cron', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not WP Cron Jobs are enabled.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td data-export-label="WP Cron"><?php esc_html_e( 'WordPress cron', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not WP Cron Jobs are enabled.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php if ( $environment['wp_cron'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
@ -129,12 +154,12 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</tr>
<tr>
<td data-export-label="Language"><?php esc_html_e( 'Language', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The current language used by WordPress. Default = English', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The current language used by WordPress. Default = English', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['language'] ); ?></td>
</tr>
<tr>
<td data-export-label="External object cache"><?php _e( 'External object cache', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not WordPress is using an external object cache.', 'woocommerce' ) ); ?></td>
<td data-export-label="External object cache"><?php esc_html_e( 'External object cache', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not WordPress is using an external object cache.', 'woocommerce' ) ); ?></td>
<td>
<?php if ( $environment['external_object_cache'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
@ -154,18 +179,28 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tbody>
<tr>
<td data-export-label="Server Info"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Information about the web server that is currently hosting your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['server_info'] ); ?></td>
</tr>
<tr>
<td data-export-label="PHP Version"><?php esc_html_e( 'PHP version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of PHP installed on your hosting server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of PHP installed on your hosting server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( version_compare( $environment['php_version'], '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend a minimum PHP version of 5.6. See: %2$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 {
if ( version_compare( $environment['php_version'], '7.2', '>=' ) ) {
echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>';
} else {
$update_link = ' <a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . esc_html__( 'How to update your PHP version', 'woocommerce' ) . '</a>';
if ( version_compare( $environment['php_version'], '5.4', '<' ) ) {
$notice = __( 'WooCommerce will run under this version of PHP, however, some features such as geolocation are not compatible. Support for this version will be dropped in the next major release. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
} elseif ( version_compare( $environment['php_version'], '5.6', '<' ) ) {
$notice = __( 'WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
} elseif ( version_compare( $environment['php_version'], '7.2', '<' ) ) {
$notice = __( 'We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
}
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . '</mark>';
}
?>
</td>
@ -173,27 +208,27 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php if ( function_exists( 'ini_get' ) ) : ?>
<tr>
<td data-export-label="PHP Post Max Size"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The largest filesize that can be contained in one post.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( size_format( $environment['php_post_max_size'] ) ); ?></td>
</tr>
<tr>
<td data-export-label="PHP Time Limit"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The amount of time (in seconds) that your site will spend on a single operation before timing out (to avoid server lockups)', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['php_max_execution_time'] ); ?></td>
</tr>
<tr>
<td data-export-label="PHP Max Input Vars"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The maximum number of variables your server can use for a single function to avoid overloads.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['php_max_input_vars'] ); ?></td>
</tr>
<tr>
<td data-export-label="cURL Version"><?php esc_html_e( 'cURL version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of cURL installed on your server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of cURL installed on your server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['curl_version'] ); ?></td>
</tr>
<tr>
<td data-export-label="SUHOSIN Installed"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( '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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo $environment['suhosin_installed'] ? '<span class="dashicons dashicons-yes"></span>' : '&ndash;'; ?></td>
</tr>
<?php endif; ?>
@ -204,11 +239,12 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
?>
<tr>
<td data-export-label="MySQL Version"><?php esc_html_e( 'MySQL version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of MySQL installed on your hosting server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of MySQL installed on your hosting server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
/* Translators: %1$s: MySQL version, %2$s: Recommended MySQL version. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $environment['mysql_version'] ) . '</mark>';
}
@ -218,16 +254,17 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php endif; ?>
<tr>
<td data-export-label="Max Upload Size"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo size_format( $environment['max_upload_size'] ); ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The largest filesize that can be uploaded to your WordPress installation.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( size_format( $environment['max_upload_size'] ) ); ?></td>
</tr>
<tr>
<td data-export-label="Default Timezone is UTC"><?php esc_html_e( 'Default timezone is UTC', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The default timezone for your server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The default timezone for your server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
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>';
/* Translators: %s: default timezone.. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'woocommerce' ), esc_html( $environment['default_timezone'] ) ) . '</mark>';
} else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
}
@ -236,91 +273,97 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</tr>
<tr>
<td data-export-label="fsockopen/cURL"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( '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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( '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 esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( '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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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>';
/* Translators: %s classname and link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '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 esc_html_e( 'DOMDocument', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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>';
/* Translators: %s: classname and link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '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 esc_html_e( 'GZip', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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>';
/* Translators: %s: classname and link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '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 esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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>';
/* Translators: %s: classname and link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '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 esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'PayPal uses this method of communicating when sending back transaction information.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>';
/* Translators: %s: function name. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Remote Get"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>';
/* Translators: %s: function name. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>';
}
?>
</td>
@ -338,10 +381,10 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
?>
<tr>
<td data-export-label="<?php echo esc_attr( $row['name'] ); ?>"><?php echo esc_html( $row['name'] ); ?>:</td>
<td class="help"><?php echo isset( $row['help'] ) ? $row['help'] : ''; ?></td>
<td class="help"><?php echo esc_html( isset( $row['help'] ) ? $row['help'] : '' ); ?></td>
<td>
<mark class="<?php echo esc_attr( $css_class ); ?>">
<?php echo $icon; ?> <?php echo ! empty( $row['note'] ) ? wp_kses_data( $row['note'] ) : ''; ?>
<?php echo wp_kses_post( $icon ); ?> <?php echo wp_kses_data( ! empty( $row['note'] ) ? $row['note'] : '' ); ?>
</mark>
</td>
</tr>
@ -358,8 +401,8 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</thead>
<tbody>
<tr>
<td data-export-label="WC Database Version"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td data-export-label="WC Database Version"><?php esc_html_e( 'WooCommerce database version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce version.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $database['wc_database_version'] ); ?></td>
</tr>
<tr>
@ -368,7 +411,8 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<td>
<?php
if ( strlen( $database['database_prefix'] ) > 20 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$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>';
/* Translators: %1$s: Database prefix, %2$s: Docs link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$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">' . esc_html__( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>';
}
@ -379,13 +423,16 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php if ( $settings['geolocation_enabled'] ) { ?>
<tr>
<td data-export-label="MaxMind GeoIP Database"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The GeoIP database from MaxMind is used to geolocate customers.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( file_exists( $database['maxmind_geoip_database'] ) ) {
if ( version_compare( $environment['php_version'], '5.4', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . wp_kses_post( __( 'MaxMind GeoIP database requires at least PHP 5.4.', 'woocommerce' ) ) . '</mark>';
} elseif ( 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". 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 );
/* Translators: %1$s: Library url, %2$s: install path. */
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '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 "MaxMind DB binary, gzipped" file next to "GeoLite2 Country". Please remember to uncompress GeoLite2-Country_xxxxxxxx.tar.gz and upload the GeoLite2-Country.mmdb file only.', 'woocommerce' ), '<a href="https://dev.maxmind.com/geoip/geoip2/geolite2/">https://dev.maxmind.com/geoip/geoip2/geolite2/</a>', '<code class="private">' . esc_html( $database['maxmind_geoip_database'] ) . '</code>' ) . '</mark>', esc_html( WC_LOG_DIR ) );
}
?>
</td>
@ -395,19 +442,19 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr>
<td><?php esc_html_e( 'Total Database Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['data'] + $database['database_size']['index'] ); ?></td>
<td><?php printf( '%.2fMB', esc_html( $database['database_size']['data'] + $database['database_size']['index'] ) ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Database Data Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['data'] ); ?></td>
<td><?php printf( '%.2fMB', esc_html( $database['database_size']['data'] ) ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Database Index Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['index'] ); ?></td>
<td><?php printf( '%.2fMB', esc_html( $database['database_size']['index'] ) ); ?></td>
</tr>
<?php foreach ( $database['database_tables']['woocommerce'] as $table => $table_data ) { ?>
@ -417,9 +464,10 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<td>
<?php
if ( ! $table_data ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Table does not exist', 'woocommerce' ) . '</mark>';
} else {
printf( __( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) );
/* Translators: %1$f: Table size, %2$f: Index size. */
printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ) );
}
?>
</td>
@ -431,7 +479,10 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php printf( __( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) ); ?>
<?php
/* Translators: %1$f: Table size, %2$f: Index size. */
printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ) );
?>
</td>
</tr>
<?php } ?>
@ -466,18 +517,23 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tbody>
<tr>
<td data-export-label="Secure connection (HTTPS)"><?php esc_html_e( 'Secure connection (HTTPS)', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Is the connection to your store secure?', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Is the connection to your store secure?', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php if ( $security['secure_connection'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php else : ?>
<mark class="error"><span class="dashicons dashicons-warning"></span><?php printf( __( 'Your store is not using HTTPS. <a href="%s" target="_blank">Learn more about HTTPS and SSL Certificates</a>.', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/' ); ?></mark>
<mark class="error"><span class="dashicons dashicons-warning"></span>
<?php
/* Translators: %s: docs link. */
echo wp_kses_post( sprintf( __( 'Your store is not using HTTPS. <a href="%s" target="_blank">Learn more about HTTPS and SSL Certificates</a>.', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/' ) );
?>
</mark>
<?php endif; ?>
</td>
</tr>
<tr>
<td data-export-label="Hide errors from visitors"><?php esc_html_e( 'Hide errors from visitors', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'Error messages can contain sensitive information about your store environment. These should be hidden from untrusted visitors.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Error messages can contain sensitive information about your store environment. These should be hidden from untrusted visitors.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php if ( $security['hide_errors'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
@ -514,8 +570,8 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
$version_string = ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'woocommerce' ), $plugin['version_latest'] ) . '</strong>';
}
if ( false != $plugin['network_activated'] ) {
$network_string = ' &ndash; <strong style="color:black;">' . __( 'Network enabled', 'woocommerce' ) . '</strong>';
if ( false !== $plugin['network_activated'] ) {
$network_string = ' &ndash; <strong style="color:black;">' . esc_html__( 'Network enabled', 'woocommerce' ) . '</strong>';
}
}
$untested_string = '';
@ -524,13 +580,13 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
}
?>
<tr>
<td><?php echo $plugin_name; ?></td>
<td><?php echo wp_kses_post( $plugin_name ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php
/* translators: %s: plugin author */
printf( __( 'by %s', 'woocommerce' ), $plugin['author_name'] );
echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string;
printf( esc_html__( 'by %s', 'woocommerce' ), esc_html( $plugin['author_name'] ) );
echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string; // WPCS: XSS ok.
?>
</td>
</tr>
@ -549,42 +605,42 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tbody>
<tr>
<td data-export-label="API Enabled"><?php esc_html_e( 'API enabled', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Does your site have REST API enabled?', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Does your site have REST API enabled?', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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 esc_html_e( 'Force SSL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Does your site force a SSL Certificate for transactions?', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Does your site force a SSL Certificate for transactions?', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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 esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'What currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></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 esc_html_e( 'Currency position', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The position of the currency symbol.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The position of the currency symbol.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $settings['currency_position'] ); ?></td>
</tr>
<tr>
<td data-export-label="Thousand Separator"><?php esc_html_e( 'Thousand separator', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The thousand separator of displayed prices.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The thousand separator of displayed prices.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $settings['thousand_separator'] ); ?></td>
</tr>
<tr>
<td data-export-label="Decimal Separator"><?php esc_html_e( 'Decimal separator', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The decimal separator of displayed prices.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The decimal separator of displayed prices.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $settings['decimal_separator'] ); ?></td>
</tr>
<tr>
<td data-export-label="Number of Decimals"><?php esc_html_e( 'Number of decimals', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The number of decimal points shown in displayed prices.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The number of decimal points shown in displayed prices.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $settings['number_of_decimals'] ); ?></td>
</tr>
<tr>
<td data-export-label="Taxonomies: Product Types"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'A list of taxonomy terms that can be used in regard to order/product statuses.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
$display_terms = array();
@ -597,7 +653,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</tr>
<tr>
<td data-export-label="Taxonomies: Product Visibility"><?php esc_html_e( 'Taxonomies: Product visibility', 'woocommerce' ); ?></th>
<td class="help"><?php echo wc_help_tip( __( 'A list of taxonomy terms used for product visibility.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'A list of taxonomy terms used for product visibility.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
$display_terms = array();
@ -613,7 +669,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="WC Pages"><h2><?php esc_html_e( 'WC pages', 'woocommerce' ); ?></h2></th>
<th colspan="3" data-export-label="WC Pages"><h2><?php esc_html_e( 'WooCommerce pages', 'woocommerce' ); ?></h2></th>
</tr>
</thead>
<tbody>
@ -623,36 +679,39 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
$error = false;
if ( $page['page_id'] ) {
$page_name = '<a href="' . get_edit_post_link( $page['page_id'] ) . '" aria-label="' . sprintf( __( 'Edit %s page', 'woocommerce' ), esc_html( $page['page_name'] ) ) . '">' . esc_html( $page['page_name'] ) . '</a>';
/* Translators: %s: page name. */
$page_name = '<a href="' . get_edit_post_link( $page['page_id'] ) . '" aria-label="' . sprintf( esc_html__( 'Edit %s page', 'woocommerce' ), esc_html( $page['page_name'] ) ) . '">' . esc_html( $page['page_name'] ) . '</a>';
} else {
$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( sprintf( __( 'The URL of your %s page (along with the Page ID).', 'woocommerce' ), $page_name ) ) . '</td><td>';
echo '<tr><td data-export-label="' . esc_attr( $page_name ) . '">' . wp_kses_post( $page_name ) . ':</td>';
/* Translators: %s: page name. */
echo '<td class="help">' . wc_help_tip( sprintf( esc_html__( 'The URL of your %s page (along with the Page ID).', 'woocommerce' ), $page_name ) ) . '</td><td>';
// Page ID check.
if ( ! $page['page_set'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page not set', 'woocommerce' ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Page not set', 'woocommerce' ) . '</mark>';
$error = true;
} elseif ( ! $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>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Page ID is set, but the page does not exist', 'woocommerce' ) . '</mark>';
$error = true;
} elseif ( ! $page['page_visible'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page visibility should be <a href="%s" target="_blank">public</a>', 'woocommerce' ), 'https://codex.wordpress.org/Content_Visibility' ) . '</mark>';
/* Translators: %s: docs link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . wp_kses_post( sprintf( __( 'Page visibility should be <a href="%s" target="_blank">public</a>', 'woocommerce' ), 'https://codex.wordpress.org/Content_Visibility' ) ) . '</mark>';
$error = true;
} else {
// Shortcode check
// Shortcode check.
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>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Page does not contain the shortcode.', 'woocommerce' ), esc_html( $page['shortcode'] ) ) . '</mark>';
$error = true;
}
}
}
if ( ! $error ) {
echo '<mark class="yes">#' . absint( $page['page_id'] ) . ' - ' . str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) . '</mark>';
echo '<mark class="yes">#' . absint( $page['page_id'] ) . ' - ' . esc_html( str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) ) . '</mark>';
}
echo '</td></tr>';
@ -669,66 +728,73 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tbody>
<tr>
<td data-export-label="Name"><?php esc_html_e( 'Name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the current active theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The name of the current active theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Version"><?php esc_html_e( 'Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the current active theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The installed version of the current active theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
echo esc_html( $theme['version'] );
if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) {
/* translators: %s: theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . '</strong>';
echo ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . '</strong>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Author URL"><?php esc_html_e( 'Author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The theme developers URL.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The theme developers URL.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['author_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="Child Theme"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not the current theme is a child theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php 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 are modifying WooCommerce on a parent theme that you did not build personally 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>
<?php
if ( $theme['is_child_theme'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
/* Translators: %s docs link. */
echo '<span class="dashicons dashicons-no-alt"></span> &ndash; ' . wp_kses_post( sprintf( __( 'If you are modifying WooCommerce on a parent theme that you did not build personally 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 ( $theme['is_child_theme'] ) : ?>
<tr>
<td data-export-label="Parent Theme Name"><?php esc_html_e( 'Parent theme name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the parent theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The name of the parent theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['parent_name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Version"><?php esc_html_e( 'Parent theme version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the parent theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The installed version of the parent theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
echo esc_html( $theme['parent_version'] );
if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) {
/* translators: %s: parant theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>';
/* translators: %s: parent theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'woocommerce' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Parent Theme Author URL"><?php esc_html_e( 'Parent theme author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The parent theme developers URL.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The parent theme developers URL.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['parent_author_url'] ); ?></td>
</tr>
<?php endif ?>
<tr>
<td data-export-label="WooCommerce Support"><?php esc_html_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' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not the current active theme declares WooCommerce support.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( ! $theme['has_woocommerce_support'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Not declared', 'woocommerce' ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Not declared', 'woocommerce' ) . '</mark>';
} else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
}
@ -740,7 +806,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Templates"><h2><?php esc_html_e( 'Templates', 'woocommerce' ); ?><?php echo wc_help_tip( __( 'This section shows any files that are overriding the default WooCommerce template pages.', 'woocommerce' ) ); ?></h2></th>
<th colspan="3" data-export-label="Templates"><h2><?php esc_html_e( 'Templates', 'woocommerce' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows any files that are overriding the default WooCommerce template pages.', 'woocommerce' ) ); ?></h2></th>
</tr>
</thead>
<tbody>
@ -763,10 +829,11 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) {
$current_version = $override['version'] ? $override['version'] : '-';
printf(
__( '%1$s version %2$s is out of date. The core version is %3$s', 'woocommerce' ),
'<code>' . $override['file'] . '</code>',
'<strong style="color:red">' . $current_version . '</strong>',
$override['core_version']
/* Translators: %1$s: Template name, %2$s: Template version, %3$s: Core version. */
esc_html__( '%1$s version %2$s is out of date. The core version is %3$s', 'woocommerce' ),
'<code>' . esc_html( $override['file'] ) . '</code>',
'<strong style="color:red">' . esc_html( $current_version ) . '</strong>',
esc_html( $override['core_version'] )
);
} else {
echo esc_html( $override['file'] );

View File

@ -1,16 +0,0 @@
<?php
/**
* Admin View: Notice - Tracking
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div id="message" class="updated woocommerce-message woocommerce-tracker">
<p><?php printf( __( 'Want to help make WooCommerce even more awesome? Allow WooCommerce to collect non-sensitive diagnostic data and usage information, and get %1$s discount on your next WooThemes purchase. <a href="%2$s" target="_blank">Find out more</a>.', 'woocommerce' ), '20%', 'https://woocommerce.com/usage-tracking/' ); ?></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>
</p>
</div>

View File

@ -214,6 +214,7 @@ function woocommerce_wp_select( $field ) {
$field_attributes['style'] = $field['style'];
$field_attributes['id'] = $field['id'];
$field_attributes['name'] = $field['name'];
$field_attributes['class'] = $field['class'];
$tooltip = ! empty( $field['description'] ) && false !== $field['desc_tip'] ? $field['description'] : '';
$description = ! empty( $field['description'] ) && false === $field['desc_tip'] ? $field['description'] : '';

View File

@ -166,6 +166,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
'amount' => $data['amount'],
'reason' => $data['reason'],
'refunded_by' => $data['refunded_by'],
'refunded_payment' => $data['refunded_payment'],
'meta_data' => $data['meta_data'],
'line_items' => $data['line_items'],
);
@ -383,6 +384,11 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
'type' => 'integer',
'context' => array( 'view', 'edit' ),
),
'refunded_payment' => array(
'description' => __( 'If the payment was refunded via the API.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view' ),
),
'meta_data' => array(
'description' => __( 'Meta data.', 'woocommerce' ),
'type' => 'array',

View File

@ -603,7 +603,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'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 ),
'log_directory_writable' => (bool) @fopen( WC_LOG_DIR . 'test-log.log', 'a' ),
'wp_version' => get_bloginfo( 'version' ),
'wp_multisite' => is_multisite(),
'wp_memory_limit' => $wp_memory_limit,

View File

@ -337,7 +337,7 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $note->comment_ID,
'created_at' => $this->server->format_datetime( $note->comment_date_gmt ),
'note' => $note->comment_content,
'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false,
'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ),
);
}

View File

@ -1269,7 +1269,7 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $note->comment_ID,
'created_at' => $this->server->format_datetime( $note->comment_date_gmt ),
'note' => $note->comment_content,
'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false,
'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ),
);
return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) );

View File

@ -440,7 +440,7 @@ class WC_API_Products extends WC_API_Resource {
}
$product->delete( true );
$result = $product->get_id() > 0 ? false : true;
$result = ! ( $product->get_id() > 0 );
} else {
$product->delete();
$result = 'trash' === $product->get_status();

View File

@ -84,11 +84,6 @@ class WC_API_Webhooks extends WC_API_Resource {
$webhooks = array();
foreach ( $query['results'] as $webhook_id ) {
if ( ! $this->is_readable( $webhook_id ) ) {
continue;
}
$webhooks[] = current( $this->get_webhook( $webhook_id, $fields ) );
}

View File

@ -1316,7 +1316,7 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $note->comment_ID,
'created_at' => $this->server->format_datetime( $note->comment_date_gmt ),
'note' => $note->comment_content,
'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false,
'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ),
);
return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) );

View File

@ -499,7 +499,7 @@ class WC_API_Products extends WC_API_Resource {
}
$product->delete( true );
$result = $product->get_id() > 0 ? false : true;
$result = ! ( $product->get_id() > 0 );
} else {
$product->delete();
$result = 'trash' === $product->get_status();

View File

@ -84,11 +84,6 @@ class WC_API_Webhooks extends WC_API_Resource {
$webhooks = array();
foreach ( $query['results'] as $webhook_id ) {
if ( ! $this->is_readable( $webhook_id ) ) {
continue;
}
$webhooks[] = current( $this->get_webhook( $webhook_id, $fields ) );
}

View File

@ -1675,7 +1675,7 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller {
}
$product->delete( true );
$result = $product->get_id() > 0 ? false : true;
$result = ! ( $product->get_id() > 0 );
} else {
// If we don't support trashing for this type, error out.
if ( ! $supports_trash ) {

View File

@ -4,15 +4,11 @@
*
* Handles WC-API endpoint requests.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.0
* @package WooCommerce/API
* @since 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* API class.
@ -130,78 +126,78 @@ class WC_API extends WC_Legacy_API {
*/
private function rest_api_includes() {
// Exception handler.
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-exception.php' );
include_once dirname( __FILE__ ) . '/api/class-wc-rest-exception.php';
// Authentication.
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-authentication.php' );
include_once dirname( __FILE__ ) . '/api/class-wc-rest-authentication.php';
// 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-crud-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php' );
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php' );
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-crud-controller.php';
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php';
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php';
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php';
// REST API v1 controllers.
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-coupons-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-customer-downloads-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-customers-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-orders-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-notes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-refunds-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attribute-terms-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attributes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-categories-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-reviews-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-shipping-classes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-tags-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-products-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-sales-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-top-sellers-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-reports-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-tax-classes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-taxes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhook-deliveries-controller.php' );
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhooks-controller.php' );
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-coupons-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-customer-downloads-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-customers-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-orders-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-notes-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-refunds-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attribute-terms-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attributes-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-categories-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-reviews-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-shipping-classes-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-tags-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-products-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-sales-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-top-sellers-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-reports-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-tax-classes-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-taxes-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhook-deliveries-controller.php';
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhooks-controller.php';
// Legacy v2 code.
include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-coupons-controller.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-orders-controller.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-products-controller.php' );
include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-coupons-controller.php';
include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-orders-controller.php';
include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-products-controller.php';
// REST API v2 controllers.
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customers-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-orders-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-network-orders-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-order-notes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-order-refunds-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-attribute-terms-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-attributes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-categories-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-reviews-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-shipping-classes-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-tags-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-products-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-variations-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-report-sales-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-report-top-sellers-controller.php' );
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-setting-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-controller.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' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-methods-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-payment-gateways-controller.php' );
include_once dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-customers-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-orders-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-network-orders-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-order-notes-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-order-refunds-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-attribute-terms-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-attributes-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-categories-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-reviews-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-shipping-classes-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-tags-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-products-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-variations-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-report-sales-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-report-top-sellers-controller.php';
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-setting-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-controller.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';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-methods-controller.php';
include_once dirname( __FILE__ ) . '/api/class-wc-rest-payment-gateways-controller.php';
}
/**

View File

@ -4,15 +4,15 @@
*
* Handles wc-auth endpoint requests.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.4.0
* @package WooCommerce/API
* @since 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* Auth class.
*/
class WC_Auth {
/**
@ -28,23 +28,21 @@ class WC_Auth {
* @since 2.4.0
*/
public function __construct() {
// Add query vars
// Add query vars.
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
// Register auth endpoint
// Register auth endpoint.
add_action( 'init', array( __CLASS__, 'add_endpoint' ), 0 );
// Handle auth requests
add_action( 'parse_request', array( $this, 'handle_auth_requests' ), 0 );
// Handle auth requests.
add_action( 'parse_request.', array( $this, 'handle_auth_requests' ), 0 );
}
/**
* Add query vars.
*
* @since 2.4.0
*
* @param array $vars
*
* @param array $vars Query variables.
* @return string[]
*/
public function add_query_vars( $vars ) {
@ -66,9 +64,7 @@ class WC_Auth {
* Get scope name.
*
* @since 2.4.0
*
* @param string $scope
*
* @param string $scope Permission scope.
* @return string
*/
protected function get_i18n_scope( $scope ) {
@ -85,34 +81,32 @@ class WC_Auth {
* Return a list of permissions a scope allows.
*
* @since 2.4.0
*
* @param string $scope
*
* @param string $scope Permission scope.
* @return array
*/
protected function get_permissions_in_scope( $scope ) {
$permissions = array();
switch ( $scope ) {
case 'read' :
case 'read':
$permissions[] = __( 'View coupons', 'woocommerce' );
$permissions[] = __( 'View customers', 'woocommerce' );
$permissions[] = __( 'View orders and sales reports', 'woocommerce' );
$permissions[] = __( 'View products', 'woocommerce' );
break;
case 'write' :
break;
case 'write':
$permissions[] = __( 'Create webhooks', 'woocommerce' );
$permissions[] = __( 'Create coupons', 'woocommerce' );
$permissions[] = __( 'Create customers', 'woocommerce' );
$permissions[] = __( 'Create orders', 'woocommerce' );
$permissions[] = __( 'Create products', 'woocommerce' );
break;
case 'read_write' :
break;
case 'read_write':
$permissions[] = __( 'Create webhooks', 'woocommerce' );
$permissions[] = __( 'View and manage coupons', 'woocommerce' );
$permissions[] = __( 'View and manage customers', 'woocommerce' );
$permissions[] = __( 'View and manage orders and sales reports', 'woocommerce' );
$permissions[] = __( 'View and manage products', 'woocommerce' );
break;
break;
}
return apply_filters( 'woocommerce_api_permissions_in_scope', $permissions, $scope );
}
@ -121,27 +115,28 @@ class WC_Auth {
* Build auth urls.
*
* @since 2.4.0
*
* @param array $data
* @param string $endpoint
*
* @param array $data Data to build URL.
* @param string $endpoint Endpoint.
* @return string
*/
protected function build_url( $data, $endpoint ) {
$url = wc_get_endpoint_url( 'wc-auth/v' . self::VERSION, $endpoint, home_url( '/' ) );
return add_query_arg( array(
'app_name' => wc_clean( $data['app_name'] ),
'user_id' => wc_clean( $data['user_id'] ),
'return_url' => urlencode( $this->get_formatted_url( $data['return_url'] ) ),
'callback_url' => urlencode( $this->get_formatted_url( $data['callback_url'] ) ),
'scope' => wc_clean( $data['scope'] ),
), $url );
return add_query_arg(
array(
'app_name' => wc_clean( $data['app_name'] ),
'user_id' => wc_clean( $data['user_id'] ),
'return_url' => rawurlencode( $this->get_formatted_url( $data['return_url'] ) ),
'callback_url' => rawurlencode( $this->get_formatted_url( $data['callback_url'] ) ),
'scope' => wc_clean( $data['scope'] ),
), $url
);
}
/**
* Decode and format a URL.
* @param string $url
*
* @param string $url URL.
* @return string
*/
protected function get_formatted_url( $url ) {
@ -158,8 +153,10 @@ class WC_Auth {
* Make validation.
*
* @since 2.4.0
* @throws Exception When validate fails.
*/
protected function make_validation() {
$data = array();
$params = array(
'app_name',
'user_id',
@ -169,19 +166,21 @@ class WC_Auth {
);
foreach ( $params as $param ) {
if ( empty( $_REQUEST[ $param ] ) ) {
if ( empty( $_REQUEST[ $param ] ) ) { // WPCS: input var ok, CSRF ok.
/* translators: %s: parameter */
throw new Exception( sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param ) );
}
$data[ $param ] = wp_unslash( $_REQUEST[ $param ] ); // WPCS: input var ok, CSRF ok, sanitization ok.
}
if ( ! in_array( $_REQUEST['scope'], array( 'read', 'write', 'read_write' ) ) ) {
if ( ! in_array( $data['scope'], array( 'read', 'write', 'read_write' ), true ) ) {
/* translators: %s: scope */
throw new Exception( sprintf( __( 'Invalid scope %s', 'woocommerce' ), wc_clean( $_REQUEST['scope'] ) ) );
throw new Exception( sprintf( __( 'Invalid scope %s', 'woocommerce' ), wc_clean( $data['scope'] ) ) );
}
foreach ( array( 'return_url', 'callback_url' ) as $param ) {
$param = $this->get_formatted_url( $_REQUEST[ $param ] );
$param = $this->get_formatted_url( $data[ $param ] );
if ( false === filter_var( $param, FILTER_VALIDATE_URL ) ) {
/* translators: %s: url */
@ -189,7 +188,7 @@ class WC_Auth {
}
}
$callback_url = $this->get_formatted_url( $_REQUEST['callback_url'] );
$callback_url = $this->get_formatted_url( $data['callback_url'] );
if ( 0 !== stripos( $callback_url, 'https://' ) ) {
throw new Exception( __( 'The callback_url needs to be over SSL', 'woocommerce' ) );
@ -201,17 +200,17 @@ class WC_Auth {
*
* @since 2.4.0
*
* @param string $app_name
* @param string $app_user_id
* @param string $scope
* @param string $app_name App name.
* @param string $app_user_id User ID.
* @param string $scope Scope.
*
* @return array
*/
protected function create_keys( $app_name, $app_user_id, $scope ) {
global $wpdb;
/* translators: 1: app name 2: scope 3: date 4: time */
$description = sprintf(
/* translators: 1: app name 2: scope 3: date 4: time */
__( '%1$s - API %2$s (created on %3$s at %4$s).', 'woocommerce' ),
wc_clean( $app_name ),
$this->get_i18n_scope( $scope ),
@ -221,7 +220,7 @@ class WC_Auth {
$user = wp_get_current_user();
// Created API keys.
$permissions = ( in_array( $scope, array( 'read', 'write', 'read_write' ) ) ) ? sanitize_text_field( $scope ) : 'read';
$permissions = in_array( $scope, array( 'read', 'write', 'read_write' ), true ) ? sanitize_text_field( $scope ) : 'read';
$consumer_key = 'ck_' . wc_rand_hash();
$consumer_secret = 'cs_' . wc_rand_hash();
@ -259,17 +258,16 @@ class WC_Auth {
*
* @since 2.4.0
*
* @param array $consumer_data
* @param string $url
*
* @throws Exception When validation fails.
* @param array $consumer_data Consumer data.
* @param string $url URL.
* @return bool
* @throws Exception
*/
protected function post_consumer_data( $consumer_data, $url ) {
$params = array(
'body' => json_encode( $consumer_data ),
'timeout' => 60,
'headers' => array(
'body' => wp_json_encode( $consumer_data ),
'timeout' => 60,
'headers' => array(
'Content-Type' => 'application/json;charset=' . get_bloginfo( 'charset' ),
),
);
@ -278,7 +276,7 @@ class WC_Auth {
if ( is_wp_error( $response ) ) {
throw new Exception( $response->get_error_message() );
} elseif ( 200 != $response['response']['code'] ) {
} elseif ( 200 !== intval( $response['response']['code'] ) ) {
throw new Exception( __( 'An error occurred in the request and at the time were unable to send the consumer data', 'woocommerce' ) );
}
@ -293,15 +291,15 @@ class WC_Auth {
public function handle_auth_requests() {
global $wp;
if ( ! empty( $_GET['wc-auth-version'] ) ) {
$wp->query_vars['wc-auth-version'] = $_GET['wc-auth-version'];
if ( ! empty( $_GET['wc-auth-version'] ) ) { // WPCS: input var ok, CSRF ok.
$wp->query_vars['wc-auth-version'] = wc_clean( wp_unslash( $_GET['wc-auth-version'] ) ); // WPCS: input var ok, CSRF ok.
}
if ( ! empty( $_GET['wc-auth-route'] ) ) {
$wp->query_vars['wc-auth-route'] = $_GET['wc-auth-route'];
$wp->query_vars['wc-auth-route'] = wc_clean( wp_unslash( $_GET['wc-auth-route'] ) ); // WPCS: input var ok, CSRF ok.
}
// wc-auth endpoint requests
// wc-auth endpoint requests.
if ( ! empty( $wp->query_vars['wc-auth-version'] ) && ! empty( $wp->query_vars['wc-auth-route'] ) ) {
$this->auth_endpoint( $wp->query_vars['wc-auth-route'] );
}
@ -311,8 +309,8 @@ class WC_Auth {
* Auth endpoint.
*
* @since 2.4.0
*
* @param string $route
* @throws Exception When validation fails.
* @param string $route Route.
*/
protected function auth_endpoint( $route ) {
ob_start();
@ -327,50 +325,74 @@ class WC_Auth {
$route = strtolower( wc_clean( $route ) );
$this->make_validation();
// Login endpoint
if ( 'login' == $route && ! is_user_logged_in() ) {
wc_get_template( 'auth/form-login.php', array(
'app_name' => $_REQUEST['app_name'],
'return_url' => add_query_arg( array( 'success' => 0, 'user_id' => wc_clean( $_REQUEST['user_id'] ) ), $this->get_formatted_url( $_REQUEST['return_url'] ) ),
'redirect_url' => $this->build_url( $_REQUEST, 'authorize' ),
) );
$data = wp_unslash( $_REQUEST ); // WPCS: input var ok, CSRF ok.
// Login endpoint.
if ( 'login' === $route && ! is_user_logged_in() ) {
wc_get_template(
'auth/form-login.php', array(
'app_name' => wc_clean( $data['app_name'] ),
'return_url' => add_query_arg(
array(
'success' => 0,
'user_id' => wc_clean( $data['user_id'] ),
), $this->get_formatted_url( $data['return_url'] )
),
'redirect_url' => $this->build_url( $data, 'authorize' ),
)
);
exit;
// Redirect with user is logged in
} elseif ( 'login' == $route && is_user_logged_in() ) {
wp_redirect( esc_url_raw( $this->build_url( $_REQUEST, 'authorize' ) ) );
} elseif ( 'login' === $route && is_user_logged_in() ) {
// Redirect with user is logged in.
wp_redirect( esc_url_raw( $this->build_url( $data, 'authorize' ) ) );
exit;
// Redirect with user is not logged in and trying to access the authorize endpoint
} elseif ( 'authorize' == $route && ! is_user_logged_in() ) {
wp_redirect( esc_url_raw( $this->build_url( $_REQUEST, 'login' ) ) );
} elseif ( 'authorize' === $route && ! is_user_logged_in() ) {
// Redirect with user is not logged in and trying to access the authorize endpoint.
wp_redirect( esc_url_raw( $this->build_url( $data, 'login' ) ) );
exit;
// Authorize endpoint
} elseif ( 'authorize' == $route && current_user_can( 'manage_woocommerce' ) ) {
wc_get_template( 'auth/form-grant-access.php', array(
'app_name' => $_REQUEST['app_name'],
'return_url' => add_query_arg( array( 'success' => 0, 'user_id' => wc_clean( $_REQUEST['user_id'] ) ), $this->get_formatted_url( $_REQUEST['return_url'] ) ),
'scope' => $this->get_i18n_scope( wc_clean( $_REQUEST['scope'] ) ),
'permissions' => $this->get_permissions_in_scope( wc_clean( $_REQUEST['scope'] ) ),
'granted_url' => wp_nonce_url( $this->build_url( $_REQUEST, 'access_granted' ), 'wc_auth_grant_access', 'wc_auth_nonce' ),
'logout_url' => wp_logout_url( $this->build_url( $_REQUEST, 'login' ) ),
'user' => wp_get_current_user(),
) );
} elseif ( 'authorize' === $route && current_user_can( 'manage_woocommerce' ) ) {
// Authorize endpoint.
wc_get_template(
'auth/form-grant-access.php', array(
'app_name' => wc_clean( $data['app_name'] ),
'return_url' => add_query_arg(
array(
'success' => 0,
'user_id' => wc_clean( $data['user_id'] ),
), $this->get_formatted_url( $data['return_url'] )
),
'scope' => $this->get_i18n_scope( wc_clean( $data['scope'] ) ),
'permissions' => $this->get_permissions_in_scope( wc_clean( $data['scope'] ) ),
'granted_url' => wp_nonce_url( $this->build_url( $data, 'access_granted' ), 'wc_auth_grant_access', 'wc_auth_nonce' ),
'logout_url' => wp_logout_url( $this->build_url( $data, 'login' ) ),
'user' => wp_get_current_user(),
)
);
exit;
// Granted access endpoint
} elseif ( 'access_granted' == $route && current_user_can( 'manage_woocommerce' ) ) {
if ( ! isset( $_GET['wc_auth_nonce'] ) || ! wp_verify_nonce( $_GET['wc_auth_nonce'], 'wc_auth_grant_access' ) ) {
} elseif ( 'access_granted' === $route && current_user_can( 'manage_woocommerce' ) ) {
// Granted access endpoint.
if ( ! isset( $_GET['wc_auth_nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['wc_auth_nonce'] ) ), 'wc_auth_grant_access' ) ) { // WPCS: input var ok.
throw new Exception( __( 'Invalid nonce verification', 'woocommerce' ) );
}
$consumer_data = $this->create_keys( $_REQUEST['app_name'], $_REQUEST['user_id'], $_REQUEST['scope'] );
$response = $this->post_consumer_data( $consumer_data, $this->get_formatted_url( $_REQUEST['callback_url'] ) );
$consumer_data = $this->create_keys( $data['app_name'], $data['user_id'], $data['scope'] );
$response = $this->post_consumer_data( $consumer_data, $this->get_formatted_url( $data['callback_url'] ) );
if ( $response ) {
wp_redirect( esc_url_raw( add_query_arg( array( 'success' => 1, 'user_id' => wc_clean( $_REQUEST['user_id'] ) ), $this->get_formatted_url( $_REQUEST['return_url'] ) ) ) );
wp_redirect(
esc_url_raw(
add_query_arg(
array(
'success' => 1,
'user_id' => wc_clean( $data['user_id'] ),
), $this->get_formatted_url( $data['return_url'] )
)
)
);
exit;
}
} else {
@ -380,7 +402,7 @@ class WC_Auth {
$this->maybe_delete_key( $consumer_data );
/* translators: %s: error message */
wp_die( sprintf( __( 'Error: %s.', 'woocommerce' ), $e->getMessage() ), __( 'Access denied', 'woocommerce' ), array( 'response' => 401 ) );
wp_die( sprintf( esc_html__( 'Error: %s.', 'woocommerce' ), esc_html( $e->getMessage() ) ), esc_html__( 'Access denied', 'woocommerce' ), array( 'response' => 401 ) );
}
}
@ -389,7 +411,7 @@ class WC_Auth {
*
* @since 2.4.0
*
* @param array $key
* @param array $key Key.
*/
private function maybe_delete_key( $key ) {
global $wpdb;

View File

@ -1,16 +1,15 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WooCommerce Autoloader.
*
* @class WC_Autoloader
* @version 2.3.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 2.3.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Autoloader class.
*/
class WC_Autoloader {
@ -25,8 +24,8 @@ class WC_Autoloader {
* The Constructor.
*/
public function __construct() {
if ( function_exists( "__autoload" ) ) {
spl_autoload_register( "__autoload" );
if ( function_exists( '__autoload' ) ) {
spl_autoload_register( '__autoload' );
}
spl_autoload_register( array( $this, 'autoload' ) );
@ -37,7 +36,7 @@ class WC_Autoloader {
/**
* Take a class name and turn it into a file name.
*
* @param string $class
* @param string $class Class name.
* @return string
*/
private function get_file_name_from_class( $class ) {
@ -47,12 +46,12 @@ class WC_Autoloader {
/**
* Include a class file.
*
* @param string $path
* @return bool successful or not
* @param string $path File path.
* @return bool Successful or not.
*/
private function load_file( $path ) {
if ( $path && is_readable( $path ) ) {
include_once( $path );
include_once $path;
return true;
}
return false;
@ -61,7 +60,7 @@ class WC_Autoloader {
/**
* Auto-load WC classes on demand to reduce memory consumption.
*
* @param string $class
* @param string $class Class name.
*/
public function autoload( $class ) {
$class = strtolower( $class );
@ -70,14 +69,14 @@ class WC_Autoloader {
return;
}
$file = $this->get_file_name_from_class( $class );
$path = '';
$file = $this->get_file_name_from_class( $class );
$path = '';
if ( 0 === strpos( $class, 'wc_addons_gateway_' ) ) {
if ( 0 === strpos( $class, 'wc_addons_gateway_' ) ) {
$path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 18 ) . '/';
} elseif ( 0 === strpos( $class, 'wc_gateway_' ) ) {
} elseif ( 0 === strpos( $class, 'wc_gateway_' ) ) {
$path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 11 ) . '/';
} elseif ( 0 === strpos( $class, 'wc_shipping_' ) ) {
} elseif ( 0 === strpos( $class, 'wc_shipping_' ) ) {
$path = $this->include_path . 'shipping/' . substr( str_replace( '_', '-', $class ), 12 ) . '/';
} elseif ( 0 === strpos( $class, 'wc_shortcode_' ) ) {
$path = $this->include_path . 'shortcodes/';

View File

@ -2,13 +2,11 @@
/**
* Background Emailer
*
* @version 3.0.1
* @package WooCommerce/Classes
* @version 3.0.1
* @package WooCommerce/Classes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WC_Background_Process', false ) ) {
include_once dirname( __FILE__ ) . '/abstracts/class-wc-background-process.php';
@ -59,7 +57,7 @@ class WC_Background_Emailer extends WC_Background_Process {
WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] );
} catch ( Exception $e ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING );
trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
}
}
}
@ -89,7 +87,7 @@ class WC_Background_Emailer extends WC_Background_Process {
if ( ! headers_sent() ) {
header( 'Connection: close' );
}
@ob_end_flush();
@ob_end_flush(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
flush();
}
}
@ -117,7 +115,7 @@ class WC_Background_Emailer extends WC_Background_Process {
// Pass cookies through with the request so nonces function.
$cookies = array();
foreach ( $_COOKIE as $name => $value ) {
foreach ( $_COOKIE as $name => $value ) { // WPCS: input var ok.
if ( 'PHPSESSID' === $name ) {
continue;
}

View File

@ -2,13 +2,11 @@
/**
* Background Updater
*
* @version 2.6.0
* @package WooCommerce/Classes
* @version 2.6.0
* @package WooCommerce/Classes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WC_Background_Process', false ) ) {
include_once dirname( __FILE__ ) . '/abstracts/class-wc-background-process.php';

View File

@ -1,17 +1,15 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC_Breadcrumb class.
*
* @class WC_Breadcrumb
* @version 2.3.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 2.3.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Breadcrumb class.
*/
class WC_Breadcrumb {
@ -25,8 +23,8 @@ class WC_Breadcrumb {
/**
* Add a crumb so we don't get lost.
*
* @param string $name
* @param string $link
* @param string $name Name.
* @param string $link Link.
*/
public function add_crumb( $name, $link = '' ) {
$this->crumbs[] = array(
@ -99,14 +97,14 @@ class WC_Breadcrumb {
$shop_page_id = wc_get_page_id( 'shop' );
$shop_page = get_post( $shop_page_id );
// If permalinks contain the shop page in the URI prepend the breadcrumb with shop
if ( $shop_page_id && $shop_page && isset( $permalinks['product_base'] ) && strstr( $permalinks['product_base'], '/' . $shop_page->post_name ) && get_option( 'page_on_front' ) != $shop_page_id ) {
// If permalinks contain the shop page in the URI prepend the breadcrumb with shop.
if ( $shop_page_id && $shop_page && isset( $permalinks['product_base'] ) && strstr( $permalinks['product_base'], '/' . $shop_page->post_name ) && intval( get_option( 'page_on_front' ) ) !== $shop_page_id ) {
$this->add_crumb( get_the_title( $shop_page ), get_permalink( $shop_page ) );
}
}
/**
* is home trail.
* Is home trail..
*/
private function add_crumbs_home() {
$this->add_crumb( single_post_title( '', false ) );
@ -120,7 +118,7 @@ class WC_Breadcrumb {
}
/**
* attachment trail.
* Attachment trail.
*/
private function add_crumbs_attachment() {
global $post;
@ -132,23 +130,27 @@ class WC_Breadcrumb {
/**
* Single post trail.
*
* @param int $post_id
* @param string $permalink
* @param int $post_id Post ID.
* @param string $permalink Post permalink.
*/
private function add_crumbs_single( $post_id = 0, $permalink = '' ) {
if ( ! $post_id ) {
global $post;
} else {
$post = get_post( $post_id );
$post = get_post( $post_id ); // WPCS: override ok.
}
if ( 'product' === get_post_type( $post ) ) {
$this->prepend_shop_page();
$terms = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_breadcrumb_product_terms_args', array(
'orderby' => 'parent',
'order' => 'DESC',
) ) );
$terms = wc_get_product_terms(
$post->ID, 'product_cat', apply_filters(
'woocommerce_breadcrumb_product_terms_args', array(
'orderby' => 'parent',
'order' => 'DESC',
)
)
);
if ( $terms ) {
$main_term = apply_filters( 'woocommerce_breadcrumb_main_term', $terms[0], $terms );
@ -183,8 +185,8 @@ class WC_Breadcrumb {
$parent_id = $post->post_parent;
while ( $parent_id ) {
$page = get_post( $parent_id );
$parent_id = $page->post_parent;
$page = get_post( $parent_id );
$parent_id = $page->post_parent;
$parent_crumbs[] = array( get_the_title( $page->ID ), get_permalink( $page->ID ) );
}
@ -217,6 +219,8 @@ class WC_Breadcrumb {
$current_term = $GLOBALS['wp_query']->get_queried_object();
$this->prepend_shop_page();
/* translators: %s: product tag */
$this->add_crumb( sprintf( __( 'Products tagged &ldquo;%s&rdquo;', 'woocommerce' ), $current_term->name ) );
}
@ -224,7 +228,7 @@ class WC_Breadcrumb {
* Shop breadcrumb.
*/
private function add_crumbs_shop() {
if ( get_option( 'page_on_front' ) == wc_get_page_id( 'shop' ) ) {
if ( intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) {
return;
}
@ -232,7 +236,7 @@ class WC_Breadcrumb {
if ( ! $_name ) {
$product_post_type = get_post_type_object( 'product' );
$_name = $product_post_type->labels->singular_name;
$_name = $product_post_type->labels->singular_name;
}
$this->add_crumb( $_name, get_post_type_archive_link( 'product' ) );
@ -255,7 +259,7 @@ class WC_Breadcrumb {
private function add_crumbs_category() {
$this_category = get_category( $GLOBALS['wp_query']->get_queried_object() );
if ( 0 != $this_category->parent ) {
if ( 0 !== intval( $this_category->parent ) ) {
$this->term_ancestors( $this_category->term_id, 'category' );
}
@ -267,6 +271,8 @@ class WC_Breadcrumb {
*/
private function add_crumbs_tag() {
$queried_object = $GLOBALS['wp_query']->get_queried_object();
/* translators: %s: tag name */
$this->add_crumb( sprintf( __( 'Posts tagged &ldquo;%s&rdquo;', 'woocommerce' ), single_tag_title( '', false ) ), get_tag_link( $queried_object->term_id ) );
}
@ -294,7 +300,7 @@ class WC_Breadcrumb {
$this->add_crumb( $taxonomy->labels->name );
if ( 0 != $this_term->parent ) {
if ( 0 !== intval( $this_term->parent ) ) {
$this->term_ancestors( $this_term->term_id, $this_term->taxonomy );
}
@ -308,14 +314,16 @@ class WC_Breadcrumb {
global $author;
$userdata = get_userdata( $author );
/* translators: %s: author name */
$this->add_crumb( sprintf( __( 'Author: %s', 'woocommerce' ), $userdata->display_name ) );
}
/**
* Add crumbs for a term.
*
* @param int $term_id
* @param string $taxonomy
* @param int $term_id Term ID.
* @param string $taxonomy Taxonomy.
*/
private function term_ancestors( $term_id, $taxonomy ) {
$ancestors = get_ancestors( $term_id, $taxonomy );
@ -334,8 +342,10 @@ class WC_Breadcrumb {
* Endpoints.
*/
private function endpoint_trail() {
// Is an endpoint showing?
if ( is_wc_endpoint_url() && ( $endpoint = WC()->query->get_current_endpoint() ) && ( $endpoint_title = WC()->query->get_endpoint_title( $endpoint ) ) ) {
$endpoint = is_wc_endpoint_url() ? WC()->query->get_current_endpoint() : '';
$endpoint_title = $endpoint ? WC()->query->get_endpoint_title( $endpoint ) : '';
if ( $endpoint_title ) {
$this->add_crumb( $endpoint_title );
}
}
@ -345,6 +355,7 @@ class WC_Breadcrumb {
*/
private function search_trail() {
if ( is_search() ) {
/* translators: %s: search term */
$this->add_crumb( sprintf( __( 'Search results for &ldquo;%s&rdquo;', 'woocommerce' ), get_search_query() ), remove_query_arg( 'paged' ) );
}
}
@ -354,6 +365,7 @@ class WC_Breadcrumb {
*/
private function paged_trail() {
if ( get_query_var( 'paged' ) ) {
/* translators: %d: page number */
$this->add_crumb( sprintf( __( 'Page %d', 'woocommerce' ), get_query_var( 'paged' ) ) );
}
}

View File

@ -2,16 +2,10 @@
/**
* WC_Cache_Helper class.
*
* @class WC_Cache_Helper
* @version 2.2.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WC_Cache_Helper.
@ -26,6 +20,8 @@ class WC_Cache_Helper {
add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
add_action( 'delete_version_transients', array( __CLASS__, 'delete_version_transients' ) );
add_action( 'wp', array( __CLASS__, 'prevent_caching' ) );
add_action( 'clean_term_cache', array( __CLASS__, 'clean_term_cache' ), 10, 2 );
add_action( 'edit_terms', array( __CLASS__, 'clean_term_cache' ), 10, 2 );
}
/**
@ -93,7 +89,7 @@ class WC_Cache_Helper {
public static function geolocation_ajax_redirect() {
if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && ! is_checkout() && ! is_cart() && ! is_account_page() && ! is_ajax() && empty( $_POST ) ) { // WPCS: CSRF ok, input var ok.
$location_hash = self::geolocation_ajax_get_location_hash();
$current_hash = isset( $_GET['v'] ) ? wc_clean( wp_unslash( $_GET['v'] ) ) : ''; // WPCS: sanitization ok, input var ok.
$current_hash = isset( $_GET['v'] ) ? wc_clean( wp_unslash( $_GET['v'] ) ) : ''; // WPCS: sanitization ok, input var ok, CSRF ok.
if ( empty( $current_hash ) || $current_hash !== $location_hash ) {
global $wp;
@ -141,7 +137,10 @@ class WC_Cache_Helper {
if ( false === $transient_value || true === $refresh ) {
self::delete_version_transients( $transient_value );
set_transient( $transient_name, $transient_value = time() );
$transient_value = time();
set_transient( $transient_name, $transient_value );
}
return $transient_value;
}
@ -196,11 +195,42 @@ class WC_Cache_Helper {
if ( $enabled && ! in_array( '_wc_session_', $settings, true ) ) {
?>
<div class="error">
<p><?php echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with WooCommerce you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'woocommerce' ), '<code>_wc_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) ); ?></p>
<p>
<?php
/* translators: 1: key 2: URL */
echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with WooCommerce you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'woocommerce' ), '<code>_wc_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) );
?>
</p>
</div>
<?php
}
}
/**
* Clean term caches added by WooCommerce.
*
* @since 3.3.4
* @param array|int $ids Array of ids or single ID to clear cache for.
* @param string $taxonomy Taxonomy name.
*/
public static function clean_term_cache( $ids, $taxonomy ) {
if ( 'product_cat' === $taxonomy ) {
$ids = is_array( $ids ) ? $ids : array( $ids );
$clear_ids = array();
foreach ( $ids as $id ) {
$clear_ids[] = $id;
$clear_ids = array_merge( $clear_ids, get_ancestors( $id, 'product_cat', 'taxonomy' ) );
}
$clear_ids = array_unique( $clear_ids );
foreach ( $clear_ids as $id ) {
wp_cache_delete( 'product-category-hierarchy-' . $id, 'product_cat' );
}
}
}
}
WC_Cache_Helper::init();

View File

@ -6,13 +6,11 @@
*
* We suggest using the action woocommerce_cart_calculate_fees hook for adding fees.
*
* @author Automattic
* @package WooCommerce/Classes
* @version 3.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WC_Cart_Fees class.
@ -80,7 +78,7 @@ final class WC_Cart_Fees {
public function add_fee( $args = array() ) {
$fee_props = (object) wp_parse_args( $args, $this->default_fee_props );
$fee_props->name = $fee_props->name ? $fee_props->name : __( 'Fee', 'woocommerce' );
$fee_props->tax_class = in_array( $fee_props->tax_class, array_merge( WC_Tax::get_tax_classes(), WC_Tax::get_tax_class_slugs() ), true ) ? $fee_props->tax_class: '';
$fee_props->tax_class = in_array( $fee_props->tax_class, array_merge( WC_Tax::get_tax_classes(), WC_Tax::get_tax_class_slugs() ), true ) ? $fee_props->tax_class : '';
$fee_props->taxable = wc_string_to_bool( $fee_props->taxable );
$fee_props->amount = wc_format_decimal( $fee_props->amount );
@ -92,7 +90,9 @@ final class WC_Cart_Fees {
return new WP_Error( 'fee_exists', __( 'Fee has already been added.', 'woocommerce' ) );
}
return $this->fees[ $fee_props->id ] = $fee_props;
$this->fees[ $fee_props->id ] = $fee_props;
return $this->fees[ $fee_props->id ];
}
/**

View File

@ -2,8 +2,8 @@
/**
* Cart session handling class.
*
* @author Automattic
* @package WooCommerce/Classes
* @version 3.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -105,7 +105,7 @@ final class WC_Cart_Session {
wc_add_notice( sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'woocommerce' ), $product->get_name() ), 'error' );
do_action( 'woocommerce_remove_cart_item_from_session', $key, $values );
} elseif ( ! empty( $values['data_hash'] ) && ! hash_equals( $values['data_hash'], wc_get_cart_item_data_hash( $product ) ) ) {
} elseif ( ! empty( $values['data_hash'] ) && ! hash_equals( $values['data_hash'], wc_get_cart_item_data_hash( $product ) ) ) { // phpcs:ignore PHPCompatibility.PHP.NewFunctions.hash_equalsFound
$update_cart_session = true;
/* translators: %1$s: product name. %2$s product permalink */
wc_add_notice( sprintf( __( '%1$s has been removed from your cart because it has since been modified. You can add it back to your cart <a href="%2$s">here</a>.', 'woocommerce' ), $product->get_name(), $product->get_permalink() ), 'notice' );
@ -113,9 +113,11 @@ final class WC_Cart_Session {
} else {
// Put session data into array. Run through filter so other plugins can load their own session data.
$session_data = array_merge( $values, array(
'data' => $product,
) );
$session_data = array_merge(
$values, array(
'data' => $product,
)
);
$cart_contents[ $key ] = apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key );
// Add to cart right away so the product is visible in woocommerce_get_cart_item_from_session hook.
@ -157,7 +159,7 @@ final class WC_Cart_Session {
if ( ! headers_sent() && did_action( 'wp_loaded' ) ) {
if ( ! $this->cart->is_empty() ) {
$this->set_cart_cookies( true );
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) { // WPCS: input var ok.
$this->set_cart_cookies( false );
}
}
@ -198,9 +200,11 @@ final class WC_Cart_Session {
*/
public function persistent_cart_update() {
if ( get_current_user_id() && apply_filters( 'woocommerce_persistent_cart_enabled', true ) ) {
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), array(
'cart' => $this->get_cart_for_session(),
) );
update_user_meta(
get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), array(
'cart' => $this->get_cart_for_session(),
)
);
}
}
@ -223,7 +227,7 @@ final class WC_Cart_Session {
if ( $set ) {
wc_setcookie( 'woocommerce_items_in_cart', 1 );
wc_setcookie( 'woocommerce_cart_hash', md5( wp_json_encode( $this->get_cart_for_session() ) ) );
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) { // WPCS: input var ok.
wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS );
wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS );
}

View File

@ -9,8 +9,8 @@
* - if something is being stored e.g. item total, store unrounded. This is so taxes can be recalculated later accurately.
* - if calculating a total, round (if settings allow).
*
* @author Automattic
* @package WooCommerce/Classes
* @version 3.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -102,16 +102,16 @@ final class WC_Cart_Totals {
* @var array
*/
protected $totals = array(
'fees_total' => 0,
'fees_total_tax' => 0,
'items_subtotal' => 0,
'items_subtotal_tax' => 0,
'items_total' => 0,
'items_total_tax' => 0,
'total' => 0,
'shipping_total' => 0,
'shipping_tax_total' => 0,
'discounts_total' => 0,
'fees_total' => 0,
'fees_total_tax' => 0,
'items_subtotal' => 0,
'items_subtotal_tax' => 0,
'items_total' => 0,
'items_total_tax' => 0,
'total' => 0,
'shipping_total' => 0,
'shipping_tax_total' => 0,
'discounts_total' => 0,
);
/**
@ -212,7 +212,7 @@ final class WC_Cart_Totals {
* into the same format for use by this class.
*
* Each item is made up of the following props, in addition to those returned by get_default_item_props() for totals.
* - key: An identifier for the item (cart item key or line item ID).
* - key: An identifier for the item (cart item key or line item ID).
* - cart_item: For carts, the cart item from the cart which may include custom data.
* - quantity: The qty for this line.
* - price: The line price in cents.
@ -312,13 +312,12 @@ final class WC_Cart_Totals {
$fee->taxes = wc_array_merge_recursive_numeric( $fee->taxes, WC_Tax::calc_tax( $fee->total * $proportion, WC_Tax::get_rates( $tax_class ) ) );
}
}
} elseif ( $fee->object->taxable ) {
$fee->taxes = WC_Tax::calc_tax( $fee->total, WC_Tax::get_rates( $fee->tax_class, $this->cart->get_customer() ), false );
}
}
$fee->taxes = apply_filters( 'woocommerce_cart_totals_get_fees_from_cart_taxes', $fee->taxes, $fee, $this );
$fee->taxes = apply_filters( 'woocommerce_cart_totals_get_fees_from_cart_taxes', $fee->taxes, $fee, $this );
$fee->total_tax = array_sum( array_map( array( $this, 'round_line_tax' ), $fee->taxes ) );
// Set totals within object.
@ -366,13 +365,13 @@ final class WC_Cart_Totals {
foreach ( $this->coupons as $coupon ) {
switch ( $coupon->get_discount_type() ) {
case 'fixed_product' :
case 'fixed_product':
$coupon->sort = 1;
break;
case 'percent' :
case 'percent':
$coupon->sort = 2;
break;
case 'fixed_cart' :
case 'fixed_cart':
$coupon->sort = 3;
break;
default:
@ -391,7 +390,7 @@ final class WC_Cart_Totals {
* Sort coupons so discounts apply consistently across installs.
*
* In order of priority;
* - sort param
* - sort param
* - usage restriction
* - coupon value
* - ID
@ -422,10 +421,10 @@ final class WC_Cart_Totals {
*/
protected function remove_item_base_taxes( $item ) {
if ( $item->price_includes_tax && $item->taxable ) {
$base_tax_rates = WC_Tax::get_base_tax_rates( $item->product->get_tax_class( 'unfiltered' ) );
$base_tax_rates = WC_Tax::get_base_tax_rates( $item->product->get_tax_class( 'unfiltered' ) );
// Work out a new base price without the shop's base tax.
$taxes = WC_Tax::calc_tax( $item->price, $base_tax_rates, true );
$taxes = WC_Tax::calc_tax( $item->price, $base_tax_rates, true );
// Now we have a new item price (excluding TAX).
$item->price = round( $item->price - array_sum( $taxes ) );
@ -452,11 +451,11 @@ final class WC_Cart_Totals {
if ( $item->tax_rates !== $base_tax_rates ) {
// Work out a new base price without the shop's base tax.
$taxes = WC_Tax::calc_tax( $item->price, $base_tax_rates, true );
$new_taxes = WC_Tax::calc_tax( $item->price - array_sum( $taxes ), $item->tax_rates, false );
$taxes = WC_Tax::calc_tax( $item->price, $base_tax_rates, true );
$new_taxes = WC_Tax::calc_tax( $item->price - array_sum( $taxes ), $item->tax_rates, false );
// Now we have a new item price.
$item->price = $item->price - array_sum( $taxes ) + array_sum( $new_taxes );
$item->price = round( $item->price - array_sum( $taxes ) + array_sum( $new_taxes ) );
}
}
return $item;
@ -551,7 +550,8 @@ final class WC_Cart_Totals {
* Get taxes merged by type.
*
* @since 3.2.0
* @param array|string $types Types to merge and return. Defaults to all.
* @param bool $in_cents If returned value should be in cents.
* @param array|string $types Types to merge and return. Defaults to all.
* @return array
*/
protected function get_merged_taxes( $in_cents = false, $types = array( 'items', 'fees', 'shipping' ) ) {
@ -584,7 +584,7 @@ final class WC_Cart_Totals {
* Combine item taxes into a single array, preserving keys.
*
* @since 3.2.0
* @param array $taxes Taxes to combine.
* @param array $item_taxes Taxes to combine.
* @return array
*/
protected function combine_item_taxes( $item_taxes ) {

View File

@ -5,18 +5,14 @@
* The WooCommerce cart class stores cart data and active coupons as well as handling customer sessions and some cart related urls.
* The cart class also has a price calculation function which calls upon other classes to calculate totals.
*
* @version 2.1.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
include_once( WC_ABSPATH . 'includes/legacy/class-wc-legacy-cart.php' );
include_once( WC_ABSPATH . 'includes/class-wc-cart-session.php' );
require_once WC_ABSPATH . 'includes/legacy/class-wc-legacy-cart.php';
require_once WC_ABSPATH . 'includes/class-wc-cart-session.php';
/**
* WC_Cart class.
@ -796,7 +792,8 @@ class WC_Cart extends WC_Legacy_Cart {
if ( get_option( 'woocommerce_hold_stock_minutes' ) > 0 && ! $product->backorders_allowed() ) {
$order_id = isset( WC()->session->order_awaiting_payment ) ? absint( WC()->session->order_awaiting_payment ) : 0;
$held_stock = $wpdb->get_var(
$wpdb->prepare( "
$wpdb->prepare(
"
SELECT SUM( order_item_meta.meta_value ) AS held_qty
FROM {$wpdb->posts} AS posts
LEFT JOIN {$wpdb->prefix}woocommerce_order_items as order_items ON posts.ID = order_items.order_id
@ -811,7 +808,7 @@ class WC_Cart extends WC_Legacy_Cart {
$product->get_stock_managed_by_id(),
$order_id
)
);
); // WPCS: unprepared SQL ok.
if ( $product->get_stock_quantity() < ( $held_stock + $product_qty_in_cart[ $product->get_stock_managed_by_id() ] ) ) {
/* translators: 1: product name 2: minutes */
@ -893,16 +890,16 @@ class WC_Cart extends WC_Legacy_Cart {
foreach ( $taxes as $key => $tax ) {
$code = WC_Tax::get_rate_code( $key );
if ( $code || $key === apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) ) {
if ( $code || apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) === $key ) {
if ( ! isset( $tax_totals[ $code ] ) ) {
$tax_totals[ $code ] = new stdClass();
$tax_totals[ $code ] = new stdClass();
$tax_totals[ $code ]->amount = 0;
}
$tax_totals[ $code ]->tax_rate_id = $key;
$tax_totals[ $code ]->is_compound = WC_Tax::is_compound( $key );
$tax_totals[ $code ]->label = WC_Tax::get_rate_label( $key );
$tax_totals[ $code ]->amount += wc_round_tax_total( $tax );
$tax_totals[ $code ]->formatted_amount = wc_price( wc_round_tax_total( $tax_totals[ $code ]->amount ) );
$tax_totals[ $code ]->tax_rate_id = $key;
$tax_totals[ $code ]->is_compound = WC_Tax::is_compound( $key );
$tax_totals[ $code ]->label = WC_Tax::get_rate_label( $key );
$tax_totals[ $code ]->amount += wc_round_tax_total( $tax );
$tax_totals[ $code ]->formatted_amount = wc_price( wc_round_tax_total( $tax_totals[ $code ]->amount ) );
}
}
@ -1055,10 +1052,10 @@ class WC_Cart extends WC_Legacy_Cart {
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id, $quantity );
// Generate a ID based on product ID, variation ID, variation data, and other cart item data.
$cart_id = $this->generate_cart_id( $product_id, $variation_id, $variation, $cart_item_data );
$cart_id = $this->generate_cart_id( $product_id, $variation_id, $variation, $cart_item_data );
// Find the cart item key in the existing cart.
$cart_item_key = $this->find_product_in_cart( $cart_id );
$cart_item_key = $this->find_product_in_cart( $cart_id );
// Force quantity to 1 if sold individually and check for existing item in cart.
if ( $product_data->is_sold_individually() ) {
@ -1077,6 +1074,7 @@ class WC_Cart extends WC_Legacy_Cart {
// Stock check - only check if we're managing stock and backorders are not allowed.
if ( ! $product_data->is_in_stock() ) {
/* translators: %s: product name */
throw new Exception( sprintf( __( 'You cannot add &quot;%s&quot; to the cart because the product is out of stock.', 'woocommerce' ), $product_data->get_name() ) );
}
@ -1090,12 +1088,15 @@ class WC_Cart extends WC_Legacy_Cart {
$products_qty_in_cart = $this->get_cart_item_quantities();
if ( isset( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ] ) && ! $product_data->has_enough_stock( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ] + $quantity ) ) {
throw new Exception( sprintf(
'<a href="%s" class="button wc-forward">%s</a> %s',
wc_get_cart_url(),
__( 'View Cart', 'woocommerce' ),
sprintf( __( 'You cannot add that amount to the cart &mdash; we have %1$s in stock and you already have %2$s in your cart.', 'woocommerce' ), wc_format_stock_quantity_for_display( $product_data->get_stock_quantity(), $product_data ), wc_format_stock_quantity_for_display( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ], $product_data ) )
) );
throw new Exception(
sprintf(
'<a href="%s" class="button wc-forward">%s</a> %s',
wc_get_cart_url(),
__( 'View Cart', 'woocommerce' ),
/* translators: 1: quantity in stock 2: current quantity */
sprintf( __( 'You cannot add that amount to the cart &mdash; we have %1$s in stock and you already have %2$s in your cart.', 'woocommerce' ), wc_format_stock_quantity_for_display( $product_data->get_stock_quantity(), $product_data ), wc_format_stock_quantity_for_display( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ], $product_data ) )
)
);
}
}
@ -1107,15 +1108,19 @@ class WC_Cart extends WC_Legacy_Cart {
$cart_item_key = $cart_id;
// Add item after merging with $cart_item_data - hook to allow plugins to modify cart item.
$this->cart_contents[ $cart_item_key ] = apply_filters( 'woocommerce_add_cart_item', array_merge( $cart_item_data, array(
'key' => $cart_item_key,
'product_id' => $product_id,
'variation_id' => $variation_id,
'variation' => $variation,
'quantity' => $quantity,
'data' => $product_data,
'data_hash' => wc_get_cart_item_data_hash( $product_data ),
) ), $cart_item_key );
$this->cart_contents[ $cart_item_key ] = apply_filters(
'woocommerce_add_cart_item', array_merge(
$cart_item_data, array(
'key' => $cart_item_key,
'product_id' => $product_id,
'variation_id' => $variation_id,
'variation' => $variation,
'quantity' => $quantity,
'data' => $product_data,
'data_hash' => wc_get_cart_item_data_hash( $product_data ),
)
), $cart_item_key
);
}
do_action( 'woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data );
@ -1180,7 +1185,7 @@ class WC_Cart extends WC_Legacy_Cart {
/**
* Set the quantity for an item in the cart.
*
* @param string $cart_item_key contains the id of the cart item.
* @param string $cart_item_key contains the id of the cart item.
* @param int $quantity contains the quantity of the item.
* @param bool $refresh_totals whether or not to calculate totals after setting the new qty.
* @return bool
@ -1190,7 +1195,7 @@ class WC_Cart extends WC_Legacy_Cart {
do_action( 'woocommerce_before_cart_item_quantity_zero', $cart_item_key, $this );
unset( $this->cart_contents[ $cart_item_key ] );
} else {
$old_quantity = $this->cart_contents[ $cart_item_key ]['quantity'];
$old_quantity = $this->cart_contents[ $cart_item_key ]['quantity'];
$this->cart_contents[ $cart_item_key ]['quantity'] = $quantity;
do_action( 'woocommerce_after_cart_item_quantity_update', $cart_item_key, $quantity, $old_quantity, $this );
}
@ -1252,7 +1257,7 @@ class WC_Cart extends WC_Legacy_Cart {
$this->shipping_methods = $this->needs_shipping() ? $this->get_chosen_shipping_methods( WC()->shipping->calculate_shipping( $this->get_shipping_packages() ) ) : array();
$shipping_taxes = wp_list_pluck( $this->shipping_methods, 'taxes' );
$merged_taxes = array();
$merged_taxes = array();
foreach ( $shipping_taxes as $taxes ) {
foreach ( $taxes as $tax_id => $tax_amount ) {
if ( ! isset( $merged_taxes[ $tax_id ] ) ) {
@ -1280,7 +1285,7 @@ class WC_Cart extends WC_Legacy_Cart {
$chosen_methods = array();
// Get chosen methods for each package to get our totals.
foreach ( $calculated_shipping_packages as $key => $package ) {
$chosen_method = wc_get_chosen_shipping_method_for_package( $key, $package );
$chosen_method = wc_get_chosen_shipping_method_for_package( $key, $package );
if ( $chosen_method ) {
$chosen_methods[ $key ] = $package['rates'][ $chosen_method ];
}
@ -1324,7 +1329,8 @@ class WC_Cart extends WC_Legacy_Cart {
* @return array of cart items
*/
public function get_shipping_packages() {
return apply_filters( 'woocommerce_cart_shipping_packages',
return apply_filters(
'woocommerce_cart_shipping_packages',
array(
array(
'contents' => $this->get_items_needing_shipping(),
@ -1341,7 +1347,7 @@ class WC_Cart extends WC_Legacy_Cart {
'address' => $this->get_customer()->get_shipping_address(),
'address_2' => $this->get_customer()->get_shipping_address_2(),
),
'cart_subtotal' => $this->get_displayed_subtotal(),
'cart_subtotal' => $this->get_displayed_subtotal(),
),
)
);
@ -1445,10 +1451,18 @@ class WC_Cart extends WC_Legacy_Cart {
// Get user and posted emails to compare.
$current_user = wp_get_current_user();
$check_emails = array_unique( array_filter( array_map( 'strtolower', array_map( 'sanitize_email', array(
$posted['billing_email'],
$current_user->user_email,
) ) ) ) );
$check_emails = array_unique(
array_filter(
array_map(
'strtolower', array_map(
'sanitize_email', array(
$posted['billing_email'],
$current_user->user_email,
)
)
)
)
);
// Limit to defined email addresses.
$restrictions = $coupon->get_email_restrictions();
@ -1474,21 +1488,23 @@ class WC_Cart extends WC_Legacy_Cart {
}
// Check against billing emails of existing users.
$users_query = new WP_User_Query( array(
'fields' => 'ID',
'meta_query' => array(
array(
'key' => '_billing_email',
'value' => $check_emails,
'compare' => 'IN',
$users_query = new WP_User_Query(
array(
'fields' => 'ID',
'meta_query' => array(
array(
'key' => '_billing_email',
'value' => $check_emails,
'compare' => 'IN',
),
),
),
) );
)
); // WPCS: slow query ok.
$user_id_matches = array_unique( array_filter( array_merge( $user_id_matches, $users_query->get_results() ) ) );
foreach ( $user_id_matches as $user_id ) {
$usage_count += count( array_keys( $used_by, $user_id ) );
$usage_count += count( array_keys( $used_by, (string) $user_id, true ) );
}
if ( $usage_count >= $coupon->get_usage_limit_per_user() ) {
@ -1511,7 +1527,7 @@ class WC_Cart extends WC_Legacy_Cart {
foreach ( $check_emails as $check_email ) {
// With a direct match we return true.
if ( in_array( $check_email, $restrictions ) ) {
if ( in_array( $check_email, $restrictions, true ) ) {
return true;
}
@ -1545,7 +1561,7 @@ class WC_Cart extends WC_Legacy_Cart {
* Applies a coupon code passed to the method.
*
* @param string $coupon_code - The code to apply.
* @return bool True if the coupon is applied, false if it does not exist or cannot be applied.
* @return bool True if the coupon is applied, false if it does not exist or cannot be applied.
*/
public function apply_coupon( $coupon_code ) {
// Coupons are globally disabled.
@ -1615,7 +1631,7 @@ class WC_Cart extends WC_Legacy_Cart {
// Choose free shipping.
if ( $the_coupon->get_free_shipping() ) {
$packages = WC()->shipping->get_packages();
$packages = WC()->shipping->get_packages();
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
foreach ( $packages as $i => $package ) {
@ -1646,7 +1662,7 @@ class WC_Cart extends WC_Legacy_Cart {
}
foreach ( $this->get_applied_coupons() as $code ) {
$coupon = new WC_Coupon( $code );
$coupon = new WC_Coupon( $code );
$coupons[ $code ] = $coupon;
}
@ -1662,7 +1678,7 @@ class WC_Cart extends WC_Legacy_Cart {
*/
public function get_coupon_discount_amount( $code, $ex_tax = true ) {
$totals = $this->get_coupon_discount_totals();
$discount_amount = isset( $totals[ $code ] ) ? $totals[ $code ]: 0;
$discount_amount = isset( $totals[ $code ] ) ? $totals[ $code ] : 0;
if ( ! $ex_tax ) {
$discount_amount += $this->get_coupon_discount_tax_amount( $code );
@ -1701,8 +1717,8 @@ class WC_Cart extends WC_Legacy_Cart {
* @return bool
*/
public function remove_coupon( $coupon_code ) {
$coupon_code = wc_format_coupon_code( $coupon_code );
$position = array_search( $coupon_code, $this->get_applied_coupons(), true );
$coupon_code = wc_format_coupon_code( $coupon_code );
$position = array_search( $coupon_code, $this->get_applied_coupons(), true );
if ( false !== $position ) {
unset( $this->applied_coupons[ $position ] );
@ -1748,12 +1764,14 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $tax_class The tax class for the fee if taxable. A blank string is standard tax class. (default: '').
*/
public function add_fee( $name, $amount, $taxable = false, $tax_class = '' ) {
$this->fees_api()->add_fee( array(
'name' => $name,
'amount' => (float) $amount,
'taxable' => $taxable,
'tax_class' => $tax_class,
) );
$this->fees_api()->add_fee(
array(
'name' => $name,
'amount' => (float) $amount,
'taxable' => $taxable,
'tax_class' => $tax_class,
)
);
}
/**

View File

@ -1,18 +1,17 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main checkout class.
* Checkout functionality
*
* The WooCommerce checkout class handles the checkout process, collecting user data and processing the payment.
*
* @class WC_Checkout
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 3.4.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Checkout class.
*/
class WC_Checkout {
@ -32,6 +31,7 @@ class WC_Checkout {
/**
* Holds posted data for backwards compatibility.
*
* @var array
*/
protected $legacy_posted_data = array();
@ -60,32 +60,36 @@ class WC_Checkout {
/**
* See if variable is set. Used to support legacy public variables which are no longer defined.
*
* @param string $key
* @param string $key Key.
* @return bool
*/
public function __isset( $key ) {
return in_array( $key, array(
'enable_signup',
'enable_guest_checkout',
'must_create_account',
'checkout_fields',
'posted',
'shipping_method',
'payment_method',
'customer_id',
'shipping_methods',
) );
return in_array(
$key,
array(
'enable_signup',
'enable_guest_checkout',
'must_create_account',
'checkout_fields',
'posted',
'shipping_method',
'payment_method',
'customer_id',
'shipping_methods',
),
true
);
}
/**
* Sets the legacy public variables for backwards compatibility.
*
* @param string $key
* @param mixed $value
* @param string $key Key.
* @param mixed $value Value.
*/
public function __set( $key, $value ) {
switch ( $key ) {
case 'enable_signup' :
case 'enable_signup':
$bool_value = wc_string_to_bool( $value );
if ( $bool_value !== $this->is_registration_enabled() ) {
@ -94,7 +98,7 @@ class WC_Checkout {
add_filter( 'woocommerce_checkout_registration_enabled', $bool_value ? '__return_true' : '__return_false', 0 );
}
break;
case 'enable_guest_checkout' :
case 'enable_guest_checkout':
$bool_value = wc_string_to_bool( $value );
if ( $bool_value === $this->is_registration_required() ) {
@ -103,13 +107,13 @@ class WC_Checkout {
add_filter( 'woocommerce_checkout_registration_required', $bool_value ? '__return_false' : '__return_true', 0 );
}
break;
case 'checkout_fields' :
case 'checkout_fields':
$this->fields = $value;
break;
case 'shipping_methods' :
case 'shipping_methods':
WC()->session->set( 'chosen_shipping_methods', $value );
break;
case 'posted' :
case 'posted':
$this->legacy_posted_data = $value;
break;
}
@ -118,33 +122,32 @@ class WC_Checkout {
/**
* Gets the legacy public variables for backwards compatibility.
*
* @param string $key
*
* @param string $key Key.
* @return array|string
*/
public function __get( $key ) {
if ( in_array( $key, array( 'posted', 'shipping_method', 'payment_method' ) ) && empty( $this->legacy_posted_data ) ) {
if ( in_array( $key, array( 'posted', 'shipping_method', 'payment_method' ), true ) && empty( $this->legacy_posted_data ) ) {
$this->legacy_posted_data = $this->get_posted_data();
}
switch ( $key ) {
case 'enable_signup' :
case 'enable_signup':
return $this->is_registration_enabled();
case 'enable_guest_checkout' :
case 'enable_guest_checkout':
return ! $this->is_registration_required();
case 'must_create_account' :
case 'must_create_account':
return $this->is_registration_required() && ! is_user_logged_in();
case 'checkout_fields' :
case 'checkout_fields':
return $this->get_checkout_fields();
case 'posted' :
case 'posted':
wc_doing_it_wrong( 'WC_Checkout->posted', 'Use $_POST directly.', '3.0.0' );
return $this->legacy_posted_data;
case 'shipping_method' :
case 'shipping_method':
return $this->legacy_posted_data['shipping_method'];
case 'payment_method' :
case 'payment_method':
return $this->legacy_posted_data['payment_method'];
case 'customer_id' :
case 'customer_id':
return apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() );
case 'shipping_methods' :
case 'shipping_methods':
return (array) WC()->session->get( 'chosen_shipping_methods' );
}
}
@ -206,19 +209,19 @@ class WC_Checkout {
);
if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) {
$this->fields['account']['account_username'] = array(
'type' => 'text',
'label' => __( 'Account username', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Username', 'woocommerce' ),
'type' => 'text',
'label' => __( 'Account username', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Username', 'woocommerce' ),
);
}
if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) {
$this->fields['account']['account_password'] = array(
'type' => 'password',
'label' => __( 'Create account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
'type' => 'password',
'label' => __( 'Create account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
);
}
@ -254,29 +257,31 @@ class WC_Checkout {
/**
* Create an order. Error codes:
* 520 - Cannot insert order into the database.
* 521 - Cannot get order after creation.
* 522 - Cannot update order.
* 525 - Cannot create line item.
* 526 - Cannot create fee item.
* 527 - Cannot create shipping item.
* 528 - Cannot create tax item.
* 529 - Cannot create coupon item.
* 520 - Cannot insert order into the database.
* 521 - Cannot get order after creation.
* 522 - Cannot update order.
* 525 - Cannot create line item.
* 526 - Cannot create fee item.
* 527 - Cannot create shipping item.
* 528 - Cannot create tax item.
* 529 - Cannot create coupon item.
*
* @throws Exception
* @param $data Posted data.
* @throws Exception When checkout validation fails.
* @param array $data Posted data.
* @return int|WP_ERROR
*/
public function create_order( $data ) {
// Give plugins the opportunity to create an order themselves.
if ( $order_id = apply_filters( 'woocommerce_create_order', null, $this ) ) {
$order_id = apply_filters( 'woocommerce_create_order', null, $this );
if ( $order_id ) {
return $order_id;
}
try {
$order_id = absint( WC()->session->get( 'order_awaiting_payment' ) );
$cart_hash = md5( json_encode( wc_clean( WC()->cart->get_cart_for_session() ) ) . WC()->cart->total );
$cart_hash = md5( wp_json_encode( wc_clean( WC()->cart->get_cart_for_session() ) ) . WC()->cart->total );
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
$order = $order_id ? wc_get_order( $order_id ) : null;
/**
* If there is an order pending payment, we can resume it here so
@ -284,7 +289,7 @@ class WC_Checkout {
* different items or cost, create a new order. We use a hash to
* detect changes which is based on cart items + order total.
*/
if ( $order_id && ( $order = wc_get_order( $order_id ) ) && $order->has_cart_hash( $cart_hash ) && $order->has_status( array( 'pending', 'failed' ) ) ) {
if ( $order && $order->has_cart_hash( $cart_hash ) && $order->has_status( array( 'pending', 'failed' ) ) ) {
// Action for 3rd parties.
do_action( 'woocommerce_resume_order', $order_id );
@ -298,10 +303,10 @@ class WC_Checkout {
if ( is_callable( array( $order, "set_{$key}" ) ) ) {
$order->{"set_{$key}"}( $value );
// Store custom fields prefixed with wither shipping_ or billing_. This is for backwards compatibility with 2.6.x.
// TODO: Fix conditional to only include shipping/billing address fields in a smarter way without str(i)pos.
// Store custom fields prefixed with wither shipping_ or billing_. This is for backwards compatibility with 2.6.x.
// TODO: Fix conditional to only include shipping/billing address fields in a smarter way without str(i)pos.
} elseif ( ( 0 === stripos( $key, 'billing_' ) || 0 === stripos( $key, 'shipping_' ) )
&& ! in_array( $key, array( 'shipping_method', 'shipping_total', 'shipping_tax' ) ) ) {
&& ! in_array( $key, array( 'shipping_method', 'shipping_total', 'shipping_tax' ), true ) ) {
$order->update_meta_data( '_' . $key, $value );
}
}
@ -314,7 +319,7 @@ class WC_Checkout {
$order->set_customer_ip_address( WC_Geolocation::get_ip_address() );
$order->set_customer_user_agent( wc_get_user_agent() );
$order->set_customer_note( isset( $data['order_comments'] ) ? $data['order_comments'] : '' );
$order->set_payment_method( isset( $available_gateways[ $data['payment_method'] ] ) ? $available_gateways[ $data['payment_method'] ] : $data['payment_method'] );
$order->set_payment_method( isset( $available_gateways[ $data['payment_method'] ] ) ? $available_gateways[ $data['payment_method'] ] : $data['payment_method'] );
$order->set_shipping_total( WC()->cart->get_shipping_total() );
$order->set_discount_total( WC()->cart->get_discount_total() );
$order->set_discount_tax( WC()->cart->get_discount_tax() );
@ -329,6 +334,7 @@ class WC_Checkout {
/**
* Action hook to adjust order before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order', $order, $data );
@ -347,40 +353,46 @@ class WC_Checkout {
/**
* Add line items to the order.
*
* @param WC_Order $order
* @param WC_Cart $cart
* @param WC_Order $order Order instance.
* @param WC_Cart $cart Cart instance.
*/
public function create_order_line_items( &$order, $cart ) {
foreach ( $cart->get_cart() as $cart_item_key => $values ) {
/**
* Filter hook to get initial item object.
*
* @since 3.1.0
*/
$item = apply_filters( 'woocommerce_checkout_create_order_line_item_object', new WC_Order_Item_Product(), $cart_item_key, $values, $order );
$product = $values['data'];
$item->legacy_values = $values; // @deprecated For legacy actions.
$item->legacy_cart_item_key = $cart_item_key; // @deprecated For legacy actions.
$item->set_props( array(
'quantity' => $values['quantity'],
'variation' => $values['variation'],
'subtotal' => $values['line_subtotal'],
'total' => $values['line_total'],
'subtotal_tax' => $values['line_subtotal_tax'],
'total_tax' => $values['line_tax'],
'taxes' => $values['line_tax_data'],
) );
$item->set_props(
array(
'quantity' => $values['quantity'],
'variation' => $values['variation'],
'subtotal' => $values['line_subtotal'],
'total' => $values['line_total'],
'subtotal_tax' => $values['line_subtotal_tax'],
'total_tax' => $values['line_tax'],
'taxes' => $values['line_tax_data'],
)
);
if ( $product ) {
$item->set_props( array(
'name' => $product->get_name(),
'tax_class' => $product->get_tax_class(),
'product_id' => $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id(),
'variation_id' => $product->is_type( 'variation' ) ? $product->get_id() : 0,
) );
$item->set_props(
array(
'name' => $product->get_name(),
'tax_class' => $product->get_tax_class(),
'product_id' => $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id(),
'variation_id' => $product->is_type( 'variation' ) ? $product->get_id() : 0,
)
);
}
$item->set_backorder_meta();
/**
* Action hook to adjust item before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order_line_item', $item, $cart_item_key, $values, $order );
@ -393,27 +405,30 @@ class WC_Checkout {
/**
* Add fees to the order.
*
* @param WC_Order $order
* @param WC_Cart $cart
* @param WC_Order $order Order instance.
* @param WC_Cart $cart Cart instance.
*/
public function create_order_fee_lines( &$order, $cart ) {
foreach ( $cart->get_fees() as $fee_key => $fee ) {
$item = new WC_Order_Item_Fee();
$item->legacy_fee = $fee; // @deprecated For legacy actions.
$item->legacy_fee_key = $fee_key; // @deprecated For legacy actions.
$item->set_props( array(
'name' => $fee->name,
'tax_class' => $fee->taxable ? $fee->tax_class: 0,
'amount' => $fee->amount,
'total' => $fee->total,
'total_tax' => $fee->tax,
'taxes' => array(
'total' => $fee->tax_data,
),
) );
$item->set_props(
array(
'name' => $fee->name,
'tax_class' => $fee->taxable ? $fee->tax_class : 0,
'amount' => $fee->amount,
'total' => $fee->total,
'total_tax' => $fee->tax,
'taxes' => array(
'total' => $fee->tax_data,
),
)
);
/**
* Action hook to adjust item before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order_fee_item', $item, $fee_key, $fee, $order );
@ -426,26 +441,27 @@ class WC_Checkout {
/**
* Add shipping lines to the order.
*
* @param WC_Order $order
* @param array $chosen_shipping_methods
* @param array $packages
* @param WC_Order $order Order Instance.
* @param array $chosen_shipping_methods Chosen shipping methods.
* @param array $packages Packages.
*/
public function create_order_shipping_lines( &$order, $chosen_shipping_methods, $packages ) {
foreach ( $packages as $package_key => $package ) {
if ( isset( $chosen_shipping_methods[ $package_key ], $package['rates'][ $chosen_shipping_methods[ $package_key ] ] ) ) {
/** @var WC_Shipping_Rate $shipping_rate */
$shipping_rate = $package['rates'][ $chosen_shipping_methods[ $package_key ] ];
$item = new WC_Order_Item_Shipping();
$item->legacy_package_key = $package_key; // @deprecated For legacy actions.
$item->set_props( array(
'method_title' => $shipping_rate->label,
'method_id' => $shipping_rate->method_id,
'instance_id' => $shipping_rate->instance_id,
'total' => wc_format_decimal( $shipping_rate->cost ),
'taxes' => array(
'total' => $shipping_rate->taxes,
),
) );
$item->set_props(
array(
'method_title' => $shipping_rate->label,
'method_id' => $shipping_rate->method_id,
'instance_id' => $shipping_rate->instance_id,
'total' => wc_format_decimal( $shipping_rate->cost ),
'taxes' => array(
'total' => $shipping_rate->taxes,
),
)
);
foreach ( $shipping_rate->get_meta_data() as $key => $value ) {
$item->add_meta_data( $key, $value, true );
@ -453,6 +469,7 @@ class WC_Checkout {
/**
* Action hook to adjust item before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order_shipping_item', $item, $package_key, $package, $order );
@ -466,24 +483,27 @@ class WC_Checkout {
/**
* Add tax lines to the order.
*
* @param WC_Order $order
* @param WC_Cart $cart
* @param WC_Order $order Order instance.
* @param WC_Cart $cart Cart instance.
*/
public function create_order_tax_lines( &$order, $cart ) {
foreach ( array_keys( $cart->get_cart_contents_taxes() + $cart->get_shipping_taxes() + $cart->get_fee_taxes() ) as $tax_rate_id ) {
if ( $tax_rate_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
$item = new WC_Order_Item_Tax();
$item->set_props( array(
'rate_id' => $tax_rate_id,
'tax_total' => $cart->get_tax_amount( $tax_rate_id ),
'shipping_tax_total' => $cart->get_shipping_tax_amount( $tax_rate_id ),
'rate_code' => WC_Tax::get_rate_code( $tax_rate_id ),
'label' => WC_Tax::get_rate_label( $tax_rate_id ),
'compound' => WC_Tax::is_compound( $tax_rate_id ),
) );
$item->set_props(
array(
'rate_id' => $tax_rate_id,
'tax_total' => $cart->get_tax_amount( $tax_rate_id ),
'shipping_tax_total' => $cart->get_shipping_tax_amount( $tax_rate_id ),
'rate_code' => WC_Tax::get_rate_code( $tax_rate_id ),
'label' => WC_Tax::get_rate_label( $tax_rate_id ),
'compound' => WC_Tax::is_compound( $tax_rate_id ),
)
);
/**
* Action hook to adjust item before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order_tax_item', $item, $tax_rate_id, $order );
@ -497,21 +517,24 @@ class WC_Checkout {
/**
* Add coupon lines to the order.
*
* @param WC_Order $order
* @param WC_Cart $cart
* @param WC_Order $order Order instance.
* @param WC_Cart $cart Cart instance.
*/
public function create_order_coupon_lines( &$order, $cart ) {
foreach ( $cart->get_coupons() as $code => $coupon ) {
$item = new WC_Order_Item_Coupon();
$item->set_props( array(
'code' => $code,
'discount' => $cart->get_coupon_discount_amount( $code ),
'discount_tax' => $cart->get_coupon_discount_tax_amount( $code ),
) );
$item->set_props(
array(
'code' => $code,
'discount' => $cart->get_coupon_discount_amount( $code ),
'discount_tax' => $cart->get_coupon_discount_tax_amount( $code ),
)
);
$item->add_meta_data( 'coupon_data', $coupon->get_data() );
/**
* Action hook to adjust item before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order_coupon_item', $item, $code, $coupon, $order );
@ -525,10 +548,8 @@ class WC_Checkout {
* See if a fieldset should be skipped.
*
* @since 3.0.0
*
* @param string $fieldset_key
* @param array $data
*
* @param string $fieldset_key Fieldset key.
* @param array $data Posted data.
* @return bool
*/
protected function maybe_skip_fieldset( $fieldset_key, $data ) {
@ -550,12 +571,12 @@ class WC_Checkout {
public function get_posted_data() {
$skipped = array();
$data = array(
'terms' => (int) isset( $_POST['terms'] ),
'createaccount' => (int) ! empty( $_POST['createaccount'] ),
'payment_method' => isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : '',
'shipping_method' => isset( $_POST['shipping_method'] ) ? wc_clean( $_POST['shipping_method'] ) : '',
'ship_to_different_address' => ! empty( $_POST['ship_to_different_address'] ) && ! wc_ship_to_billing_address_only(),
'woocommerce_checkout_update_totals' => isset( $_POST['woocommerce_checkout_update_totals'] ),
'terms' => (int) isset( $_POST['terms'] ), // WPCS: input var ok, CSRF ok.
'createaccount' => (int) ! empty( $_POST['createaccount'] ), // WPCS: input var ok, CSRF ok.
'payment_method' => isset( $_POST['payment_method'] ) ? wc_clean( wp_unslash( $_POST['payment_method'] ) ) : '', // WPCS: input var ok, CSRF ok.
'shipping_method' => isset( $_POST['shipping_method'] ) ? wc_clean( wp_unslash( $_POST['shipping_method'] ) ) : '', // WPCS: input var ok, CSRF ok.
'ship_to_different_address' => ! empty( $_POST['ship_to_different_address'] ) && ! wc_ship_to_billing_address_only(), // WPCS: input var ok, CSRF ok.
'woocommerce_checkout_update_totals' => isset( $_POST['woocommerce_checkout_update_totals'] ), // WPCS: input var ok, CSRF ok.
);
foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) {
if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) {
@ -566,17 +587,17 @@ class WC_Checkout {
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );
switch ( $type ) {
case 'checkbox' :
$value = isset( $_POST[ $key ] ) ? 1 : '';
case 'checkbox':
$value = isset( $_POST[ $key ] ) ? 1 : ''; // WPCS: input var ok, CSRF ok.
break;
case 'multiselect' :
$value = isset( $_POST[ $key ] ) ? implode( ', ', wc_clean( $_POST[ $key ] ) ) : '';
case 'multiselect':
$value = isset( $_POST[ $key ] ) ? implode( ', ', wc_clean( wp_unslash( $_POST[ $key ] ) ) ) : ''; // WPCS: input var ok, CSRF ok.
break;
case 'textarea' :
$value = isset( $_POST[ $key ] ) ? wc_sanitize_textarea( $_POST[ $key ] ) : '';
case 'textarea':
$value = isset( $_POST[ $key ] ) ? wc_sanitize_textarea( wp_unslash( $_POST[ $key ] ) ) : ''; // WPCS: input var ok, CSRF ok.
break;
default :
$value = isset( $_POST[ $key ] ) ? wc_clean( $_POST[ $key ] ) : '';
default:
$value = isset( $_POST[ $key ] ) ? wc_clean( wp_unslash( $_POST[ $key ] ) ) : ''; // WPCS: input var ok, CSRF ok.
break;
}
@ -584,7 +605,7 @@ class WC_Checkout {
}
}
if ( in_array( 'shipping', $skipped ) && ( WC()->cart->needs_shipping_address() || wc_ship_to_billing_address_only() ) ) {
if ( in_array( 'shipping', $skipped, true ) && ( WC()->cart->needs_shipping_address() || wc_ship_to_billing_address_only() ) ) {
foreach ( $this->get_checkout_fields( 'shipping' ) as $key => $field ) {
$data[ $key ] = isset( $data[ 'billing_' . substr( $key, 9 ) ] ) ? $data[ 'billing_' . substr( $key, 9 ) ] : '';
}
@ -600,8 +621,8 @@ class WC_Checkout {
* Validates the posted checkout data based on field properties.
*
* @since 3.0.0
* @param array $data An array of posted data.
* @param WP_Error $errors
* @param array $data An array of posted data.
* @param WP_Error $errors Validation error.
*/
protected function validate_posted_data( &$data, &$errors ) {
foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) {
@ -617,26 +638,27 @@ class WC_Checkout {
$field_label = isset( $field['label'] ) ? $field['label'] : '';
switch ( $fieldset_key ) {
case 'shipping' :
case 'shipping':
/* translators: %s: field name */
$field_label = sprintf( __( 'Shipping %s', 'woocommerce' ), $field_label );
break;
case 'billing' :
break;
case 'billing':
/* translators: %s: field name */
$field_label = sprintf( __( 'Billing %s', 'woocommerce' ), $field_label );
break;
break;
}
if ( in_array( 'postcode', $format ) ) {
if ( in_array( 'postcode', $format, true ) ) {
$country = isset( $data[ $fieldset_key . '_country' ] ) ? $data[ $fieldset_key . '_country' ] : WC()->customer->{"get_{$fieldset_key}_country"}();
$data[ $key ] = wc_format_postcode( $data[ $key ], $country );
if ( '' !== $data[ $key ] && ! WC_Validation::is_postcode( $data[ $key ], $country ) ) {
/* translators: %s: field name */
$errors->add( 'validation', sprintf( __( '%s is not a valid postcode / ZIP.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ) );
}
}
if ( in_array( 'phone', $format ) ) {
if ( in_array( 'phone', $format, true ) ) {
$data[ $key ] = wc_format_phone_number( $data[ $key ] );
if ( '' !== $data[ $key ] && ! WC_Validation::is_phone( $data[ $key ] ) ) {
@ -645,7 +667,7 @@ class WC_Checkout {
}
}
if ( in_array( 'email', $format ) && '' !== $data[ $key ] ) {
if ( in_array( 'email', $format, true ) && '' !== $data[ $key ] ) {
$data[ $key ] = sanitize_email( $data[ $key ] );
if ( ! is_email( $data[ $key ] ) ) {
@ -655,11 +677,11 @@ class WC_Checkout {
}
}
if ( '' !== $data[ $key ] && in_array( 'state', $format ) ) {
if ( '' !== $data[ $key ] && in_array( 'state', $format, true ) ) {
$country = isset( $data[ $fieldset_key . '_country' ] ) ? $data[ $fieldset_key . '_country' ] : WC()->customer->{"get_{$fieldset_key}_country"}();
$valid_states = WC()->countries->get_states( $country );
if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
if ( ! empty( $valid_states ) && is_array( $valid_states ) && count( $valid_states ) > 0 ) {
$valid_state_values = array_map( 'wc_strtoupper', array_flip( array_map( 'wc_strtoupper', $valid_states ) ) );
$data[ $key ] = wc_strtoupper( $data[ $key ] );
@ -668,7 +690,7 @@ class WC_Checkout {
$data[ $key ] = $valid_state_values[ $data[ $key ] ];
}
if ( ! in_array( $data[ $key ], $valid_state_values ) ) {
if ( ! in_array( $data[ $key ], $valid_state_values, true ) ) {
/* translators: 1: state field 2: valid states */
$errors->add( 'validation', sprintf( __( '%1$s is not valid. Please enter one of the following: %2$s', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>', implode( ', ', $valid_states ) ) );
}
@ -687,14 +709,14 @@ class WC_Checkout {
* Validates that the checkout has enough info to proceed.
*
* @since 3.0.0
* @param array $data An array of posted data.
* @param WP_Error $errors
* @param array $data An array of posted data.
* @param WP_Error $errors Validation errors.
*/
protected function validate_checkout( &$data, &$errors ) {
$this->validate_posted_data( $data, $errors );
$this->check_cart_items();
if ( empty( $data['woocommerce_checkout_update_totals'] ) && ! empty( $_POST['terms-field'] ) && empty( $data['terms'] ) && apply_filters( 'woocommerce_checkout_show_terms', wc_get_page_id( 'terms' ) > 0 ) ) {
if ( empty( $data['woocommerce_checkout_update_totals'] ) && ! empty( $_POST['terms-field'] ) && empty( $data['terms'] ) && apply_filters( 'woocommerce_checkout_show_terms', wc_get_page_id( 'terms' ) > 0 ) ) { // WPCS: input var ok, CSRF ok.
$errors->add( 'terms', __( 'You must accept our Terms &amp; Conditions.', 'woocommerce' ) );
}
@ -703,7 +725,8 @@ class WC_Checkout {
if ( empty( $shipping_country ) ) {
$errors->add( 'shipping', __( 'Please enter an address to continue.', 'woocommerce' ) );
} elseif ( ! in_array( WC()->customer->get_shipping_country(), array_keys( WC()->countries->get_shipping_countries() ) ) ) {
} elseif ( ! in_array( WC()->customer->get_shipping_country(), array_keys( WC()->countries->get_shipping_countries() ), true ) ) {
/* translators: %s: shipping location */
$errors->add( 'shipping', sprintf( __( 'Unfortunately <strong>we do not ship %s</strong>. Please enter an alternative shipping address.', 'woocommerce' ), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country() ) );
} else {
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
@ -733,9 +756,9 @@ class WC_Checkout {
* Set address field for customer.
*
* @since 3.0.7
* @param $field string to update
* @param $key
* @param $data array of data to get the value from
* @param string $field String to update.
* @param string $key Field key.
* @param array $data Array of data to get the value from.
*/
protected function set_customer_address_fields( $field, $key, $data ) {
if ( isset( $data[ "billing_{$field}" ] ) ) {
@ -750,8 +773,8 @@ class WC_Checkout {
/**
* Update customer and session data from the posted checkout data.
*
* @since 3.0.0
* @param array $data
* @since 3.0.0
* @param array $data Posted data.
*/
protected function update_session( $data ) {
// Update both shipping and billing to the passed billing address first if set.
@ -767,7 +790,7 @@ class WC_Checkout {
array_walk( $address_fields, array( $this, 'set_customer_address_fields' ), $data );
WC()->customer->save();
// Update customer shipping and payment method to posted method
// Update customer shipping and payment method to posted method.
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
if ( is_array( $data['shipping_method'] ) ) {
@ -787,9 +810,9 @@ class WC_Checkout {
/**
* Process an order that does require payment.
*
* @since 3.0.0
* @param int $order_id
* @param string $payment_method
* @since 3.0.0
* @param int $order_id Order ID.
* @param string $payment_method Payment method.
*/
protected function process_order_payment( $order_id, $payment_method ) {
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
@ -798,13 +821,13 @@ class WC_Checkout {
return;
}
// Store Order ID in session so it can be re-used after payment failure
// Store Order ID in session so it can be re-used after payment failure.
WC()->session->set( 'order_awaiting_payment', $order_id );
// Process Payment
// Process Payment.
$result = $available_gateways[ $payment_method ]->process_payment( $order_id );
// Redirect to success/confirmation/payment page
// Redirect to success/confirmation/payment page.
if ( isset( $result['result'] ) && 'success' === $result['result'] ) {
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );
@ -820,8 +843,8 @@ class WC_Checkout {
/**
* Process an order that doesn't require payment.
*
* @since 3.0.0
* @param int $order_id
* @since 3.0.0
* @param int $order_id Order ID.
*/
protected function process_order_without_payment( $order_id ) {
$order = wc_get_order( $order_id );
@ -829,10 +852,12 @@ class WC_Checkout {
wc_empty_cart();
if ( is_ajax() ) {
wp_send_json( array(
'result' => 'success',
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ),
) );
wp_send_json(
array(
'result' => 'success',
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ),
)
);
} else {
wp_safe_redirect(
apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order )
@ -843,8 +868,9 @@ class WC_Checkout {
/**
* Create a new customer account if needed.
* @param array $data
* @throws Exception
*
* @throws Exception When not able to create customer.
* @param array $data Posted data.
*/
protected function process_customer( $data ) {
$customer_id = apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() );
@ -861,10 +887,10 @@ class WC_Checkout {
wp_set_current_user( $customer_id );
wc_set_customer_auth_cookie( $customer_id );
// As we are now logged in, checkout will need to refresh to show logged in data
// As we are now logged in, checkout will need to refresh to show logged in data.
WC()->session->set( 'reload_checkout', true );
// Also, recalculate cart totals to reveal any role-based discounts that were unavailable before registering
// Also, recalculate cart totals to reveal any role-based discounts that were unavailable before registering.
WC()->cart->calculate_totals();
}
@ -895,7 +921,7 @@ class WC_Checkout {
if ( is_callable( array( $customer, "set_{$key}" ) ) ) {
$customer->{"set_{$key}"}( $value );
// Store custom fields prefixed with wither shipping_ or billing_.
// Store custom fields prefixed with wither shipping_ or billing_.
} elseif ( 0 === stripos( $key, 'billing_' ) || 0 === stripos( $key, 'shipping_' ) ) {
$customer->update_meta_data( $key, $value );
}
@ -903,6 +929,7 @@ class WC_Checkout {
/**
* Action hook to adjust customer before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_update_customer', $customer, $data );
@ -918,7 +945,7 @@ class WC_Checkout {
*/
protected function send_ajax_failure_response() {
if ( is_ajax() ) {
// only print notices if not reloading the checkout, otherwise they're lost in the page reload
// Only print notices if not reloading the checkout, otherwise they're lost in the page reload.
if ( ! isset( WC()->session->reload_checkout ) ) {
ob_start();
wc_print_notices();
@ -940,10 +967,14 @@ class WC_Checkout {
/**
* Process the checkout after the confirm order button is pressed.
*
* @throws Exception When validation fails.
*/
public function process_checkout() {
try {
if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-process_checkout' ) ) {
$nonce_value = wc_get_var( $_REQUEST['woocommerce-process-checkout-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
if ( empty( $nonce_value ) || ! wp_verify_nonce( $nonce_value, 'woocommerce-process_checkout' ) ) {
WC()->session->set( 'refresh_totals', true );
throw new Exception( __( 'We were unable to process your order, please try again.', 'woocommerce' ) );
}
@ -954,6 +985,7 @@ class WC_Checkout {
do_action( 'woocommerce_before_checkout_process' );
if ( WC()->cart->is_empty() ) {
/* translators: %s: shop cart url */
throw new Exception( sprintf( __( 'Sorry, your session has expired. <a href="%s" class="wc-backward">Return to shop</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'shop' ) ) ) );
}
@ -998,8 +1030,8 @@ class WC_Checkout {
/**
* Get a posted address field after sanitization and validation.
*
* @param string $key
* @param string $type billing for shipping
* @param string $key Field key.
* @param string $type Type of address. Available options: 'billing' or 'shipping'.
* @return string
*/
public function get_posted_address_data( $key, $type = 'billing' ) {
@ -1014,12 +1046,12 @@ class WC_Checkout {
/**
* Gets the value either from the posted data, or from the users meta data.
*
* @param string $input
* @param string $input Input key.
* @return string
*/
public function get_value( $input ) {
if ( ! empty( $_POST[ $input ] ) ) {
return wc_clean( $_POST[ $input ] );
if ( ! empty( $_POST[ $input ] ) ) { // WPCS: input var ok, CSRF OK.
return wc_clean( wp_unslash( $_POST[ $input ] ) ); // WPCS: input var ok, CSRF OK.
} else {

View File

@ -6,9 +6,7 @@
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* CLI class.

View File

@ -1,19 +1,17 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Comments
*
* Handle comments (reviews and order notes).
*
* @class WC_Comments
* @version 2.3.0
* @package WooCommerce/Classes/Products
* @category Class
* @author WooThemes
* @package WooCommerce/Classes/Products
* @version 2.3.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Comments class.
*/
class WC_Comments {
@ -21,34 +19,34 @@ class WC_Comments {
* Hook in methods.
*/
public static function init() {
// Rating posts
// Rating posts.
add_filter( 'comments_open', array( __CLASS__, 'comments_open' ), 10, 2 );
add_filter( 'preprocess_comment', array( __CLASS__, 'check_comment_rating' ), 0 );
add_action( 'comment_post', array( __CLASS__, 'add_comment_rating' ), 1 );
add_action( 'comment_moderation_recipients', array( __CLASS__, 'comment_moderation_recipients' ), 10, 2 );
// Clear transients
// Clear transients.
add_action( 'wp_update_comment_count', array( __CLASS__, 'clear_transients' ) );
// Secure order notes
// Secure order notes.
add_filter( 'comments_clauses', array( __CLASS__, 'exclude_order_comments' ), 10, 1 );
add_filter( 'comment_feed_where', array( __CLASS__, 'exclude_order_comments_from_feed_where' ) );
// Secure webhook comments
// Secure webhook comments.
add_filter( 'comments_clauses', array( __CLASS__, 'exclude_webhook_comments' ), 10, 1 );
add_filter( 'comment_feed_where', array( __CLASS__, 'exclude_webhook_comments_from_feed_where' ) );
// Count comments
// Count comments.
add_filter( 'wp_count_comments', array( __CLASS__, 'wp_count_comments' ), 10, 2 );
// Delete comments count cache whenever there is a new comment or a comment status changes
// Delete comments count cache whenever there is a new comment or a comment status changes.
add_action( 'wp_insert_comment', array( __CLASS__, 'delete_comments_count_cache' ) );
add_action( 'wp_set_comment_status', array( __CLASS__, 'delete_comments_count_cache' ) );
// Support avatars for `review` comment type
// Support avatars for `review` comment type.
add_filter( 'get_avatar_comment_types', array( __CLASS__, 'add_avatar_for_review_comment_type' ) );
// Review of verified purchase
// Review of verified purchase.
add_action( 'comment_post', array( __CLASS__, 'add_comment_purchase_verification' ) );
}
@ -56,8 +54,8 @@ class WC_Comments {
* See if comments are open.
*
* @since 3.1.0
* @param bool $open
* @param int $post_id
* @param bool $open Whether the current post is open for comments.
* @param int $post_id Post ID.
* @return bool
*/
public static function comments_open( $open, $post_id ) {
@ -75,7 +73,8 @@ class WC_Comments {
* shop managers can view orders anyway.
*
* The frontend view order pages get around this filter by using remove_filter('comments_clauses', array( 'WC_Comments' ,'exclude_order_comments'), 10, 1 );
* @param array $clauses
*
* @param array $clauses A compacted array of comment query clauses.
* @return array
*/
public static function exclude_order_comments( $clauses ) {
@ -84,7 +83,10 @@ class WC_Comments {
}
/**
* Exclude order comments from feed.
*
* @deprecated 3.1
* @param mixed $join Deprecated.
*/
public static function exclude_order_comments_from_feed_join( $join ) {
wc_deprecated_function( 'WC_Comments::exclude_order_comments_from_feed_join', '3.1' );
@ -93,7 +95,7 @@ class WC_Comments {
/**
* Exclude order comments from queries and RSS.
*
* @param string $where
* @param string $where The WHERE clause of the query.
* @return string
*/
public static function exclude_order_comments_from_feed_where( $where ) {
@ -102,8 +104,9 @@ class WC_Comments {
/**
* Exclude webhook comments from queries and RSS.
*
* @since 2.2
* @param array $clauses
* @param array $clauses A compacted array of comment query clauses.
* @return array
*/
public static function exclude_webhook_comments( $clauses ) {
@ -112,7 +115,10 @@ class WC_Comments {
}
/**
* Exclude webhooks comments from feed.
*
* @deprecated 3.1
* @param mixed $join Deprecated.
*/
public static function exclude_webhook_comments_from_feed_join( $join ) {
wc_deprecated_function( 'WC_Comments::exclude_webhook_comments_from_feed_join', '3.1' );
@ -120,8 +126,9 @@ class WC_Comments {
/**
* Exclude webhook comments from queries and RSS.
*
* @since 2.1
* @param string $where
* @param string $where The WHERE clause of the query.
* @return string
*/
public static function exclude_webhook_comments_from_feed_where( $where ) {
@ -131,13 +138,13 @@ class WC_Comments {
/**
* Validate the comment ratings.
*
* @param array $comment_data
* @param array $comment_data Comment data.
* @return array
*/
public static function check_comment_rating( $comment_data ) {
// If posting a comment (not trackback etc) and not logged in
if ( ! is_admin() && isset( $_POST['comment_post_ID'], $_POST['rating'], $comment_data['comment_type'] ) && 'product' === get_post_type( $_POST['comment_post_ID'] ) && empty( $_POST['rating'] ) && '' === $comment_data['comment_type'] && 'yes' === get_option( 'woocommerce_enable_review_rating' ) && 'yes' === get_option( 'woocommerce_review_rating_required' ) ) {
wp_die( __( 'Please rate the product.', 'woocommerce' ) );
// If posting a comment (not trackback etc) and not logged in.
if ( ! is_admin() && isset( $_POST['comment_post_ID'], $_POST['rating'], $comment_data['comment_type'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) && empty( $_POST['rating'] ) && '' === $comment_data['comment_type'] && 'yes' === get_option( 'woocommerce_enable_review_rating' ) && 'yes' === get_option( 'woocommerce_review_rating_required' ) ) { // WPCS: input var ok, CSRF ok.
wp_die( esc_html__( 'Please rate the product.', 'woocommerce' ) );
exit;
}
return $comment_data;
@ -145,16 +152,17 @@ class WC_Comments {
/**
* Rating field for comments.
* @param int $comment_id
*
* @param int $comment_id Comment ID.
*/
public static function add_comment_rating( $comment_id ) {
if ( isset( $_POST['rating'] ) && 'product' === get_post_type( $_POST['comment_post_ID'] ) ) {
if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) {
if ( isset( $_POST['rating'], $_POST['comment_post_ID'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok.
if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok, CSRF ok, sanitization ok.
return;
}
add_comment_meta( $comment_id, 'rating', (int) esc_attr( $_POST['rating'] ), true );
add_comment_meta( $comment_id, 'rating', intval( $_POST['rating'] ), true ); // WPCS: input var ok, CSRF ok.
$post_id = isset( $_POST['comment_post_ID'] ) ? (int) $_POST['comment_post_ID'] : 0;
$post_id = isset( $_POST['comment_post_ID'] ) ? absint( $_POST['comment_post_ID'] ) : 0; // WPCS: input var ok, CSRF ok.
if ( $post_id ) {
self::clear_transients( $post_id );
}
@ -163,8 +171,9 @@ class WC_Comments {
/**
* Modify recipient of review email.
* @param array $emails
* @param int $comment_id
*
* @param array $emails Emails.
* @param int $comment_id Comment ID.
* @return array
*/
public static function comment_moderation_recipients( $emails, $comment_id ) {
@ -179,7 +188,8 @@ class WC_Comments {
/**
* Ensure product average rating and review count is kept up to date.
* @param int $post_id
*
* @param int $post_id Post ID.
*/
public static function clear_transients( $post_id ) {
@ -196,8 +206,6 @@ class WC_Comments {
* new comment or the status of a comment changes. Cache
* will be regenerated next time WC_Comments::wp_count_comments()
* is called.
*
* @return void
*/
public static function delete_comments_count_cache() {
delete_transient( 'wc_count_comments' );
@ -223,12 +231,14 @@ class WC_Comments {
'all' => 0,
);
$count = $wpdb->get_results( "
$count = $wpdb->get_results(
"
SELECT comment_approved, COUNT(*) AS num_comments
FROM {$wpdb->comments}
WHERE comment_type NOT IN ('order_note', 'webhook_delivery')
GROUP BY comment_approved
", ARRAY_A );
", ARRAY_A
);
$approved = array(
'0' => 'moderated',
@ -267,8 +277,9 @@ class WC_Comments {
/**
* Make sure WP displays avatars for comments with the `review` type.
*
* @since 2.3
* @param array $comment_types
* @param array $comment_types Comment types.
* @return array
*/
public static function add_avatar_for_review_comment_type( $comment_types ) {
@ -277,7 +288,8 @@ class WC_Comments {
/**
* Determine if a review is from a verified owner at submission.
* @param int $comment_id
*
* @param int $comment_id Comment ID.
* @return bool
*/
public static function add_comment_purchase_verification( $comment_id ) {
@ -294,7 +306,7 @@ class WC_Comments {
* Get product rating for a product. Please note this is not cached.
*
* @since 3.0.0
* @param WC_Product $product
* @param WC_Product $product Product instance.
* @return float
*/
public static function get_average_rating_for_product( &$product ) {
@ -303,14 +315,18 @@ class WC_Comments {
$count = $product->get_rating_count();
if ( $count ) {
$ratings = $wpdb->get_var( $wpdb->prepare("
$ratings = $wpdb->get_var(
$wpdb->prepare(
"
SELECT SUM(meta_value) FROM $wpdb->commentmeta
LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
WHERE meta_key = 'rating'
AND comment_post_ID = %d
AND comment_approved = '1'
AND meta_value > 0
", $product->get_id() ) );
", $product->get_id()
)
);
$average = number_format( $ratings / $count, 2, '.', '' );
} else {
$average = 0;
@ -328,18 +344,22 @@ class WC_Comments {
* Get product review count for a product (not replies). Please note this is not cached.
*
* @since 3.0.0
* @param WC_Product $product
* @param WC_Product $product Product instance.
* @return int
*/
public static function get_review_count_for_product( &$product ) {
global $wpdb;
$count = $wpdb->get_var( $wpdb->prepare("
$count = $wpdb->get_var(
$wpdb->prepare(
"
SELECT COUNT(*) FROM $wpdb->comments
WHERE comment_parent = 0
AND comment_post_ID = %d
AND comment_approved = '1'
", $product->get_id() ) );
", $product->get_id()
)
);
$product->set_review_count( $count );
@ -353,14 +373,16 @@ class WC_Comments {
* Get product rating count for a product. Please note this is not cached.
*
* @since 3.0.0
* @param WC_Product $product
* @return array of integers
* @param WC_Product $product Product instance.
* @return int[]
*/
public static function get_rating_counts_for_product( &$product ) {
global $wpdb;
$counts = array();
$raw_counts = $wpdb->get_results( $wpdb->prepare( "
$raw_counts = $wpdb->get_results(
$wpdb->prepare(
"
SELECT meta_value, COUNT( * ) as meta_value_count FROM $wpdb->commentmeta
LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
WHERE meta_key = 'rating'
@ -368,10 +390,12 @@ class WC_Comments {
AND comment_approved = '1'
AND meta_value > 0
GROUP BY meta_value
", $product->get_id() ) );
", $product->get_id()
)
);
foreach ( $raw_counts as $count ) {
$counts[ $count->meta_value ] = absint( $count->meta_value_count );
$counts[ $count->meta_value ] = absint( $count->meta_value_count ); // WPCS: slow query ok.
}
$product->set_rating_counts( $counts );

View File

@ -2,13 +2,11 @@
/**
* WooCommerce countries
*
* @version 3.3.0
* @package WooCommerce\l10n
* @package WooCommerce\l10n
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
defined( 'ABSPATH' ) || exit;
/**
* The WooCommerce countries class stores country/state data.
@ -84,7 +82,7 @@ class WC_Countries {
$continents = $this->get_continents();
$continents_and_ccs = wp_list_pluck( $continents, 'countries' );
foreach ( $continents_and_ccs as $continent_code => $countries ) {
if ( false !== array_search( $cc, $countries ) ) {
if ( false !== array_search( $cc, $countries, true ) ) {
return $continent_code;
}
}
@ -376,7 +374,7 @@ class WC_Countries {
public function shipping_to_prefix( $country_code = '' ) {
$country_code = $country_code ? $country_code : WC()->customer->get_shipping_country();
$countries = array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' );
$return = in_array( $country_code, $countries ) ? __( 'to the', 'woocommerce' ) : __( 'to', 'woocommerce' );
$return = in_array( $country_code, $countries, true ) ? __( 'to the', 'woocommerce' ) : __( 'to', 'woocommerce' );
return apply_filters( 'woocommerce_countries_shipping_to_prefix', $return, $country_code );
}
@ -390,7 +388,7 @@ class WC_Countries {
public function estimated_for_prefix( $country_code = '' ) {
$country_code = $country_code ? $country_code : $this->get_base_country();
$countries = array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' );
$return = in_array( $country_code, $countries ) ? __( 'the', 'woocommerce' ) . ' ' : '';
$return = in_array( $country_code, $countries, true ) ? __( 'the', 'woocommerce' ) . ' ' : '';
return apply_filters( 'woocommerce_countries_estimated_for_prefix', $return, $country_code );
}
@ -401,7 +399,7 @@ class WC_Countries {
* @return string
*/
public function tax_or_vat() {
$return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ) ) ? __( 'VAT', 'woocommerce' ) : __( 'Tax', 'woocommerce' );
$return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ), true ) ? __( 'VAT', 'woocommerce' ) : __( 'Tax', 'woocommerce' );
return apply_filters( 'woocommerce_countries_tax_or_vat', $return );
}
@ -412,7 +410,7 @@ class WC_Countries {
* @return string
*/
public function inc_tax_or_vat() {
$return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ) ) ? __( '(incl. VAT)', 'woocommerce' ) : __( '(incl. tax)', 'woocommerce' );
$return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ), true ) ? __( '(incl. VAT)', 'woocommerce' ) : __( '(incl. tax)', 'woocommerce' );
return apply_filters( 'woocommerce_countries_inc_tax_or_vat', $return );
}
@ -423,7 +421,7 @@ class WC_Countries {
* @return string
*/
public function ex_tax_or_vat() {
$return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ) ) ? __( '(ex. VAT)', 'woocommerce' ) : __( '(ex. tax)', 'woocommerce' );
$return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ), true ) ? __( '(ex. VAT)', 'woocommerce' ) : __( '(ex. tax)', 'woocommerce' );
return apply_filters( 'woocommerce_countries_ex_tax_or_vat', $return );
}
@ -928,7 +926,7 @@ class WC_Countries {
),
),
'IM' => array(
'state' => array(
'state' => array(
'required' => false,
),
),

View File

@ -1,25 +1,25 @@
<?php
include_once( 'legacy/class-wc-legacy-coupon.php' );
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WooCommerce coupons.
*
* The WooCommerce coupons class gets coupon data from storage and checks coupon validity.
*
* @class WC_Coupon
* @version 3.0.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 3.0.0
*/
defined( 'ABSPATH' ) || exit;
require_once dirname( __FILE__ ) . '/legacy/class-wc-legacy-coupon.php';
/**
* Coupon class.
*/
class WC_Coupon extends WC_Legacy_Coupon {
/**
* Data array, with defaults.
*
* @since 3.0.0
* @var array
*/
@ -49,7 +49,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
'virtual' => false,
);
// Coupon message codes
// Coupon message codes.
const E_WC_COUPON_INVALID_FILTERED = 100;
const E_WC_COUPON_INVALID_REMOVED = 101;
const E_WC_COUPON_NOT_YOURS_REMOVED = 102;
@ -62,7 +62,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
const E_WC_COUPON_NOT_APPLICABLE = 109;
const E_WC_COUPON_NOT_VALID_SALE_ITEMS = 110;
const E_WC_COUPON_PLEASE_ENTER = 111;
const E_WC_COUPON_MAX_SPEND_LIMIT_MET = 112;
const E_WC_COUPON_MAX_SPEND_LIMIT_MET = 112;
const E_WC_COUPON_EXCLUDED_PRODUCTS = 113;
const E_WC_COUPON_EXCLUDED_CATEGORIES = 114;
const WC_COUPON_SUCCESS = 200;
@ -70,12 +70,14 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Cache group.
*
* @var string
*/
protected $cache_group = 'coupons';
/**
* Coupon constructor. Loads coupon data.
*
* @param mixed $data Coupon data, object, ID or code.
*/
public function __construct( $data = '' ) {
@ -83,7 +85,10 @@ class WC_Coupon extends WC_Legacy_Coupon {
if ( $data instanceof WC_Coupon ) {
$this->set_id( absint( $data->get_id() ) );
} elseif ( $coupon = apply_filters( 'woocommerce_get_shop_coupon_data', false, $data ) ) {
}
$coupon = apply_filters( 'woocommerce_get_shop_coupon_data', false, $data );
if ( $coupon ) {
$this->read_manual_coupon( $data, $coupon );
return;
} elseif ( is_int( $data ) && 'shop_coupon' === get_post_type( $data ) ) {
@ -110,11 +115,12 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Checks the coupon type.
* @param string $type Array or string of types
*
* @param string $type Array or string of types.
* @return bool
*/
public function is_type( $type ) {
return ( $this->get_discount_type() === $type || ( is_array( $type ) && in_array( $this->get_discount_type(), $type ) ) );
return ( $this->get_discount_type() === $type || ( is_array( $type ) && in_array( $this->get_discount_type(), $type, true ) ) );
}
/**
@ -128,18 +134,19 @@ class WC_Coupon extends WC_Legacy_Coupon {
}
/*
|--------------------------------------------------------------------------
| Getters
|--------------------------------------------------------------------------
|
| Methods for getting data from the coupon object.
|
*/
|--------------------------------------------------------------------------
| Getters
|--------------------------------------------------------------------------
|
| Methods for getting data from the coupon object.
|
*/
/**
* Get coupon code.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_code( $context = 'view' ) {
@ -148,8 +155,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get coupon description.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_description( $context = 'view' ) {
@ -158,8 +166,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get discount type.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_discount_type( $context = 'view' ) {
@ -168,8 +177,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get coupon amount.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return float
*/
public function get_amount( $context = 'view' ) {
@ -178,8 +188,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get coupon expiration date.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
*/
public function get_date_expires( $context = 'view' ) {
@ -188,8 +199,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get date_created
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
*/
public function get_date_created( $context = 'view' ) {
@ -198,8 +210,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get date_modified
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
*/
public function get_date_modified( $context = 'view' ) {
@ -208,8 +221,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get coupon usage count.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_usage_count( $context = 'view' ) {
@ -218,8 +232,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get the "indvidual use" checkbox status.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return bool
*/
public function get_individual_use( $context = 'view' ) {
@ -228,8 +243,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get product IDs this coupon can apply to.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_product_ids( $context = 'view' ) {
@ -238,8 +254,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get product IDs that this coupon should not apply to.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_excluded_product_ids( $context = 'view' ) {
@ -248,8 +265,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get coupon usage limit.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_usage_limit( $context = 'view' ) {
@ -258,8 +276,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get coupon usage limit per customer (for a single customer)
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_usage_limit_per_user( $context = 'view' ) {
@ -268,8 +287,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Usage limited to certain amount of items
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer|null
*/
public function get_limit_usage_to_x_items( $context = 'view' ) {
@ -278,8 +298,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* If this coupon grants free shipping or not.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return bool
*/
public function get_free_shipping( $context = 'view' ) {
@ -288,8 +309,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get product categories this coupon can apply to.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_product_categories( $context = 'view' ) {
@ -298,8 +320,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get product categories this coupon cannot not apply to.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_excluded_product_categories( $context = 'view' ) {
@ -308,8 +331,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* If this coupon should exclude items on sale.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return bool
*/
public function get_exclude_sale_items( $context = 'view' ) {
@ -318,8 +342,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get minimum spend amount.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return float
*/
public function get_minimum_amount( $context = 'view' ) {
@ -327,8 +352,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
}
/**
* Get maximum spend amount.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return float
*/
public function get_maximum_amount( $context = 'view' ) {
@ -337,8 +363,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get emails to check customer usage restrictions.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_email_restrictions( $context = 'view' ) {
@ -347,8 +374,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get records of all users who have used the current coupon.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_used_by( $context = 'view' ) {
@ -359,7 +387,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
* If the filter is added through the woocommerce_get_shop_coupon_data filter, it's virtual and not in the DB.
*
* @since 3.2.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return boolean
*/
public function get_virtual( $context = 'view' ) {
@ -369,10 +397,10 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Get discount amount for a cart item.
*
* @param float $discounting_amount Amount the coupon is being applied to
* @param array|null $cart_item Cart item being discounted if applicable
* @param boolean $single True if discounting a single qty item, false if its the line
* @return float Amount this coupon has discounted
* @param float $discounting_amount Amount the coupon is being applied to.
* @param array|null $cart_item Cart item being discounted if applicable.
* @param boolean $single True if discounting a single qty item, false if its the line.
* @return float Amount this coupon has discounted.
*/
public function get_discount_amount( $discounting_amount, $cart_item = null, $single = false ) {
$discount = 0;
@ -406,21 +434,21 @@ class WC_Coupon extends WC_Legacy_Coupon {
}
/*
|--------------------------------------------------------------------------
| Setters
|--------------------------------------------------------------------------
|
| Functions for setting coupon data. These should not update anything in the
| database itself and should only change what is stored in the class
| object.
|
*/
|--------------------------------------------------------------------------
| Setters
|--------------------------------------------------------------------------
|
| Functions for setting coupon data. These should not update anything in the
| database itself and should only change what is stored in the class
| object.
|
*/
/**
* Set coupon code.
* @since 3.0.0
* @param string $code
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param string $code Coupon code.
*/
public function set_code( $code ) {
$this->set_prop( 'code', wc_format_coupon_code( $code ) );
@ -428,9 +456,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set coupon description.
* @since 3.0.0
* @param string $description
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param string $description Description.
*/
public function set_description( $description ) {
$this->set_prop( 'description', $description );
@ -438,15 +466,15 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set discount type.
* @since 3.0.0
* @param string $discount_type
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param string $discount_type Discount type.
*/
public function set_discount_type( $discount_type ) {
if ( 'percent_product' === $discount_type ) {
$discount_type = 'percent'; // Backwards compatibility.
}
if ( ! in_array( $discount_type, array_keys( wc_get_coupon_types() ) ) ) {
if ( ! in_array( $discount_type, array_keys( wc_get_coupon_types() ), true ) ) {
$this->error( 'coupon_invalid_discount_type', __( 'Invalid discount type', 'woocommerce' ) );
}
$this->set_prop( 'discount_type', $discount_type );
@ -454,9 +482,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set amount.
* @since 3.0.0
* @param float $amount
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param float $amount Amount.
*/
public function set_amount( $amount ) {
$amount = wc_format_decimal( $amount );
@ -478,9 +506,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set expiration date.
*
* @since 3.0.0
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
* @throws WC_Data_Exception
*/
public function set_date_expires( $date ) {
$this->set_date_prop( 'date_expires', $date );
@ -488,9 +516,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set date_created
*
* @since 3.0.0
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
* @throws WC_Data_Exception
*/
public function set_date_created( $date ) {
$this->set_date_prop( 'date_created', $date );
@ -498,9 +526,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set date_modified
*
* @since 3.0.0
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
* @throws WC_Data_Exception
*/
public function set_date_modified( $date ) {
$this->set_date_prop( 'date_modified', $date );
@ -508,9 +536,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set how many times this coupon has been used.
* @since 3.0.0
* @param int $usage_count
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param int $usage_count Usage count.
*/
public function set_usage_count( $usage_count ) {
$this->set_prop( 'usage_count', absint( $usage_count ) );
@ -518,9 +546,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set if this coupon can only be used once.
* @since 3.0.0
* @param bool $is_individual_use
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param bool $is_individual_use If is for individual use.
*/
public function set_individual_use( $is_individual_use ) {
$this->set_prop( 'individual_use', (bool) $is_individual_use );
@ -528,9 +556,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the product IDs this coupon can be used with.
* @since 3.0.0
* @param array $product_ids
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param array $product_ids Products IDs.
*/
public function set_product_ids( $product_ids ) {
$this->set_prop( 'product_ids', array_filter( wp_parse_id_list( (array) $product_ids ) ) );
@ -538,9 +566,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the product IDs this coupon cannot be used with.
* @since 3.0.0
* @param array $excluded_product_ids
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param array $excluded_product_ids Exclude product IDs.
*/
public function set_excluded_product_ids( $excluded_product_ids ) {
$this->set_prop( 'excluded_product_ids', array_filter( wp_parse_id_list( (array) $excluded_product_ids ) ) );
@ -548,9 +576,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the amount of times this coupon can be used.
* @since 3.0.0
* @param int $usage_limit
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param int $usage_limit Usage limit.
*/
public function set_usage_limit( $usage_limit ) {
$this->set_prop( 'usage_limit', absint( $usage_limit ) );
@ -558,9 +586,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the amount of times this coupon can be used per user.
* @since 3.0.0
* @param int $usage_limit
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param int $usage_limit Usage limit.
*/
public function set_usage_limit_per_user( $usage_limit ) {
$this->set_prop( 'usage_limit_per_user', absint( $usage_limit ) );
@ -568,9 +596,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set usage limit to x number of items.
* @since 3.0.0
* @param int|null $limit_usage_to_x_items
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param int|null $limit_usage_to_x_items Limit usage to X items.
*/
public function set_limit_usage_to_x_items( $limit_usage_to_x_items ) {
$this->set_prop( 'limit_usage_to_x_items', is_null( $limit_usage_to_x_items ) ? null : absint( $limit_usage_to_x_items ) );
@ -578,9 +606,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set if this coupon enables free shipping or not.
* @since 3.0.0
* @param bool $free_shipping
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param bool $free_shipping If grant free shipping.
*/
public function set_free_shipping( $free_shipping ) {
$this->set_prop( 'free_shipping', (bool) $free_shipping );
@ -588,9 +616,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the product category IDs this coupon can be used with.
* @since 3.0.0
* @param array $product_categories
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param array $product_categories List of product categories.
*/
public function set_product_categories( $product_categories ) {
$this->set_prop( 'product_categories', array_filter( wp_parse_id_list( (array) $product_categories ) ) );
@ -598,9 +626,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the product category IDs this coupon cannot be used with.
* @since 3.0.0
* @param array $excluded_product_categories
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param array $excluded_product_categories List of excluded product categories.
*/
public function set_excluded_product_categories( $excluded_product_categories ) {
$this->set_prop( 'excluded_product_categories', array_filter( wp_parse_id_list( (array) $excluded_product_categories ) ) );
@ -608,9 +636,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set if this coupon should excluded sale items or not.
* @since 3.0.0
* @param bool $exclude_sale_items
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param bool $exclude_sale_items If should exclude sale items.
*/
public function set_exclude_sale_items( $exclude_sale_items ) {
$this->set_prop( 'exclude_sale_items', (bool) $exclude_sale_items );
@ -618,9 +646,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the minimum spend amount.
* @since 3.0.0
* @param float $amount
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param float $amount Minium amount.
*/
public function set_minimum_amount( $amount ) {
$this->set_prop( 'minimum_amount', wc_format_decimal( $amount ) );
@ -628,9 +656,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set the maximum spend amount.
* @since 3.0.0
* @param float $amount
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param float $amount Maximum amount.
*/
public function set_maximum_amount( $amount ) {
$this->set_prop( 'maximum_amount', wc_format_decimal( $amount ) );
@ -638,9 +666,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set email restrictions.
* @since 3.0.0
* @param array $emails
* @throws WC_Data_Exception
*
* @since 3.0.0
* @param array $emails List of emails.
*/
public function set_email_restrictions( $emails = array() ) {
$emails = array_filter( array_map( 'sanitize_email', array_map( 'strtolower', (array) $emails ) ) );
@ -654,9 +682,9 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set which users have used this coupon.
*
* @since 3.0.0
* @param array $used_by
* @throws WC_Data_Exception
* @param array $used_by List of user IDs.
*/
public function set_used_by( $used_by ) {
$this->set_prop( 'used_by', array_filter( $used_by ) );
@ -664,6 +692,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Set coupon virtual state.
*
* @param boolean $virtual Whether it is virtual or not.
* @since 3.2.0
*/
@ -679,42 +708,43 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Developers can programmatically return coupons. This function will read those values into our WC_Coupon class.
* @since 3.0.0
* @param string $code Coupon code
* @param array $coupon Array of coupon properties
*
* @since 3.0.0
* @param string $code Coupon code.
* @param array $coupon Array of coupon properties.
*/
public function read_manual_coupon( $code, $coupon ) {
foreach ( $coupon as $key => $value ) {
switch ( $key ) {
case 'excluded_product_ids' :
case 'exclude_product_ids' :
case 'excluded_product_ids':
case 'exclude_product_ids':
if ( ! is_array( $coupon[ $key ] ) ) {
wc_doing_it_wrong( $key, $key . ' should be an array instead of a string.', '3.0' );
$coupon['excluded_product_ids'] = wc_string_to_array( $value );
}
break;
case 'exclude_product_categories' :
case 'excluded_product_categories' :
case 'exclude_product_categories':
case 'excluded_product_categories':
if ( ! is_array( $coupon[ $key ] ) ) {
wc_doing_it_wrong( $key, $key . ' should be an array instead of a string.', '3.0' );
$coupon['excluded_product_categories'] = wc_string_to_array( $value );
}
break;
case 'product_ids' :
case 'product_ids':
if ( ! is_array( $coupon[ $key ] ) ) {
wc_doing_it_wrong( $key, $key . ' should be an array instead of a string.', '3.0' );
$coupon[ $key ] = wc_string_to_array( $value );
}
break;
case 'individual_use' :
case 'free_shipping' :
case 'exclude_sale_items' :
case 'individual_use':
case 'free_shipping':
case 'exclude_sale_items':
if ( ! is_bool( $coupon[ $key ] ) ) {
wc_doing_it_wrong( $key, $key . ' should be true or false instead of yes or no.', '3.0' );
$coupon[ $key ] = wc_string_to_bool( $value );
}
break;
case 'expiry_date' :
case 'expiry_date':
$coupon['date_expires'] = $value;
break;
}
@ -728,7 +758,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Increase usage count for current coupon.
*
* @param string $used_by Either user ID or billing email
* @param string $used_by Either user ID or billing email.
*/
public function increase_usage_count( $used_by = '' ) {
if ( $this->get_id() && $this->data_store ) {
@ -745,7 +775,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Decrease usage count for current coupon.
*
* @param string $used_by Either user ID or billing email
* @param string $used_by Either user ID or billing email.
*/
public function decrease_usage_count( $used_by = '' ) {
if ( $this->get_id() && $this->get_usage_count() > 0 && $this->data_store ) {
@ -760,10 +790,10 @@ class WC_Coupon extends WC_Legacy_Coupon {
}
/*
|--------------------------------------------------------------------------
| Validation & Error Handling
|--------------------------------------------------------------------------
*/
|--------------------------------------------------------------------------
| Validation & Error Handling
|--------------------------------------------------------------------------
*/
/**
* Returns the error_message string.
@ -779,8 +809,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
* Check if a coupon is valid for the cart.
*
* @deprecated 3.2.0 In favor of WC_Discounts->is_coupon_valid.
* @throws Exception
* @return bool Validity.
* @return bool
*/
public function is_valid() {
$discounts = new WC_Discounts( WC()->cart );
@ -806,9 +835,8 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Check if a coupon is valid for a product.
*
* @param WC_Product $product
* @param array $values
*
* @param WC_Product $product Product instance.
* @param array $values Values.
* @return bool
*/
public function is_valid_for_product( $product, $values = array() ) {
@ -820,32 +848,32 @@ class WC_Coupon extends WC_Legacy_Coupon {
$product_cats = wc_get_product_cat_ids( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() );
$product_ids = array( $product->get_id(), $product->get_parent_id() );
// Specific products get the discount
if ( sizeof( $this->get_product_ids() ) && sizeof( array_intersect( $product_ids, $this->get_product_ids() ) ) ) {
// Specific products get the discount.
if ( count( $this->get_product_ids() ) && count( array_intersect( $product_ids, $this->get_product_ids() ) ) ) {
$valid = true;
}
// Category discounts
if ( sizeof( $this->get_product_categories() ) && sizeof( array_intersect( $product_cats, $this->get_product_categories() ) ) ) {
// Category discounts.
if ( count( $this->get_product_categories() ) && count( array_intersect( $product_cats, $this->get_product_categories() ) ) ) {
$valid = true;
}
// No product ids - all items discounted
if ( ! sizeof( $this->get_product_ids() ) && ! sizeof( $this->get_product_categories() ) ) {
// No product ids - all items discounted.
if ( ! count( $this->get_product_ids() ) && ! count( $this->get_product_categories() ) ) {
$valid = true;
}
// Specific product IDs excluded from the discount
if ( sizeof( $this->get_excluded_product_ids() ) && sizeof( array_intersect( $product_ids, $this->get_excluded_product_ids() ) ) ) {
// Specific product IDs excluded from the discount.
if ( count( $this->get_excluded_product_ids() ) && count( array_intersect( $product_ids, $this->get_excluded_product_ids() ) ) ) {
$valid = false;
}
// Specific categories excluded from the discount
if ( sizeof( $this->get_excluded_product_categories() ) && sizeof( array_intersect( $product_cats, $this->get_excluded_product_categories() ) ) ) {
// Specific categories excluded from the discount.
if ( count( $this->get_excluded_product_categories() ) && count( array_intersect( $product_cats, $this->get_excluded_product_categories() ) ) ) {
$valid = false;
}
// Sale Items excluded from discount
// Sale Items excluded from discount.
if ( $this->get_exclude_sale_items() && $product->is_on_sale() ) {
$valid = false;
}
@ -876,20 +904,20 @@ class WC_Coupon extends WC_Legacy_Coupon {
/**
* Map one of the WC_Coupon message codes to a message string.
*
* @param integer $msg_code
* @return string| Message/error string
* @param integer $msg_code Message code.
* @return string Message/error string.
*/
public function get_coupon_message( $msg_code ) {
switch ( $msg_code ) {
case self::WC_COUPON_SUCCESS :
case self::WC_COUPON_SUCCESS:
$msg = __( 'Coupon code applied successfully.', 'woocommerce' );
break;
case self::WC_COUPON_REMOVED :
break;
case self::WC_COUPON_REMOVED:
$msg = __( 'Coupon code removed successfully.', 'woocommerce' );
break;
break;
default:
$msg = '';
break;
break;
}
return apply_filters( 'woocommerce_coupon_message', $msg, $msg_code, $this );
}
@ -904,49 +932,49 @@ class WC_Coupon extends WC_Legacy_Coupon {
switch ( $err_code ) {
case self::E_WC_COUPON_INVALID_FILTERED:
$err = __( 'Coupon is not valid.', 'woocommerce' );
break;
break;
case self::E_WC_COUPON_NOT_EXIST:
/* translators: %s: coupon code */
$err = sprintf( __( 'Coupon "%s" does not exist!', 'woocommerce' ), $this->get_code() );
break;
break;
case self::E_WC_COUPON_INVALID_REMOVED:
/* translators: %s: coupon code */
$err = sprintf( __( 'Sorry, it seems the coupon "%s" is invalid - it has now been removed from your order.', 'woocommerce' ), $this->get_code() );
break;
break;
case self::E_WC_COUPON_NOT_YOURS_REMOVED:
/* translators: %s: coupon code */
$err = sprintf( __( 'Sorry, it seems the coupon "%s" is not yours - it has now been removed from your order.', 'woocommerce' ), $this->get_code() );
break;
break;
case self::E_WC_COUPON_ALREADY_APPLIED:
$err = __( 'Coupon code already applied!', 'woocommerce' );
break;
break;
case self::E_WC_COUPON_ALREADY_APPLIED_INDIV_USE_ONLY:
/* translators: %s: coupon code */
$err = sprintf( __( 'Sorry, coupon "%s" has already been applied and cannot be used in conjunction with other coupons.', 'woocommerce' ), $this->get_code() );
break;
break;
case self::E_WC_COUPON_USAGE_LIMIT_REACHED:
$err = __( 'Coupon usage limit has been reached.', 'woocommerce' );
break;
break;
case self::E_WC_COUPON_EXPIRED:
$err = __( 'This coupon has expired.', 'woocommerce' );
break;
break;
case self::E_WC_COUPON_MIN_SPEND_LIMIT_NOT_MET:
/* translators: %s: coupon minimum amount */
$err = sprintf( __( 'The minimum spend for this coupon is %s.', 'woocommerce' ), wc_price( $this->get_minimum_amount() ) );
break;
break;
case self::E_WC_COUPON_MAX_SPEND_LIMIT_MET:
/* translators: %s: coupon maximum amount */
$err = sprintf( __( 'The maximum spend for this coupon is %s.', 'woocommerce' ), wc_price( $this->get_maximum_amount() ) );
break;
break;
case self::E_WC_COUPON_NOT_APPLICABLE:
$err = __( 'Sorry, this coupon is not applicable to your cart contents.', 'woocommerce' );
break;
break;
case self::E_WC_COUPON_EXCLUDED_PRODUCTS:
// Store excluded products that are in cart in $products
// Store excluded products that are in cart in $products.
$products = array();
if ( ! WC()->cart->is_empty() ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
if ( in_array( $cart_item['product_id'], $this->get_excluded_product_ids() ) || in_array( $cart_item['variation_id'], $this->get_excluded_product_ids() ) || in_array( $cart_item['data']->get_parent_id(), $this->get_excluded_product_ids() ) ) {
if ( in_array( intval( $cart_item['product_id'] ), $this->get_excluded_product_ids(), true ) || in_array( intval( $cart_item['variation_id'] ), $this->get_excluded_product_ids(), true ) || in_array( intval( $cart_item['data']->get_parent_id() ), $this->get_excluded_product_ids(), true ) ) {
$products[] = $cart_item['data']->get_name();
}
}
@ -956,16 +984,16 @@ class WC_Coupon extends WC_Legacy_Coupon {
$err = sprintf( __( 'Sorry, this coupon is not applicable to the products: %s.', 'woocommerce' ), implode( ', ', $products ) );
break;
case self::E_WC_COUPON_EXCLUDED_CATEGORIES:
// Store excluded categories that are in cart in $categories
// Store excluded categories that are in cart in $categories.
$categories = array();
if ( ! WC()->cart->is_empty() ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$product_cats = wc_get_product_cat_ids( $cart_item['product_id'] );
$intersect = array_intersect( $product_cats, $this->get_excluded_product_categories() );
if ( sizeof( $intersect = array_intersect( $product_cats, $this->get_excluded_product_categories() ) ) > 0 ) {
if ( count( $intersect ) > 0 ) {
foreach ( $intersect as $cat_id ) {
$cat = get_term( $cat_id, 'product_cat' );
$cat = get_term( $cat_id, 'product_cat' );
$categories[] = $cat->name;
}
}
@ -977,10 +1005,10 @@ class WC_Coupon extends WC_Legacy_Coupon {
break;
case self::E_WC_COUPON_NOT_VALID_SALE_ITEMS:
$err = __( 'Sorry, this coupon is not valid for sale items.', 'woocommerce' );
break;
break;
default:
$err = '';
break;
break;
}
return apply_filters( 'woocommerce_coupon_error', $err, $err_code, $this );
}
@ -990,22 +1018,22 @@ class WC_Coupon extends WC_Legacy_Coupon {
* No coupon instance will be available where a coupon does not exist,
* so this static method exists.
*
* @param int $err_code Error code
* @return string| Error string
* @param int $err_code Error code.
* @return string Error string.
*/
public static function get_generic_coupon_error( $err_code ) {
switch ( $err_code ) {
case self::E_WC_COUPON_NOT_EXIST:
$err = __( 'Coupon does not exist!', 'woocommerce' );
break;
break;
case self::E_WC_COUPON_PLEASE_ENTER:
$err = __( 'Please enter a coupon code.', 'woocommerce' );
break;
break;
default:
$err = '';
break;
break;
}
// When using this static method, there is no $this to pass to filter
// When using this static method, there is no $this to pass to filter.
return apply_filters( 'woocommerce_coupon_error', $err, $err_code, null );
}
}

View File

@ -2,18 +2,15 @@
/**
* Class for customer download logs.
*
* @version 3.3.0
* @since 3.3.0
* @package WooCommerce/Classes
* @author Automattic
* @package WooCommerce/Classes
* @version 3.3.0
* @since 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WC_Customer_Download_Log.
* Customer download log class.
*/
class WC_Customer_Download_Log extends WC_Data {

View File

@ -1,20 +1,22 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for customer download permissions.
*
* @version 3.0.0
* @since 3.0.0
* @package WooCommerce/Classes
* @author WooThemes
* @package WooCommerce/Classes
* @version 3.0.0
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Customer download class.
*/
class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* This is the name of this object type.
*
* @var string
*/
protected $object_type = 'customer_download';
@ -41,9 +43,9 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Constructor.
*
* @param int|object|array $download
* @param int|object|array $download Download ID, instance or data.
*/
public function __construct( $download = 0 ) {
public function __construct( $download = 0 ) {
parent::__construct( $download );
if ( is_numeric( $download ) && $download > 0 ) {
@ -63,7 +65,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
if ( $this->get_id() > 0 ) {
$this->data_store->read( $this );
}
}
}
/*
|--------------------------------------------------------------------------
@ -74,7 +76,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get download id.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_download_id( $context = 'view' ) {
@ -84,7 +86,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get product id.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_product_id( $context = 'view' ) {
@ -94,7 +96,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get user id.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_user_id( $context = 'view' ) {
@ -104,7 +106,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get user_email.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_user_email( $context = 'view' ) {
@ -114,7 +116,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get order_id.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_order_id( $context = 'view' ) {
@ -124,7 +126,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get order_key.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_order_key( $context = 'view' ) {
@ -134,7 +136,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get downloads_remaining.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer|string
*/
public function get_downloads_remaining( $context = 'view' ) {
@ -144,7 +146,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get access_granted.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|null Object if the date is set or null if there is no date.
*/
public function get_access_granted( $context = 'view' ) {
@ -154,7 +156,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get access_expires.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|null Object if the date is set or null if there is no date.
*/
public function get_access_expires( $context = 'view' ) {
@ -164,12 +166,12 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Get download_count.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return integer
*/
public function get_download_count( $context = 'view' ) {
// Check for count of download logs.
$data_store = WC_Data_Store::load( 'customer-download-log' );
$data_store = WC_Data_Store::load( 'customer-download-log' );
$download_log_ids = $data_store->get_download_logs_for_permission( $this->get_id() );
$download_log_count = 0;
@ -195,7 +197,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set download id.
*
* @param string $value
* @param string $value Download ID.
*/
public function set_download_id( $value ) {
$this->set_prop( 'download_id', $value );
@ -203,7 +205,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set product id.
*
* @param int $value
* @param int $value Product ID.
*/
public function set_product_id( $value ) {
$this->set_prop( 'product_id', absint( $value ) );
@ -212,7 +214,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set user id.
*
* @param int $value
* @param int $value User ID.
*/
public function set_user_id( $value ) {
$this->set_prop( 'user_id', absint( $value ) );
@ -221,7 +223,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set user_email.
*
* @param int $value
* @param int $value User email.
*/
public function set_user_email( $value ) {
$this->set_prop( 'user_email', sanitize_email( $value ) );
@ -230,7 +232,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set order_id.
*
* @param int $value
* @param int $value Order ID.
*/
public function set_order_id( $value ) {
$this->set_prop( 'order_id', absint( $value ) );
@ -239,7 +241,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set order_key.
*
* @param string $value
* @param string $value Order key.
*/
public function set_order_key( $value ) {
$this->set_prop( 'order_key', $value );
@ -248,7 +250,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set downloads_remaining.
*
* @param integer|string $value
* @param integer|string $value Amount of downloads remaining.
*/
public function set_downloads_remaining( $value ) {
$this->set_prop( 'downloads_remaining', '' === $value ? '' : absint( $value ) );
@ -275,7 +277,7 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
/**
* Set download_count.
*
* @param int $value
* @param int $value Download count.
*/
public function set_download_count( $value ) {
$this->set_prop( 'download_count', absint( $value ) );
@ -285,8 +287,9 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
* Track a download on this permission.
*
* @since 3.3.0
* @param int user_id Id of the user performing the download
* @param string user_ip_address IP Address of the user performing the download
* @throws Exception When permission ID is invalid.
* @param int $user_id Id of the user performing the download.
* @param string $user_ip_address IP Address of the user performing the download.
*/
public function track_download( $user_id = null, $user_ip_address = null ) {
global $wpdb;
@ -300,15 +303,16 @@ class WC_Customer_Download extends WC_Data implements ArrayAccess {
// Use SQL to avoid possible issues with downloads in quick succession.
// If downloads_remaining is blank, leave it blank (unlimited).
// Also, ensure downloads_remaining doesn't drop below zero.
$query = $wpdb->prepare( "
$query = $wpdb->prepare(
"
UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions
SET download_count = download_count + 1,
downloads_remaining = IF( downloads_remaining = '', '', GREATEST( 0, downloads_remaining - 1 ) )
WHERE permission_id = %d",
$this->get_id()
);
$wpdb->query( $query );
$wpdb->query( $query ); // WPCS: unprepared SQL ok.
// Re-read this download from the data store to pull updated counts.
$this->data_store->read( $this );
@ -336,6 +340,7 @@ WHERE permission_id = %d",
/**
* Save data to the database.
*
* @since 3.0.0
* @return int Item ID
*/
@ -360,8 +365,9 @@ WHERE permission_id = %d",
*/
/**
* offsetGet
* @param string $offset
* OffsetGet.
*
* @param string $offset Offset.
* @return mixed
*/
public function offsetGet( $offset ) {
@ -371,9 +377,10 @@ WHERE permission_id = %d",
}
/**
* offsetSet
* @param string $offset
* @param mixed $value
* OffsetSet.
*
* @param string $offset Offset.
* @param mixed $value Value.
*/
public function offsetSet( $offset, $value ) {
if ( is_callable( array( $this, "set_$offset" ) ) ) {
@ -382,8 +389,9 @@ WHERE permission_id = %d",
}
/**
* offsetUnset
* @param string $offset
* OffsetUnset
*
* @param string $offset Offset.
*/
public function offsetUnset( $offset ) {
if ( is_callable( array( $this, "set_$offset" ) ) ) {
@ -392,12 +400,13 @@ WHERE permission_id = %d",
}
/**
* offsetExists
* @param string $offset
* OffsetExists.
*
* @param string $offset Offset.
* @return bool
*/
public function offsetExists( $offset ) {
return in_array( $offset, array_keys( $this->data ) );
return in_array( $offset, array_keys( $this->data ), true );
}
/**
@ -407,7 +416,7 @@ WHERE permission_id = %d",
* @return bool
*/
public function __isset( $key ) {
return in_array( $key, array_keys( $this->data ) );
return in_array( $key, array_keys( $this->data ), true );
}
/**

View File

@ -1,18 +1,17 @@
<?php
include_once( 'legacy/class-wc-legacy-customer.php' );
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* The WooCommerce customer class handles storage of the current customer's data, such as location.
*
* @class WC_Customer
* @version 3.0.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 3.0.0
*/
defined( 'ABSPATH' ) || exit;
require_once dirname( __FILE__ ) . '/legacy/class-wc-legacy-customer.php';
/**
* Customer class.
*/
class WC_Customer extends WC_Legacy_Customer {
@ -31,28 +30,28 @@ class WC_Customer extends WC_Legacy_Customer {
'role' => 'customer',
'username' => '',
'billing' => array(
'first_name' => '',
'last_name' => '',
'company' => '',
'address_1' => '',
'address_2' => '',
'city' => '',
'state' => '',
'postcode' => '',
'country' => '',
'email' => '',
'phone' => '',
'first_name' => '',
'last_name' => '',
'company' => '',
'address_1' => '',
'address_2' => '',
'city' => '',
'state' => '',
'postcode' => '',
'country' => '',
'email' => '',
'phone' => '',
),
'shipping' => array(
'first_name' => '',
'last_name' => '',
'company' => '',
'address_1' => '',
'address_2' => '',
'city' => '',
'state' => '',
'postcode' => '',
'country' => '',
'first_name' => '',
'last_name' => '',
'company' => '',
'address_1' => '',
'address_2' => '',
'city' => '',
'state' => '',
'postcode' => '',
'country' => '',
),
'is_paying_customer' => false,
);
@ -84,9 +83,9 @@ class WC_Customer extends WC_Legacy_Customer {
* If $customer is 'new', you can build a new WC_Customer object. If it's empty, some
* data will be pulled from the session for the current user/customer.
*
* @param WC_Customer|int $data Customer ID or data.
* @param bool $is_session True if this is the customer session
* @throws Exception if customer cannot be read/found and $data is set.
* @param WC_Customer|int $data Customer ID or data.
* @param bool $is_session True if this is the customer session.
* @throws Exception If customer cannot be read/found and $data is set.
*/
public function __construct( $data = 0, $is_session = false ) {
parent::__construct( $data );
@ -137,7 +136,12 @@ class WC_Customer extends WC_Legacy_Customer {
*/
public function delete_and_reassign( $reassign = null ) {
if ( $this->data_store ) {
$this->data_store->delete( $this, array( 'force_delete' => true, 'reassign' => $reassign ) );
$this->data_store->delete(
$this, array(
'force_delete' => true,
'reassign' => $reassign,
)
);
$this->set_id( 0 );
return true;
}
@ -175,13 +179,14 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get taxable address.
*
* @return array
*/
public function get_taxable_address() {
$tax_based_on = get_option( 'woocommerce_tax_based_on' );
// Check shipping method at this point to see if we need special handling
if ( true === apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) && sizeof( array_intersect( wc_get_chosen_shipping_method_ids(), apply_filters( 'woocommerce_local_pickup_methods', array( 'legacy_local_pickup', 'local_pickup' ) ) ) ) > 0 ) {
// Check shipping method at this point to see if we need special handling.
if ( true === apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) && count( array_intersect( wc_get_chosen_shipping_method_ids(), apply_filters( 'woocommerce_local_pickup_methods', array( 'legacy_local_pickup', 'local_pickup' ) ) ) ) > 0 ) {
$tax_based_on = 'base';
}
@ -267,7 +272,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set if customer has tax exemption.
*
* @param bool $is_vat_exempt
* @param bool $is_vat_exempt If is vat exempt.
*/
public function set_is_vat_exempt( $is_vat_exempt ) {
$this->is_vat_exempt = wc_string_to_bool( $is_vat_exempt );
@ -276,7 +281,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Calculated shipping?
*
* @param boolean $calculated
* @param bool $calculated If shipping is calculated.
*/
public function set_calculated_shipping( $calculated = true ) {
$this->calculated_shipping = wc_string_to_bool( $calculated );
@ -286,8 +291,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer's password.
*
* @since 3.0.0
* @param string $password
* @throws WC_Data_Exception
* @param string $password Password.
*/
public function set_password( $password ) {
$this->password = wc_clean( $password );
@ -296,7 +300,6 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Gets the customers last order.
*
* @param WC_Customer
* @return WC_Order|false
*/
public function get_last_order() {
@ -306,7 +309,6 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Return the number of orders this customer has.
*
* @param WC_Customer
* @return integer
*/
public function get_order_count() {
@ -316,7 +318,6 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Return how much money this customer has spent.
*
* @param WC_Customer
* @return float
*/
public function get_total_spent() {
@ -324,16 +325,16 @@ class WC_Customer extends WC_Legacy_Customer {
}
/*
|--------------------------------------------------------------------------
| Getters
|--------------------------------------------------------------------------
*/
|--------------------------------------------------------------------------
| Getters
|--------------------------------------------------------------------------
*/
/**
* Return the customer's username.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_username( $context = 'view' ) {
@ -344,7 +345,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return the customer's email.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_email( $context = 'view' ) {
@ -355,7 +356,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return customer's first name.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_first_name( $context = 'view' ) {
@ -366,7 +367,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return customer's last name.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_last_name( $context = 'view' ) {
@ -377,7 +378,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return customer's display name.
*
* @since 3.1.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_display_name( $context = 'view' ) {
@ -388,7 +389,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return customer's user role.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_role( $context = 'view' ) {
@ -399,7 +400,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return the date this customer was created.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|null object if the date is set or null if there is no date.
*/
public function get_date_created( $context = 'view' ) {
@ -410,7 +411,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Return the date this customer was last updated.
*
* @since 3.0.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return WC_DateTime|null object if the date is set or null if there is no date.
*/
public function get_date_modified( $context = 'view' ) {
@ -423,7 +424,7 @@ class WC_Customer extends WC_Legacy_Customer {
* @since 3.0.0
* @param string $prop Name of prop to get.
* @param string $address billing or shipping.
* @param string $context What the value is for. Valid values are view and edit.
* @param string $context What the value is for. Valid values are 'view' and 'edit'. What the value is for. Valid values are view and edit.
* @return mixed
*/
protected function get_address_prop( $prop, $address = 'billing', $context = 'view' ) {
@ -443,7 +444,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Get billing.
*
* @since 3.2.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_billing( $context = 'view' ) {
@ -453,7 +454,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_first_name.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_first_name( $context = 'view' ) {
@ -463,7 +464,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_last_name.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_last_name( $context = 'view' ) {
@ -473,7 +474,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_company.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_company( $context = 'view' ) {
@ -483,7 +484,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_address_1.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_address( $context = 'view' ) {
@ -493,7 +494,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_address_1.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_address_1( $context = 'view' ) {
@ -503,7 +504,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_address_2.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string $value
*/
public function get_billing_address_2( $context = 'view' ) {
@ -513,7 +514,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_city.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string $value
*/
public function get_billing_city( $context = 'view' ) {
@ -523,7 +524,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_state.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_state( $context = 'view' ) {
@ -533,7 +534,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_postcode.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_postcode( $context = 'view' ) {
@ -543,7 +544,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_country.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_country( $context = 'view' ) {
@ -553,7 +554,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_email.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_email( $context = 'view' ) {
@ -563,7 +564,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get billing_phone.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_billing_phone( $context = 'view' ) {
@ -574,7 +575,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Get shipping.
*
* @since 3.2.0
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return array
*/
public function get_shipping( $context = 'view' ) {
@ -584,7 +585,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_first_name.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_first_name( $context = 'view' ) {
@ -594,17 +595,17 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_last_name.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_last_name( $context = 'view' ) {
return $this->get_address_prop( 'last_name', 'shipping', $context );
return $this->get_address_prop( 'last_name', 'shipping', $context );
}
/**
* Get shipping_company.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_company( $context = 'view' ) {
@ -614,7 +615,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_address_1.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_address( $context = 'view' ) {
@ -624,7 +625,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_address_1.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_address_1( $context = 'view' ) {
@ -634,7 +635,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_address_2.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_address_2( $context = 'view' ) {
@ -644,7 +645,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_city.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_city( $context = 'view' ) {
@ -654,7 +655,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_state.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_state( $context = 'view' ) {
@ -664,7 +665,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_postcode.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_postcode( $context = 'view' ) {
@ -674,7 +675,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Get shipping_country.
*
* @param string $context
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return string
*/
public function get_shipping_country( $context = 'view' ) {
@ -684,11 +685,11 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Is the user a paying customer?
*
* @since 3.0.0
* @param string $context
* @since 3.0.0
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
* @return bool
*/
function get_is_paying_customer( $context = 'view' ) {
public function get_is_paying_customer( $context = 'view' ) {
return $this->get_prop( 'is_paying_customer', $context );
}
@ -702,8 +703,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer's username.
*
* @since 3.0.0
* @param string $username
* @throws WC_Data_Exception
* @param string $username Username.
*/
public function set_username( $username ) {
$this->set_prop( 'username', $username );
@ -713,8 +713,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer's email.
*
* @since 3.0.0
* @param string $value
* @throws WC_Data_Exception
* @param string $value Email.
*/
public function set_email( $value ) {
if ( $value && ! is_email( $value ) ) {
@ -727,8 +726,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer's first name.
*
* @since 3.0.0
* @param string $first_name
* @throws WC_Data_Exception
* @param string $first_name First name.
*/
public function set_first_name( $first_name ) {
$this->set_prop( 'first_name', $first_name );
@ -738,8 +736,7 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer's last name.
*
* @since 3.0.0
* @param string $last_name
* @throws WC_Data_Exception
* @param string $last_name Last name.
*/
public function set_last_name( $last_name ) {
$this->set_prop( 'last_name', $last_name );
@ -753,20 +750,19 @@ class WC_Customer extends WC_Legacy_Customer {
*/
public function set_display_name( $display_name ) {
/* translators: 1: first name 2: last name */
$this->set_prop( 'display_name', is_email( $display_name ) ? sprintf( __( '%1$s %2$s', 'display name', 'woocommerce' ), $this->get_first_name(), $this->get_last_name() ) : $display_name );
$this->set_prop( 'display_name', is_email( $display_name ) ? sprintf( _x( '%1$s %2$s', 'display name', 'woocommerce' ), $this->get_first_name(), $this->get_last_name() ) : $display_name );
}
/**
* Set customer's user role(s).
*
* @since 3.0.0
* @param mixed $role
* @throws WC_Data_Exception
* @param mixed $role User role.
*/
public function set_role( $role ) {
global $wp_roles;
if ( $role && ! empty( $wp_roles->roles ) && ! in_array( $role, array_keys( $wp_roles->roles ) ) ) {
if ( $role && ! empty( $wp_roles->roles ) && ! in_array( $role, array_keys( $wp_roles->roles ), true ) ) {
$this->error( 'customer_invalid_role', __( 'Invalid role', 'woocommerce' ) );
}
$this->set_prop( 'role', $role );
@ -777,7 +773,6 @@ class WC_Customer extends WC_Legacy_Customer {
*
* @since 3.0.0
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
* @throws WC_Data_Exception
*/
public function set_date_created( $date = null ) {
$this->set_date_prop( 'date_created', $date );
@ -788,7 +783,6 @@ class WC_Customer extends WC_Legacy_Customer {
*
* @since 3.0.0
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
* @throws WC_Data_Exception
*/
public function set_date_modified( $date = null ) {
$this->set_date_prop( 'date_modified', $date );
@ -798,7 +792,6 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer address to match shop base address.
*
* @since 3.0.0
* @throws WC_Data_Exception
*/
public function set_billing_address_to_base() {
$base = wc_get_customer_default_location();
@ -809,7 +802,6 @@ class WC_Customer extends WC_Legacy_Customer {
* Set customer shipping address to base address.
*
* @since 3.0.0
* @throws WC_Data_Exception
*/
public function set_shipping_address_to_base() {
$base = wc_get_customer_default_location();
@ -819,11 +811,10 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Sets all address info at once.
*
* @param string $country
* @param string $state
* @param string $postcode
* @param string $city
* @throws WC_Data_Exception
* @param string $country Country.
* @param string $state State.
* @param string $postcode Postcode.
* @param string $city City.
*/
public function set_billing_location( $country, $state = '', $postcode = '', $city = '' ) {
$billing = $this->get_prop( 'billing', 'edit' );
@ -837,11 +828,10 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Sets all shipping info at once.
*
* @param string $country
* @param string $state
* @param string $postcode
* @param string $city
* @throws WC_Data_Exception
* @param string $country Country.
* @param string $state State.
* @param string $postcode Postcode.
* @param string $city City.
*/
public function set_shipping_location( $country, $state = '', $postcode = '', $city = '' ) {
$shipping = $this->get_prop( 'shipping', 'edit' );
@ -856,9 +846,9 @@ class WC_Customer extends WC_Legacy_Customer {
* Sets a prop for a setter method.
*
* @since 3.0.0
* @param string $prop Name of prop to set.
* @param string $prop Name of prop to set.
* @param string $address Name of address to set. billing or shipping.
* @param mixed $value Value of the prop.
* @param mixed $value Value of the prop.
*/
protected function set_address_prop( $prop, $address = 'billing', $value ) {
if ( array_key_exists( $prop, $this->data[ $address ] ) ) {
@ -875,8 +865,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_first_name.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing first name.
*/
public function set_billing_first_name( $value ) {
$this->set_address_prop( 'first_name', 'billing', $value );
@ -885,8 +874,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_last_name.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing last name.
*/
public function set_billing_last_name( $value ) {
$this->set_address_prop( 'last_name', 'billing', $value );
@ -895,8 +883,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_company.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing company.
*/
public function set_billing_company( $value ) {
$this->set_address_prop( 'company', 'billing', $value );
@ -905,8 +892,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_address_1.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing address line 1.
*/
public function set_billing_address( $value ) {
$this->set_billing_address_1( $value );
@ -915,8 +901,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_address_1.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing address line 1.
*/
public function set_billing_address_1( $value ) {
$this->set_address_prop( 'address_1', 'billing', $value );
@ -925,8 +910,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_address_2.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing address line 2.
*/
public function set_billing_address_2( $value ) {
$this->set_address_prop( 'address_2', 'billing', $value );
@ -935,8 +919,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_city.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing city.
*/
public function set_billing_city( $value ) {
$this->set_address_prop( 'city', 'billing', $value );
@ -945,8 +928,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_state.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing state.
*/
public function set_billing_state( $value ) {
$this->set_address_prop( 'state', 'billing', $value );
@ -955,8 +937,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_postcode.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing postcode.
*/
public function set_billing_postcode( $value ) {
$this->set_address_prop( 'postcode', 'billing', $value );
@ -965,8 +946,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_country.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing country.
*/
public function set_billing_country( $value ) {
$this->set_address_prop( 'country', 'billing', $value );
@ -975,8 +955,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_email.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing email.
*/
public function set_billing_email( $value ) {
if ( $value && ! is_email( $value ) ) {
@ -988,8 +967,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set billing_phone.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Billing phone.
*/
public function set_billing_phone( $value ) {
$this->set_address_prop( 'phone', 'billing', $value );
@ -998,8 +976,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_first_name.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping first name.
*/
public function set_shipping_first_name( $value ) {
$this->set_address_prop( 'first_name', 'shipping', $value );
@ -1008,8 +985,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_last_name.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping last name.
*/
public function set_shipping_last_name( $value ) {
$this->set_address_prop( 'last_name', 'shipping', $value );
@ -1018,8 +994,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_company.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping company.
*/
public function set_shipping_company( $value ) {
$this->set_address_prop( 'company', 'shipping', $value );
@ -1028,8 +1003,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_address_1.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping address line 1.
*/
public function set_shipping_address( $value ) {
$this->set_shipping_address_1( $value );
@ -1038,8 +1012,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_address_1.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping address line 1.
*/
public function set_shipping_address_1( $value ) {
$this->set_address_prop( 'address_1', 'shipping', $value );
@ -1048,8 +1021,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_address_2.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping address line 2.
*/
public function set_shipping_address_2( $value ) {
$this->set_address_prop( 'address_2', 'shipping', $value );
@ -1058,8 +1030,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_city.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping city.
*/
public function set_shipping_city( $value ) {
$this->set_address_prop( 'city', 'shipping', $value );
@ -1068,8 +1039,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_state.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping state.
*/
public function set_shipping_state( $value ) {
$this->set_address_prop( 'state', 'shipping', $value );
@ -1078,8 +1048,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_postcode.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping postcode.
*/
public function set_shipping_postcode( $value ) {
$this->set_address_prop( 'postcode', 'shipping', $value );
@ -1088,8 +1057,7 @@ class WC_Customer extends WC_Legacy_Customer {
/**
* Set shipping_country.
*
* @param string $value
* @throws WC_Data_Exception
* @param string $value Shipping country.
*/
public function set_shipping_country( $value ) {
$this->set_address_prop( 'country', 'shipping', $value );
@ -1099,10 +1067,9 @@ class WC_Customer extends WC_Legacy_Customer {
* Set if the user a paying customer.
*
* @since 3.0.0
* @param bool $is_paying_customer
* @throws WC_Data_Exception
* @param bool $is_paying_customer If is a paying customer.
*/
function set_is_paying_customer( $is_paying_customer ) {
public function set_is_paying_customer( $is_paying_customer ) {
$this->set_prop( 'is_paying_customer', (bool) $is_paying_customer );
}
}

View File

@ -4,18 +4,14 @@
*
* Extends Exception to provide additional data.
*
* @author WooThemes
* @category Core
* @package WooCommerce
* @since 3.0
* @package WooCommerce\Classes
* @since 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* WC_Data_Exception class.
* Data exception class.
*/
class WC_Data_Exception extends Exception {

View File

@ -1,20 +1,23 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC Data Store.
*
* @since 3.0.0
* @version 3.0.0
* @category Class
* @author WooThemes
* @package WooCommerce\Classes
* @since 3.0.0
* @version 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Data store class.
*/
class WC_Data_Store {
/**
* Contains an instance of the data store class that we are working with.
*
* @var WC_Data_Store
*/
private $instance = null;
@ -26,6 +29,8 @@ class WC_Data_Store {
* that type will be used first when available, if a store is requested like
* this and doesn't exist, then the store would fall back to 'product'.
* Ran through `woocommerce_data_stores`.
*
* @var array
*/
private $stores = array(
'coupon' => 'WC_Coupon_Data_Store_CPT',
@ -52,11 +57,14 @@ class WC_Data_Store {
/**
* Contains the name of the current data store's class name.
*
* @var string
*/
private $current_class_name = '';
/**
* The object type this store works with.
*
* @var string
*/
private $object_type = '';
@ -66,18 +74,17 @@ class WC_Data_Store {
* Tells WC_Data_Store which object (coupon, product, order, etc)
* store we want to work with.
*
* @throws Exception When validation fails.
* @param string $object_type Name of object.
*
* @throws Exception
*/
public function __construct( $object_type ) {
$this->object_type = $object_type;
$this->stores = apply_filters( 'woocommerce_data_stores', $this->stores );
$this->stores = apply_filters( 'woocommerce_data_stores', $this->stores );
// If this object type can't be found, check to see if we can load one
// level up (so if product-type isn't found, we try product).
if ( ! array_key_exists( $object_type, $this->stores ) ) {
$pieces = explode( '-', $object_type );
$pieces = explode( '-', $object_type );
$object_type = $pieces[0];
}
@ -88,13 +95,13 @@ class WC_Data_Store {
throw new Exception( __( 'Invalid data store.', 'woocommerce' ) );
}
$this->current_class_name = get_class( $store );
$this->instance = $store;
$this->instance = $store;
} else {
if ( ! class_exists( $store ) ) {
throw new Exception( __( 'Invalid data store.', 'woocommerce' ) );
}
$this->current_class_name = $store;
$this->instance = new $store;
$this->instance = new $store();
}
} else {
throw new Exception( __( 'Invalid data store.', 'woocommerce' ) );
@ -143,7 +150,7 @@ class WC_Data_Store {
* Reads an object from the data store.
*
* @since 3.0.0
* @param WC_Data
* @param WC_Data $data WooCommerce data instance.
*/
public function read( &$data ) {
$this->instance->read( $data );
@ -153,7 +160,7 @@ class WC_Data_Store {
* Create an object in the data store.
*
* @since 3.0.0
* @param WC_Data
* @param WC_Data $data WooCommerce data instance.
*/
public function create( &$data ) {
$this->instance->create( $data );
@ -163,7 +170,7 @@ class WC_Data_Store {
* Update an object in the data store.
*
* @since 3.0.0
* @param WC_Data
* @param WC_Data $data WooCommerce data instance.
*/
public function update( &$data ) {
$this->instance->update( $data );
@ -173,8 +180,8 @@ class WC_Data_Store {
* Delete an object from the data store.
*
* @since 3.0.0
* @param WC_Data
* @param array $args Array of args to pass to the delete method.
* @param WC_Data $data WooCommerce data instance.
* @param array $args Array of args to pass to the delete method.
*/
public function delete( &$data, $args = array() ) {
$this->instance->delete( $data, $args );
@ -186,10 +193,8 @@ class WC_Data_Store {
* through to the instance if that function exists.
*
* @since 3.0.0
*
* @param $method
* @param $parameters
*
* @param string $method Method.
* @param mixed $parameters Parameters.
* @return mixed
*/
public function __call( $method, $parameters ) {
@ -198,5 +203,4 @@ class WC_Data_Store {
return call_user_func_array( array( $this->instance, $method ), array_merge( array( &$object ), $parameters ) );
}
}
}

View File

@ -1,18 +1,16 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC Wrapper for PHP DateTime which adds support for gmt/utc offset when a
* timezone is absent.
* timezone is absent
*
* @class WC_DateTime
* @since 3.0.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @since 3.0.0
* @package WooCommerce/Classes
*/
defined( 'ABSPATH' ) || exit;
/**
* Datetime class.
*/
class WC_DateTime extends DateTime {
@ -37,7 +35,7 @@ class WC_DateTime extends DateTime {
/**
* Set UTC offset - this is a fixed offset instead of a timezone.
*
* @param int $offset
* @param int $offset Offset.
*/
public function set_utc_offset( $offset ) {
$this->utc_offset = intval( $offset );
@ -57,8 +55,7 @@ class WC_DateTime extends DateTime {
/**
* Set timezone.
*
* @param DateTimeZone $timezone
*
* @param DateTimeZone $timezone DateTimeZone instance.
* @return DateTime
*/
public function setTimezone( $timezone ) {
@ -90,7 +87,7 @@ class WC_DateTime extends DateTime {
* Format a date based on the offset timestamp.
*
* @since 3.0.0
* @param string $format
* @param string $format Date format.
* @return string
*/
public function date( $format ) {
@ -101,7 +98,7 @@ class WC_DateTime extends DateTime {
* Return a localised date based on offset timestamp. Wrapper for date_i18n function.
*
* @since 3.0.0
* @param string $format
* @param string $format Date format.
* @return string
*/
public function date_i18n( $format = 'Y-m-d' ) {

View File

@ -7,9 +7,7 @@
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* Handles deprecation notices and triggering of legacy action hooks.

View File

@ -7,9 +7,7 @@
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/**
* Handles deprecation notices and triggering of legacy filter hooks

View File

@ -509,7 +509,7 @@ class WC_Discounts {
$this->discounts[ $coupon->get_code() ][ $item->key ] += $discount;
}
// Allow post-processing for custom coupon types (e.g. calculating discrepancy, etc)
// Allow post-processing for custom coupon types (e.g. calculating discrepancy, etc).
$this->discounts[ $coupon->get_code() ] = apply_filters( 'woocommerce_coupon_custom_discounts_array', $this->discounts[ $coupon->get_code() ], $coupon );
return array_sum( $this->discounts[ $coupon->get_code() ] );

View File

@ -1,19 +1,17 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Download handler.
* Download handler
*
* Handle digital downloads.
*
* @class WC_Download_Handler
* @version 2.2.0
* @package WooCommerce/Classes
* @category Class
* @author WooThemes
* @package WooCommerce/Classes
* @version 2.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Download handler class.
*/
class WC_Download_Handler {
@ -21,7 +19,7 @@ class WC_Download_Handler {
* Hook in methods.
*/
public static function init() {
if ( isset( $_GET['download_file'], $_GET['order'] ) && ( isset( $_GET['email'] ) || isset( $_GET['uid'] ) ) ) {
if ( isset( $_GET['download_file'], $_GET['order'] ) && ( isset( $_GET['email'] ) || isset( $_GET['uid'] ) ) ) { // WPCS: input var ok, CSRF ok.
add_action( 'init', array( __CLASS__, 'download_product' ) );
}
add_action( 'woocommerce_download_file_redirect', array( __CLASS__, 'download_file_redirect' ), 10, 2 );
@ -33,45 +31,47 @@ class WC_Download_Handler {
* Check if we need to download a file and check validity.
*/
public static function download_product() {
$product_id = absint( $_GET['download_file'] );
$product = wc_get_product( $product_id );
$data_store = WC_Data_Store::load( 'customer-download' );
$product_id = absint( $_GET['download_file'] ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.VIP.ValidatedSanitizedInput.InputNotValidated
$product = wc_get_product( $product_id );
$data_store = WC_Data_Store::load( 'customer-download' );
if ( ! $product || empty( $_GET['key'] ) || empty( $_GET['order'] ) ) {
if ( ! $product || empty( $_GET['key'] ) || empty( $_GET['order'] ) ) { // WPCS: input var ok, CSRF ok.
self::download_error( __( 'Invalid download link.', 'woocommerce' ) );
}
// Fallback, accept email address if it's passed.
if ( empty( $_GET['email'] ) && empty( $_GET['uid'] ) ) {
if ( empty( $_GET['email'] ) && empty( $_GET['uid'] ) ) { // WPCS: input var ok, CSRF ok.
self::download_error( __( 'Invalid download link.', 'woocommerce' ) );
}
if ( isset( $_GET['email'] ) ) {
$email_address = $_GET['email'];
if ( isset( $_GET['email'] ) ) { // WPCS: input var ok, CSRF ok.
$email_address = wp_unslash( $_GET['email'] ); // WPCS: input var ok, CSRF ok, sanitization ok.
} else {
// Get email address from order to verify hash.
$order_id = wc_get_order_id_by_order_key( $_GET['order'] );
$order = wc_get_order( $order_id );
$order_id = wc_get_order_id_by_order_key( wc_clean( wp_unslash( $_GET['order'] ) ) ); // WPCS: input var ok, CSRF ok.
$order = wc_get_order( $order_id );
$email_address = is_a( $order, 'WC_Order' ) ? $order->get_billing_email() : null;
// Prepare email address hash.
$email_hash = function_exists( 'hash' ) ? hash( 'sha256', $email_address ) : sha1( $email_address );
if ( is_null( $email_address ) || ! hash_equals( $_GET['uid'], $email_hash ) ) {
if ( is_null( $email_address ) || ! hash_equals( wp_unslash( $_GET['uid'] ), $email_hash ) ) { // WPCS: input var ok, CSRF ok, sanitization ok.
self::download_error( __( 'Invalid download link.', 'woocommerce' ) );
}
}
$download_ids = $data_store->get_downloads( array(
'user_email' => sanitize_email( str_replace( ' ', '+', $email_address ) ),
'order_key' => wc_clean( $_GET['order'] ),
'product_id' => $product_id,
'download_id' => wc_clean( preg_replace( '/\s+/', ' ', $_GET['key'] ) ),
'orderby' => 'downloads_remaining',
'order' => 'DESC',
'limit' => 1,
'return' => 'ids',
) );
$download_ids = $data_store->get_downloads(
array(
'user_email' => sanitize_email( str_replace( ' ', '+', $email_address ) ),
'order_key' => wc_clean( wp_unslash( $_GET['order'] ) ), // WPCS: input var ok, CSRF ok.
'product_id' => $product_id,
'download_id' => wc_clean( preg_replace( '/\s+/', ' ', wp_unslash( $_GET['key'] ) ) ), // WPCS: input var ok, CSRF ok, sanitization ok.
'orderby' => 'downloads_remaining',
'order' => 'DESC',
'limit' => 1,
'return' => 'ids',
)
);
if ( empty( $download_ids ) ) {
self::download_error( __( 'Invalid download link.', 'woocommerce' ) );
@ -97,7 +97,7 @@ class WC_Download_Handler {
// Track the download in logs and change remaining/counts.
$current_user_id = get_current_user_id();
$ip_address = WC_Geolocation::get_ip_address();
$ip_address = WC_Geolocation::get_ip_address();
$download->track_download( $current_user_id > 0 ? $current_user_id : null, ! empty( $ip_address ) ? $ip_address : null );
self::download( $product->get_file_download_path( $download->get_download_id() ), $download->get_product_id() );
@ -105,19 +105,23 @@ class WC_Download_Handler {
/**
* Check if an order is valid for downloading from.
* @param WC_Customer_Download $download
* @access private
*
* @param WC_Customer_Download $download Download instance.
*/
private static function check_order_is_valid( $download ) {
if ( $download->get_order_id() && ( $order = wc_get_order( $download->get_order_id() ) ) && ! $order->is_download_permitted() ) {
self::download_error( __( 'Invalid order.', 'woocommerce' ), '', 403 );
if ( $download->get_order_id() ) {
$order = wc_get_order( $download->get_order_id() );
if ( $order && ! $order->is_download_permitted() ) {
self::download_error( __( 'Invalid order.', 'woocommerce' ), '', 403 );
}
}
}
/**
* Check if there are downloads remaining.
* @param WC_Customer_Download $download
* @access private
*
* @param WC_Customer_Download $download Download instance.
*/
private static function check_downloads_remaining( $download ) {
if ( '' !== $download->get_downloads_remaining() && 0 >= $download->get_downloads_remaining() ) {
@ -127,8 +131,8 @@ class WC_Download_Handler {
/**
* Check if the download has expired.
* @param WC_Customer_Download $download
* @access private
*
* @param WC_Customer_Download $download Download instance.
*/
private static function check_download_expiry( $download ) {
if ( ! is_null( $download->get_access_expires() ) && $download->get_access_expires()->getTimestamp() < strtotime( 'midnight', current_time( 'timestamp', true ) ) ) {
@ -138,14 +142,14 @@ class WC_Download_Handler {
/**
* Check if a download requires the user to login first.
* @param WC_Customer_Download $download
* @access private
*
* @param WC_Customer_Download $download Download instance.
*/
private static function check_download_login_required( $download ) {
if ( $download->get_user_id() && 'yes' === get_option( 'woocommerce_downloads_require_login' ) ) {
if ( ! is_user_logged_in() ) {
if ( wc_get_page_id( 'myaccount' ) ) {
wp_safe_redirect( add_query_arg( 'wc_error', urlencode( __( 'You must be logged in to download files.', 'woocommerce' ) ), wc_get_page_permalink( 'myaccount' ) ) );
wp_safe_redirect( add_query_arg( 'wc_error', rawurlencode( __( 'You must be logged in to download files.', 'woocommerce' ) ), wc_get_page_permalink( 'myaccount' ) ) );
exit;
} else {
self::download_error( __( 'You must be logged in to download files.', 'woocommerce' ) . ' <a href="' . esc_url( wp_login_url( wc_get_page_permalink( 'myaccount' ) ) ) . '" class="wc-forward">' . __( 'Login', 'woocommerce' ) . '</a>', __( 'Log in to Download Files', 'woocommerce' ), 403 );
@ -157,16 +161,18 @@ class WC_Download_Handler {
}
/**
* @deprecated
* Count download.
*
* @param $download_data
* @deprecated unknown
* @param array $download_data Download data.
*/
public static function count_download( $download_data ) {}
/**
* Download a file - hook into init function.
* @param string $file_path URL to file
* @param integer $product_id of the product being downloaded
*
* @param string $file_path URL to file.
* @param integer $product_id Product ID of the product being downloaded.
*/
public static function download( $file_path, $product_id ) {
if ( ! $file_path ) {
@ -182,17 +188,18 @@ class WC_Download_Handler {
$filename = apply_filters( 'woocommerce_file_download_filename', $filename, $product_id );
$file_download_method = apply_filters( 'woocommerce_file_download_method', get_option( 'woocommerce_file_download_method', 'force' ), $product_id );
// Add action to prevent issues in IE
// Add action to prevent issues in IE.
add_action( 'nocache_headers', array( __CLASS__, 'ie_nocache_headers_fix' ) );
// Trigger download via one of the methods
// Trigger download via one of the methods.
do_action( 'woocommerce_download_file_' . $file_download_method, $file_path, $filename );
}
/**
* Redirect to a file to start the download.
* @param string $file_path
* @param string $filename
*
* @param string $file_path File path.
* @param string $filename File name.
*/
public static function download_file_redirect( $file_path, $filename = '' ) {
header( 'Location: ' . $file_path );
@ -201,7 +208,8 @@ class WC_Download_Handler {
/**
* Parse file path and see if its remote or local.
* @param string $file_path
*
* @param string $file_path File path.
* @return array
*/
public static function parse_file_path( $file_path ) {
@ -215,18 +223,18 @@ class WC_Download_Handler {
* via filters we can still do the string replacement on a HTTP file.
*/
$replacements = array(
$wp_uploads_url => $wp_uploads_dir,
network_site_url( '/', 'https' ) => ABSPATH,
$wp_uploads_url => $wp_uploads_dir,
network_site_url( '/', 'https' ) => ABSPATH,
str_replace( 'https:', 'http:', network_site_url( '/', 'http' ) ) => ABSPATH,
site_url( '/', 'https' ) => ABSPATH,
str_replace( 'https:', 'http:', site_url( '/', 'http' ) ) => ABSPATH,
site_url( '/', 'https' ) => ABSPATH,
str_replace( 'https:', 'http:', site_url( '/', 'http' ) ) => ABSPATH,
);
$file_path = str_replace( array_keys( $replacements ), array_values( $replacements ), $file_path );
$parsed_file_path = parse_url( $file_path );
$parsed_file_path = wp_parse_url( $file_path );
$remote_file = true;
// See if path needs an abspath prepended to work
// See if path needs an abspath prepended to work.
if ( file_exists( ABSPATH . $file_path ) ) {
$remote_file = false;
$file_path = ABSPATH . $file_path;
@ -235,8 +243,8 @@ class WC_Download_Handler {
$remote_file = false;
$file_path = realpath( WP_CONTENT_DIR . substr( $file_path, 11 ) );
// Check if we have an absolute path
} elseif ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array( 'http', 'https', 'ftp' ) ) ) && isset( $parsed_file_path['path'] ) && file_exists( $parsed_file_path['path'] ) ) {
// Check if we have an absolute path.
} elseif ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array( 'http', 'https', 'ftp' ), true ) ) && isset( $parsed_file_path['path'] ) && file_exists( $parsed_file_path['path'] ) ) {
$remote_file = false;
$file_path = $parsed_file_path['path'];
}
@ -249,19 +257,20 @@ class WC_Download_Handler {
/**
* Download a file using X-Sendfile, X-Lighttpd-Sendfile, or X-Accel-Redirect if available.
* @param string $file_path
* @param string $filename
*
* @param string $file_path File path.
* @param string $filename File name.
*/
public static function download_file_xsendfile( $file_path, $filename ) {
$parsed_file_path = self::parse_file_path( $file_path );
if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules() ) ) {
if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules(), true ) ) {
self::download_headers( $parsed_file_path['file_path'], $filename );
header( "X-Sendfile: " . $parsed_file_path['file_path'] );
header( 'X-Sendfile: ' . $parsed_file_path['file_path'] );
exit;
} elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) {
self::download_headers( $parsed_file_path['file_path'], $filename );
header( "X-Lighttpd-Sendfile: " . $parsed_file_path['file_path'] );
header( 'X-Lighttpd-Sendfile: ' . $parsed_file_path['file_path'] );
exit;
} elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) {
self::download_headers( $parsed_file_path['file_path'], $filename );
@ -270,14 +279,15 @@ class WC_Download_Handler {
exit;
}
// Fallback
// Fallback.
self::download_file_force( $file_path, $filename );
}
/**
* Force download - this is the default method.
* @param string $file_path
* @param string $filename
*
* @param string $file_path File path.
* @param string $filename File name.
*/
public static function download_file_force( $file_path, $filename ) {
$parsed_file_path = self::parse_file_path( $file_path );
@ -297,17 +307,17 @@ class WC_Download_Handler {
/**
* Get content type of a download.
* @param string $file_path
*
* @param string $file_path File path.
* @return string
* @access private
*/
private static function get_download_content_type( $file_path ) {
$file_extension = strtolower( substr( strrchr( $file_path, "." ), 1 ) );
$ctype = "application/force-download";
$file_extension = strtolower( substr( strrchr( $file_path, '.' ), 1 ) );
$ctype = 'application/force-download';
foreach ( get_allowed_mime_types() as $mime => $type ) {
$mimes = explode( '|', $mime );
if ( in_array( $file_extension, $mimes ) ) {
if ( in_array( $file_extension, $mimes, true ) ) {
$ctype = $type;
break;
}
@ -318,23 +328,24 @@ class WC_Download_Handler {
/**
* Set headers for the download.
* @param string $file_path
* @param string $filename
* @access private
*
* @param string $file_path File path.
* @param string $filename File name.
*/
private static function download_headers( $file_path, $filename ) {
self::check_server_config();
self::clean_buffers();
wc_nocache_headers();
header( "X-Robots-Tag: noindex, nofollow", true );
header( "Content-Type: " . self::get_download_content_type( $file_path ) );
header( "Content-Description: File Transfer" );
header( "Content-Disposition: attachment; filename=\"" . $filename . "\";" );
header( "Content-Transfer-Encoding: binary" );
header( 'X-Robots-Tag: noindex, nofollow', true );
header( 'Content-Type: ' . self::get_download_content_type( $file_path ) );
header( 'Content-Description: File Transfer' );
header( 'Content-Disposition: attachment; filename="' . $filename . '";' );
header( 'Content-Transfer-Encoding: binary' );
if ( $size = @filesize( $file_path ) ) {
header( "Content-Length: " . $size );
$size = @filesize( $file_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
if ( $size ) {
header( 'Content-Length: ' . $size );
}
}
@ -347,50 +358,48 @@ class WC_Download_Handler {
set_magic_quotes_runtime( 0 ); // @codingStandardsIgnoreLine
}
if ( function_exists( 'apache_setenv' ) ) {
@apache_setenv( 'no-gzip', 1 );
@apache_setenv( 'no-gzip', 1 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_apache_setenv
}
@ini_set( 'zlib.output_compression', 'Off' );
@session_write_close();
@ini_set( 'zlib.output_compression', 'Off' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_set
@session_write_close(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.SessionFunctionsUsage.session_session_write_close
}
/**
* Clean all output buffers.
*
* Can prevent errors, for example: transfer closed with 3 bytes remaining to read.
*
* @access private
*/
private static function clean_buffers() {
if ( ob_get_level() ) {
$levels = ob_get_level();
for ( $i = 0; $i < $levels; $i++ ) {
@ob_end_clean();
@ob_end_clean(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
}
} else {
@ob_end_clean();
@ob_end_clean(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
}
}
/**
* readfile_chunked.
* Read file chunked.
*
* Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/.
*
* @param string $file
* @return bool Success or fail
* @param string $file File.
* @return bool Success or fail
*/
public static function readfile_chunked( $file ) {
if ( ! defined( 'WC_CHUNK_SIZE' ) ) {
define( 'WC_CHUNK_SIZE', 1024 * 1024 );
}
$handle = @fopen( $file, 'r' );
$handle = @fopen( $file, 'r' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
if ( false === $handle ) {
return false;
}
while ( ! @feof( $handle ) ) {
echo @fread( $handle, (int) WC_CHUNK_SIZE );
while ( ! @feof( $handle ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
echo @fread( $handle, (int) WC_CHUNK_SIZE ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions.file_system_read_fread
if ( ob_get_length() ) {
ob_flush();
@ -398,7 +407,7 @@ class WC_Download_Handler {
}
}
return @fclose( $handle );
return @fclose( $handle ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fclose
}
/**
@ -406,7 +415,7 @@ class WC_Download_Handler {
*
* IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set.
*
* @param array $headers
* @param array $headers HTTP headers.
* @return array
*/
public static function ie_nocache_headers_fix( $headers ) {
@ -419,16 +428,16 @@ class WC_Download_Handler {
/**
* Die with an error message if the download fails.
* @param string $message
* @param string $title
* @param integer $status
* @access private
*
* @param string $message Error message.
* @param string $title Error title.
* @param integer $status Error status.
*/
private static function download_error( $message, $title = '', $status = 404 ) {
if ( ! strstr( $message, '<a ' ) ) {
$message .= ' <a href="' . esc_url( wc_get_page_permalink( 'shop' ) ) . '" class="wc-forward">' . esc_html__( 'Go to shop', 'woocommerce' ) . '</a>';
}
wp_die( $message, $title, array( 'response' => $status ) );
wp_die( $message, $title, array( 'response' => $status ) ); // WPCS: XSS ok.
}
}

View File

@ -1,32 +1,40 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Transactional Emails Controller
*
* WooCommerce Emails Class which handles the sending on transactional emails and email templates. This class loads in available emails.
*
* @class WC_Emails
* @version 2.3.0
* @package WooCommerce/Classes/Emails
* @category Class
* @author WooThemes
* @package WooCommerce/Classes/Emails
* @version 2.3.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Emails class.
*/
class WC_Emails {
/** @var array Array of email notification classes */
public $emails;
/**
* Array of email notification classes
*
* @var array
*/
public $emails = array();
/** @var WC_Emails The single instance of the class */
/**
* The single instance of the class
*
* @var WC_Emails
*/
protected static $_instance = null;
/**
* Background emailer class.
*
* @var WC_Background_Emailer
*/
protected static $background_emailer;
protected static $background_emailer = null;
/**
* Main WC_Emails Instance.
@ -66,27 +74,29 @@ class WC_Emails {
* Hook in all transactional emails.
*/
public static function init_transactional_emails() {
$email_actions = apply_filters( 'woocommerce_email_actions', array(
'woocommerce_low_stock',
'woocommerce_no_stock',
'woocommerce_product_on_backorder',
'woocommerce_order_status_pending_to_processing',
'woocommerce_order_status_pending_to_completed',
'woocommerce_order_status_processing_to_cancelled',
'woocommerce_order_status_pending_to_failed',
'woocommerce_order_status_pending_to_on-hold',
'woocommerce_order_status_failed_to_processing',
'woocommerce_order_status_failed_to_completed',
'woocommerce_order_status_failed_to_on-hold',
'woocommerce_order_status_on-hold_to_processing',
'woocommerce_order_status_on-hold_to_cancelled',
'woocommerce_order_status_on-hold_to_failed',
'woocommerce_order_status_completed',
'woocommerce_order_fully_refunded',
'woocommerce_order_partially_refunded',
'woocommerce_new_customer_note',
'woocommerce_created_customer',
) );
$email_actions = apply_filters(
'woocommerce_email_actions', array(
'woocommerce_low_stock',
'woocommerce_no_stock',
'woocommerce_product_on_backorder',
'woocommerce_order_status_pending_to_processing',
'woocommerce_order_status_pending_to_completed',
'woocommerce_order_status_processing_to_cancelled',
'woocommerce_order_status_pending_to_failed',
'woocommerce_order_status_pending_to_on-hold',
'woocommerce_order_status_failed_to_processing',
'woocommerce_order_status_failed_to_completed',
'woocommerce_order_status_failed_to_on-hold',
'woocommerce_order_status_on-hold_to_processing',
'woocommerce_order_status_on-hold_to_cancelled',
'woocommerce_order_status_on-hold_to_failed',
'woocommerce_order_status_completed',
'woocommerce_order_fully_refunded',
'woocommerce_order_partially_refunded',
'woocommerce_new_customer_note',
'woocommerce_created_customer',
)
);
if ( apply_filters( 'woocommerce_defer_transactional_emails', false ) ) {
self::$background_emailer = new WC_Background_Emailer();
@ -107,10 +117,12 @@ class WC_Emails {
*/
public static function queue_transactional_email() {
if ( is_a( self::$background_emailer, 'WC_Background_Emailer' ) ) {
self::$background_emailer->push_to_queue( array(
'filter' => current_filter(),
'args' => func_get_args(),
) );
self::$background_emailer->push_to_queue(
array(
'filter' => current_filter(),
'args' => func_get_args(),
)
);
} else {
call_user_func_array( array( __CLASS__, 'send_transactional_email' ), func_get_args() );
}
@ -150,19 +162,18 @@ class WC_Emails {
do_action_ref_array( current_filter() . '_notification', $args );
} catch ( Exception $e ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
trigger_error( 'Transactional email triggered fatal error for callback ' . current_filter(), E_USER_WARNING );
trigger_error( 'Transactional email triggered fatal error for callback ' . current_filter(), E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
}
}
}
/**
* Constructor for the email class hooks in all emails that can be sent.
*
*/
public function __construct() {
$this->init();
// Email Header, Footer and content hooks
// Email Header, Footer and content hooks.
add_action( 'woocommerce_email_header', array( $this, 'email_header' ) );
add_action( 'woocommerce_email_footer', array( $this, 'email_footer' ) );
add_action( 'woocommerce_email_order_details', array( $this, 'order_downloads' ), 10, 4 );
@ -171,16 +182,16 @@ class WC_Emails {
add_action( 'woocommerce_email_customer_details', array( $this, 'customer_details' ), 10, 3 );
add_action( 'woocommerce_email_customer_details', array( $this, 'email_addresses' ), 20, 3 );
// Hooks for sending emails during store events
// Hooks for sending emails during store events.
add_action( 'woocommerce_low_stock_notification', array( $this, 'low_stock' ) );
add_action( 'woocommerce_no_stock_notification', array( $this, 'no_stock' ) );
add_action( 'woocommerce_product_on_backorder_notification', array( $this, 'backorder' ) );
add_action( 'woocommerce_created_customer_notification', array( $this, 'customer_new_account' ), 10, 3 );
// Hook for replacing {site_title} in email-footer.
add_filter( 'woocommerce_email_footer_text' , array( $this, 'email_footer_replace_site_title' ) );
add_filter( 'woocommerce_email_footer_text', array( $this, 'email_footer_replace_site_title' ) );
// Let 3rd parties unhook the above via this hook
// Let 3rd parties unhook the above via this hook.
do_action( 'woocommerce_email', $this );
}
@ -188,26 +199,26 @@ class WC_Emails {
* Init email classes.
*/
public function init() {
// Include email classes
include_once( dirname( __FILE__ ) . '/emails/class-wc-email.php' );
// Include email classes.
include_once dirname( __FILE__ ) . '/emails/class-wc-email.php';
$this->emails['WC_Email_New_Order'] = include( 'emails/class-wc-email-new-order.php' );
$this->emails['WC_Email_Cancelled_Order'] = include( 'emails/class-wc-email-cancelled-order.php' );
$this->emails['WC_Email_Failed_Order'] = include( 'emails/class-wc-email-failed-order.php' );
$this->emails['WC_Email_Customer_On_Hold_Order'] = include( 'emails/class-wc-email-customer-on-hold-order.php' );
$this->emails['WC_Email_Customer_Processing_Order'] = include( 'emails/class-wc-email-customer-processing-order.php' );
$this->emails['WC_Email_Customer_Completed_Order'] = include( 'emails/class-wc-email-customer-completed-order.php' );
$this->emails['WC_Email_Customer_Refunded_Order'] = include( 'emails/class-wc-email-customer-refunded-order.php' );
$this->emails['WC_Email_Customer_Invoice'] = include( 'emails/class-wc-email-customer-invoice.php' );
$this->emails['WC_Email_Customer_Note'] = include( 'emails/class-wc-email-customer-note.php' );
$this->emails['WC_Email_Customer_Reset_Password'] = include( 'emails/class-wc-email-customer-reset-password.php' );
$this->emails['WC_Email_Customer_New_Account'] = include( 'emails/class-wc-email-customer-new-account.php' );
$this->emails['WC_Email_New_Order'] = include 'emails/class-wc-email-new-order.php';
$this->emails['WC_Email_Cancelled_Order'] = include 'emails/class-wc-email-cancelled-order.php';
$this->emails['WC_Email_Failed_Order'] = include 'emails/class-wc-email-failed-order.php';
$this->emails['WC_Email_Customer_On_Hold_Order'] = include 'emails/class-wc-email-customer-on-hold-order.php';
$this->emails['WC_Email_Customer_Processing_Order'] = include 'emails/class-wc-email-customer-processing-order.php';
$this->emails['WC_Email_Customer_Completed_Order'] = include 'emails/class-wc-email-customer-completed-order.php';
$this->emails['WC_Email_Customer_Refunded_Order'] = include 'emails/class-wc-email-customer-refunded-order.php';
$this->emails['WC_Email_Customer_Invoice'] = include 'emails/class-wc-email-customer-invoice.php';
$this->emails['WC_Email_Customer_Note'] = include 'emails/class-wc-email-customer-note.php';
$this->emails['WC_Email_Customer_Reset_Password'] = include 'emails/class-wc-email-customer-reset-password.php';
$this->emails['WC_Email_Customer_New_Account'] = include 'emails/class-wc-email-customer-new-account.php';
$this->emails = apply_filters( 'woocommerce_email_classes', $this->emails );
// include css inliner
// include css inliner.
if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
include_once( dirname( __FILE__ ) . '/libraries/class-emogrifier.php' );
include_once dirname( __FILE__ ) . '/libraries/class-emogrifier.php';
}
}
@ -241,7 +252,7 @@ class WC_Emails {
/**
* Get the email header.
*
* @param mixed $email_heading heading for the email
* @param mixed $email_heading Heading for the email.
*/
public function email_header( $email_heading ) {
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) );
@ -280,7 +291,7 @@ class WC_Emails {
do_action( 'woocommerce_email_header', $email_heading, null );
echo wpautop( wptexturize( $message ) );
echo wpautop( wptexturize( $message ) ); // WPCS: XSS ok.
do_action( 'woocommerce_email_footer', null );
@ -293,15 +304,15 @@ class WC_Emails {
/**
* Send the email.
*
* @param mixed $to
* @param mixed $subject
* @param mixed $message
* @param string $headers (default: "Content-Type: text/html\r\n")
* @param string $attachments (default: "")
* @param mixed $to Receiver.
* @param mixed $subject Email subject.
* @param mixed $message Message.
* @param string $headers Email headers (default: "Content-Type: text/html\r\n").
* @param string $attachments Attachments (default: "").
* @return bool
*/
public function send( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) {
// Send
public function send( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = '' ) {
// Send.
$email = new WC_Email();
return $email->send( $to, $subject, $message, $headers, $attachments );
}
@ -309,7 +320,7 @@ class WC_Emails {
/**
* Prepare and send the customer invoice email on demand.
*
* @param int|WC_Order $order
* @param int|WC_Order $order Order instance or ID.
*/
public function customer_invoice( $order ) {
$email = $this->emails['WC_Email_Customer_Invoice'];
@ -324,9 +335,9 @@ class WC_Emails {
/**
* Customer new account welcome email.
*
* @param int $customer_id
* @param array $new_customer_data
* @param bool $password_generated
* @param int $customer_id Customer ID.
* @param array $new_customer_data New customer data.
* @param bool $password_generated If password is generated.
*/
public function customer_new_account( $customer_id, $new_customer_data = array(), $password_generated = false ) {
if ( ! $customer_id ) {
@ -342,16 +353,30 @@ class WC_Emails {
/**
* Show the order details table
*
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
* @param string $email
* @param WC_Order $order Order instance.
* @param bool $sent_to_admin If should sent to admin.
* @param bool $plain_text If is plain text email.
* @param string $email Email address.
*/
public function order_details( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) {
if ( $plain_text ) {
wc_get_template( 'emails/plain/email-order-details.php', array( 'order' => $order, 'sent_to_admin' => $sent_to_admin, 'plain_text' => $plain_text, 'email' => $email ) );
wc_get_template(
'emails/plain/email-order-details.php', array(
'order' => $order,
'sent_to_admin' => $sent_to_admin,
'plain_text' => $plain_text,
'email' => $email,
)
);
} else {
wc_get_template( 'emails/email-order-details.php', array( 'order' => $order, 'sent_to_admin' => $sent_to_admin, 'plain_text' => $plain_text, 'email' => $email ) );
wc_get_template(
'emails/email-order-details.php', array(
'order' => $order,
'sent_to_admin' => $sent_to_admin,
'plain_text' => $plain_text,
'email' => $email,
)
);
}
}
@ -359,10 +384,10 @@ class WC_Emails {
* Show order downloads in a table.
*
* @since 3.2.0
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
* @param string $email
* @param WC_Order $order Order instance.
* @param bool $sent_to_admin If should sent to admin.
* @param bool $plain_text If is plain text email.
* @param string $email Email address.
*/
public function order_downloads( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) {
$show_downloads = $order->has_downloadable_item() && $order->is_download_permitted() && ! $sent_to_admin;
@ -372,25 +397,45 @@ class WC_Emails {
}
$downloads = $order->get_downloadable_items();
$columns = apply_filters( 'woocommerce_email_downloads_columns', array(
'download-product' => __( 'Product', 'woocommerce' ),
'download-expires' => __( 'Expires', 'woocommerce' ),
'download-file' => __( 'Download', 'woocommerce' ),
) );
$columns = apply_filters(
'woocommerce_email_downloads_columns', array(
'download-product' => __( 'Product', 'woocommerce' ),
'download-expires' => __( 'Expires', 'woocommerce' ),
'download-file' => __( 'Download', 'woocommerce' ),
)
);
if ( $plain_text ) {
wc_get_template( 'emails/plain/email-downloads.php', array( 'order' => $order, 'sent_to_admin' => $sent_to_admin, 'plain_text' => $plain_text, 'email' => $email, 'downloads' => $downloads, 'columns' => $columns ) );
wc_get_template(
'emails/plain/email-downloads.php', array(
'order' => $order,
'sent_to_admin' => $sent_to_admin,
'plain_text' => $plain_text,
'email' => $email,
'downloads' => $downloads,
'columns' => $columns,
)
);
} else {
wc_get_template( 'emails/email-downloads.php', array( 'order' => $order, 'sent_to_admin' => $sent_to_admin, 'plain_text' => $plain_text, 'email' => $email, 'downloads' => $downloads, 'columns' => $columns ) );
wc_get_template(
'emails/email-downloads.php', array(
'order' => $order,
'sent_to_admin' => $sent_to_admin,
'plain_text' => $plain_text,
'email' => $email,
'downloads' => $downloads,
'columns' => $columns,
)
);
}
}
/**
* Add order meta to email templates.
*
* @param mixed $order
* @param bool $sent_to_admin (default: false)
* @param bool $plain_text (default: false)
* @param WC_Order $order Order instance.
* @param bool $sent_to_admin If should sent to admin.
* @param bool $plain_text If is plain text email.
*/
public function order_meta( $order, $sent_to_admin = false, $plain_text = false ) {
$fields = apply_filters( 'woocommerce_email_order_meta_fields', array(), $sent_to_admin, $order );
@ -421,14 +466,14 @@ class WC_Emails {
foreach ( $fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
echo $field['label'] . ': ' . $field['value'] . "\n";
echo $field['label'] . ': ' . $field['value'] . "\n"; // WPCS: XSS ok.
}
}
} else {
foreach ( $fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
echo '<p><strong>' . $field['label'] . ':</strong> ' . $field['value'] . '</p>';
echo '<p><strong>' . $field['label'] . ':</strong> ' . $field['value'] . '</p>'; // WPCS: XSS ok.
}
}
}
@ -437,7 +482,8 @@ class WC_Emails {
/**
* Is customer detail field valid?
* @param array $field
*
* @param array $field Field data to check if is valid.
* @return boolean
*/
public function customer_detail_field_is_valid( $field ) {
@ -449,10 +495,9 @@ class WC_Emails {
*
* In versions prior to 3.2 this was used for notes, phone and email but this data has moved.
*
* @param WC_Order $order
* @param bool $sent_to_admin (default: false)
* @param bool $plain_text (default: false)
* @return string
* @param WC_Order $order Order instance.
* @param bool $sent_to_admin If should sent to admin.
* @param bool $plain_text If is plain text email.
*/
public function customer_details( $order, $sent_to_admin = false, $plain_text = false ) {
if ( ! is_a( $order, 'WC_Order' ) ) {
@ -473,23 +518,34 @@ class WC_Emails {
/**
* Get the email addresses.
*
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
* @param WC_Order $order Order instance.
* @param bool $sent_to_admin If should sent to admin.
* @param bool $plain_text If is plain text email.
*/
public function email_addresses( $order, $sent_to_admin = false, $plain_text = false ) {
if ( ! is_a( $order, 'WC_Order' ) ) {
return;
}
if ( $plain_text ) {
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order, 'sent_to_admin' => $sent_to_admin ) );
wc_get_template(
'emails/plain/email-addresses.php', array(
'order' => $order,
'sent_to_admin' => $sent_to_admin,
)
);
} else {
wc_get_template( 'emails/email-addresses.php', array( 'order' => $order, 'sent_to_admin' => $sent_to_admin ) );
wc_get_template(
'emails/email-addresses.php', array(
'order' => $order,
'sent_to_admin' => $sent_to_admin,
)
);
}
}
/**
* Get blog name formatted for emails.
*
* @return string
*/
private function get_blogname() {
@ -499,7 +555,7 @@ class WC_Emails {
/**
* Low stock notification email.
*
* @param WC_Product $product
* @param WC_Product $product Product instance.
*/
public function low_stock( $product ) {
if ( 'no' === get_option( 'woocommerce_notify_low_stock', 'yes' ) ) {
@ -507,8 +563,8 @@ class WC_Emails {
}
$subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product low in stock', 'woocommerce' ) );
/* translators: 1: product name 2: items in stock */
$message = sprintf(
/* translators: 1: product name 2: items in stock */
__( '%1$s is low in stock. There are %2$d left.', 'woocommerce' ),
html_entity_decode( strip_tags( $product->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ),
html_entity_decode( strip_tags( $product->get_stock_quantity() ) )
@ -526,7 +582,7 @@ class WC_Emails {
/**
* No stock notification email.
*
* @param WC_Product $product
* @param WC_Product $product Product instance.
*/
public function no_stock( $product ) {
if ( 'no' === get_option( 'woocommerce_notify_no_stock', 'yes' ) ) {
@ -549,14 +605,16 @@ class WC_Emails {
/**
* Backorder notification email.
*
* @param array $args
* @param array $args Arguments.
*/
public function backorder( $args ) {
$args = wp_parse_args( $args, array(
'product' => '',
'quantity' => '',
'order_id' => '',
) );
$args = wp_parse_args(
$args, array(
'product' => '',
'quantity' => '',
'order_id' => '',
)
);
$order = wc_get_order( $args['order_id'] );
if (
@ -569,8 +627,9 @@ class WC_Emails {
}
$subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product backorder', 'woocommerce' ) );
/* translators: 1: product quantity 2: product name 3: order number */
$message = sprintf( __( '%1$s units of %2$s have been backordered in order #%3$s.', 'woocommerce' ), $args['quantity'], html_entity_decode( strip_tags( $args['product']->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ), $order->get_order_number() );
wp_mail(
apply_filters( 'woocommerce_email_recipient_backorder', get_option( 'woocommerce_stock_email_recipient' ), $args ),
apply_filters( 'woocommerce_email_subject_backorder', $subject, $args ),
@ -587,9 +646,9 @@ class WC_Emails {
* @see WC_Structured_Data::generate_order_data()
*
* @since 2.6.0
* @param mixed $order
* @param bool $sent_to_admin (default: false)
* @param bool $plain_text (default: false)
* @param WC_Order $order Order instance.
* @param bool $sent_to_admin If should sent to admin.
* @param bool $plain_text If is plain text email.
*/
public function order_schema_markup( $order, $sent_to_admin = false, $plain_text = false ) {
wc_deprecated_function( 'WC_Emails::order_schema_markup', '3.0', 'WC_Structured_Data::generate_order_data' );

View File

@ -1,11 +1,9 @@
<?php
/**
* WooCommerce Product Embed.
* WooCommerce product embed
*
* @version 2.4.11
* @package WooCommerce/Classes/Embed
* @category Class
* @author WooThemes
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -14,10 +12,6 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Embed Class which handles any WooCommerce Products that are embedded on this site or another site.
*
* @class WC_Embed
* @version 2.4.11
* @author WooThemes
*/
class WC_Embed {
@ -80,7 +74,7 @@ class WC_Embed {
// Make sure we're only affecting embedded products.
if ( self::is_embedded_product() ) {
echo '<p><span class="wc-embed-price">' . $_product->get_price_html() . '</span></p>';
echo '<p><span class="wc-embed-price">' . $_product->get_price_html() . '</span></p>'; // WPCS: XSS ok.
if ( ! empty( $post->post_excerpt ) ) {
ob_start();
@ -121,12 +115,18 @@ class WC_Embed {
*/
public static function get_ratings() {
// Make sure we're only affecting embedded products.
if ( self::is_embedded_product() && ( $_product = wc_get_product( get_the_ID() ) ) && $_product->get_average_rating() > 0 ) {
if ( ! self::is_embedded_product() ) {
return;
}
$_product = wc_get_product( get_the_ID() );
if ( $_product && $_product->get_average_rating() > 0 ) {
?>
<div class="wc-embed-rating">
<?php
/* translators: %s: average rating */
printf(
/* translators: %s: average rating */
esc_html__( 'Rated %s out of 5', 'woocommerce' ),
esc_html( $_product->get_average_rating() )
);

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